* virtio-sound: release control request clarification @ 2023-10-17 15:19 Matias Ezequiel Vara Larsen 2023-10-17 15:29 ` Manos Pitsidianakis 2023-10-18 1:06 ` Anton Yakovlev via Virtualization 0 siblings, 2 replies; 5+ messages in thread From: Matias Ezequiel Vara Larsen @ 2023-10-17 15:19 UTC (permalink / raw) To: virtualization; +Cc: mst, stefanha, virtio-comment 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? Regarding 2), I interpret it as "the device shall wait until all I/O messages are proceeded to complete the RELEASE control request". 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. 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? - According to the specification, should the driver wait in RELEASE an amount of time proportional to the number of periods yet to be reproduced? Thanks, Matias. [1] https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html [2] https://github.com/rust-vmm/vhost-device/tree/main/staging/vhost-device-sound _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: virtio-sound: release control request clarification 2023-10-17 15:19 virtio-sound: release control request clarification Matias Ezequiel Vara Larsen @ 2023-10-17 15:29 ` Manos Pitsidianakis 2023-10-18 1:06 ` Anton Yakovlev via Virtualization 1 sibling, 0 replies; 5+ messages in thread From: Manos Pitsidianakis @ 2023-10-17 15:29 UTC (permalink / raw) To: Matias Ezequiel Vara Larsen; +Cc: mst, virtualization, stefanha, virtio-comment On Tue, 17 Oct 2023 at 18:19, Matias Ezequiel Vara Larsen <mvaralar@redhat.com> 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? It means the latter. At no point is the host's consumption of audio data mentioned except for implicit or explicit period notifications. > > Regarding 2), I interpret it as "the device shall wait until all I/O > messages are proceeded to complete the RELEASE control request". Possible state transitions to RELEASE state are from PREPARE and STOP, which neither are associated with active I/O in the streams. The correct interpretation is "Do not reply to the control request if you have pending I/O messages for this stream ID". > 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. > > 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 guess is this is because of the guest alsa doing prebuffering, not that the host is supposed to handle those I/O messages. -- Manos _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: virtio-sound: release control request clarification 2023-10-17 15:19 virtio-sound: release control request clarification Matias Ezequiel Vara Larsen 2023-10-17 15:29 ` Manos Pitsidianakis @ 2023-10-18 1:06 ` Anton Yakovlev via Virtualization 2023-10-18 13:30 ` [virtio-comment] " Matias Ezequiel Vara Larsen 1 sibling, 1 reply; 5+ messages in thread From: Anton Yakovlev via Virtualization @ 2023-10-18 1:06 UTC (permalink / raw) To: Matias Ezequiel Vara Larsen, virtualization; +Cc: mst, stefanha, virtio-comment 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@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [virtio-comment] Re: virtio-sound: release control request clarification 2023-10-18 1:06 ` Anton Yakovlev via Virtualization @ 2023-10-18 13:30 ` Matias Ezequiel Vara Larsen 2023-10-19 1:39 ` Anton Yakovlev via Virtualization 0 siblings, 1 reply; 5+ messages in thread From: Matias Ezequiel Vara Larsen @ 2023-10-18 13:30 UTC (permalink / raw) To: Anton Yakovlev; +Cc: mst, virtualization, stefanha, virtio-comment Hello Anton, thanks for the response. I added some inline comments. On Wed, Oct 18, 2023 at 10:06:05AM +0900, Anton Yakovlev wrote: > 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... > > Thank you, I got it. If I correctly understand you, after RELEASE is issued, the specs specify only that the device should "return" all buffers or "complete" them. Device implementations MAY or MAY NOT playback them. In other words, the specification does not specify if consumption should occur. I had interpreted this to mean that the guest intended to output those buffers, leaving the device implementation with no option but to do so. > > 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. > Thanks for clarifying. Sorry to repeat myself, the point I want to make is that the virtsnd_pcm_sync_stop() function that sends the RELEASE control request uses virtsnd_ctl_msg_send_sync(). Message timeouts are set up by the "msg_timeout_ms" module parameter. The timeout is the same as for other control requests, such as SET_PARAM and PREPARE, but these commands do not require flushing a queue, so I wondered how the timeout could be the same. > > > 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. > > I agree, thanks. Matias. > 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 > > This publicly archived list offers a means to provide input to the > OASIS Virtual I/O Device (VIRTIO) TC. > > In order to verify user consent to the Feedback License terms and > to minimize spam in the list archive, subscription is required > before posting. > > Subscribe: virtio-comment-subscribe@lists.oasis-open.org > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org > List help: virtio-comment-help@lists.oasis-open.org > List archive: https://lists.oasis-open.org/archives/virtio-comment/ > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists > Committee: https://www.oasis-open.org/committees/virtio/ > Join OASIS: https://www.oasis-open.org/join/ > _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [virtio-comment] Re: virtio-sound: release control request clarification 2023-10-18 13:30 ` [virtio-comment] " Matias Ezequiel Vara Larsen @ 2023-10-19 1:39 ` Anton Yakovlev via Virtualization 0 siblings, 0 replies; 5+ messages in thread From: Anton Yakovlev via Virtualization @ 2023-10-19 1:39 UTC (permalink / raw) To: Matias Ezequiel Vara Larsen; +Cc: mst, virtualization, stefanha, virtio-comment Hi Matias, On 18.10.2023 22:30, Matias Ezequiel Vara Larsen wrote: > Hello Anton, > > thanks for the response. I added some inline comments. > > On Wed, Oct 18, 2023 at 10:06:05AM +0900, Anton Yakovlev wrote: >> 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... >> >> > > Thank you, I got it. If I correctly understand you, after RELEASE is > issued, the specs specify only that the device should "return" all > buffers or "complete" them. Device implementations MAY or MAY NOT > playback them. In other words, the specification does not specify if > consumption should occur. I had interpreted this to mean that the guest > intended to output those buffers, leaving the device implementation with > no option but to do so. > >>> 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. >> > > Thanks for clarifying. Sorry to repeat myself, the point I want to make > is that the virtsnd_pcm_sync_stop() function that sends the RELEASE > control request uses virtsnd_ctl_msg_send_sync(). Message timeouts are > set up by the "msg_timeout_ms" module parameter. The timeout is the same > as for other control requests, such as SET_PARAM and PREPARE, but these > commands do not require flushing a queue, so I wondered how the timeout > could be the same. In general, I don't think it's possible to scale/adjust the timeout value for any of the control requests at runtime. You pointed only at the RELEASE request, but depending on the device implementation, other requests may also take an unpredictable amount of time. For example, if the device communicates with an audio server over the network. Therefore, in order not to overcomplicate things, a single more or less reasonable default value was chosen. Which is also suitable for RELEASE (see my thoughts above). Best regards, >> >>> 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. >> >> > > I agree, thanks. > > Matias. > >> 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=d5297ffc-9da6-41eb-a09f-b57cd7282232&auth=53c7c7de28b92dfd96e93d9dd61a23e634d2fbec-411b9d1d7b38e7727e6478284b6313d5ad82f5a5 >>> [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 >> >> This publicly archived list offers a means to provide input to the >> OASIS Virtual I/O Device (VIRTIO) TC. >> >> In order to verify user consent to the Feedback License terms and >> to minimize spam in the list archive, subscription is required >> before posting. >> >> Subscribe: virtio-comment-subscribe@lists.oasis-open.org >> Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org >> List help: virtio-comment-help@lists.oasis-open.org >> List archive: https://ddec1-0-en-ctp.trendmicro.com:443/wis/clicktime/v1/query?url=https%3a%2f%2flists.oasis%2dopen.org%2farchives%2fvirtio%2dcomment%2f&umid=d5297ffc-9da6-41eb-a09f-b57cd7282232&auth=53c7c7de28b92dfd96e93d9dd61a23e634d2fbec-a481d373f80a6c1b5882e1f0170a0687329391b1 >> Feedback License: https://ddec1-0-en-ctp.trendmicro.com:443/wis/clicktime/v1/query?url=https%3a%2f%2fwww.oasis%2dopen.org%2fwho%2fipr%2ffeedback%5flicense.pdf&umid=d5297ffc-9da6-41eb-a09f-b57cd7282232&auth=53c7c7de28b92dfd96e93d9dd61a23e634d2fbec-9797dad096ce101e2ddeccc4601649f954e89c09 >> List Guidelines: https://ddec1-0-en-ctp.trendmicro.com:443/wis/clicktime/v1/query?url=https%3a%2f%2fwww.oasis%2dopen.org%2fpolicies%2dguidelines%2fmailing%2dlists&umid=d5297ffc-9da6-41eb-a09f-b57cd7282232&auth=53c7c7de28b92dfd96e93d9dd61a23e634d2fbec-e529fd6878ce2da5bc6d951687d9f90e34808b1b >> Committee: https://ddec1-0-en-ctp.trendmicro.com:443/wis/clicktime/v1/query?url=https%3a%2f%2fwww.oasis%2dopen.org%2fcommittees%2fvirtio%2f&umid=d5297ffc-9da6-41eb-a09f-b57cd7282232&auth=53c7c7de28b92dfd96e93d9dd61a23e634d2fbec-afc2604472b6094aee00bdd9a5aa0a65d12f7e19 >> Join OASIS: https://ddec1-0-en-ctp.trendmicro.com:443/wis/clicktime/v1/query?url=https%3a%2f%2fwww.oasis%2dopen.org%2fjoin%2f&umid=d5297ffc-9da6-41eb-a09f-b57cd7282232&auth=53c7c7de28b92dfd96e93d9dd61a23e634d2fbec-cae044bc06deaf94443835e5f72f10909d5abeec >> -- Anton Yakovlev Senior Software Engineer OpenSynergy GmbH Rotherstr. 20, 10245 Berlin _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-10-19 1:39 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-10-17 15:19 virtio-sound: release control request clarification Matias Ezequiel Vara Larsen 2023-10-17 15:29 ` Manos Pitsidianakis 2023-10-18 1:06 ` Anton Yakovlev via Virtualization 2023-10-18 13:30 ` [virtio-comment] " Matias Ezequiel Vara Larsen 2023-10-19 1:39 ` Anton Yakovlev via Virtualization
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox