virtio-snd: add virtio sound device specification
PATCH v6 1/1 virtio-snd: add virtio sound device specification
This patch proposes virtio specification for a new virtio sound device, that may be useful in case when having audio is required but a device passthrough or emulation is not an option.
---
v5->v6 changes:
1. Add the direction of the jack to the configuration of the jack.
2. Split the features field in a stream configuration into two: the features (these can be negotiated with the device) and the flags (additional capabilities of the device).
3. Fix the features field size in a setting stream parameters control request (u8->le32).
4. Introduce the polling mode feature for a message-based transport.
5. Clarify the length value of a used descriptor for an input stream.
6. Add two device requirements for the stream release control request (regarding completing all pending I/O requests).
7. Spec v4 introduced bidirectional streams. But this has increased the overall complexity of managing streams on both sides. Since this is a rather rare case, we decided to abandon it at the moment. If necessary, bidirectional streams can be added as an additional feature in the future.
conformance.tex | 32 ++- content.tex | 1 + introduction.tex | 3 + virtio-sound.tex | 728 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 761 insertions(+), 3 deletions(-) create mode 100644 virtio-sound.tex
conformance.tex +29 -3
@@ -15,7 +15,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \begin{itemize} \item Clause \ref{sec:Conformance / Driver Conformance}. \item One of clauses \ref{sec:Conformance / Driver Conformance / PCI Driver Conformance}, \ref{sec:Conformance / Driver Conformance / MMIO Driver Conformance} or \ref{sec:Conformance / Driver Conformance / Channel I/O Driver Conformance}. - \item One of clauses \ref{sec:Conformance / Driver Conformance / Network Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Block Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Console Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Entropy Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Traditional Memory Balloon Driver Conformance}, \ref{sec:Conformance / Driver Conformance / SCSI Host Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Input Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Crypto Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Socket Driver Conformance} or \ref{sec:Conformance / Driver Conformance / IOMMU Driver Conformance}. + \item One of clauses \ref{sec:Conformance / Driver Conformance / Network Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Block Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Console Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Entropy Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Traditional Memory Balloon Driver Conformance}, \ref{sec:Conformance / Driver Conformance / SCSI Host Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Input Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Crypto Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Socket Driver Conformance}, \ref{sec:Conformance / Driver Conformance / IOMMU Driver Conformance} or \ref{sec:Conformance / Driver Conformance / Sound Driver Conformance}. \item Clause \ref{sec:Conformance / Legacy Interface: Transitional Device and Transitional Driver Conformance}. \end{itemize} \item[Device] A device MUST conform to four conformance clauses:
@@ -32,8 +32,9 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \ref{sec:Conformance / Device Conformance / Input Device Conformance}, \ref{sec:Conformance / Device Conformance / Crypto Device Conformance}, \ref{sec:Conformance / Device Conformance / Socket Device Conformance}, -\ref{sec:Conformance / Device Conformance / RPMB Device Conformance} or -\ref{sec:Conformance / Device Conformance / IOMMU Device Conformance}. +\ref{sec:Conformance / Device Conformance / RPMB Device Conformance}, +\ref{sec:Conformance / Device Conformance / IOMMU Device Conformance} or +\ref{sec:Conformance / Device Conformance / Sound Device Conformance}. \item Clause \ref{sec:Conformance / Legacy Interface: Transitional Device and Transitional Driver Conformance}. \end{itemize} \end{description}
@@ -220,6 +221,17 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \item \ref{drivernormative:Device Types / IOMMU Device / Device operations / Fault reporting} \end{itemize} +\conformance{\subsection}{Sound Driver Conformance}\label{sec:Conformance / Driver Conformance / Sound Driver Conformance} + +A sound driver MUST conform to the following normative statements: + +\begin{itemize} +\item \ref{drivernormative:Device Types / Sound Device / Device Initialization} +\item \ref{drivernormative:Device Types / Sound Device / Device Operation / PCM Stream Parameters} +\item \ref{drivernormative:Device Types / Sound Device / Device Operation / PCM Output Stream} +\item \ref{drivernormative:Device Types / Sound Device / Device Operation / PCM Input Stream} +\end{itemize} + \conformance{\section}{Device Conformance}\label{sec:Conformance / Device Conformance} A device MUST conform to the following normative statements:
@@ -408,6 +420,20 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets} \item \ref{devicenormative:Device Types / IOMMU Device / Device operations / Fault reporting} \end{itemize} +\conformance{\subsection}{Sound Device Conformance}\label{sec:Conformance / Device Conformance / Sound Device Conformance} + +A sound device MUST conform to the following normative statements: + +\begin{itemize} +\item \ref{devicenormative:Device Types / Sound Device / Device Initialization} +\item \ref{devicenormative:Device Types / Sound Device / Device Operation / Jack Configuration} +\item \ref{devicenormative:Device Types / Sound Device / Device Operation / PCM Stream Configuration} +\item \ref{devicenormative:Device Types / Sound Device / Device Operation / PCM Stream Parameters} +\item \ref{devicenormative:Device Types / Sound Device / Device Operation / PCM Stream Release} +\item \ref{devicenormative:Device Types / Sound Device / Device Operation / PCM Output Stream} +\item \ref{devicenormative:Device Types / Sound Device / Device Operation / PCM Input Stream} +\end{itemize} + \conformance{\section}{Legacy Interface: Transitional Device and Transitional Driver Conformance}\label{sec:Conformance / Legacy Interface: Transitional Device and Transitional Driver Conformance} A conformant implementation MUST be either transitional or non-transitional, see \ref{intro:Legacy
content.tex +1 -0
@@ -6062,6 +6062,7 @@ \subsubsection{Legacy Interface: Framing Requirements}\label{sec:Device \input{virtio-fs.tex} \input{virtio-rpmb.tex} \input{virtio-iommu.tex} +\input{virtio-sound.tex} \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
introduction.tex +3 -0
@@ -66,6 +66,9 @@ \section{Normative References}\label{sec:Normative References} \phantomsection\label{intro:eMMC}\textbf{[eMMC]} & eMMC Electrical Standard (5.1), JESD84-B51, \newline\url{http://www.jedec.org/sites/default/files/docs/JESD84-B51.pdf}\\ + \phantomsection\label{intro:HDA}\textbf{[HDA]} & + High Definition Audio Specification, + \newline\url{https://www.intel.com/content/dam/www/public/us/en/documents/product-specifications/high-definition-audio-specification.pdf}\\ \end{longtable}
virtio-sound.tex new file +728 -0
728 lines not on this page · raw message
Signature · 6 lines
2.25.1 --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Hi,
Quoted 1 line
4. Introduce the polling mode feature for a message-based transport.
BTW: is that driver -> device or device -> driver or both? In case both: should we have two separate feature flags maybe?
Otherwise this looks good to me.
cheers,
Gerd
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Hi,
Quoted 6 lines · Gerd Hoffmann
Hi,Quoted 1 line
4. Introduce the polling mode feature for a message-based transport.
BTW: is that driver -> device or device -> driver or both? In case both: should we have two separate feature flags maybe?
It's driver -> device direction. The driver needs notifications from the device in any case, so it makes no sense to suppress notifications in this direction (device -> driver).
Quoted 12 lines
Otherwise this looks good to me.
cheers,
Gerd---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Signature · 10 lines
Anton Yakovlev Senior Software Engineer OpenSynergy GmbH Rotherstr. 20, 10245 Berlin --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 5 lines · Anton Yakovlev
Hi,
Quoted 2 lines · Gerd Hoffmann
Hi,
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
4. Introduce the polling mode feature for a message-based transport.
BTW: is that driver -> device or device -> driver or both? In case both: should we have two separate feature flags maybe?
It's driver -> device direction. The driver needs notifications from the device in any case, so it makes no sense to suppress notifications in this direction (device -> driver).
Hmm, unless I missed something it doesn't matter whenever the guest kernel checks virtqueues from irq handler or timer ...
cheers,
Gerd
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 11 lines · Gerd Hoffmann
Quoted 10 lines · Anton Yakovlev
Hi,
Quoted 6 lines · Gerd Hoffmann
Hi,Quoted 1 line
4. Introduce the polling mode feature for a message-based transport.
BTW: is that driver -> device or device -> driver or both? In case both: should we have two separate feature flags maybe?
Quoted 6 lines
Quoted 3 lines
It's driver -> device direction. The driver needs notifications from the device in any case, so it makes no sense to suppress notifications in this direction (device -> driver).
Hmm, unless I missed something it doesn't matter whenever the guest kernel checks virtqueues from irq handler or timer ...
Because in the general case, it is impossible to predict when a notification will come from the device. Even if we are talking about a period time, this does not mean that the device will send notifications precisely at these intervals. And this means that the driver must do a tricky poll, trying to guess when the notification will arrive, i.e. just waste CPU resources.
Quoted 5 lines
cheers,
Gerd
Signature · 10 lines
Anton Yakovlev Senior Software Engineer OpenSynergy GmbH Rotherstr. 20, 10245 Berlin --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 16 lines · Anton Yakovlev
Quoted 15 lines · Gerd Hoffmann
Quoted 13 lines · Anton Yakovlev
Hi,
Quoted 6 lines · Gerd Hoffmann
Hi,Quoted 1 line
4. Introduce the polling mode feature for a message-based transport.
BTW: is that driver -> device or device -> driver or both? In case both: should we have two separate feature flags maybe?
It's driver -> device direction. The driver needs notifications from the device in any case, so it makes no sense to suppress notifications in this direction (device -> driver).
Quoted 8 lines
Quoted 2 lines
Hmm, unless I missed something it doesn't matter whenever the guest kernel checks virtqueues from irq handler or timer ...
Because in the general case, it is impossible to predict when a notification will come from the device. Even if we are talking about a period time, this does not mean that the device will send notifications precisely at these intervals. And this means that the driver must do a tricky poll, trying to guess when the notification will arrive, i.e. just waste CPU resources.
Well, the simplest way to handle this would be that each time the driver submits a buffer to the device it also checks whenever the device has completed buffers. No irq, no timer -> no extra wakeups to collect completed buffers.
Drawback is that completed buffers might be unnoticed for a while then due to jitter, the driver might see sometimes no buffers and sometimes multiple buffers. For latency-sensitive workloads this will probably not work very well.
So, not sure whenever it makes sense to have that as an option or whenever guest drivers would just use notifications unconditionally anyway.
But in any case we should clarify in the spec that this means the driver doesn't notify and the device polls.
cheers,
Gerd
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Quoted 31 lines · Gerd Hoffmann
Quoted 16 lines · Anton Yakovlev
Quoted 15 lines · Gerd Hoffmann
Quoted 13 lines · Anton Yakovlev
Hi,
Quoted 6 lines · Gerd Hoffmann
Hi,Quoted 1 line
4. Introduce the polling mode feature for a message-based transport.
BTW: is that driver -> device or device -> driver or both? In case both: should we have two separate feature flags maybe?
It's driver -> device direction. The driver needs notifications from the device in any case, so it makes no sense to suppress notifications in this direction (device -> driver).
Quoted 8 lines
Quoted 2 lines
Hmm, unless I missed something it doesn't matter whenever the guest kernel checks virtqueues from irq handler or timer ...
Because in the general case, it is impossible to predict when a notification will come from the device. Even if we are talking about a period time, this does not mean that the device will send notifications precisely at these intervals. And this means that the driver must do a tricky poll, trying to guess when the notification will arrive, i.e. just waste CPU resources.
Well, the simplest way to handle this would be that each time the driver submits a buffer to the device it also checks whenever the device has completed buffers. No irq, no timer -> no extra wakeups to collect completed buffers.
Quoted 8 lines
Drawback is that completed buffers might be unnoticed for a while then due to jitter, the driver might see sometimes no buffers and sometimes multiple buffers. For latency-sensitive workloads this will probably not work very well.
So, not sure whenever it makes sense to have that as an option or whenever guest drivers would just use notifications unconditionally anyway.
Well, right from the beginning the driver enqueues buffers at stream start. At this moment there are no completed buffers in the queue (the first one should arrive after one period). So, no completed buffers and no notifications from the device. The only option is to set a hrtimer. We tried such approach and it's just bad for an audio in a vm. Because it's impossible to predict when timer will fire. We tried to set a 10ms hrtimer and it could wake up after 10ms or after 80ms in the worst case. And what's the point then? Interrupts for message-based transport enforced not only for making a driver design much simpler, but also to guarantee that the driver will receive completed buffer exactly at right time.
Quoted 3 lines
But in any case we should clarify in the spec that this means the driver doesn't notify and the device polls.
I think it's not necessary. Now the spec states
---
\item VIRTIO_SND_PCM_F_MSG_POLLING - suppress available buffer notifications for tx and rx queues,
---
So, it's about available buffers, not used ones. It should be pretty obvious, that is this case the device must poll virtqueue for new messages.
Quoted 5 lines
cheers,
Gerd
Signature · 17 lines
Anton Yakovlev Senior Software Engineer OpenSynergy GmbH Rotherstr. 20, 10245 Berlin Phone: +49 30 60 98 54 0 E-Mail: [email protected] www.opensynergy.com Handelsregister/Commercial Registry: Amtsgericht Charlottenburg, HRB 108616B Geschäftsführer/Managing Director: Regis Adjamah --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]