From: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
To: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Cc: virtio-dev@lists.oasis-open.org, alsa-devel@alsa-project.org,
"Michael S. Tsirkin" <mst@redhat.com>,
Takashi Iwai <tiwai@suse.com>,
linux-kernel@vger.kernel.org, Jaroslav Kysela <perex@perex.cz>,
virtualization@lists.linux-foundation.org
Subject: Re: [PATCH v2 6/9] ALSA: virtio: PCM substream operators
Date: Tue, 26 Jan 2021 08:25:58 +0100 (CET) [thread overview]
Message-ID: <d92151ca-cde3-d1e6-23fe-f0c671379e9@intel.com> (raw)
In-Reply-To: <7b4fa4c1-4af1-47b5-d2e6-bb2f81e75488@intel.com>
One more thing I missed yesterday:
On Mon, 25 Jan 2021, Guennadi Liakhovetski wrote:
>
> On Sun, 24 Jan 2021, Anton Yakovlev wrote:
>
>> Introduce the operators required for the operation of substreams.
>>
>> Signed-off-by: Anton Yakovlev <anton.yakovlev@opensynergy.com>
>> ---
>> sound/virtio/Makefile | 3 +-
>> sound/virtio/virtio_pcm.c | 5 +-
>> sound/virtio/virtio_pcm.h | 2 +
>> sound/virtio/virtio_pcm_ops.c | 513 ++++++++++++++++++++++++++++++++++
>> 4 files changed, 521 insertions(+), 2 deletions(-)
>> create mode 100644 sound/virtio/virtio_pcm_ops.c
>
> [snip]
>
>> diff --git a/sound/virtio/virtio_pcm_ops.c b/sound/virtio/virtio_pcm_ops.c
>> new file mode 100644
>> index 000000000000..19882777fcd6
>> --- /dev/null
>> +++ b/sound/virtio/virtio_pcm_ops.c
>> @@ -0,0 +1,513 @@
>
> [snip]
>
>> +/**
>> + * virtsnd_pcm_release() - Release the PCM substream on the device side.
>> + * @substream: VirtIO substream.
>> + *
>> + * Context: Any context that permits to sleep.
>> + * Return: 0 on success, -errno on failure.
>> + */
>> +static inline bool virtsnd_pcm_released(struct virtio_pcm_substream
>> *substream)
>> +{
>> + /*
>> + * The spec states that upon receipt of the RELEASE command "the
>> device
>> + * MUST complete all pending I/O messages for the specified stream
>> ID".
>> + * Thus, we consider the absence of I/O messages in the queue as an
>> + * indication that the substream has been released.
>> + */
>> + return atomic_read(&substream->msg_count) == 0;
>
> Also here having it atomic doesn't really seem to help. This just means, that
> at some point of time it was == 0.
>
>> +}
>> +
>> +static int virtsnd_pcm_release(struct virtio_pcm_substream *substream)
>
> kernel-doc missing
>
>> +{
>> + struct virtio_snd *snd = substream->snd;
>> + struct virtio_snd_msg *msg;
>> + unsigned int js = msecs_to_jiffies(msg_timeout_ms);
>> + int rc;
>> +
>> + msg = virtsnd_pcm_ctl_msg_alloc(substream, VIRTIO_SND_R_PCM_RELEASE,
>> + GFP_KERNEL);
>> + if (IS_ERR(msg))
>> + return PTR_ERR(msg);
>> +
>> + rc = virtsnd_ctl_msg_send_sync(snd, msg);
>> + if (rc)
>> + return rc;
>> +
>> + return wait_event_interruptible_timeout(substream->msg_empty,
>> + virtsnd_pcm_released(substream),
>> + js);
wait_event_interruptible_timeout() will return a positive number in
success cases, 0 means a timeout and condition still false. Whereas when
you call this function you interpret 0 as success and you expect any != 0
to be a negative error. Wondering how this worked during your tests?
Thanks
Guennadi
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2021-01-26 7:26 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-24 16:53 [PATCH v2 0/9] ALSA: add virtio sound driver Anton Yakovlev
2021-01-24 16:54 ` [PATCH v2 1/9] uapi: virtio_ids: add a sound device type ID from OASIS spec Anton Yakovlev
2021-01-24 16:54 ` [PATCH v2 2/9] ALSA: virtio: add virtio sound driver Anton Yakovlev
2021-01-25 14:54 ` Guennadi Liakhovetski
2021-02-01 23:18 ` [virtio-dev] " Anton Yakovlev
[not found] ` <s5h35yd9jf0.wl-tiwai@suse.de>
2021-02-03 17:34 ` Anton Yakovlev
2021-01-24 16:54 ` [PATCH v2 3/9] ALSA: virtio: handling control messages Anton Yakovlev
2021-01-25 15:22 ` Guennadi Liakhovetski
2021-02-01 23:18 ` [virtio-dev] " Anton Yakovlev
2021-01-24 16:54 ` [PATCH v2 4/9] ALSA: virtio: build PCM devices and substream hardware descriptors Anton Yakovlev
2021-01-25 15:44 ` Guennadi Liakhovetski
2021-02-01 23:19 ` [virtio-dev] " Anton Yakovlev
2021-01-24 16:54 ` [PATCH v2 5/9] ALSA: virtio: handling control and I/O messages for the PCM device Anton Yakovlev
2021-01-25 16:25 ` Guennadi Liakhovetski
2021-02-01 23:20 ` Anton Yakovlev
2021-01-24 16:54 ` [PATCH v2 6/9] ALSA: virtio: PCM substream operators Anton Yakovlev
2021-01-25 16:59 ` Guennadi Liakhovetski
2021-01-26 7:25 ` Guennadi Liakhovetski [this message]
2021-02-01 23:21 ` Anton Yakovlev
2021-01-24 16:54 ` [PATCH v2 7/9] ALSA: virtio: introduce jack support Anton Yakovlev
2021-01-26 7:40 ` Guennadi Liakhovetski
2021-01-24 16:54 ` [PATCH v2 8/9] ALSA: virtio: introduce PCM channel map support Anton Yakovlev
2021-01-26 9:22 ` Guennadi Liakhovetski
2021-02-01 23:21 ` Anton Yakovlev
2021-01-24 16:54 ` [PATCH v2 9/9] ALSA: virtio: introduce device suspend/resume support Anton Yakovlev
[not found] ` <s5hpn1h81ot.wl-tiwai@suse.de>
2021-02-08 10:23 ` [PATCH v2 0/9] ALSA: add virtio sound driver 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=d92151ca-cde3-d1e6-23fe-f0c671379e9@intel.com \
--to=guennadi.liakhovetski@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=virtio-dev@lists.oasis-open.org \
--cc=virtualization@lists.linux-foundation.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;
as well as URLs for NNTP newsgroup(s).