From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646405054913788.9644861073467; Fri, 4 Mar 2022 06:44:14 -0800 (PST) Received: from localhost ([::1]:47216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9AD-0004Rg-0M for importer@patchew.org; Fri, 04 Mar 2022 09:44:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38136) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8od-0007oc-RE for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:21:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51467) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8oa-00007v-42 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:21:53 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-52-Mm_ldKa_PPO28EQhXnBbdw-1; Fri, 04 Mar 2022 09:21:48 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8AE99FC81; Fri, 4 Mar 2022 14:21:45 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 61EB32ED84; Fri, 4 Mar 2022 14:21:25 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D584C1800386; Fri, 4 Mar 2022 15:21:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403711; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zqNuyc6/1XT7rQYIy8gcLwnJ3QsYqn/+JsrC/zhuMF0=; b=I5dp3/M1g0zFMi92MOLAaoXVY2FKhRpvuK3qCjafISwzOW7voH5IddDQLLche4i3OAu/nv YYUGMYShj3s/lCUpzkhb0TF+YRjWkXQQ5TkJzSLvZXj28BD2eXgS/J2SaYGF3lo14Ig5OS iBbAQcbrJpXPSgOqNGXLeAd4JDpTTMs= X-MC-Unique: Mm_ldKa_PPO28EQhXnBbdw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 01/35] hw/usb: pacify xhciwmi.exe warning Date: Fri, 4 Mar 2022 15:20:49 +0100 Message-Id: <20220304142123.956171-2-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , Yan Vugenfirer , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , Pavel Polozov , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , "Denis V. Lunev" , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646405057582100001 Content-Type: text/plain; charset="utf-8" From: "Denis V. Lunev" xhciwmi.exe is used inside Windows 2022 SVVP tests. This tool called as 'xhciwmi.exe --verify' reports that 'The firmware loaded on this controller has known bugs and/or compatibility issues'. This is just a warning but there is no particular sense to ignore it. This patch just pacifies the tool. There is a big question whether this change should be put using machine type mechanics, but at my opinion this would be an overkill. Signed-off-by: Denis V. Lunev Tested-by: Pavel Polozov CC: Yan Vugenfirer CC: Gerd Hoffmann Reviewed-by: Yan Vugenfirer Message-Id: <20211223095443.130276-1-den@openvz.org> Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-xhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 14bdb8967686..0cd0a5e54027 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -2523,7 +2523,7 @@ static void xhci_process_commands(XHCIState *xhci) case CR_VENDOR_NEC_FIRMWARE_REVISION: if (xhci->nec_quirks) { event.type =3D 48; /* NEC reply */ - event.length =3D 0x3025; + event.length =3D 0x3034; } else { event.ccode =3D CC_TRB_ERROR; } --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646405562429540.1832854337769; Fri, 4 Mar 2022 06:52:42 -0800 (PST) Received: from localhost ([::1]:39372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9IP-0001d1-Sm for importer@patchew.org; Fri, 04 Mar 2022 09:52:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8oe-0007pW-6K for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:21:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43531) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8oa-00008c-Lb for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:21:54 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-331-nhZ3vlirNZyIN2bziaR5Uw-1; Fri, 04 Mar 2022 09:21:49 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 592CCFC80; Fri, 4 Mar 2022 14:21:47 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 50F807DE5E; Fri, 4 Mar 2022 14:21:46 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E1A4C1800394; Fri, 4 Mar 2022 15:21:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403712; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PC/TnAgEtZW+A9j9gQ4ee9w9hCyjPbjZ3C8l7vcAV7A=; b=S1EgejLnVDC2a4RX7zvLLKVGxKvoMRA4mNqsAJJO3lr/COKNl1nJUjwHKcn7guRrGu99Mp sfjez0H8xKnX6ien4+RlJlZ66U210I0RWCBdxyBQl7Fs14Utk7+NiTPxaKf4mNbH0XULk0 XSbZN23dFW3XeFNQfWtGGa/lm9KKxAs= X-MC-Unique: nhZ3vlirNZyIN2bziaR5Uw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 02/35] hw/usb/dev-mtp: create directories with a+x mode mask Date: Fri, 4 Mar 2022 15:20:50 +0100 Message-Id: <20220304142123.956171-3-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646405563846100001 From: Volker R=C3=BCmelin Current code creates directories with mode 0644. Even the creator can't create files in the new directory. Set all x mode flags in variable mask and clear all x mode flags in function open() to preserve the current open mode. Signed-off-by: Volker R=C3=BCmelin Message-Id: <20220122140619.7514-1-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- hw/usb/dev-mtp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 1e6ac76bef9b..e6b77a2a941d 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -1607,7 +1607,7 @@ static void usb_mtp_write_data(MTPState *s, uint32_t = handle) usb_mtp_object_lookup(s, s->dataset.parent_handle); char *path =3D NULL; uint64_t rc; - mode_t mask =3D 0644; + mode_t mask =3D 0755; int ret =3D 0; =20 assert(d !=3D NULL); @@ -1635,7 +1635,7 @@ static void usb_mtp_write_data(MTPState *s, uint32_t = handle) } =20 d->fd =3D open(path, O_CREAT | O_WRONLY | - O_CLOEXEC | O_NOFOLLOW, mask); + O_CLOEXEC | O_NOFOLLOW, mask & 0666); if (d->fd =3D=3D -1) { ret =3D 1; goto done; --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646406105481547.0620361423411; Fri, 4 Mar 2022 07:01:45 -0800 (PST) Received: from localhost ([::1]:60728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9RA-0007xs-Dr for importer@patchew.org; Fri, 04 Mar 2022 10:01:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8p5-0000rE-1o for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:22:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25020) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8p3-0000GV-F8 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:22:22 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-350-frTATKKtM0OM1eqEH4IqEg-1; Fri, 04 Mar 2022 09:22:18 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5813E801AFE; Fri, 4 Mar 2022 14:22:16 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 13A0D2ED75; Fri, 4 Mar 2022 14:21:47 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id F03AA180039D; Fri, 4 Mar 2022 15:21:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403740; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4dU1YDkDSzs6uMQwQgw4xY7kY/3Em9e65XDeCswSYW0=; b=IqYqsLy923a1RzEkSDXA1ZwjLXBQFaGQljCt1xULZp8Fd/+gf5+0HACe+Vqniss0k3ttaT RilVswgId+KbOQb3jaQfStdjPEjKitiJGhaWZw0yjOJKTvCPTs7Qt5pOgnCz8TvC9bwpWO Pciwf2MVWFaOaDvxQQBALGLH3KEZXE8= X-MC-Unique: frTATKKtM0OM1eqEH4IqEg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 03/35] usb/ohci: Move trace point and log ep number to help debugging Date: Fri, 4 Mar 2022 15:20:51 +0100 Message-Id: <20220304142123.956171-4-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646406106586100001 Content-Type: text/plain; charset="utf-8" From: BALATON Zoltan Signed-off-by: BALATON Zoltan Message-Id: <4e3a05a64b5029a88654eab9a873fb45ac80b1a7.1643117600.git.balato= n@eik.bme.hu> Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ohci.c | 14 +++++++------- hw/usb/trace-events | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index a93d6b2e9882..f915cc547351 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -1033,21 +1033,21 @@ static int ohci_service_td(OHCIState *ohci, struct = ohci_ed *ed) ohci->async_td =3D 0; ohci->async_complete =3D false; } else { + dev =3D ohci_find_device(ohci, OHCI_BM(ed->flags, ED_FA)); + if (dev =3D=3D NULL) { + trace_usb_ohci_td_dev_error(); + return 1; + } + ep =3D usb_ep_get(dev, pid, OHCI_BM(ed->flags, ED_EN)); if (ohci->async_td) { /* ??? The hardware should allow one active packet per endpoint. We only allow one active packet per controller. This should be sufficient as long as devices respond in a timely manner. */ - trace_usb_ohci_td_too_many_pending(); + trace_usb_ohci_td_too_many_pending(ep->nr); return 1; } - dev =3D ohci_find_device(ohci, OHCI_BM(ed->flags, ED_FA)); - if (dev =3D=3D NULL) { - trace_usb_ohci_td_dev_error(); - return 1; - } - ep =3D usb_ep_get(dev, pid, OHCI_BM(ed->flags, ED_EN)); usb_packet_setup(&ohci->usb_packet, pid, ep, 0, addr, !flag_r, OHCI_BM(td.flags, TD_DI) =3D=3D 0); usb_packet_addbuf(&ohci->usb_packet, ohci->usb_buf, pktlen); diff --git a/hw/usb/trace-events b/hw/usb/trace-events index b8287b63f15d..9773cb53300d 100644 --- a/hw/usb/trace-events +++ b/hw/usb/trace-events @@ -51,7 +51,7 @@ usb_ohci_td_skip_async(void) "" usb_ohci_td_pkt_hdr(uint32_t addr, int64_t pktlen, int64_t len, const char= *s, int flag_r, uint32_t cbp, uint32_t be) " TD @ 0x%.8x %" PRId64 " of %"= PRId64 " bytes %s r=3D%d cbp=3D0x%.8x be=3D0x%.8x" usb_ohci_td_pkt_short(const char *dir, const char *buf) "%s data: %s" usb_ohci_td_pkt_full(const char *dir, const char *buf) "%s data: %s" -usb_ohci_td_too_many_pending(void) "" +usb_ohci_td_too_many_pending(int ep) "ep=3D%d" usb_ohci_td_packet_status(int status) "status=3D%d" usb_ohci_ed_read_error(uint32_t addr) "ED read error at 0x%x" usb_ohci_ed_pkt(uint32_t cur, int h, int c, uint32_t head, uint32_t tail, = uint32_t next) "ED @ 0x%.8x h=3D%u c=3D%u\n head=3D0x%.8x tailp=3D0x%.8x n= ext=3D0x%.8x" --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646405874001858.3787616634701; Fri, 4 Mar 2022 06:57:54 -0800 (PST) Received: from localhost ([::1]:52168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9NQ-0001xg-Ja for importer@patchew.org; Fri, 04 Mar 2022 09:57:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8ou-0000Hq-VB for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:22:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37506) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8ot-0000Ev-Df for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:22:12 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-520-alYB5lpFPWyl_E1tAJ9ndg-1; Fri, 04 Mar 2022 09:22:07 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DCAA8FC81; Fri, 4 Mar 2022 14:22:05 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DDE891057059; Fri, 4 Mar 2022 14:21:48 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 0806C18003A7; Fri, 4 Mar 2022 15:21:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403730; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PzMFBP0l+WrNxBuICGRpdfAruoi2OmgMa+g4nr7G2dk=; b=d2eBUuzsj64ExT1WQUFiFLfA3LJMY9jsJi6sZ3Vy9ytC22hxGpa26vcevMDfhJVT9Q2Afo 5Nh4WmRKhYBxoP5W5TNkuMirEV3ObVmMVZa6ZgLivMiufT2kKCfeV9reXO6+AXwHgORTPo gApKoZxS9xdKNNvP/bPeH2J1WjHfwMw= X-MC-Unique: alYB5lpFPWyl_E1tAJ9ndg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 04/35] usb/ohci: Move cancelling async packet to ohci_stop_endpoints() Date: Fri, 4 Mar 2022 15:20:52 +0100 Message-Id: <20220304142123.956171-5-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646405874400100001 Content-Type: text/plain; charset="utf-8" From: BALATON Zoltan This is always done before calling this function so remove duplicated code and do it within the function at one place. Signed-off-by: BALATON Zoltan Message-Id: Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ohci.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index f915cc547351..6d762973ebd2 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -369,6 +369,10 @@ void ohci_stop_endpoints(OHCIState *ohci) USBDevice *dev; int i, j; =20 + if (ohci->async_td) { + usb_cancel_packet(&ohci->usb_packet); + ohci->async_td =3D 0; + } for (i =3D 0; i < ohci->num_ports; i++) { dev =3D ohci->rhport[i].port.dev; if (dev && dev->attached) { @@ -398,10 +402,6 @@ static void ohci_roothub_reset(OHCIState *ohci) usb_port_reset(&port->port); } } - if (ohci->async_td) { - usb_cancel_packet(&ohci->usb_packet); - ohci->async_td =3D 0; - } ohci_stop_endpoints(ohci); } =20 @@ -1277,10 +1277,6 @@ static void ohci_frame_boundary(void *opaque) =20 /* Cancel all pending packets if either of the lists has been disabled= . */ if (ohci->old_ctl & (~ohci->ctl) & (OHCI_CTL_BLE | OHCI_CTL_CLE)) { - if (ohci->async_td) { - usb_cancel_packet(&ohci->usb_packet); - ohci->async_td =3D 0; - } ohci_stop_endpoints(ohci); } ohci->old_ctl =3D ohci->ctl; --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646405482830123.25188528011859; Fri, 4 Mar 2022 06:51:22 -0800 (PST) Received: from localhost ([::1]:34890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9H7-00071I-OP for importer@patchew.org; Fri, 04 Mar 2022 09:51:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8pL-00015S-Fp for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:22:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40924) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8pJ-0000Mj-4a for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:22:39 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-102-ut3IOS2yNWur971_VJN9Hw-1; Fri, 04 Mar 2022 09:22:34 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E85A41091DA0; Fri, 4 Mar 2022 14:22:32 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8731F866F5; Fri, 4 Mar 2022 14:22:07 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 1573918003A8; Fri, 4 Mar 2022 15:21:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GjR+4qjtFklzx6/r/Mu6DDEFmuJDYJjNypVS7eElvrw=; b=clk108BoNZFVq3HKss5G4zaCJM2GGp8U6fuw1ikNJVxDP/Mj6y7CkXrRLD0YpE+OLTj55u l+xzPa4JKym2J7HXYOHz8j0r7LLlUquakR5sfqnWQ8hN7MOKHUNIOqpWTRrNQf7U7kW4YB 8GwORaJFSEyHsafZhMEm4hmb7VAtZmo= X-MC-Unique: ut3IOS2yNWur971_VJN9Hw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 05/35] usb/ohci: Move USBPortOps related functions together Date: Fri, 4 Mar 2022 15:20:53 +0100 Message-Id: <20220304142123.956171-6-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646405484955100001 From: BALATON Zoltan This also allows removing two forward declarations Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <9fd730375c4cad0b11163631660d68711d3fc13f.1643117600.git.balato= n@eik.bme.hu> Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ohci.c | 215 +++++++++++++++++++++++----------------------- 1 file changed, 106 insertions(+), 109 deletions(-) diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index 6d762973ebd2..190f5a8aba18 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -58,8 +58,6 @@ struct ohci_hcca { #define ED_WBACK_OFFSET offsetof(struct ohci_ed, head) #define ED_WBACK_SIZE 4 =20 -static void ohci_async_cancel_device(OHCIState *ohci, USBDevice *dev); - /* Bitfields for the first word of an Endpoint Desciptor. */ #define OHCI_ED_FA_SHIFT 0 #define OHCI_ED_FA_MASK (0x7f<opaque; - OHCIPort *port =3D &s->rhport[port1->index]; - uint32_t old_state =3D port->ctrl; - - /* set connect status */ - port->ctrl |=3D OHCI_PORT_CCS | OHCI_PORT_CSC; - - /* update speed */ - if (port->port.dev->speed =3D=3D USB_SPEED_LOW) { - port->ctrl |=3D OHCI_PORT_LSDA; - } else { - port->ctrl &=3D ~OHCI_PORT_LSDA; - } - - /* notify of remote-wakeup */ - if ((s->ctl & OHCI_CTL_HCFS) =3D=3D OHCI_USB_SUSPEND) { - ohci_set_interrupt(s, OHCI_INTR_RD); - } - - trace_usb_ohci_port_attach(port1->index); - - if (old_state !=3D port->ctrl) { - ohci_set_interrupt(s, OHCI_INTR_RHSC); - } -} - -static void ohci_detach(USBPort *port1) -{ - OHCIState *s =3D port1->opaque; - OHCIPort *port =3D &s->rhport[port1->index]; - uint32_t old_state =3D port->ctrl; - - ohci_async_cancel_device(s, port1->dev); - - /* set connect status */ - if (port->ctrl & OHCI_PORT_CCS) { - port->ctrl &=3D ~OHCI_PORT_CCS; - port->ctrl |=3D OHCI_PORT_CSC; - } - /* disable port */ - if (port->ctrl & OHCI_PORT_PES) { - port->ctrl &=3D ~OHCI_PORT_PES; - port->ctrl |=3D OHCI_PORT_PESC; - } - trace_usb_ohci_port_detach(port1->index); - - if (old_state !=3D port->ctrl) { - ohci_set_interrupt(s, OHCI_INTR_RHSC); - } -} - -static void ohci_wakeup(USBPort *port1) -{ - OHCIState *s =3D port1->opaque; - OHCIPort *port =3D &s->rhport[port1->index]; - uint32_t intr =3D 0; - if (port->ctrl & OHCI_PORT_PSS) { - trace_usb_ohci_port_wakeup(port1->index); - port->ctrl |=3D OHCI_PORT_PSSC; - port->ctrl &=3D ~OHCI_PORT_PSS; - intr =3D OHCI_INTR_RHSC; - } - /* Note that the controller can be suspended even if this port is not = */ - if ((s->ctl & OHCI_CTL_HCFS) =3D=3D OHCI_USB_SUSPEND) { - trace_usb_ohci_remote_wakeup(s->name); - /* This is the one state transition the controller can do by itsel= f */ - s->ctl &=3D ~OHCI_CTL_HCFS; - s->ctl |=3D OHCI_USB_RESUME; - /* In suspend mode only ResumeDetected is possible, not RHSC: - * see the OHCI spec 5.1.2.3. - */ - intr =3D OHCI_INTR_RD; - } - ohci_set_interrupt(s, intr); -} - -static void ohci_child_detach(USBPort *port1, USBDevice *child) -{ - OHCIState *s =3D port1->opaque; - - ohci_async_cancel_device(s, child); -} - static USBDevice *ohci_find_device(OHCIState *ohci, uint8_t addr) { USBDevice *dev; @@ -634,17 +546,6 @@ static int ohci_copy_iso_td(OHCIState *ohci, return 0; } =20 -static void ohci_process_lists(OHCIState *ohci, int completion); - -static void ohci_async_complete_packet(USBPort *port, USBPacket *packet) -{ - OHCIState *ohci =3D container_of(packet, OHCIState, usb_packet); - - trace_usb_ohci_async_complete(); - ohci->async_complete =3D true; - ohci_process_lists(ohci, 1); -} - #define USUB(a, b) ((int16_t)((uint16_t)(a) - (uint16_t)(b))) =20 static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed, @@ -1789,22 +1690,118 @@ static void ohci_mem_write(void *opaque, } } =20 -static void ohci_async_cancel_device(OHCIState *ohci, USBDevice *dev) -{ - if (ohci->async_td && - usb_packet_is_inflight(&ohci->usb_packet) && - ohci->usb_packet.ep->dev =3D=3D dev) { - usb_cancel_packet(&ohci->usb_packet); - ohci->async_td =3D 0; - } -} - static const MemoryRegionOps ohci_mem_ops =3D { .read =3D ohci_mem_read, .write =3D ohci_mem_write, .endianness =3D DEVICE_LITTLE_ENDIAN, }; =20 +/* USBPortOps */ +static void ohci_attach(USBPort *port1) +{ + OHCIState *s =3D port1->opaque; + OHCIPort *port =3D &s->rhport[port1->index]; + uint32_t old_state =3D port->ctrl; + + /* set connect status */ + port->ctrl |=3D OHCI_PORT_CCS | OHCI_PORT_CSC; + + /* update speed */ + if (port->port.dev->speed =3D=3D USB_SPEED_LOW) { + port->ctrl |=3D OHCI_PORT_LSDA; + } else { + port->ctrl &=3D ~OHCI_PORT_LSDA; + } + + /* notify of remote-wakeup */ + if ((s->ctl & OHCI_CTL_HCFS) =3D=3D OHCI_USB_SUSPEND) { + ohci_set_interrupt(s, OHCI_INTR_RD); + } + + trace_usb_ohci_port_attach(port1->index); + + if (old_state !=3D port->ctrl) { + ohci_set_interrupt(s, OHCI_INTR_RHSC); + } +} + +static void ohci_async_cancel_device(OHCIState *ohci, USBDevice *dev) +{ + if (ohci->async_td && + usb_packet_is_inflight(&ohci->usb_packet) && + ohci->usb_packet.ep->dev =3D=3D dev) { + usb_cancel_packet(&ohci->usb_packet); + ohci->async_td =3D 0; + } +} + +static void ohci_child_detach(USBPort *port1, USBDevice *child) +{ + OHCIState *s =3D port1->opaque; + + ohci_async_cancel_device(s, child); +} + +static void ohci_detach(USBPort *port1) +{ + OHCIState *s =3D port1->opaque; + OHCIPort *port =3D &s->rhport[port1->index]; + uint32_t old_state =3D port->ctrl; + + ohci_async_cancel_device(s, port1->dev); + + /* set connect status */ + if (port->ctrl & OHCI_PORT_CCS) { + port->ctrl &=3D ~OHCI_PORT_CCS; + port->ctrl |=3D OHCI_PORT_CSC; + } + /* disable port */ + if (port->ctrl & OHCI_PORT_PES) { + port->ctrl &=3D ~OHCI_PORT_PES; + port->ctrl |=3D OHCI_PORT_PESC; + } + trace_usb_ohci_port_detach(port1->index); + + if (old_state !=3D port->ctrl) { + ohci_set_interrupt(s, OHCI_INTR_RHSC); + } +} + +static void ohci_wakeup(USBPort *port1) +{ + OHCIState *s =3D port1->opaque; + OHCIPort *port =3D &s->rhport[port1->index]; + uint32_t intr =3D 0; + if (port->ctrl & OHCI_PORT_PSS) { + trace_usb_ohci_port_wakeup(port1->index); + port->ctrl |=3D OHCI_PORT_PSSC; + port->ctrl &=3D ~OHCI_PORT_PSS; + intr =3D OHCI_INTR_RHSC; + } + /* Note that the controller can be suspended even if this port is not = */ + if ((s->ctl & OHCI_CTL_HCFS) =3D=3D OHCI_USB_SUSPEND) { + trace_usb_ohci_remote_wakeup(s->name); + /* This is the one state transition the controller can do by itsel= f */ + s->ctl &=3D ~OHCI_CTL_HCFS; + s->ctl |=3D OHCI_USB_RESUME; + /* + * In suspend mode only ResumeDetected is possible, not RHSC: + * see the OHCI spec 5.1.2.3. + */ + intr =3D OHCI_INTR_RD; + } + ohci_set_interrupt(s, intr); +} + +static void ohci_async_complete_packet(USBPort *port, USBPacket *packet) +{ + OHCIState *ohci =3D container_of(packet, OHCIState, usb_packet); + + trace_usb_ohci_async_complete(); + ohci->async_complete =3D true; + ohci_process_lists(ohci, 1); +} + static USBPortOps ohci_port_ops =3D { .attach =3D ohci_attach, .detach =3D ohci_detach, --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646405663022673.0375854567138; Fri, 4 Mar 2022 06:54:23 -0800 (PST) Received: from localhost ([::1]:43372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9K1-0004Ny-Qg for importer@patchew.org; Fri, 04 Mar 2022 09:54:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8pM-00018V-95 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:22:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:36141) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8pK-0000Mt-Qc for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:22:40 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-671-NXfoAY6uNBSCzlrmuLcCYQ-1; Fri, 04 Mar 2022 09:22:35 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 66FCBFC80; Fri, 4 Mar 2022 14:22:33 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1F8E77B616; Fri, 4 Mar 2022 14:22:18 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 217AA18003AA; Fri, 4 Mar 2022 15:21:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403758; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wobwSMYvpOR0/L25JZJ36tSIJ+eDjnvKr1Hpifs4R8k=; b=WIU9pzkmb+t/v5AgsybF421e8BbgbxfZ/snZA7uNOOVBjKhm0ICq0SKC/a+y5tEGwyq17D a77fXhLHv23piCk8h4yu2PzgncR/AOU1Tx9a+fJLQnVUWm/GkHPAVKFQeHDvaWW/7Fv2oz KXdJrUgvlH6RCHCOOjEzIx0yUkIRQWg= X-MC-Unique: NXfoAY6uNBSCzlrmuLcCYQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 06/35] usb/ohci: Merge ohci_async_cancel_device() into ohci_child_detach() Date: Fri, 4 Mar 2022 15:20:54 +0100 Message-Id: <20220304142123.956171-7-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646405664704100001 From: BALATON Zoltan These two do the same and only used once so no need to have two functions, simplify by merging them. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <5fc8ba0bbf55703014d22dd06ab2f9eabaf370bf.1643117600.git.balato= n@eik.bme.hu> Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ohci.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index 190f5a8aba18..09d07367cc09 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -1725,8 +1725,10 @@ static void ohci_attach(USBPort *port1) } } =20 -static void ohci_async_cancel_device(OHCIState *ohci, USBDevice *dev) +static void ohci_child_detach(USBPort *port1, USBDevice *dev) { + OHCIState *ohci =3D port1->opaque; + if (ohci->async_td && usb_packet_is_inflight(&ohci->usb_packet) && ohci->usb_packet.ep->dev =3D=3D dev) { @@ -1735,20 +1737,13 @@ static void ohci_async_cancel_device(OHCIState *ohc= i, USBDevice *dev) } } =20 -static void ohci_child_detach(USBPort *port1, USBDevice *child) -{ - OHCIState *s =3D port1->opaque; - - ohci_async_cancel_device(s, child); -} - static void ohci_detach(USBPort *port1) { OHCIState *s =3D port1->opaque; OHCIPort *port =3D &s->rhport[port1->index]; uint32_t old_state =3D port->ctrl; =20 - ohci_async_cancel_device(s, port1->dev); + ohci_child_detach(port1, port1->dev); =20 /* set connect status */ if (port->ctrl & OHCI_PORT_CCS) { --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646405261249635.3359174790777; Fri, 4 Mar 2022 06:47:41 -0800 (PST) Received: from localhost ([::1]:54778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9DY-00015F-HH for importer@patchew.org; Fri, 04 Mar 2022 09:47:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38334) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8pX-0001oD-UF for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:22:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42693) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8pW-0000Nz-2L for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:22:51 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-532-sRhndiq5Mumc-xSD2244PA-1; Fri, 04 Mar 2022 09:22:46 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9EFDB1006AA6; Fri, 4 Mar 2022 14:22:44 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B80C779903; Fri, 4 Mar 2022 14:22:34 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 2E7CB180092D; Fri, 4 Mar 2022 15:21:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1MnnL79aZQCXXDFaQnWXnSPY4kihmAYEB3BQdjZSKdA=; b=SziKUfM/RdbzaB1TYklSvjOrsW2iqbmQTcZZInNFlhV3zwKgmjsV3Kch12MCEaZH2jHrCW YJXz3vx8+y3anozhuNF0rhEVs3txubEP37jOLv74r1M46B3F65ufMGYRVtLDYyvLORUSoI lSzW/HEBzHTSoUozO2dHJ85ZpuKDF6E= X-MC-Unique: sRhndiq5Mumc-xSD2244PA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 07/35] usb/ohci: Don't use packet from OHCIState for isochronous transfers Date: Fri, 4 Mar 2022 15:20:55 +0100 Message-Id: <20220304142123.956171-8-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646405287654100001 Content-Type: text/plain; charset="utf-8" From: BALATON Zoltan Since isochronous transfers cannot be handled async (the function returns error in that case) we don't need to remember the packet. Avoid using the usb_packet field in OHCIState (as that can be a waiting async packet on another endpoint) and allocate and use a local USBPacket for the iso transfer instead. After this we don't have to care if we're called from a completion callback or not so we can drop that parameter as well. Signed-off-by: BALATON Zoltan Message-Id: Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ohci.c | 71 +++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index 09d07367cc09..895b29fb8657 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -548,8 +548,7 @@ static int ohci_copy_iso_td(OHCIState *ohci, =20 #define USUB(a, b) ((int16_t)((uint16_t)(a) - (uint16_t)(b))) =20 -static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed, - int completion) +static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed) { int dir; size_t len =3D 0; @@ -559,6 +558,9 @@ static int ohci_service_iso_td(OHCIState *ohci, struct = ohci_ed *ed, int i; USBDevice *dev; USBEndpoint *ep; + USBPacket *pkt; + uint8_t buf[8192]; + bool int_req; struct ohci_iso_td iso_td; uint32_t addr; uint16_t starting_frame; @@ -693,40 +695,42 @@ static int ohci_service_iso_td(OHCIState *ohci, struc= t ohci_ed *ed, } else { len =3D end_addr - start_addr + 1; } - if (len > sizeof(ohci->usb_buf)) { - len =3D sizeof(ohci->usb_buf); + if (len > sizeof(buf)) { + len =3D sizeof(buf); } =20 if (len && dir !=3D OHCI_TD_DIR_IN) { - if (ohci_copy_iso_td(ohci, start_addr, end_addr, ohci->usb_buf, le= n, + if (ohci_copy_iso_td(ohci, start_addr, end_addr, buf, len, DMA_DIRECTION_TO_DEVICE)) { ohci_die(ohci); return 1; } } =20 - if (!completion) { - bool int_req =3D relative_frame_number =3D=3D frame_count && - OHCI_BM(iso_td.flags, TD_DI) =3D=3D 0; - dev =3D ohci_find_device(ohci, OHCI_BM(ed->flags, ED_FA)); - if (dev =3D=3D NULL) { - trace_usb_ohci_td_dev_error(); - return 1; - } - ep =3D usb_ep_get(dev, pid, OHCI_BM(ed->flags, ED_EN)); - usb_packet_setup(&ohci->usb_packet, pid, ep, 0, addr, false, int_r= eq); - usb_packet_addbuf(&ohci->usb_packet, ohci->usb_buf, len); - usb_handle_packet(dev, &ohci->usb_packet); - if (ohci->usb_packet.status =3D=3D USB_RET_ASYNC) { - usb_device_flush_ep_queue(dev, ep); - return 1; - } + dev =3D ohci_find_device(ohci, OHCI_BM(ed->flags, ED_FA)); + if (dev =3D=3D NULL) { + trace_usb_ohci_td_dev_error(); + return 1; } - if (ohci->usb_packet.status =3D=3D USB_RET_SUCCESS) { - ret =3D ohci->usb_packet.actual_length; + ep =3D usb_ep_get(dev, pid, OHCI_BM(ed->flags, ED_EN)); + pkt =3D g_new0(USBPacket, 1); + usb_packet_init(pkt); + int_req =3D relative_frame_number =3D=3D frame_count && + OHCI_BM(iso_td.flags, TD_DI) =3D=3D 0; + usb_packet_setup(pkt, pid, ep, 0, addr, false, int_req); + usb_packet_addbuf(pkt, buf, len); + usb_handle_packet(dev, pkt); + if (pkt->status =3D=3D USB_RET_ASYNC) { + usb_device_flush_ep_queue(dev, ep); + g_free(pkt); + return 1; + } + if (pkt->status =3D=3D USB_RET_SUCCESS) { + ret =3D pkt->actual_length; } else { - ret =3D ohci->usb_packet.status; + ret =3D pkt->status; } + g_free(pkt); =20 trace_usb_ohci_iso_td_so(start_offset, end_offset, start_addr, end_add= r, str, len, ret); @@ -734,7 +738,7 @@ static int ohci_service_iso_td(OHCIState *ohci, struct = ohci_ed *ed, /* Writeback */ if (dir =3D=3D OHCI_TD_DIR_IN && ret >=3D 0 && ret <=3D len) { /* IN transfer succeeded */ - if (ohci_copy_iso_td(ohci, start_addr, end_addr, ohci->usb_buf, re= t, + if (ohci_copy_iso_td(ohci, start_addr, end_addr, buf, ret, DMA_DIRECTION_FROM_DEVICE)) { ohci_die(ohci); return 1; @@ -1057,7 +1061,7 @@ exit_no_retire: } =20 /* Service an endpoint list. Returns nonzero if active TD were found. */ -static int ohci_service_ed_list(OHCIState *ohci, uint32_t head, int comple= tion) +static int ohci_service_ed_list(OHCIState *ohci, uint32_t head) { struct ohci_ed ed; uint32_t next_ed; @@ -1108,8 +1112,9 @@ static int ohci_service_ed_list(OHCIState *ohci, uint= 32_t head, int completion) break; } else { /* Handle isochronous endpoints */ - if (ohci_service_iso_td(ohci, &ed, completion)) + if (ohci_service_iso_td(ohci, &ed)) { break; + } } } =20 @@ -1136,20 +1141,20 @@ static void ohci_sof(OHCIState *ohci) } =20 /* Process Control and Bulk lists. */ -static void ohci_process_lists(OHCIState *ohci, int completion) +static void ohci_process_lists(OHCIState *ohci) { if ((ohci->ctl & OHCI_CTL_CLE) && (ohci->status & OHCI_STATUS_CLF)) { if (ohci->ctrl_cur && ohci->ctrl_cur !=3D ohci->ctrl_head) { trace_usb_ohci_process_lists(ohci->ctrl_head, ohci->ctrl_cur); } - if (!ohci_service_ed_list(ohci, ohci->ctrl_head, completion)) { + if (!ohci_service_ed_list(ohci, ohci->ctrl_head)) { ohci->ctrl_cur =3D 0; ohci->status &=3D ~OHCI_STATUS_CLF; } } =20 if ((ohci->ctl & OHCI_CTL_BLE) && (ohci->status & OHCI_STATUS_BLF)) { - if (!ohci_service_ed_list(ohci, ohci->bulk_head, completion)) { + if (!ohci_service_ed_list(ohci, ohci->bulk_head)) { ohci->bulk_cur =3D 0; ohci->status &=3D ~OHCI_STATUS_BLF; } @@ -1173,7 +1178,7 @@ static void ohci_frame_boundary(void *opaque) int n; =20 n =3D ohci->frame_number & 0x1f; - ohci_service_ed_list(ohci, le32_to_cpu(hcca.intr[n]), 0); + ohci_service_ed_list(ohci, le32_to_cpu(hcca.intr[n])); } =20 /* Cancel all pending packets if either of the lists has been disabled= . */ @@ -1181,7 +1186,7 @@ static void ohci_frame_boundary(void *opaque) ohci_stop_endpoints(ohci); } ohci->old_ctl =3D ohci->ctl; - ohci_process_lists(ohci, 0); + ohci_process_lists(ohci); =20 /* Stop if UnrecoverableError happened or ohci_sof will crash */ if (ohci->intr_status & OHCI_INTR_UE) { @@ -1794,7 +1799,7 @@ static void ohci_async_complete_packet(USBPort *port,= USBPacket *packet) =20 trace_usb_ohci_async_complete(); ohci->async_complete =3D true; - ohci_process_lists(ohci, 1); + ohci_process_lists(ohci); } =20 static USBPortOps ohci_port_ops =3D { --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646406280266596.9304144320378; Fri, 4 Mar 2022 07:04:40 -0800 (PST) Received: from localhost ([::1]:41084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9Tz-0005dE-3h for importer@patchew.org; Fri, 04 Mar 2022 10:04:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8pR-0001RU-4w for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:22:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:30640) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8pP-0000NR-Dg for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:22:44 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-265-IkerpFCIN-qd9s5XcoQH_Q-1; Fri, 04 Mar 2022 09:22:39 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D0B9C801AFE; Fri, 4 Mar 2022 14:22:37 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E32157B616; Fri, 4 Mar 2022 14:22:34 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 40BB0180092E; Fri, 4 Mar 2022 15:21:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CsCFb5CJyI+ZCBU6CBW9Mm7Xi4HwAt4PFtlSY7MXD14=; b=DXizzi9weKafiDjb+0tuqMM5gTnQiniOczNsgxt6VigGduRMhJJK+nqbbZJCbdfccj9RIV +bM+ZP/vfT15rQIT7iaAkrYOLtpbJneAXJ/8GMMcC2Tw2H2+aaAW78HpSyN2nBn/6mraIe eJDgyKoJBE4p9pEMHEMnblMfjZK3z8o= X-MC-Unique: IkerpFCIN-qd9s5XcoQH_Q-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 08/35] audio: replace open-coded buffer arithmetic Date: Fri, 4 Mar 2022 15:20:56 +0100 Message-Id: <20220304142123.956171-9-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646406281044100001 From: Volker R=C3=BCmelin Replace open-coded buffer arithmetic with the new function audio_ring_posb(). That's the position in backward direction of a given point at a given distance. Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Akihiko Odaki Message-Id: <20220301191311.26695-1-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- audio/audio_int.h | 13 +++++++++++++ audio/audio.c | 25 +++++++------------------ audio/coreaudio.c | 10 ++++------ audio/sdlaudio.c | 11 +++++------ 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 428a091d05e5..71be162271b5 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -266,6 +266,19 @@ static inline size_t audio_ring_dist(size_t dst, size_= t src, size_t len) return (dst >=3D src) ? (dst - src) : (len - src + dst); } =20 +/** + * audio_ring_posb() - returns new position in ringbuffer in backward + * direction at given distance + * + * @pos: current position in ringbuffer + * @dist: distance in ringbuffer to walk in reverse direction + * @len: size of ringbuffer + */ +static inline size_t audio_ring_posb(size_t pos, size_t dist, size_t len) +{ + return pos >=3D dist ? pos - dist : len - dist + pos; +} + #define dolog(fmt, ...) AUD_log(AUDIO_CAP, fmt, ## __VA_ARGS__) =20 #ifdef DEBUG diff --git a/audio/audio.c b/audio/audio.c index dc28685d226d..e7a139e28949 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -574,19 +574,13 @@ static size_t audio_pcm_sw_get_rpos_in(SWVoiceIn *sw) { HWVoiceIn *hw =3D sw->hw; ssize_t live =3D hw->total_samples_captured - sw->total_hw_samples_acq= uired; - ssize_t rpos; =20 if (audio_bug(__func__, live < 0 || live > hw->conv_buf->size)) { dolog("live=3D%zu hw->conv_buf->size=3D%zu\n", live, hw->conv_buf-= >size); return 0; } =20 - rpos =3D hw->conv_buf->pos - live; - if (rpos >=3D 0) { - return rpos; - } else { - return hw->conv_buf->size + rpos; - } + return audio_ring_posb(hw->conv_buf->pos, live, hw->conv_buf->size); } =20 static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *buf, size_t size) @@ -1394,12 +1388,10 @@ void audio_generic_run_buffer_in(HWVoiceIn *hw) =20 void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size) { - ssize_t start =3D (ssize_t)hw->pos_emul - hw->pending_emul; + size_t start; =20 - if (start < 0) { - start +=3D hw->size_emul; - } - assert(start >=3D 0 && start < hw->size_emul); + start =3D audio_ring_posb(hw->pos_emul, hw->pending_emul, hw->size_emu= l); + assert(start < hw->size_emul); =20 *size =3D MIN(*size, hw->pending_emul); *size =3D MIN(*size, hw->size_emul - start); @@ -1415,13 +1407,10 @@ void audio_generic_put_buffer_in(HWVoiceIn *hw, voi= d *buf, size_t size) void audio_generic_run_buffer_out(HWVoiceOut *hw) { while (hw->pending_emul) { - size_t write_len, written; - ssize_t start =3D ((ssize_t) hw->pos_emul) - hw->pending_emul; + size_t write_len, written, start; =20 - if (start < 0) { - start +=3D hw->size_emul; - } - assert(start >=3D 0 && start < hw->size_emul); + start =3D audio_ring_posb(hw->pos_emul, hw->pending_emul, hw->size= _emul); + assert(start < hw->size_emul); =20 write_len =3D MIN(hw->pending_emul, hw->size_emul - start); =20 diff --git a/audio/coreaudio.c b/audio/coreaudio.c index d8a21d3e5075..1fdd1d4b14f6 100644 --- a/audio/coreaudio.c +++ b/audio/coreaudio.c @@ -333,12 +333,10 @@ static OSStatus audioDeviceIOProc( =20 len =3D frameCount * hw->info.bytes_per_frame; while (len) { - size_t write_len; - ssize_t start =3D ((ssize_t) hw->pos_emul) - hw->pending_emul; - if (start < 0) { - start +=3D hw->size_emul; - } - assert(start >=3D 0 && start < hw->size_emul); + size_t write_len, start; + + start =3D audio_ring_posb(hw->pos_emul, hw->pending_emul, hw->size= _emul); + assert(start < hw->size_emul); =20 write_len =3D MIN(MIN(hw->pending_emul, len), hw->size_emul - start); diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index c68c62a3e4f1..d6f3aa1a9ac5 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -224,12 +224,11 @@ static void sdl_callback_out(void *opaque, Uint8 *buf= , int len) /* dolog("callback_out: len=3D%d avail=3D%zu\n", len, hw->pending_= emul); */ =20 while (hw->pending_emul && len) { - size_t write_len; - ssize_t start =3D (ssize_t)hw->pos_emul - hw->pending_emul; - if (start < 0) { - start +=3D hw->size_emul; - } - assert(start >=3D 0 && start < hw->size_emul); + size_t write_len, start; + + start =3D audio_ring_posb(hw->pos_emul, hw->pending_emul, + hw->size_emul); + assert(start < hw->size_emul); =20 write_len =3D MIN(MIN(hw->pending_emul, len), hw->size_emul - start); --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164640645533631.713040410707663; Fri, 4 Mar 2022 07:07:35 -0800 (PST) Received: from localhost ([::1]:49660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9Wo-000306-64 for importer@patchew.org; Fri, 04 Mar 2022 10:07:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8pb-00022h-Or for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:22:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:38210) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8pa-0000OW-6U for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:22:55 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-401-dudPXEZhMzy2b-byXEeBKg-1; Fri, 04 Mar 2022 09:22:50 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E923F1854E26; Fri, 4 Mar 2022 14:22:48 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7195A808BD; Fri, 4 Mar 2022 14:22:39 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 50CE51800930; Fri, 4 Mar 2022 15:21:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403773; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l3yjkI+OFuK6ktDSGxqhnf8/yPH5EcnYhM1aCcC7f1U=; b=L7Lii6fkTsY/IEqC2dLZBzGxulY2VjPQYybHS5cBSXMuE7x6YsGMIJ0VCIlTxHjkzxb2OY gvf7XcI/trr8i0li/28f6ITsicjuOSqZUvKXNa0qDCJCZiPYp2SkAreWm8eFcxspbNf30Q 5boc/ATmoVjb9Rr7qkmMSoD+zZRTmyQ= X-MC-Unique: dudPXEZhMzy2b-byXEeBKg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 09/35] audio: move function audio_pcm_hw_clip_out() Date: Fri, 4 Mar 2022 15:20:57 +0100 Message-Id: <20220304142123.956171-10-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646406456191100001 From: Volker R=C3=BCmelin Move the function audio_pcm_hw_clip_out() into the correct section 'Hard voice (playback)'. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Volker R=C3=BCmelin Message-Id: <20220301191311.26695-2-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- audio/audio.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index e7a139e28949..dfd32912da48 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -548,25 +548,6 @@ static size_t audio_pcm_hw_get_live_in(HWVoiceIn *hw) return live; } =20 -static void audio_pcm_hw_clip_out(HWVoiceOut *hw, void *pcm_buf, size_t le= n) -{ - size_t clipped =3D 0; - size_t pos =3D hw->mix_buf->pos; - - while (len) { - st_sample *src =3D hw->mix_buf->samples + pos; - uint8_t *dst =3D advance(pcm_buf, clipped * hw->info.bytes_per_fra= me); - size_t samples_till_end_of_buf =3D hw->mix_buf->size - pos; - size_t samples_to_clip =3D MIN(len, samples_till_end_of_buf); - - hw->clip(dst, src, samples_to_clip); - - pos =3D (pos + samples_to_clip) % hw->mix_buf->size; - len -=3D samples_to_clip; - clipped +=3D samples_to_clip; - } -} - /* * Soft voice (capture) */ @@ -677,6 +658,25 @@ static size_t audio_pcm_hw_get_live_out (HWVoiceOut *h= w, int *nb_live) return 0; } =20 +static void audio_pcm_hw_clip_out(HWVoiceOut *hw, void *pcm_buf, size_t le= n) +{ + size_t clipped =3D 0; + size_t pos =3D hw->mix_buf->pos; + + while (len) { + st_sample *src =3D hw->mix_buf->samples + pos; + uint8_t *dst =3D advance(pcm_buf, clipped * hw->info.bytes_per_fra= me); + size_t samples_till_end_of_buf =3D hw->mix_buf->size - pos; + size_t samples_to_clip =3D MIN(len, samples_till_end_of_buf); + + hw->clip(dst, src, samples_to_clip); + + pos =3D (pos + samples_to_clip) % hw->mix_buf->size; + len -=3D samples_to_clip; + clipped +=3D samples_to_clip; + } +} + /* * Soft voice (playback) */ --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646405766056162.5307675871428; Fri, 4 Mar 2022 06:56:06 -0800 (PST) Received: from localhost ([::1]:47924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9Lh-0007Q4-1U for importer@patchew.org; Fri, 04 Mar 2022 09:56:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8pd-0002At-TE for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:22:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:60450) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8pc-0000Ok-Bs for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:22:57 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-107-6cxZujNaPuOOk1XqWPbP6Q-1; Fri, 04 Mar 2022 09:22:50 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E16901854E21; Fri, 4 Mar 2022 14:22:48 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4837483092; Fri, 4 Mar 2022 14:22:46 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 5CE2D1800934; Fri, 4 Mar 2022 15:21:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403775; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1CIrGEnX/ivFjkEyndIGbmi18SsTsrHcjbfXWxVknGo=; b=D0To/mt6yUQP+47yLqs27LWBr3YJdTzh4+8BVN4sEoetaudZUVPna2ggOfpMdnB5yD7j+c fO8KG0a7aceHa52e1ESpB2/ozqnDIqGNWWr1fnLOqhMVuLYoE9e46XECv+U/tvJegFaZ3i /0LPsrD3XG6vgF8UUBsd6kWvKSORFU4= X-MC-Unique: 6cxZujNaPuOOk1XqWPbP6Q-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 10/35] audio: add function audio_pcm_hw_conv_in() Date: Fri, 4 Mar 2022 15:20:58 +0100 Message-Id: <20220304142123.956171-11-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646405767447100001 From: Volker R=C3=BCmelin Add a function audio_pcm_hw_conv_in() similar to the existing counterpart function audio_pcm_hw_clip_out(). This function reduces the number of calls to the pcm_ops functions get_buffer_in() and put_buffer_in(). That's one less call to get_buffer_in() and put_buffer_in() every time the conv_buffer wraps around. Signed-off-by: Volker R=C3=BCmelin Message-Id: <20220301191311.26695-3-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- audio/audio.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index dfd32912da48..f28e91853f0b 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -548,6 +548,24 @@ static size_t audio_pcm_hw_get_live_in(HWVoiceIn *hw) return live; } =20 +static size_t audio_pcm_hw_conv_in(HWVoiceIn *hw, void *pcm_buf, size_t sa= mples) +{ + size_t conv =3D 0; + STSampleBuffer *conv_buf =3D hw->conv_buf; + + while (samples) { + uint8_t *src =3D advance(pcm_buf, conv * hw->info.bytes_per_frame); + size_t proc =3D MIN(samples, conv_buf->size - conv_buf->pos); + + hw->conv(conv_buf->samples + conv_buf->pos, src, proc); + conv_buf->pos =3D (conv_buf->pos + proc) % conv_buf->size; + samples -=3D proc; + conv +=3D proc; + } + + return conv; +} + /* * Soft voice (capture) */ @@ -1219,7 +1237,6 @@ static void audio_run_out (AudioState *s) static size_t audio_pcm_hw_run_in(HWVoiceIn *hw, size_t samples) { size_t conv =3D 0; - STSampleBuffer *conv_buf =3D hw->conv_buf; =20 if (hw->pcm_ops->run_buffer_in) { hw->pcm_ops->run_buffer_in(hw); @@ -1235,11 +1252,7 @@ static size_t audio_pcm_hw_run_in(HWVoiceIn *hw, siz= e_t samples) break; } =20 - proc =3D MIN(size / hw->info.bytes_per_frame, - conv_buf->size - conv_buf->pos); - - hw->conv(conv_buf->samples + conv_buf->pos, buf, proc); - conv_buf->pos =3D (conv_buf->pos + proc) % conv_buf->size; + proc =3D audio_pcm_hw_conv_in(hw, buf, size / hw->info.bytes_per_f= rame); =20 samples -=3D proc; conv +=3D proc; --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646406638647738.6490550252553; Fri, 4 Mar 2022 07:10:38 -0800 (PST) Received: from localhost ([::1]:58164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9Zk-0000MD-7H for importer@patchew.org; Fri, 04 Mar 2022 10:10:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8q1-0003Qx-Hh for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:23:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54610) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8q0-0000QS-2C for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:23:21 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-149-fVl6hZg7PI2fmbpbutFURA-1; Fri, 04 Mar 2022 09:23:13 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3C0A71006AA5; Fri, 4 Mar 2022 14:23:08 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC24B866EF; Fri, 4 Mar 2022 14:22:50 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 68E761800935; Fri, 4 Mar 2022 15:21:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403798; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6x9q7bDR9PBKD4SHJYTDYhwfGMRNMDWp2mG2twanq5U=; b=EPAXGYVAxpYGIYHWZFjdz50c8Dv5MiBIYgc2DGNiBSRZzoB3PAxk57isr1L4iQHHfssVie sePV/KMMlCJAyYcMysDwmtcpUtMyVjK4f0459HPuB6AoDLVlmbbgYNw8ELoaZ16dTH52wx xp6mJ5KpiuwCYjB0kMtl4e6HA0Q74hw= X-MC-Unique: fVl6hZg7PI2fmbpbutFURA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 11/35] audio: inline function audio_pcm_sw_get_rpos_in() Date: Fri, 4 Mar 2022 15:20:59 +0100 Message-Id: <20220304142123.956171-12-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646406640148100001 From: Volker R=C3=BCmelin Simplify code by inlining function audio_pcm_sw_get_rpos_in() at the only call site and remove the duplicated audio_bug() test. Signed-off-by: Volker R=C3=BCmelin Message-Id: <20220301191311.26695-4-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- audio/audio.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index f28e91853f0b..35437986d9dd 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -569,37 +569,24 @@ static size_t audio_pcm_hw_conv_in(HWVoiceIn *hw, voi= d *pcm_buf, size_t samples) /* * Soft voice (capture) */ -static size_t audio_pcm_sw_get_rpos_in(SWVoiceIn *sw) -{ - HWVoiceIn *hw =3D sw->hw; - ssize_t live =3D hw->total_samples_captured - sw->total_hw_samples_acq= uired; - - if (audio_bug(__func__, live < 0 || live > hw->conv_buf->size)) { - dolog("live=3D%zu hw->conv_buf->size=3D%zu\n", live, hw->conv_buf-= >size); - return 0; - } - - return audio_ring_posb(hw->conv_buf->pos, live, hw->conv_buf->size); -} - static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *buf, size_t size) { HWVoiceIn *hw =3D sw->hw; size_t samples, live, ret =3D 0, swlim, isamp, osamp, rpos, total =3D = 0; struct st_sample *src, *dst =3D sw->buf; =20 - rpos =3D audio_pcm_sw_get_rpos_in(sw) % hw->conv_buf->size; - live =3D hw->total_samples_captured - sw->total_hw_samples_acquired; - if (audio_bug(__func__, live > hw->conv_buf->size)) { - dolog("live_in=3D%zu hw->conv_buf->size=3D%zu\n", live, hw->conv_b= uf->size); - return 0; - } - - samples =3D size / sw->info.bytes_per_frame; if (!live) { return 0; } + if (audio_bug(__func__, live > hw->conv_buf->size)) { + dolog("live_in=3D%zu hw->conv_buf->size=3D%zu\n", live, hw->conv_b= uf->size); + return 0; + } + + rpos =3D audio_ring_posb(hw->conv_buf->pos, live, hw->conv_buf->size); + + samples =3D size / sw->info.bytes_per_frame; =20 swlim =3D (live * sw->ratio) >> 32; swlim =3D MIN (swlim, samples); --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646405529041358.18662053682203; Fri, 4 Mar 2022 06:52:09 -0800 (PST) Received: from localhost ([::1]:37536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9Hr-0000PW-Jl for importer@patchew.org; Fri, 04 Mar 2022 09:52:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38406) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8pk-0002ZT-IB for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:23:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48863) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8pj-0000PF-4I for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:23:04 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-590-m8MJbeduMQS3CU0IxTO7FA-1; Fri, 04 Mar 2022 09:23:01 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3403A1854E27; Fri, 4 Mar 2022 14:22:59 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CFDE22ED81; Fri, 4 Mar 2022 14:22:50 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 74B231800937; Fri, 4 Mar 2022 15:21:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403782; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QM4SxWKptiEN0lpRGR0RN07jbGnJmBLPK7wOIAq9Uiw=; b=ECKSqmjpg7c6qIy1MuVQdN01NE8r4OBx8naTTW0Z4VOHnB5UGiFFsE4XXLAMIvIqyB3Ju/ eysk/Ynb3SXDeYDPGPiMJurlf0ntbbScPCzHE7OHVwy4J2LvP5uqQ65k598L6mG4M4sZMy J40bMTNiFv1tNxVqnfB8tFW5cCfURfk= X-MC-Unique: m8MJbeduMQS3CU0IxTO7FA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 12/35] paaudio: increase default latency to 46ms Date: Fri, 4 Mar 2022 15:21:00 +0100 Message-Id: <20220304142123.956171-13-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646405531263100001 From: Volker R=C3=BCmelin This is a patch to improve the pulseaudio playback experience. Asking pulseaudio for a playback latency of 15ms is quite demanding. Increase this to 46ms. The total playback latency now is 31ms larger. One of the next patches will reduce the total playback latency again by more than 46ms. Here is a quote from the PulseAudio Latency Control documentation: 'For the sake of (...) drop-out safety always make sure to pick the highest latency possible that fulfills your needs.' Signed-off-by: Volker R=C3=BCmelin Message-Id: <20220301191311.26695-5-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- audio/paaudio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index 75401d53910a..9df1e69c086f 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -744,7 +744,7 @@ static int qpa_validate_per_direction_opts(Audiodev *de= v, { if (!pdo->has_latency) { pdo->has_latency =3D true; - pdo->latency =3D 15000; + pdo->latency =3D 46440; } return 1; } --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646405703487593.8417203577679; Fri, 4 Mar 2022 06:55:03 -0800 (PST) Received: from localhost ([::1]:46146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9Kg-0006Df-H7 for importer@patchew.org; Fri, 04 Mar 2022 09:55:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8q7-0003WB-AX for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:23:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:33758) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8q5-0000Qz-Op for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:23:27 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-657-RwRfK_keOGyvM9Ib7DhQbw-1; Fri, 04 Mar 2022 09:23:23 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7D9D1FC82; Fri, 4 Mar 2022 14:23:14 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D196A1057067; Fri, 4 Mar 2022 14:23:00 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 80DAE18009A6; Fri, 4 Mar 2022 15:21:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403804; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dY25QO2U7eTGMKgXp39n5WX1s4kU4FSW2pfPZLBSlYA=; b=TFojBndehabOOhceKyICJPJq1PFxBoexVJ499SeVRxjn0x6UYaidUFO/4yfUlqaVXFzbEn 1aCxFXA7UneHytWrARE4NWeToQLCN7cZgM4Auu4zL3C1SmcfrT1H4XnoRmpqlsdNB8kDuk YZD/QR4XJVCWdZDvxxZ9OtwrGufBqC8= X-MC-Unique: RwRfK_keOGyvM9Ib7DhQbw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 13/35] jackaudio: use more jack audio buffers Date: Fri, 4 Mar 2022 15:21:01 +0100 Message-Id: <20220304142123.956171-14-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646405704962100001 From: Volker R=C3=BCmelin The next patch reduces the effective qemu playback buffer size by timer-period. Increase the number of jack audio buffers by one to preserve the total effective buffer size. The size of one jack audio buffer is 512 samples. With audio defaults that's 512 samples / 44100 samples/s =3D 11.6 ms and only slightly larger than the timer-period of 10 ms. The larger jack audio buffer increases audio dropout safety, because the high priority jack-audio worker threads can provide audio data for a longer period of time as with a smaller buffer and more audio data in the mixing engine buffer that they can't access. Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Christian Schoenebeck Message-Id: <20220301191311.26695-6-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- audio/jackaudio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/jackaudio.c b/audio/jackaudio.c index 317009e93660..26246c3a8b43 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -483,8 +483,8 @@ static int qjack_client_init(QJackClient *c) c->buffersize =3D 512; } =20 - /* create a 2 period buffer */ - qjack_buffer_create(&c->fifo, c->nchannels, c->buffersize * 2); + /* create a 3 period buffer */ + qjack_buffer_create(&c->fifo, c->nchannels, c->buffersize * 3); =20 qjack_client_connect_ports(c); c->state =3D QJACK_STATE_RUNNING; --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646406083461689.7389649560728; Fri, 4 Mar 2022 07:01:23 -0800 (PST) Received: from localhost ([::1]:60350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9Qo-0007ec-CI for importer@patchew.org; Fri, 04 Mar 2022 10:01:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8q9-0003Zz-IG for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:23:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:50552) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8q7-0000Rb-UX for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:23:29 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-609-VAoaOAaDMlqg_yYu2SVtXA-1; Fri, 04 Mar 2022 09:23:26 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 79A0E835DE1; Fri, 4 Mar 2022 14:23:14 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D994B1057059; Fri, 4 Mar 2022 14:23:09 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 8D22618009A7; Fri, 4 Mar 2022 15:21:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403807; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ui4CfxKhlynO4qirwjH9anS0yn4WvwIgkFz+4TC0svE=; b=MrQWT+ZJ9HDBzPZ2fkhW944PtxTARs5izxkM8nSE6kedH0iHicA4sPIGKmccwf1dNUt8ug 8suxyq/KG5J4QEogwkW5E8eh60klqHAX8vFOPSHXvbcuJN/2Eq/E0vBI9bfk6whuI4yADQ qrd0wYCp7TH41r96FevVBExzCVafJ4I= X-MC-Unique: VAoaOAaDMlqg_yYu2SVtXA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 14/35] audio: copy playback stream in sequential order Date: Fri, 4 Mar 2022 15:21:02 +0100 Message-Id: <20220304142123.956171-15-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646406084986100001 From: Volker R=C3=BCmelin Change the code to copy the playback stream in sequential order. The advantage can be seen in the next patches where the stream copy operation effectively becomes a write through operation. The following diagram shows the average buffer fill level and the stream copy sequence. ### represents a timer_period sized chunk. The rest of the buffer sizes are not to scale. With current code: |--------| |#####111| |---#####| sw->buf mix_buf backend buffer 1. clip |--------| |---#####| |111##222| sw->buf mix_buf backend buffer 2. write to audio device 333 -> |--------| |---#####| |---111##| -> 222 sw->buf mix_buf backend buffer 3a. sw device write |-----333| |---#####| |---111##| sw->buf mix_buf backend buffer 3b. resample and mix |--------| |333#####| |---111##| sw->buf mix_buf backend buffer With this patch: 111 -> |--------| |---#####| |---#####| sw->buf mix_buf backend buffer 1a: sw device write |-----111| |---#####| |---#####| sw->buf mix_buf backend buffer 1b. resample and mix |--------| |111##222| |---#####| sw->buf mix_buf backend buffer 2. clip |--------| |---111##| |222##333| sw->buf mix_buf backend buffer 3. write to audio device |--------| |---111##| |---222##| -> 333 sw->buf mix_buf backend buffer The effective total playback buffer size is reduced by timer_period. Signed-off-by: Volker R=C3=BCmelin Message-Id: <20220301191311.26695-7-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- audio/audio.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 35437986d9dd..9e2d7fb20978 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1134,6 +1134,15 @@ static void audio_run_out (AudioState *s) size_t played, live, prev_rpos, free; int nb_live; =20 + for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { + if (sw->active) { + free =3D audio_get_free(sw); + if (free > 0) { + sw->callback.fn(sw->callback.opaque, free); + } + } + } + live =3D audio_pcm_hw_get_live_out (hw, &nb_live); if (!nb_live) { live =3D 0; @@ -1162,14 +1171,6 @@ static void audio_run_out (AudioState *s) } =20 if (!live) { - for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_ne= xt) { - if (sw->active) { - free =3D audio_get_free (sw); - if (free > 0) { - sw->callback.fn (sw->callback.opaque, free); - } - } - } if (hw->pcm_ops->run_buffer_out) { hw->pcm_ops->run_buffer_out(hw); } @@ -1210,13 +1211,6 @@ static void audio_run_out (AudioState *s) if (!sw->total_hw_samples_mixed) { sw->empty =3D 1; } - - if (sw->active) { - free =3D audio_get_free (sw); - if (free > 0) { - sw->callback.fn (sw->callback.opaque, free); - } - } } } } --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646406263583337.45140046805204; Fri, 4 Mar 2022 07:04:23 -0800 (PST) Received: from localhost ([::1]:40722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9Ti-0005PA-9b for importer@patchew.org; Fri, 04 Mar 2022 10:04:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38568) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8qA-0003c3-Eb for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:23:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:21735) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8q8-0000SA-W2 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:23:30 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-217-gMzJTrmhOb63v7690aCd1g-1; Fri, 04 Mar 2022 09:23:25 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A79AB1854E27; Fri, 4 Mar 2022 14:23:19 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2648D866E9; Fri, 4 Mar 2022 14:23:16 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 9909018009A8; Fri, 4 Mar 2022 15:21:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403808; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h9koEPAs6esAu6q4l+So46UIpGwvLZt3TuFSjDnyUjc=; b=i3x00759qljRrt1SvIVlsxih/7DtMAJBnKo+6DGtzWDgfgvkIR+8DTN3zQgwGmrpFY+uCf 5xj3dDC2v+3dH5Z8FBXlxsIHtrrjqzrQ+j69jn7wiavgf//WDvEscErebKvSCqIrf38uuf xJoQiGeg3Ucn81w4w/gD1tzl5+7OP1E= X-MC-Unique: gMzJTrmhOb63v7690aCd1g-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 15/35] audio: add pcm_ops function table for capture backend Date: Fri, 4 Mar 2022 15:21:03 +0100 Message-Id: <20220304142123.956171-16-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646406265235100001 From: Volker R=C3=BCmelin Add a pcm_ops function table for the capture backend. This avoids additional code in the next patches to test if the pcm_ops table is available. Signed-off-by: Volker R=C3=BCmelin Message-Id: <20220301191311.26695-8-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- audio/audio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/audio/audio.c b/audio/audio.c index 9e2d7fb20978..55f885f8e9cf 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1804,6 +1804,7 @@ void AUD_remove_card (QEMUSoundCard *card) g_free (card->name); } =20 +static struct audio_pcm_ops capture_pcm_ops; =20 CaptureVoiceOut *AUD_add_capture( AudioState *s, @@ -1849,6 +1850,7 @@ CaptureVoiceOut *AUD_add_capture( =20 hw =3D &cap->hw; hw->s =3D s; + hw->pcm_ops =3D &capture_pcm_ops; QLIST_INIT (&hw->sw_head); QLIST_INIT (&cap->cb_head); =20 --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646406797504616.5671649806475; Fri, 4 Mar 2022 07:13:17 -0800 (PST) Received: from localhost ([::1]:38638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9cK-0006KI-Gp for importer@patchew.org; Fri, 04 Mar 2022 10:13:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8qJ-00043n-GI for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:23:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39780) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8qH-0000Ty-Ui for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:23:39 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-178-2WE27digNReB00JcLDunLw-1; Fri, 04 Mar 2022 09:23:33 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E6D10801AFE; Fri, 4 Mar 2022 14:23:31 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 282CB7A525; Fri, 4 Mar 2022 14:23:16 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id A50D418009AA; Fri, 4 Mar 2022 15:21:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403816; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZtW+dPwkd4OdT/Zpa2fY3A7LD1PtcBH5jmip8WSVPyo=; b=ZIVvUu3T9g7ZgxzY50rwIM6qi8FHgv94trtROMRgKsAHFf/0Do9wBWlYao88tVEI7s/edt WPGlNMi8Krtg4Xa+UV51GiPGddT0WRPr6T+UVxqhsODxG8qEvo4KK0348n97Pk8R/Ai+G5 JQxXmgPT56eXhkzJ52lo/jBopJthlUY= X-MC-Unique: 2WE27digNReB00JcLDunLw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 16/35] Revert "audio: fix wavcapture segfault" Date: Fri, 4 Mar 2022 15:21:04 +0100 Message-Id: <20220304142123.956171-17-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646406799572100001 From: Volker R=C3=BCmelin This reverts commit cbaf25d1f59ee13fc7542a06ea70784f2e000c04. Since previous commit every audio backend has a pcm_ops function table. It's no longer necessary to test if the table is available. Signed-off-by: Volker R=C3=BCmelin Message-Id: <20220301191311.26695-9-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- audio/audio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 55f885f8e9cf..c420a8bd1c4a 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -612,7 +612,7 @@ static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *bu= f, size_t size) total +=3D isamp; } =20 - if (hw->pcm_ops && !hw->pcm_ops->volume_in) { + if (!hw->pcm_ops->volume_in) { mixeng_volume (sw->buf, ret, &sw->vol); } =20 @@ -718,7 +718,7 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *= buf, size_t size) if (swlim) { sw->conv (sw->buf, buf, swlim); =20 - if (sw->hw->pcm_ops && !sw->hw->pcm_ops->volume_out) { + if (!sw->hw->pcm_ops->volume_out) { mixeng_volume (sw->buf, swlim, &sw->vol); } } --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646405984317180.6860546266729; Fri, 4 Mar 2022 06:59:44 -0800 (PST) Received: from localhost ([::1]:56516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9PD-0004y7-9e for importer@patchew.org; Fri, 04 Mar 2022 09:59:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8qO-0004HA-Gb for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:23:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36717) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8qL-0000UJ-Qk for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:23:43 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-564-ePe8unDWNIiIkPLRZzj-TA-1; Fri, 04 Mar 2022 09:23:38 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0926801AFE; Fri, 4 Mar 2022 14:23:36 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4FA802ED75; Fri, 4 Mar 2022 14:23:21 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C15CB18009AB; Fri, 4 Mar 2022 15:21:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403821; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6b57T3LPzo27SGRnrAK7g8DDPQK5CvyyGhlbIQ2i89E=; b=QAO3rYBMuDuRuwrxwsgvUz9k+7+IxLUas5HYNpWb02Oba4Ch/G0MbWltzsU1vNGA2gzkS4 xAGye2FjvoNy3ivzDFbFo3hzHIrEVU8nWAmoiBooUV5Q8g6bzK14elyce6UkTAJiu76F5s rr4xjr+h8xd0WXE/+8Ym0pS2r1BmFlk= X-MC-Unique: ePe8unDWNIiIkPLRZzj-TA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 17/35] audio: restore mixing-engine playback buffer size Date: Fri, 4 Mar 2022 15:21:05 +0100 Message-Id: <20220304142123.956171-18-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646405985418100001 From: Volker R=C3=BCmelin Commit ff095e5231 "audio: api for mixeng code free backends" introduced another FIFO for the audio subsystem with exactly the same size as the mixing-engine FIFO. Most audio backends use this generic FIFO. The generic FIFO used together with the mixing-engine FIFO doubles the audio FIFO size, because that's just two independent FIFOs connected together in series. For audio playback this nearly doubles the playback latency. This patch restores the effective mixing-engine playback buffer size to a pre v4.2.0 size by only accepting the amount of samples for the mixing-engine queue which the downstream queue accepts. Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Akihiko Odaki Message-Id: <20220301191311.26695-10-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- audio/audio_int.h | 7 ++++- audio/alsaaudio.c | 1 + audio/audio.c | 69 +++++++++++++++++++++++++++++++++++------------ audio/coreaudio.c | 3 +++ audio/jackaudio.c | 1 + audio/noaudio.c | 1 + audio/ossaudio.c | 12 +++++++++ audio/sdlaudio.c | 3 +++ audio/wavaudio.c | 1 + 9 files changed, 80 insertions(+), 18 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 71be162271b5..2a6914d2aa65 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -161,10 +161,14 @@ struct audio_pcm_ops { void (*fini_out)(HWVoiceOut *hw); size_t (*write) (HWVoiceOut *hw, void *buf, size_t size); void (*run_buffer_out)(HWVoiceOut *hw); + /* + * Get the free output buffer size. This is an upper limit. The size + * returned by function get_buffer_out may be smaller. + */ + size_t (*buffer_get_free)(HWVoiceOut *hw); /* * get a buffer that after later can be passed to put_buffer_out; opti= onal * returns the buffer, and writes it's size to size (in bytes) - * this is unrelated to the above buffer_size_out function */ void *(*get_buffer_out)(HWVoiceOut *hw, size_t *size); /* @@ -190,6 +194,7 @@ void audio_generic_run_buffer_in(HWVoiceIn *hw); void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size); void audio_generic_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size); void audio_generic_run_buffer_out(HWVoiceOut *hw); +size_t audio_generic_buffer_get_free(HWVoiceOut *hw); void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size); size_t audio_generic_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size= ); size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size); diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 2b9789e64771..b04716a6cc21 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -916,6 +916,7 @@ static struct audio_pcm_ops alsa_pcm_ops =3D { .init_out =3D alsa_init_out, .fini_out =3D alsa_fini_out, .write =3D alsa_write, + .buffer_get_free =3D audio_generic_buffer_get_free, .run_buffer_out =3D audio_generic_run_buffer_out, .enable_out =3D alsa_enable_out, =20 diff --git a/audio/audio.c b/audio/audio.c index c420a8bd1c4a..a88572e71388 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -663,6 +663,12 @@ static size_t audio_pcm_hw_get_live_out (HWVoiceOut *h= w, int *nb_live) return 0; } =20 +static size_t audio_pcm_hw_get_free(HWVoiceOut *hw) +{ + return (hw->pcm_ops->buffer_get_free ? hw->pcm_ops->buffer_get_free(hw= ) : + INT_MAX) / hw->info.bytes_per_frame; +} + static void audio_pcm_hw_clip_out(HWVoiceOut *hw, void *pcm_buf, size_t le= n) { size_t clipped =3D 0; @@ -687,7 +693,8 @@ static void audio_pcm_hw_clip_out(HWVoiceOut *hw, void = *pcm_buf, size_t len) */ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *buf, size_t size) { - size_t hwsamples, samples, isamp, osamp, wpos, live, dead, left, swlim= , blck; + size_t hwsamples, samples, isamp, osamp, wpos, live, dead, left, blck; + size_t hw_free; size_t ret =3D 0, pos =3D 0, total =3D 0; =20 if (!sw) { @@ -710,27 +717,28 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void= *buf, size_t size) } =20 wpos =3D (sw->hw->mix_buf->pos + live) % hwsamples; - samples =3D size / sw->info.bytes_per_frame; =20 dead =3D hwsamples - live; - swlim =3D ((int64_t) dead << 32) / sw->ratio; - swlim =3D MIN (swlim, samples); - if (swlim) { - sw->conv (sw->buf, buf, swlim); + hw_free =3D audio_pcm_hw_get_free(sw->hw); + hw_free =3D hw_free > live ? hw_free - live : 0; + samples =3D ((int64_t)MIN(dead, hw_free) << 32) / sw->ratio; + samples =3D MIN(samples, size / sw->info.bytes_per_frame); + if (samples) { + sw->conv(sw->buf, buf, samples); =20 if (!sw->hw->pcm_ops->volume_out) { - mixeng_volume (sw->buf, swlim, &sw->vol); + mixeng_volume(sw->buf, samples, &sw->vol); } } =20 - while (swlim) { + while (samples) { dead =3D hwsamples - live; left =3D hwsamples - wpos; blck =3D MIN (dead, left); if (!blck) { break; } - isamp =3D swlim; + isamp =3D samples; osamp =3D blck; st_rate_flow_mix ( sw->rate, @@ -740,7 +748,7 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *= buf, size_t size) &osamp ); ret +=3D isamp; - swlim -=3D isamp; + samples -=3D isamp; pos +=3D isamp; live +=3D osamp; wpos =3D (wpos + osamp) % hwsamples; @@ -1002,6 +1010,11 @@ static size_t audio_get_avail (SWVoiceIn *sw) return (((int64_t) live << 32) / sw->ratio) * sw->info.bytes_per_frame; } =20 +static size_t audio_sw_bytes_free(SWVoiceOut *sw, size_t free) +{ + return (((int64_t)free << 32) / sw->ratio) * sw->info.bytes_per_frame; +} + static size_t audio_get_free(SWVoiceOut *sw) { size_t live, dead; @@ -1021,13 +1034,11 @@ static size_t audio_get_free(SWVoiceOut *sw) dead =3D sw->hw->mix_buf->size - live; =20 #ifdef DEBUG_OUT - dolog ("%s: get_free live %zu dead %zu ret %" PRId64 "\n", - SW_NAME (sw), - live, dead, (((int64_t) dead << 32) / sw->ratio) * - sw->info.bytes_per_frame); + dolog("%s: get_free live %zu dead %zu sw_bytes %zu\n", + SW_NAME(sw), live, dead, audio_sw_bytes_free(sw, dead)); #endif =20 - return (((int64_t) dead << 32) / sw->ratio) * sw->info.bytes_per_frame; + return dead; } =20 static void audio_capture_mix_and_clear(HWVoiceOut *hw, size_t rpos, @@ -1131,12 +1142,21 @@ static void audio_run_out (AudioState *s) } =20 while ((hw =3D audio_pcm_hw_find_any_enabled_out(s, hw))) { - size_t played, live, prev_rpos, free; + size_t played, live, prev_rpos; + size_t hw_free =3D audio_pcm_hw_get_free(hw); int nb_live; =20 for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { if (sw->active) { - free =3D audio_get_free(sw); + size_t sw_free =3D audio_get_free(sw); + size_t free; + + if (hw_free > sw->total_hw_samples_mixed) { + free =3D audio_sw_bytes_free(sw, + MIN(sw_free, hw_free - sw->total_hw_samples_mixed)= ); + } else { + free =3D 0; + } if (free > 0) { sw->callback.fn(sw->callback.opaque, free); } @@ -1398,6 +1418,15 @@ void audio_generic_put_buffer_in(HWVoiceIn *hw, void= *buf, size_t size) hw->pending_emul -=3D size; } =20 +size_t audio_generic_buffer_get_free(HWVoiceOut *hw) +{ + if (hw->buf_emul) { + return hw->size_emul - hw->pending_emul; + } else { + return hw->samples * hw->info.bytes_per_frame; + } +} + void audio_generic_run_buffer_out(HWVoiceOut *hw) { while (hw->pending_emul) { @@ -1445,6 +1474,12 @@ size_t audio_generic_write(HWVoiceOut *hw, void *buf= , size_t size) { size_t total =3D 0; =20 + if (hw->pcm_ops->buffer_get_free) { + size_t free =3D hw->pcm_ops->buffer_get_free(hw); + + size =3D MIN(size, free); + } + while (total < size) { size_t dst_size =3D size - total; size_t copy_size, proc; diff --git a/audio/coreaudio.c b/audio/coreaudio.c index 1fdd1d4b14f6..91ea6ae975e5 100644 --- a/audio/coreaudio.c +++ b/audio/coreaudio.c @@ -283,6 +283,7 @@ static int coreaudio_buf_unlock (coreaudioVoiceOut *cor= e, const char *fn_name) coreaudio_buf_unlock(core, "coreaudio_" #name); \ return ret; \ } +COREAUDIO_WRAPPER_FUNC(buffer_get_free, size_t, (HWVoiceOut *hw), (hw)) COREAUDIO_WRAPPER_FUNC(get_buffer_out, void *, (HWVoiceOut *hw, size_t *si= ze), (hw, size)) COREAUDIO_WRAPPER_FUNC(put_buffer_out, size_t, @@ -652,6 +653,8 @@ static struct audio_pcm_ops coreaudio_pcm_ops =3D { .fini_out =3D coreaudio_fini_out, /* wrapper for audio_generic_write */ .write =3D coreaudio_write, + /* wrapper for audio_generic_buffer_get_free */ + .buffer_get_free =3D coreaudio_buffer_get_free, /* wrapper for audio_generic_get_buffer_out */ .get_buffer_out =3D coreaudio_get_buffer_out, /* wrapper for audio_generic_put_buffer_out */ diff --git a/audio/jackaudio.c b/audio/jackaudio.c index 26246c3a8b43..bf757250b597 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -652,6 +652,7 @@ static struct audio_pcm_ops jack_pcm_ops =3D { .init_out =3D qjack_init_out, .fini_out =3D qjack_fini_out, .write =3D qjack_write, + .buffer_get_free =3D audio_generic_buffer_get_free, .run_buffer_out =3D audio_generic_run_buffer_out, .enable_out =3D qjack_enable_out, =20 diff --git a/audio/noaudio.c b/audio/noaudio.c index aac87dbc93fb..84a6bfbb1c87 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -118,6 +118,7 @@ static struct audio_pcm_ops no_pcm_ops =3D { .init_out =3D no_init_out, .fini_out =3D no_fini_out, .write =3D no_write, + .buffer_get_free =3D audio_generic_buffer_get_free, .run_buffer_out =3D audio_generic_run_buffer_out, .enable_out =3D no_enable_out, =20 diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 60eff66424b9..1bd680084065 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -389,6 +389,17 @@ static void oss_run_buffer_out(HWVoiceOut *hw) } } =20 +static size_t oss_buffer_get_free(HWVoiceOut *hw) +{ + OSSVoiceOut *oss =3D (OSSVoiceOut *)hw; + + if (oss->mmapped) { + return INT_MAX; + } else { + return audio_generic_buffer_get_free(hw); + } +} + static void *oss_get_buffer_out(HWVoiceOut *hw, size_t *size) { OSSVoiceOut *oss =3D (OSSVoiceOut *) hw; @@ -750,6 +761,7 @@ static struct audio_pcm_ops oss_pcm_ops =3D { .init_out =3D oss_init_out, .fini_out =3D oss_fini_out, .write =3D oss_write, + .buffer_get_free =3D oss_buffer_get_free, .run_buffer_out =3D oss_run_buffer_out, .get_buffer_out =3D oss_get_buffer_out, .put_buffer_out =3D oss_put_buffer_out, diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index d6f3aa1a9ac5..e605c787baf3 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -309,6 +309,7 @@ static void sdl_callback_in(void *opaque, Uint8 *buf, i= nt len) SDL_UnlockAudioDevice(sdl->devid); \ } =20 +SDL_WRAPPER_FUNC(buffer_get_free, size_t, (HWVoiceOut *hw), (hw), Out) SDL_WRAPPER_FUNC(get_buffer_out, void *, (HWVoiceOut *hw, size_t *size), (hw, size), Out) SDL_WRAPPER_FUNC(put_buffer_out, size_t, @@ -471,6 +472,8 @@ static struct audio_pcm_ops sdl_pcm_ops =3D { .fini_out =3D sdl_fini_out, /* wrapper for audio_generic_write */ .write =3D sdl_write, + /* wrapper for audio_generic_buffer_get_free */ + .buffer_get_free =3D sdl_buffer_get_free, /* wrapper for audio_generic_get_buffer_out */ .get_buffer_out =3D sdl_get_buffer_out, /* wrapper for audio_generic_put_buffer_out */ diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 20e6853f8586..ac666335c783 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -197,6 +197,7 @@ static struct audio_pcm_ops wav_pcm_ops =3D { .init_out =3D wav_init_out, .fini_out =3D wav_fini_out, .write =3D wav_write_out, + .buffer_get_free =3D audio_generic_buffer_get_free, .run_buffer_out =3D audio_generic_run_buffer_out, .enable_out =3D wav_enable_out, }; --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646406183395586.3301194342827; Fri, 4 Mar 2022 07:03:03 -0800 (PST) Received: from localhost ([::1]:34794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9SQ-0001AK-4Y for importer@patchew.org; Fri, 04 Mar 2022 10:03:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38832) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8qr-0004kX-15 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:36460) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8qp-0001IN-AS for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:12 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-247-qSvx-YxXMWiSbhTKL01krw-1; Fri, 04 Mar 2022 09:24:09 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DE4A81006AA5; Fri, 4 Mar 2022 14:24:07 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AFB0C832AE; Fri, 4 Mar 2022 14:23:33 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id CDB6018009AC; Fri, 4 Mar 2022 15:21:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403850; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/t8awGVSb3LoEgSj8kOF9+qQ1uXEEzUpjHhd65P9f24=; b=i9Nz+qe7srTVNdP/cD8xiLqfw3avmD2mK9GqE0Mf+LhhasuidPWDFAghrQolqM8aAcK2Vs qiJrWpg1/teXt+BgsDOWf4d0j40EaL8NjeX61eZS4YvWecMZyeFnI5ZajUAe1NLRW/fb/h yWeLKI8D2iMjrq1CMnIEyRtxGWDtuYU= X-MC-Unique: qSvx-YxXMWiSbhTKL01krw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 18/35] paaudio: reduce effective playback buffer size Date: Fri, 4 Mar 2022 15:21:06 +0100 Message-Id: <20220304142123.956171-19-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646406184280100001 From: Volker R=C3=BCmelin Add the buffer_get_free pcm_ops function to reduce the effective playback buffer size. All intermediate audio playback buffers become temporary buffers. Signed-off-by: Volker R=C3=BCmelin Message-Id: <20220301191311.26695-11-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- audio/paaudio.c | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index 9df1e69c086f..d94f858ec761 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -201,39 +201,53 @@ unlock_and_fail: return 0; } =20 +static size_t qpa_buffer_get_free(HWVoiceOut *hw) +{ + PAVoiceOut *p =3D (PAVoiceOut *)hw; + PAConnection *c =3D p->g->conn; + size_t l; + + pa_threaded_mainloop_lock(c->mainloop); + + CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail, + "pa_threaded_mainloop_lock failed\n"); + if (pa_stream_get_state(p->stream) !=3D PA_STREAM_READY) { + /* wait for stream to become ready */ + l =3D 0; + goto unlock; + } + + l =3D pa_stream_writable_size(p->stream); + CHECK_SUCCESS_GOTO(c, l !=3D (size_t) -1, unlock_and_fail, + "pa_stream_writable_size failed\n"); + +unlock: + pa_threaded_mainloop_unlock(c->mainloop); + return l; + +unlock_and_fail: + pa_threaded_mainloop_unlock(c->mainloop); + return 0; +} + static void *qpa_get_buffer_out(HWVoiceOut *hw, size_t *size) { - PAVoiceOut *p =3D (PAVoiceOut *) hw; + PAVoiceOut *p =3D (PAVoiceOut *)hw; PAConnection *c =3D p->g->conn; void *ret; - size_t l; int r; =20 pa_threaded_mainloop_lock(c->mainloop); =20 CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail, "pa_threaded_mainloop_lock failed\n"); - if (pa_stream_get_state(p->stream) !=3D PA_STREAM_READY) { - /* wait for stream to become ready */ - l =3D 0; - ret =3D NULL; - goto unlock; - } - - l =3D pa_stream_writable_size(p->stream); - CHECK_SUCCESS_GOTO(c, l !=3D (size_t) -1, unlock_and_fail, - "pa_stream_writable_size failed\n"); =20 *size =3D -1; r =3D pa_stream_begin_write(p->stream, &ret, size); CHECK_SUCCESS_GOTO(c, r >=3D 0, unlock_and_fail, "pa_stream_begin_write failed\n"); =20 -unlock: pa_threaded_mainloop_unlock(c->mainloop); - if (*size > l) { - *size =3D l; - } return ret; =20 unlock_and_fail: @@ -901,6 +915,7 @@ static struct audio_pcm_ops qpa_pcm_ops =3D { .init_out =3D qpa_init_out, .fini_out =3D qpa_fini_out, .write =3D qpa_write, + .buffer_get_free =3D qpa_buffer_get_free, .get_buffer_out =3D qpa_get_buffer_out, .put_buffer_out =3D qpa_put_buffer_out, .volume_out =3D qpa_volume_out, --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646405950612712.5659853049075; Fri, 4 Mar 2022 06:59:10 -0800 (PST) Received: from localhost ([::1]:54498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9Of-0003cE-9D for importer@patchew.org; Fri, 04 Mar 2022 09:59:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8qn-0004fH-PE for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:32235) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8ql-0001E0-JF for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:08 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-113-CLFqTrbWNdu1Iqe8wVzi2Q-1; Fri, 04 Mar 2022 09:24:04 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3AB661006AA7; Fri, 4 Mar 2022 14:24:02 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3AF487B616; Fri, 4 Mar 2022 14:23:38 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D9DE818009AE; Fri, 4 Mar 2022 15:21:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403847; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FSgcpgra0vIwtKyU6UVTJ8vqwM3vHylvGpblIOXwlIU=; b=CSKJO5QkDhyRQxTgjjBSLMRlI8I6k/qUCAvsO4gDaEG7sJON4+/IjJg+kYlExwBBcLtEpY UnOwkZQKDjpssgEg8bURDhaPpxSwnSMOYY1fuZRxhwL88vnZBX0McqlR2/JUt6DCxuamcJ DD8fkVA4gPFFWJRx2HnF+YB+SHSLhL8= X-MC-Unique: CLFqTrbWNdu1Iqe8wVzi2Q-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 19/35] dsoundaudio: reduce effective playback buffer size Date: Fri, 4 Mar 2022 15:21:07 +0100 Message-Id: <20220304142123.956171-20-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646405951963100001 From: Volker R=C3=BCmelin Add the buffer_get_free pcm_ops function to reduce the effective playback buffer size. All intermediate audio playback buffers become temporary buffers. Signed-off-by: Volker R=C3=BCmelin Message-Id: <20220301191311.26695-12-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- audio/dsoundaudio.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 3dd2c4d4a60b..231f3e65b3c8 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -427,22 +427,18 @@ static void dsound_enable_out(HWVoiceOut *hw, bool en= able) } } =20 -static void *dsound_get_buffer_out(HWVoiceOut *hw, size_t *size) +static size_t dsound_buffer_get_free(HWVoiceOut *hw) { DSoundVoiceOut *ds =3D (DSoundVoiceOut *) hw; LPDIRECTSOUNDBUFFER dsb =3D ds->dsound_buffer; HRESULT hr; - DWORD ppos, wpos, act_size; - size_t req_size; - int err; - void *ret; + DWORD ppos, wpos; =20 hr =3D IDirectSoundBuffer_GetCurrentPosition( dsb, &ppos, ds->first_time ? &wpos : NULL); if (FAILED(hr)) { dsound_logerr(hr, "Could not get playback buffer position\n"); - *size =3D 0; - return NULL; + return 0; } =20 if (ds->first_time) { @@ -450,13 +446,20 @@ static void *dsound_get_buffer_out(HWVoiceOut *hw, si= ze_t *size) ds->first_time =3D false; } =20 - req_size =3D audio_ring_dist(ppos, hw->pos_emul, hw->size_emul); - req_size =3D MIN(req_size, hw->size_emul - hw->pos_emul); + return audio_ring_dist(ppos, hw->pos_emul, hw->size_emul); +} =20 - if (req_size =3D=3D 0) { - *size =3D 0; - return NULL; - } +static void *dsound_get_buffer_out(HWVoiceOut *hw, size_t *size) +{ + DSoundVoiceOut *ds =3D (DSoundVoiceOut *)hw; + LPDIRECTSOUNDBUFFER dsb =3D ds->dsound_buffer; + DWORD act_size; + size_t req_size; + int err; + void *ret; + + req_size =3D MIN(*size, hw->size_emul - hw->pos_emul); + assert(req_size > 0); =20 err =3D dsound_lock_out(dsb, &hw->info, hw->pos_emul, req_size, &ret, = NULL, &act_size, NULL, false, ds->s); @@ -699,6 +702,7 @@ static struct audio_pcm_ops dsound_pcm_ops =3D { .init_out =3D dsound_init_out, .fini_out =3D dsound_fini_out, .write =3D audio_generic_write, + .buffer_get_free =3D dsound_buffer_get_free, .get_buffer_out =3D dsound_get_buffer_out, .put_buffer_out =3D dsound_put_buffer_out, .enable_out =3D dsound_enable_out, --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646406451260502.03968384536427; Fri, 4 Mar 2022 07:07:31 -0800 (PST) Received: from localhost ([::1]:49292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9Wj-0002lE-Tb for importer@patchew.org; Fri, 04 Mar 2022 10:07:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8r7-0005CJ-JK for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20433) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8r5-0002B8-Bz for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:28 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-338-zeIk67sXMrKLFAkMuHe2Ng-1; Fri, 04 Mar 2022 09:24:23 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6C024835DE4; Fri, 4 Mar 2022 14:24:21 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DB2367A525; Fri, 4 Mar 2022 14:24:03 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E5BB418009B0; Fri, 4 Mar 2022 15:21:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403866; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zT7KjHLWieymJsj01ioRSfePTxZrCZgrRYRGma6bf00=; b=b47iBAvdLluokeziHQFIYad8ZtpVeZs+EiPApTAiB3JDSGfucqIjk72rVKdoBBAClTa7hd U4cjWZNwkhZShltBITNCtm4Md+Fuz37DutxPqn40/rEBwYhEiMsZaPLzUSSAKCCQL16BbG /J5xYwaFkd0t4lEfaBAtTgPjld8GxqI= X-MC-Unique: zeIk67sXMrKLFAkMuHe2Ng-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 20/35] ossaudio: reduce effective playback buffer size Date: Fri, 4 Mar 2022 15:21:08 +0100 Message-Id: <20220304142123.956171-21-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646406452133100001 From: Volker R=C3=BCmelin Return the free buffer size for the mmapped case in function oss_buffer_get_free() to reduce the effective playback buffer size. All intermediate audio playback buffers become temporary buffers. Signed-off-by: Volker R=C3=BCmelin Message-Id: <20220301191311.26695-13-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- audio/ossaudio.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 1bd680084065..da9c232222e3 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -394,7 +394,7 @@ static size_t oss_buffer_get_free(HWVoiceOut *hw) OSSVoiceOut *oss =3D (OSSVoiceOut *)hw; =20 if (oss->mmapped) { - return INT_MAX; + return oss_get_available_bytes(oss); } else { return audio_generic_buffer_get_free(hw); } @@ -402,9 +402,10 @@ static size_t oss_buffer_get_free(HWVoiceOut *hw) =20 static void *oss_get_buffer_out(HWVoiceOut *hw, size_t *size) { - OSSVoiceOut *oss =3D (OSSVoiceOut *) hw; + OSSVoiceOut *oss =3D (OSSVoiceOut *)hw; + if (oss->mmapped) { - *size =3D MIN(oss_get_available_bytes(oss), hw->size_emul - hw->po= s_emul); + *size =3D hw->size_emul - hw->pos_emul; return hw->buf_emul + hw->pos_emul; } else { return audio_generic_get_buffer_out(hw, size); --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646406350769304.35561707533736; Fri, 4 Mar 2022 07:05:50 -0800 (PST) Received: from localhost ([::1]:43300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9V7-00077B-Gk for importer@patchew.org; Fri, 04 Mar 2022 10:05:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8r7-0005CK-Kr for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22862) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8r5-0002As-CH for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:28 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-280-8XZC0Lv0MlagsIOeVljdZg-1; Fri, 04 Mar 2022 09:24:23 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 68A561091DA3; Fri, 4 Mar 2022 14:24:21 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B4BFE7A52F; Fri, 4 Mar 2022 14:24:09 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id F18F218009B1; Fri, 4 Mar 2022 15:21:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403865; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Cq+81k6haAkzX2UVOXPff9s/ab4llUF+4v1p/e72amA=; b=in5pJ9JfmCgeKJCmZbtpvXuFa8CiMEAmjK1Bp1HgwYqz3RZz8+uIe7j+Y+iGR0rJjipaXw qre+gHtEFPqfZ6gXQLNoXNSX4K/vDmIPexKT8KIPIXPLNY8guWI77tTvlsRMrMsElGBJd9 Ln9GGd4fnDqqZEjOvduBv+yghvP6uyI= X-MC-Unique: 8XZC0Lv0MlagsIOeVljdZg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 21/35] paaudio: fix samples vs. frames mix-up Date: Fri, 4 Mar 2022 15:21:09 +0100 Message-Id: <20220304142123.956171-22-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646406351776100001 From: Volker R=C3=BCmelin Now that the mixing buffer size no longer adds to playback latency, fix the samples vs. frames mix-up in the mixing buffer size calculation. This change will go largely unnoticed as long as the user doesn't use a buffer-size smaller than timer-period. Signed-off-by: Volker R=C3=BCmelin Message-Id: <20220301191311.26695-14-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- audio/paaudio.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index d94f858ec761..a53ed85e0b82 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -549,11 +549,8 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsett= ings *as, } =20 audio_pcm_init_info (&hw->info, &obt_as); - /* - * This is wrong. hw->samples counts in frames. hw->samples will be - * number of channels times larger than expected. - */ - hw->samples =3D audio_buffer_samples( + /* hw->samples counts in frames */ + hw->samples =3D audio_buffer_frames( qapi_AudiodevPaPerDirectionOptions_base(ppdo), &obt_as, 46440); =20 return 0; @@ -601,11 +598,8 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettin= gs *as, void *drv_opaque) } =20 audio_pcm_init_info (&hw->info, &obt_as); - /* - * This is wrong. hw->samples counts in frames. hw->samples will be - * number of channels times larger than expected. - */ - hw->samples =3D audio_buffer_samples( + /* hw->samples counts in frames */ + hw->samples =3D audio_buffer_frames( qapi_AudiodevPaPerDirectionOptions_base(ppdo), &obt_as, 46440); =20 return 0; --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646406632542448.6508237931987; Fri, 4 Mar 2022 07:10:32 -0800 (PST) Received: from localhost ([::1]:57842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9Zf-00008F-EF for importer@patchew.org; Fri, 04 Mar 2022 10:10:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39272) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8rB-0005DF-EJ for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:36242) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8r7-0002E9-D3 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:31 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-41-7iVKzTo3NQWi_RODtwLQTQ-1; Fri, 04 Mar 2022 09:24:25 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CB6041091DA1; Fri, 4 Mar 2022 14:24:23 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7EFB5866E9; Fri, 4 Mar 2022 14:24:23 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 094C618009B4; Fri, 4 Mar 2022 15:21:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403868; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q78IxQUUNiw3n2nBNPjD+6c7sPCSAAJ1j96Wd/elquQ=; b=Pzq+SVcrmq6i1+0v7AZcgXP5NLiGrz36ADcenyWMtyOAwh39Q7K5jTO70KkZJjtYXhqSWV xBPempi+i0dHdsSkDwZF1F/+G2W78ejZvr10ku+MRx1AIDrk2UxDyO850sTrW1wVUdklhZ TEwxbPcwafi03WtDz3rrdJ5h0O95w7Q= X-MC-Unique: 7iVKzTo3NQWi_RODtwLQTQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 22/35] sdlaudio: fix samples vs. frames mix-up Date: Fri, 4 Mar 2022 15:21:10 +0100 Message-Id: <20220304142123.956171-23-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646406634208100001 From: Volker R=C3=BCmelin Fix the same samples vs. frames mix-up that the previous commit fixed for the PulseAudio backend. Signed-off-by: Volker R=C3=BCmelin Message-Id: <20220301191311.26695-15-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- audio/sdlaudio.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index e605c787baf3..797b47bbddb1 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -347,11 +347,8 @@ static int sdl_init_out(HWVoiceOut *hw, struct audsett= ings *as, req.freq =3D as->freq; req.format =3D aud_to_sdlfmt (as->fmt); req.channels =3D as->nchannels; - /* - * This is wrong. SDL samples are QEMU frames. The buffer size will be - * the requested buffer size multiplied by the number of channels. - */ - req.samples =3D audio_buffer_samples( + /* SDL samples are QEMU frames */ + req.samples =3D audio_buffer_frames( qapi_AudiodevSdlPerDirectionOptions_base(spdo), as, 11610); req.callback =3D sdl_callback_out; req.userdata =3D sdl; --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646406209489411.186497292994; Fri, 4 Mar 2022 07:03:29 -0800 (PST) Received: from localhost ([::1]:36996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9Sq-0002u6-Dw for importer@patchew.org; Fri, 04 Mar 2022 10:03:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8rB-0005DE-D9 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:32335) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8r7-0002D7-7B for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:31 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-511-E_cQH8c9PECnC5kW_TfQ4w-1; Fri, 04 Mar 2022 09:24:25 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D547E1854E26; Fri, 4 Mar 2022 14:24:23 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7FF9C866EE; Fri, 4 Mar 2022 14:24:23 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 164BF18009B5; Fri, 4 Mar 2022 15:21:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403868; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1jIMKVjJSErsCeq5u/YaMwoi1VPhyRsihv2AV/JvcoI=; b=YZE++aTQaRnciBBaw8cW2/lbbfIoG7MqN28Xz57VJ2blGpCpJYgN5hSQ4jyTRMCwn9JYAY BH5mfyEdzqTgFvM8Aw5G/mO3eXb7hTLyhyarUgcRYpnWHnuJ9Lw8ENIe3jNC0QBzKbUtX9 +rl6V41LGLCNaybUqfDfqfBvwhCmq4Q= X-MC-Unique: E_cQH8c9PECnC5kW_TfQ4w-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 23/35] hw/usb/redirect.c: Stop using qemu_oom_check() Date: Fri, 4 Mar 2022 15:21:11 +0100 Message-Id: <20220304142123.956171-24-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini , Eric Blake Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646406210462100001 From: Peter Maydell qemu_oom_check() is a function which essentially says "if you pass me a NULL pointer then print a message then abort()". On POSIX systems the message includes strerror(errno); on Windows it includes the GetLastError() error value printed as an integer. Other than in the implementation of qemu_memalign(), we use this function only in hw/usb/redirect.c, for three checks: * on a call to usbredirparser_create() * on a call to usberedirparser_serialize() * on a call to malloc() The usbredir library API functions make no guarantees that they will set errno on errors, let alone that they might set the Windows-specific GetLastError string. malloc() is documented as setting errno, not GetLastError -- and in any case the only thing it might set errno to is ENOMEM. So qemu_oom_check() isn't the right thing for any of these. Replace them with straightforward error-checking code. This will allow us to get rid of qemu_oom_check(). Signed-off-by: Peter Maydell Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-Id: <20220226180723.1706285-2-peter.maydell@linaro.org> Signed-off-by: Gerd Hoffmann --- hw/usb/redirect.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 5f0ef9cb3b0f..8692ea256109 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -1239,7 +1239,11 @@ static void usbredir_create_parser(USBRedirDevice *d= ev) =20 DPRINTF("creating usbredirparser\n"); =20 - dev->parser =3D qemu_oom_check(usbredirparser_create()); + dev->parser =3D usbredirparser_create(); + if (!dev->parser) { + error_report("usbredirparser_create() failed"); + exit(1); + } dev->parser->priv =3D dev; dev->parser->log_func =3D usbredir_log; dev->parser->read_func =3D usbredir_read; @@ -2239,7 +2243,10 @@ static int usbredir_put_parser(QEMUFile *f, void *pr= iv, size_t unused, } =20 usbredirparser_serialize(dev->parser, &data, &len); - qemu_oom_check(data); + if (!data) { + error_report("usbredirparser_serialize failed"); + exit(1); + } =20 qemu_put_be32(f, len); qemu_put_buffer(f, data, len); @@ -2330,7 +2337,11 @@ static int usbredir_get_bufpq(QEMUFile *f, void *pri= v, size_t unused, bufp->len =3D qemu_get_be32(f); bufp->status =3D qemu_get_be32(f); bufp->offset =3D 0; - bufp->data =3D qemu_oom_check(malloc(bufp->len)); /* regular mallo= c! */ + bufp->data =3D malloc(bufp->len); /* regular malloc! */ + if (!bufp->data) { + error_report("usbredir_get_bufpq: out of memory"); + exit(1); + } bufp->free_on_destroy =3D bufp->data; qemu_get_buffer(f, bufp->data, bufp->len); QTAILQ_INSERT_TAIL(&endp->bufpq, bufp, next); --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646406791746553.4732227693478; Fri, 4 Mar 2022 07:13:11 -0800 (PST) Received: from localhost ([::1]:38282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9cC-000664-T9 for importer@patchew.org; Fri, 04 Mar 2022 10:13:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8rC-0005EA-Ks for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:34 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38997) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8rB-0002KZ-2g for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:34 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-556-5TGrwCzqMTezrQLqBbfq3A-1; Fri, 04 Mar 2022 09:24:27 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2FA3A1006AA7; Fri, 4 Mar 2022 14:24:26 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C04D1866E9; Fri, 4 Mar 2022 14:24:25 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 226D318009B6; Fri, 4 Mar 2022 15:21:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403870; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ug+btb4HV8bMTYexsCMbWvO+8M+VFHq3hy1KJUFE1F8=; b=XLGz3Z3/rLQNo1g+zDhGKaIBGEaCi6az0fzgvZEvTT+j38SP96Fge/lrY6adkQk9fvq+DN +MqK90qgFliW63EUaTiydCWRVWBRN5BGJ8ZZgtu+CcnNyEL+GVuwIUfZBnEtaTTAG5u6u0 ghmJhyEz7YTsZrkNWrbLCLoxnGsMfdQ= X-MC-Unique: 5TGrwCzqMTezrQLqBbfq3A-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 24/35] coreaudio: Notify error in coreaudio_init_out Date: Fri, 4 Mar 2022 15:21:12 +0100 Message-Id: <20220304142123.956171-25-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646406793443100001 From: Akihiko Odaki Otherwise, the audio subsystem tries to use the voice and eventually aborts due to the maximum number of samples in the buffer is not set. Signed-off-by: Akihiko Odaki Reviewed-by: Christian Schoenebeck Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20220226115953.60335-1-akihiko.odaki@gmail.com> Signed-off-by: Gerd Hoffmann --- audio/coreaudio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/audio/coreaudio.c b/audio/coreaudio.c index 91ea6ae975e5..0f19d0ce01c5 100644 --- a/audio/coreaudio.c +++ b/audio/coreaudio.c @@ -603,6 +603,8 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct au= dsettings *as, coreaudio_playback_logerr(status, "Could not remove voice property cha= nge listener\n"); } + + return -1; } =20 return 0; --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646406386036409.98335221040793; Fri, 4 Mar 2022 07:06:26 -0800 (PST) Received: from localhost ([::1]:45534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9Vh-0000EH-Kr for importer@patchew.org; Fri, 04 Mar 2022 10:06:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39330) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8rE-0005FR-04 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46340) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8rB-0002Kn-5W for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:35 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-164-K5UzOdwTMwiUK7h2Pbhu3A-1; Fri, 04 Mar 2022 09:24:28 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EC239801AFE; Fri, 4 Mar 2022 14:24:26 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7FE12866E9; Fri, 4 Mar 2022 14:24:26 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 2F8A718009B8; Fri, 4 Mar 2022 15:21:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403871; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OpKErTmmTGnHwRYPOgvS0SjzqB/msUj5VLfFK6l1uDg=; b=gHqhMEGCwIN3bfSBCs1u+8L/W0pYon8e3WST8H8WbMvAkvri/H22Cr8TFrodi59bK4wIHC l02heNvaTBmHQhszMJtFK974E7FKbzzg8cjlqrl/XofGFiUGxemU8sbMdRtYBIdt3N/+lg 77RDVm9jG7y7XtZHEGELvC1cgzRdkOI= X-MC-Unique: K5UzOdwTMwiUK7h2Pbhu3A-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 25/35] hw/i386: Improve bounds checking in OVMF table parsing Date: Fri, 4 Mar 2022 15:21:13 +0100 Message-Id: <20220304142123.956171-26-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646406387163100001 From: Dov Murik When pc_system_parse_ovmf_flash() parses the optional GUIDed table in the end of the OVMF flash memory area, the table length field is checked for sizes that are too small, but doesn't error on sizes that are too big (bigger than the flash content itself). Add a check for maximal size of the OVMF table, and add an error report in case the size is invalid. In such a case, an error like this will be displayed during launch: qemu-system-x86_64: OVMF table has invalid size 4047 and the table parsing is skipped. Signed-off-by: Dov Murik Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20220222071906.2632426-2-dovmurik@linux.ibm.com> Signed-off-by: Gerd Hoffmann --- hw/i386/pc_sysfw_ovmf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/i386/pc_sysfw_ovmf.c b/hw/i386/pc_sysfw_ovmf.c index f4dd92c58825..df15c9737b93 100644 --- a/hw/i386/pc_sysfw_ovmf.c +++ b/hw/i386/pc_sysfw_ovmf.c @@ -24,6 +24,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/error-report.h" #include "hw/i386/pc.h" #include "cpu.h" =20 @@ -66,7 +67,13 @@ void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, size= _t flash_size) ptr -=3D sizeof(uint16_t); tot_len =3D le16_to_cpu(*(uint16_t *)ptr) - sizeof(guid) - sizeof(uint= 16_t); =20 - if (tot_len <=3D 0) { + if (tot_len < 0 || tot_len > (ptr - flash_ptr)) { + error_report("OVMF table has invalid size %d", tot_len); + return; + } + + if (tot_len =3D=3D 0) { + /* no entries in the OVMF table */ return; } =20 --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646407060454163.42238656704137; Fri, 4 Mar 2022 07:17:40 -0800 (PST) Received: from localhost ([::1]:51616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9gZ-0006h0-0u for importer@patchew.org; Fri, 04 Mar 2022 10:17:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8rv-00061q-2O for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:25:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:41095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8rs-0003k7-NX for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:25:18 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-365-f8-ah2hnO3Gz2HrTPLEjKg-1; Fri, 04 Mar 2022 09:25:13 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9F90E801AFE; Fri, 4 Mar 2022 14:25:11 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1B18479903; Fri, 4 Mar 2022 14:24:28 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 3C81018009B9; Fri, 4 Mar 2022 15:21:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403916; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=baB6RIsA5GUnZG4FGkm5qO3av4UGDOoFdzE+3tpXKXY=; b=U2mUX/wLWUr2Rs/+MVDE69ycpUV7soGvKPg/OhhygbGYjsOMSad/U1UAiwKg+HxQTqKrJN a1lJ8tIYqgMi6lGPPfdRkDgVvDLXPnchN7xIb+G1sxU+OPSFH6lCwJk4QN/Xqz038hibFc rsxfCJzbB8ORHukCOfV7JwA4oBak5UA= X-MC-Unique: f8-ah2hnO3Gz2HrTPLEjKg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 26/35] hw/i386: Replace magic number with field length calculation Date: Fri, 4 Mar 2022 15:21:14 +0100 Message-Id: <20220304142123.956171-27-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Dov Murik , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646407062002100001 From: Dov Murik Replce the literal magic number 48 with length calculation (32 bytes at the end of the firmware after the table footer + 16 bytes of the OVMF table footer GUID). No functional change intended. Signed-off-by: Dov Murik Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20220222071906.2632426-3-dovmurik@linux.ibm.com> Signed-off-by: Gerd Hoffmann --- hw/i386/pc_sysfw_ovmf.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/i386/pc_sysfw_ovmf.c b/hw/i386/pc_sysfw_ovmf.c index df15c9737b93..07a4c267faae 100644 --- a/hw/i386/pc_sysfw_ovmf.c +++ b/hw/i386/pc_sysfw_ovmf.c @@ -30,6 +30,8 @@ =20 #define OVMF_TABLE_FOOTER_GUID "96b582de-1fb2-45f7-baea-a366c55a082d" =20 +static const int bytes_after_table_footer =3D 32; + static bool ovmf_flash_parsed; static uint8_t *ovmf_table; static int ovmf_table_len; @@ -53,12 +55,13 @@ void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, siz= e_t flash_size) =20 /* * if this is OVMF there will be a table footer - * guid 48 bytes before the end of the flash file. If it's - * not found, silently abort the flash parsing. + * guid 48 bytes before the end of the flash file + * (=3D 32 bytes after the table + 16 bytes the GUID itself). + * If it's not found, silently abort the flash parsing. */ qemu_uuid_parse(OVMF_TABLE_FOOTER_GUID, &guid); guid =3D qemu_uuid_bswap(guid); /* guids are LE */ - ptr =3D flash_ptr + flash_size - 48; + ptr =3D flash_ptr + flash_size - (bytes_after_table_footer + sizeof(gu= id)); if (!qemu_uuid_is_equal((QemuUUID *)ptr, &guid)) { return; } --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646406939189970.6543973240675; Fri, 4 Mar 2022 07:15:39 -0800 (PST) Received: from localhost ([::1]:47264 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9eb-0003br-Tg for importer@patchew.org; Fri, 04 Mar 2022 10:15:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8rF-0005Ft-L1 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28347) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8rD-0002Xv-Gv for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:37 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-500-uJCeHHzHPdyT9UPSy61dMw-1; Fri, 04 Mar 2022 09:24:31 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3F218FC80; Fri, 4 Mar 2022 14:24:30 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C2CAC866F5; Fri, 4 Mar 2022 14:24:29 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 4A97A18009BA; Fri, 4 Mar 2022 15:21:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403875; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hKRpgDNQ2RtBTM72+VusA365l4BToXznUDUzVSdfOUg=; b=Ur//MejQdpjvsLMC3t/sWSMgIHjnNuD8OkorHCaBbCh2F00D4J89Zt168l6YnwDqc+CJD5 m54t2DQNrYipFkMXYHBBz9fKj+LYHly8FpgVEHCHRlSyC30bWnUmmX9gXOqLSnjlmD5ypW nNBSi5nbg76jjOap6LzPkAZ6DkB2MTI= X-MC-Unique: uJCeHHzHPdyT9UPSy61dMw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 27/35] docs: Add spec of OVMF GUIDed table for SEV guests Date: Fri, 4 Mar 2022 15:21:15 +0100 Message-Id: <20220304142123.956171-28-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Dov Murik , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646406940955100001 From: Dov Murik Add docs/specs/sev-guest-firmware.rst which describes the GUIDed table in the end of OVMF's image which is parsed by QEMU, and currently used to describe some values for SEV and SEV-ES guests. Signed-off-by: Dov Murik Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20220103091413.2869-1-dovmurik@linux.ibm.com> Signed-off-by: Gerd Hoffmann --- docs/specs/index.rst | 1 + docs/specs/sev-guest-firmware.rst | 125 ++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 docs/specs/sev-guest-firmware.rst diff --git a/docs/specs/index.rst b/docs/specs/index.rst index ecc43896bb21..2a35700fb322 100644 --- a/docs/specs/index.rst +++ b/docs/specs/index.rst @@ -18,3 +18,4 @@ guest hardware that is specific to QEMU. acpi_mem_hotplug acpi_pci_hotplug acpi_nvdimm + sev-guest-firmware diff --git a/docs/specs/sev-guest-firmware.rst b/docs/specs/sev-guest-firmw= are.rst new file mode 100644 index 000000000000..3f7f082df594 --- /dev/null +++ b/docs/specs/sev-guest-firmware.rst @@ -0,0 +1,125 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D +QEMU/Guest Firmware Interface for AMD SEV and SEV-ES +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D + +Overview +=3D=3D=3D=3D=3D=3D=3D=3D + +The guest firmware image (OVMF) may contain some configuration entries +which are used by QEMU before the guest launches. These are listed in a +GUIDed table at a known location in the firmware image. QEMU parses +this table when it loads the firmware image into memory, and then QEMU +reads individual entries when their values are needed. + +Though nothing in the table structure is SEV-specific, currently all the +entries in the table are related to SEV and SEV-ES features. + + +Table parsing in QEMU +--------------------- + +The table is parsed from the footer: first the presence of the table +footer GUID (96b582de-1fb2-45f7-baea-a366c55a082d) at 0xffffffd0 is +verified. If that is found, two bytes at 0xffffffce are the entire +table length. + +Then the table is scanned backwards looking for the specific entry GUID. + +QEMU files related to parsing and scanning the OVMF table: + - ``hw/i386/pc_sysfw_ovmf.c`` + +The edk2 firmware code that constructs this structure is in the +`OVMF Reset Vector file`_. + + +Table memory layout +------------------- + ++------------+--------+-----------------------------------------+ +| GPA | Length | Description | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ +| 0xffffff80 | 4 | Zero padding | ++------------+--------+-----------------------------------------+ +| 0xffffff84 | 4 | SEV hashes table base address | ++------------+--------+-----------------------------------------+ +| 0xffffff88 | 4 | SEV hashes table size (=3D0x400) | ++------------+--------+-----------------------------------------+ +| 0xffffff8c | 2 | SEV hashes table entry length (=3D0x1a) | ++------------+--------+-----------------------------------------+ +| 0xffffff8e | 16 | SEV hashes table GUID: | +| | | 7255371f-3a3b-4b04-927b-1da6efa8d454 | ++------------+--------+-----------------------------------------+ +| 0xffffff9e | 4 | SEV secret block base address | ++------------+--------+-----------------------------------------+ +| 0xffffffa2 | 4 | SEV secret block size (=3D0xc00) | ++------------+--------+-----------------------------------------+ +| 0xffffffa6 | 2 | SEV secret block entry length (=3D0x1a) | ++------------+--------+-----------------------------------------+ +| 0xffffffa8 | 16 | SEV secret block GUID: | +| | | 4c2eb361-7d9b-4cc3-8081-127c90d3d294 | ++------------+--------+-----------------------------------------+ +| 0xffffffb8 | 4 | SEV-ES AP reset RIP | ++------------+--------+-----------------------------------------+ +| 0xffffffbc | 2 | SEV-ES reset block entry length (=3D0x16) | ++------------+--------+-----------------------------------------+ +| 0xffffffbe | 16 | SEV-ES reset block entry GUID: | +| | | 00f771de-1a7e-4fcb-890e-68c77e2fb44e | ++------------+--------+-----------------------------------------+ +| 0xffffffce | 2 | Length of entire table including table | +| | | footer GUID and length (=3D0x72) | ++------------+--------+-----------------------------------------+ +| 0xffffffd0 | 16 | OVMF GUIDed table footer GUID: | +| | | 96b582de-1fb2-45f7-baea-a366c55a082d | ++------------+--------+-----------------------------------------+ +| 0xffffffe0 | 8 | Application processor entry point code | ++------------+--------+-----------------------------------------+ +| 0xffffffe8 | 8 | "\0\0\0\0VTF\0" | ++------------+--------+-----------------------------------------+ +| 0xfffffff0 | 16 | Reset vector code | ++------------+--------+-----------------------------------------+ + + +Table entries description +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D + +SEV-ES reset block +------------------ + +Entry GUID: 00f771de-1a7e-4fcb-890e-68c77e2fb44e + +For the initial boot of an AP under SEV-ES, the "reset" RIP must be +programmed to the RAM area defined by this entry. The entry's format +is: + +* IP value [0:15] +* CS segment base [31:16] + +A hypervisor reads the CS segment base and IP value. The CS segment +base value represents the high order 16-bits of the CS segment base, so +the hypervisor must left shift the value of the CS segment base by 16 +bits to form the full CS segment base for the CS segment register. It +would then program the EIP register with the IP value as read. + + +SEV secret block +---------------- + +Entry GUID: 4c2eb361-7d9b-4cc3-8081-127c90d3d294 + +This describes the guest RAM area where the hypervisor should inject the +Guest Owner secret (using SEV_LAUNCH_SECRET). + + +SEV hashes table +---------------- + +Entry GUID: 7255371f-3a3b-4b04-927b-1da6efa8d454 + +This describes the guest RAM area where the hypervisor should install a +table describing the hashes of certain firmware configuration device +files that would otherwise be passed in unchecked. The current use is +for the kernel, initrd and command line values, but others may be added. + + +.. _OVMF Reset Vector file: + https://github.com/tianocore/edk2/blob/master/OvmfPkg/ResetVector/Ia16/= ResetVectorVtf0.asm --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646406506284324.3807676380044; Fri, 4 Mar 2022 07:08:26 -0800 (PST) Received: from localhost ([::1]:51896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9Xd-0004ZV-74 for importer@patchew.org; Fri, 04 Mar 2022 10:08:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8rI-0005Jg-7z for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:26915) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8rF-0002fZ-Ck for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:38 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-551-z3FCljN6OD-x5FKODCbu5Q-1; Fri, 04 Mar 2022 09:24:33 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 085D31854E26; Fri, 4 Mar 2022 14:24:32 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B8417866F5; Fri, 4 Mar 2022 14:24:31 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 56CDD18009BB; Fri, 4 Mar 2022 15:21:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403876; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=98/liyrwCEk/qn6JyeC5cc/WbBQeLoFeN+V78zlxylc=; b=MQgizRgmZEKVV1+TuH1TleqfpiuHn7C42E7rn1Xr1nF8+kBa70ftvy5ozaRdKukPWY785l 69tHQ40Cv+J08Tt09hsZLB+UXf9KzkA84uEQofv6Bk4baRXqw/Yb8qAjU+VjIlwULI6QOv tV+cuy9UD3SJdXO0OJXQvxwJDQe/wa0= X-MC-Unique: z3FCljN6OD-x5FKODCbu5Q-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 28/35] ui/console: fix crash when using gl context with non-gl listeners Date: Fri, 4 Mar 2022 15:21:16 +0100 Message-Id: <20220304142123.956171-29-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646406506663100003 From: Marc-Andr=C3=A9 Lureau The commit 7cc712e98 ("ui: dispatch GL events to all listener") mechanically replaced the dpy_gl calls with a dispatch loop, using the same pre-conditions. However, it didn't take into account that all listeners do not have to implement the GL callbacks. Add the missing pre-conditions before calling the callbacks. Fix crash when running a GL-enabled VM with "-device virtio-gpu-gl-pci -display egl-headless -vnc :0". Fixes: 7cc712e98 ("ui: dispatch GL events to all listener") Reported-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20220214201337.1814787-2-marcandre.lureau@redhat.com> Signed-off-by: Gerd Hoffmann --- ui/console.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/ui/console.c b/ui/console.c index 40eebb6d2cc2..79a01afd1ea7 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1860,7 +1860,9 @@ void dpy_gl_scanout_disable(QemuConsole *con) con->scanout.kind =3D SCANOUT_NONE; } QLIST_FOREACH(dcl, &s->listeners, next) { - dcl->ops->dpy_gl_scanout_disable(dcl); + if (dcl->ops->dpy_gl_scanout_disable) { + dcl->ops->dpy_gl_scanout_disable(dcl); + } } } =20 @@ -1881,10 +1883,12 @@ void dpy_gl_scanout_texture(QemuConsole *con, x, y, width, height }; QLIST_FOREACH(dcl, &s->listeners, next) { - dcl->ops->dpy_gl_scanout_texture(dcl, backing_id, - backing_y_0_top, - backing_width, backing_height, - x, y, width, height); + if (dcl->ops->dpy_gl_scanout_texture) { + dcl->ops->dpy_gl_scanout_texture(dcl, backing_id, + backing_y_0_top, + backing_width, backing_height, + x, y, width, height); + } } } =20 @@ -1897,7 +1901,9 @@ void dpy_gl_scanout_dmabuf(QemuConsole *con, con->scanout.kind =3D SCANOUT_DMABUF; con->scanout.dmabuf =3D dmabuf; QLIST_FOREACH(dcl, &s->listeners, next) { - dcl->ops->dpy_gl_scanout_dmabuf(dcl, dmabuf); + if (dcl->ops->dpy_gl_scanout_dmabuf) { + dcl->ops->dpy_gl_scanout_dmabuf(dcl, dmabuf); + } } } =20 @@ -1951,7 +1957,9 @@ void dpy_gl_update(QemuConsole *con, =20 graphic_hw_gl_block(con, true); QLIST_FOREACH(dcl, &s->listeners, next) { - dcl->ops->dpy_gl_update(dcl, x, y, w, h); + if (dcl->ops->dpy_gl_update) { + dcl->ops->dpy_gl_update(dcl, x, y, w, h); + } } graphic_hw_gl_block(con, false); } --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646406548549794.4625197438053; Fri, 4 Mar 2022 07:09:08 -0800 (PST) Received: from localhost ([::1]:54038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9YJ-00063M-Dp for importer@patchew.org; Fri, 04 Mar 2022 10:09:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8rI-0005Jc-74 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36586) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8rF-0002fW-CX for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:38 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-646-6yTF0cYoMVuPGqOjghdDGQ-1; Fri, 04 Mar 2022 09:24:35 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 267E8801AFE; Fri, 4 Mar 2022 14:24:34 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D7754866F6; Fri, 4 Mar 2022 14:24:33 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 62C2F18009BC; Fri, 4 Mar 2022 15:21:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403876; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YB5PrzaEW6sk05UkOwzmVXKM5jsIDv8/SI0CNq9ZMbk=; b=IgCqGdthFhVgkzWsW3zqOU+gAhbLgEhU/E9jgdcPNXl8eadSPavbVIa6XW32jtkchTlZlt BkNAFptAYJyljDbpBqkBcwKvyJZn5i4qWqnlQmfbLZ/LNWaDswn+GXwNs+lLcG4PRNle1i C5++mYSIaH2LU04o0i4Z4XHr7G9/CI8= X-MC-Unique: 6yTF0cYoMVuPGqOjghdDGQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 29/35] ui/console: fix texture leak when calling surface_gl_create_texture() Date: Fri, 4 Mar 2022 15:21:17 +0100 Message-Id: <20220304142123.956171-30-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646406549071100003 From: Marc-Andr=C3=A9 Lureau Make surface_gl_create_texture() idempotent: if the surface is already bound to a texture, do not create a new one. This fixes texture leaks when there are multiple DBus listeners, for example. Reported-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20220214201337.1814787-3-marcandre.lureau@redhat.com> Signed-off-by: Gerd Hoffmann --- ui/console-gl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/console-gl.c b/ui/console-gl.c index 7c9894a51d99..8e3c9a3c8c01 100644 --- a/ui/console-gl.c +++ b/ui/console-gl.c @@ -49,6 +49,10 @@ void surface_gl_create_texture(QemuGLShader *gls, assert(gls); assert(QEMU_IS_ALIGNED(surface_stride(surface), surface_bytes_per_pixe= l(surface))); =20 + if (surface->texture) { + return; + } + switch (surface->format) { case PIXMAN_BE_b8g8r8x8: case PIXMAN_BE_b8g8r8a8: --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646406713261653.5143038464623; Fri, 4 Mar 2022 07:11:53 -0800 (PST) Received: from localhost ([::1]:34416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9ay-0003U6-2A for importer@patchew.org; Fri, 04 Mar 2022 10:11:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8rX-0005Tz-GE for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:30343) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8rV-0003QQ-OF for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:24:54 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-623-74EwTDLBPHK7sxxd7ltDOQ-1; Fri, 04 Mar 2022 09:24:43 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 472701854E21; Fri, 4 Mar 2022 14:24:37 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EF842866ED; Fri, 4 Mar 2022 14:24:36 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 6F81D18009BD; Fri, 4 Mar 2022 15:21:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403893; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g2h1ELJiTAe2kno7BGPFP7lqi+SRruAWDb3ZkkVobtY=; b=g3KlrK6DqGiNQK0LzMxvEK9UW+6ipgR6LC091uKlXi/smNUYAkVPwzL94njTkUglzOyM2t 9v60obIug7zukxmEZTdeBAwswye8VTYpaWIQXYT03mnysmJV0JfHR8yFldKTpaxDKMGz8X fGIK/extIqxMoI7W9HYMYDAYYC6qJL8= X-MC-Unique: 74EwTDLBPHK7sxxd7ltDOQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 30/35] ui: do not create a surface when resizing a GL scanout Date: Fri, 4 Mar 2022 15:21:18 +0100 Message-Id: <20220304142123.956171-31-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646406714758100005 From: Marc-Andr=C3=A9 Lureau qemu_console_resize() will create a blank surface and replace the current scanout with it if called while the current scanout is GL (texture or dmabuf). This is not only very costly, but also can produce glitches on the display/listener side. Instead, compare the current console size with the fitting console functions, which also works when the scanout is GL. Note: there might be still an unnecessary surface creation on calling qemu_console_resize() when the size is actually changing, but display backends currently rely on DisplaySurface details during dpy_gfx_switch() to handle various resize aspects. We would need more refactoring to handle resize without DisplaySurface, this is left for a future improvement. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20220214201337.1814787-4-marcandre.lureau@redhat.com> Signed-off-by: Gerd Hoffmann --- ui/console.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ui/console.c b/ui/console.c index 79a01afd1ea7..365a2c14b809 100644 --- a/ui/console.c +++ b/ui/console.c @@ -2400,13 +2400,12 @@ static void vc_chr_open(Chardev *chr, =20 void qemu_console_resize(QemuConsole *s, int width, int height) { - DisplaySurface *surface =3D qemu_console_surface(s); + DisplaySurface *surface; =20 assert(s->console_type =3D=3D GRAPHIC_CONSOLE); =20 - if (surface && (surface->flags & QEMU_ALLOCATED_FLAG) && - pixman_image_get_width(surface->image) =3D=3D width && - pixman_image_get_height(surface->image) =3D=3D height) { + if (qemu_console_get_width(s, -1) =3D=3D width && + qemu_console_get_height(s, -1) =3D=3D height) { return; } =20 --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646407227044999.0775042880492; Fri, 4 Mar 2022 07:20:27 -0800 (PST) Received: from localhost ([::1]:59190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9jF-0003Zz-R9 for importer@patchew.org; Fri, 04 Mar 2022 10:20:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39536) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8rq-0005ul-Ir for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:25:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60613) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8rp-0003jZ-2e for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:25:14 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-588-YOl7vMUwPXGkuip4YicFeQ-1; Fri, 04 Mar 2022 09:25:09 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0DBD01854E21; Fri, 4 Mar 2022 14:25:08 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 350102ED90; Fri, 4 Mar 2022 14:24:39 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 7BDF418009BE; Fri, 4 Mar 2022 15:21:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403912; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zxTB1op1Ykv/qiF9h6GJ/vbetoB1UFiuIdJ3qs8E528=; b=gMf0wPPmvQc5XcFU+BZXiodTm+eKH/HltIuPnLbqMscyBJ0VZTheciJDGRHKra3DTdHSe5 HRgPA5sR72k2jnf4XrtNaiDIxgV1px7ML5kmRnyb5YCL1n/rI2kEWdnSIOFAVafeXab2hF ngeOJkIMhOQKQyZ5WzcjmSeAnGCnoJw= X-MC-Unique: YOl7vMUwPXGkuip4YicFeQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 31/35] ui/clipboard: fix use-after-free regression Date: Fri, 4 Mar 2022 15:21:19 +0100 Message-Id: <20220304142123.956171-32-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646407227267100001 From: Marc-Andr=C3=A9 Lureau The same info may be used to update the clipboard, and may be freed before being ref'ed again. Fixes: 70a54b01693ed ("ui: avoid compiler warnings from unused clipboard in= fo variable") Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20220214115917.1679568-1-marcandre.lureau@redhat.com> Signed-off-by: Gerd Hoffmann --- ui/clipboard.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/clipboard.c b/ui/clipboard.c index 5f15cf853d07..9079ef829b51 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -66,8 +66,10 @@ void qemu_clipboard_update(QemuClipboardInfo *info) =20 notifier_list_notify(&clipboard_notifiers, ¬ify); =20 - qemu_clipboard_info_unref(cbinfo[info->selection]); - cbinfo[info->selection] =3D qemu_clipboard_info_ref(info); + if (cbinfo[info->selection] !=3D info) { + qemu_clipboard_info_unref(cbinfo[info->selection]); + cbinfo[info->selection] =3D qemu_clipboard_info_ref(info); + } } =20 QemuClipboardInfo *qemu_clipboard_info(QemuClipboardSelection selection) --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646406848130770.5289090395703; Fri, 4 Mar 2022 07:14:08 -0800 (PST) Received: from localhost ([::1]:43092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9d8-0000qK-W1 for importer@patchew.org; Fri, 04 Mar 2022 10:14:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8rs-0005zA-O5 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:25:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:60600) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8rq-0003jl-UR for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:25:16 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-611-nN5WgqcgMvW9p91w9fsaXQ-1; Fri, 04 Mar 2022 09:25:11 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DCB7BFC80; Fri, 4 Mar 2022 14:25:09 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9D923866F2; Fri, 4 Mar 2022 14:25:09 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 87FE918009BF; Fri, 4 Mar 2022 15:21:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403914; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sAtABj5a02/dn0ZmsdYNgkJzHoZl/SCjASDomLNiUe8=; b=POde7B23/Iq9GtStyZFq9JzOmldT+mB2c4O7GtlOm83YaCuYEBjMtA1ND9vt3bopKJirA+ gRaETDaBvNIav4osQugN0GmMMFWnsFpZ6edRoIXFhAOevME4Vw8DqRy+y8531UoSi+IUEj XuNFXuiEhMJ63hP3uxG6MarlUMvq/gI= X-MC-Unique: nN5WgqcgMvW9p91w9fsaXQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 32/35] ui/cocoa: Add Services menu Date: Fri, 4 Mar 2022 15:21:20 +0100 Message-Id: <20220304142123.956171-33-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646406850153100001 From: Akihiko Odaki Services menu functionality of Cocoa is described at: https://developer.apple.com/design/human-interface-guidelines/macos/extensi= ons/services/ Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20220214091320.51750-1-akihiko.odaki@gmail.com> Signed-off-by: Gerd Hoffmann --- ui/cocoa.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/cocoa.m b/ui/cocoa.m index b6e70e9134db..8ab9ab5e84da 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1611,11 +1611,15 @@ static void create_initial_menus(void) NSMenuItem *menuItem; =20 [NSApp setMainMenu:[[NSMenu alloc] init]]; + [NSApp setServicesMenu:[[NSMenu alloc] initWithTitle:@"Services"]]; =20 // Application menu menu =3D [[NSMenu alloc] initWithTitle:@""]; [menu addItemWithTitle:@"About QEMU" action:@selector(do_about_menu_it= em:) keyEquivalent:@""]; // About QEMU [menu addItem:[NSMenuItem separatorItem]]; //Separator + menuItem =3D [menu addItemWithTitle:@"Services" action:nil keyEquivale= nt:@""]; + [menuItem setSubmenu:[NSApp servicesMenu]]; + [menu addItem:[NSMenuItem separatorItem]]; [menu addItemWithTitle:@"Hide QEMU" action:@selector(hide:) keyEquival= ent:@"h"]; //Hide QEMU menuItem =3D (NSMenuItem *)[menu addItemWithTitle:@"Hide Others" actio= n:@selector(hideOtherApplications:) keyEquivalent:@"h"]; // Hide Others [menuItem setKeyEquivalentModifierMask:(NSEventModifierFlagOption|NSEv= entModifierFlagCommand)]; --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164640724573355.732666928463004; Fri, 4 Mar 2022 07:20:45 -0800 (PST) Received: from localhost ([::1]:60150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9jZ-0004EY-0i for importer@patchew.org; Fri, 04 Mar 2022 10:20:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8sM-0006AG-0F for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:25:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59607) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8sK-0003wD-HM for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:25:45 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-48-UqVxcv1JNWatKSt0FtPCCg-1; Fri, 04 Mar 2022 09:25:40 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB1B2FC80; Fri, 4 Mar 2022 14:25:38 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B271B106223E; Fri, 4 Mar 2022 14:25:14 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 944B618009C1; Fri, 4 Mar 2022 15:21:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403943; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3zDGyS5PxnhZKyMOllGG6HBiyw79weIS5S9ZZw+Jzy8=; b=SYX1N+8S86NFsLgxPyE70Si/DT9G5KydKWJOC39nKxIfF/fwjytWUavTtNnonM6Bwx4BOL KBZjbj7jKttRwvCK7+jHbN4AlV+1J9cPzyt9TEQPwYPI8NZtPy5E3DFX8716IQzJu7wTDj XpErwzv5dT5klVGkqxc1buG/oDROF28= X-MC-Unique: UqVxcv1JNWatKSt0FtPCCg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 33/35] softmmu/qdev-monitor: Add virtio-gpu-gl aliases Date: Fri, 4 Mar 2022 15:21:21 +0100 Message-Id: <20220304142123.956171-34-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, TVD_SPACE_RATIO=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646407247510100003 Content-Type: text/plain; charset="utf-8" From: Akihiko Odaki Signed-off-by: Akihiko Odaki Message-Id: <20220213021800.2525-1-akihiko.odaki@gmail.com> Signed-off-by: Gerd Hoffmann --- softmmu/qdev-monitor.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 01f3834db575..a0df820b9ded 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -83,6 +83,8 @@ static const QDevAlias qdev_alias_table[] =3D { { "virtio-gpu-device", "virtio-gpu", QEMU_ARCH_VIRTIO_MMIO }, { "virtio-gpu-ccw", "virtio-gpu", QEMU_ARCH_VIRTIO_CCW }, { "virtio-gpu-pci", "virtio-gpu", QEMU_ARCH_VIRTIO_PCI }, + { "virtio-gpu-gl-device", "virtio-gpu-gl", QEMU_ARCH_VIRTIO_MMIO }, + { "virtio-gpu-gl-pci", "virtio-gpu-gl", QEMU_ARCH_VIRTIO_PCI }, { "virtio-input-host-device", "virtio-input-host", QEMU_ARCH_VIRTIO_MM= IO }, { "virtio-input-host-ccw", "virtio-input-host", QEMU_ARCH_VIRTIO_CCW }, { "virtio-input-host-pci", "virtio-input-host", QEMU_ARCH_VIRTIO_PCI }, --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646407158975413.31395078115406; Fri, 4 Mar 2022 07:19:18 -0800 (PST) Received: from localhost ([::1]:55958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9i9-0001Q6-N7 for importer@patchew.org; Fri, 04 Mar 2022 10:19:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39744) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8sW-0006bz-8F for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:25:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49707) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8sU-0003yx-0e for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:25:55 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-626-0UhdXD9TNXCJHfZfBknTzw-1; Fri, 04 Mar 2022 09:25:50 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E3849800423; Fri, 4 Mar 2022 14:25:48 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4604983C0F; Fri, 4 Mar 2022 14:25:13 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id A199618009C4; Fri, 4 Mar 2022 15:21:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403953; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Rb9Qcza6r7yvid9p6hqGBWtWgsoEB4ik7XqeKgTyY8c=; b=PWHuDrOMTjfZu3UCcAQJjZIKzuVybqJj5uosvG0OtPLka+ephoH2sgoY39xTBbbb9g8DUA NyYc195C/wR9aUl3KLLcSF2E3WQuWAoYiqZcVK/LOo7tDNcWiqshUwsblfifVWnYoM9bKp cRErGLtAXZ1ZIrliH081TFSUBgwZvng= X-MC-Unique: 0UhdXD9TNXCJHfZfBknTzw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 34/35] edid: Fix clock of Detailed Timing Descriptor Date: Fri, 4 Mar 2022 15:21:22 +0100 Message-Id: <20220304142123.956171-35-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646407160859100003 Content-Type: text/plain; charset="utf-8" From: Akihiko Odaki The clock field is 16-bits in EDID Detailed Timing Descriptor, but edid_desc_timing assumed it is 32-bit. Write the 16-bit value if it fits in 16-bit. Write DisplayID otherwise. Signed-off-by: Akihiko Odaki Message-Id: <20220213021529.2248-1-akihiko.odaki@gmail.com> Signed-off-by: Gerd Hoffmann --- hw/display/edid-generate.c | 66 ++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/hw/display/edid-generate.c b/hw/display/edid-generate.c index bccf32af69ce..2cb819675e0b 100644 --- a/hw/display/edid-generate.c +++ b/hw/display/edid-generate.c @@ -255,33 +255,31 @@ static void edid_desc_dummy(uint8_t *desc) edid_desc_type(desc, 0x10); } =20 -static void edid_desc_timing(uint8_t *desc, uint32_t refresh_rate, +static void edid_desc_timing(uint8_t *desc, const Timings *timings, uint32_t xres, uint32_t yres, uint32_t xmm, uint32_t ymm) { - Timings timings; - generate_timings(&timings, refresh_rate, xres, yres); - stl_le_p(desc, timings.clock); + stw_le_p(desc, timings->clock); =20 desc[2] =3D xres & 0xff; - desc[3] =3D timings.xblank & 0xff; + desc[3] =3D timings->xblank & 0xff; desc[4] =3D (((xres & 0xf00) >> 4) | - ((timings.xblank & 0xf00) >> 8)); + ((timings->xblank & 0xf00) >> 8)); =20 desc[5] =3D yres & 0xff; - desc[6] =3D timings.yblank & 0xff; + desc[6] =3D timings->yblank & 0xff; desc[7] =3D (((yres & 0xf00) >> 4) | - ((timings.yblank & 0xf00) >> 8)); + ((timings->yblank & 0xf00) >> 8)); =20 - desc[8] =3D timings.xfront & 0xff; - desc[9] =3D timings.xsync & 0xff; + desc[8] =3D timings->xfront & 0xff; + desc[9] =3D timings->xsync & 0xff; =20 - desc[10] =3D (((timings.yfront & 0x00f) << 4) | - ((timings.ysync & 0x00f) << 0)); - desc[11] =3D (((timings.xfront & 0x300) >> 2) | - ((timings.xsync & 0x300) >> 4) | - ((timings.yfront & 0x030) >> 2) | - ((timings.ysync & 0x030) >> 4)); + desc[10] =3D (((timings->yfront & 0x00f) << 4) | + ((timings->ysync & 0x00f) << 0)); + desc[11] =3D (((timings->xfront & 0x300) >> 2) | + ((timings->xsync & 0x300) >> 4) | + ((timings->yfront & 0x030) >> 2) | + ((timings->ysync & 0x030) >> 4)); =20 desc[12] =3D xmm & 0xff; desc[13] =3D ymm & 0xff; @@ -348,13 +346,10 @@ static void init_displayid(uint8_t *did) edid_checksum(did + 1, did[2] + 4); } =20 -static void qemu_displayid_generate(uint8_t *did, uint32_t refresh_rate, +static void qemu_displayid_generate(uint8_t *did, const Timings *timings, uint32_t xres, uint32_t yres, uint32_t xmm, uint32_t ymm) { - Timings timings; - generate_timings(&timings, refresh_rate, xres, yres); - did[0] =3D 0x70; /* display id extension */ did[1] =3D 0x13; /* version 1.3 */ did[2] =3D 23; /* length */ @@ -364,21 +359,21 @@ static void qemu_displayid_generate(uint8_t *did, uin= t32_t refresh_rate, did[6] =3D 0x00; /* revision */ did[7] =3D 0x14; /* block length */ =20 - did[8] =3D timings.clock & 0xff; - did[9] =3D (timings.clock & 0xff00) >> 8; - did[10] =3D (timings.clock & 0xff0000) >> 16; + did[8] =3D timings->clock & 0xff; + did[9] =3D (timings->clock & 0xff00) >> 8; + did[10] =3D (timings->clock & 0xff0000) >> 16; =20 did[11] =3D 0x88; /* leave aspect ratio undefined */ =20 stw_le_p(did + 12, 0xffff & (xres - 1)); - stw_le_p(did + 14, 0xffff & (timings.xblank - 1)); - stw_le_p(did + 16, 0xffff & (timings.xfront - 1)); - stw_le_p(did + 18, 0xffff & (timings.xsync - 1)); + stw_le_p(did + 14, 0xffff & (timings->xblank - 1)); + stw_le_p(did + 16, 0xffff & (timings->xfront - 1)); + stw_le_p(did + 18, 0xffff & (timings->xsync - 1)); =20 stw_le_p(did + 20, 0xffff & (yres - 1)); - stw_le_p(did + 22, 0xffff & (timings.yblank - 1)); - stw_le_p(did + 24, 0xffff & (timings.yfront - 1)); - stw_le_p(did + 26, 0xffff & (timings.ysync - 1)); + stw_le_p(did + 22, 0xffff & (timings->yblank - 1)); + stw_le_p(did + 24, 0xffff & (timings->yfront - 1)); + stw_le_p(did + 26, 0xffff & (timings->ysync - 1)); =20 edid_checksum(did + 1, did[2] + 4); } @@ -386,6 +381,7 @@ static void qemu_displayid_generate(uint8_t *did, uint3= 2_t refresh_rate, void qemu_edid_generate(uint8_t *edid, size_t size, qemu_edid_info *info) { + Timings timings; uint8_t *desc =3D edid + 54; uint8_t *xtra3 =3D NULL; uint8_t *dta =3D NULL; @@ -409,9 +405,6 @@ void qemu_edid_generate(uint8_t *edid, size_t size, if (!info->prefy) { info->prefy =3D 800; } - if (info->prefx >=3D 4096 || info->prefy >=3D 4096) { - large_screen =3D 1; - } if (info->width_mm && info->height_mm) { width_mm =3D info->width_mm; height_mm =3D info->height_mm; @@ -421,6 +414,11 @@ void qemu_edid_generate(uint8_t *edid, size_t size, height_mm =3D qemu_edid_dpi_to_mm(dpi, info->prefy); } =20 + generate_timings(&timings, refresh_rate, info->prefx, info->prefy); + if (info->prefx >=3D 4096 || info->prefy >=3D 4096 || timings.clock >= =3D 65536) { + large_screen =3D 1; + } + /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D extensions =3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ =20 if (size >=3D 256) { @@ -501,7 +499,7 @@ void qemu_edid_generate(uint8_t *edid, size_t size, =20 if (!large_screen) { /* The DTD section has only 12 bits to store the resolution */ - edid_desc_timing(desc, refresh_rate, info->prefx, info->prefy, + edid_desc_timing(desc, &timings, info->prefx, info->prefy, width_mm, height_mm); desc =3D edid_desc_next(edid, dta, desc); } @@ -536,7 +534,7 @@ void qemu_edid_generate(uint8_t *edid, size_t size, /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D display id extensions= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ =20 if (did && large_screen) { - qemu_displayid_generate(did, refresh_rate, info->prefx, info->pref= y, + qemu_displayid_generate(did, &timings, info->prefx, info->prefy, width_mm, height_mm); } =20 --=20 2.35.1 From nobody Wed May 15 01:32:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646407441253357.08170509779075; Fri, 4 Mar 2022 07:24:01 -0800 (PST) Received: from localhost ([::1]:39698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9mi-0001Li-R9 for importer@patchew.org; Fri, 04 Mar 2022 10:24:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8sW-0006d8-Dp for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:25:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22576) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8sU-0003z1-Ha for qemu-devel@nongnu.org; Fri, 04 Mar 2022 09:25:56 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-590-cNlEh7zEN2SLUpl4boxAIQ-1; Fri, 04 Mar 2022 09:25:50 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3FFB41091DA1; Fri, 4 Mar 2022 14:25:49 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 87D1F7A531; Fri, 4 Mar 2022 14:25:40 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id AF65118009CD; Fri, 4 Mar 2022 15:21:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646403953; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ku1/XHDTNM3BoCvzsUaib/HSk1vCXJfZqU4oWFkh7wM=; b=f8qzpg1FOGqjgbwxLVIDt4uxviVP63AavNI+2nN5OpMsUSvU963I1nRIdX2z0DOMJ8fwFo ahevKDPB5ZFswQ5Dx/pmDuwhotSo0W72ofHdeBsX66PIYqt33wi0iTIeZ1LbQupNMKSixF NS/hxye96M6jtIK0i+AmtXun7mFo+C4= X-MC-Unique: cNlEh7zEN2SLUpl4boxAIQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 35/35] hw/display/vmware_vga: replace fprintf calls with trace events Date: Fri, 4 Mar 2022 15:21:23 +0100 Message-Id: <20220304142123.956171-36-kraxel@redhat.com> In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com> References: <20220304142123.956171-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=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: , Cc: Eduardo Habkost , Peter Maydell , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Akihiko Odaki , "Michael S. Tsirkin" , Thomas Huth , Richard Henderson , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Carwyn Ellis , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646407443182100001 From: Carwyn Ellis Debug output was always being sent to STDERR. This has been replaced with trace events. Signed-off-by: Carwyn Ellis Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20220206183956.10694-2-carwynellis@gmail.com> Signed-off-by: Gerd Hoffmann --- hw/display/vmware_vga.c | 30 ++++++++++++++++++------------ hw/display/trace-events | 3 +++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c index e2969a6c81c8..0cc43a1f15f6 100644 --- a/hw/display/vmware_vga.c +++ b/hw/display/vmware_vga.c @@ -297,46 +297,52 @@ static inline bool vmsvga_verify_rect(DisplaySurface = *surface, int x, int y, int w, int h) { if (x < 0) { - fprintf(stderr, "%s: x was < 0 (%d)\n", name, x); + trace_vmware_verify_rect_less_than_zero(name, "x", x); return false; } if (x > SVGA_MAX_WIDTH) { - fprintf(stderr, "%s: x was > %d (%d)\n", name, SVGA_MAX_WIDTH, x); + trace_vmware_verify_rect_greater_than_bound(name, "x", SVGA_MAX_WI= DTH, + x); return false; } if (w < 0) { - fprintf(stderr, "%s: w was < 0 (%d)\n", name, w); + trace_vmware_verify_rect_less_than_zero(name, "w", w); return false; } if (w > SVGA_MAX_WIDTH) { - fprintf(stderr, "%s: w was > %d (%d)\n", name, SVGA_MAX_WIDTH, w); + trace_vmware_verify_rect_greater_than_bound(name, "w", SVGA_MAX_WI= DTH, + w); return false; } if (x + w > surface_width(surface)) { - fprintf(stderr, "%s: width was > %d (x: %d, w: %d)\n", - name, surface_width(surface), x, w); + trace_vmware_verify_rect_surface_bound_exceeded(name, "width", + surface_width(surf= ace), + "x", x, "w", w); return false; } =20 if (y < 0) { - fprintf(stderr, "%s: y was < 0 (%d)\n", name, y); + trace_vmware_verify_rect_less_than_zero(name, "y", y); return false; } if (y > SVGA_MAX_HEIGHT) { - fprintf(stderr, "%s: y was > %d (%d)\n", name, SVGA_MAX_HEIGHT, y); + trace_vmware_verify_rect_greater_than_bound(name, "y", SVGA_MAX_HE= IGHT, + y); return false; } if (h < 0) { - fprintf(stderr, "%s: h was < 0 (%d)\n", name, h); + trace_vmware_verify_rect_less_than_zero(name, "h", h); return false; } if (h > SVGA_MAX_HEIGHT) { - fprintf(stderr, "%s: h was > %d (%d)\n", name, SVGA_MAX_HEIGHT, h); + trace_vmware_verify_rect_greater_than_bound(name, "y", SVGA_MAX_HE= IGHT, + y); return false; } if (y + h > surface_height(surface)) { - fprintf(stderr, "%s: update height > %d (y: %d, h: %d)\n", - name, surface_height(surface), y, h); + trace_vmware_verify_rect_surface_bound_exceeded(name, "height", + surface_height(sur= face), + "y", y, "h", h); return false; } =20 diff --git a/hw/display/trace-events b/hw/display/trace-events index 4a687d1b8ea6..91efc88f04f5 100644 --- a/hw/display/trace-events +++ b/hw/display/trace-events @@ -21,6 +21,9 @@ vmware_palette_write(uint32_t index, uint32_t value) "ind= ex %d, value 0x%x" vmware_scratch_read(uint32_t index, uint32_t value) "index %d, value 0x%x" vmware_scratch_write(uint32_t index, uint32_t value) "index %d, value 0x%x" vmware_setmode(uint32_t w, uint32_t h, uint32_t bpp) "%dx%d @ %d bpp" +vmware_verify_rect_less_than_zero(const char *name, const char *param, int= x) "%s: %s was < 0 (%d)" +vmware_verify_rect_greater_than_bound(const char *name, const char *param,= int bound, int x) "%s: %s was > %d (%d)" +vmware_verify_rect_surface_bound_exceeded(const char *name, const char *co= mponent, int bound, const char *param1, int value1, const char *param2, int= value2) "%s: %s > %d (%s: %d, %s: %d)" =20 # virtio-gpu-base.c virtio_gpu_features(bool virgl) "virgl %d" --=20 2.35.1