android_kernel_samsung_sm8650/sound/virtio
Matias Ezequiel Vara Larsen 039d2a958c UPSTREAM: ALSA: virtio: use ack callback
This commit uses the ack() callback to determine when a buffer has been
updated, then exposes it to guest.

The current mechanism splits a dma buffer into descriptors that are
exposed to the device. This dma buffer is shared with the user
application. When the device consumes a buffer, the driver moves the
request from the used ring to available ring.

The driver exposes the buffer to the device without knowing if the
content has been updated from the user. The section 2.8.21.1 of the
virtio spec states that: "The device MAY access the descriptor chains
the driver created and the memory they refer to immediately". If the
device picks up buffers from the available ring just after it is
notified, it happens that the content may be old.

When the ack() callback is invoked, the driver exposes only the buffers
that have already been updated, i.e., enqueued in the available ring.
Thus, the device always picks up a buffer that is updated.

For capturing, the driver starts by exposing all the available buffers
to device. After device updates the content of a buffer, it enqueues it
in the used ring. It is only after the ack() for capturing is issued
that the driver re-enqueues the buffer in the available ring.

Co-developed-by: Anton Yakovlev <anton.yakovlev@opensynergy.com>
Signed-off-by: Anton Yakovlev <anton.yakovlev@opensynergy.com>
Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
Link: https://lore.kernel.org/r/ZTjkn1YAFz67yfqx@fedora
Signed-off-by: Takashi Iwai <tiwai@suse.de>

Bug: 331600622
Change-Id: If1269f1777432256eea0e0275b678d0d649753bb
(cherry picked from commit fe981e67568c41de6caae25d70b5f203b94452cc)
Signed-off-by: Brian Daniels <briandaniels@google.com>
2024-05-14 21:47:20 +00:00
..
Kconfig
Makefile UPSTREAM: ALSA: virtio: add support for audio controls 2024-04-04 15:35:58 +00:00
virtio_card.c UPSTREAM: ALSA: virtio: add support for audio controls 2024-04-04 15:35:58 +00:00
virtio_card.h UPSTREAM: ALSA: virtio: add support for audio controls 2024-04-04 15:35:58 +00:00
virtio_chmap.c ALSA: virtio: introduce PCM channel map support 2021-03-07 09:08:20 +01:00
virtio_ctl_msg.c ALSA: virtio: fix kernel-doc 2021-04-27 08:39:39 +02:00
virtio_ctl_msg.h ALSA: virtio: handling control messages 2021-03-07 09:07:27 +01:00
virtio_jack.c ALSA: virtio: introduce jack support 2021-03-07 09:08:11 +01:00
virtio_kctl.c UPSTREAM: ALSA: virtio: Fix "Coverity: virtsnd_kctl_tlv_op(): Uninitialized variables" warning. 2024-04-04 15:35:58 +00:00
virtio_pcm_msg.c UPSTREAM: ALSA: virtio: use ack callback 2024-05-14 21:47:20 +00:00
virtio_pcm_ops.c UPSTREAM: ALSA: virtio: use ack callback 2024-05-14 21:47:20 +00:00
virtio_pcm.c UPSTREAM: ALSA: virtio: use ack callback 2024-05-14 21:47:20 +00:00
virtio_pcm.h UPSTREAM: ALSA: virtio: use ack callback 2024-05-14 21:47:20 +00:00