Re: virtio-sound: release control request clarification

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Matias,


On 18.10.2023 00:19, Matias Ezequiel Vara Larsen wrote:
Hello,

This email is to clarify the VirtIO specification regarding the RELEASE
control request. Section 5.14.6.6.5.1 [1] states the following device
requirements for the RELEASE control request:
1. The device MUST complete all pending I/O messages for the specified
stream ID.
2. The device MUST NOT complete the control request while there are
pending I/O messages for the specified stream ID.

The 1) requirement does not indicate what "complete" means. Does it mean
that the pending I/O messages in the tx queue shall be outputted in the
host, i.e., consumed by the audio backend? Or, completion means simply
to put the requests in the used-ring without consuming them?

Here "to complete" means moving the buffers to the used list in vring.
Technically, the specification only requires that the device "return" all
referenced DMA memory to the guest before completing the RELEASE control
request. What the device actually does with these I/O messages is
implementation dependent and is not within the scope of the specification.
Thus...


Regarding 2), I interpret it as "the device shall wait until all I/O
messages are proceeded to complete the RELEASE control request".

...you can do this way if you really need to.


Currently, the kernel driver seems not expecting such a delay when the
RELEASE command is sent. If I understand correctly, the kernel driver
first sends the RELEASE command and waits a fixed amount of time until
the device can process it. Then, the driver waits a fixed amount of time
until all pending IO messages are completed. If the device follows the
specification and waits until all messages IO are completed to issue the
completion of the RELEASE command, the kernel driver may timeout. The
time to complete N IO messages in the TX queue could be proportional
with the number of pending messages.

The default timeout for control requests in the ALSA driver is 1 second. In
theory, this time should be enough to completely reproduce/fill the 500ms
buffer, and complete all requests, including the RELEASE control request. If
the device fails to do this, then most likely there are some problems with the
implementation.


In our device implementation [2], RELEASE is handled as follows:
- Drop all messages in the TX queue without outputting in the host.
- Complete the RELEASE control request.

This seems to be working, however, I can observe that sometimes there
are still requests in the TX queue when we get RELEASE. Those requests
are never reproduced in the host.

My questions are:
- In the specification, should we modify it to clarify that all pending
   IO messages in the device are discarded during RELEASE, that is, not
   output to the host, but signaled to the guest as completed?

No, we shouldn't. See comment above.


- According to the specification, should the driver wait in RELEASE an
   amount of time proportional to the number of periods yet to be
   reproduced?

This is purely a matter of driver implementation. It is possible to implement
the driver without timeouts, but this would be a bad idea. Because bugs in the
device could lead to an infinite wait in the kernel.


Best regards,


Thanks, Matias.

[1]
https://ddec1-0-en-ctp.trendmicro.com:443/wis/clicktime/v1/query?url=https%3a%2f%2fdocs.oasis%2dopen.org%2fvirtio%2fvirtio%2fv1.2%2fcsd01%2fvirtio%2dv1.2%2dcsd01.html&umid=31e1136e-6322-4698-9f1d-d631ac36403e&auth=53c7c7de28b92dfd96e93d9dd61a23e634d2fbec-586f0596c89224a3bc9e20df81eaea8933bb129a
[2]
https://github.com/rust-vmm/vhost-device/tree/main/staging/vhost-device-sound

--
Anton Yakovlev
Senior Software Engineer

OpenSynergy GmbH
Rotherstr. 20, 10245 Berlin
_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization



[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux