OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

virtio-dev message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [virtio-dev] virtio-snd spec question


On Sun, Feb 6, 2022 at 9:41 PM Shreyansh Chouhan <chouhan.shreyansh2702@gmail.com> wrote:
Hi,

On Thu, 3 Feb 2022 at 16:06, Stefan Hajnoczi <stefanha@redhat.com> wrote:
>
> On Tue, Feb 01, 2022 at 03:57:10PM -0800, Roman Kiryanov wrote:
> > Hello,
> >
> > I work in Android Studio Emulator and I am currently implementing a
> > virtio-snd device. We found a spec draft here:
> >
> > https://github.com/oasis-tcs/virtio-spec/commit/e73c8cdf3e822fd83c26c6de964a947670f93cc3#diff-73045e70aeaf45f93087610437b705e2d320c82a9d29b4027721f5f5f3918dc5
> >
> > It mentions four virtqueues: ctl, event, rx and tx. It is not very clear
> > where a virtio-snd device should put responses to the ctl requests from the
> > linux kernel driver. There is a kernel driver implementation and we have a
> > virtio-snd device implemented in another emulator, it uses the same
> > virtqueue (ctl) to put ctl responses and the current kernel driver seems
> > happy with this.
> >
> > Do you know if this is expected behavior? I am far from an expert here, but
> > I believe the device and the kernel will race here by reading from the same
> > virtqueue: the device could read VirtQueueElement produced by itself before
> > the kernel if the kernel is not fast enough.

I think that is the intended behavior. Each virtqueue is supposed to have
device and driver writable areas. (Separate used ring and avail ring
in case of split
virtqueues, and in case of packed virtqueues we have something similar
but within a single circular buffer.)

I don't think there will be any races. In case of split virtqueues we
have separate
avail and used rings and device and the driver look for buffers to consume from
these different rings. In case of packed virtqueues we have flags and
a wrap counting
bit and we use these to make sure we don't read anything not intended for us.

You can check these explanations out for more details, these are what I used
when I started the sound card implementation.

Split Virtqueue:
https://www.redhat.com/en/blog/virtqueues-and-virtio-ring-how-data-travels
Packed Virtqueue:
https://www.redhat.com/en/blog/packed-virtqueue-how-reduce-overhead-virtio

Hi,
thank you all for looking into this. This helped me to make some progress. My device is able to play audio, sometimes clean and sometimes I see the guest issues a lot ofÂPCM_PREPARE/PCM_START/PCM_STOP/PCM_RELEASE requests for no reason. Maybe it is not happy with my replies in the tx virtqueue.

Do you happen to have a more recent patch to the spec for virtio-snd? The patch ( https://github.com/oasis-tcs/virtio-spec/commit/e73c8cdf3e822fd83c26c6de964a947670f93cc3 ) says "The driver MUST NOT place device-writable buffers into the tx queue" while it seems expect for the device to write status messages there. Also, it is never mentioned which status messages to write into the tx virtqueue (I guess it is virtio_snd_pcm_status) and theÂvirtio_snd_pcm_status::latency_bytes explanation is not very elaborate. I believe it is the amount of bytes buffered in the device waiting to go toÂAUD_write.

Could you please clarify? Thank you.

Regards,
Roman.


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]