From nobody Thu Nov 14 17:42:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708245296834573.1041249737464; Sun, 18 Feb 2024 00:34:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rbcci-00037V-Jl; Sun, 18 Feb 2024 03:34:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rbccf-000375-DZ; Sun, 18 Feb 2024 03:34:06 -0500 Received: from mailout02.t-online.de ([194.25.134.17]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rbccd-0006K5-SJ; Sun, 18 Feb 2024 03:34:04 -0500 Received: from fwd72.aul.t-online.de (fwd72.aul.t-online.de [10.223.144.98]) by mailout02.t-online.de (Postfix) with SMTP id DE5CBF19; Sun, 18 Feb 2024 09:34:01 +0100 (CET) Received: from linpower.localnet ([79.208.24.6]) by fwd72.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1rbccb-2fYGZ70; Sun, 18 Feb 2024 09:34:01 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 6CD8E20037A; Sun, 18 Feb 2024 09:33:51 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Manos Pitsidianakis , "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org, qemu-stable@nongnu.org Subject: [PATCH v2 05/11] hw/audio/virtio-sound: free all stream buffers on reset Date: Sun, 18 Feb 2024 09:33:45 +0100 Message-Id: <20240218083351.8524-5-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1708245241-5081A95D-522D0378/0/0 CLEAN NORMAL X-TOI-MSGID: 7d7c11d3-d51f-44da-9173-e0d8a0b2dd74 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=194.25.134.17; envelope-from=volker.ruemelin@t-online.de; helo=mailout02.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1708245298427100003 All remaining stream buffers in the stream queues must be freed after a reset. This is the initial state of the virtio-sound device. Signed-off-by: Volker R=C3=BCmelin --- hw/audio/virtio-snd.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c index e5497b6bf6..2b630ada82 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -1318,12 +1318,23 @@ static void virtio_snd_reset(VirtIODevice *vdev) { VirtIOSound *s =3D VIRTIO_SND(vdev); virtio_snd_ctrl_command *cmd; + uint32_t i; =20 while (!QTAILQ_EMPTY(&s->cmdq)) { cmd =3D QTAILQ_FIRST(&s->cmdq); QTAILQ_REMOVE(&s->cmdq, cmd, next); virtio_snd_ctrl_cmd_free(cmd); } + + for (i =3D 0; i < s->snd_conf.streams; i++) { + VirtIOSoundPCMStream *stream =3D &s->streams[i]; + VirtIOSoundPCMBuffer *buffer; + + while ((buffer =3D QSIMPLEQ_FIRST(&stream->queue))) { + QSIMPLEQ_REMOVE_HEAD(&stream->queue, entry); + virtio_snd_pcm_buffer_free(buffer); + } + } } =20 static void virtio_snd_class_init(ObjectClass *klass, void *data) --=20 2.35.3