All of lore.kernel.org
 help / color / mirror / Atom feed
From: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
To: Alexander Mikhalitsyn <alexander@mihalicyn.com>, qemu-devel@nongnu.org
Cc: "Volker Rümelin" <vr_qemu@t-online.de>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
	"Stéphane Graber" <stgraber@stgraber.org>,
	"Daniel P . Berrangé" <berrange@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Alexander Mikhalitsyn" <alexander@mihalicyn.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Alexander Mikhalitsyn" <aleksandr.mikhalitsyn@futurfusion.io>
Subject: Re: [PATCH v3 4/9] hw/audio/virtio-sound: split out virtio_snd_pcm_start_stop()
Date: Mon, 29 Jun 2026 10:51:44 +0300	[thread overview]
Message-ID: <thdvdk.23mk4gyijvrt@linaro.org> (raw)
In-Reply-To: <20260626123531.132078-5-alexander@mihalicyn.com>

On Fri, 26 Jun 2026 15:35, Alexander Mikhalitsyn <alexander@mihalicyn.com> wrote:
>From: Volker Rümelin <vr_qemu@t-online.de>
>
>Split out virtio_snd_pcm_start_stop(). This is a preparation
>for the next patch so that it doesn't become too big.
>
>Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
>[AM: there were too many conflicts, I did `git checkout --ours -- <.>`
>     and then reimplemented the patch idea
>/AM]
>Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
>Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>---
>v3:
>	- resurrected error_report(..) as suggested by Marc-André Lureau
>---
> hw/audio/trace-events |  3 ++-
> hw/audio/virtio-snd.c | 59 ++++++++++++++++++++++++++++---------------
> 2 files changed, 41 insertions(+), 21 deletions(-)
>
>diff --git a/hw/audio/trace-events b/hw/audio/trace-events
>index 30f59215453..75d1fb37bd9 100644
>--- a/hw/audio/trace-events
>+++ b/hw/audio/trace-events
>@@ -53,7 +53,8 @@ virtio_snd_unrealize(void *snd) "snd %p: unrealize"
> virtio_snd_handle_pcm_set_params(uint32_t stream) "VIRTIO_SND_PCM_SET_PARAMS called for stream %"PRIu32
> virtio_snd_handle_ctrl(void *vdev, void *vq) "snd %p: handle ctrl event for queue %p"
> virtio_snd_handle_pcm_info(uint32_t stream) "VIRTIO_SND_R_PCM_INFO called for stream %"PRIu32
>-virtio_snd_handle_pcm_start_stop(const char *code, uint32_t stream) "%s called for stream %"PRIu32
>+virtio_snd_handle_pcm_start(uint32_t stream) "VIRTIO_SND_R_PCM_START called for stream %"PRIu32
>+virtio_snd_handle_pcm_stop(uint32_t stream) "VIRTIO_SND_R_PCM_STOP called for stream %"PRIu32
> virtio_snd_handle_pcm_release(uint32_t stream) "VIRTIO_SND_PCM_RELEASE called for stream %"PRIu32
> virtio_snd_handle_code(uint32_t val, const char *code) "ctrl code msg val = %"PRIu32" == %s"
> virtio_snd_handle_chmap_info(void) "VIRTIO_SND_CHMAP_INFO called"
>diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c
>index 8f4421ba844..300ba13ffeb 100644
>--- a/hw/audio/virtio-snd.c
>+++ b/hw/audio/virtio-snd.c
>@@ -521,7 +521,44 @@ static void virtio_snd_handle_pcm_prepare(VirtIOSound *s,
> }
> 
> /*
>- * Handles VIRTIO_SND_R_PCM_START.
>+ * Starts/Stops a VirtIOSound card stream.
>+ * Returns the response status code. (VIRTIO_SND_S_*).
>+ *
>+ * @s: VirtIOSound device
>+ * @stream_id: stream id
>+ * @start: whether to start or stop the stream
>+ */
>+static uint32_t virtio_snd_pcm_start_stop(VirtIOSound *s,
>+                                          uint32_t stream_id,
>+                                          bool start)
>+{
>+    VirtIOSoundPCMStream *stream;
>+
>+    stream = virtio_snd_pcm_get_stream(s, stream_id);
>+    if (!stream) {
>+        qemu_log_mask(LOG_GUEST_ERROR,
>+            "%s: Invalid stream id: %"PRIu32 "\n", __func__, stream_id);

Minor formatting nit:

+        qemu_log_mask(LOG_GUEST_ERROR,
+                      "%s: Invalid stream id: %"PRIu32 "\n",
+                      __func__, stream_id);

>+        return cpu_to_le32(VIRTIO_SND_S_BAD_MSG);
>+    }
>+
>+    if (start) {
>+        trace_virtio_snd_handle_pcm_start(stream_id);
>+    } else {
>+        trace_virtio_snd_handle_pcm_stop(stream_id);
>+    }

Let's move the trace_*() calls at the start of the function, before the 
error checking, like it used to be.

>+
>+    stream->active = start;
>+    if (stream->info.direction == VIRTIO_SND_D_OUTPUT) {
>+        audio_be_set_active_out(s->audio_be, stream->voice.out, start);
>+    } else {
>+        audio_be_set_active_in(s->audio_be, stream->voice.in, start);
>+    }
>+
>+    return cpu_to_le32(VIRTIO_SND_S_OK);
>+}
>+
>+/*
>+ * Handles VIRTIO_SND_R_PCM_START and VIRTIO_SND_R_PCM_STOP.
>  *
>  * @s: VirtIOSound device
>  * @cmd: The request command queue element from VirtIOSound cmdq field
>@@ -531,7 +568,6 @@ static void virtio_snd_handle_pcm_start_stop(VirtIOSound *s,
>                                              virtio_snd_ctrl_command *cmd,
>                                              bool start)
> {
>-    VirtIOSoundPCMStream *stream;
>     virtio_snd_pcm_hdr req;
>     uint32_t stream_id;
>     size_t msg_sz = iov_to_buf(cmd->elem->out_sg,
>@@ -549,24 +585,7 @@ static void virtio_snd_handle_pcm_start_stop(VirtIOSound *s,
>     }
> 
>     stream_id = le32_to_cpu(req.stream_id);
>-    cmd->resp.code = cpu_to_le32(VIRTIO_SND_S_OK);
>-    trace_virtio_snd_handle_pcm_start_stop(start ? "VIRTIO_SND_R_PCM_START" :
>-            "VIRTIO_SND_R_PCM_STOP", stream_id);
>-
>-    stream = virtio_snd_pcm_get_stream(s, stream_id);
>-    if (stream) {
>-        stream->active = start;
>-        if (stream->info.direction == VIRTIO_SND_D_OUTPUT) {
>-            audio_be_set_active_out(s->audio_be, stream->voice.out, start);
>-        } else {
>-            audio_be_set_active_in(s->audio_be, stream->voice.in, start);
>-        }
>-    } else {
>-        error_report("Invalid stream id: %"PRIu32, stream_id);
>-        cmd->resp.code = cpu_to_le32(VIRTIO_SND_S_BAD_MSG);
>-        return;
>-    }
>-    stream->active = start;
>+    cmd->resp.code = virtio_snd_pcm_start_stop(s, stream_id, start);
> }
> 
> /*
>-- 
>2.47.3
>


  reply	other threads:[~2026-06-29  7:56 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26 12:35 [PATCH v3 0/9] hw/audio/virtio-sound: basic migration support Alexander Mikhalitsyn
2026-06-26 12:35 ` [PATCH v3 1/9] hw/audio/virtio-sound: remove command and stream mutexes Alexander Mikhalitsyn
2026-06-29  7:43   ` Manos Pitsidianakis
2026-06-26 12:35 ` [PATCH v3 2/9] hw/audio/virtio-sound: allocate an array of streams Alexander Mikhalitsyn
2026-06-29  7:44   ` Manos Pitsidianakis
2026-06-26 12:35 ` [PATCH v3 3/9] hw/audio/virtio-sound: free all stream buffers on reset Alexander Mikhalitsyn
2026-06-29  7:50   ` Manos Pitsidianakis
2026-06-26 12:35 ` [PATCH v3 4/9] hw/audio/virtio-sound: split out virtio_snd_pcm_start_stop() Alexander Mikhalitsyn
2026-06-29  7:51   ` Manos Pitsidianakis [this message]
2026-06-26 12:35 ` [PATCH v3 5/9] hw/audio/virtio-sound: add stream state variable Alexander Mikhalitsyn
2026-06-26 14:12   ` marcandre.lureau
2026-06-29  7:58   ` Manos Pitsidianakis
2026-06-29  8:21     ` Michael S. Tsirkin
2026-06-29  8:31       ` Manos Pitsidianakis
2026-06-26 12:35 ` [PATCH v3 6/9] hw/audio/virtio-sound: introduce virtio_snd_pcm_open() Alexander Mikhalitsyn
2026-06-29  8:19   ` Manos Pitsidianakis
2026-06-26 12:35 ` [PATCH v3 7/9] hw/audio/virtio-sound: introduce virtio_snd_set_active() Alexander Mikhalitsyn
2026-06-26 12:35 ` [PATCH v3 8/9] hw/audio/virtio-sound: remove channel positions field from VirtIOSoundPCMStream Alexander Mikhalitsyn
2026-06-26 14:12   ` marcandre.lureau
2026-06-29  8:22   ` Manos Pitsidianakis
2026-06-26 12:35 ` [PATCH v3 9/9] hw/audio/virtio-sound: add missing vmstate fields Alexander Mikhalitsyn
2026-06-26 14:12   ` marcandre.lureau
2026-06-29  8:23   ` Manos Pitsidianakis
2026-06-29 11:04 ` [PATCH v3 0/9] hw/audio/virtio-sound: basic migration support Manos Pitsidianakis
2026-06-29 11:32   ` Aleksandr Mikhalitsyn
2026-06-29 12:01     ` Manos Pitsidianakis

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=thdvdk.23mk4gyijvrt@linaro.org \
    --to=manos.pitsidianakis@linaro.org \
    --cc=aleksandr.mikhalitsyn@futurfusion.io \
    --cc=alexander@mihalicyn.com \
    --cc=berrange@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stgraber@stgraber.org \
    --cc=vr_qemu@t-online.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.