Discussion of the implementations of VIRTIO specification
 help / color / mirror / Atom feed
From: Anton Yakovlev <anton.yakovlev@opensynergy.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: Liam Girdwood <liam.r.girdwood@linux.intel.com>,
	Jean-Philippe Brucker <jean-philippe@linaro.org>,
	Mikhail Golubev <Mikhail.Golubev@opensynergy.com>,
	"virtio-dev@lists.oasis-open.org"
	<virtio-dev@lists.oasis-open.org>, Takashi Iwai <tiwai@suse.de>,
	Mark Brown <broonie@kernel.org>
Subject: Re: [virtio-dev] [PATCH] snd: Add virtio sound device specification
Date: Mon, 2 Dec 2019 14:06:53 +0100	[thread overview]
Message-ID: <b96600a6-1161-dbaf-c74c-c1bf8331de00@opensynergy.com> (raw)
In-Reply-To: <20191125093110.vixnxeasmpdfbcxs@sirius.home.kraxel.org>

Hi,

Sorry for the late reply, I was not available for a week.


On 25.11.2019 10:31, Gerd Hoffmann wrote:
>    Hi,
> 
>>> Instead of PCM_OUTPUT and PCM_INPUT I would put the number of input and
>>> output streams into the device config space (and explicitly allow count
>>> being zero).
>>
>> There are several options for the number of streams:
>>
>> 1. The device can provide one input and/or output stream.
>> 2. The device can provide several input and/or output streams, and all of them
>> share the same capabilities.
>> 3. The device can provide several input and/or output streams, and they can
>> have different set of capabilities.
>>
>> Overall design depends on chosen option. Current draft is based on p.1. But we
>> have never discussed what is the best solution here.
> 
> (3) looks most useful to me.

Then we need to refactor device configuration. I would propose to put into
configuration space only a total number of all available PCM streams and
introduce special control request to query per-stream configuration. A
response should contain a stream type (input/output) and all its capabilities.


>>> PCM_MSG -- I would drop the feature bit and make that mandatory, so we
>>> have a common baseline on which all drivers and devices can agree on.
>>
>> Then we need to inform device what "transport" will be in use (I assumed it
>> would be feature negotiation).
> 
> Whenever other transports (i.e. via shared memory) are supported: yes,
> that should be a feature bit.
> 
> Not sure about choosing the transport.  If both msg (i.e. via virtqueue)
> and shared memory are available, does it make sense to allow the driver
> choose the transport each time it starts a stream?

Shared memory based transport in any case will require some additional
actions. For HOST_MEM case the driver will need to get an access to host
buffer somehow. In GUEST_MEM case the driver will need to provide a buffer for
the host.

At first sight, we could extend the set_params request with the transport_type 
field and some additional information. For example, in case of GUEST_MEM the 
request could be followed by a buffer sg-list. This way it will work like you 
said: the driver chooses the transport each time it starts a stream.


>>> Right now this is defined for the pci transport only.
>>
>> And now we only declare a feature bit, right?
> 
> Not fully sure what you mean here.
> 
> Having the first revision define only the virtqueue transport, reserve a
> feature bit for the shared memory transport and hash out the details of
> that later is possible.

Yes, that's what I wanted to clarify.


>>>> Configuration space
>>>> -------------------
>>>>
>>>> We talked about PCM formats defined in ALSA. In Linux kernel v5.4-rc8 we have
>>>>
>>>> Do we really need all of them? And I skipped endianess, but should we care
>>>> about it as well?
>>>
>>> I'd keep the list as short as possible.  The formats listed in the patch
>>> looked like a good start.
>>
>> It was proposed to have all non-compressed formats.
>>
>> And... do we care about cross-endian cases?
> 
> I'd start with little endian formats only.  virtio byte order is little
> endian, and the world is moving to little endian anyway.  We can add big
> endian formats later should this turn out to be needed, but I don't
> expect that to be the case.

Great!


> 
>>> I'd suggest bytes (and rename the field to period_bytes).
> 
>>>> struct virtio_snd_pcm_status {
>>>>       le32 status;
>>>>       le32 actual_length;
>>>> };
>>>
>>> Hmm.  Why actual_length?  Do we want allow short transfers?  Why?
>>> Wouldn't it be more useful to just fill the buffer completely?
>>
>> In current design we have no buffer size requirements. It means, that in
>> theory the device and the driver could have buffers with different sizes.
> 
> Should we define that the (virtio) buffer size must be period_bytes then?

It will have no sense, since the driver chooses period_bytes at runtime. If we
gonna introduce any buffer constrains, it must be set by the device in a
stream configuration.


>> Also, the capture stream is a special case. Now we don't state explicitly
>> whether read request is blockable or not.
> 
> The concept of "blockable" doesn't exist at that level.  The driver
> submits buffers to the device, the device fills them and notifies the
> driver when the buffer is full.  It simply doesn't work like a read(2)
> syscall.

But you described exactly "blockable" case: an I/O request is completed not
immediately but upon some condition (the buffer is full). In case of message-
based transport, both the device and the driver will have its own buffers. And
for capturing these buffers might be filled at different speed. For example,
in order to improve latency, the device could complete requests immediately
and fill in buffers with whatever it has at the moment.


> Buffers not being filled completely could possibly happen when stopping
> a stream with a half-filled buffer, if we want allow that in the spec.
> 
> Another possible case would be compressed streams with variable bitrate,
> where the number of bytes needed for a millisecond of sound data isn't
> fixed.

Compressed streams are not part of PCM framework anyway.


> cheers,
>    Gerd
> 
> 

-- 
Anton Yakovlev
Senior Software Engineer

OpenSynergy GmbH
Rotherstr. 20, 10245 Berlin

Phone: +49 30 60 98 54 0
E-Mail: anton.yakovlev@opensynergy.com

www.opensynergy.com

Handelsregister/Commercial Registry: Amtsgericht Charlottenburg, HRB 108616B
Geschäftsführer/Managing Director: Regis Adjamah

---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


  reply	other threads:[~2019-12-02 13:07 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-24 14:43 [virtio-dev] [PATCH] snd: Add virtio sound device specification Mikhail Golubev
2019-10-28 16:05 ` Liam Girdwood
2019-10-29  9:42   ` Anton Yakovlev
2019-10-29 10:14     ` Anton Yakovlev
     [not found]       ` <20191029121810.GB5253@sirena.co.uk>
2019-10-29 13:16         ` Anton Yakovlev
     [not found]           ` <20191030121137.GC6693@sirena.co.uk>
2019-11-01 13:37             ` Anton Yakovlev
     [not found]               ` <20191111193903.GE4264@sirena.co.uk>
2019-11-13 12:01                 ` Anton Yakovlev
     [not found]                   ` <20191114212940.GC4664@sirena.co.uk>
2019-11-19  9:26                     ` Anton Yakovlev
2019-11-11 15:20     ` Liam Girdwood
2019-11-12 11:09       ` Jean-Philippe Brucker
2019-11-12 14:20         ` Liam Girdwood
2019-11-12 16:05           ` Jean-Philippe Brucker
2019-11-12 18:02             ` Liam Girdwood
2019-11-12 18:47               ` Matti Moell
2019-11-19 15:23                 ` Liam Girdwood
2019-11-13  9:44               ` Anton Yakovlev
2019-11-19 16:09                 ` Liam Girdwood
2019-11-20 14:24                   ` Anton Yakovlev
2019-11-21  9:04                     ` Gerd Hoffmann
2019-11-21 12:57                       ` Anton Yakovlev
2019-11-22  7:19                         ` Gerd Hoffmann
2019-11-22 13:46                           ` Anton Yakovlev
2019-11-25  9:31                             ` Gerd Hoffmann
2019-12-02 13:06                               ` Anton Yakovlev [this message]
2019-12-03  9:00                                 ` Gerd Hoffmann
2019-12-04 11:15                                   ` Anton Yakovlev
2019-12-04 12:52                                     ` Gerd Hoffmann
2019-12-05 12:06                                       ` Anton Yakovlev
2019-12-06  8:31                                         ` Gerd Hoffmann
     [not found]                         ` <20191122123521.GB6849@sirena.org.uk>
2019-11-22 14:06                           ` Anton Yakovlev
     [not found]                             ` <D68AC0D0-851B-4F87-BE0E-F49527B83E24@redhat.com>
2019-11-28 11:42                               ` Gerd Hoffmann
2019-12-02 13:28                               ` Anton Yakovlev
     [not found]                               ` <20191128121920.GB4210@sirena.org.uk>
2019-12-02 13:30                                 ` Anton Yakovlev
     [not found]                                   ` <20191202135519.GF1998@sirena.org.uk>
2019-12-04  8:04                                     ` Anton Yakovlev
2019-11-25 16:50                     ` Liam Girdwood
2019-11-13  7:54           ` Anton Yakovlev
2019-11-12 12:45       ` Anton Yakovlev
2019-11-12 15:16         ` Liam Girdwood
2019-11-13  9:05           ` Anton Yakovlev
2019-11-19 15:49             ` Liam Girdwood
2019-11-20  9:32               ` Gerd Hoffmann
     [not found]   ` <20191028192952.GI5015@sirena.co.uk>
2019-10-29 10:46     ` Anton Yakovlev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b96600a6-1161-dbaf-c74c-c1bf8331de00@opensynergy.com \
    --to=anton.yakovlev@opensynergy.com \
    --cc=Mikhail.Golubev@opensynergy.com \
    --cc=broonie@kernel.org \
    --cc=jean-philippe@linaro.org \
    --cc=kraxel@redhat.com \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=tiwai@suse.de \
    --cc=virtio-dev@lists.oasis-open.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox