Matias Ezequiel Vara Larsen
2023-Sep-19 14:18 UTC
virtio-sound linux driver conformance to spec
On Tue, Sep 19, 2023 at 05:43:56AM -0400, Michael S. Tsirkin wrote:> On Wed, Sep 13, 2023 at 05:04:24PM +0200, Matias Ezequiel Vara Larsen wrote: > > Hello, > > > > This email is to report a behavior of the Linux virtio-sound driver that > > looks like it is not conforming to the VirtIO specification. The kernel > > driver is moving buffers from the used ring to the available ring > > without knowing if the content has been updated from the user. If the > > device picks up buffers from the available ring just after it is > > notified, it happens that the content is old. > > Then, what happens, exactly? Do things still work?We are currently developing a vhost-user backend for virtio-sound and what happens is that if the backend implementation decides to copy the content of a buffer from a request that just arrived to the available ring, it gets the old content thus reproducing some sections two times. For example, we observe that when issuing `aplay FrontLeft.wav`, we hear `Front, front left...`. To fix this issue, our current implementation delays reading from guest memory just until the audio engine requires. However, the first implementation shall also work since it is conforming to the specification. Matias
On Tue, Sep 19, 2023 at 04:18:57PM +0200, Matias Ezequiel Vara Larsen wrote:> On Tue, Sep 19, 2023 at 05:43:56AM -0400, Michael S. Tsirkin wrote: > > On Wed, Sep 13, 2023 at 05:04:24PM +0200, Matias Ezequiel Vara Larsen wrote: > > > Hello, > > > > > > This email is to report a behavior of the Linux virtio-sound driver that > > > looks like it is not conforming to the VirtIO specification. The kernel > > > driver is moving buffers from the used ring to the available ring > > > without knowing if the content has been updated from the user. If the > > > device picks up buffers from the available ring just after it is > > > notified, it happens that the content is old. > > > > Then, what happens, exactly? Do things still work? > > We are currently developing a vhost-user backend for virtio-sound and > what happens is that if the backend implementation decides to copy the > content of a buffer from a request that just arrived to the available > ring, it gets the old content thus reproducing some sections two times. > For example, we observe that when issuing `aplay FrontLeft.wav`, we hear > `Front, front left...`. To fix this issue, our current implementation > delays reading from guest memory just until the audio engine requires. > However, the first implementation shall also work since it is conforming > to the specification. > > MatiasSounds like it. How hard is it to change the behaviour though? Does it involve changing userspace? Maybe we need to fix the spec after all... -- MST