From nobody Mon Apr 13 11:14:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772826670; cv=none; d=zohomail.com; s=zohoarc; b=fLrL9tJCvQnxhIf/2AU25WdJKTnASsKCoi1uOG+WyqgA1v5FJETBHVh4mPFIHkt/9dm8+hrn2nE9D5s7UqgvC15mRugmMbiAN6iOltQBkMfJiOyDQGGozNB0sDHzy8HtRET4JfHucPazaNzYVBolFRCRRbspsZM2+j3fJ+RtH0E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772826670; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ajuMgwjCTtN4ZPB1zEJyv0G4VENDgEDxiFhANRLA7Jg=; b=QXTH7L9/hKzhk3FSeXHf2TFPSFpFCJj2orq69I1YAMEVUvgWzZ8b1TSXDRj/r0SCGA+nRrzDStEU9bLWKbYK3ctX5qGY7m8gIyI9wcE0K1QUHzjQZGmxKeSsE5Gei7/NIywHgnkI8SN38eQZNtz3kTQAYybG+kKiRrGd+IvDPw8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772826670679712.973859220428; Fri, 6 Mar 2026 11:51:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vybCN-0004B1-Cw; Fri, 06 Mar 2026 14:50:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vybCL-0004A9-Vs for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:50:58 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vybCG-0000Pu-Qh for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:50:57 -0500 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-439cb5af25bso3069796f8f.1 for ; Fri, 06 Mar 2026 11:50:52 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439dad97be5sm6191805f8f.11.2026.03.06.11.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:50:49 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 03843689D0; Fri, 06 Mar 2026 19:50:49 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772826651; x=1773431451; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ajuMgwjCTtN4ZPB1zEJyv0G4VENDgEDxiFhANRLA7Jg=; b=mlAmj90pYLs+MLyCpO/yPBzqySyF1PiwWiw7pNygypm2kL9ZcgSLouuWgIlpxwtAjS 1xpxHMk3gLaF/7l2DVW9gUVX5+geBxU9DtiP99Zgwn8zRcUYofZdK81g19yFzXZUIH4P aXK5zmiALIaReOWXOKIeM5SbAhpC2+O/86FNFbfSRmuN9zyYXdCjYOwsQcfNMhFcB8RP akqGKyImdZvrt5+p2cVP4xkDIOYPJyGVNVpKLQhvCCCVZIU99clHFJTemSILrBfd6zZL UQgujpKEJXCkSfZSAbAXghu3nuZTC2V1gkVASHHmvz/xyVFVv5983rz74M19FEAm7pUf P7tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772826651; x=1773431451; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ajuMgwjCTtN4ZPB1zEJyv0G4VENDgEDxiFhANRLA7Jg=; b=mI+mVIQ8Vi5vQYyiZtzJ4bCEO6enG4QsjDhVsSXhPywBOcFlqJnPyfxeGKZ38Il+lQ 0KmBc9lpIXe5+uGF6Rdge5gRnJ+KF1U4UuTaooVppR9QQxEmAkStQ2f9siyYXLefJETm 4u86HKoFBQKd9+EZRGdNjD3Vm2KO152LzUFI2O9bI4negqrpctWuCUWU0o6/MgcOmavb cF73nMsZtVkKSg2aqBAmZl5uu1SjvYjSBksZALF7XCYgejPIaRyUoQ7TciwP9yK7lraC nbYoaMpcprlosu9ewwL3K+gjGVgARoHvuMgnoApBHvrYT23L9EPMAduTEkUcjHPNJg0t +70w== X-Gm-Message-State: AOJu0Yw7BwC9F9kmhRO/C49IUu3F5aog9MlZOlzdv5ctebIOHPaLYdXP ydOMZWjyOUZnqWa7sWsRo9c5yGMs4Gz43+apNrcxc4/889cZ/FdBe25WgvpTDkD5Q6k= X-Gm-Gg: ATEYQzwss1VwkCKJEqmjBWMrbwO1DzdaSS9X0XvyjTpKOIntoSDx99dzY/HNC+RfG9o QnI3vwqlK9q47A2greEWLkvPnOt1BlwblGvaDOMG3ZqHQYcPUvw93ry8Xme09RBl6TLPhmzEfP1 ESvhH1YS5kcaBd8fqWDuaHqxQ10mTCP01Qqjo7iTApkTIDxO9HgecZQpREt0qJQZlFFrMR6u1U1 jeUqp08kvs9oaqdtWmjKjPtodBphWC6R5oWi65V7/qCSYorOScZT3jt7+mqunDc2D8AkNtXLg+p VM/0AMMCdgR67tSILoC6+46n3so61YPAY5tUjga4U5081Gez/YlzGnMSbUWl/fSslkOHaqnhIMf vlgc6d6o/Gr4TxLG83HY1WFBOhYqolHJgwjvomwbPqc5Xocc2iJXMB00RglnN6NAQ3Ixstb7v+C iZf9Pz3Y0rN2Bx2VfxDW/rgbSTlFd6KHv1hg== X-Received: by 2002:a05:6000:400f:b0:439:b59e:5e65 with SMTP id ffacd0b85a97d-439da355a90mr6060205f8f.6.1772826651254; Fri, 06 Mar 2026 11:50:51 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Andrew Keesler , Markus Armbruster , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , "Michael S. Tsirkin" , Eric Blake Subject: [PULL 01/20] Support per-head resolutions with virtio-gpu Date: Fri, 6 Mar 2026 19:50:28 +0000 Message-ID: <20260306195048.2869788-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306195048.2869788-1-alex.bennee@linaro.org> References: <20260306195048.2869788-1-alex.bennee@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::42c; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772826673724158500 From: Andrew Keesler In 454f4b0f, we started down the path of supporting separate configurations per display head (e.g., you have 2 heads - one with EDID name "AAA" and the other with EDID name "BBB"). In this change, we add resolution to this configuration surface (e.g., you have 2 heads - one with resolution 111x222 and the other with resolution 333x444). -display vnc=3Dlocalhost:0,id=3Daaa,display=3Dvga,head=3D0 \ -display vnc=3Dlocalhost:1,id=3Dbbb,display=3Dvga,head=3D1 \ -device '{"driver":"virtio-vga", "max_outputs":2, "id":"vga", "outputs":[ { "name":"AAA", "xres":111, "yres":222 }, { "name":"BBB", "xres":333, "yres":444 } ]}' Here is the behavior matrix of the current resolution configuration surface (xres/yres) with the new resolution configuration surface (outputs[i].xres/yres). Note - we use "xres" and "yres" (instead of, say, "width" and "height") to match analogous virtio_gpu_base_conf.xres/yres. Case: !(xres || yres) && !(outputs[i].has_xres && outputs[i].has_yres) Behavior: current behavior - outputs[0] enabled with default xres/yres Case: (xres || yres) && !(outputs[i].has_xres && outputs[i].has_yres) Behavior: current behavior - outputs[0] enabled with xres/yres Case: outputs[i].has_xres && outputs[i].has_yres Behavior: new behavior - outputs[i] enabled with outputs[i].xres/yres Case: outputs[i].has_xres !=3D outputs[i].has_yres Behavior: error Signed-off-by: Andrew Keesler Acked-by: Markus Armbruster Message-ID: <20260210123038.2332364-2-ankeesler@google.com> [AJB: fix format strings for size_t in error_setg] Message-ID: <20260304165043.1437519-2-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e diff --git a/qapi/virtio.json b/qapi/virtio.json index cd67c4f52e3..09dd0e6d05a 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -970,15 +970,24 @@ ## # @VirtIOGPUOutput: # -# Describes configuration of a VirtIO GPU output. +# Describes configuration of a VirtIO GPU output. If both @xres and +# @yres are set, they take precedence over root virtio-gpu resolution +# configuration and enable the corresponding output. If none of @xres +# and @yres are set, root virtio-gpu resolution configuration takes +# precedence and only the first output is enabled. Only setting one +# of @xres or @yres is an error. # # @name: the name of the output # +# @xres: horizontal resolution of the output in pixels (since 11.0) +# +# @yres: vertical resolution of the output in pixels (since 11.0) +# # Since: 10.1 ## =20 { 'struct': 'VirtIOGPUOutput', - 'data': { 'name': 'str' } } + 'data': { 'name': 'str', '*xres': 'uint16', '*yres': 'uint16' } } =20 ## # @DummyVirtioForceArrays: diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index 7269477a1c8..cb76302e2d8 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -233,6 +233,22 @@ virtio_gpu_base_device_realize(DeviceState *qdev, g->req_state[0].width =3D g->conf.xres; g->req_state[0].height =3D g->conf.yres; =20 + for (output_idx =3D 0, node =3D g->conf.outputs; + node && output_idx < g->conf.max_outputs; + output_idx++, node =3D node->next) { + if (node->value->has_xres !=3D node->value->has_yres) { + error_setg(errp, + "must set both outputs[%zd].xres and outputs[%zd].y= res", + output_idx, output_idx); + return false; + } + if (node->value->has_xres && node->value->has_yres) { + g->enabled_output_bitmask |=3D (1 << output_idx); + g->req_state[output_idx].width =3D node->value->xres; + g->req_state[output_idx].height =3D node->value->yres; + } + } + g->hw_ops =3D &virtio_gpu_ops; for (i =3D 0; i < g->conf.max_outputs; i++) { g->scanout[i].con =3D --=20 2.47.3 From nobody Mon Apr 13 11:14:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772826695; cv=none; d=zohomail.com; s=zohoarc; b=Tm2la6puKJbyizdxNVh5LajLHHyMALvoltAAX9+1RMQSDpF5bI7PjJpaXgSteF0oonuNqFBl0LNBSIwPkW6xPxSwtNazosWQJGHH6cn5cBorgfJ26NwSpoGFbuLzbLM3XoIz4LPpl9So4sI/wjEt6mUwPrsoQuwU1WKSLOg/7AM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772826695; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=E6hymyS/XV95BcDo7HFmoPR2rakOhmcWotYixkOfleY=; b=XdnqvDzWcZiEPdAP8OCk4OGKb4DREJsnZo/YB6aLRm6t51NhA3GjfnqSqcFgSdAZxhNHF9llV6mjz8Qs1zagm8doWzqw2UNhRNue6gtrZTw3f8pKzl5fBdFVh0joiLtI5F+NrUmjAFOzWbG55JHe2+6bRROJuo5YzuY/SGxP8J8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772826695755442.4746942060865; Fri, 6 Mar 2026 11:51:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vybCN-0004Bd-UB; Fri, 06 Mar 2026 14:51:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vybCL-00049Y-Ha for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:50:57 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vybCG-0000Pt-OL for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:50:56 -0500 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-439c56e822eso3880502f8f.2 for ; Fri, 06 Mar 2026 11:50:52 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439dae2bdf8sm6206702f8f.25.2026.03.06.11.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:50:49 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 1C816689D1; Fri, 06 Mar 2026 19:50:49 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772826651; x=1773431451; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E6hymyS/XV95BcDo7HFmoPR2rakOhmcWotYixkOfleY=; b=Z8yPgVtkfllI05/0PiXSnxd3Y2fA19sDaXNuZc6T+o1ROPMRv642WVWjeBrqGn0QSx dFydUl+nBUE4Qpl9Hjg2ejC2pu2J/Vkh1sGyi2i5ZZ+EPfAhJOWHemVbPHqtE3JKWIC4 BErc+XptwWt5PpLq++R7wSgjZf1djbbtLQ9k1GtAjTbkxL6ph1+fAIs4EWfVUJi0Twlg pHQiKyoU5UVEXLVku83DmYZ6C5ev2jfUAq5ga2OVwX9+/LCyZ/bMN233pUIe15E4Xgmn +QePpDELTLM0S2GYVjfH4NOYQCTMJAA1AhEueQ0lQbnconMkz1FAmdcJgqOnJpYQFlSf ADwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772826651; x=1773431451; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=E6hymyS/XV95BcDo7HFmoPR2rakOhmcWotYixkOfleY=; b=o0H2Yi7TaixQKBXoMAX4PhgZMwuJHulSN1YBp6AlulvEvwZhqb+/J31x2NJjAgcLl1 REKz6mE1i0rHBLk5F2WkS/AEpjxNa0JRlqNz4OdeEzVKXI4YmlrLSKmkvbk8DAFLi63K SuiJu3qNWGfN9Ln5rC4GKSyZVZB8a1jekmQlaeeEP8kN0E0R9W2PbjT/OSO00PAuvMlw Lc1vGwX3WsvRJ69cDRBnMTPaAINJ+3ubej6I3umM3Mh8+at1P0NsMb93VpPARv6506LP 8HGWWzEFOe/QKGeNcmGAjHsNl/67bH3Frnp6ZcGbSwm3SO+YFtw6DvF72tkPcsti3dch TBPw== X-Gm-Message-State: AOJu0YzenTDUp1NnFzykBQ+8rv7DRl6PfAPX0HBelxKrBUd2ee0+KNL4 +4a4+fcWSW6zmfBxs/VxsZUF59zc7H8r+yskHoeDTpAfsU86p/6T3i4RvEotJtLRg9k= X-Gm-Gg: ATEYQzzqOLGlvo5V1nNejan7n4FTq4D9MTFVWQxwxKSa0agF7AtIK1/+k8BoYlwQsBB D0YBnTWnwYny/CoWjVaX4IJqyVy1Z+Waoe95WQeS3Q/98pRDM/H16GS4qpvGa58oEuR8tN1oMN7 m1OmWYc4nX0umBmruEdWTKWPGtJmB7CCFOCgf4NNfM+POhAyXPdAlNur+iMHSl6VDZXKJbs9Edw xoxPqYHyzqEMMl7UpHRHlfEokr47xljK+TkHnnWdxORVMV06qzdDRePuqdLRQ2Vj0QVzECMbd0Z SqiGRHwkxRHt4T4GrrWUBcwUMtVkr4rhv8B7kMgt5v+Frh6ITDvs3KcAL3Gj/G+LPDCcpHUNsZo 59P4UPUCsNYAE2pXx18+mqJ2ey11UJiMIMf29AKdBSiGELB4NS7nkWUIttcgjchAsVCxrO6YBZP ULnWgU9L3TNfnFl7wb2bSJ3PI= X-Received: by 2002:a05:6000:2410:b0:439:c20e:5ed1 with SMTP id ffacd0b85a97d-439da5555f2mr6091522f8f.12.1772826650675; Fri, 06 Mar 2026 11:50:50 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dongwon Kim , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Vivek Kasireddy , "Michael S. Tsirkin" , Akihiko Odaki , Dmitry Osipenko Subject: [PULL 02/20] virtio-gpu: Fix scanout dmabuf cleanup during resource destruction Date: Fri, 6 Mar 2026 19:50:29 +0000 Message-ID: <20260306195048.2869788-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306195048.2869788-1-alex.bennee@linaro.org> References: <20260306195048.2869788-1-alex.bennee@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::42f; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772826697945154100 From: Dongwon Kim When a virtio-gpu resource is destroyed, any associated udmabuf must be properly torn down. Currently, the code may leave dangling references to dmabuf file descriptors in the scanout primary buffers. This patch updates virtio_gpu_fini_udmabuf to: 1. Iterate through all active scanouts. 2. Identify dmabufs that match the resource's file descriptor. 3. Close the dmabuf and invalidate the resource's FD reference to prevent use-after-free or double-close scenarios. 4. Finally, trigger the underlying udmabuf destruction. This ensures that the display backend does not attempt to access memory or FDs that have been released by the guest or the host. Cc: Alex Benn=C3=A9e Cc: Gerd Hoffmann Cc: Marc-Andr=C3=A9 Lureau Cc: Vivek Kasireddy Signed-off-by: Dongwon Kim Message-ID: <20260304203230.1955266-1-dongwon.kim@intel.com> Signed-off-by: Alex Benn=C3=A9e diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 58e0f91fda6..65312f869dd 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -357,7 +357,8 @@ bool virtio_gpu_scanout_blob_to_fb(struct virtio_gpu_fr= amebuffer *fb, /* virtio-gpu-udmabuf.c */ bool virtio_gpu_have_udmabuf(void); void virtio_gpu_init_udmabuf(struct virtio_gpu_simple_resource *res); -void virtio_gpu_fini_udmabuf(struct virtio_gpu_simple_resource *res); +void virtio_gpu_fini_udmabuf(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res); int virtio_gpu_update_dmabuf(VirtIOGPU *g, uint32_t scanout_id, struct virtio_gpu_simple_resource *res, diff --git a/hw/display/virtio-gpu-udmabuf-stubs.c b/hw/display/virtio-gpu-= udmabuf-stubs.c index f692e135103..85d03935a33 100644 --- a/hw/display/virtio-gpu-udmabuf-stubs.c +++ b/hw/display/virtio-gpu-udmabuf-stubs.c @@ -12,7 +12,7 @@ void virtio_gpu_init_udmabuf(struct virtio_gpu_simple_res= ource *res) /* nothing (stub) */ } =20 -void virtio_gpu_fini_udmabuf(struct virtio_gpu_simple_resource *res) +void virtio_gpu_fini_udmabuf(VirtIOGPU *g, struct virtio_gpu_simple_resour= ce *res) { /* nothing (stub) */ } diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabu= f.c index d804f321aa3..74b6a7766af 100644 --- a/hw/display/virtio-gpu-udmabuf.c +++ b/hw/display/virtio-gpu-udmabuf.c @@ -151,13 +151,6 @@ void virtio_gpu_init_udmabuf(struct virtio_gpu_simple_= resource *res) res->blob =3D pdata; } =20 -void virtio_gpu_fini_udmabuf(struct virtio_gpu_simple_resource *res) -{ - if (res->remapped) { - virtio_gpu_destroy_udmabuf(res); - } -} - static void virtio_gpu_free_dmabuf(VirtIOGPU *g, VGPUDMABuf *dmabuf) { struct virtio_gpu_scanout *scanout; @@ -169,6 +162,26 @@ static void virtio_gpu_free_dmabuf(VirtIOGPU *g, VGPUD= MABuf *dmabuf) g_free(dmabuf); } =20 +void virtio_gpu_fini_udmabuf(VirtIOGPU *g, struct virtio_gpu_simple_resour= ce *res) +{ + int max_outputs =3D g->parent_obj.conf.max_outputs; + int i; + + for (i =3D 0; i < max_outputs; i++) { + VGPUDMABuf *dmabuf =3D g->dmabuf.primary[i]; + + if (dmabuf && + qemu_dmabuf_get_num_planes(dmabuf->buf) > 0 && + qemu_dmabuf_get_fds(dmabuf->buf, NULL)[0] =3D=3D res->dmabuf_f= d && + res->dmabuf_fd !=3D -1) { + qemu_dmabuf_close(dmabuf->buf); + res->dmabuf_fd =3D -1; + } + } + + virtio_gpu_destroy_udmabuf(res); +} + static VGPUDMABuf *virtio_gpu_create_dmabuf(VirtIOGPU *g, uint32_t scanout_id, diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 643e91ca2a7..b2af861f0d8 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -902,7 +902,7 @@ void virtio_gpu_cleanup_mapping(VirtIOGPU *g, res->addrs =3D NULL; =20 if (res->blob) { - virtio_gpu_fini_udmabuf(res); + virtio_gpu_fini_udmabuf(g, res); } } =20 --=20 2.47.3 From nobody Mon Apr 13 11:14:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772826780; cv=none; d=zohomail.com; s=zohoarc; b=kc0vAfB/oaFg+YeXXkS3GYBgfl/oXYWd8r4WtR0cW5Xt0T5izSnHMxmjFubbrFe6+6hBU/Tz3UgyHerV9pyv7Td4OnmElLM5oRjUg0AZR2Y2TBAHFpexawp5PsOdJ6NGiclvG1Oxee75IhuBEeElVPU+foH20aXLNKg0QUkmVHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772826780; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=39GedOA/zhD2INkZV87nF0IgHSvIChHEdqlmVOM0ds4=; b=ahKtW9TMJJoce3ZTrpGQp9BFrqaQoqwCTLAYAdu4fHj8rOQ8BPrkvCBMIG0pEnABM4/Ttj4baSZI+yiZrZKstf0eH3AhK8Qpv17f2Piz2IiTay6/XPugtFvYSH0DZfUFOHe4/BqmKpIkvjs00/CR2BJTsVG/NY1MXfq5ZtxxzMQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772826780679749.6101261551869; Fri, 6 Mar 2026 11:53:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vybDM-0005wz-TO; Fri, 06 Mar 2026 14:52:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vybCO-0004Cb-I7 for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:02 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vybCM-0000Qe-28 for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:00 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4852a8482fcso5061965e9.3 for ; Fri, 06 Mar 2026 11:50:57 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-485237f354esm24971605e9.5.2026.03.06.11.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:50:52 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 30A1E689D2; Fri, 06 Mar 2026 19:50:49 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772826656; x=1773431456; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=39GedOA/zhD2INkZV87nF0IgHSvIChHEdqlmVOM0ds4=; b=TO6XF65gb8NOVPw1XJm2imnnKAbPKG2jTyz/fCkJT8vDTtwiYtdBLu3g1/KXvVoHds 1rybxKbaAxgGdqgyD2O1u1JU2/WpnhkqIWFqMpvxuY8oKk50kP/MzAjH8nNhW2z6584I Y6dIbnxo8jFx9mhHNTBP4DZNx+EHsqP9Ge6U4tcZWN2YOtY79BqsW0Q//NvCGqQP94m6 y45C3X70KWDE69SORX34jTZoSLXML5ywQcgtaEAON8hn0pnrpV3cPg5auG5G5Rt4szOF NqsvsDkBEUhTuLihpn0BQGzX4fKTKsoOvz681E6++Z0u4rMVRsnQKZWxLM0kcLpnhQZR 3WQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772826656; x=1773431456; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=39GedOA/zhD2INkZV87nF0IgHSvIChHEdqlmVOM0ds4=; b=G+be8hEK7crvEXWu+eRE7GuqL/ev5pgten7wV0ifcjTWAmQ0WKz6qLtQuvyk84Tzny wMCcUnWOOGEfU+jV/6zOv8xsac7vSsDgJrAynHWqYFTFlO/rXKMcwROmVCREwwpFCMFf pcV1zoDRu0Mld4C0nQ60PXsAMB+DsomBvbZIlMg+gZSl2EQIPyqIY6FzFysa7UrR+c1b HENutE8UbTPaKdr3Vgu2L3Vq5KMbuM7KQYOaLrthLUO+05dKsXlqOzf0rupG1RECnJ81 FAZRIzhEVRlFjG8d9o3i6U8Pk+MQHTI2bPIr3ntnE15hSkyTl4gt6UnBdRzTVMnKOVku MY1A== X-Gm-Message-State: AOJu0YxlHAskkbO9kcbBHx6fmwtuaESH6D82+lI2Hb7LaSUSvHEJiHsg qjSqMTabSZbGuNqazjMcuDAukJZTqFCNVCF+zdSos8thMJx5v0Vz3KsgUg4dNDX6ViQ= X-Gm-Gg: ATEYQzydHS2eDHsMVdaO6lK5FvbJOJOriyeGEwagO+PW2NeeqDrURlnHxWgae3A8vvr Pp0GL5YJSMQ8Shbpo3Q1Okb98Bfb16fJaL0fk4t8JlkzsCAzmVSv6r/s2s+GsE+ZDDkuaNySl12 ox9VEYD///wpHkIWX3uNKzx5F1ewT2IPCtpgZi/XYvtoxkpNdUdjT2gU8SQhkfiTCcJQyma0q/d /b5DrdMM+7qyK6gbqQW3SXlF06wCjfeKrXCSbUgOAtsPLyccaV5XsmCd1kdQO3bnoNj2rOoMqjT NHBhkTLa9znRF2COUoQ3NcLFSUIrIZXYF4LNTWWFw03evzI0qqBhYBr3Zxxv56xIMA09/RMtxkB XvAVaqrwYOna/gzhjbaKuE1VjM5Bm8ZKHAaN+PPHTfb6GCwjDkkew6ueKlBBq528nlc3KyPJoM3 4i+PBvmt84SeBs/J8nnsFkL2Y= X-Received: by 2002:a05:600c:1e88:b0:483:1403:c47f with SMTP id 5b1f17b1804b1-485269182b5mr64592525e9.6.1772826656381; Fri, 06 Mar 2026 11:50:56 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , Akihiko Odaki , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pierre-Eric Pelloux-Prayer , Yiwei Zhang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 03/20] ui/gtk: Don't disable scanout when display is refreshed Date: Fri, 6 Mar 2026 19:50:30 +0000 Message-ID: <20260306195048.2869788-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306195048.2869788-1-alex.bennee@linaro.org> References: <20260306195048.2869788-1-alex.bennee@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772826783053154100 From: Dmitry Osipenko Display refreshment is invoked by a timer and it erroneously disables the active scanout if it happens to be invoked after scanout has been enabled. This offending scanout-disable race condition with a timer can be easily hit when Qemu runs with a disabled vsync by using SDL or GTK displays (with vblank_mode=3D0 for GTK). Refreshment of display's content shouldn't disable the active display. Fix it by keeping the scanout's state unchanged when display is redrawn. Reviewed-by: Akihiko Odaki Acked-by: Michael S. Tsirkin Tested-by: Alex Benn=C3=A9e Acked-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Yiwei Zhang Signed-off-by: Dmitry Osipenko Message-ID: <20260303151422.977399-2-dmitry.osipenko@collabora.com> Message-ID: <20260304165043.1437519-4-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index ae9239999cd..0dbb429958e 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -180,7 +180,6 @@ void gd_egl_refresh(DisplayChangeListener *dcl) =20 if (vc->gfx.glupdates) { vc->gfx.glupdates =3D 0; - gtk_egl_set_scanout_mode(vc, false); gd_egl_draw(vc); } } diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index cd86022d264..c709b2ce0f6 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -199,7 +199,6 @@ void gd_gl_area_refresh(DisplayChangeListener *dcl) =20 if (vc->gfx.glupdates) { vc->gfx.glupdates =3D 0; - gtk_gl_area_set_scanout_mode(vc, false); gtk_gl_area_queue_render(GTK_GL_AREA(vc->gfx.drawing_area)); } } --=20 2.47.3 From nobody Mon Apr 13 11:14:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772826716; cv=none; d=zohomail.com; s=zohoarc; b=FcONDWLRFmqmvGfm087PogPVlTcxwX8dUNzfRDhPVyC9ccczYmSgwWjYjJt7qSBWk86HmRIPzaK/v77Lco6UGsnwBybj7RMeEpoSvuQjzKmcRuJJ2n2x8lacJ44CNhGyVu6TsD3w9PgwMVCrC4GmWN2NNcNImEu8jLBz6hxdPvE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772826716; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=C8fUu9eL4RVgzTGz/rJOnsGcUeJpizCfVBD7U0YbHu0=; b=n1SozgdEA1UWx+oWFdxZ/BIlxov4El+YTzsPhwsvGMio5vFf1tbKEve3eg2XyAySNNk2lY/Lb/L2UFT8YUX9Y6lBGcCto51jR1KkcFzjCuhu7DwO/nAuAs00r/D1G7Yxhd6xFGrhcwdEv7TY4yYg2gWVPXbEqieKXAUkFwAhuB0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772826716554147.62377711750105; Fri, 6 Mar 2026 11:51:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vybCX-0004D7-BO; Fri, 06 Mar 2026 14:51:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vybCM-0004As-Uw for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:50:59 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vybCJ-0000Q8-3p for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:50:58 -0500 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-439b6d9c981so4244060f8f.1 for ; Fri, 06 Mar 2026 11:50:53 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439dada3b43sm5889348f8f.13.2026.03.06.11.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:50:51 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 46814689D3; Fri, 06 Mar 2026 19:50:49 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772826653; x=1773431453; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=C8fUu9eL4RVgzTGz/rJOnsGcUeJpizCfVBD7U0YbHu0=; b=i2Tz+ERTOHAfT+ZIi/fUADipyt5eOg9kS/n6GoTpXWVx3qY+jaRCO6vKrFro5OcQk3 Jdy+q7Yau47CeFmIgb7I/7Z01zzrv0+j7+e/TMsHVQG+Y8TvaftXPIFrIlhpilsCZ4JB c6IN+pgIH/QBleTPgTBIlHchCVcbe8VsN/ID76c4S5HtBimMDChWFJWL/IxMUj31Wops uMXcEzfW53kgakMgZStG/jz8eUiEC/6jJDe/e9st25bu/rXRmBDyZ8rfaaQtxwu0jWqr 1R3+YIDF4bUOcyJ37H29VjKiWU5Dqs9cgUGfgGulX5bduwMGfQTw/EW3KQOos4nk0aik 2f3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772826653; x=1773431453; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=C8fUu9eL4RVgzTGz/rJOnsGcUeJpizCfVBD7U0YbHu0=; b=Cm/s+thJZyrtD8827QBEy6+H/nUrQXQ7g6DR5rBTT16rS6CcLg98yJbXB1X/U/Uw4M 5Uc3kw9S82h+ilLLvOjApw6vVZBxRsFR/hRCATlLKUZNIV3iS8DE+IwNNUSQpSURefnd nrCCU5M6xEVnyOqgrRGaDWuzXr7Z9dYjHtvI3FetCIW9g9rODT2NEG7aI/q4ZQWPpixN Dc/GRSFtlEhedHwSBY4cWeTBjFmcShWsd8klJN1B7IyR7fi4qMHFB+w7/BzY/JE/YJog lUS4mgVH1o+7B7Cwxnwu1/31tqlswi/DfcSvY250/0RDlOxQfXUWE+5rlARRk+YUEEeD ZOOQ== X-Gm-Message-State: AOJu0Ywqf06t1JJg+lrYr8kym541huvfxvDa+AZc3dcMXvdiXZp6ElA1 P6FciBOii37oxpTRW/Wv1GDsqmPHn461+PxGyCZqU2mER5o7zlQsfmfRqeXdKhSh7WM= X-Gm-Gg: ATEYQzxZU9n8oSCtiToLJya/I9tk2G6fCi/S4RISJnrMQ263H0A/LgaZ5HfH+3HNAn0 KMd3VROxmt0upE6oxVZ1Ylu5ILzZj/NWrPEeO/pfWy1XpIGkCcSh1Le74NlVF0re6tTaGpX7Tmz N45KP0iV95HT3h2WBxgLpoC+7lZ5TLcH3VMxZ1R0yy1TDGajE9A6OWzAH23lZUo4mpbssWO5RA3 CvF9Jl84pMK93W2Ozlzsa+mEgsRGw1ZkLo5JTPD3G56/sfX6SLiI1TQjEmr1eq/LYQj3G94Pyy3 MnpRrKL5aqwu5RpvzLt+IJ5KD2OH66gwBtG2jT7fAgaftIRgJ35hkQXF/YUP33dwP00V2jUkmoZ Ok6xeN0bRAx9WNcBCz407B3ZOtSjUTHlr27hLmCcBeNjx5hNMnU0UeQ4m1SrgqFSU5JM3RjZH9b T5jBqOU/YXIUH5D0Gv6/a2XiA= X-Received: by 2002:a05:6000:2881:b0:439:bb42:dbde with SMTP id ffacd0b85a97d-439da65531cmr6370732f8f.23.1772826652779; Fri, 06 Mar 2026 11:50:52 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , Akihiko Odaki , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pierre-Eric Pelloux-Prayer , Yiwei Zhang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 04/20] ui/sdl2: Don't disable scanout when display is refreshed Date: Fri, 6 Mar 2026 19:50:31 +0000 Message-ID: <20260306195048.2869788-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306195048.2869788-1-alex.bennee@linaro.org> References: <20260306195048.2869788-1-alex.bennee@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::433; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772826718617158500 From: Dmitry Osipenko Display refreshment is invoked by a timer and it erroneously disables the active scanout if it happens to be invoked after scanout has been enabled. This offending scanout-disable race condition with a timer can be easily hit when Qemu runs with a disabled vsync by using SDL or GTK displays (with vblank_mode=3D0 for GTK). Refreshment of display's content shouldn't disable the active display. Fix it by keeping the scanout's state unchanged when display is redrawn. Reviewed-by: Akihiko Odaki Acked-by: Michael S. Tsirkin Tested-by: Alex Benn=C3=A9e Acked-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Yiwei Zhang Signed-off-by: Dmitry Osipenko Message-ID: <20260303151422.977399-3-dmitry.osipenko@collabora.com> Message-ID: <20260304165043.1437519-5-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c index 3be17d1079a..5eca0248233 100644 --- a/ui/sdl2-gl.c +++ b/ui/sdl2-gl.c @@ -51,7 +51,6 @@ static void sdl2_gl_render_surface(struct sdl2_console *s= con) int ww, wh; =20 SDL_GL_MakeCurrent(scon->real_window, scon->winctx); - sdl2_set_scanout_mode(scon, false); =20 SDL_GetWindowSize(scon->real_window, &ww, &wh); surface_gl_setup_viewport(scon->gls, scon->surface, ww, wh); --=20 2.47.3 From nobody Mon Apr 13 11:14:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772826726; cv=none; d=zohomail.com; s=zohoarc; b=EK6yJImpJRuJUQS0D3HJhBGqbo6yxaJKhqZawJR1hoovyYNkYlSEn6B4M6E4D5GMcoGciOwDI0qUnwjBfMUFaiX1Mho0GwT+KRvCXysDvr6wGdN7yNfnAyhRvIHJxZ6Wf6p+qvSPK6dOOxvu5L/6A1FZps1ZWSJ0oDKrSm0rwgw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772826726; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=a2kV+uwRVblqcYCucxpenxbvBTbdi2je9MkAk6XrOXE=; b=TVQll7Q9bkKLauJGK9FGb23g+utO4rjvVR6D8agtIhzJqx+8aTIpwlTEPwBOJVkBPGihsYuX7FzOueyVxby20kr2n7zu1rGYsQRo4Uc+zA623O8QWUPfqSCz5aGUEyUuX8bOIV1wTt/uZuDZoycm5Zi73JI9Qlg4mpudkqVZoR0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772826726660933.8359529186391; Fri, 6 Mar 2026 11:52:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vybDM-0005yg-Sy; Fri, 06 Mar 2026 14:52:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vybCP-0004Cj-1D for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:03 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vybCM-0000Qn-M1 for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:00 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4837584120eso74144955e9.1 for ; Fri, 06 Mar 2026 11:50:58 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4851fae00absm133404985e9.4.2026.03.06.11.50.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:50:54 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 62130689D4; Fri, 06 Mar 2026 19:50:49 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772826657; x=1773431457; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=a2kV+uwRVblqcYCucxpenxbvBTbdi2je9MkAk6XrOXE=; b=mnWF8Qhl4ziSh89UPWvY4MB7YxhiyvtHQrIGjg6GAZ3GR5K+ErCjlD1hxXYfno4YQu g7C+Aiw7/iBSAPpVXbgKQrDbSmTX/QYcUQqzFdZl4ZFvCpKwDd41cl/3qAh8NA/lytO4 /GdospuNA9DqsJB3tPukEfv6rR1YqHwpKlrQp/WcF//itOCpR67oiiBpn0sBuUdP+fWU 1sbHhlv/PDS8HHnUScK/FzAK/Wf3FNP1wuOcvzxS7KLlnPA9YsblmLlzmmVFm6ZHsDV0 Fi/05GXOGChEWtl2NaBMxOshhyIzxiydSWMAofbDLyKg3Nk6CqK0cobrJhao1lVSrp8Q G1Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772826657; x=1773431457; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=a2kV+uwRVblqcYCucxpenxbvBTbdi2je9MkAk6XrOXE=; b=XeRZTG8nmxzcW6CBE3b79JIJpUJg5JyYWnkqTPyHkJ/a6lnE/cGTLUZBEuw9TSClxR yoWi8WID9tYYhLSBotQYXZNJUq8/7UK2IhfcbKPeKI9ywDN2emP0HQOTJGguw8HoiTRv liWyZ0fJkjKb6U0syVLhrmmjl1mYOO/Syku7UXjh3S45ihsxh7fkEX5OYKWiOCCbnJB/ RYYZMj7XkKdaFpotPToghApltiBTnv3ZcNYi26gVVzBEUCIYvxoYLjC3ZDA3KkCPgFRl UFDoWm5MtpgKfEb40rvm5IwYbG1YCoDVmofdr9wVNfnw01YRtYEH8UZXeX9SAmWrOm7Y jWbw== X-Gm-Message-State: AOJu0YzBZBtuAnhZv2QCoZOUwS9gvpCpTSIa4Dc7qMEbieRkpYJpyvmB MHTfzYuoyKgiVOFfI0z/Utela1RsqigPWWpGJPPWK1N7dVNlg+aFtKo5TZfbf7yfmLY= X-Gm-Gg: ATEYQzzGWa6FavSDrsFrKBaOK5wpSyWOyE2mK8puw83cP9ObrTcwcl/N3Z9orqM/MLt Mv34pzx6VMQW2tt0CAQVtJKYBTnX1hIfCKPd8Y5ci0WvFBdMmQe1gkbFF756DTMf5L7cm5+Hfsc 1GW2y6eelQaZdhOO1L/bMLX30xXYKh/2HwnYf/hMkL6LWL9FtGHDMcOwx+lxESzJF/2MWjLgVqP F5C0Kblum4rO53mTmMom79aPaGitJOtt1jb/TeA9e0IfIK6tKFo3MKn2jvOgzmAHZ/3WMb/wBb9 ISk+k7CgmqMcZphb9+TG0VFKAz0suV2Z2IbKLGMeeTuR+HiVpsbCN12zCoLz5l2N/rtwyIEXGQK uhNcAEjkrPSX7inU7nwoFh4zfrjbsyHSlSuGPytqBOSfJHj64wajQ024fMxp4GPU/pAgWdmhCse 9fijkdiv5mHrA3MObcPsAajLM= X-Received: by 2002:a05:600c:4591:b0:47e:e78a:c834 with SMTP id 5b1f17b1804b1-48526978664mr56717595e9.34.1772826657056; Fri, 06 Mar 2026 11:50:57 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 05/20] ui/egl: Don't change bound GL context when creating new context Date: Fri, 6 Mar 2026 19:50:32 +0000 Message-ID: <20260306195048.2869788-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306195048.2869788-1-alex.bennee@linaro.org> References: <20260306195048.2869788-1-alex.bennee@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::334; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772826728243154100 From: Dmitry Osipenko Don't change bound GL context when creating new GL context for consistency with behavior expected by virglrenderer that assumes context-creation doesn= 't switch context. eglCreateContext() doesn't require GL context to be bound when it's invoked. Update qemu_egl_create_context() to spawn GL sub-contexts from a given shared GL context instead of a currently-bound context. Signed-off-by: Dmitry Osipenko Message-ID: <20260303151422.977399-4-dmitry.osipenko@collabora.com> Message-ID: <20260304165043.1437519-6-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e diff --git a/include/ui/egl-context.h b/include/ui/egl-context.h index c2761d747a4..4d559ae7bd4 100644 --- a/include/ui/egl-context.h +++ b/include/ui/egl-context.h @@ -5,7 +5,8 @@ #include "ui/egl-helpers.h" =20 QEMUGLContext qemu_egl_create_context(DisplayGLCtx *dgc, - QEMUGLParams *params); + QEMUGLParams *params, + EGLContext share_context); void qemu_egl_destroy_context(DisplayGLCtx *dgc, QEMUGLContext ctx); int qemu_egl_make_context_current(DisplayGLCtx *dgc, QEMUGLContext ctx); diff --git a/ui/dbus.c b/ui/dbus.c index 905ee6fea71..4f24215555a 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -47,9 +47,7 @@ static DBusDisplay *dbus_display; static QEMUGLContext dbus_create_context(DisplayGLCtx *dgc, QEMUGLParams *params) { - eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, - qemu_egl_rn_ctx); - return qemu_egl_create_context(dgc, params); + return qemu_egl_create_context(dgc, params, qemu_egl_rn_ctx); } =20 static bool diff --git a/ui/egl-context.c b/ui/egl-context.c index aed3e3ba1f3..5787199347b 100644 --- a/ui/egl-context.c +++ b/ui/egl-context.c @@ -3,7 +3,8 @@ #include "ui/egl-context.h" =20 QEMUGLContext qemu_egl_create_context(DisplayGLCtx *dgc, - QEMUGLParams *params) + QEMUGLParams *params, + EGLContext share_context) { EGLContext ctx; EGLint ctx_att_core[] =3D { @@ -19,8 +20,7 @@ QEMUGLContext qemu_egl_create_context(DisplayGLCtx *dgc, }; bool gles =3D (qemu_egl_mode =3D=3D DISPLAY_GL_MODE_ES); =20 - ctx =3D eglCreateContext(qemu_egl_display, qemu_egl_config, - eglGetCurrentContext(), + ctx =3D eglCreateContext(qemu_egl_display, qemu_egl_config, share_conte= xt, gles ? ctx_att_gles : ctx_att_core); return ctx; } diff --git a/ui/egl-headless.c b/ui/egl-headless.c index 1f6b845500d..352b30b43fb 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -42,9 +42,7 @@ static void egl_gfx_switch(DisplayChangeListener *dcl, static QEMUGLContext egl_create_context(DisplayGLCtx *dgc, QEMUGLParams *params) { - eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, - qemu_egl_rn_ctx); - return qemu_egl_create_context(dgc, params); + return qemu_egl_create_context(dgc, params, qemu_egl_rn_ctx); } =20 static void egl_scanout_disable(DisplayChangeListener *dcl) diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index 0dbb429958e..1b5c1d4533c 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -219,9 +219,7 @@ QEMUGLContext gd_egl_create_context(DisplayGLCtx *dgc, { VirtualConsole *vc =3D container_of(dgc, VirtualConsole, gfx.dgc); =20 - eglMakeCurrent(qemu_egl_display, vc->gfx.esurface, - vc->gfx.esurface, vc->gfx.ectx); - return qemu_egl_create_context(dgc, params); + return qemu_egl_create_context(dgc, params, vc->gfx.ectx); } =20 void gd_egl_scanout_disable(DisplayChangeListener *dcl) diff --git a/ui/spice-display.c b/ui/spice-display.c index 28399f8a817..5052f371f44 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -1033,9 +1033,7 @@ static void spice_gl_switch(DisplayChangeListener *dc= l, static QEMUGLContext qemu_spice_gl_create_context(DisplayGLCtx *dgc, QEMUGLParams *params) { - eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, - qemu_egl_rn_ctx); - return qemu_egl_create_context(dgc, params); + return qemu_egl_create_context(dgc, params, qemu_egl_rn_ctx); } =20 static void qemu_spice_gl_scanout_disable(DisplayChangeListener *dcl) --=20 2.47.3 From nobody Mon Apr 13 11:14:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772826759; cv=none; d=zohomail.com; s=zohoarc; b=BzZQ470K8Gh8c/i1Ur012/XWn4Rwx2SZSe9XoUA7tRpL6kC83/dmWydS2o1D3tB84VTvnahvOZqZMesrcIGqWdR4xEq4tZx+ElLSKFqK/FQbocJzUanobQu7ZFsvLsTGnaAqTshPMlD2vDZVPnwQZJNiR4LHVsZ6GoFACGGHEdw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772826759; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9Ywt0UlJuFZem0wHlvStS/BsneoI1aIANoubc5aE6vw=; b=hMLo+OxjtdIfkcpzocuaRrv6G9tqXZ+DZWcYOhtwRUYBaSRlyZ4QUvWWAQa1NWZiKY5LsH3YlWfayYL7Bfs8aeorBJy7cUDxNyLlopg8WHHuB4aWV0AaZV8569hhMTsI6rHp0A9iLUJLDz0u0N2HMpRcBVxnSZKX7YJpR0p1W0s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772826759762639.8226216598689; Fri, 6 Mar 2026 11:52:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vybDH-0005Gy-1d; Fri, 06 Mar 2026 14:51:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vybCN-0004BD-BP for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:50:59 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vybCJ-0000QD-43 for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:50:59 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-439b73f4ab4so6371058f8f.1 for ; Fri, 06 Mar 2026 11:50:54 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439dae35cf7sm6608821f8f.26.2026.03.06.11.50.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:50:52 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 76A4C689D5; Fri, 06 Mar 2026 19:50:49 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772826653; x=1773431453; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9Ywt0UlJuFZem0wHlvStS/BsneoI1aIANoubc5aE6vw=; b=w05TMZUvypXaCSn7WrSUvV6g3HF/PolzmHoHRSENn2QtLiQPXrDDZVRzSF0TU6f3sX 30P5rQORmoQx6Aymuw6ItTIjkVeIjwBR+tAXSdmRyARrtdHt99BjGQf4GC5lNmBJk7vt 2iB/mDqr7BDYgw+IvTd46Q7Sddf6C6+7pHDzFiPacYkYXUXLHEPT8AGg0CpHt5ZkZJVV vnb5h9qt9HsWk1TuRmBAzZoxRGXcudP18epWul9vKtxTXhrurkWeGg72nWkoHiZSwtKO RYGFCEM7BaML2tcTVxQHxgcoMyAZpDgVokN7Rs/1mdpSJ40dH5Fo0vT0h5uTa6fXbDyz I14Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772826653; x=1773431453; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=9Ywt0UlJuFZem0wHlvStS/BsneoI1aIANoubc5aE6vw=; b=oYwSH/E0sMHta89OsgVrZJl4P+5IPojQjY5gbFy0mWUzSo7t51ftZ+EcFNRavk64g3 vYqThgH4GeZGGLsW/WRtmpYbY3EUUg5qRp76vR3+wCR50jrzMGJDtSRtKbsomHU5g6Jh WmhsWkWWKm2aULWLeTTWRPrnmuzmryZdstin3/nlbV3syvEYfUfgLAlI1I89381smpEg DoMYEb2NlzVTjPK3QULShmJcjh/LwtstOceIb4kYpgduSDDTP8vpOEKY02TP+UAkpneh onafsPRqp5KuJTn4NX5PrJ5hYNGFmIkOuqVnmqdiaPAcICLcZZBmBbO1bqpyPKi4OQqr hu2g== X-Gm-Message-State: AOJu0Ywbuhdc9qSqIfmaRmbzFX2ad0ZxnYW77ad6yMQqR397dkZJsVia 5MTAOokPBsYypFpuc4lKVGXE+kRGMOnATOud/GSuzTZ7NHVB+fY/1GwSruxPRGwrznLEFpny6GL LvvOJ X-Gm-Gg: ATEYQzywfnXBcngaCK6xLifaxAqL72qN5QtlInsgelyo+Zj21SqJKDSCFNTxxRSeiSk fNlerb922M+JC3pnCU65sv58/48N1j0E7iC4cAJzGpOR14ZaVk/W2VbEBtk4/LM5LRpODpC+b91 It86Ol3WAoSl8WBiGc4Qn3fpRhq7qq22jQ1wPVhjUP+S6eKyFj87XB/x+JvPtFSiO+CdkwaFkDY Zy4mfszCknIZxdWB3TYfBB4NfnHzQQFBSqSSGxU+nSFUQGeJ3JBdU5nSw++PG9UfJ6cw7BNO/gd iUtWjHVmu6drV38vilExu1UWnw24lfwMU+177kSwAbG4Z2ecvWPlplWZimFYLWydDpjDVf3XtMu N1gsbs/2VyLRnSEKPbCuGzgAKbswqvdADFTA6Xt9aswx/X9ydnBXO/mXAFoEPH80XJ5SqUXVlLt M4OirFLQOHuAlszhk9FEE3vU4= X-Received: by 2002:a05:6000:258a:b0:439:bdd7:425f with SMTP id ffacd0b85a97d-439da882125mr5981887f8f.35.1772826653452; Fri, 06 Mar 2026 11:50:53 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PULL 06/20] ui/gdk: Restore original context after new context creation Date: Fri, 6 Mar 2026 19:50:33 +0000 Message-ID: <20260306195048.2869788-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306195048.2869788-1-alex.bennee@linaro.org> References: <20260306195048.2869788-1-alex.bennee@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::436; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772826760892154100 From: Dmitry Osipenko Get currently bound GL context when creating new GL context and restore it after the creation for consistency with behavior expected by virglrender= er that assumes context-creation doesn't switch context. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Dmitry Osipenko Message-ID: <20260303151422.977399-5-dmitry.osipenko@collabora.com> Message-ID: <20260304165043.1437519-7-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index c709b2ce0f6..ce49000d3f1 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -250,11 +250,13 @@ QEMUGLContext gd_gl_area_create_context(DisplayGLCtx = *dgc, QEMUGLParams *params) { VirtualConsole *vc =3D container_of(dgc, VirtualConsole, gfx.dgc); + GdkGLContext *ctx, *current_ctx; GdkWindow *window; - GdkGLContext *ctx; GError *err =3D NULL; int major, minor; =20 + current_ctx =3D gdk_gl_context_get_current(); + window =3D gtk_widget_get_window(vc->gfx.drawing_area); ctx =3D gdk_window_create_gl_context(window, &err); if (err) { @@ -275,8 +277,12 @@ QEMUGLContext gd_gl_area_create_context(DisplayGLCtx *= dgc, =20 gdk_gl_context_make_current(ctx); gdk_gl_context_get_version(ctx, &major, &minor); - gdk_gl_context_clear_current(); - gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area)); + + if (current_ctx) { + gdk_gl_context_make_current(current_ctx); + } else { + gdk_gl_context_clear_current(); + } =20 if (gd_cmp_gl_context_version(major, minor, params) =3D=3D -1) { /* created ctx version < requested version */ --=20 2.47.3 From nobody Mon Apr 13 11:14:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772826709; cv=none; d=zohomail.com; s=zohoarc; b=WjFoJrNqeiTsNIJjcne48cLF21Ve6dBgAkQtrY6m8FWIFOBLN6B7e2pCHrvO5kHi2fFfKXy4NaMVe7zYaVyfBKCk5nMYmsdNdIqa9kGrkjE35o3Jy0kPieRJ40MSlqHMT/j0aVFBEFlllS5bT5MDd/JPYb0tclbDAGXFJW3wsYA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772826709; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gPkKXJYX4SKRB+WSPLR+a/LvTfT4xEY7xvivBzryjps=; b=A/nFMI7VkPWsx1DaYhGVBk+z48+PR5wmAQSHETPwbGIUC05XwsUJsbs+qPZt93hTIzryYKPcaJXd97WtB2yvSpkuqp1ygMja93T1plRZd8/6x9yhw5VOP0Hoq1viBNUG+98IY1O3WCElIC7OC9tRFY1YNFNfQ0vuzyBBZswJduI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772826709627750.1247132003714; Fri, 6 Mar 2026 11:51:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vybCd-0004LD-Iu; Fri, 06 Mar 2026 14:51:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vybCN-0004BL-E1 for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:50:59 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vybCL-0000QG-3u for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:50:59 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4836f363ad2so112134085e9.1 for ; Fri, 06 Mar 2026 11:50:55 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48527686fa9sm72936415e9.8.2026.03.06.11.50.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:50:52 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 8C5FA689D6; Fri, 06 Mar 2026 19:50:49 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772826654; x=1773431454; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gPkKXJYX4SKRB+WSPLR+a/LvTfT4xEY7xvivBzryjps=; b=nMVXj6q22f9qsEm8fchzugtA30fbCK/wTvh/mFI32rBxMasbQ+osXwRa0UoN8j4hG9 7zmZr1GH1BmyMa/acMmi5hS6/h6ahjW54cDls/KSCws5dALUnA5H4Dlmj3CvckPlFy9Z 61l0Nx1/scTenJJJfHl08JPCzzQOr6br7Ulv/aSs7o9ZKiIVuKVZbWAqTLxKrq1W+wAi Ygte1azwyB8ldi7qyUet0NaYM66eQ9H4kzPatjlCSvMOTzUNSWGA+jp1iQPagCSQ8aEL 8bo8htofMeFZAOKd02So0Mz8o2MRk3zM25QJV/5IHRd0g01DBunRhd/5xDLm9pMqxbXV 7GyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772826654; x=1773431454; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=gPkKXJYX4SKRB+WSPLR+a/LvTfT4xEY7xvivBzryjps=; b=wiDeWcCigtYYSNrzvLX2w33dpEGSznvxcRgyP1of7tYaibmHKOST8Qms9m3+wL0jM7 WNvE55ljKksy7xl1hip4A94GNQ1CCJA4qEYmtjTqJeQqqOGX3dJ2QPWcdoZEinC9Yijc GtO7momtiwu/1ioLYiUgM0+whOuCAJXITCxNYjag9E+xSw8rtY+cCeQr34IxDd1ZToTK Djbrb7rfqnyNnYGjanN961KF8rcA164nmZNmqrxynld0WLhSQjS3Pxx/HYwerchh6eyv BYlR3/IxdvFjXRI6Vh4DYFtut26NWB7zCVPTcdUrizXPUXhSUOFNBiiLXk/gwn8+kjGc XFeA== X-Gm-Message-State: AOJu0YwEgCiMJzXsn54BpxFwVl8roomIXXMDtHsOlN5FNfMzwyik+CfG YGnNJQ8HloFCRHl5lTDX3TQqrRJ0j5R/47DOpzWNt3yj3dz7gELhbz1wUaUFjDJGsLk= X-Gm-Gg: ATEYQzzftdDQNXdx/NeouRAVcPRjB+bRnRYWSGFXBT8qN6CqFiIOjIholesYdDMbmx+ afjzrE7kF+mnfYMhD2HRos1btAEO7d6PR80uJhSGtLsKMBu0I84dXaac98iTlhkNLjeG7aF5QDI akoRLCZWytqootOz9/zq0z9rsRNvxvnfnFxe/CKSaFmxQEi6pGWKqldB+zF7w0zUjeg2fcNXwMH /OMdA6rQ/SWp9fE+jLoOAdnuFta+hvjhvW+/qMmq9Y6z7qg7q88AVvyA202IJIR7Kjveyv3Xi8v JW3QAXZuNe/P3Hjm0UCD5sz3fpr2czNQP+5+6iulZ8WvLbqSdU0l9pcHxIFihjzniSt2LPNb/aA gbQ91nWL+HmQ28u5kCkZ+LRjWtn9I00EuCs42JhMPVx28VncW79YeZJtDZ3i0D2Rd4Ue9OyEB/P /MykIPlhC7MWTf6apa8cYKecQ= X-Received: by 2002:a05:600c:3acf:b0:483:6f37:1b33 with SMTP id 5b1f17b1804b1-48526978d48mr58668425e9.30.1772826654070; Fri, 06 Mar 2026 11:50:54 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , Akihiko Odaki , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pierre-Eric Pelloux-Prayer , Yiwei Zhang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 07/20] ui/sdl2: Restore original context after new context creation Date: Fri, 6 Mar 2026 19:50:34 +0000 Message-ID: <20260306195048.2869788-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306195048.2869788-1-alex.bennee@linaro.org> References: <20260306195048.2869788-1-alex.bennee@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::331; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772826710615158500 From: Dmitry Osipenko SDL API changes GL context to a newly created GL context, which differs from other GL providers that don't switch context. Change SDL backend to restore the original GL context. This allows Qemu's virtio-gpu to support new virglrenderer async-fencing feature for Virgl contexts, otherwise virglrenderer's vrend creates a fence-sync context on the Qemu's main-loop thread that erroneously stays in-use by the main-loop after creation, not allowing vrend's fence-sync thread switch to this new context that belongs to it. Reviewed-by: Akihiko Odaki Acked-by: Michael S. Tsirkin Tested-by: Alex Benn=C3=A9e Acked-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Yiwei Zhang Signed-off-by: Dmitry Osipenko Message-ID: <20260303151422.977399-6-dmitry.osipenko@collabora.com> Message-ID: <20260304165043.1437519-8-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c index 5eca0248233..fbac3edbc09 100644 --- a/ui/sdl2-gl.c +++ b/ui/sdl2-gl.c @@ -139,10 +139,12 @@ QEMUGLContext sdl2_gl_create_context(DisplayGLCtx *dg= c, QEMUGLParams *params) { struct sdl2_console *scon =3D container_of(dgc, struct sdl2_console, d= gc); - SDL_GLContext ctx; + SDL_GLContext ctx, current_ctx; =20 assert(scon->opengl); =20 + current_ctx =3D SDL_GL_GetCurrentContext(); + SDL_GL_MakeCurrent(scon->real_window, scon->winctx); =20 SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1); @@ -167,6 +169,9 @@ QEMUGLContext sdl2_gl_create_context(DisplayGLCtx *dgc, SDL_GL_CONTEXT_PROFILE_ES); ctx =3D SDL_GL_CreateContext(scon->real_window); } + + SDL_GL_MakeCurrent(scon->real_window, current_ctx); + return (QEMUGLContext)ctx; } =20 --=20 2.47.3 From nobody Mon Apr 13 11:14:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772826760; cv=none; d=zohomail.com; s=zohoarc; b=YI1JXYKEILrMOqSzvVgm+lA4f9XbP+rgZsWTRtHrxvIa1lZ4LEfJ+HBjwWw47DokOj5f48PRSIEDjKhlm6wlxeoI4s4peDT3A4P/YvV4ELKi5hQEajg53f+WjJSJozffA5RIbY97Sw0Fon+eC3j0Dswsly0HXrwQ9vV/9JWZhZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772826760; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zgbYRpk8ljdnbZv89/v2Xx4zmhiXOdG5XIL02YG2oOc=; b=A7WS+aJB9XydtjQOG98uw6R/tsHxCAvB9xV1cudC/2qklmlIpVk0feWRCC4urL0PHEMNd5/TtLq/XqG9Y1K1F1aFX0cUjpzKAZUXuNA3oOCUFV1+DgxEc/bJRA/P2/NOhU1qecl6jKetOFbT83F/B4L8ocR1Omq+pqAXONWuSfc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772826760396486.3381784765063; Fri, 6 Mar 2026 11:52:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vybDC-0004sR-1H; Fri, 06 Mar 2026 14:51:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vybCO-0004Ci-UA for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:02 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vybCL-0000QU-9f for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:00 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4837584120eso74144715e9.1 for ; Fri, 06 Mar 2026 11:50:56 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-485246ece8bsm36441285e9.4.2026.03.06.11.50.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:50:53 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A9953689D7; Fri, 06 Mar 2026 19:50:49 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772826655; x=1773431455; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zgbYRpk8ljdnbZv89/v2Xx4zmhiXOdG5XIL02YG2oOc=; b=r2HBE0Jof+O1EhMAIrae3wmzXNtc2X9ClcZF7k4i9bXGchFOvKLm493cBNBvCiU1zn GNU4W3BYDdXUHQZrFXDk2Fzoz/raMHr3VtBbLziMySB1nEqbDXqmlxi6anqzSQ2J35L5 EqnoJ32Gf9Apl54rLandKkEwf2hCDid6tjmXAov7KBF+a8NQivR68U1nBbWu+O3BRIZO Cf8LTGjSVGN6uEahfXEDBhINk9QhEvR3p9hfF7jvUn9jGmK76AbfwlU9RhCFfuRS/lmQ vpByJU2hXScCaDixW34FODkpNQbhmUdeLHMeE0vf3XnG1tOMMzqdoNWJIs9ttOzZCP4l RzGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772826655; x=1773431455; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=zgbYRpk8ljdnbZv89/v2Xx4zmhiXOdG5XIL02YG2oOc=; b=F7ItaHIpP3RUtoFQ5E/WV9aVjehgrcqdxGnSPoiY0TtOgPpsqG5kX6XvRUMOW13SfE Ug6V4kEiIXiygXivlNdyihjEJnGIuZMy1aswDkFTQLrWf7oW1r9T9Qk63+LkyEtR9rlE 16AXYT+7AFGosCI1rZjIFV+e54fSxjVCJ0E3dIEb59eCT6S6VQ1PzGMhZuz3JwyaIJ8x VpGIdsTY1AjhnHFHfYUhH6gjT0crZRG4slwjuyYIRVGVaxlLTgjxqAzi+FqtQAsRhySH eNbYD6IGj6AGpnufrr7IXOiyRrHlFJC8pHcBvFmsseQlt91Rw+ExEd+BB3ZySqF53q6q j2Aw== X-Gm-Message-State: AOJu0Ywb/WPcT2APypPCXTOPLEN6GGYx65Kx6XsNxTyYwF0nhFH5Hymu uMyK9ur4CenYnseXPMpc9bVHOHThVfWHVei9Ji6NsuTX/keftw4w47u5T864addU8ss= X-Gm-Gg: ATEYQzwWT+6OpexXDJ6ELB2PTAmJI+kg1EAzg5qpyrp+ARVGIzEaklKkblXzbRrfFSf G3BkAGokAXNl+zTH8tRb+Ge7h+x+hkuWN+/9wC2Cy5dB1K/CacIlcNZ4V6bXVVUWiwS3mm/IqKe JL53cp2nG71YYtfB/DDN2JOTGPES081lWkNPI8nFi28Vuy+HaY689q3WvYr5VMl00fSo/Lrgvg/ XwtqyLBRDMQposMcSUyw9n65wu3wMfKjtzU6/xM3w1LqRvY0fgdCu918lvYAPansFGc2DweqyeA yrDewHJ+X6Ux9aS9UbEsVS5s3XAiTNXg2iLthh5kKzjLlPNDNNnDsWDD5kCnHZc0IQW+aV3RCpo /iI+gYf+wOqpya7zqmvgAYtKBjQ2lWAqCCBEwWEyGTBTeFNSmuvijX0phJ4rrvPOPA1rDulRKQt SjvT0SIcPcLD9cABZ5ig/NiSk= X-Received: by 2002:a05:600c:4591:b0:483:6d4a:7e6d with SMTP id 5b1f17b1804b1-48526978644mr51581675e9.30.1772826655452; Fri, 06 Mar 2026 11:50:55 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierre-Eric Pelloux-Prayer , Akihiko Odaki , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Yiwei Zhang , Dmitry Osipenko , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 08/20] ui/sdl2: Implement dpy dmabuf functions Date: Fri, 6 Mar 2026 19:50:35 +0000 Message-ID: <20260306195048.2869788-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306195048.2869788-1-alex.bennee@linaro.org> References: <20260306195048.2869788-1-alex.bennee@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::333; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772826762836154100 From: Pierre-Eric Pelloux-Prayer If EGL is used, we can rely on dmabuf to import textures without doing copies. To get this working on X11, we use the existing SDL hint: SDL_HINT_VIDEO_X11_FORCE_EGL (because dmabuf can't be used with GLX). Reviewed-by: Akihiko Odaki Acked-by: Michael S. Tsirkin Tested-by: Alex Benn=C3=A9e Signed-off-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Yiwei Zhang Signed-off-by: Dmitry Osipenko Message-ID: <20260303151422.977399-7-dmitry.osipenko@collabora.com> [AJB: ifdef CONFIG_OPENGL/CONFIG_GBM for non-linux hosts] Message-ID: <20260304165043.1437519-9-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e diff --git a/meson.build b/meson.build index 7b4e5bc72b5..6b1838b159e 100644 --- a/meson.build +++ b/meson.build @@ -1946,10 +1946,8 @@ if get_option('gtk') \ endif endif =20 -x11 =3D not_found -if gtkx11.found() - x11 =3D dependency('x11', method: 'pkg-config', required: gtkx11.found()) -endif +x11 =3D dependency('x11', method: 'pkg-config', required: gtkx11.found()) + png =3D not_found if get_option('png').allowed() and have_system png =3D dependency('libpng', version: '>=3D1.6.34', required: get_optio= n('png'), diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h index dbe6e3d9739..9daf5ecffae 100644 --- a/include/ui/sdl2.h +++ b/include/ui/sdl2.h @@ -45,6 +45,7 @@ struct sdl2_console { bool gui_keysym; SDL_GLContext winctx; QKbdState *kbd; + bool has_dmabuf; #ifdef CONFIG_OPENGL QemuGLShader *gls; egl_fb guest_fb; @@ -96,5 +97,11 @@ void sdl2_gl_scanout_texture(DisplayChangeListener *dcl, void *d3d_tex2d); void sdl2_gl_scanout_flush(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t h); +void sdl2_gl_scanout_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf); +void sdl2_gl_release_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf); +bool sdl2_gl_has_dmabuf(DisplayChangeListener *dcl); +void sdl2_gl_console_init(struct sdl2_console *scon); =20 #endif /* SDL2_H */ diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c index fbac3edbc09..bb066cdd885 100644 --- a/ui/sdl2-gl.c +++ b/ui/sdl2-gl.c @@ -26,6 +26,8 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/main-loop.h" +#include "qemu/error-report.h" #include "ui/console.h" #include "ui/input.h" #include "ui/sdl2.h" @@ -250,3 +252,69 @@ void sdl2_gl_scanout_flush(DisplayChangeListener *dcl, =20 SDL_GL_SwapWindow(scon->real_window); } + +#ifdef CONFIG_GBM +void sdl2_gl_scanout_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf) +{ + struct sdl2_console *scon =3D container_of(dcl, struct sdl2_console, d= cl); + const int *fds; + + assert(scon->opengl); + SDL_GL_MakeCurrent(scon->real_window, scon->winctx); + + egl_dmabuf_import_texture(dmabuf); + if (!qemu_dmabuf_get_texture(dmabuf)) { + fds =3D qemu_dmabuf_get_fds(dmabuf, NULL); + error_report("%s: failed fd=3D%d", __func__, fds ? fds[0] : -1); + return; + } + + sdl2_gl_scanout_texture(dcl, qemu_dmabuf_get_texture(dmabuf), false, + qemu_dmabuf_get_width(dmabuf), + qemu_dmabuf_get_height(dmabuf), + 0, 0, + qemu_dmabuf_get_width(dmabuf), + qemu_dmabuf_get_height(dmabuf), + NULL); + + if (qemu_dmabuf_get_allow_fences(dmabuf)) { + scon->guest_fb.dmabuf =3D dmabuf; + } +} + +void sdl2_gl_release_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf) +{ + egl_dmabuf_release_texture(dmabuf); +} + +bool sdl2_gl_has_dmabuf(DisplayChangeListener *dcl) +{ + struct sdl2_console *scon =3D container_of(dcl, struct sdl2_console, d= cl); + + return scon->has_dmabuf; +} +#endif + +void sdl2_gl_console_init(struct sdl2_console *scon) +{ + bool hidden =3D scon->hidden; + + scon->hidden =3D true; + scon->surface =3D qemu_create_displaysurface(1, 1); + sdl2_window_create(scon); + + /* + * QEMU checks whether console supports dma-buf before switching + * to the console. To break this chicken-egg problem we pre-check + * dma-buf availability beforehand using a dummy SDL window. + */ + scon->has_dmabuf =3D qemu_egl_has_dmabuf(); + + sdl2_window_destroy(scon); + qemu_free_displaysurface(scon->surface); + + scon->surface =3D NULL; + scon->hidden =3D hidden; +} diff --git a/ui/sdl2.c b/ui/sdl2.c index 032dc14bc39..aaaede56e0e 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -35,6 +35,10 @@ #include "qemu/log.h" #include "qemu-main.h" =20 +#ifdef CONFIG_X11 +#include +#endif + static int sdl2_num_outputs; static struct sdl2_console *sdl2_console; =20 @@ -120,6 +124,11 @@ void sdl2_window_create(struct sdl2_console *scon) /* The SDL renderer is only used by sdl2-2D, when OpenGL is disabl= ed */ scon->real_renderer =3D SDL_CreateRenderer(scon->real_window, -1, = 0); } + +#ifdef CONFIG_OPENGL + qemu_egl_display =3D eglGetCurrentDisplay(); +#endif + sdl_update_caption(scon); } =20 @@ -808,6 +817,12 @@ static const DisplayChangeListenerOps dcl_gl_ops =3D { .dpy_gl_scanout_disable =3D sdl2_gl_scanout_disable, .dpy_gl_scanout_texture =3D sdl2_gl_scanout_texture, .dpy_gl_update =3D sdl2_gl_scanout_flush, + +#ifdef CONFIG_GBM + .dpy_gl_scanout_dmabuf =3D sdl2_gl_scanout_dmabuf, + .dpy_gl_release_dmabuf =3D sdl2_gl_release_dmabuf, + .dpy_has_dmabuf =3D sdl2_gl_has_dmabuf, +#endif }; =20 static bool @@ -835,6 +850,35 @@ static void sdl2_display_early_init(DisplayOptions *o) } } =20 +static void sdl2_set_hint_x11_force_egl(void) +{ +#if defined(SDL_HINT_VIDEO_X11_FORCE_EGL) && defined(CONFIG_OPENGL) && \ + defined(CONFIG_X11) + Display *x_disp =3D XOpenDisplay(NULL); + EGLDisplay egl_display; + + if (!x_disp) { + return; + } + + /* Prefer EGL over GLX to get dma-buf support. */ + egl_display =3D eglGetDisplay((EGLNativeDisplayType)x_disp); + + if (egl_display !=3D EGL_NO_DISPLAY) { + /* + * Setting X11_FORCE_EGL hint doesn't make SDL to prefer X11 over + * Wayland. SDL will use Wayland driver even if XWayland presents. + * It's always safe to set the hint even if X11 is not used by SDL. + * SDL will work regardless of the hint. + */ + SDL_SetHint(SDL_HINT_VIDEO_X11_FORCE_EGL, "1"); + eglTerminate(egl_display); + } + + XCloseDisplay(x_disp); +#endif +} + static void sdl2_display_init(DisplayState *ds, DisplayOptions *o) { uint8_t data =3D 0; @@ -862,6 +906,7 @@ static void sdl2_display_init(DisplayState *ds, Display= Options *o) SDL_SetHint(SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED, "0"); #endif SDL_SetHint(SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4, "1"); + sdl2_set_hint_x11_force_egl(); SDL_EnableScreenSaver(); memset(&info, 0, sizeof(info)); SDL_VERSION(&info.version); @@ -906,9 +951,12 @@ static void sdl2_display_init(DisplayState *ds, Displa= yOptions *o) #endif sdl2_console[i].dcl.con =3D con; sdl2_console[i].kbd =3D qkbd_state_init(con); +#ifdef CONFIG_OPENGL if (display_opengl) { qemu_console_set_display_gl_ctx(con, &sdl2_console[i].dgc); + sdl2_gl_console_init(&sdl2_console[i]); } +#endif register_displaychangelistener(&sdl2_console[i].dcl); =20 #if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_X11) --=20 2.47.3 From nobody Mon Apr 13 11:14:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772826742; cv=none; d=zohomail.com; s=zohoarc; b=h1RKbXAUsfnepOiVG+8ODN4lv9I8O+Lo0ZtCb2WyEYfwn+i+cKUpnu7bmuQO0qZz9nL3VzhOm3cBHo98qgZl7vjB4jze0uVWP5sj9G0Iy5mL1NMqQHYal1dzqJtKluBd1PWCf5DCKl6H7XuhFcCLhKhSpNxjTeCxlCNk0K+f+cA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772826742; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jx8Lc4PU9gFc5YSQurhHft6B2Pg7POf9lPTDKPwGiY8=; b=Q82Y2uzeFHtJ6bACziIWsW4yyeC2/8GRgRG75nJhyWsTG/LyJjKIvi3gIDnZzjSw2A0BNTsN7ulrh1RutMjCt06Cq1ClC4z8kY7WaM4F4+Hcqdeb0csdrCPuCey+5uZUe7GN3YT6sznIAnSUzBWb7QgSHdWoTLpr02AoboN8Q9I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772826742683715.184834669059; Fri, 6 Mar 2026 11:52:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vybDS-0006J3-OS; Fri, 06 Mar 2026 14:52:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vybCO-0004CW-1O for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:02 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vybCL-0000QL-9p for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:50:59 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4852a9c6309so4261835e9.0 for ; Fri, 06 Mar 2026 11:50:56 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-485276b7571sm54152365e9.13.2026.03.06.11.50.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:50:53 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id C2EFA689D8; Fri, 06 Mar 2026 19:50:49 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772826655; x=1773431455; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jx8Lc4PU9gFc5YSQurhHft6B2Pg7POf9lPTDKPwGiY8=; b=dIEnuew42qO3M49KQczvamTkWMCh7rQAhHsVbE1pcGT2MRFGRGFxOZKF0JbTw0Rg36 cqZGhDhLJuWG8QQVuehtOhRPdk4fWehd9mhU/n9EXeR9NYow6SusYqjE5WGLzunTfcw5 GTbfSODgcWLIkDAQx5UKLmMdwYaNi/gDZgOge5ztLC5K6nboQNBw4zzD1XIL6zEOP7Gk 82fPsPKV6Ewntekez09OuZPK+Ttf8VxMQO/p2wwTGH9YGQCaPxCLAG8p8b9fqQ4xtoq7 7bmTWbZbXAD2LHwSJabeWu4EyjzzEvLMWrF9+5leSB93GcjCQaQx+mXbpaAjgxwbbFmP XuXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772826655; x=1773431455; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=jx8Lc4PU9gFc5YSQurhHft6B2Pg7POf9lPTDKPwGiY8=; b=pz2xFONiW7f1afOwZraq5hZNlFV1Sk44qwffBlqP3B8Mr/rgdX2FBoxiCAwlDwnpon ZHT69DTGFqCSWQjns8l+WzZZeXfUkkKPZG3cjTByxboKSNKnUqM9ceQBhLkFyyuCvdIg YNcoDAyGDF+FN1ykAtlE2aVOA1en3aWZBgCadl+bBBUF/+l0DVv3yEP6zKijvOjJrNv/ h9uXUH1Xt6I6lbVxmjxVjlTS8Jw51Zgc2du/GTyOgyOW7WL/1GEAwBCQOBvR+yOegwy0 JcOaZDLoWW7xJXVl5zjTMk5BJpdkZfrKW9OskYOUmtXlPY8L6n6E/WbnQi7XNG0dJ2K8 t4dQ== X-Gm-Message-State: AOJu0YyzM4RWCOd8vVAy7mcFZ8tA+YhqJa2L+dHUpItYuC/9Xl2dTBE7 B6XAITaMeQo1QEpFJp6BTOzzdaVHT2h/8JW9pfl1RfJuUpmzFy+yGhCweLRemlvjZ8I= X-Gm-Gg: ATEYQzxW3No7OjmFX8yx2QqsNXvK/Ig0VD/pLWXP4iSdINKk/yVkAJLaDtV3PzhMEy/ px3wZjZ0/tAPiyLunbighMgZjvBxpQvx1yTlDUJnJwWYjIkbVDaP6Q6VYXi0U0lmfi0BfGZeUQO 6OzSipLgRXcS3YIH6INkv4J7UM0c1/+O22l5kDLPzBvutCk5XdWSVGV+PixZLh0q/h1G5rcfDz3 z1XI1GemQbrLhJRDcO3/gEZdIsoiBf+wG7EFP9JO3Dhkr9OL+I50b3YLePI1wkoJ6b0wNpcuyI+ MbvfUfheZUvybodUkPf4cZDmBXBMFB/RpoTH3Gc838h3T1Xg0wYerOHPR9hD/qdvj9HJwJLQRDi 6MZ0ZQhX+5Ee3VvsW8foV9dWfEFZzDZqgynXTjRT/ci0uwrkrhZfrtaOuSSdYxIZgykh55LyKvX 4YYekmkgfiIift0O/tDwF2n3FYAS/8ngkxzQ== X-Received: by 2002:a05:600c:609a:b0:477:63a4:88fe with SMTP id 5b1f17b1804b1-48526919691mr56836275e9.2.1772826654838; Fri, 06 Mar 2026 11:50:54 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , qemu-stable@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Akihiko Odaki , "Michael S. Tsirkin" Subject: [PULL 09/20] virtio-gpu: Ensure BHs are invoked only from main-loop thread Date: Fri, 6 Mar 2026 19:50:36 +0000 Message-ID: <20260306195048.2869788-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306195048.2869788-1-alex.bennee@linaro.org> References: <20260306195048.2869788-1-alex.bennee@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::329; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772826744571154100 From: Dmitry Osipenko QEMU's display GL core is tied to main-loop thread and virtio-gpu interacts with display while processing GPU commands. Virtio-gpu BHs work in generic AIO context that can be invoked on vCPU thread, while GL and UI toolkits are bound to the main-loop thread. Make virtio-gpu BHs use iohandler AIO context that is handled in a main-loop thread only. 0 SDL_GL_MakeCurrent() (libSDL3) 1 SDL_GL_MakeCurrent_REAL() (libSDL2) 2 sdl2_gl_make_context_current() (ui/sdl2-gl.c:201) 3 make_current() (virglrenderer.c:639) 4 vrend_finish_context_switch() (vrend_renderer.c:11630) 5 vrend_hw_switch_context() (vrend_renderer.c:11613) 6 vrend_renderer_force_ctx_0() (vrend_renderer.c:12986) 7 virgl_renderer_force_ctx_0() (virglrenderer.c:460) 8 virtio_gpu_virgl_process_cmd() (virtio-gpu-virgl.c:1013) 9 virtio_gpu_process_cmdq() (virtio-gpu.c:1050) 10 virtio_gpu_gl_handle_ctrl() (virtio-gpu-gl.c:86) 11 aio_bh_poll() (util/async.c) 12 aio_poll() (util/aio-posix.c) 13 blk_pwrite() (block/block-gen.c:1985) 14 pflash_update() (pflash_cfi01.c:396) 15 pflash_write() (pflash_cfi01.c:541) 16 memory_region_dispatch_write() (system/memory.c:1554) 17 flatview_write() (system/physmem.c:3333) 18 address_space_write() (system/physmem.c:3453) 19 kvm_cpu_exec() (accel/kvm/kall-all.c:3248) 20 kvm_vcpu_thread_fn() (accel/kvm/kaccel-ops.c:53) Cc: qemu-stable@nongnu.org Signed-off-by: Dmitry Osipenko Message-ID: <20260303151422.977399-8-dmitry.osipenko@collabora.com> Message-ID: <20260304165043.1437519-10-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 42d20899390..6344bd7b689 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -552,4 +552,14 @@ QEMUBH *virtio_bh_new_guarded_full(DeviceState *dev, #define virtio_bh_new_guarded(dev, cb, opaque) \ virtio_bh_new_guarded_full((dev), (cb), (opaque), (stringify(cb))) =20 +/* + * The "_io" variant runs BH only on a main-loop thread, while generic BH + * may run on a vCPU thread. + */ +QEMUBH *virtio_bh_io_new_guarded_full(DeviceState *dev, + QEMUBHFunc *cb, void *opaque, + const char *name); +#define virtio_bh_io_new_guarded(dev, cb, opaque) \ + virtio_bh_io_new_guarded_full((dev), (cb), (opaque), (stringify(cb))) + #endif diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 0f754829fb7..10c4b5160f4 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -1203,9 +1203,9 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) } =20 #if VIRGL_VERSION_MAJOR >=3D 1 - gl->cmdq_resume_bh =3D aio_bh_new(qemu_get_aio_context(), - virtio_gpu_virgl_resume_cmdq_bh, - g); + gl->cmdq_resume_bh =3D virtio_bh_io_new_guarded(DEVICE(g), + virtio_gpu_virgl_resume_= cmdq_bh, + g); #endif =20 return 0; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index b2af861f0d8..a89d49aa8cc 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1526,9 +1526,9 @@ void virtio_gpu_device_realize(DeviceState *qdev, Err= or **errp) =20 g->ctrl_vq =3D virtio_get_queue(vdev, 0); g->cursor_vq =3D virtio_get_queue(vdev, 1); - g->ctrl_bh =3D virtio_bh_new_guarded(qdev, virtio_gpu_ctrl_bh, g); - g->cursor_bh =3D virtio_bh_new_guarded(qdev, virtio_gpu_cursor_bh, g); - g->reset_bh =3D qemu_bh_new(virtio_gpu_reset_bh, g); + g->ctrl_bh =3D virtio_bh_io_new_guarded(qdev, virtio_gpu_ctrl_bh, g); + g->cursor_bh =3D virtio_bh_io_new_guarded(qdev, virtio_gpu_cursor_bh, = g); + g->reset_bh =3D virtio_bh_io_new_guarded(qdev, virtio_gpu_reset_bh, g); qemu_cond_init(&g->reset_cond); QTAILQ_INIT(&g->reslist); QTAILQ_INIT(&g->cmdq); diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 22d798e6cdd..4c5a4479bfa 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -4497,3 +4497,13 @@ QEMUBH *virtio_bh_new_guarded_full(DeviceState *dev, return qemu_bh_new_full(cb, opaque, name, &transport->mem_reentrancy_guard); } + +QEMUBH *virtio_bh_io_new_guarded_full(DeviceState *dev, + QEMUBHFunc *cb, void *opaque, + const char *name) +{ + DeviceState *transport =3D qdev_get_parent_bus(dev)->parent; + + return aio_bh_new_full(iohandler_get_aio_context(), cb, opaque, name, + &transport->mem_reentrancy_guard); +} --=20 2.47.3 From nobody Mon Apr 13 11:14:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772826728; cv=none; d=zohomail.com; s=zohoarc; b=K//H/H2Obnf6e8BZP1DkBv9VNyYxCaobxOPkCrN09aT2UBhd9QLZhPKMH0Jpm0pZSBU4BlNxb79h3WtaQhbmYFbszwznur64la7KLE3XxX20DFTjZpa2pmFRi/l4PJWwDHg3rLUzd56Lm8s5ZhyCuT1OYuSHkUi2yJlEHw+QmoM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772826728; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gfe3K7QKeRshXSLGLqPywya5dd4X5MPIdqIvBVHRxYY=; b=eoU+coES8TmCHJNJOiU/gbEtzG+wWn8DER6GgR1ozCJ50hxlRwO9nKHms1JpYIGEQD2D/FFYaOpiW8F4som7Yy7W9mohzX2VgK470ZUQCEHzEriGXQQV986JVjLeRIXz1wjF33mqwthpFzuRxdlnlhuwgTJYvtdwTPnkW2/NfKE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772826728771992.328855272711; Fri, 6 Mar 2026 11:52:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vybDE-0004te-4P; Fri, 06 Mar 2026 14:51:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vybCT-0004DX-UR for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:07 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vybCQ-0000Rx-1x for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:03 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-483a233819aso94836385e9.3 for ; Fri, 06 Mar 2026 11:51:00 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4851fae00absm133406515e9.4.2026.03.06.11.50.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:50:53 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id DA061689D9; Fri, 06 Mar 2026 19:50:49 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772826660; x=1773431460; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gfe3K7QKeRshXSLGLqPywya5dd4X5MPIdqIvBVHRxYY=; b=XcEwnzOIk7U2iRKQlQ/Q7pZnrnaQ+z3RET2UJJcvdkuosp0/51Ik/40JhBZQl2zExo W/+M87x8elxbUgjv7sZVMZjJPUbE6MvxfpXtKxI9joIj+5k33H/sRe3/zJ0e5mIm9iz2 l+DZwWTq9+SyspITjPPVFcQpWxc4FL39hJYo3HPfS4Ad+yr0IpBXjO1XCE5xw5kHLrN+ 4himvwGyt2CWQ9q0sRyTzh6Tg2MPXUItepmQBxNB8jAcAoAvl8Xxn4QN7NLe7H8sU2uW q1EYYVviUxzNsOBZPfBebW1cVpdADoc1qpw80vvGGNiXKbBtBYCg+cdEA5hs7T6zoWJW bSSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772826660; x=1773431460; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=gfe3K7QKeRshXSLGLqPywya5dd4X5MPIdqIvBVHRxYY=; b=IemlVMGXSSYMrkSGi55CsUip0msKjIcnlFD4Q7l2CkO74IJR+FFGss/xZePfKSI8cd wN1FPbDkbmhRWOT7McyP2GpuRbhoKiIrFPYh8kn8lLgN3SUsChuDmlIevDgvhR36hH0/ rZ3fARSk1S+c9wxdny4EDdydrwBtXaGxp1oH5RtpsMKGGsFsFgoMSEzc++E6u9OhsK9P u8UGTw2x9RAun4UWb/hwe3Xd8UAcH0XwiB4FkI1KPVD5cucXYSfTH1D3FN7paUmopErH zRSbvUZeUnXEBR+m7JE0PacXymhh/Fx6Gdn69MqC1Sys9rB91UKPRssPZJLVmPPeeomM 2+Hg== X-Gm-Message-State: AOJu0Ywn6ooNzK+5V4NazXnvbn0Jgm6+pXziglHg3OHNvZovgTM6wnz2 jrVCVzsOPBCoMlGWk0AUDTJk1qVoVwmcAwCAp1wagLg9mr8Hb2NYJED2shnCQEE7ZYk= X-Gm-Gg: ATEYQzyRDjB3jHnkZhIGtF50tMzSI4t8gDbbhGW8vagLix4rg+6TY5kh5gR2R6bwzCH QeN2WpGWoGVPsKEBimNZ6KTbzhjyFwuXbZLjONLqpcBUqNjis8pz5yd07+qvyg55NgdcoZ2jyIe faL/AysnOoQJQyg7941Jh9KPUcNML78FZfa48yzplURLRBzHZoBF8ADthfqMoaDVsMOSWIVlMVo yjk5PnzX9tRucOEqWTCPhr4+khnwh31LQW+CcJ1ZY75cnYenSIf4CABZuwEoFG8FZRuGiIIS7sg 0iR9AxqZwlbxDsqQhUe6z5R8R7EbEttujQ64v2pwmsr/ZN+3vc4u/1LFYpP8R4NoDnWi9nsdZ9w EBDvGvssudn0I0GEuPiqbWMkCVSunPDmP1W4WgxKLrbqari7rbMRFJCJ7xdEs2lVe0JashmBtcK I4LEP84K+hII+7DeS71yNfBxVcaMJz39FNrQ== X-Received: by 2002:a05:600c:34d2:b0:483:badb:6191 with SMTP id 5b1f17b1804b1-48526923595mr54794455e9.8.1772826659679; Fri, 06 Mar 2026 11:50:59 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , Akihiko Odaki , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pierre-Eric Pelloux-Prayer , Yiwei Zhang , Akihiko Odaki Subject: [PULL 10/20] virtio-gpu: Handle virgl fence creation errors Date: Fri, 6 Mar 2026 19:50:37 +0000 Message-ID: <20260306195048.2869788-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306195048.2869788-1-alex.bennee@linaro.org> References: <20260306195048.2869788-1-alex.bennee@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::32b; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772826730853154100 From: Dmitry Osipenko Print out error messages when virgl fence creation fails to aid debugging of the fence-related bugs. Reviewed-by: Akihiko Odaki Acked-by: Michael S. Tsirkin Tested-by: Alex Benn=C3=A9e Acked-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Yiwei Zhang Tested-by: Yiwei Zhang Signed-off-by: Dmitry Osipenko Message-ID: <20260303151422.977399-9-dmitry.osipenko@collabora.com> Message-ID: <20260304165043.1437519-11-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 10c4b5160f4..f00c666f61f 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -900,6 +900,7 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { bool cmd_suspended =3D false; + int ret; =20 VIRTIO_GPU_FILL_CMD(cmd->cmd_hdr); =20 @@ -1000,14 +1001,30 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, trace_virtio_gpu_fence_ctrl(cmd->cmd_hdr.fence_id, cmd->cmd_hdr.type); #if VIRGL_VERSION_MAJOR >=3D 1 if (cmd->cmd_hdr.flags & VIRTIO_GPU_FLAG_INFO_RING_IDX) { - virgl_renderer_context_create_fence(cmd->cmd_hdr.ctx_id, - VIRGL_RENDERER_FENCE_FLAG_MERG= EABLE, - cmd->cmd_hdr.ring_idx, - cmd->cmd_hdr.fence_id); + const uint32_t flags =3D VIRGL_RENDERER_FENCE_FLAG_MERGEABLE; + + ret =3D virgl_renderer_context_create_fence(cmd->cmd_hdr.ctx_id, f= lags, + cmd->cmd_hdr.ring_idx, + cmd->cmd_hdr.fence_id); + if (ret) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: virgl_renderer_context_create_fence error: = %s", + __func__, strerror(-ret)); + } return; } #endif - virgl_renderer_create_fence(cmd->cmd_hdr.fence_id, cmd->cmd_hdr.type); + + /* + * Unlike other virglrenderer functions, this one returns a positive + * error code. + */ + ret =3D virgl_renderer_create_fence(cmd->cmd_hdr.fence_id, 0); + if (ret) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: virgl_renderer_create_fence error: %s", + __func__, strerror(ret)); + } } =20 static void virgl_write_fence(void *opaque, uint32_t fence) --=20 2.47.3 From nobody Mon Apr 13 11:14:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772826740; cv=none; d=zohomail.com; s=zohoarc; b=H8xsMlDt9FyMuhTqFkz9/X/mInK6WhRLAVu5p454+IETXaEMp7ylOpsVFWOrzEYnJyTxg5AWoEPPRT0xvSQMITmBPq/rkw8lTFmdZsys3HQPhOSo/P+xVncwFq96HoaArFa7050/5GzKLT+l66fYIp4LCihV8AeDeJCXEOxg+8E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772826740; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=howWJpF0OymlEFhH8Fw/3xWbTAfWZ7/hMcypwjVC4sI=; b=GY458W7+awLSZdMGuGNGZu7zxDN2bOiAQamkHVsJ9nKrx9tkMWiKWOK46IPrCd7IWHrkfCTe8FlcQBYzUoncitaedEjITjJxQSykt2i/ZkCIoqAa5uGoRxlotNuXDTlnEQuS5nQ7Hafke2t9Zf3Wa6CwN5Qdx1kwKpkB8InVQ1I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772826740646108.91872621832954; Fri, 6 Mar 2026 11:52:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vybDN-00061T-4U; Fri, 06 Mar 2026 14:52:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vybCQ-0004Cl-BR for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:03 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vybCN-0000R9-9m for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:01 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4852afd42ceso3855025e9.2 for ; Fri, 06 Mar 2026 11:50:58 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4851fad2812sm227679535e9.1.2026.03.06.11.50.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:50:54 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id F3AA3689DA; Fri, 06 Mar 2026 19:50:49 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772826658; x=1773431458; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=howWJpF0OymlEFhH8Fw/3xWbTAfWZ7/hMcypwjVC4sI=; b=Y5mevFZAPmU61ZbOBUAENqL7Ke27liPTEUHoyO8plSvCGwD6OWdCPVimBncoW/jcfK HPzDoutnjRei4/9BaCEMxQHQt5g60mtjx9EVUpYrQM8wjCA1nZLJAm9IBa3vcDsCCpN/ HNxozlasPhBhdhXr0dYLu/jxkRcvxl5hkBJaTnyTFsbBQNKUBzYPy1/LUR3Q84LkD2e8 z+9iU6PaZhmR6dNyznmn9+pior+RI6oCWeTUiZl7+IxgX4AFJzM3zd6t005EPqH9wY7K Nr2dHTRe8lHzkzGFCj3vPM0GZ1DOTCNTegrvbuorvnTtMVyooFWIHVngeVQlvWqBEsAr qdFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772826658; x=1773431458; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=howWJpF0OymlEFhH8Fw/3xWbTAfWZ7/hMcypwjVC4sI=; b=UW/DRuw4uCq13O02UdSDv6AxkdlTlfwGhYNBjG5B3JbeDOd1pFYhuucSfC1CdPPSlb fLlScMZXqWpXDne6WnX9vEi9xu09WCyqhUepoJ3BAqpgtIAKosisBjjIqpL4jdIojl7i K+pHkeE/eIC7rXhOwJ+IxX1Ye6BSbQDP96hl0VCdNbMCGd0yX5PPbe313BFVWgrWiBiq VP8QDbWr3wkGNUOwhuOESIFndqth3bRemh9YNGV4AHwud699kqVaKD1aQiE0lncEX2fq 2d3yVS+eirH92oPiidEoLmCxk8e5FoL5hgKn/1ZEi6OVebSr+ZTTiIF3edq4MC3lE2ql D68w== X-Gm-Message-State: AOJu0YxYYS2ifBd6CGIL4dMpjRTYIJOwrNvy/PX+Kdd6GwRybCIx4Piw eJ7SwF6YxMstVwIRMmaUOVWfkD0JcfPA2W01pT95rDOnQbqjZBkgzQqd7ZNcXLtztyA= X-Gm-Gg: ATEYQzzaOFM+VSpYoMkRne7JS6O1p5+z33JKysVc4BVeOGBJIX4r25qfbZVF/fvpdqi gsTdky56rwuMrEcMpnAg6Tesv/z100TL54YV02tNm2aEXfq98CT5/hSfAD4D5ZVUvqxMMuwX6Ba FCMPh44+vlzW/ujpM6qHNAQIBGIX8L2pMEYceCtQQafQldcTxaA7wnqZz3Fb8QCSgj1EFlUYiR8 G+AS0IRRn6Asyh1/ZGClTF6Y/GG+9dnj22jBfVrl0OCZhuJWp+b3vx28AuG+JN87IMcI9Aopub/ QGo58YYvho0nM0u++jtOsvuorki0Ejhfbrl3b77FvbwdPQZ5IjDATCre7d8Sf5DcMaYuW1kNtBe bA9RONn27hOLY9uodGCqxLyWXnONBIF4+o4KSbcyzWFUY+1tRnJUgvCCwyRWE1hOEB6au5CFA/p NXWTx3VA08nre9KmLuGCafkengBf4Yvi4tFQ== X-Received: by 2002:a05:600c:45d1:b0:483:a361:41a5 with SMTP id 5b1f17b1804b1-4852697866fmr56181425e9.30.1772826657754; Fri, 06 Mar 2026 11:50:57 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , Akihiko Odaki , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pierre-Eric Pelloux-Prayer , Yiwei Zhang , Akihiko Odaki , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 11/20] virtio-gpu: Support asynchronous fencing Date: Fri, 6 Mar 2026 19:50:38 +0000 Message-ID: <20260306195048.2869788-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306195048.2869788-1-alex.bennee@linaro.org> References: <20260306195048.2869788-1-alex.bennee@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::335; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772826742611154100 From: Dmitry Osipenko Support asynchronous fencing feature of virglrenderer. It allows Qemu to handle fence as soon as it's signalled instead of periodically polling the fence status. This feature is required for enabling DRM context support in Qemu because legacy fencing mode isn't supported for DRM contexts in virglrenderer. Reviewed-by: Akihiko Odaki Acked-by: Michael S. Tsirkin Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Acked-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Yiwei Zhang Tested-by: Yiwei Zhang Signed-off-by: Dmitry Osipenko Message-ID: <20260303151422.977399-10-dmitry.osipenko@collabora.com> Message-ID: <20260304165043.1437519-12-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e diff --git a/meson.build b/meson.build index 6b1838b159e..0029c970b08 100644 --- a/meson.build +++ b/meson.build @@ -2524,6 +2524,8 @@ config_host_data.set('CONFIG_VNC_JPEG', jpeg.found()) config_host_data.set('CONFIG_VNC_SASL', sasl.found()) if virgl.found() config_host_data.set('VIRGL_VERSION_MAJOR', virgl.version().split('.')[0= ]) + config_host_data.set('VIRGL_VERSION_MINOR', virgl.version().split('.')[1= ]) + config_host_data.set('VIRGL_VERSION_MICRO', virgl.version().split('.')[2= ]) endif config_host_data.set('CONFIG_VIRTFS', have_virtfs) config_host_data.set('CONFIG_VTE', vte.found()) diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 65312f869dd..2610a32e408 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -233,6 +233,13 @@ struct VirtIOGPUClass { Error **errp); }; =20 +struct virtio_gpu_virgl_context_fence { + uint32_t ctx_id; + uint32_t ring_idx; + uint64_t fence_id; + QSLIST_ENTRY(virtio_gpu_virgl_context_fence) next; +}; + /* VirtIOGPUGL renderer states */ typedef enum { RS_START, /* starting state */ @@ -250,6 +257,9 @@ struct VirtIOGPUGL { QEMUTimer *print_stats; =20 QEMUBH *cmdq_resume_bh; + + QEMUBH *async_fence_bh; + QSLIST_HEAD(, virtio_gpu_virgl_context_fence) async_fenceq; }; =20 struct VhostUserGPU { @@ -380,5 +390,6 @@ void virtio_gpu_virgl_reset_scanout(VirtIOGPU *g); void virtio_gpu_virgl_reset(VirtIOGPU *g); int virtio_gpu_virgl_init(VirtIOGPU *g); GArray *virtio_gpu_virgl_get_capsets(VirtIOGPU *g); +void virtio_gpu_virgl_reset_async_fences(VirtIOGPU *g); =20 #endif diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c index b98ef2ef987..3e0680880e1 100644 --- a/hw/display/virtio-gpu-gl.c +++ b/hw/display/virtio-gpu-gl.c @@ -169,6 +169,11 @@ static void virtio_gpu_gl_device_unrealize(DeviceState= *qdev) if (gl->renderer_state >=3D RS_INITED) { #if VIRGL_VERSION_MAJOR >=3D 1 qemu_bh_delete(gl->cmdq_resume_bh); + + if (gl->async_fence_bh) { + virtio_gpu_virgl_reset_async_fences(g); + qemu_bh_delete(gl->async_fence_bh); + } #endif if (virtio_gpu_stats_enabled(g->parent_obj.conf)) { timer_free(gl->print_stats); diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index f00c666f61f..ae1880c358b 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -24,6 +24,23 @@ =20 #include =20 +/* + * VIRGL_CHECK_VERSION available since libvirglrenderer 1.0.1 and was fixed + * in 1.1.0. Undefine bugged version of the macro and provide our own. + */ +#if defined(VIRGL_CHECK_VERSION) && \ + VIRGL_VERSION_MAJOR =3D=3D 1 && VIRGL_VERSION_MINOR < 1 +#undef VIRGL_CHECK_VERSION +#endif + +#ifndef VIRGL_CHECK_VERSION +#define VIRGL_CHECK_VERSION(major, minor, micro) \ + (VIRGL_VERSION_MAJOR > (major) || \ + VIRGL_VERSION_MAJOR =3D=3D (major) && VIRGL_VERSION_MINOR > (minor) |= | \ + VIRGL_VERSION_MAJOR =3D=3D (major) && VIRGL_VERSION_MINOR =3D=3D (min= or) && \ + VIRGL_VERSION_MICRO >=3D (micro)) +#endif + struct virtio_gpu_virgl_resource { struct virtio_gpu_simple_resource base; MemoryRegion *mr; @@ -1079,6 +1096,103 @@ static void virgl_write_context_fence(void *opaque,= uint32_t ctx_id, } #endif =20 +void virtio_gpu_virgl_reset_async_fences(VirtIOGPU *g) +{ + struct virtio_gpu_virgl_context_fence *f; + VirtIOGPUGL *gl =3D VIRTIO_GPU_GL(g); + + while (!QSLIST_EMPTY(&gl->async_fenceq)) { + f =3D QSLIST_FIRST(&gl->async_fenceq); + + QSLIST_REMOVE_HEAD(&gl->async_fenceq, next); + + g_free(f); + } +} + +#if VIRGL_CHECK_VERSION(1, 1, 2) +static void virtio_gpu_virgl_async_fence_bh(void *opaque) +{ + QSLIST_HEAD(, virtio_gpu_virgl_context_fence) async_fenceq; + struct virtio_gpu_ctrl_command *cmd, *tmp; + struct virtio_gpu_virgl_context_fence *f; + VirtIOGPU *g =3D opaque; + VirtIOGPUGL *gl =3D VIRTIO_GPU_GL(g); + + if (gl->renderer_state !=3D RS_INITED) { + return; + } + + QSLIST_MOVE_ATOMIC(&async_fenceq, &gl->async_fenceq); + + while (!QSLIST_EMPTY(&async_fenceq)) { + f =3D QSLIST_FIRST(&async_fenceq); + + QSLIST_REMOVE_HEAD(&async_fenceq, next); + + QTAILQ_FOREACH_SAFE(cmd, &g->fenceq, next, tmp) { + /* + * the guest can end up emitting fences out of order + * so we should check all fenced cmds not just the first one. + */ + if (cmd->cmd_hdr.fence_id > f->fence_id) { + continue; + } + if (cmd->cmd_hdr.flags & VIRTIO_GPU_FLAG_INFO_RING_IDX) { + if (cmd->cmd_hdr.ring_idx !=3D f->ring_idx) { + continue; + } + if (cmd->cmd_hdr.ctx_id !=3D f->ctx_id) { + continue; + } + } + virtio_gpu_ctrl_response_nodata(g, cmd, VIRTIO_GPU_RESP_OK_NOD= ATA); + QTAILQ_REMOVE(&g->fenceq, cmd, next); + g_free(cmd); + } + + trace_virtio_gpu_fence_resp(f->fence_id); + g_free(f); + g->inflight--; + if (virtio_gpu_stats_enabled(g->parent_obj.conf)) { + trace_virtio_gpu_dec_inflight_fences(g->inflight); + } + } +} + +static void +virtio_gpu_virgl_push_async_fence(VirtIOGPU *g, uint32_t ctx_id, + uint32_t ring_idx, uint64_t fence_id) +{ + struct virtio_gpu_virgl_context_fence *f; + VirtIOGPUGL *gl =3D VIRTIO_GPU_GL(g); + + f =3D g_new(struct virtio_gpu_virgl_context_fence, 1); + f->ctx_id =3D ctx_id; + f->ring_idx =3D ring_idx; + f->fence_id =3D fence_id; + + QSLIST_INSERT_HEAD_ATOMIC(&gl->async_fenceq, f, next); + + qemu_bh_schedule(gl->async_fence_bh); +} + +static void virgl_write_async_fence(void *opaque, uint32_t fence) +{ + VirtIOGPU *g =3D opaque; + + virtio_gpu_virgl_push_async_fence(g, 0, UINT32_MAX, fence); +} + +static void virgl_write_async_context_fence(void *opaque, uint32_t ctx_id, + uint32_t ring_idx, uint64_t fe= nce) +{ + VirtIOGPU *g =3D opaque; + + virtio_gpu_virgl_push_async_fence(g, ctx_id, ring_idx, fence); +} +#endif + static virgl_renderer_gl_context virgl_create_context(void *opaque, int scanout_idx, struct virgl_renderer_gl_ctx_param *params) @@ -1178,6 +1292,8 @@ void virtio_gpu_virgl_reset_scanout(VirtIOGPU *g) void virtio_gpu_virgl_reset(VirtIOGPU *g) { virgl_renderer_reset(); + + virtio_gpu_virgl_reset_async_fences(g); } =20 int virtio_gpu_virgl_init(VirtIOGPU *g) @@ -1190,6 +1306,12 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) if (qemu_egl_display) { virtio_gpu_3d_cbs.version =3D 4; virtio_gpu_3d_cbs.get_egl_display =3D virgl_get_egl_display; +#if VIRGL_CHECK_VERSION(1, 1, 2) + virtio_gpu_3d_cbs.write_fence =3D virgl_write_async_fence; + virtio_gpu_3d_cbs.write_context_fence =3D virgl_write_async_contex= t_fence; + flags |=3D VIRGL_RENDERER_ASYNC_FENCE_CB; + flags |=3D VIRGL_RENDERER_THREAD_SYNC; +#endif } #endif #ifdef VIRGL_RENDERER_D3D11_SHARE_TEXTURE @@ -1223,6 +1345,11 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) gl->cmdq_resume_bh =3D virtio_bh_io_new_guarded(DEVICE(g), virtio_gpu_virgl_resume_= cmdq_bh, g); +#if VIRGL_CHECK_VERSION(1, 1, 2) + gl->async_fence_bh =3D virtio_bh_io_new_guarded(DEVICE(g), + virtio_gpu_virgl_async_f= ence_bh, + g); +#endif #endif =20 return 0; --=20 2.47.3 From nobody Mon Apr 13 11:14:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772826781; cv=none; d=zohomail.com; s=zohoarc; b=I+ocel6WUPii9/8dp1HcqGdyTMW4tI9R5ZMp6HE2i7er40JcAivnS1T+RdFcfkCY2JpWAqhcj9/3ssjjc4Ny5d/HpZ5pYYncPNn7NO0nCqkJDdF/UKKG3DIeU47h/lDLONkV2YIKd2k/q2U3AU8s47gdKn+Q3cC6JICkk0zv0u8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772826781; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TRS02MZ6aEMRyeENzvEVRS+yAlrpGP763UJyGyRbzXc=; b=Gbjpc+3Hz8OMx6AltIqo2czpRAyPd6o+P06Tuqu8F968O9bxOg8nAM4Fv+4GpZlXUpoHFl1NVzodU2I9b1lC4Cns2aJOw/cGt8Pc3B/dOjLo8U/RXvkKXUVdwuVIzf3FliXLmzMMW5J9ZUPrrWllHA+PFUI+bhCxUfrKen+ssws= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772826780988951.2069442583054; Fri, 6 Mar 2026 11:53:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vybDH-0005Js-CP; Fri, 06 Mar 2026 14:51:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vybCQ-0004Cm-M9 for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:03 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vybCN-0000RN-Ts for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:02 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-48371119eacso114188165e9.2 for ; Fri, 06 Mar 2026 11:50:59 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4852470b412sm50445705e9.8.2026.03.06.11.50.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:50:54 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 1C692689DB; Fri, 06 Mar 2026 19:50:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772826658; x=1773431458; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TRS02MZ6aEMRyeENzvEVRS+yAlrpGP763UJyGyRbzXc=; b=oJx4mc1nXrJNLYxKPzxCpRyxkha4kdp6Xhey9n1IV9kqMLgociMFkTGVfJQdgWKJdP +3WiopOt4J6GJTdIfAqhCEdahEXHujILI62MbG8DJkoQFmmrurxhFn9xgHfqJh6OBSF0 kPWzYG/LgM53otGodpaEVhzuA8pjZ2NQMkNAnnsyoh4hBlDP9LxxbuDE6Ko3n/nMiR/H MUaeps+L4R4VGhNB7VxDVfzcSj7lIyl8Ui4FrxC3qnIHk0q79QfqAk4uzZ9jE6IIqYqe wUFQ641OnFmpv9c5WmxSPSaf5GUAOKeR9EfJqWNoIWZAoMluwOfEBknkM917F7atVWxB D/xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772826658; x=1773431458; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=TRS02MZ6aEMRyeENzvEVRS+yAlrpGP763UJyGyRbzXc=; b=Qzdm5hc9LNGO0/jxuk3WMagTlL5Kys4ENbQw3uJIbJQpff0zo0HIKyYJbTzp3ecEmC QoV83YwuKgojC9HbBps3/f+zv8uSDO1ay70txOeekEP58dJ2mT06427D0CpQJzahcl3n oaVE7Bn7e8LQzL1JX+EWUsFPvmxHnrHyItL0pw2BeKXrQXAx7BUaOfqFhAawAhJdJ8UE TKR7U/K0Rkl5Lb1+qi5fXOFO/FWreaQDvyWAWloogSXjSHEAK6VjTYeOsgnCIno+pKkx NtwqCgcGEWflzwVcGwVR5LVmE3a4IvKoWwH9bK3pUdnJiI5l9ZFlnMFy7sVJTBwsCtGf w4gA== X-Gm-Message-State: AOJu0Yxlt5JrnBOgcxoe0ppJZzWmfQg7QVkF/QvKqfgNV5lH20t5f2Cv FyRYhDcAQc9BsOFSjc94nHmErMoDOsXXEN++q/H9VlX5+LTq3ie+sFyTjZhHEZ+yN4w= X-Gm-Gg: ATEYQzxSYssu99b9M5Aa9T9lIdoc0iBq3fvfJlQp930toQ1wE4A1Kglt4bKPs29rjYG UKKG4tXUqpd4JSvsgpTT09jIJjUoU+Jw5Xmv/1BQyLOaRW5GtG68ZlUCXbFX09VqKXmuAvVdCsO x/VRjLxEu3hL3lUFgVhkQWfrvJDYyysnuduTpAZRB1qQOuzSdenxFxKOQyaz1uiaNlJ+++TF6/Z 4vFv+Uko3xYVn3Le5v6pwe5TCSnMnN5nrvq3tkIanTImW1XFCypaTz2SAVdcBYcQ21CIh1fS/4I DRTQfpA1b4pPmIiquhL74qIdiZXio4f3fvl38FI1k0Gr/tJUDgdhHAjKt/E/3BuUcMINiDaMApN q5h6FxCNusAjPthuSNCEpqb72sNo5El9N1XZ4bZJ++oKd31aesLtXz9dj4uQKDDq9RQ+JKzNEkZ cttkWRxSRUa6eCwnCBaMSIYnqz4gIsim9Ojg== X-Received: by 2002:a05:600c:8714:b0:477:6374:6347 with SMTP id 5b1f17b1804b1-48526957d50mr50072905e9.22.1772826658421; Fri, 06 Mar 2026 11:50:58 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , Akihiko Odaki , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pierre-Eric Pelloux-Prayer , Yiwei Zhang , Pierrick Bouvier , Akihiko Odaki Subject: [PULL 12/20] virtio-gpu: Support DRM native context Date: Fri, 6 Mar 2026 19:50:39 +0000 Message-ID: <20260306195048.2869788-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306195048.2869788-1-alex.bennee@linaro.org> References: <20260306195048.2869788-1-alex.bennee@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::330; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x330.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772826783235158500 From: Dmitry Osipenko Add support for DRM native contexts to VirtIO-GPU. DRM context is enabled using a new virtio-gpu-gl device option "drm_native_context=3Don". Unlike Virgl and Venus contexts that operate on application API level, DRM native contexts work on a kernel UAPI level. This lower level results in a lightweight context implementations that yield better performance. Reviewed-by: Akihiko Odaki Acked-by: Michael S. Tsirkin Tested-by: Alex Benn=C3=A9e Acked-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Yiwei Zhang Tested-by: Yiwei Zhang Signed-off-by: Dmitry Osipenko Message-ID: <20260303151422.977399-11-dmitry.osipenko@collabora.com> Message-ID: <20260304165043.1437519-13-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e diff --git a/docs/system/devices/virtio/virtio-gpu.rst b/docs/system/device= s/virtio/virtio-gpu.rst index 0f4bb304a9b..086e2fcf27b 100644 --- a/docs/system/devices/virtio/virtio-gpu.rst +++ b/docs/system/devices/virtio/virtio-gpu.rst @@ -84,6 +84,17 @@ of virtio-gpu host memory window. This is typically betw= een 256M and 8G. =20 .. _venus: https://gitlab.freedesktop.org/virgl/venus-protocol/ =20 +DRM native context is supported since release of `virglrenderer`_ v1.0.0 +using `drm`_ protocol. ``DRM`` virtio-gpu capability set ("capset") requi= res +host blob support (``hostmem`` and ``blob`` fields) and should be enabled +using ``drm_native_context`` field. The ``hostmem`` field specifies the s= ize +of virtio-gpu host memory window. This is typically between 256M and 8G. + +.. parsed-literal:: + -device virtio-gpu-gl,hostmem=3D8G,blob=3Don,drm_native_context=3Don + +.. _drm: https://gitlab.freedesktop.org/virgl/virglrenderer/-/tree/main/sr= c/drm + virtio-gpu rutabaga ------------------- =20 diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 2610a32e408..1a999887481 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -100,6 +100,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_RUTABAGA_ENABLED, VIRTIO_GPU_FLAG_VENUS_ENABLED, VIRTIO_GPU_FLAG_RESOURCE_UUID_ENABLED, + VIRTIO_GPU_FLAG_DRM_ENABLED, }; =20 #define virtio_gpu_virgl_enabled(_cfg) \ @@ -122,6 +123,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.hostmem > 0) #define virtio_gpu_venus_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_VENUS_ENABLED)) +#define virtio_gpu_drm_enabled(_cfg) \ + (_cfg.flags & (1 << VIRTIO_GPU_FLAG_DRM_ENABLED)) =20 struct virtio_gpu_base_conf { uint32_t max_outputs; diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c index 3e0680880e1..b941e9a4b78 100644 --- a/hw/display/virtio-gpu-gl.c +++ b/hw/display/virtio-gpu-gl.c @@ -159,6 +159,8 @@ static const Property virtio_gpu_gl_properties[] =3D { VIRTIO_GPU_FLAG_STATS_ENABLED, false), DEFINE_PROP_BIT("venus", VirtIOGPU, parent_obj.conf.flags, VIRTIO_GPU_FLAG_VENUS_ENABLED, false), + DEFINE_PROP_BIT("drm_native_context", VirtIOGPU, parent_obj.conf.flags, + VIRTIO_GPU_FLAG_DRM_ENABLED, false), }; =20 static void virtio_gpu_gl_device_unrealize(DeviceState *qdev) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index ae1880c358b..f5fe1bf4e73 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -1323,6 +1323,25 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) if (virtio_gpu_venus_enabled(g->parent_obj.conf)) { flags |=3D VIRGL_RENDERER_VENUS | VIRGL_RENDERER_RENDER_SERVER; } + if (virtio_gpu_drm_enabled(g->parent_obj.conf)) { + flags |=3D VIRGL_RENDERER_DRM; + + if (!(flags & VIRGL_RENDERER_ASYNC_FENCE_CB)) { + /* + * Virglrenderer skips enabling DRM context support without + * enabled async-fence feature. VirtIO-GPU will initialize + * successfully, but DRM context won't be available in guest. + * + * For vrend async-fencing can be enabled only if EGL display + * is used. Vrend can't be disabled in QEMU, hence DRM implici= tly + * requires EGL too. + * + * Async-fence was bugged in virglrenderer versions <=3D 1.1.1. + */ + error_report("drm requires egl display and virglrenderer >=3D = 1.2.0"); + return -EINVAL; + } + } #endif =20 ret =3D virgl_renderer_init(g, flags, &virtio_gpu_3d_cbs); @@ -1386,5 +1405,14 @@ GArray *virtio_gpu_virgl_get_capsets(VirtIOGPU *g) } } =20 + if (virtio_gpu_drm_enabled(g->parent_obj.conf)) { + virgl_renderer_get_cap_set(VIRTIO_GPU_CAPSET_DRM, + &capset_max_ver, + &capset_max_size); + if (capset_max_size) { + virtio_gpu_virgl_add_capset(capset_ids, VIRTIO_GPU_CAPSET_DRM); + } + } + return capset_ids; } diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index a89d49aa8cc..de7a86a73d2 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1517,6 +1517,21 @@ void virtio_gpu_device_realize(DeviceState *qdev, Er= ror **errp) #endif } =20 + if (virtio_gpu_drm_enabled(g->parent_obj.conf)) { +#ifdef VIRGL_VERSION_MAJOR + #if VIRGL_VERSION_MAJOR >=3D 1 + if (!virtio_gpu_blob_enabled(g->parent_obj.conf) || + !virtio_gpu_hostmem_enabled(g->parent_obj.conf)) { + error_setg(errp, "drm requires enabled blob and hostmem option= s"); + return; + } + #else + error_setg(errp, "old virglrenderer, drm unsupported"); + return; + #endif +#endif + } + if (!virtio_gpu_base_device_realize(qdev, virtio_gpu_handle_ctrl_cb, virtio_gpu_handle_cursor_cb, --=20 2.47.3 From nobody Mon Apr 13 11:14:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772826742; cv=none; d=zohomail.com; s=zohoarc; b=aSnc0GSxwUktfYDx43kQz3s/NUis/JdL4aLEYWX+bJlKqVm1HxwZ8KCxNinFdh6XtfrDCYL5tzUpdTn00XSPgjwGy6TF7KDAcimUUkOOy301Xo2/GnedXnazMfl5r5cbqxZjeD0IrPVf2veX2nKs0RNXHoR/XP/20k8vEUM0fp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772826742; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QaOr02l+PpVLKCER1liS5P0axb5tYfgZOqqZ3SJhCzo=; b=T22HJ4KB16gHthl9RRjivVUe4+/u4xpi8Mf4QSKR603kupdML5pDderIkV15utrtEQdveA+igTspsa9tNsaXwQ+fHkDOOBPIHe0iuIoj/PkvfJd0j6kPTGfzgAZ0GfHWhSHoLF2tU5sD6pMCoL0hlw10Jw6NVOSwDp4045lYBRE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772826742065799.19187822075; Fri, 6 Mar 2026 11:52:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vybDJ-0005Xe-ED; Fri, 06 Mar 2026 14:51:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vybCV-0004E5-Bz for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:09 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vybCQ-0000SL-5l for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:03 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-48374014a77so115644695e9.3 for ; Fri, 06 Mar 2026 11:51:01 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4852aac79b3sm12200045e9.19.2026.03.06.11.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:50:58 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 3289F689DC; Fri, 06 Mar 2026 19:50:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772826661; x=1773431461; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QaOr02l+PpVLKCER1liS5P0axb5tYfgZOqqZ3SJhCzo=; b=bseMgFIp0tEYFUHU8xYJ1gr+JgcKPMmWQs29Kn6m+0OEliGbSQOrxbEKKMyID07JDr caNu+MfXg0tOQmd9CMMRYsXBdvvR6H2D1p2SbjViYWA3BZm//RmKGmX2r8NYExLijf/+ /7K9525TycLZXDRll1uHZ+NiWGdQPtnua4UuCMwcuSHscLj44E00IkNTZmF33RpuxE/e 70h33kbtVjCBLoVJgP5DMhAPjZl2Kul3W3zHEN/se7o08QRuxJPXuyDYQEzhkyNRUXVe ZLTo2P4TF0Nbf2TIffAj0cx19q8FQDQVZTqkvJsTx6c9TYGzrEiLwgMEzsOi6LcPaqAH Rn8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772826661; x=1773431461; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=QaOr02l+PpVLKCER1liS5P0axb5tYfgZOqqZ3SJhCzo=; b=mJjHju44OJ23vQg3iq1fzT3MwaHAr1ZuMXgSOf3yrWHSFu1Wg7BjLBwv1kpHRj3wa/ HcXbl6H93grwu5CoBuvqvslqhkmHKh8Qe+uKjAWTak0LukEsYWpdxa+97fqMSHFVqOcs uxWmlwH+aetmUp1Jhp+GbjQOEtVSeU1zbpuU8uAn9VJ7/XQ60RqEQ4K+077tg1zZR887 S3rtyk91ABrQxRbSKhWwrKwnrvKK7kdPQpc9+bsNjcOQtboHPh6E5WJXNx90YR2OJD+0 sDCu+FpAhzVHi4vO8Rn9LwGicLengMPqbiVBk3f1zBEVE2/sB+PBV9Ls2H5j/Xf/4oVr 12Ww== X-Gm-Message-State: AOJu0Ywvne7rfCdsedHIroq+VyxV3K7vDL1jMBRHBfRdUXVuAmxLj8iU l8HzWBecORuGEpmV/aon2qkwIKmVcvow0WaUhGKmzz7JORYaOEgDIx8Gkl6rOfpLMv4= X-Gm-Gg: ATEYQzzsIUIrEdg8PCP1YOtkpdBTiPS3vJu4NewvgxkO06h4KVLMbvYqFAM29QJEX9U Ws6dhLbQaHqZV29ZQl27i/U/QckG6xSxqYnSVJ01Z+YWPFEqklAgWg5Pu0us/KdW7yB2siKccys 317Z952jrOO3oMoqA0fsESlBQV6nSxjgQv+k4EPVDts/CqADC565TJVJp82zulz5EjxvGRZileE 3OzMZaaboYkAg2cRuaYeeE4p2O4O/Pgy34XZ5sVIhVmHP6PwqmPB2VRPvE4h+GIwyrqt9wkUkUd JesDcdR5zFjgtxjdi48OplXyHsDKtKy/7mGRbRRADQyPc20OC2bQy53hvWtGiPi4UxmdFtvIXZ+ 4GKWcfPHVq6M1E5s/VVnfiwYYDiBjHn5JlA9mjy/7o8zra2j9nbnjcvvce1IUnlU3j3MQpHTA46 JYLesHTJycMgJPWjdDP23FAtc= X-Received: by 2002:a05:600c:1912:b0:477:b0b9:3129 with SMTP id 5b1f17b1804b1-485269188b8mr58494245e9.3.1772826660565; Fri, 06 Mar 2026 11:51:00 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , Akihiko Odaki , Pierre-Eric Pelloux-Prayer , Yiwei Zhang , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pierrick Bouvier Subject: [PULL 13/20] docs/system: virtio-gpu: Add link to Mesa VirGL doc Date: Fri, 6 Mar 2026 19:50:40 +0000 Message-ID: <20260306195048.2869788-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306195048.2869788-1-alex.bennee@linaro.org> References: <20260306195048.2869788-1-alex.bennee@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772826744463154100 From: Dmitry Osipenko Extend virtio-gpu documentation with a link to the Mesa VirGL documentation. Suggested-by: Akihiko Odaki Reviewed-by: Akihiko Odaki Acked-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Yiwei Zhang Signed-off-by: Dmitry Osipenko Message-ID: <20260303151422.977399-12-dmitry.osipenko@collabora.com> Message-ID: <20260304165043.1437519-14-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e diff --git a/docs/system/devices/virtio/virtio-gpu.rst b/docs/system/device= s/virtio/virtio-gpu.rst index 086e2fcf27b..89153103b9f 100644 --- a/docs/system/devices/virtio/virtio-gpu.rst +++ b/docs/system/devices/virtio/virtio-gpu.rst @@ -61,7 +61,7 @@ on typical modern Linux distributions. virtio-gpu virglrenderer ------------------------ =20 -When using virgl accelerated graphics mode in the guest, OpenGL API calls +When using `virgl`_ accelerated graphics mode in the guest, OpenGL API cal= ls are translated into an intermediate representation (see `Gallium3D`_). The intermediate representation is communicated to the host and the `virglrenderer`_ library on the host translates the intermediate @@ -70,6 +70,7 @@ representation back to OpenGL API calls. .. parsed-literal:: -device virtio-gpu-gl =20 +.. _virgl: https://docs.mesa3d.org/drivers/virgl.html .. _Gallium3D: https://www.freedesktop.org/wiki/Software/gallium/ .. _virglrenderer: https://gitlab.freedesktop.org/virgl/virglrenderer/ =20 --=20 2.47.3 From nobody Mon Apr 13 11:14:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772826759; cv=none; d=zohomail.com; s=zohoarc; b=bXRex/aWocw8EvTuN82KixLUeuK4A4/rgFJ8+/59kAcAoucBtVeR5gWwSjkC6abt2nbE0KJIehv0TFSg4DgJP25iXJsavrN+17GPyguMTx7sOzTrtTp980LY12yM4Fu6tg3gHOEvIhVpTfO4gRPDsbxZaXOegJVcYPxOkS5s6s0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772826759; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1Msw/rTa8Xu2Of6o1/fUJKClgRIjYd2FntFGU5RPSt8=; b=arGfh5LhwROfUQloYsBMv6Bh0MRo9fOPxM23ZQUHjOEFtg04eds67bkxfOZf/7dRoIaoFwqBH3ZypxaQqQyc975YvjmvEMHO/lpEYIhSzu57hRlC4AV1fJLTy4y3XeOE9xmbzSFlCgrIBe7WjAlhYZPp7HVoSxcEqjj99UU5y+Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772826759739509.22589697921524; Fri, 6 Mar 2026 11:52:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vybDY-0006T0-S1; Fri, 06 Mar 2026 14:52:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vybCO-0004Cc-QJ for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:02 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vybCM-0000Qf-2h for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:00 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-48375f1defeso72344085e9.0 for ; Fri, 06 Mar 2026 11:50:57 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4851fad2812sm227680615e9.1.2026.03.06.11.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:50:56 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 49E4B689DD; Fri, 06 Mar 2026 19:50:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772826656; x=1773431456; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1Msw/rTa8Xu2Of6o1/fUJKClgRIjYd2FntFGU5RPSt8=; b=RdqUKpk41Pi0wNveg95z2Rlm5vvmCb109tgotCdupyPgCwVC/bxQYxrZ3+aYy1L8MD h4CIvE3UeSv6Jhs9vyEyXi0w5h8c/NdfrlMChD0dRCGE8SRX9YZ5QGK6szfKHLgPMv2N 92r8FmHJzkno4pBMCJhMyOBACawgTOs+b/jmayBk6bk0qmpeHGn1EVoP4U5Ql8w1QVRr F7iRE432dmQK6BmJILqxIi2Dp1gWwLgjh72pluEdN86Uz4oGqS9P3sqhmDz+LeglfMZd NW8+82Yp773/Dkwvqw9z8ZXNxuGfGvp1h0xh+q76ZM/+s4oz49ldRDIxUIF1dyNWXAat AQfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772826656; x=1773431456; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=1Msw/rTa8Xu2Of6o1/fUJKClgRIjYd2FntFGU5RPSt8=; b=KK0cMdCM9lmlgXiNIA659dqpst6e2utaGvIVu7K9loLfcezUTB7B66nu6W8Lg9mCqZ E7KewPnrbgRU2Z8aO9HXPsob2dvZ0GrmN/JoVCpeqqnhqqu/qnafoFN5WoFo2yP29/YP A+5qAXyIPHUkU0OXnWDhueDIMrwAkjgADVz9ed9Q9GdDUF9TeU7xu4i3SWnG0a3WJVwI RsT+Gg2qHYKTkMzvO0ybDuAw5vAXNEToRPqvMRslw8HvZq8+OrocGEm9MP9cIgtsXMXM 0ncGACYygPzHMn1jYf8glyGdHaovwo6Gw6aiSpMOzjCsl9Oc6m0150auHMNWti+2nm+I kbOQ== X-Gm-Message-State: AOJu0YzecvM/2xYtpxEh5edkPwDPCjBoSMk5BF7aXSMsnoE3mAPODa5I K7jcfoEIjxMyNX9nxpt1QpamV6nSZjFQAxEQazGHeyVZHs7DFVD7utw8H4r9MGovuY4= X-Gm-Gg: ATEYQzw96cEoPiB25mXUxNadCeZ5w2f6L2D/rCiEFDotj7rt+GsZZUPiSFYrJ+3Q7YX tgFUMHsW8/JweYPBpcVFcs8M+hUm0eWQGYdGxQ7iOQBJtsjzZz/IZCLuKLdspXFgpBOhaZsdLuD /+F7BMnWxAGwfhxb0bpmtFImFPzvtlSqyH3iMfPSHx/s41fnmvdeokQyaHAY2jf3eSoMFPSX0UT fB+Gd+8oa3DyBx6vf295sGGT8PbEQKysiy56sd173sksbluosfPlv81sYmwa5+z0zvhSuRQmytk Bdi/taPwXODz8p5Yccxqc4Esl5ZuRyDluhoBacw7+cgburUsiKUuW8nStGRv53+i0A5W20e6Cp/ ttRL5zUNzXc/ke39yXwVriVBVWZq0QzyBb1G+FOzMfQtTQ8JYWTnyFh76utAjgvCJKemFLNDr0H lU/Zq6+xAOQbBbWfpSjE0Y8nE= X-Received: by 2002:a05:600c:8714:b0:477:6374:6347 with SMTP id 5b1f17b1804b1-48526957d50mr50071825e9.22.1772826656552; Fri, 06 Mar 2026 11:50:56 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , Akihiko Odaki , Pierre-Eric Pelloux-Prayer , Yiwei Zhang , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Pierrick Bouvier Subject: [PULL 14/20] docs/system: virtio-gpu: Update Venus link Date: Fri, 6 Mar 2026 19:50:41 +0000 Message-ID: <20260306195048.2869788-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306195048.2869788-1-alex.bennee@linaro.org> References: <20260306195048.2869788-1-alex.bennee@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::32f; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772826760793158500 From: Dmitry Osipenko Change virtio-gpu Venus link, pointing it at the Mesa Venus documentation instead of the protocol. The Mesa doc provides more information and also has a link to the protocol. Suggested-by: Akihiko Odaki Reviewed-by: Akihiko Odaki Acked-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Yiwei Zhang Signed-off-by: Dmitry Osipenko Message-ID: <20260303151422.977399-13-dmitry.osipenko@collabora.com> Message-ID: <20260304165043.1437519-15-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e diff --git a/docs/system/devices/virtio/virtio-gpu.rst b/docs/system/device= s/virtio/virtio-gpu.rst index 89153103b9f..ef5fb0401d5 100644 --- a/docs/system/devices/virtio/virtio-gpu.rst +++ b/docs/system/devices/virtio/virtio-gpu.rst @@ -83,7 +83,7 @@ of virtio-gpu host memory window. This is typically betwe= en 256M and 8G. .. parsed-literal:: -device virtio-gpu-gl,hostmem=3D8G,blob=3Dtrue,venus=3Dtrue =20 -.. _venus: https://gitlab.freedesktop.org/virgl/venus-protocol/ +.. _venus: https://docs.mesa3d.org/drivers/venus.html =20 DRM native context is supported since release of `virglrenderer`_ v1.0.0 using `drm`_ protocol. ``DRM`` virtio-gpu capability set ("capset") requi= res --=20 2.47.3 From nobody Mon Apr 13 11:14:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772826744; cv=none; d=zohomail.com; s=zohoarc; b=iDtyHbgO5mhkT46MYnSeE5rDNA/r57CD3wxX9jYFm6fLrz7v6vzAvwIep3fYVaKgFNcRzjno0rWXOpRxU5vfoeWHi5rmefwUzkG3lPw8jZB4mEN2JeQW+L2OXWgn15mKz+kFNtUZmhVWPOBvKLu9rYlN/Z9xkOYVP2u8z26utrY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772826744; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pS5AFqvs7neblJVLo/6AkMOZ1wbglI8t3qNCBUD2rL0=; b=IGTVhCDOfcvIAkDIr5Y9D1KtvlevftULw4mCfY+7XXyI2X7spAEg30DyXHdvlnrGiccFszn71tZNoCTTZzez4lHajL3PMfzx1JvBkXx8MwcqvfC5jdeQrrOKUM7ATQqSFLxBt2dW87UqezDXHGKz1ZcgAIoUJEqSuwyAL8xYVqc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772826744397255.48034587269342; Fri, 6 Mar 2026 11:52:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vybDY-0006Ty-Rn; Fri, 06 Mar 2026 14:52:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vybCV-0004EC-Cw for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:09 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vybCP-0000Rs-2B for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:03 -0500 Received: by mail-wm1-x344.google.com with SMTP id 5b1f17b1804b1-48529c325f0so4850215e9.0 for ; Fri, 06 Mar 2026 11:51:00 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48527648a19sm55127515e9.0.2026.03.06.11.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:50:57 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 63797689DE; Fri, 06 Mar 2026 19:50:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772826659; x=1773431459; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pS5AFqvs7neblJVLo/6AkMOZ1wbglI8t3qNCBUD2rL0=; b=E9H9+8mB3/wFowTcHWlh/1Rya21jGYD5XdOG0ngJAYT8YDBouyBmgSf9d8UzqtYsaV L0/r1+fmAbSCBBT0NrwmLdm1U+9yshXnERWTMiM288GBx1nYGOV1M9a9L8JpQe/z1AZ3 rzVvvISQxQBlk3zfNp4NuLx+KVvzWl6pHbIHsMzbBTYy0COXWqnf32dgFBBiGErlWSyU /xjXNzLPY8z127Cv55Obb1lSOQhS3MqmNzBrAa8i6ockJsxzUIwIUPP2g/T5m+/IsGDc jr6TWaNkEnC2v6SiQadDVrCToaQKN+/Qj+jpiIbF2IvRoKhQFDLe23hfqdMmNVWN1wIA nlog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772826659; x=1773431459; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=pS5AFqvs7neblJVLo/6AkMOZ1wbglI8t3qNCBUD2rL0=; b=wDv+J9Brd5oFw7qJytrqmid+naBQLpFT43jlH9sY2R+S/FCeYz+/8eooMOQhkcNXaO HQ0S3/igfBYFdstZMKlmxlMKDDRfij4WS5f/uOwOGTGGgTK1CNh+npzCyRDwq76JSolz +quSamm78eudgdUoXjjhBK2WY6C4ZvwTDAJGzyY1VrKcPauWoblmGjDTL/U3d7vmhLEg va4F+ca3cu8690MFwA0Qh/93+zpAF05sjoxcgTpVjHi98OcgbMJPXD/d8vZlkoqHbGmL VrKX7rvlBSqTGmtZG2F/lqNuh5ZtYVgYmwZfB6fPn/Ck2cEZxJvzHgXZknzdCMeO7LSH gtrQ== X-Gm-Message-State: AOJu0YyXNIw3PnahgtET5Fx2jXiFihO59K8/oFPJ42tUs+LayN085qg/ 8UbmBPakjx7eDHHDh1f1x+v9/RyI4Tsnd52ql9Vz89XhA2rIZeluiqYZSKSYuYB1cqA= X-Gm-Gg: ATEYQzyt4mkYOYS0TaD1zMLmZnoEbGSdLmptUrkX6ZuMTrttQvAWivkg0FOSa4wzKDA MqLZwrlx0syc61SvFc7eiLilW9StZqg47PZXUOxz5m9khRO1yRE/oq2fAVyO9xZ5dJ7TsBCnSEL spfhlPoe1KwzZUN17A+8U69UIHwzfWTqjLVjdgwJHif9E3Sr2lPkhiwM8NbGzcD30TiZJAcebxV iM3CxB8wg3SP6YYRj1ZGGSPFKWlUVlTEArYATXKahcGyvcS61fcZ8UkPbFxqZcrX6SJ4TbMSlpv zjabS5yNY0UJ1mVOZ0gyFgbKDOwzHQkw59Zz1o3LW6IfIYVKaD479pC28A3+0ZTZ9zdqWRpZN8c 0UpJwZ/CLYvsoaEQFd+ENHAfJr+I8Hx0MAeAXy1FuRK7yO8XmZLUwNYZK2EBnh4UIxqtDFox3qb GCBXK5BGgfZTonZcH1lM37uVrHgUFPg2pwkg== X-Received: by 2002:a05:600c:1908:b0:480:3a72:524a with SMTP id 5b1f17b1804b1-4852695943emr59983305e9.19.1772826659376; Fri, 06 Mar 2026 11:50:59 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Sergio Lopez Pascual , Akihiko Odaki , Pierre-Eric Pelloux-Prayer , Yiwei Zhang , Dmitry Osipenko , Pierrick Bouvier Subject: [PULL 15/20] docs/system: virtio-gpu: Document host/guest requirements Date: Fri, 6 Mar 2026 19:50:42 +0000 Message-ID: <20260306195048.2869788-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306195048.2869788-1-alex.bennee@linaro.org> References: <20260306195048.2869788-1-alex.bennee@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::344; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x344.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772826744814158500 This attempts to tidy up the VirtIO GPU documentation to make the list of requirements clearer. There are still a lot of moving parts and the distros have some catching up to do before this is all handled automatically. Cc: Sergio Lopez Pascual Reviewed-by: Akihiko Odaki Acked-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Yiwei Zhang Signed-off-by: Dmitry Osipenko [dmitry.osipenko@collabora.com: Extended and corrected doc] Message-ID: <20260303151422.977399-14-dmitry.osipenko@collabora.com> Message-ID: <20260304165043.1437519-16-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e diff --git a/docs/system/devices/virtio/virtio-gpu.rst b/docs/system/device= s/virtio/virtio-gpu.rst index ef5fb0401d5..d05f8cb8e3f 100644 --- a/docs/system/devices/virtio/virtio-gpu.rst +++ b/docs/system/devices/virtio/virtio-gpu.rst @@ -7,14 +7,28 @@ VirtIO GPU =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 This document explains the setup and usage of the virtio-gpu device. -The virtio-gpu device paravirtualizes the GPU and display controller. +The virtio-gpu device provides a GPU and display controller +paravirtualized using VirtIO. It supports a number of different modes +from simple 2D displays to fully accelerated 3D graphics. =20 -Linux kernel support --------------------- +Linux guest kernel support +-------------------------- =20 virtio-gpu requires a guest Linux kernel built with the ``CONFIG_DRM_VIRTIO_GPU`` option. =20 +3D acceleration +--------------- + +3D acceleration of a virtualized GPU is still an evolving field. +Depending on the 3D mode you are running you may need to override +distribution supplied libraries with more recent versions or enable +build options. There are a number of requirements the host must meet +to be able to be able to support guests. QEMU must be able to access the +host's GPU and for the best performance be able to reliably share GPU +memory with the guest. Details of 3D acceleration requirements are +described in a further sections. + QEMU virtio-gpu variants ------------------------ =20 @@ -67,8 +81,14 @@ intermediate representation is communicated to the host = and the `virglrenderer`_ library on the host translates the intermediate representation back to OpenGL API calls. =20 +By default OpenGL version on guest is limited to 4.3. In order to enable +OpenGL 4.6 support, virtio-gpu host blobs feature (``hostmem`` and ``blob= `` +fields) should be enabled. The ``hostmem`` field specifies the size of +virtio-gpu host memory window. This is typically between 256M and 8G. + .. parsed-literal:: -device virtio-gpu-gl + -device virtio-gpu-gl,hostmem=3D8G,blob=3Dtrue =20 .. _virgl: https://docs.mesa3d.org/drivers/virgl.html .. _Gallium3D: https://www.freedesktop.org/wiki/Software/gallium/ @@ -96,6 +116,67 @@ of virtio-gpu host memory window. This is typically bet= ween 256M and 8G. =20 .. _drm: https://gitlab.freedesktop.org/virgl/virglrenderer/-/tree/main/sr= c/drm =20 +.. list-table:: Linux Host Requirements + :header-rows: 1 + + * - Capability + - Kernel Version + - Libvirglrenderer Version + * - OpenGL pass-through + - Any Linux version compatible with QEMU if not using host blobs featu= re, + Linux 6.13+ otherwise + - 0.8.2+ + * - Vulkan pass-through + - Linux 6.13+ + - 1.0.0+ + * - AMDGPU DRM native context + - Linux 6.13+ + - 1.1.0+ + * - Freedreno DRM native context + - Linux 6.4+ + - 1.0.0+ + * - Intel i915 DRM native context + - Linux 6.13+ + - 1.3.0+ + * - Asahi DRM native context + - `Downstream version`_ of Asahi Linux kernel + - 1.2.0+ + * - Panfrost native context + - Linux 6.13+ + - 1.3.0+ + +.. _Downstream version: https://github.com/AsahiLinux/linux + +.. list-table:: Linux Guest Requirements + :header-rows: 1 + + * - Capability + - Kernel Version + - Mesa Version + * - OpenGL pass-through + - Any Linux version supporting virtio-gpu + - 16.0.0+ + * - Vulkan pass-through + - Linux 5.16+ + - 24.2.0+ + * - AMDGPU DRM native context + - Linux 6.14+ + - 25.0.0+ + * - Freedreno DRM native context + - Linux 6.14+ + - 23.1.0+ + * - Intel i915 DRM native context + - Linux 6.14+ + - 26.1.0+ + * - Asahi DRM native context + - Linux 6.14+ + - 24.2.0+ + * - Panfrost native context + - Linux 6.14+ + - `mr36814`_ + +.. _mr36814: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/368= 14 + virtio-gpu rutabaga ------------------- =20 @@ -135,3 +216,21 @@ Surfaceless is the default if ``wsi`` is not specified. .. _Wayland display passthrough: https://www.youtube.com/watch?v=3DOZJiHMt= IQ2M .. _gfxstream-enabled rutabaga: https://crosvm.dev/book/appendix/rutabaga_= gfx.html .. _guest Wayland proxy: https://crosvm.dev/book/devices/wayland.html + +.. list-table:: Linux Host Requirements + :header-rows: 1 + + * - Capability + - Kernel Version + * - Vulkan+Wayland pass-through + - Linux 6.13+ + +.. list-table:: Linux Guest Requirements + :header-rows: 1 + + * - Capability + - Kernel Version + - Mesa Version + * - Vulkan+Wayland pass-through + - Linux 5.16+ + - 24.3.0+ --=20 2.47.3 From nobody Mon Apr 13 11:14:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772826739; cv=none; d=zohomail.com; s=zohoarc; b=kbkelDqTsiFbaDvoLt7hVEId6MFeVK3F8OwxQwPtHwI/diUeszYYkr1dKM8FTai8/hYSQJ5b1l1ACYVJ3We6TyMe9gpLjPa2s+OauFGVWAWpVKyFtBRmHqEsiNchv63QpQcjEzDDonLhq3OeY1FUJ6fWSn/OG+cNRa9XKoUQL8c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772826739; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lqfMeh7SO7T4uFotbbczP7UgIC82Ne3itRNZDNM569A=; b=GOm9hD0yQ+VrfHeVwOVQS8BdMbtx+RLL4nPvxh7MzWPp/Rx/NpQ7ICy8BKxn+zUun9rra261suin49R4HQxnN/Xo3LVQQST41W8xCFNN9SLtirMcmCyX80+m3MD200Au07Ys5ni1XHjGoT1DC+19YZmKFiIMQskswn1UKCSpkf8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772826739978636.652816382263; Fri, 6 Mar 2026 11:52:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vybDc-0006rJ-HU; Fri, 06 Mar 2026 14:52:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vybCV-0004ED-Cn for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:09 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vybCQ-0000SQ-NJ for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:04 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-482f454be5bso98452965e9.0 for ; Fri, 06 Mar 2026 11:51:02 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-485244b6e9esm43632815e9.5.2026.03.06.11.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:50:57 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 7B23C689DF; Fri, 06 Mar 2026 19:50:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772826661; x=1773431461; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lqfMeh7SO7T4uFotbbczP7UgIC82Ne3itRNZDNM569A=; b=oxd9ciXL24i3vwDP2H8YivJ+19ZPFEaN12pVLzyOOwMcCtfKuDOrnMFmCUUOkUZDw3 9Qe1DofnLBNsQBk/jw6kaVl5e14rOvN8XjT81C+35eV8EVEIOfmJ1CeNyBfELH9nzA5j P9eNdLbwlmSZddjQ4XisS7De9aAyfb21Vsz5NMW5ZPEWQWPuhqWl/0Z2Wu59alc+03y4 2W8HnzQF0KT7syoNeFwVKFi+94ki6sLNkqjDvXnQjIoDiuc760MxkTjrdMFjI/1xYGS9 V1uGy9Zl6vYQ2EncyKwuaWxAt3hMSbR1eCefwOm41HiMuuewC107fVQbAUxoCic1i4UD uyWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772826661; x=1773431461; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=lqfMeh7SO7T4uFotbbczP7UgIC82Ne3itRNZDNM569A=; b=EtWBstuBgOWrNa48egJwlc97TJaWRQ7+zROk2ZwbeIycdl29mAsO234SrVebrxsuND XJ5slOS0s6CwHYJ2CYg9VSyDAlg8ItaNKzdCgKTs0Qz39/5+7BhlOIQuRhYr2RyjO1xm 8ICzJYp8nQV59QHjI2YwGlB6vvbaG59U+Fs+bc9UQgU5ZfXEMzIHCb+hOvv2pjcz/RKN sgOms11yo5giu5xr4Blz8OeNWJlAgvhnm879gUf8srfdEvMcMeXEduE8F/bqJx9LrfPw MLKMOrHpWjMmuLGQvGxPhbTaYChB/QsCr4sAygYygBJnLKn3uu0Kr+jNo7cCR7spoLeG 2Xag== X-Gm-Message-State: AOJu0YwEAMQV96zExB6Dh/kA0S0eZFm442IFwjMzE1R5ysLvJRt8urKn kTljZFdGJz1FI9fru++kSrXL3P/krJL7ANsRkuJb1nJZfQ9wMKZbwKaqB9Kg2ILG758= X-Gm-Gg: ATEYQzwPamPHEx+mSq9oSb+h6S861rIIrc4Z4xiv4jMpRNN4s5bKhC7munZmEP6mkhu j2FG7Z96vmY4i8lLtfhrUV5ZybxuBcNdmn5j0K//a6OMtdcfZvE2SCEwbCfbfAvZ0SlSLw08ruY 7AIomHV7VEQdqefVi2xucluSStG+ZUtO4LMjnRJkiAAdUjJPsarTcZYuW+B7BIeu//zTDwa3KiU N4TW5aT7SSnqxz5bVUsZeuvirhoMs7j208/JKsXF066mVb7M59ik4Kt1F/yKFxzgqHpIuZdB0aW g1LAs8AebX3AsyNY7U7DmOhWG13PtQHMZSpwAxC6Ci0E8ZT0BcqYHaDVPZ2Z8YqyvRn264i2pW5 aE685ygGa/ZcgfUYkM4Snp5bHxhrJU10KvcAoUXKAxPrNVH0dDgBbv2JIIcllpO35shMd4nNkNp iFdSFZj/ehmelSzhXpI7kcSbw= X-Received: by 2002:a05:600c:64c7:b0:47e:e59c:67c5 with SMTP id 5b1f17b1804b1-4852671d9c3mr52513325e9.8.1772826661215; Fri, 06 Mar 2026 11:51:01 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , Akihiko Odaki , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Michael S. Tsirkin" Subject: [PULL 16/20] virtio-gpu: Remove superfluous memory_region_set_enabled() Date: Fri, 6 Mar 2026 19:50:43 +0000 Message-ID: <20260306195048.2869788-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306195048.2869788-1-alex.bennee@linaro.org> References: <20260306195048.2869788-1-alex.bennee@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::331; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772826742510154100 From: Dmitry Osipenko There is no need to explicitly enable/disable memory region when it's added or deleted respectively. Remove superfluous set_enabled() calls for consistency. Suggested-by: Akihiko Odaki Reviewed-by: Akihiko Odaki Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Dmitry Osipenko Message-ID: <20260303151422.977399-15-dmitry.osipenko@collabora.com> Message-ID: <20260304165043.1437519-17-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index f5fe1bf4e73..abf7c176a65 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -171,7 +171,6 @@ virtio_gpu_virgl_map_resource_blob(VirtIOGPU *g, mr =3D &vmr->mr; memory_region_init_ram_ptr(mr, OBJECT(vmr), "mr", size, data); memory_region_add_subregion(&b->hostmem, offset, mr); - memory_region_set_enabled(mr, true); =20 res->mr =3D mr; =20 @@ -225,7 +224,6 @@ virtio_gpu_virgl_unmap_resource_blob(VirtIOGPU *g, b->renderer_blocked++; =20 /* memory region owns self res->mr object and frees it by itself */ - memory_region_set_enabled(mr, false); memory_region_del_subregion(&b->hostmem, mr); object_unparent(OBJECT(vmr)); } --=20 2.47.3 From nobody Mon Apr 13 11:14:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772826744; cv=none; d=zohomail.com; s=zohoarc; b=bs0eCIhLAAG79gZAgh7JF1RTytvAY44G8QSKpxPKVCh2tFADn48hDcxWK9U1jdLx/kSJwfoVcSFKAxstB3PRWoqXrwjzE3/9rP0s3YVVtsvS/Bani8NMu0vmJZfkqOTwndFPBgD6aNbkbSvha151rdKUnb7wnFHHZCMKehsJKHA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772826744; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=A8nF3OjA0ZKOuKtYP366/rOO+hCQVT28eX6+4MbMNiM=; b=LazLDgcozcxIc1tZRDmY5tz69f7dBNs6GfRUXK8IqoeZSDLtKdmkBiIJwk7rxsg9qxrHCeSSI++a64ZqWaF42SZq399o5rNN9IVGmbOW9aJSAsGl2cyUjjhnzoRv5l4IuR4bdsdGVb9eYWBoRnpcBUr1wfhrVuRjfV7+SFvWdWE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177282674405475.35302778180267; Fri, 6 Mar 2026 11:52:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vybDS-0006J1-PC; Fri, 06 Mar 2026 14:52:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vybCW-0004Ep-HK for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:09 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vybCT-0000Sl-Nb for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:08 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4852a9c6309so4263645e9.0 for ; Fri, 06 Mar 2026 11:51:03 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4852ad0ce60sm46296695e9.12.2026.03.06.11.50.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:50:59 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 95737689E0; Fri, 06 Mar 2026 19:50:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772826662; x=1773431462; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=A8nF3OjA0ZKOuKtYP366/rOO+hCQVT28eX6+4MbMNiM=; b=iaNlHfdUHsAPnzMe8/Jrf25Qfye9EvYBVKz+WjuD6lsLqrTq9SMtjqrVJ9MC8meTwY 7iauw0l4dTLxTJlSh54iklFcs2WsmGPevDwoV9U6aX4VFeI4hfJWu8p8N9d8Xk7Miuxd IongzbFjgzm2A5YhY+23Rd43JT/aLgKARXyr8J4uBM3OsnPTHB9JjoKWgYqHEC42AdTR zPhKprKOR2lKFuO+MHWX2afzIYaVeuPctzQSgaKDaXeyfvI0nDIA37Q3Ia/d7qwvUPcy DlGQ1AI5N7myLKI+14nOjL5QgKOGuP6JZItCJd3MGCaG6SpxwR+7zxpPFJWRevt0wkG9 q3Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772826662; x=1773431462; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=A8nF3OjA0ZKOuKtYP366/rOO+hCQVT28eX6+4MbMNiM=; b=EWSFp+O4nKylHEzY4F5Xdk6YHfTKwWFcxUCCIizcr4+IBzmGVKPP+GxHOcvL7TJRos izHy/d3Jt7yiagZ7KqyT7QDqcs1NEfreZPlTsT2agPf06fjXBQyg85k8/KiCai6GFmES 9MySUcVPXUKiOutxDJNvrwi6pGiuf8LTr5mAexnqHORCoi5xuH+lWZy/YV5rBv9BeG1C wIxgDs/HGYIVru7kcxlkjFxQjwSBZlyBrfBN9KKOp1hTHQ077cr2a8Dq36soMKMEEODu TXvUxe92kOwCRHGTIt0j8UaxMfPIjgem0fw7KDLeh582xW+2/gVYtQeohmvh4mNt2yCZ smyA== X-Gm-Message-State: AOJu0YyLU0bWpFEpUQQtrUFhRl6oZHKrxHdp5OOW5IoAoVpdQQFCRair lD1uzWPPoH5kWxNaZz6FNtrOoF0Lj0kqhJb+HAhQORfRyazZOaxqDdNZAmOVBXOK6IM= X-Gm-Gg: ATEYQzwznhuDoB3BH7rdodJWlPYzYzWaQpr6stirzx2aXZrmHBlH3yeYxm4nxv78aDP FQYh9Y62oFSUhptTVH/mAxdK0OtnAyzGhW0LvpoVFMvXcvSO5xhc/m/sPEEggbfM4hAwGEhJ2E0 QUA/k5DQsaf5y+uFMgJgxsjvleaHhRIUkkaBTFgohFRXjGXswcbiq17IU8vlItR2u+Wu7ER25sr TTa860yxtvikfUXwMfLDskYtDpDbdKSUP/h1T7AL5GiUtJWWaBG2jL9ws4rw5lSf3sqoUv5g9ta +9DbIKcHpYYzWwF+TP56+O4MoSn05SKNcCnh5la7MxX+4heYVAnbSza2866cI86xE3QfKTTly+/ aemn/VjNYfn8aw924aYHpMj0X/F4MXFVYimDRCPwCLbsZZgBd4qm0NOW35ew5zs0WYMsfcRZTFa ZsZNyheBJ5cO8ObaH7nYZEmWc= X-Received: by 2002:a05:600c:548b:b0:477:2f7c:314f with SMTP id 5b1f17b1804b1-485269306b5mr59099725e9.10.1772826662140; Fri, 06 Mar 2026 11:51:02 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , Akihiko Odaki , Akihiko Odaki , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Michael S. Tsirkin" Subject: [PULL 17/20] virtio-gpu: Validate hostmem mapping offset Date: Fri, 6 Mar 2026 19:50:44 +0000 Message-ID: <20260306195048.2869788-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306195048.2869788-1-alex.bennee@linaro.org> References: <20260306195048.2869788-1-alex.bennee@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::332; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772826746593154100 From: Dmitry Osipenko Check hostmem mapping boundaries originated from guest. Suggested-by: Akihiko Odaki Reviewed-by: Akihiko Odaki Signed-off-by: Dmitry Osipenko Message-ID: <20260303151422.977399-16-dmitry.osipenko@collabora.com> Message-ID: <20260304165043.1437519-18-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index abf7c176a65..f4d1113827e 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -791,6 +791,7 @@ static void virgl_cmd_resource_map_blob(VirtIOGPU *g, struct virtio_gpu_resource_map_blob mblob; struct virtio_gpu_virgl_resource *res; struct virtio_gpu_resp_map_info resp; + VirtIOGPUBase *b =3D VIRTIO_GPU_BASE(g); int ret; =20 VIRTIO_GPU_FILL_CMD(mblob); @@ -804,6 +805,15 @@ static void virgl_cmd_resource_map_blob(VirtIOGPU *g, return; } =20 + if (mblob.offset + res->base.blob_size > b->conf.hostmem || + mblob.offset + res->base.blob_size < mblob.offset) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: failed to map virgl resource: invalid offset\n", + __func__); + cmd->error =3D VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER; + return; + } + ret =3D virtio_gpu_virgl_map_resource_blob(g, res, mblob.offset); if (ret) { cmd->error =3D VIRTIO_GPU_RESP_ERR_UNSPEC; --=20 2.47.3 From nobody Mon Apr 13 11:14:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772827090; cv=none; d=zohomail.com; s=zohoarc; b=DMRQyVpIL+HN22ISnbJug+bo/EAxjE0TNigQWLoG/hjJMdZk0klOKBfrHq2NTEfvkRbzcMwK+DGEhWz0YXJOXcQGxbHiXwLCTypzx9RGjy/PJ5ZNFJevwOhNvh7QgDcBt95Gh76o9QZKm1Nzz/+nTffE6LcwG1J8yHzXtDkH5AY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772827090; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=G/UXjFf9Bz2RP8j5199U69kamuhlHWXflthUc5X+lt0=; b=EYvAnPoojtmNKK0VUnR5K9ogdMlHsLp5tR0c2LBiXns7xwQqeAiuVHP1h9o6k4kd/JdKO5U+RSZGJVgF5//CMIK8V73X3JW9UAJ+FLQPZ9sWfR6cg3GSV2dPK/lmikMziFuedvNFp3YX/L6AEUSiptOI/vfF0oIgONkLrZkRNik= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772827089957778.4721018661014; Fri, 6 Mar 2026 11:58:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vybIl-0004sZ-JO; Fri, 06 Mar 2026 14:57:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vybId-0004rI-Bm for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:57:28 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vybIa-0001Wr-J6 for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:57:26 -0500 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-439c4a93841so2772002f8f.1 for ; Fri, 06 Mar 2026 11:57:22 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439dae4b860sm6284687f8f.36.2026.03.06.11.57.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:57:20 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B0350689E1; Fri, 06 Mar 2026 19:50:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772827041; x=1773431841; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=G/UXjFf9Bz2RP8j5199U69kamuhlHWXflthUc5X+lt0=; b=OCJnQaJ5ViR3bt7gsbwh+ywJW/KFPdraSrKkYoqlKsY5T1PmZZTidy+pj0vGjK+di+ VM+Gc59BNlm9o47+Ebj8GJwsQjQnVHUOSxXdbR5/M1b3OE9wTn6NKA14JG5H8vI5Uvx9 K/cK2BcW49KbHUkdoV6jO46w9flP8K+H+EbQ8GOknbBOapT0xQV1/g3xfbgQx3eDW/kn M+kbufW5Ddo9gm00AwNSsIZ3BkMd1vylQlPLQIRdO71K3Kv1na8xB5xbs8vDlJiXttGI ReOwO977cxKG7H8s5o5aTtKJuG11C+9nuJMmEVHjvgHPt6UucihYwduPRt/9N7fkxCjM be4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772827041; x=1773431841; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=G/UXjFf9Bz2RP8j5199U69kamuhlHWXflthUc5X+lt0=; b=GyovMym3YhmKdc1X98pMlnzNR+iBb5/y4MWLMTnAOZrqea5lAFCnahZH+Hck/sKSWA UV3UTmEXImhUwqwMiouBcUByEkpmqqfZgTz6ymZkGqjeMX4ckbSn9UljBdpv53buNz8D Q769TeeLyyQ92HtESodYWtRGWR1wlgYtuY2PjHUjq5hZiDR1NwpFFljERppZfuncnQOy s+9xWknvRr4xxk+6K8HeG3fAlpqGWaH4wHGgaZfBKsqRXjluROj6DGy/UJw+3SnJP8AE 9sKCjVqJa/6lWFPMIneYE8wHfxbHoSvpGPAuld4m4EeYCb1SaR65WYH6M0Vb+da167IT 7fmQ== X-Gm-Message-State: AOJu0YzoCWW18o4OeVo+eGPPxGHWSq4/7rnWXQ3U/Am7Vxy5KvJ994u8 0ODr6ZnN4/rUbusHENuiYqBUssvPlNB0simijycwBFAj8r6qEu2/O0lE9yprgsUjpdA= X-Gm-Gg: ATEYQzyajWzi3NgmMZH/caEcPy878BKZet1EM+/3XKBLLquV2p8df2O95+lQaqVDqGV G9css8WMrUycBzOx+jMvHWFm48r0rZejrN/bTqGLNmcft9hMoY4yb7178VX6lcMLJcVm5d7EPbs ZPdmd0HUSKQP/EXGgEzlTd4WPnFcN+8FwgAOf+aHiiTPMs/JLcN0S2NbTHbzOHV9BjJTjmazYhX k+JDY3e9wQtkYVT0O3lCAR4CF+IIeYiPRuU/gT9SiIEhah1hWujqumngF6bLVPqclXa5OSVFnzD 2Lpa9AKl/23FfksS7ALaXdCQtzf4Q954zc5qW4xla3mjqAQ3CXmqXZy3cdutTGYb9uANY0ZQe8F vParfi6Rd1f1GAhCTMh8V2JMrRgoX5H4QSNOyRm3bUisy8LTV0h0BjlHgzN1V2wUf+rq6EG+pOd KuQWEvU8FKc72SU9QvsPWSj0M= X-Received: by 2002:a05:6000:400e:b0:439:b0ed:2afe with SMTP id ffacd0b85a97d-439da348192mr5251923f8f.11.1772827041166; Fri, 06 Mar 2026 11:57:21 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , Akihiko Odaki , Akihiko Odaki , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Michael S. Tsirkin" Subject: [PULL 18/20] virtio-gpu: Replace finish_unmapping with mapping_state Date: Fri, 6 Mar 2026 19:50:45 +0000 Message-ID: <20260306195048.2869788-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306195048.2869788-1-alex.bennee@linaro.org> References: <20260306195048.2869788-1-alex.bennee@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::42d; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772827092247158500 From: Dmitry Osipenko Allow virtio_gpu_virgl_unmap_resource_blob() to be invoked while async unmapping is in progress. Do it in preparation to improvement of virtio-gpu resetting that will require this change. Suggested-by: Akihiko Odaki Reviewed-by: Akihiko Odaki Signed-off-by: Dmitry Osipenko Message-ID: <20260303151422.977399-17-dmitry.osipenko@collabora.com> Message-ID: <20260304165043.1437519-19-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index f4d1113827e..d1b5162f440 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -68,11 +68,17 @@ virgl_get_egl_display(G_GNUC_UNUSED void *cookie) #endif =20 #if VIRGL_VERSION_MAJOR >=3D 1 +enum virtio_gpu_virgl_hostmem_region_mapping_state { + VIRTIO_GPU_MR_MAPPED, + VIRTIO_GPU_MR_UNMAP_STARTED, + VIRTIO_GPU_MR_UNMAP_COMPLETED, +}; + struct virtio_gpu_virgl_hostmem_region { Object parent_obj; MemoryRegion mr; struct VirtIOGPU *g; - bool finish_unmapping; + enum virtio_gpu_virgl_hostmem_region_mapping_state mapping_state; }; =20 #define TYPE_VIRTIO_GPU_VIRGL_HOSTMEM_REGION "virtio-gpu-virgl-hostmem-reg= ion" @@ -109,7 +115,7 @@ static void virtio_gpu_virgl_hostmem_region_finalize(Ob= ject *obj) return; } =20 - vmr->finish_unmapping =3D true; + vmr->mapping_state =3D VIRTIO_GPU_MR_UNMAP_COMPLETED; =20 b =3D VIRTIO_GPU_BASE(vmr->g); b->renderer_blocked--; @@ -167,6 +173,7 @@ virtio_gpu_virgl_map_resource_blob(VirtIOGPU *g, object_initialize_child(OBJECT(g), name, vmr, TYPE_VIRTIO_GPU_VIRGL_HOSTMEM_REGION); vmr->g =3D g; + vmr->mapping_state =3D VIRTIO_GPU_MR_MAPPED; =20 mr =3D &vmr->mr; memory_region_init_ram_ptr(mr, OBJECT(vmr), "mr", size, data); @@ -195,7 +202,8 @@ virtio_gpu_virgl_unmap_resource_blob(VirtIOGPU *g, =20 vmr =3D to_hostmem_region(res->mr); =20 - trace_virtio_gpu_cmd_res_unmap_blob(res->base.resource_id, mr, vmr->fi= nish_unmapping); + trace_virtio_gpu_cmd_res_unmap_blob(res->base.resource_id, mr, + vmr->mapping_state); =20 /* * Perform async unmapping in 3 steps: @@ -206,7 +214,8 @@ virtio_gpu_virgl_unmap_resource_blob(VirtIOGPU *g, * asynchronously by virtio_gpu_virgl_hostmem_region_finalize(). * 3. Finish the unmapping with final virgl_renderer_resource_unmap(). */ - if (vmr->finish_unmapping) { + switch (vmr->mapping_state) { + case VIRTIO_GPU_MR_UNMAP_COMPLETED: res->mr =3D NULL; g_free(vmr); =20 @@ -217,15 +226,22 @@ virtio_gpu_virgl_unmap_resource_blob(VirtIOGPU *g, __func__, strerror(-ret)); return ret; } - } else { - *cmd_suspended =3D true; + break; =20 + case VIRTIO_GPU_MR_MAPPED: /* render will be unblocked once MR is freed */ b->renderer_blocked++; =20 + vmr->mapping_state =3D VIRTIO_GPU_MR_UNMAP_STARTED; + /* memory region owns self res->mr object and frees it by itself */ memory_region_del_subregion(&b->hostmem, mr); object_unparent(OBJECT(vmr)); + + /* Fallthrough */ + case VIRTIO_GPU_MR_UNMAP_STARTED: + *cmd_suspended =3D true; + break; } =20 return 0; diff --git a/hw/display/trace-events b/hw/display/trace-events index e323a82cff2..4bfc457fbac 100644 --- a/hw/display/trace-events +++ b/hw/display/trace-events @@ -39,7 +39,7 @@ virtio_gpu_cmd_res_create_2d(uint32_t res, uint32_t fmt, = uint32_t w, uint32_t h) virtio_gpu_cmd_res_create_3d(uint32_t res, uint32_t fmt, uint32_t w, uint3= 2_t h, uint32_t d) "res 0x%x, fmt 0x%x, w %d, h %d, d %d" virtio_gpu_cmd_res_create_blob(uint32_t res, uint64_t size) "res 0x%x, siz= e %" PRId64 virtio_gpu_cmd_res_map_blob(uint32_t res, void *vmr, void *mr) "res 0x%x, = vmr %p, mr %p" -virtio_gpu_cmd_res_unmap_blob(uint32_t res, void *mr, bool finish_unmappin= g) "res 0x%x, mr %p, finish_unmapping %d" +virtio_gpu_cmd_res_unmap_blob(uint32_t res, void *mr, int mapping_state) "= res 0x%x, mr %p, mapping_state %d" virtio_gpu_cmd_res_unref(uint32_t res) "res 0x%x" virtio_gpu_cmd_res_back_attach(uint32_t res) "res 0x%x" virtio_gpu_cmd_res_back_detach(uint32_t res) "res 0x%x" --=20 2.47.3 From nobody Mon Apr 13 11:14:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772827089; cv=none; d=zohomail.com; s=zohoarc; b=MZ2Yj6bl1esd9EqzhIG6YX1INZmPPNZzH6HHRv8UnR0lL7tWIvrEeG1eTFC0c7H7iwnxG6MRMEVyF1FsyKYgfgpOdVT/fddFSIMQGPa3uKfuTMNJudlu9L44REYFPIq2rjwjefvBYtbAk6vE5VLiymy/H/ss7QbK5PtzYqBNkZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772827089; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UwOC0PCe7NzEBubZnw5hYS6oFj5OnELU54pqMdnKW7c=; b=YA8E18+n08Y+MJpKk/t25uLVJztKrRW6gpIipEBJiORbRH5P8lnlmuHbZyxeKCbNMVtEYt910/gsBexBAWtmhHGfUykYsiZldFDLd4oty5PV0zYM0Cy3eCX+GbsaW/b9gxTQIkXokqRr6qjK7BCiMsIUHkM8M2P5jU+8a3OU3KE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772827089615233.28540537412164; Fri, 6 Mar 2026 11:58:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vybIl-0004sd-P3; Fri, 06 Mar 2026 14:57:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vybId-0004rH-Bs for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:57:28 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vybIb-0001Wt-3r for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:57:26 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-48372efa020so85609355e9.2 for ; Fri, 06 Mar 2026 11:57:22 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48523803b5fsm25147495e9.7.2026.03.06.11.57.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:57:20 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id CB758689D1; Fri, 06 Mar 2026 19:50:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772827042; x=1773431842; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UwOC0PCe7NzEBubZnw5hYS6oFj5OnELU54pqMdnKW7c=; b=W8wurtGf32nkLv3iMFIq9FOaM0DM+J+dBCyrFC1oUfSGgR6ljx0tubkKeUQz6Vptav XZgVDBcaDsOXOw1mirVeWcOgqj4D8UB4H/q00Q/vJ8EbZ7jZQfppB+H4VNRKX+R2GZLL kFqbfWscdm+5qffV4Jbfx80AagGmHluyxbm6arcRGtMOretSlEziXmf9PVY+gWJOlPQX R97QmPSOiOJA89l1dNUNeIQQ2FDZMOb/8gm37KNklCJkQ7VA+y7OgqTcxKdjq/Vyy3IL /ASsmPBSnheUWxzVHTc7PMHDWL9Y8+SyvK35SJlLx0deh2S76YrsHDN9jXJSLHJjsEu3 LpTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772827042; x=1773431842; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=UwOC0PCe7NzEBubZnw5hYS6oFj5OnELU54pqMdnKW7c=; b=TA/tDu+SX6H3IHbugX2Oda6jrPFvAYXtwt4uT2Ecp0jOVfB13eGICEcpek6FhOznC8 9JMrSuA1UKNTI7F18rPDdX7txRmBXcYAGtFbifX9GBjenfgoyv88C69+t5iD779DunCw sGHPrSWtUf94mNHRkMYw8VupoBHdR5al+ERX4PrHJlTiq3CpU6LHf+uKEw+KdupLPy0v z3H0zowvEH/pVhzUX0xvEc1OGDW12yHWC7+c8US87YLT1+huKwa+Ce9BHryBDNtEUwTw 2dpSbMnXHb2P+S9vizFxCZzuaOLQrLSVesoTENSDwa/6wtwYE10VFQhlpCHnhwqOaXbU gDpw== X-Gm-Message-State: AOJu0YzybUuhVVRW9pzf8/CyKfIxTBP7ROdTgCnaFl51j4QVsdVmmZU9 VT1WFmj0FrEKU/AOteMvnu3RDljGo/CsEZO5AjW9/XIvsisCrVVkr21NI7fNi1G8Psg= X-Gm-Gg: ATEYQzzPmbz/5jc9tR0OCY5EOc38Uthw5F9OmVPwTptHTsbWQepMIyymm2NHvVK7TR+ bywZ3JMFZcMarq1VpF9u2DRXFUvLDkAN1Q79qLTPRu/hcC3/pl1AnL76AtFRP2Brq5G3yeTk1xf iI14eiiwpbFWkOXZ2LyhTq0tRC3aJWIaVpb5ri1UDQXKO4xIHx8k8m3YTYD4FF+SqFduQpQU9wG K7YcCN7GwDOUWxe8/pxO4BirmFGT5woMktA0XA3Ko6BSx+Vx1WeuEGryM9vClPczFXfRhNT5tLv xxN6/cg/LKzDMramFjlZ+rAIvh7HkMk6+7+UmJxQApbkIM9N221Z7kyOiDUA0xs/9OGH0/+BRYi pZ0eYMA7VlPO+o0SLulr/HYUm8yf9n6AqQZhrs6rp+gx9c14eSGfezvTMnEu4k8XiORTER95MIo gNU2kul5AczARl4y1fvWzDubs= X-Received: by 2002:a05:600c:3acf:b0:480:1c10:5633 with SMTP id 5b1f17b1804b1-48526979e65mr54746975e9.26.1772827041697; Fri, 06 Mar 2026 11:57:21 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , Akihiko Odaki , Akihiko Odaki , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Michael S. Tsirkin" Subject: [PULL 19/20] virtio-gpu: Destroy virgl resources on virtio-gpu reset Date: Fri, 6 Mar 2026 19:50:46 +0000 Message-ID: <20260306195048.2869788-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306195048.2869788-1-alex.bennee@linaro.org> References: <20260306195048.2869788-1-alex.bennee@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::335; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772827091646154100 From: Dmitry Osipenko Properly destroy virgl resources on virtio-gpu reset to not leak resources on a hot reboot of a VM. Suggested-by: Akihiko Odaki Reviewed-by: Akihiko Odaki Signed-off-by: Dmitry Osipenko Message-ID: <20260303151422.977399-18-dmitry.osipenko@collabora.com> Message-ID: <20260304165043.1437519-20-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 1a999887481..ec3db3b4123 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -390,9 +390,11 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd); void virtio_gpu_virgl_fence_poll(VirtIOGPU *g); void virtio_gpu_virgl_reset_scanout(VirtIOGPU *g); -void virtio_gpu_virgl_reset(VirtIOGPU *g); -int virtio_gpu_virgl_init(VirtIOGPU *g); GArray *virtio_gpu_virgl_get_capsets(VirtIOGPU *g); void virtio_gpu_virgl_reset_async_fences(VirtIOGPU *g); +void virtio_gpu_virgl_resource_destroy(VirtIOGPU *g, + struct virtio_gpu_simple_resource *= res, + Error **errp); +bool virtio_gpu_virgl_update_render_state(VirtIOGPU *g); =20 #endif diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c index b941e9a4b78..8b71dd6fc26 100644 --- a/hw/display/virtio-gpu-gl.c +++ b/hw/display/virtio-gpu-gl.c @@ -63,29 +63,14 @@ static void virtio_gpu_gl_flushed(VirtIOGPUBase *b) static void virtio_gpu_gl_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq) { VirtIOGPU *g =3D VIRTIO_GPU(vdev); - VirtIOGPUGL *gl =3D VIRTIO_GPU_GL(vdev); struct virtio_gpu_ctrl_command *cmd; =20 if (!virtio_queue_ready(vq)) { return; } =20 - switch (gl->renderer_state) { - case RS_RESET: - virtio_gpu_virgl_reset(g); - /* fallthrough */ - case RS_START: - if (virtio_gpu_virgl_init(g)) { - gl->renderer_state =3D RS_INIT_FAILED; - return; - } - - gl->renderer_state =3D RS_INITED; - break; - case RS_INIT_FAILED: + if (!virtio_gpu_virgl_update_render_state(g)) { return; - case RS_INITED: - break; } =20 cmd =3D virtqueue_pop(vq, sizeof(struct virtio_gpu_ctrl_command)); @@ -201,6 +186,7 @@ static void virtio_gpu_gl_class_init(ObjectClass *klass= , const void *data) vgc->process_cmd =3D virtio_gpu_virgl_process_cmd; vgc->update_cursor_data =3D virtio_gpu_gl_update_cursor_data; =20 + vgc->resource_destroy =3D virtio_gpu_virgl_resource_destroy; vdc->realize =3D virtio_gpu_gl_device_realize; vdc->unrealize =3D virtio_gpu_gl_device_unrealize; vdc->reset =3D virtio_gpu_gl_reset; diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index d1b5162f440..1819f9cb7e9 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -96,6 +96,10 @@ static void virtio_gpu_virgl_resume_cmdq_bh(void *opaque) { VirtIOGPU *g =3D opaque; =20 + if (!virtio_gpu_virgl_update_render_state(g)) { + return; + } + virtio_gpu_process_cmdq(g); } =20 @@ -344,14 +348,46 @@ static void virgl_cmd_create_resource_3d(VirtIOGPU *g, virgl_renderer_resource_create(&args, NULL, 0); } =20 +static int +virtio_gpu_virgl_resource_unref(VirtIOGPU *g, + struct virtio_gpu_virgl_resource *res, + bool *suspended) +{ + struct iovec *res_iovs =3D NULL; + int num_iovs =3D 0; +#if VIRGL_VERSION_MAJOR >=3D 1 + int ret; + + ret =3D virtio_gpu_virgl_unmap_resource_blob(g, res, suspended); + if (ret) { + return ret; + } + if (*suspended) { + return 0; + } +#endif + + virgl_renderer_resource_detach_iov(res->base.resource_id, + &res_iovs, + &num_iovs); + if (res_iovs !=3D NULL && num_iovs !=3D 0) { + virtio_gpu_cleanup_mapping_iov(g, res_iovs, num_iovs); + } + virgl_renderer_resource_unref(res->base.resource_id); + + QTAILQ_REMOVE(&g->reslist, &res->base, next); + + g_free(res); + + return 0; +} + static void virgl_cmd_resource_unref(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd, bool *cmd_suspended) { struct virtio_gpu_resource_unref unref; struct virtio_gpu_virgl_resource *res; - struct iovec *res_iovs =3D NULL; - int num_iovs =3D 0; =20 VIRTIO_GPU_FILL_CMD(unref); trace_virtio_gpu_cmd_res_unref(unref.resource_id); @@ -364,27 +400,21 @@ static void virgl_cmd_resource_unref(VirtIOGPU *g, return; } =20 -#if VIRGL_VERSION_MAJOR >=3D 1 - if (virtio_gpu_virgl_unmap_resource_blob(g, res, cmd_suspended)) { - cmd->error =3D VIRTIO_GPU_RESP_ERR_UNSPEC; - return; - } - if (*cmd_suspended) { - return; - } -#endif + virtio_gpu_virgl_resource_unref(g, res, cmd_suspended); +} =20 - virgl_renderer_resource_detach_iov(unref.resource_id, - &res_iovs, - &num_iovs); - if (res_iovs !=3D NULL && num_iovs !=3D 0) { - virtio_gpu_cleanup_mapping_iov(g, res_iovs, num_iovs); - } - virgl_renderer_resource_unref(unref.resource_id); +void virtio_gpu_virgl_resource_destroy(VirtIOGPU *g, + struct virtio_gpu_simple_resource *= base, + Error **errp) +{ + struct virtio_gpu_virgl_resource *res; + bool suspended =3D false; =20 - QTAILQ_REMOVE(&g->reslist, &res->base, next); + res =3D container_of(base, struct virtio_gpu_virgl_resource, base); =20 - g_free(res); + if (virtio_gpu_virgl_resource_unref(g, res, &suspended)) { + error_setg(errp, "failed to destroy virgl resource"); + } } =20 static void virgl_cmd_context_create(VirtIOGPU *g, @@ -1291,6 +1321,10 @@ static void virtio_gpu_fence_poll(void *opaque) VirtIOGPU *g =3D opaque; VirtIOGPUGL *gl =3D VIRTIO_GPU_GL(g); =20 + if (!virtio_gpu_virgl_update_render_state(g)) { + return; + } + virgl_renderer_poll(); virtio_gpu_process_cmdq(g); if (!QTAILQ_EMPTY(&g->cmdq) || !QTAILQ_EMPTY(&g->fenceq)) { @@ -1313,14 +1347,30 @@ void virtio_gpu_virgl_reset_scanout(VirtIOGPU *g) } } =20 -void virtio_gpu_virgl_reset(VirtIOGPU *g) +static bool virtio_gpu_virgl_reset(VirtIOGPU *g) { + struct virtio_gpu_simple_resource *res, *tmp; + + /* + * Virgl blob resource unmapping can be suspended and + * deferred on unref, ensure that destruction is completed. + */ + QTAILQ_FOREACH_SAFE(res, &g->reslist, next, tmp) { + virtio_gpu_virgl_resource_destroy(g, res, NULL); + } + + if (!QTAILQ_EMPTY(&g->reslist)) { + return false; + } + virgl_renderer_reset(); =20 virtio_gpu_virgl_reset_async_fences(g); + + return true; } =20 -int virtio_gpu_virgl_init(VirtIOGPU *g) +static int virtio_gpu_virgl_init(VirtIOGPU *g) { int ret; uint32_t flags =3D 0; @@ -1398,6 +1448,35 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) return 0; } =20 +bool virtio_gpu_virgl_update_render_state(VirtIOGPU *g) +{ + VirtIOGPUGL *gl =3D VIRTIO_GPU_GL(g); + + switch (gl->renderer_state) { + case RS_RESET: + virgl_renderer_force_ctx_0(); + + if (!virtio_gpu_virgl_reset(g)) { + return false; + } + /* fallthrough */ + case RS_START: + if (virtio_gpu_virgl_init(g)) { + gl->renderer_state =3D RS_INIT_FAILED; + return false; + } + + gl->renderer_state =3D RS_INITED; + break; + case RS_INIT_FAILED: + return false; + case RS_INITED: + break; + } + + return true; +} + static void virtio_gpu_virgl_add_capset(GArray *capset_ids, uint32_t capse= t_id) { g_array_append_val(capset_ids, capset_id); --=20 2.47.3 From nobody Mon Apr 13 11:14:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772826739; cv=none; d=zohomail.com; s=zohoarc; b=DpoFm2NvemQ1sWceLUUeUxdKD/wkwxSeokj29+wBe32SHpitKVIkHGAvnK7os2AjvhKo2JCBgzTrvl06IVY1g17SrfdwUrl36WJgvTVra1GFBLCj1SHaMtzR1xzuD9k/VmAMw4gHZG34DsFfqGwapXokpeSoJstmEeuoVEJWtVY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772826739; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=uK3c2N7J7e+anI448dkPp4SW/OHMVl4XpP6gl2e8CWo=; b=EgaCGYfJela/ORdJPv1OvkmjoPTV6p+kibuz2eJB8CMvTv7sHGq/xkCSwiTl+slgPf3tcW4ckyBb7dyWBOc2wW+Jz7p091oqSvsPLYVVP1w1uF1cZYf3rAz6sFicYtyH3NH9bAfPoMPAmXzbkzPqYi9y0mLsRaUX/3VjSoWFaAg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772826739137739.3867174874854; Fri, 6 Mar 2026 11:52:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vybDJ-0005XF-BS; Fri, 06 Mar 2026 14:51:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vybCX-0004Eq-3U for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:09 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vybCV-0000Sr-4L for qemu-devel@nongnu.org; Fri, 06 Mar 2026 14:51:08 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4852c9b4158so1468475e9.0 for ; Fri, 06 Mar 2026 11:51:03 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4852767d8e4sm53256055e9.2.2026.03.06.11.50.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:51:00 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id E5639689E2; Fri, 06 Mar 2026 19:50:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772826663; x=1773431463; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uK3c2N7J7e+anI448dkPp4SW/OHMVl4XpP6gl2e8CWo=; b=Ol0tgEfCA8Zh9TJeWy+FcoilebqDo1wnFrq5a3kLwcnOUIRLzl62cQvIkhgnqE1s2a THbhsly3zd5ICrpoMbIOOjHt+JrzxMY9vuuPfn2aXNViWRpCJAV7/gy1hobZrmKFvlgC x1Px3vspLG/RRjqJ+TthwwGnzYUVyd1hx8CjYwSiYmK8rovwQy4HgU7fnLa1bhFejUxO eyQHUERKX4YuAphF1tJH6fVcp+Ew58xGMtRrYZ1BKS00KP0lzaqmOwnTeM1MWtPXKzWR GxTEX5l0OIcEVfLWwssWz4AQvEZY2LSAyF5WlhyuXu8p5WBAcHKY7NBjx6t0rWMmDJeg k/aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772826663; x=1773431463; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=uK3c2N7J7e+anI448dkPp4SW/OHMVl4XpP6gl2e8CWo=; b=TlKoj0RdWC0eA8nAwPz0A6e8c6GYpj3DMj5PXOBG/T25bD9KbXjeIBsjjw1L9C+WWC hh/XsJNqp4JRAl8W3kEVyzTMdDvN5lkwvU+ECZblFwRejIEk857Z3HdAa2bNH7gyuwhF dlCoaIWgFCOviP6/JWIIfa1DZXOoT0/nEgsKuGqDUXj6Cwnk0Suh4yq7h47fQXZu9cqX EBgxiMXSh2WIi2pcMipXzcX2hlDUtnQ4wSIMquTtxtG6VZiDXWLa++Bz6fg8eTdYyUmd CDQV4gTCpH3Fhc8bCXhV4ToeBvp3EBnUyGsdtCVioeaHvS/ltT32TlS95AAYp9cDSC91 5t8Q== X-Gm-Message-State: AOJu0YzeFSrnreUn4J+IiqD8qVv2kp1bnpxXex/vJRfBIlanGtkT+Y98 F9XSm7nAwFHp68AO4VVn+w+zq54JSTBNFI8aewZK1M63mwpVL/pFM1ZrV6fm6aRwcxE= X-Gm-Gg: ATEYQzzqHnF3OE7hNep/18aUD+xZuXMai22qsgiz+uQNz+bghLrk0bbbEnrlOGrFOWl 62VOTkYvtypWQuPk13hI4+MAVriHYnO+RqXxcA710lQO/bhnB/7eli7E4VgZRtzCIx2GuiyfaI6 peR+Vw3Q5f1guJjyg490S7EMij1OcAQc5G9+fPfQnNrIYArU+WP6SBvOC4APyH2pvQv9rtF9jEb SNuT/Kv4KvLDuFzbLIZWvtmYsY31Ho0xAYqeWxrz04exI+ZI7tgOMq7+xLikn2A+UYQC6l8k71S eC5BFBgAoy4LVYw0jFLwdp0zlp8Y360LXDdLO6Lbhu3siobP9gPwb4ilFN86bBba0IOLlKU+Ezj Dj6xAbMMe2mcopZd/dwfnM204G7rmeQx6E+wdCiR1FJKtA9qLboVeorH8W+7Eg4rG7htKE9a8v2 RmcAkphQDQ4vv3WdlWt4SBnsc= X-Received: by 2002:a05:600c:444f:b0:480:4b59:932e with SMTP id 5b1f17b1804b1-4852692498emr50821475e9.11.1772826662764; Fri, 06 Mar 2026 11:51:02 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , Yiwei Zhang , Akihiko Odaki , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Michael S. Tsirkin" , Akihiko Odaki Subject: [PULL 20/20] virtio-gpu: Support mapping hostmem blobs with map_fixed Date: Fri, 6 Mar 2026 19:50:47 +0000 Message-ID: <20260306195048.2869788-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306195048.2869788-1-alex.bennee@linaro.org> References: <20260306195048.2869788-1-alex.bennee@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::333; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772826740842158500 From: Dmitry Osipenko Support mapping virgl blobs to a fixed location of a hostmem memory region using new virglrenderer MAP_FIXED API. This new feature closes multiple problems for virtio-gpu on QEMU: - Having dedicated memory region for each mapped blob works notoriously slow due to QEMU's memory region software design built around RCU that isn't optimized for frequent removal of the regions - KVM isn't optimized for a frequent slot changes too - QEMU/KVM has a limit for a total number of created memory regions, crashing QEMU when limit is reached This patch makes virtio-gpu-gl to pre-create a single anonymous memory region covering whole hostmem area to which blobs will be mapped using the MAP_FIXED API. Not all virgl resources will support mapping at a fixed memory address. For them, we will continue to create individual nested memory sub-regions. In particular, vrend resources may not have MAP_FIXED capability. Venus and DRM native contexts will largely benefit from the MAP_FIXED feature in terms of performance and stability improvement. Tested-by: Yiwei Zhang Reviewed-by: Akihiko Odaki Signed-off-by: Dmitry Osipenko Message-ID: <20260303151422.977399-19-dmitry.osipenko@collabora.com> Message-ID: <20260304165043.1437519-21-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index ec3db3b4123..f69fc194627 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -263,6 +263,9 @@ struct VirtIOGPUGL { =20 QEMUBH *async_fence_bh; QSLIST_HEAD(, virtio_gpu_virgl_context_fence) async_fenceq; + + MemoryRegion hostmem_background; + void *hostmem_mmap; }; =20 struct VhostUserGPU { diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c index 8b71dd6fc26..2b7a41c4664 100644 --- a/hw/display/virtio-gpu-gl.c +++ b/hw/display/virtio-gpu-gl.c @@ -13,6 +13,7 @@ =20 #include "qemu/osdep.h" #include "qemu/iov.h" +#include "qemu/mmap-alloc.h" #include "qemu/module.h" #include "qemu/error-report.h" #include "qapi/error.h" @@ -106,7 +107,12 @@ static void virtio_gpu_gl_reset(VirtIODevice *vdev) static void virtio_gpu_gl_device_realize(DeviceState *qdev, Error **errp) { ERRP_GUARD(); - VirtIOGPU *g =3D VIRTIO_GPU(qdev); + VirtIOGPUBase *b =3D VIRTIO_GPU_BASE(qdev); + VirtIOGPU *g =3D VIRTIO_GPU(b); +#if !defined(CONFIG_WIN32) + VirtIOGPUGL *gl =3D VIRTIO_GPU_GL(g); + void *map; +#endif =20 #if HOST_BIG_ENDIAN error_setg(errp, "virgl is not supported on bigendian platforms"); @@ -136,6 +142,24 @@ static void virtio_gpu_gl_device_realize(DeviceState *= qdev, Error **errp) g->parent_obj.conf.flags |=3D 1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLE= D; #endif =20 +#if !defined(CONFIG_WIN32) + if (virtio_gpu_hostmem_enabled(b->conf)) { + map =3D qemu_ram_mmap(-1, b->conf.hostmem, qemu_real_host_page_siz= e(), + 0, 0); + if (map =3D=3D MAP_FAILED) { + error_setg_errno(errp, errno, + "virgl hostmem region could not be initialize= d"); + return; + } + + gl->hostmem_mmap =3D map; + memory_region_init_ram_ptr(&gl->hostmem_background, NULL, + "hostmem-background", b->conf.hostmem, + gl->hostmem_mmap); + memory_region_add_subregion(&b->hostmem, 0, &gl->hostmem_backgroun= d); + } +#endif + virtio_gpu_device_realize(qdev, errp); } =20 @@ -172,6 +196,17 @@ static void virtio_gpu_gl_device_unrealize(DeviceState= *qdev) gl->renderer_state =3D RS_START; =20 g_array_unref(g->capset_ids); + + /* + * It is not guaranteed that the memory region will be finalized + * immediately with memory_region_del_subregion(), there can be + * a remaining reference to gl->hostmem_mmap. VirtIO-GPU is not + * hotpluggable, hence no need to worry about the leaked mapping. + * + * The memory_region_del_subregion(gl->hostmem_background) is unnecess= ary + * because b->hostmem and gl->hostmem_background belong to the same + * device and will be gone at the same time. + */ } =20 static void virtio_gpu_gl_class_init(ObjectClass *klass, const void *data) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 1819f9cb7e9..b7a2d160ddd 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -41,9 +41,13 @@ VIRGL_VERSION_MICRO >=3D (micro)) #endif =20 +#define VIRGL_HAS_MAP_FIXED \ + (VIRGL_CHECK_VERSION(1, 3, 0) && !IS_ENABLED(CONFIG_WIN32)) + struct virtio_gpu_virgl_resource { struct virtio_gpu_simple_resource base; MemoryRegion *mr; + void *map_fixed; }; =20 static struct virtio_gpu_virgl_resource * @@ -155,6 +159,9 @@ virtio_gpu_virgl_map_resource_blob(VirtIOGPU *g, g_autofree char *name =3D NULL; struct virtio_gpu_virgl_hostmem_region *vmr; VirtIOGPUBase *b =3D VIRTIO_GPU_BASE(g); +#if VIRGL_HAS_MAP_FIXED + VirtIOGPUGL *gl =3D VIRTIO_GPU_GL(g); +#endif MemoryRegion *mr; uint64_t size; void *data; @@ -165,6 +172,41 @@ virtio_gpu_virgl_map_resource_blob(VirtIOGPU *g, return -EOPNOTSUPP; } =20 +#if VIRGL_HAS_MAP_FIXED + /* + * virgl_renderer_resource_map_fixed() allows to create multiple + * mappings of the same resource, while virgl_renderer_resource_map() + * not. Don't allow mapping same resource twice. + */ + if (res->map_fixed || res->mr) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: failed to map(fixed) virgl resource: already ma= pped\n", + __func__); + return -EBUSY; + } + + ret =3D virgl_renderer_resource_map_fixed(res->base.resource_id, + gl->hostmem_mmap + offset); + switch (ret) { + case 0: + res->map_fixed =3D gl->hostmem_mmap + offset; + return 0; + + case -EOPNOTSUPP: + /* + * MAP_FIXED is unsupported by this resource. + * Mapping falls back to a blob subregion method in that case. + */ + break; + + default: + qemu_log_mask(LOG_GUEST_ERROR, + "%s: failed to map(fixed) virgl resource: %s\n", + __func__, strerror(-ret)); + return ret; + } +#endif + ret =3D virgl_renderer_resource_map(res->base.resource_id, &data, &siz= e); if (ret) { qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to map virgl resource: = %s\n", @@ -181,7 +223,7 @@ virtio_gpu_virgl_map_resource_blob(VirtIOGPU *g, =20 mr =3D &vmr->mr; memory_region_init_ram_ptr(mr, OBJECT(vmr), "mr", size, data); - memory_region_add_subregion(&b->hostmem, offset, mr); + memory_region_add_subregion_overlap(&b->hostmem, offset, mr, 1); =20 res->mr =3D mr; =20 @@ -200,6 +242,21 @@ virtio_gpu_virgl_unmap_resource_blob(VirtIOGPU *g, MemoryRegion *mr =3D res->mr; int ret; =20 +#if VIRGL_HAS_MAP_FIXED + if (res->map_fixed) { + if (mmap(res->map_fixed, res->base.blob_size, PROT_READ | PROT_WRI= TE, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, + -1, 0) =3D=3D MAP_FAILED) { + ret =3D -errno; + error_report("%s: failed to unmap(fixed) virgl resource: %s", + __func__, strerror(-ret)); + return ret; + } + + res->map_fixed =3D NULL; + } +#endif + if (!mr) { return 0; } --=20 2.47.3