From nobody Sat Apr 11 23:04:26 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=1772643108; cv=none; d=zohomail.com; s=zohoarc; b=BTMqCtUAfGu7FLKsKKKCMAU1DGuGpt36R3EKop/i64cn537j9VqoKorTvPaSLlTNv9pXqL0GLfJK/SA+rg3Oc6odtnIAuRHOcQlS+uY6ImEMT0INoZOtKuNSYNDnA8uMwBFLM2je+hlbHn25GDiw5FJpHuH6kcN/yB6B2MGtD4Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772643108; 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=UZAvHG40jXQMBngawC8NrPyT3mArKFlvPG9XrbzWnFE=; b=U5/CoIjxXj9jDG6qfmigI7+7W0pZY8G7WGUD6ahfXVUygOZBypqfcH00CxTtmeXbuTFf/MrMQ88oUxmOI4qssSlV5l42vammYI5InOqatpm2XYY6a08/b5cItOcJgULT41Xgi2NL6yAp9YStKyMhFKxQM20Eqo4ACBYLN2/7KJQ= 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 1772643108380414.9034654060091; Wed, 4 Mar 2026 08:51:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxpR1-0003rs-Ja; Wed, 04 Mar 2026 11:50: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 1vxpQx-0003pS-UQ for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:52 -0500 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vxpQt-0002PC-U4 for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:51 -0500 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-65bfc858561so3383315a12.2 for ; Wed, 04 Mar 2026 08:50:46 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-65fac06e3fasm5775501a12.25.2026.03.04.08.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:50:44 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id C78285FB2D; Wed, 04 Mar 2026 16:50:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772643046; x=1773247846; 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=UZAvHG40jXQMBngawC8NrPyT3mArKFlvPG9XrbzWnFE=; b=r80TizfW5A0K2c5OUJzq1zs/7w9Biwtl0zL6OdhnQot2cQl79qbbOJ2eGtvvl0VKI2 fVnpPWBGIH1KCjTtV+coDKfNBQ5i8kBqMKHA/LN3qXziNbTJFHg/5SDSMaQLQAaXeQl7 x8wB3anTNbX8i9jE6OEueJ9q5kg6EZoW8YQMis9E6/F6PfV6Ahr+uvRW7Z1xU2jP4duJ PaMYeVqRR6u5Vf94UnT3BvYqo5ojPsgpCkM7d6/243F2+LE+V1jlAnWnCihQxLMFggvO stXlh+9ImaKC751DpMO8aFMc6aX8qb8TL2DStaO1unKvkIwi2yNkIvxZmgQw1QD2Q1G4 qP6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772643046; x=1773247846; 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=UZAvHG40jXQMBngawC8NrPyT3mArKFlvPG9XrbzWnFE=; b=RMc3XIZcONiAyE5aWdED00+BK2RXLogXwxJsacAvDmXYlR8y4ebq5uMFTM8lhU9oJG tF3zXshwuY3y+sFRhr1KJNq1DC4ZxtuhN0AcNZ1Uc4Q+4Z0ZtHGh0EhY3dDA6nzgyJs5 iacphJFJ6syrnU6bvpTIo0hz2nFEG2SscpDMQGdmOZ1nvIA8rCuHX0GUph8VOEDUbSQO mOr2FOs0Aj6TC+UHnE2iqZ4EV82W6kHvzc7lZ3MVwaEHG5+95m3IqLLlM1RfyaycDttC 5fG4diKkfcyc+LTBOvo8Cose/FfzfJT0ZR9cKY+oRfk5voQtVOymV1tMBozCad32o3/x nBNg== X-Gm-Message-State: AOJu0YxmK0LlU/2/9pERIrPd5t9RcObfEfurAMPWEaWnNYKthx+2I+cG E7qibGdjDk7pXLI+9QaAzuMylcOrhVnr+eHFsGmhnVyxgF6jBszGzPD0ggnr52H72cs= X-Gm-Gg: ATEYQzxwjWiXh/XwDS2XraqRmz3pApFo/xNty13+2hmHz9mhDJx2XWwa7ZZDWFpTZK4 Km7voceZAmskO6kqOhAO98s7TnL842+pNU9r9AMSgnppbm4BIQac7QskWC3andJ/ZKrlvfEa1V3 lXrNYVOlCsePS0ql80GexUlO4+6bgI9hyNs31AbrmhJkYdojQ+NZwwgGN/EloxwW5SaoLMKkGkB 95/rbAus+EMRoFXDop7g/53HfEa+j3L7Ux8tyD7VD3Cj+FtvdWA7SiWOl4M9yAb5kMgztvDbeqk xiv1s0jSi0t3iKbEhY+cQ/e6NOSims9WdFs9MLsOipY3RId4SLsxRtNrklPXCIbBonDt2fj7MnD HaztbV2cPD+624E5w7Fx6kKZT+AfE7aLmnWDiWmOk+TopFqm4GPvVMGJ742DodJhltG8bc4785S NOOWI5Bl03zC+y96017onK2VI= X-Received: by 2002:a05:6402:40c8:b0:660:48f:22b9 with SMTP id 4fb4d7f45d1cf-660ef78bfc7mr1456247a12.12.1772643045513; Wed, 04 Mar 2026 08:50:45 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Blake , "Michael S. Tsirkin" , Dmitry Osipenko , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Andrew Keesler Subject: [PATCH 01/20] Support per-head resolutions with virtio-gpu Date: Wed, 4 Mar 2026 16:50:23 +0000 Message-ID: <20260304165043.1437519-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304165043.1437519-1-alex.bennee@linaro.org> References: <20260304165043.1437519-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::533; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x533.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: 1772643110966139100 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] Signed-off-by: Alex Benn=C3=A9e --- qapi/virtio.json | 13 +++++++++++-- hw/display/virtio-gpu-base.c | 16 ++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) 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 Sat Apr 11 23:04:26 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=1772643076; cv=none; d=zohomail.com; s=zohoarc; b=cJo36ARWNE3bcRiOxhR3Nbbna5FVqcTHqjOo1GoCqsa4pP1msDs1wdPPwi178bqZXJMlEjMyAF2+oZbyMsfT1HM9UxHYQR+lSmRRObd4yWvagEZmiST4uP8lJ7cF/SLMXGBfzOg2SmAr6H4HasZBd7lFzv2urCjRddRjByw+Fow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772643076; 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=XB0LouhneiGd1+ORaYMQ9LlDP2eplcvPYyqDfPmQLc4=; b=U9YC18O9ZFuu8xK5yrSIEG9rGfanMDORvaa9W87JfMAPnvqkSjDJVWfOSyrNYsqHitHURb+mcpPVbaerLCTDpDvf3vrtpXP8hFwZeteNIjqfIi0+pScrtxlVEVddL+2pyfQUm+XSAzng17zlUxgeYhQ5UA1tG/TIjCJrYn8g00w= 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 1772643076190433.34326393833715; Wed, 4 Mar 2026 08:51:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxpQz-0003qC-CT; Wed, 04 Mar 2026 11:50: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 1vxpQy-0003pc-Dd for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:52 -0500 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vxpQv-0002PL-Hc for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:52 -0500 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-65f812e0d93so10937041a12.2 for ; Wed, 04 Mar 2026 08:50:47 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b93968f2250sm575648466b.31.2026.03.04.08.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:50:44 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id E0C0E5FC09; Wed, 04 Mar 2026 16:50:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772643047; x=1773247847; 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=XB0LouhneiGd1+ORaYMQ9LlDP2eplcvPYyqDfPmQLc4=; b=uMizcNxEYRjuUiLgZ/Cux8lQDmlAOmEULInGcpL95KscZNPdvoife97Ec2fAPtmoFM u7gCx6w5FF6N1SiaqKfyGW8WcSkngcF1zlqKSpJWouKF+9mJUSFjJqkcIYbKPDzxpg7s PXU9SqAz9OJwMAnYy8RrrxmfTN7sjEqqsfiTWQ9h5GWRXgT+mXYQygaGaMBNhqKULbEZ JidNvcIYYrzjxiMhj9yKmtxHNwGNbfpiHrbSy2VrCRMPQ+9ts6WeL/fuCgJ6s2/Y5/Kv bksRS+Tm3UmAvxS8jGV+BDo6oHTKgfc3QYn0JXGHhdo2n31CBn0emWBtG5uAzYuOnuB0 MSsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772643047; x=1773247847; 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=XB0LouhneiGd1+ORaYMQ9LlDP2eplcvPYyqDfPmQLc4=; b=CHmPisLCUqjbtJvhTEG3ab8fkVZERIA+u0lTVbFGRZbJ4F7YerzJlsoRv7g3+OFrb5 SMGEcZsutLTX6IQsxZfZm4DiecLXUvh4KyAO8ZVxbEbbPrr8oqBxvl8hJUSJHZZraf1C ukNZ/pWa7NujD10rsN0NKsF99LgJlT9O4QbQzKH9zFibr8zWql5dnQTzh3/geoA2W1ym QohnH1xrKEAAyrm+gOuOMJDBHYjIp6sK/fpHIKGiNupwXToNFL5MOw3AT4amRcVMQkrU sqB8Z7m5nqNNW1OtwrXGIjJz0qn1tu5XM/gYAdOcxjeoNZVCKSsbpM61U46vD1Xp1ELR rAjQ== X-Gm-Message-State: AOJu0YwTJGgj/FaFY7Yiw0zoGOqmL6ko1Nq5z2BmT1ghp0vcOA9Racq9 GWWnJrH3e5Qs08NDmORIzY8DvmqWcvQ+2q5A2hPLfNMwFn0xIMMVBH0ET/e1zLxvM5s= X-Gm-Gg: ATEYQzzDJP0Fhb0Zw00m/bKrL1tdIhKspYs5XYli3fb06zZaNJ8b1h5MiUdIPGvCmwN N6i+FfW/jWsrGeFp+TLPTxHFxOnrnD00KIieOTl4bTI3vE9fjRtkrBxpqsY4fqmX7/dw4lH1TWQ s+pcTkio53CHVORor2DYZBNC4NrshDFWIFtodJtRYmG/HyMRjP9Kbr3gTHUc+XFpDxbeT+qrDdD 3ODDA23UGQIbJtCe4XWKOGvGKm5cHTo2P0awWPIw5CZG5ZiPByM9sfg95f7b57cCtDUEpQQqaIS Iop97dQ6c6hRjhndWsrQ9pB1LKpLVHirWclO8E/OE5te1HpLD51+VWtbZmaychndw7AnuH1reEH nezRSWvECTjRArILf32YHv6kyR7JzIbUT4EJfeK1UKnk+cpRhlZ7U6f8D31P8nY0xEochyMrdI8 9/i8PH8Ev/DHPSyfCd1YqEx8U= X-Received: by 2002:a17:907:720b:b0:b93:6233:5fb2 with SMTP id a640c23a62f3a-b93f14306a5mr156205066b.41.1772643046542; Wed, 04 Mar 2026 08:50:46 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Blake , "Michael S. Tsirkin" , Dmitry Osipenko , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Dongwon Kim , Gerd Hoffmann , Vivek Kasireddy Subject: [PATCH 02/20] virtio-gpu: Fix scanout dmabuf cleanup during resource destruction Date: Wed, 4 Mar 2026 16:50:24 +0000 Message-ID: <20260304165043.1437519-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304165043.1437519-1-alex.bennee@linaro.org> References: <20260304165043.1437519-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::531; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x531.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: 1772643077477158500 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: Gerd Hoffmann Cc: Marc-Andr=C3=A9 Lureau Signed-off-by: Vivek Kasireddy Signed-off-by: Dongwon Kim Acked-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260303010047.1925589-1-dongwon.kim@intel.com> [AJB: fixed stub declaration] Signed-off-by: Alex Benn=C3=A9e --- include/hw/virtio/virtio-gpu.h | 3 ++- hw/display/virtio-gpu-udmabuf-stubs.c | 2 +- hw/display/virtio-gpu-udmabuf.c | 25 ++++++++++++++++++------- hw/display/virtio-gpu.c | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-) 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..bd5b44f5fba 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,24 @@ 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 && (res->dmabuf_fd !=3D -1) && + qemu_dmabuf_get_fds(dmabuf->buf, NULL)[0] =3D=3D res->dmabuf_f= d) { + 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 Sat Apr 11 23:04:26 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=1772643127; cv=none; d=zohomail.com; s=zohoarc; b=QU9768sVYjH1ZdhqGC4W/BUP/G5lTwdD/Nm/OxSjKxChJNBlyDmtfRrwJzeR+CuWEpv18MX3sYxbPV9rGEer1ZHeZwaYSxThM5YmO9Rf4O0zUZC+No+f4RJjsWBPhgxsIIbLc+Hjld6vVydJXVINpDhSTeGxekpAcQytU0UXjWo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772643127; 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=e5chmRJdStSTBUIyVExBHarHbJeDveLuSTCJqeJVI00=; b=X/bc6HiAZfIh3pooRt8W/EmxlkqrqTfYqsgK1PfiDEXallak33k88y/rG8YI8hGQRb9jP8vsWJmvmgZkljTrNWlfxYCMTawyD6XDji6FeZqo9HRKFxsqmYaeuz59D/1Bj3CHlzdFTycKxYtTNH1RY9qqs5IV4u8hlCY/2D85yy4= 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 1772643126964656.9090655970971; Wed, 4 Mar 2026 08: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 1vxpR2-0003sh-S9; Wed, 04 Mar 2026 11:50:56 -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 1vxpQy-0003pX-Cz for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:52 -0500 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vxpQv-0002PQ-Pw for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:52 -0500 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-660dcafc85aso2140367a12.0 for ; Wed, 04 Mar 2026 08:50:48 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-65fabd4695bsm5941312a12.12.2026.03.04.08.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:50:45 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 014915FD5B; Wed, 04 Mar 2026 16:50:44 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772643047; x=1773247847; 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=e5chmRJdStSTBUIyVExBHarHbJeDveLuSTCJqeJVI00=; b=Q2kL+I9wUYbVepJ1wqsmGXWU9/Qhgo4AGB6EZoesUn2HV0FUw9mGyifBT+zKCqkaEO ifkePFgcOSOvzGZZefNFoqUVL73w0qXaG6VPglxaGXBAqi19fNV27xgYYkjdu/AXDGfH lLhwodLh54zZj7Igz0kPXFeYDWe+DMUoeLAZ62nF4AL+FSTYWLVWoaMt1x63JlHz3wV0 FKhLj9SBz9x0qUdiT7c3nnDUp4QbBmP8PlRPQe19a9TUffUuESgbO2lk+Pa4CptgocZx c9/ufjhu4bXv9dF5dUTg1RHKph2anU8fIlBUfjyAbZBjrmxnP7TMjNGAGUVp6C7aS+8o HrNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772643047; x=1773247847; 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=e5chmRJdStSTBUIyVExBHarHbJeDveLuSTCJqeJVI00=; b=T+uMU9U29PqZSLKwEA1fE9guldmKHiYiiYnJjmsbr+vaPaOBMTKgmznpeu21PJTw1w MV0++GffPiAMyKemgda1f/F6Tm6V5zRd9s/XJnW6sTeKThwyIk8QVanjav5OYay+zxA+ M8avxu+udqo+7kbQxnvnKaHiJUYn2dvteYkcu3hYvMgEtQhAN7A+86+EBgcGnJeoQpLD RCDOxT4VfAG1qF2iSQg7C4Q2KhCf5XFGzQe5YIqSIp+47pjiloq+uVEL68HCSwOsLxLp tdDtLY9h35HUmpxEdToFxljFMXiJzUU2YV3BzYQXt33QsgJ/q06mLSUwupTcSwrmpATu msIw== X-Gm-Message-State: AOJu0YyDjJCrp8vnDVUtnQaHiw56aRm9DIwOcP/E0QGaXPv+IScoILLL CgR4hwQ4KzphNgBrnDTOaZfFqT/No3qcUQc+4a1YR4ml1PiF1t15FFjj+P/ZAG1Bp5U= X-Gm-Gg: ATEYQzxllFiYqxHq3KP4/Ik+ytlfO7nE06qw362RnrYXMyVe8EBmspl/cV14MNgsco2 CBlua0BUysVgGYgZYsT3/k1zZOBzOeRj0wTYBysBYfJFwpzD/2YNBY1pLEsPIbLiCs14Rk3N9XE RPWZCWkmDKvHEJgqXahzucjWUdJ81FHH2ryEDgvqOPd494SkSb5XZuGTsrZOwiQj3CAJB7jEBFp NoN9p+mwCV+BlGUYgoypiBzl3PVWQXKDOKL+OIcFbDkI4Xvwv2+V7zEjCcQDXETN7MmwZobDU/F V6EH6FCKX376Kz6MkZbHef/sEK/qSLrt1cwKbVEHledGNYHyxDzF0aEZOB3uu/u70xjBGjShKtf nOvy8MA2LfL17hQQ/kgkadmb2zrgLlbdx/41dDQlT//DXEgNuG9KeTjMGURoAVX4Lv+BQsjuyLl +3or2AnMX+QKlhifTCKwTbhCbPuMjvleaG6Q== X-Received: by 2002:a50:85c8:0:b0:660:f98d:227e with SMTP id 4fb4d7f45d1cf-660f98d2539mr845874a12.23.1772643047221; Wed, 04 Mar 2026 08:50:47 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Blake , "Michael S. Tsirkin" , Dmitry Osipenko , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Pierre-Eric Pelloux-Prayer , Yiwei Zhang Subject: [PATCH 03/20] ui/gtk: Don't disable scanout when display is refreshed Date: Wed, 4 Mar 2026 16:50:25 +0000 Message-ID: <20260304165043.1437519-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304165043.1437519-1-alex.bennee@linaro.org> References: <20260304165043.1437519-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::534; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x534.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: 1772643128322154100 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> --- ui/gtk-egl.c | 1 - ui/gtk-gl-area.c | 1 - 2 files changed, 2 deletions(-) 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 Sat Apr 11 23:04:26 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=1772643194; cv=none; d=zohomail.com; s=zohoarc; b=Z/Kq0Mh3FWIp2n3QAmJaVEAGmZTcV33UGfFBpp5Dcjl6xiV5STB/jMlVgKX36kyDumzuhskmvTfwtVp+h+1eUasVtsztWX3psQnZ+eeBdn6+7RkNuykj6UgVsxGp/J4WLj0BPho8Xmn3wCLhqNh8DOuknpeN26QkuLS2Ug7hftI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772643194; 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=+kubWz9KDgycCqkZClTxhaq/ye7WarZSE8+MZWS4vpo=; b=HTRsDjDIC287y+OlTu8+TbKAEyx7a7wwLtPpHArNe2RS7mr3QSSrbcCSbuzrl/JwsEheSwRb7kVD7/Jx9LWolTv4uvRnb3McxsO5U2LSYvkgsOMe3BW2MYgbNfhUINo/uf7YCVMOOtXO2POw+1PbHX3k2+HZ+5MFUP2mSmoyUUM= 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 1772643194430133.3446585847404; Wed, 4 Mar 2026 08:53:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxpR4-0003tS-0A; Wed, 04 Mar 2026 11:50:58 -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 1vxpQz-0003qF-Lc for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:53 -0500 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vxpQx-0002Q0-MQ for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:53 -0500 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-65faaa8b807so3594670a12.3 for ; Wed, 04 Mar 2026 08:50:50 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-65fabd4695bsm5941315a12.12.2026.03.04.08.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:50:47 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 163DD6016A; Wed, 04 Mar 2026 16:50:44 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772643049; x=1773247849; 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=+kubWz9KDgycCqkZClTxhaq/ye7WarZSE8+MZWS4vpo=; b=iUSIXFMfE5ZLFMU3kTXxNmi5r2iO8obG/tHKwRIuI+O7Mp8W3LWDtdVIASe29O+I1T h4+RcPZgsX4aVUSkuDuC1s08ElqW9Wv7QsqjS4i8wlgZ5tBlf7vX6UqaNRzDQ5ThwnAc 6dLQzU4HHfSQwY+NzNgdd4XMBGs6Qrl28nE/t1wWIPORgGMYjF0uUG+KP/F/sYXKTSox 0AXMjmepL6K0S4XzLI6Zfqr/F8PmwXSs2VuJAGvMOk0wFFBtNPFq/YDP8CJ8bhzhRleb GGWsMfFGq40qFDMHdR/g4kH4JeeZJT7rT9GGRZv4gVagCg//r+3iw2hxjiUjLLr3SZdN reeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772643049; x=1773247849; 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=+kubWz9KDgycCqkZClTxhaq/ye7WarZSE8+MZWS4vpo=; b=GgpylXNGstZTAM0gzCrBitDZGcJnTYe0agc89H8pAzUoXJAn6fFD0VDm1jZZWBhEnG zEQ937BU8TPp8HddX4Bwzdwom1U78nVyNzFmIywjcBZjnlAzLTeUKHi88sSrPsLfAfKA 05T0x/u3OP8PIrCpqUjMr9Xpu64TqHl5S5amfq+teG921WfdUxfjE8gGOLJssJC18Rdw NnSFac0l6OLD6zdbG0oNDAvSSx0HIku6pNNxpagV8SIHfZHNE4BRvHKivI6fG95V6aed eQ92d895UyiN5c1FKmos4wBMmmxwGTFNLTmO7ELsmRP8lQTzNpKxuHqKO7Mooy0tJqCg KX3Q== X-Gm-Message-State: AOJu0YzZhzxSIsY0DpilqFyRXy80Bt38Yfm412/d7xIEmIhuOI/+R6jG K+NBmzBTzLrYhi7BGpWkzRR36Iy/zq7vXbkTDlv7vCnWL8uD5QJdXKQIvfMYNw4G4UA= X-Gm-Gg: ATEYQzymrz97nB64FDhDjC+8UEve0IBnhJUcmxp3zivv+hpEx5NWnbDx8rV1E3HaC4r IsAhEdrz6eiFX2fQo6S47FVWUrNMpu2sOg7xJPaQX8r1eXAs+ityboGvBcNslEUfLVR9C1fIboc 45PhA0ONQxQvgVAo/6nP8U49JGwZXwwwYfeKbZaEZib0gk6c2KGQ2EwId1b0FIFqSLT1cTbR7HM xNxXabBOX47lBApv16Fg+mmnojmN5GIiFXcbVmXEZQfJB398iJaNC070LSY6RWOVghQ2898zHKr AL5+Cbi4l2K42xATSM3BSOdCAJyCyD8PxGqzjkVjJbqCARHtzSfvSe7xDb35t+XCNILwuPE7dgk qlN2cunpKbg7H+mfOgcZNrYIeadbFctu1XU5YZT/6MgG3GMIORJoybIBiOWL9e8mXogyH2OUEFh WilfaB1Bjt4M9K7XiwikzPliw= X-Received: by 2002:a05:6402:27cd:b0:65f:8271:3f7a with SMTP id 4fb4d7f45d1cf-660efcac9e1mr1509478a12.16.1772643049273; Wed, 04 Mar 2026 08:50:49 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Blake , "Michael S. Tsirkin" , Dmitry Osipenko , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Pierre-Eric Pelloux-Prayer , Yiwei Zhang Subject: [PATCH 04/20] ui/sdl2: Don't disable scanout when display is refreshed Date: Wed, 4 Mar 2026 16:50:26 +0000 Message-ID: <20260304165043.1437519-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304165043.1437519-1-alex.bennee@linaro.org> References: <20260304165043.1437519-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::532; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x532.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: 1772643196709154100 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> --- ui/sdl2-gl.c | 1 - 1 file changed, 1 deletion(-) 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 Sat Apr 11 23:04:26 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=1772643079; cv=none; d=zohomail.com; s=zohoarc; b=bqhqTLIgDxTkDEKVBStXoz/rBdvdctIi0CqyXkKXKcpDj4k6SBusOsfATeVWpGT6ynQbEHG6NKOgWc6VUbbbO7eX5Vi85C0aQi9n2uobRPLCrxkqVyatQS9xAaDiw2soo+3LlYKqbmR2AZtyIP3KCuxm9mMxYvUAe8YTPa0QB48= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772643079; h=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=7fXH7Ub5GEQ4cWHh3k0llbn9h1K4aZuQosk7zKiteZE=; b=PSyXzu6g7NIYuztas2OESkd25wyB9Xos4NXDbICgE8laIfpvpykiD0j3rqxkrKxeRQkfsUaPs3+uxehwnEPIeCxAhZAmSYOsgOqC9giDc24BOfcYp/xyvBUXUoVIEGoYPUWPnaLI2uxIWmwvtZIk3Aolb5hNeoJ3aIEDkXu6/es= 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 1772643079611830.7009904983913; Wed, 4 Mar 2026 08:51:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxpR0-0003qw-SC; Wed, 04 Mar 2026 11:50:54 -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 1vxpQy-0003pt-KJ for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:52 -0500 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vxpQv-0002PZ-PS for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:52 -0500 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-b93698bb57aso545654766b.0 for ; Wed, 04 Mar 2026 08:50:49 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b935ae94441sm761499366b.50.2026.03.04.08.50.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:50:47 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 2FF2960BBE; Wed, 04 Mar 2026 16:50:44 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772643048; x=1773247848; 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=7fXH7Ub5GEQ4cWHh3k0llbn9h1K4aZuQosk7zKiteZE=; b=W0+g0GqBr8rOtdvAZuSaV95AdIJDwer5bK2LJmLUH/aYR56pVFHsdCggih7V8oDtN1 cTelGhekpTJL8YvPTZCfZLYZ8gp2dQcwwXTwlmhTT4K5DtR/yYoAj/Pl6CSfXGc3FPwy MyUakFEZlTnQifr3XcNGdRM0s12m+1cFqCaQ48GyaA86gnt9cUc2/eydYu6DPBX10DUS +7TT6TjSR4ljc4kP357NY1eV6QJpLl/XUcv+2HpTWj7miPkrg9yg71f+5IzJKGkQXEP+ 5zvhmnVWz63UAFzxalwfeX1DnPwpf9VvpXxtXyh8RIxLHTTHU/U4aEGxVvWzQQDJvXOb a2pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772643048; x=1773247848; 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=7fXH7Ub5GEQ4cWHh3k0llbn9h1K4aZuQosk7zKiteZE=; b=WGqB15urThePQQuqDNdruqIZFiidyXJohoGetF74rOZkUVhuv/IAY3CJDcqvp0GO0W HAMtcOe6xavNPHEEpa8cjjPA6u/n1QK2XZezeB096acRe66DaO67xp01TOtONfD4wAT6 WHjmG61oONgb7Ni+qRpA86ldppdMH0Zt0IE8vLTcMuWUUkg/nsTFEKm4cBpi92Za2Ewj 3mhQXx9ZeZVev7Sc4tYtdjfVrOGAaq1ezcYA9e7DSW/DghXC+vaEouJ6w99EzUhk/qgd HGgX2b/WIeUXnG8O8/bOYZB5Tqly2xGlKiqxhZjpujZd9oipDso69gqH31EYrNSblIhf 87yA== X-Gm-Message-State: AOJu0YyYw0e+nGK7twEA0b2T4A6dJKBQQTfk0yXjxENyA/hBIgrn4GS1 cxivS0mzCvQkAuic2Sz8aoWUcFTX0vjV3/fOy127xmSiNbhh3TlCeKfEkxHEfqjqxos= X-Gm-Gg: ATEYQzw47vnEWEWKgVyAHtbyhDnSW0UVdfMztLT1BTM2CdmuId/0ixya2M2KWaC0ePy 35ynpbmN/1WrY4RtiPY92yLZnvZXpunzMUeSzg87RTsCDkx3HQZcan+bCj8E8Is9xFUpeNlJi2p TnA5bF6x6qoSTtXwFphRmzzVVq4tKKaGaqjM7GUYIX+sri45xy/eGu8Qb+abXN8Sp4n5s7lQKIH DAtDn9ax9/Rc2kmYi0yRuACX+urKD1PFnJY00ZDzzUJ3gNz+VEL8jOSGwJw3hXNmnqKvYKT7dxH DQ2kZYQmNKhztycNSYGSUqrOPA66/DqGNmH4bcq6XVI4WDszsbT0E524oeyGUcUff0i1/hkPGh1 7KFdSesjq2u9zOWpL8Fck7rjyZq/4NF384B9bqm2j10EfzjT2nD9rmYI7E7P6Glg49/Jhy2bLyP pLl2iuyjqyf/oULVYKpiBe9rNKz1sC0Xy9rw== X-Received: by 2002:a17:907:c25:b0:b8f:dec3:6606 with SMTP id a640c23a62f3a-b93f01f5b0dmr182043266b.23.1772643047934; Wed, 04 Mar 2026 08:50:47 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Blake , "Michael S. Tsirkin" , Dmitry Osipenko , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 05/20] ui/egl: Don't change bound GL context when creating new context Date: Wed, 4 Mar 2026 16:50:27 +0000 Message-ID: <20260304165043.1437519-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304165043.1437519-1-alex.bennee@linaro.org> References: <20260304165043.1437519-1-alex.bennee@linaro.org> MIME-Version: 1.0 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::631; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x631.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: 1772643082549139100 Content-Type: text/plain; charset="utf-8" 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> --- include/ui/egl-context.h | 3 ++- ui/dbus.c | 4 +--- ui/egl-context.c | 6 +++--- ui/egl-headless.c | 4 +--- ui/gtk-egl.c | 4 +--- ui/spice-display.c | 4 +--- 6 files changed, 9 insertions(+), 16 deletions(-) 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 Sat Apr 11 23:04:26 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=1772643173; cv=none; d=zohomail.com; s=zohoarc; b=EkdgwHRje+82dm5HsjhkbDZDZoR8lSYEIitgc8fLiAwNmMSH4vn3HVKozbMarxGnUSlje2rZCk+7EN0OZZbvnxo9zCuByxNe6kxJ5qoDM/FFlwDVHZATlWjeIzlfM8CQZLaL3Y5Iah0lRonquQV4eqnucj/13oW8VQWU6XDdXV4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772643173; 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=t95kWQWOrKB4N4tylTfItpGqfNMJL0Byyr/GwBmoQ4E=; b=XDIgC36gTj3ZzBoZ4rjatK5HgHgSlTZtpYNol3HXtRnGoOJddFNB1aXeqUAycbeHkOhCIp+ZnH77NvG9VYJnSSXo1lnCL0wUlP4MCQWFp84QvbO5U/a/pxMI5YSEnjEaK0lDNEPXoXmQnELWQ6UVP0sUKjqzYELEGOOvJ1xR43c= 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 1772643173175572.0867795650472; Wed, 4 Mar 2026 08:52:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxpR4-0003tV-1J; Wed, 04 Mar 2026 11:50:58 -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 1vxpQz-0003qD-Im for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:53 -0500 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vxpQw-0002Pw-5z for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:53 -0500 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-65fb991d7eeso9568946a12.0 for ; Wed, 04 Mar 2026 08:50:49 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-660e793b7d4sm894036a12.7.2026.03.04.08.50.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:50:47 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 4443761EF4; Wed, 04 Mar 2026 16:50:44 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772643049; x=1773247849; 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=t95kWQWOrKB4N4tylTfItpGqfNMJL0Byyr/GwBmoQ4E=; b=kXMrmSnjZrNJHiqxY8y1+YQfJpwXLOkbzH1iXzY/QgQ2W7PkMqx1pdGLcyJgqyeRuV /tqYaT3aR2N4NlnG5pFo0uBqntXy0XH0JW20VAUsLcdGj1IzLPYa/vtATNb+2zNuIxAr jt5RnZ+Us3Vpq2/g2ZSj4qUDh49BHcWz+8kHy2uE/u06GVJWBML0p5XpLq8KRA6ll8Gc SZ8JQ3MdBDJf43XoErxd8ZwWNGwvkasRuV4lRVgD/tRSIGCEhyXZkK44amMPtqKh00C8 Y0jXzD2vzwOZWCyIhcFqQMVjBvsYpC5178PxyuusXaBaMf4inM7klfHRSOp5Z2xLdTe4 cKkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772643049; x=1773247849; 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=t95kWQWOrKB4N4tylTfItpGqfNMJL0Byyr/GwBmoQ4E=; b=CyN18voeyqhR+aayrClshZe+IPevVNjkSQ0oNGo3/Dkxu21oJ/6BF+gmoWRQmQFAsF uHSE8QNm5q88VSwpeCwft2cVACQkJrH1ErEV72TwKtz19ibIBGTfGTUtDQXKEQu//qTb pBGtKvdhvEnAhY5cuHOZEV8iwumoHQaxDXVNNP8HMZhjNH/G9U6+jaEy2XrzEY0ai0LD kx80oV1U4WrUlME71GskRDGaSnCIFjac2FXY9mnO2CgYeLQg0meYmM64tp4PyW9zSZHF C++w+SoDlKEYoI8k+JWQa0COCZ+Ffozd72CrfCFu8eOMxgzNBWHJY/Iw/7DBSG+tISDL sYqg== X-Gm-Message-State: AOJu0Yx/KRpo7v4BcAYph/JlUsL0qgUxHDIfgcmSuMpiWiMwPjBPtyHD J/5+k+jWSnWfnLGSwPVh6nZl8sBzeh5QZ5DAzHrhgJCfAjP/W7IkyIgE12ZVQG/m4Vo= X-Gm-Gg: ATEYQzz03IeszUbXgIm00wjfEKL868O2klbmQcH30A0KmIs3Q05Fdzz0kt0c8NiyfZT Qpk4cCHP6+JqOTZ6ePuke5THYe+zY0ZEvKbevvLUATjSg3da+5r5I/FVD9KfW2hDQ1g7NNYHvhX QyEqPFLzBsU7xMNWhz42LEMoFIXWE+c+loBr331Zg3nDChW5j29NbL5mwznb39+4G3IiQxOImZ3 mYD3cdTrRmjW3sChQjoT6Rhzh7e25fmtJKwkLmIDJqk2ZBRuJRTD0TIdyxvIumegh2lf+SMrsD4 jpRie46DARni8jM4Hjlo9qhHXFBOQdn/uas/QKgoURS25PeoNPz7FWSbcHBc7Rpj7qBMol9DBRf 8q4yiPijT7DfitptajAOjVKr9AZPrZYWTYcwE53qv5gJwerbLrUDP7dAKNWu2BwyZEQ1VSet3k9 w20E+Jbyg87/wHt4FUDN8FBdI= X-Received: by 2002:a05:6402:34c2:b0:660:dd8e:5382 with SMTP id 4fb4d7f45d1cf-660efa94b11mr1640523a12.13.1772643048745; Wed, 04 Mar 2026 08:50:48 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Blake , "Michael S. Tsirkin" , Dmitry Osipenko , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 06/20] ui/gdk: Restore original context after new context creation Date: Wed, 4 Mar 2026 16:50:28 +0000 Message-ID: <20260304165043.1437519-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304165043.1437519-1-alex.bennee@linaro.org> References: <20260304165043.1437519-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::534; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x534.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: 1772643174513154100 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> --- ui/gtk-gl-area.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 Sat Apr 11 23:04:26 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=1772643164; cv=none; d=zohomail.com; s=zohoarc; b=eCN1PSpuaKeiydqJZiCb0ucsXS1MLi6h5jMfeA8Dv+rxbW3rrazsoPEu/U07LCmss0T3Js3eyyRSp+a31FIw3AaJsOI92Lu1Mx0yZldOfhaYE6EuKqhINzblFNLAC8hMfN2NjgxcetuhGKKk6tCfe2IeO7dH27t5KJTF5jKreiY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772643164; 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=D9djD3xly+1+FURxga6yaG12+NYP55Xt+lHD4jM3mqc=; b=VtVLR95ggAp4zuSYB3+tekhHF9UyjSyd+6PbI93WtfPQ2i/nbDKubonB2xc3eLUc8GM9Dt1vvrndIt+xn49B1qYHvewJRh/eGAmthDe2COg15QteXbmpngrVWxO26kk0x15UmOA4MPREtRAf1IteAeKKK4SZ6uymrRtukXC6SPM= 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 1772643164486140.6999686750737; Wed, 4 Mar 2026 08:52:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxpR4-0003tk-J9; Wed, 04 Mar 2026 11:50:58 -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 1vxpQz-0003qE-LK for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:53 -0500 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vxpQx-0002Q7-Mf for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:53 -0500 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-b936331786dso760319266b.3 for ; Wed, 04 Mar 2026 08:50:51 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b93973d3ec4sm558567866b.66.2026.03.04.08.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:50:47 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 583F362A4C; Wed, 04 Mar 2026 16:50:44 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772643050; x=1773247850; 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=D9djD3xly+1+FURxga6yaG12+NYP55Xt+lHD4jM3mqc=; b=yz4KNom+8sohQRSuObEpuXY2BthQj8Pt3JC05exw4a+9U6x62lPxzorskvw+kBwmsw 4EDnL7s/9lkNDwMAiTM6WrmRLVNXmQKsRayjAsQRXNrg1snfnASyxWuaifyH26IuAY/0 FKKCAGOodpm0HGfOiU1rS0l973aXhVy2foaLvP42BoNUps3W5ne/kzl3V9xGRDL61Svi FaBipy90lH3vlUoL40A1kRhWUnkkwWyHD9I8BL+jhNBEeirCKfpg8UekzVLCPOiqZNud u3+nmEnQA2j3iPtrS5zy+qiNlweUkiT82CO/GeSr48xWcHjo7/LOMaNo50EUqv9is2CL /UOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772643050; x=1773247850; 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=D9djD3xly+1+FURxga6yaG12+NYP55Xt+lHD4jM3mqc=; b=Or5xlIEzZNBky9hNgWl+sLbW7V28TzKDJOGvUl+xPnT9Y6Yf2DA3t9N2h2/uLPVIw7 BBdyrqKT0x10nrTnNi2I5rJ4+dINoyT4kiRMdcWRT/IzKCa7r4BT1mHGzUfCLht67jyj JQ63mrXLUMv+mukv4ZaShQkdq/MeHW5EoJ7bxjJenlG68nZRmUrXQBpvetEPQp7YRJzD 0SUX6GZCA3Yy/HHN90JLwOG5Gh1IOJKQS9+6NgkbkZmy9lmXpg4R+6GajdpoiNDF/+sj uWVbD82R2GwqWcrTQDcWpNMjtedfCRdqH9zzy3QOwiaEzIALmwSZNqMr49NccOHZVNrI KNhg== X-Gm-Message-State: AOJu0Yx8waTti5niCw8oML4uCtSZCSkeQyotoYJ5ncwnvDzJBSvKdud/ XNDHDZYkqB+EEfVzZDVG0sL/88YORlkmM9C+BjcGwPTQJIQGfFe0zX9C9W1hblTYst0= X-Gm-Gg: ATEYQzxNOQ2ghEjgz68Ga3n2pwn7JUN6jBDZ6Q9vr6FjFOEqYpQVGTR2ReyVMbleg9p IoDvpMwKkNeMU2qN6q2gA9ezpS8i1gRCdlKIEdjXqVSCLy4r2+ozbEB84VEaQmcHpV5zS/+AKL2 kMVWLJtdYB6OTluITO1ig2jbKRsTdM5IvTXdHkr6GIovJgQsFto3fJk/oIh4UpV4I3DQTXGCpLN vQJr90CaYcyhqo3Lsbp+6r1Qh0xnuZiMHudovH8wUxCWn7/OJKE3P8njTDsQ9lC1UjTV1SuL1yQ DYFsVPkF0n065zoiFlUVXGCDhqdamPRjsBYQDx2r0r9Y7RQ3Yh+mY/DNVy5AfKmv8gNs8D8VqO1 HUBHcwv6Smc3Y3ziuJILSeP+S9e2TymW6jC1UBEf6l7uFkm5u6fjsrAe6ZbQeXhSWAZ5acnps3p T+ZH+Umrw04pqPNn4TzX7OCiLM0bW0Ut+CCw== X-Received: by 2002:a17:907:9618:b0:b86:e938:1b21 with SMTP id a640c23a62f3a-b93f11bb08cmr162709566b.23.1772643050133; Wed, 04 Mar 2026 08:50:50 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Blake , "Michael S. Tsirkin" , Dmitry Osipenko , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Pierre-Eric Pelloux-Prayer , Yiwei Zhang Subject: [PATCH 07/20] ui/sdl2: Restore original context after new context creation Date: Wed, 4 Mar 2026 16:50:29 +0000 Message-ID: <20260304165043.1437519-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304165043.1437519-1-alex.bennee@linaro.org> References: <20260304165043.1437519-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::632; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x632.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: 1772643166440154100 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> --- ui/sdl2-gl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 Sat Apr 11 23:04:26 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=1772643182; cv=none; d=zohomail.com; s=zohoarc; b=PXBurOlKhSyFqhdmNdlrN/fWhAvXz1nhlyRKEbx6wBI+SHH2KYP2uBhSn2M047hyxmBmEzH627l9p7o2n+LmtpDNRMiYUT2UG6jb1rwxFizg6Zd1/RJ2FPbXOE45zqcA175990qLhYoHX1/KTXu+dbkwQPCx24+ZAtsbE/mK+OI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772643182; 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=uh0+GWT4WV2YUnUP/cRvgkQG1ida/x+5HO1WSYG+bhc=; b=jkydxxQcQLIeOSmt4HsMgrW+5D+z177CUPhQ49MGgaDvfYsiXQEHt1atUZqZpBa9QxGx53AJwX0kvnZR2kaXRUx3o+X3YLIcxO3a8+JMxy/8Gb66Ae0ikXpfZqj8K0oP2xAw2RZcsstLALdUZFOG/eQPHEOOAXjouLILr82yG00= 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 1772643182912817.7190962319017; Wed, 4 Mar 2026 08:53:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxpR4-0003tg-Fl; Wed, 04 Mar 2026 11:50:58 -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 1vxpR0-0003qi-FO for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:54 -0500 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vxpQy-0002QD-DB for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:54 -0500 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-b8f9568e074so1277238766b.0 for ; Wed, 04 Mar 2026 08:50:51 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b935a597d02sm769665666b.0.2026.03.04.08.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:50:47 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 706B762D04; Wed, 04 Mar 2026 16:50:44 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772643051; x=1773247851; 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=uh0+GWT4WV2YUnUP/cRvgkQG1ida/x+5HO1WSYG+bhc=; b=aNu7JFFSMfPGGEaVBsVcdHIdaWdOyhwpRVihjwZ3DTj8T+xgOicP6oP/AxFdfoY8g0 ox4PJQtrrDkI724TUqMrI6IMgFp6TodY0nvnj2ZxF+VDA4pUPhr5pZLQtGKiL9NALz+U Yxaj8neRs8XrDTtYO5VtqEzS+yqrbaJKQSBULq7wImOzeWHwCI4LXH4onCDkczveADjv 5nyFUCc5d91pzRxpSonmoOYh1ovtrmYQeraIT7UxpMf6PAOuoYWwvpiT6rRkshjanQ4i 4GU9hr8No7FjRElOLMdG7Ko6ZYZdeKZgrCkK01xtjk6eIrHxV2AEOn7a0f3OZMKhgjMi 9BnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772643051; x=1773247851; 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=uh0+GWT4WV2YUnUP/cRvgkQG1ida/x+5HO1WSYG+bhc=; b=nOPzlMm92JOtrstHiMywOX1viJy32+gec8oaFjOL0dhNSMcLO8dTSbrazeDXdEsdtY Qr1PUE2H+wcVAI4VQISXBy0+bAPaJeHk0x08kGsy8HBQ4jzUyeLbH4ECO41WSFQZHui7 moSyEoIJXXtwAcv1/WRXchPIYJLLGJbeAh5QiJeDv99rJAa2IPOciJqLRRf9k+m/g6JE dDN12dCYQLL+gHBCsgwlH4pupeWaJ/Cbk2ES3Jt7acvR3AGwA/yp1rTwSxAZSMRJwFLn Nd6pMQpqmNmyOzQSyCHw4HGUewiwM+9nCRlhccf1IQDp/BVvKMZzlijcrJbe0VNXEnMx W0kQ== X-Gm-Message-State: AOJu0YyEkWvlV2+VvCLaqSU5TnhfSSiWdkDg6xPD03V1ziQWHzECFKjD uwx8n0MBFnXu6ijXJ6n2YmXucRrfSxPM07GEdZGnD2IM4yA4ZyACtmsGr/9ZWmGqhl0= X-Gm-Gg: ATEYQzzpNTZr4XhGbhiYyJymqlTDihVFrOVS685Zn6GH7TqtMPtOp8cKGLKEyNjBU1p LYbjtH5wS38vRTwnDlpRGwDu0E26ToocdWQHvsYg36uuEI/uzJx2RBI+rVoQXG4hVlNqXzTHGdh GHHW/UF9LmtQ2PAZR74QJKUgrh2WGiDvg5skhznfh6ABEukcGlIiSQLNHJV+cvqfxCfn9dfxa7t KMA12VV9suCca8PqVM+iZTrnzxHTHpFX17wN5GDcucH/IttA4nQeqMD9Uiy3cjbqVkRcFLdpeT7 l5jGVhYN9ff9Xisp2bsPFeoBh1wzOk1gfmkS4/u+meJVxR45oJi49lBhxPkOO0IHlvm0XE3AY84 Pz73ijnMil+vljRY7L7xsP0AIVEUNGOttKF0KoATIVCjXVoOB4E3n9+/ENerUvZPy/ufbaQYqeP mGymSbQdrC8fCeLplCm+6jDIg= X-Received: by 2002:a17:907:d28:b0:b8d:bf4d:7464 with SMTP id a640c23a62f3a-b93f14c9ee6mr150462466b.39.1772643050673; Wed, 04 Mar 2026 08:50:50 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Blake , "Michael S. Tsirkin" , Dmitry Osipenko , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierre-Eric Pelloux-Prayer , Akihiko Odaki , Yiwei Zhang Subject: [PATCH 08/20] ui/sdl2: Implement dpy dmabuf functions Date: Wed, 4 Mar 2026 16:50:30 +0000 Message-ID: <20260304165043.1437519-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304165043.1437519-1-alex.bennee@linaro.org> References: <20260304165043.1437519-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::62a; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62a.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: 1772643185149154100 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] Signed-off-by: Alex Benn=C3=A9e --- meson.build | 6 ++--- include/ui/sdl2.h | 7 +++++ ui/sdl2-gl.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++ ui/sdl2.c | 48 +++++++++++++++++++++++++++++++++ 4 files changed, 125 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index df841e12e24..e623f398be9 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 Sat Apr 11 23:04:26 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=1772643122; cv=none; d=zohomail.com; s=zohoarc; b=Zrq8SncQbYPdO4scI3p7XMfWXFtK3DnSQyhkE9XjVBQh4gN1Hl2bX427DSL8jBfUddzmdIxqzgklMqfiY2JRfIky8rvvm1ZogJnskHOFzdP7a6ZL9xPk5NtsQO3614k2uSkQtzyjgnzT8JDu704hxMSDkip55oVHJArntrey/3Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772643122; h=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=bJmoRqaZG5iu6xmMVKnJGNOL+RO6aLUM+Ssy8DYxWzU=; b=dkPcqBZFqu0WYNOIh15EB4anC0dXORUnm6DPlOc7O1aPSMTOmDgahi28TuqeqZRnrKG2Ji/wgGKiBMvWB/YeUj+YLD6zepcegrVjVas/GILZkreoUxtC/rubtegEmbkLn40X3xRD4fbDNBNqIJAAUvoceBTN7KiXu/TK3MwWRFM= 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 177264312279397.81356535872419; Wed, 4 Mar 2026 08:52:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxpR5-0003u5-CG; Wed, 04 Mar 2026 11: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 1vxpR3-0003tQ-QH for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:57 -0500 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vxpR1-0002Rj-CK for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:57 -0500 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-b9358bc9c50so766520766b.1 for ; Wed, 04 Mar 2026 08:50:54 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-660bf4d8249sm1678736a12.17.2026.03.04.08.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:50:51 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 88E2762D44; Wed, 04 Mar 2026 16:50:44 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772643054; x=1773247854; 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=bJmoRqaZG5iu6xmMVKnJGNOL+RO6aLUM+Ssy8DYxWzU=; b=AP4MfwUZXfb1HMHoERXNcYkf6oBGaXJFGHG7NrMpRHfLWWVRavP682JlHbQBsDJDtN bInCyQnhFtex+iO8MWN/vVXfHQt792QyNZ0qgWEdlGVi5Fg6rBp47LkmuYKG/NG4qBvU 2b01K3FChsvhuu+L4D9WIzIZe0/ZJeCLY+TlxttZZn8BdCEdnf2EUBvTEHUCMo6sk9BH en/NVNgRzA9dAcfpK+jqgXQkPyXB8bgKYBLeNlZkPcL/gt7a1AKeo7d9dqVFNdHL6/H9 TB6ASLYuOXuI5x8Pp2/15hk6gTa3WvO6sZywJBtRFG1Kg0uorGDp1d69TI0gINzqOAPJ WybA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772643054; x=1773247854; 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=bJmoRqaZG5iu6xmMVKnJGNOL+RO6aLUM+Ssy8DYxWzU=; b=NcAQQiLTSI5QuzHNth8RbaJg8GLvOaXwQvjmuCpdnYX5fhv5sgQ6oScOpSKgNt4YGP vY5fsoSUNzRo6Kv4NSMY3SR5SjY1exiEMNieRnaM1eSzMY4grj75jsUu/Os1qdxSpTe+ z4tiv5s4GiuKG/n0iOIakqM/JaPRN4soxgVIG22QJPbLdg6YOwfZrJKiw2w5TSpsUVFV KpcwXf6/A0Ug7/zdxwWdYEiJz+HaVZHnh0M8IJwcqHgfbJUvm3QCil2JekCrk3+VJVdk HixJvyWNHvirme8iBVmFzXRXYKC2QfLC+5jPIXq+cD1yg42TqSgHL6USQprVNwif8U0w 2thQ== X-Gm-Message-State: AOJu0YxgGlT9eDOh4oCdmCry5FmmU48YrAuJM/xhmYWtNtlRJ1jmm/NU 4/eIdEFEuSXnPGX1+vh+YgMYdXUzVNMZ8+4gTFwGTYjJkm/hPYwT0q9t2+A7BJ0LbL8= X-Gm-Gg: ATEYQzypQcMVGpyRLSjA/sOtShvkjsjBaiSVOd796WSRWhS0YeBCzYGgjSIu3Zd57mM dop7uueugZX3rdXhIS5UKz56bZdiV7m1AOnzPu/zm8rCShLFy5iV1Xy8+bojnE13qUoAxdU4/EG Kqcwt+/xrsSZSOYUFMWDBSFyEs5zc0CL+pASOukgoe5UEActpo5BXSM3neT+AYBQchGOCgOSLH4 KEtizkLTgD3fmRDWOSXGvLmgaZt2nhenH/LcgfF/6DRaJlazaT1oXUYZEVQiD5stl4e71xFC30L jcxoAKfm6iGMW0Oj4PiCeKcGWXlq+9N3xzFLZJqkj2l1F5Odjhznpq7K5EqEZsxvFVlm+lMglu4 pVqfaWmfbvHbYF4chOte8lSg8s8csvOmx1nFDQ3S7m9jFX1O+XinYuHBwa2TuxxbC+tnbqfza3d zDvUaX79llOTqJyYahswl2C+lR9ZAhugJ2Mw== X-Received: by 2002:a17:906:f59f:b0:b93:c5a9:a5e6 with SMTP id a640c23a62f3a-b93f116ab5cmr160716966b.2.1772643053564; Wed, 04 Mar 2026 08:50:53 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Blake , "Michael S. Tsirkin" , Dmitry Osipenko , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-stable@nongnu.org Subject: [PATCH 09/20] virtio-gpu: Ensure BHs are invoked only from main-loop thread Date: Wed, 4 Mar 2026 16:50:31 +0000 Message-ID: <20260304165043.1437519-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304165043.1437519-1-alex.bennee@linaro.org> References: <20260304165043.1437519-1-alex.bennee@linaro.org> MIME-Version: 1.0 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::636; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x636.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: 1772643124497158500 Content-Type: text/plain; charset="utf-8" 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> --- include/hw/virtio/virtio.h | 10 ++++++++++ hw/display/virtio-gpu-virgl.c | 6 +++--- hw/display/virtio-gpu.c | 6 +++--- hw/virtio/virtio.c | 10 ++++++++++ 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 9dd93cf965a..6fb823f241f 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -547,4 +547,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 e9d55329525..7c486833075 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 Sat Apr 11 23:04:26 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=1772643156; cv=none; d=zohomail.com; s=zohoarc; b=NQlbRBTG7DYoUv4yMtebFSC8+Jnf4LMU4m6T8n9qIDJWMTjk/qckYSAOSxg1eDz2QsTpVlYFy3Xngfp80Eiy6XeKExKKTNtlCLXJu4+OgID41Xd/22k9ntz7rkW1ow7p136MOeRcZjP5amF08XpsHCs1XqjZIolKn5tunoluOMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772643156; 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=yhaySwZ2sfnt3X/6sKY9hea4XoP3N+AuPAHONsS0p10=; b=R+XOyktmSWgY9P+Dp4VsEvGnANIugi0C88kRjF1j3WdbIaXPG+lp6JF8rTRBY7lt6QzXIN49wfnObRMJB6N0Qxjtbi2nZALP0Wg5JBY2I2zvAIHoKX72UIHBhkdkY8VoEm6ZE2wfaX7urxXIqcGF2PZS9kGBVbzXqkQK3eCg0HQ= 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 1772643156406425.97017752517604; Wed, 4 Mar 2026 08:52:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxpR3-0003t2-EV; Wed, 04 Mar 2026 11:50: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 1vxpR0-0003qu-P5 for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:54 -0500 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vxpQz-0002QX-8k for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:54 -0500 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-660ea6ceb5aso1280551a12.0 for ; Wed, 04 Mar 2026 08:50:52 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b935ac51431sm767064366b.17.2026.03.04.08.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:50:47 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 9CF6662D69; Wed, 04 Mar 2026 16:50:44 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772643051; x=1773247851; 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=yhaySwZ2sfnt3X/6sKY9hea4XoP3N+AuPAHONsS0p10=; b=El6jTeRtuI/CLNfSwCDZV2XkNk9Sy82plR842jZa99GSrp6S90jKwj+8HA+lBfU+H6 GciO15vWzyvCePRGK/2I2E/KEbip26jODnE9uy7zLfDxfLTC1ikaCvBoX9BtmLxcqA6p oPb8mGULho7XVlwu2Mq4EvRg9TY1dtD+wIzvR5tD9idWL404yFRCIMeXmECBu5gPnr7w VQIyuFqfD+O4vmoLW6eml7PuCgx+J3kk0f7Fj8J9CzqqZ4ufzhSWh+K8oTpjKFFqd++k xoHuvux9dyPqPegqfTnwvOref7ygAPsUzxxr+P/KwNyICaSyJl0rsjPzdhVPUuErQggD 2Kkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772643051; x=1773247851; 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=yhaySwZ2sfnt3X/6sKY9hea4XoP3N+AuPAHONsS0p10=; b=YLQIJHIWleNA69GL5YjBA/sIbpgq+kS/JbRkz/SKydYmKIyulqV7nVYpKiU/piPeL7 BcYVERX87AJ4OTbm0n2CbsoTK7YUs/wepscoNlWMVnGHjcKjSd4QvMgTth8GE0IQaK7r pOCBLbnGlOYzPhMGC2glSutXqBXxF6gbf++hUhSLDRMXNZsE3orNZxO3/rTSl3BGCF51 lwzMr4qVp/TNxTG8sNSWpb96OOkpUGlcIyU8QSdQyifGCoPXsxelQWjYbBNB36DzysFz 48xIADZSvlTadx591XIs4b4lkTipLSrssYIcrPD1Ry/nHwpBy7qeonbLmMJNeu/tRWf8 BhaQ== X-Gm-Message-State: AOJu0YzXcPGb/fPBpephAxVoIyxFsAGs6wxNqPcV2MB7l2jLhvjHTo5n 9Gv4PFScKuVhaQj3iCalMEs+9SmgCN2t0FI96bOMZIp9ZTDfVvALkVlcgblaxUatQFM= X-Gm-Gg: ATEYQzyz8rq6cpefkQv1glbcLCAPtWvfs/jywR/HDrFeogwZ28KeTVMsdghcvXE8hJl Zvmiqlwx0hCXG3HlmQ4xritwJ7N6x8GKIIEX0KlupsrBwo38nm7EhOwGsoVF6/aEmBvZ8lJtu9q jn7A4m6GsJ8Rr8pYsL3SPAoKqQsCNkOK19DQRCRaeaTNjO6QLpZIAiwnq08KZ3Lri792UF1lcWz BCvumsfZr+zeKLINIDFmXGINkHQzFZUIj2KKRclVEDPIMthoKTwOeP+q3WNhduGAeAHBFWBBl0Z j/w//8JvZcAaYtzbRbDoFvQTyED7M3I36iEHJZGD6DAxoJ8XbJZZkhfYYscLaFFUeIbDAgdCnSq vfH7K1H8QliuQarO2yBtG+0G31c3Aljo3/XfBJhAZdlpNUEWbmfSbuq3ZxEOk3RDq4L9gz00gMh 3firslJLxTuyaEng+yv5UwoFE= X-Received: by 2002:a17:906:c151:b0:b90:b959:4c72 with SMTP id a640c23a62f3a-b93ef735016mr183997766b.6.1772643051542; Wed, 04 Mar 2026 08:50:51 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Blake , "Michael S. Tsirkin" , Dmitry Osipenko , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Pierre-Eric Pelloux-Prayer , Yiwei Zhang Subject: [PATCH 10/20] virtio-gpu: Handle virgl fence creation errors Date: Wed, 4 Mar 2026 16:50:32 +0000 Message-ID: <20260304165043.1437519-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304165043.1437519-1-alex.bennee@linaro.org> References: <20260304165043.1437519-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::531; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x531.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: 1772643158371154100 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> --- hw/display/virtio-gpu-virgl.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) 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 Sat Apr 11 23:04:26 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=1772643127; cv=none; d=zohomail.com; s=zohoarc; b=dVVw2rsuRg6EYYfbhjF3h+c4B3MGVbsCqELqKrpYND+c4s3R5Y9/zcq0y9jguaaN5Ej1lLYYhFQ+qcrSO2ZBP4XxWTi8lhzkaJLK9u/5VcvBlwIW+XUpIx8LBDo3s7WqCstKt8IXP38zZHVb4NVXCsyiPvNaYe0lmooE14esqTs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772643127; 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=pAB/auB+/ZlG8yg4/ASl1ctvXg5k+xmktjm09EQeMvc=; b=YG88X/h4wiLLibtYzqkkq+DcivKmp+O+Wb2Ato/hwNxqKv4HUgxDUgTQIIM5KOF04SBnVsi7uAb9hlxTiRufEzo0gS7rNyL9TK8gjV+9iBIB3/WIBRg3sgCAKpYosGP3BZvJ7PckdEDgfSKaEgreotwUZDYpP5AeGz12KO98waY= 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 1772643126964696.9424796817743; Wed, 4 Mar 2026 08: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 1vxpR5-0003u4-4q; Wed, 04 Mar 2026 11: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 1vxpR2-0003sl-Uc for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:56 -0500 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vxpR0-0002RY-Nv for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:56 -0500 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-660fc3f30c1so1150707a12.1 for ; Wed, 04 Mar 2026 08:50:54 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-660f2cf4f81sm726768a12.2.2026.03.04.08.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:50:51 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B4CB662D6C; Wed, 04 Mar 2026 16:50:44 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772643053; x=1773247853; 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=pAB/auB+/ZlG8yg4/ASl1ctvXg5k+xmktjm09EQeMvc=; b=QgdBdAl/kkCfqz9auLPO6ShKsZ6Ghp9Iu2mBHksNGgdl+Lp8O++nYEuzr8NHTx+wVI s7qD9LuX2pm72Me05WYNRPmYNV+f53QXN192W1T9YN79G/KAv+WZ8p/ungJLyVVsrUrQ KhZ1PdMqKuoOq61MmDcReizfo8Gld0Oh0r9jzFuxSCFUUsIE9mUvkTlwUysi1x68ON+o 3yxNKXCYyB+oilEzFwo0o5b7nDuNvGkaKUNj/8dcm+kfnZKixlkJ8AKyNhVzNA1sitQE 2CfBOOjZAt+Mi/aOKL8cq6Qixfll/s37vlSOGxCg7AIsghrzb9MzEaV9SYTc2T1ZySkW bHSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772643053; x=1773247853; 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=pAB/auB+/ZlG8yg4/ASl1ctvXg5k+xmktjm09EQeMvc=; b=LD7sw9oX6UZVUPhnQIWfGET2ce12JcdQUuYaRVyCgYP5IVWxgo6X2eGUd6Fcyc8eb5 8mtYnI/oLU8oBSBnovcmm+8ZR2MGNwjlez6xkC9F1An3lhYkkqvbAFd3rvB6RvkZlmwT GeA6dcLj51LULXEN4JjBR6Ep+5QAzA4/iu5Fb591c+npOhH7t4BvDF14pjXbYaYTvXLe YqhVoHk342rqvYstk81aOFRLSlC/jqQzAPJ/w4LOIpgDwTXsQg86b+OFwEv6OMzDdz/C tgfy3EYON1fXcaj912SMY6uPBi+ayIOSUFjWzH9eait3ZFy2ugZBbpN8oH6L+jIe4RW3 Ogzw== X-Gm-Message-State: AOJu0Yz4Ycd4I2jluOVIPRkYWyyC3CfeJNfyXQRcPSj/E2fVS0qviFgE sOLRuRUb9giDNl55g+FPWOmyTXIjQkXE4uFpZ2w4hkdwlguh6O//pThfUZEH5L61llk= X-Gm-Gg: ATEYQzyS8uEEkXebQ2w5O8LdGe2pJSMExahJK34fMzn3obwFfnS+iiCOBjsRNgPCd91 hsRfL0I9Z06loLOgXXFmw75OZmvJqClA7xtpu93ptDcmEYN9jzvUEd5Emwh32b+cpWKH7mpjXx2 0gz6ncfYCnWufDJfs8op3tiZuB8c3fcmFDJLniCaPlPtGQtupSIgsaVLeII1wh/ad/iVKoOgj/Q eglzLWzzGGY+LWPji0qVZdOeaUr1rVxUSbUpQ9cLPwmMtGISkszHkqHl464iOykFtoIho4REBbH InTBquH76np/qrT3gf758CZFfdCQS2vcQNWVoTPQYkmgg2IG7tbkCHN/zitH3f5AoyQ/Nhwwmps BmZSGh/uEp0Hzl6uZaf+GdHBCkKkSUUADOkd39waG6X72CVzc42/vF6NPafGenHsv4hnro7DLSr 3MIgqBPb1l8gnP4uZVwC2Vpz8= X-Received: by 2002:a17:907:3ea5:b0:b93:3792:4b03 with SMTP id a640c23a62f3a-b93f1403760mr165938266b.32.1772643052806; Wed, 04 Mar 2026 08:50:52 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Blake , "Michael S. Tsirkin" , Dmitry Osipenko , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Pierre-Eric Pelloux-Prayer , Yiwei Zhang Subject: [PATCH 11/20] virtio-gpu: Support asynchronous fencing Date: Wed, 4 Mar 2026 16:50:33 +0000 Message-ID: <20260304165043.1437519-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304165043.1437519-1-alex.bennee@linaro.org> References: <20260304165043.1437519-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::536; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x536.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: 1772643130445154100 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> --- meson.build | 2 + include/hw/virtio/virtio-gpu.h | 11 +++ hw/display/virtio-gpu-gl.c | 5 ++ hw/display/virtio-gpu-virgl.c | 127 +++++++++++++++++++++++++++++++++ 4 files changed, 145 insertions(+) diff --git a/meson.build b/meson.build index e623f398be9..b51b4be2a55 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 Sat Apr 11 23:04:26 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=1772643115; cv=none; d=zohomail.com; s=zohoarc; b=D98tjBiTOuZu/NrShZFTbBZZ2usAu3goqNgsdk9+6C/m7CdcvnMcaml5rsQ3pTW62Ccdd7FrlyPfuOb0H8yGrFxlmTlPiHi7w0+X0L4g+aal43KMxR+rov0/tjAn93ZnFGRdqwVBSmOnnaP8g/0VX2udBW0tsb/S37T2rYPzGKg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772643115; 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=k7V5Ii6IobaiBeODB4/f9P2qABvi9G26OhS7yt+uN74=; b=JQbYjtPryBHLKT8Eqn3d4mzvjED14SlZ6+Bv7Lg2CHsAstyJgoOmQ7RGCsYie4T9DQtjC7WNAaB9iCjmSheJh2NVCf/79p5I7TavhnrSeqXamnwr48huAWuLPiR7iXRyZFlGCfX+u8GAWuA/tPlc9Tr7/T0QZiyHjsMMl5cXkTc= 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 1772643115100233.7252903733057; Wed, 4 Mar 2026 08:51:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxpR3-0003t1-Ey; Wed, 04 Mar 2026 11:50: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 1vxpR1-0003rt-Pi for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:55 -0500 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vxpQz-0002RA-SK for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:55 -0500 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-b8fbb24a9a9so1202538066b.0 for ; Wed, 04 Mar 2026 08:50:53 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b935aec3ea3sm769311366b.57.2026.03.04.08.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:50:51 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id CF98162D79; Wed, 04 Mar 2026 16:50:44 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772643052; x=1773247852; 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=k7V5Ii6IobaiBeODB4/f9P2qABvi9G26OhS7yt+uN74=; b=XeTdixb/ZtTWr3xZNszP2s02OheIgyv9LwL+G6TKwOagq+I7llLevKReA/SBlnMJ63 c8V+fqpNTp1XhciXt2inTElwiqvbAnsxkNtsIl0QfcjQ/rwsEOl5b3aEdyo7UZC6hZhL mrAKnuEPbFfQipXVHW3W9rH3eUOxi29HMTuCarOO7vLjLOE+B8s6PBJ/wvs3ZllIqnjr xJuzUuif5w91GJk9qq5CcQVh6G+G20C6GeU9fkdnqz9VNHUKi6TVFkJqRqBHT7c2CG4j pzYJWUqD3lzaVMMWDrd3SjEbywQvzZt4evpyxynJ+Z9i2jLZfjKFNfGYy1AwpXi48yO/ Wt1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772643052; x=1773247852; 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=k7V5Ii6IobaiBeODB4/f9P2qABvi9G26OhS7yt+uN74=; b=XLzCQeDUoJxGTHHnQDr5hjhbDGdvM+NJXW+/yiNskgnw5dYzVEY6heEbMTDXjjLrlf G6+5daxQhmY9UX5qAWswgV1SwrXEYMm3MmeiHXAXKMOAoGesKGQnJvYw2kuNjRfJUbhH gCRXIM8OemfyJoJVuPonhsUXU6tJliUXNQb94OKS87eC0+17uLoKUXgjLn6FAUWaI1hr E4gNo+R1daTY0JQF4Kw1NjyhvxunXYWQoEtxsYQeN/s7ZutNfN9pnidbfMJL+9G478IS G+Y7hSb562t0sr8PYjw3bpLpUt9jw3sO4aDqx0FezZBR8/H/U5SVl8U+xcH36FX0yvOR 3YtQ== X-Gm-Message-State: AOJu0YxHW0iXI1Oqk93bhww/o8gtw3Dfmq4jToe2CHrPAw3xlO9FbeaZ NhBGwKIP7hxxS5Tmfjjlpt8pLbeFcdd8MDH0BFPbdNLN/ni42tDO+MpSBsnz0wuzIbQ= X-Gm-Gg: ATEYQzxHJHmk4mQ9H452wYN61FyOtxGGseME698XGXdn/Z0+BPS7pRD4DyfuPsTOhWy dzlEI4XfitEi5HSTFRFMh0k3amtbtwWZBSmf0FRJ56ogo2RIcmBWwG2e5V+KTlXNHG3HWFYazZu H8rnk8hXYsJsthWUvvnqHsIZ/Saw0l0/0svXSE2FybABZCFabIdqVrJAG+PY0hlOGUkwE0//Lv8 E8nETZU5SIOfmJlpGJSmM1JqDHUQnPlr0DP14wy7vrSZQq4DQ3aTW02YdKT3GYnIosafpayHGPc 24UiOU4SrChJfTqGUaKdOE5oxUj59SgzxmKscx92WYP+yaVIVzW9ImJYu2e5OH+ku3aW9Jmdob5 rdh7rPDoitSTAw+WHwt6evw30IwHQHRzmoYWz8Bp8itavD0lldVNcSO0h8EatDVFZKLIcYMf4jI aQ6nX2UCwho+fhz8L7enSJ4kk= X-Received: by 2002:a17:907:3e11:b0:b93:61c7:4f09 with SMTP id a640c23a62f3a-b93effa5a4fmr155969866b.20.1772643052183; Wed, 04 Mar 2026 08:50:52 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Blake , "Michael S. Tsirkin" , Dmitry Osipenko , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Pierre-Eric Pelloux-Prayer , Yiwei Zhang Subject: [PATCH 12/20] virtio-gpu: Support DRM native context Date: Wed, 4 Mar 2026 16:50:34 +0000 Message-ID: <20260304165043.1437519-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304165043.1437519-1-alex.bennee@linaro.org> References: <20260304165043.1437519-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::62b; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62b.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: 1772643115719158500 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> --- docs/system/devices/virtio/virtio-gpu.rst | 11 +++++++++ include/hw/virtio/virtio-gpu.h | 3 +++ hw/display/virtio-gpu-gl.c | 2 ++ hw/display/virtio-gpu-virgl.c | 28 +++++++++++++++++++++++ hw/display/virtio-gpu.c | 15 ++++++++++++ 5 files changed, 59 insertions(+) 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 Sat Apr 11 23:04:26 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=1772643102; cv=none; d=zohomail.com; s=zohoarc; b=ki+wKUi4U0PnH/Ih6nm/acQlmDfOPnjxKDK4GurmklUhFnDqqB62u0vNq8xr/zNk1a8MP7sWpIL+HMk0++HV/CHcs2DPde9jAK2fjTaM6yhFonEBANC0FUgoKoprVQ8iStXe4hKx2ZhReckTy+JbgWwZWsw2shv2tQe4PwE+o2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772643102; h=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=EzHkTR4JqWnhH9thHwZCJ8/0KIT+iOpkuJdDWK3JNNc=; b=eoEzUtSAM+t5/CxlSY+zHoW5FovAI4TvoNB3j7blkO5HKUFwVFo9qMVTRBBjcieeO12BrUDg6aFnsaml8c9oB9t17XG7hUdHrTF2xkZY1friKHb5CkIoBkkrxypk0al6DPA8NzWnDlwixOB++nyvuVvizVPGwnjnQhLgTvUFotg= 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 17726431027121022.9301295535272; Wed, 4 Mar 2026 08:51:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxpR9-0003xS-1S; Wed, 04 Mar 2026 11:51:03 -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 1vxpR7-0003wX-Jz for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:51:01 -0500 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vxpR3-0002SI-7f for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:51:01 -0500 Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-6611d20c026so876955a12.1 for ; Wed, 04 Mar 2026 08:50:56 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-65fabf6d113sm5470817a12.19.2026.03.04.08.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:50:51 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id E384E62D8C; Wed, 04 Mar 2026 16:50:44 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772643055; x=1773247855; 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=EzHkTR4JqWnhH9thHwZCJ8/0KIT+iOpkuJdDWK3JNNc=; b=DEcdXsp+r6NcAaFG26wCRyzBNbM1mvRwRjz5dmer0bdjQksHtivdNclMOtNNl9fXRH mRZGThM0bodRPmAaZn3vVOUj6RJDhooj3+yQHAraxMm9kyVdzOxmzCcyUKUIV7LSO5cR cj6/Z8Kkrl4RMxnM/TBmHiNyBi8qpNYHZqP4CURtwBtOewnfk3NcDRP94brG/hp/ZrzR Z0Kvy1VsEfT79hKB/z0FYmStrxg3c3nYGxHnjW4tg/uIAxV8G3zuCWslgDS+peXWEUyK 1uVqzY7X0rpKKZx2R61p+95w3qvBEBb3vrdMKrP9UjpT5aHVvb2OPUzgZOXePpu6+Dhu bV+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772643055; x=1773247855; 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=EzHkTR4JqWnhH9thHwZCJ8/0KIT+iOpkuJdDWK3JNNc=; b=fB2d29TO3cga7F4widJTOVCzqcJXl9tRgMRWtbAwPu9g+73e022zOVfgNqALa0T84K yBQrrieecxMqgEUIyXmUoU7zRuoUG87kCMtkvXYCj8LruYHspdw4dMHpx32mVbN218j6 M0/eTy73p+RqosMVdqHysJICowhfCAiWTKvs3cvOS9a+2i+kb0leV+Zk2PJP5YLR1rE/ 7K1slxPJM50E5AbbSFbvoXcSEvt9VIKrOLPAGREt4Z0tY5VpVG0nPrrffmIfeSn7ojnD bTAzrkS3qh7zG1Cxh+tP7Wfv4HI5JMLziXHlWW4bHUpxmvhXFaqt/TH5ZFXBw9IHOYpr kJsQ== X-Gm-Message-State: AOJu0YzS5udPBku2C0pmgDLPOTp2GRtnMePCRKxpM5fQW2ObaOeFen8X Rq3kAqXslwwaKPNOZcYLt5LGfFms7gQi9xSqKhCgmVBZKQssdWl9acD6vYxYWY/0+rQ= X-Gm-Gg: ATEYQzyoZm6EV5+4uhbFqLtv7euctlHCsI3T2v5PwBdDXwlgn70lzko9E9sYYHXQJeV L6sJ8pC9CyX+0wMycY6pSQkEjWtbH7tM6JCzRXmtquwDwZZ6GNLB0oK4nrjezPk8QTdSzYranyc exAHE0vDHC4Ya9GWewVMsAvdXdp/ev+hXiD98UPfgwUdaRq01akMZyY6WJ5FQBT9hKcyjLjMLiK Aju7winJnDbIiziMYrpuT0aM+lO+Ih69mYLj7n6NQygYIRHSUYi/RfW07YlpDHJn63NrJjW5mUw cLHZjaSRmv6J8XrCUDNxRiudOCumJGtp4m6ci3ct7C7ORhRIJ5AeIuT2UUH6N+fBZLjiS11RXaE 8HCia+jAYv8gGIZMdlGn4J1rPVnQkHK3I0JCMJYIxrZSkGmJHKm5qRFO6AL9moBWtJCJp09L+1D N8hCEXAadx667BRHw1UVYfXmUSZNga/StwbQ== X-Received: by 2002:a05:6402:4403:b0:649:cec1:6cf1 with SMTP id 4fb4d7f45d1cf-660eef457a9mr1609764a12.0.1772643055531; Wed, 04 Mar 2026 08:50:55 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Blake , "Michael S. Tsirkin" , Dmitry Osipenko , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Pierre-Eric Pelloux-Prayer , Yiwei Zhang Subject: [PATCH 13/20] docs/system: virtio-gpu: Add link to Mesa VirGL doc Date: Wed, 4 Mar 2026 16:50:35 +0000 Message-ID: <20260304165043.1437519-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304165043.1437519-1-alex.bennee@linaro.org> References: <20260304165043.1437519-1-alex.bennee@linaro.org> MIME-Version: 1.0 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::52f; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52f.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: 1772643132780158500 Content-Type: text/plain; charset="utf-8" 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> --- docs/system/devices/virtio/virtio-gpu.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 Sat Apr 11 23:04:26 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=1772643094; cv=none; d=zohomail.com; s=zohoarc; b=UbwuiyuGV3Tr0EeCmixsjQxf2CkXN9H/LNTBx7X1+3Xi/B4+CqKw129cmRmwG/NPbcDW/OsE5y+iDp3Fp+5w2O4Yj7U/vVLWYtgfmNDw2LunCXXSzLrP3FQWXieN0QclQwibfbbm1AOZVwXO42tcivDGpX3m2nvDg82BNj7QO9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772643094; h=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=rD8sfDTiye3PlqSCB8qDZy6AtX8/oF36wNt1WbZ4BO0=; b=H33HGXKm1iHJGS7PvnnQSwmMa2E42MB0hKGm8LMRiCwxeTddMGpKuzPstBtbutI4s2/WPMOcYOD8wTVVAIJGwFYZOKLjcvmuUFGsWEK/k0Aqw0d4p456v53fYIK0P7dw/CqfcsHO8QTOr9JPub4Z2x2INVjMVcCJTQU+yrVy2Sc= 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 1772643094542512.150958045291; Wed, 4 Mar 2026 08:51:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxpR9-0003xU-KF; Wed, 04 Mar 2026 11:51:03 -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 1vxpR7-0003wk-VA for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:51:01 -0500 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vxpR2-0002Ry-53 for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:51:01 -0500 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-6610bd5f322so1127533a12.1 for ; Wed, 04 Mar 2026 08:50:55 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b935ac51843sm791234466b.16.2026.03.04.08.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:50:51 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 0477762D92; Wed, 04 Mar 2026 16:50:45 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772643054; x=1773247854; 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=rD8sfDTiye3PlqSCB8qDZy6AtX8/oF36wNt1WbZ4BO0=; b=nUcp8nWEcwK2ONA8EK+rYXvTzRdUQ6SgGvrEfu4dxBnwW73F1H38HkAhhrmihMlfDg ixlTwlNLNBWoojXGYwHDSI12U5bAJOTioEHtL+biThT5zXTV6ZxR5wXLRF1stFBGQUBd Y/lbHjOYaOi9vFjvjwg80xZfud5ymVQLbwLZJVIUHXlsCW8UXyr6QYcPIYGpYDisFx17 JyjBdRnnCWClYRFCG2pZwySsuSESPoJ1OVmjLjQcOAdWt5WtWm1hrtXjiYZQwnGTaOyq GbzHAvFPtsYPdKjdlbJciE7AvuqSJxHz31uM9bRThUwIAm4IprLBmj0LJUVRMVF+NdfF gHaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772643054; x=1773247854; 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=rD8sfDTiye3PlqSCB8qDZy6AtX8/oF36wNt1WbZ4BO0=; b=ulvrR6xfBpKklvljS2G/SbPwv+4/V2bCu6Uzor/KRR8zXe2BBi8dHes0sWX5qZ3dnW 5V6Kse8lvzW4RE9m90oWEfbKXE4RHjs2ixYNb0JlwDMQAJFNJks0NdhITFy6JSiDsR7C 6R9lOoqSWIKo8qtN7jMcQn5vrVkBGXr4pLUBJ0qvTaxpgpjWPKEMDXChGNQPTt4TOe+3 HezjEikuBbX+wVvaHn8HoBcI+PT3QNj0EwSWdPqLgzs6uzQkpKrJH1SuSp8GrSKWrKHn ObIKVY7hU/YtBYfanY2CY7VmKwVPybk6t9icxLOQsWXpXdyI892skHuQwQ/ueehkOas5 gXRA== X-Gm-Message-State: AOJu0YwDEi5vql4aODPb38G43XQmdd+iy92EPiolAvGzmhfZiUpL40J9 gm7oUzwcvR3izHSawp3r1Vs78WzIorbA0Qjj6gAcyM8U4BbPMRD9y7e8ZNk1eKCczq8= X-Gm-Gg: ATEYQzwXTeVe3HivesnHrP7ZG24zsPp/KJowVn5arjcRf/qO8s8J8gfrz3dBZbxVAYy DMP3nBUDmbTdM5A60+dB/AEO3bB9uKZ0OuKG/w7+RL4U6WrdpMEdQr+dzI2LAHCQPFxqsyWfnIp kWOpGamJ/qhApImrXkcPXfqKR2rH1sdEpfMa0pwvPYbq2eJCT5e/l+FurSn7rdRROA+i5u5qssQ wuyaQZWfG+RGUsFfao+Iv+8XVeqQaeOhBbD5zpRrWL+QZDuAEs+gUcwBEfOBKQIjsypYaAzRdt0 2w3g2+ovyWjwk4bGkCn2fgrWZFh06aMujvP4KYLukmPOI8zEtMQ3BCqvuPM4m85DVirfWuWkvCD A9T8f3/ry2EPUwSXCp9yIdEpax4DL1Roxv9qlYTlOwyrfa59PszNw5lOu9utU5Oo1Rj1USbNo2b ZIgHCC76m4DrhVa2QcrTp8vLm6FHpCCh3RKg== X-Received: by 2002:a17:906:ef0a:b0:b90:6a9b:a6cb with SMTP id a640c23a62f3a-b93f1405d9bmr142983866b.30.1772643054147; Wed, 04 Mar 2026 08:50:54 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Blake , "Michael S. Tsirkin" , Dmitry Osipenko , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Pierre-Eric Pelloux-Prayer , Yiwei Zhang Subject: [PATCH 14/20] docs/system: virtio-gpu: Update Venus link Date: Wed, 4 Mar 2026 16:50:36 +0000 Message-ID: <20260304165043.1437519-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304165043.1437519-1-alex.bennee@linaro.org> References: <20260304165043.1437519-1-alex.bennee@linaro.org> MIME-Version: 1.0 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::529; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x529.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: 1772643095986158500 Content-Type: text/plain; charset="utf-8" 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> --- docs/system/devices/virtio/virtio-gpu.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 Sat Apr 11 23:04:26 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=1772643448; cv=none; d=zohomail.com; s=zohoarc; b=PVWDb4Wx0JxfKizOJeNCQqIefJb9v7F4KNBz+WxaqMmMsDn53eGM9mvxWAuVWGQhp5WXURz+DC8fSnIOsJtme/b6xVY9h+1zcAEeMbsQsaW4wbpwF1jGUVUHbKu45QQLeDcEkWARah5N9BfNrsoQhTc6HPukXa+Uy1bbcfE2+8I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772643448; 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=oL+UTh6dS7cRr9RVX23hKu8PkaeJg5kdlCXSgZk5kTo=; b=I8mkzntMaASJykjPg1w9+4whwwobabQ+zbJQcnKcpSiqlr47RP9u7AO2bXrsTxzkQ4UsM6BA94VHhDHVlxjyzAkh2lTyyPbHazSy0y5W59HlhvXzW6UtIK2GprbAATf1WZ+Fmc2NGd1d5g/UdJqS17Ie/QaDDXJTaUDEcnq9F9I= 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 1772643448954143.3370593167922; Wed, 4 Mar 2026 08:57:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxpX6-00074v-1u; Wed, 04 Mar 2026 11:57:12 -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 1vxpX5-00074W-0m for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:57:11 -0500 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vxpX1-0003xe-9C for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:57:10 -0500 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-b8f8d80faebso1202431266b.1 for ; Wed, 04 Mar 2026 08:57:03 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b935ac75fd9sm764415366b.28.2026.03.04.08.57.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:57:00 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 1B14662D97; Wed, 04 Mar 2026 16:50:45 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772643422; x=1773248222; 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=oL+UTh6dS7cRr9RVX23hKu8PkaeJg5kdlCXSgZk5kTo=; b=CyJKSgmIPtHCGUmdVQGPJ5TccyNHYA5k6xwzmo1mMBIYgTil1mKJtXgLX8C2y2C2dE MnExM43uM761UsQRayvBjTNXePzFysnxCc8vRitDn09CWkd2pH/DQ9X5MyVtce1158FN UM7ojQp398LNBA8onqF89M51xk3nTn44Z7rjxBGRAJ4PUsNK7yCjcGVyw2B12Uuk9UQ9 5kZwday+fH+WmJkfIUCQvYn2HsNdFRPeXhxnt7Innzq32QhJL3rr95rPTcaCNYVpp/xW T2jOtY5kYvhGuyFfi3Kwe7qhsqYnVghhoBcXQl12Q+j5ugFX+fAO++5OBMfsLuvww/nh Z0vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772643422; x=1773248222; 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=oL+UTh6dS7cRr9RVX23hKu8PkaeJg5kdlCXSgZk5kTo=; b=l5AIyKi7IagwWr2NurIazLekjdbTb5wvyiUsRnjGKeV6WaTg9korUxQq3CbBrsy87j Pov56sJt/UYNg1oPNF+TCp1X0JIO5Ul46oGKU0Hfgr6bBUqXzt16nbYVvK0H55OuajTX 7Df0UPKKaAqmR/VzzGxbeTaA4r7HtaKfYe5aJry8jN+C1AF3jxCTZw99jDVm9AvpbVLi jjSYxdkUwhX6fhKkiw4XpM6+hqH2kqmAnKEUe3DR3dcuucfiCv/OffVtquJAQzV2uqo0 Xtd5/PdNDLlcHtmB0HP3oNbZ2aoh7QIlooQ8laZjQD8cgtgnVuEB0SKWiQoAQE7GSXru 3PJg== X-Gm-Message-State: AOJu0YwDgr6VhlhJg691z7IcMi1KFMQ4S0jGh2i3446Gbch/oYH95A9/ rn2tXzqvuSiSP3S/jGkuGZ+8hUI+IPPBBLEzCK8Kmz7E/bVMSvBTE+lMWT/iNitRtc8= X-Gm-Gg: ATEYQzw66ezsMz9pZtxGuPMK+zaG6pFDAk9iKPE3hu0jAaZK9YHsU76qJeGegxB0je6 jyeJxOZKk38tkaBjhwg6PkePblqtn8FE1D+alXDoGFrVaKWg3ppoGByGC7lLaMrOFqV6XS6jOja QYmfpEUlmuITgIpxKyuQkBVl86Q9KZPHa91hgRwOUuKQJfIDTT9PjoZjm4+fnOOEl0Cm8ppqBD5 KqfMjmkXc1ib+rLn0dLPcSpB8QuXNoyCP5nvgudcDeZdo7ZtroKuqSJ5ESASJ2NlAxyL1ezn1+W yFhkyJi8MTIR/HpHnkRN23opxEIgsYwyQJ7+/6Pq4LVSfgxPdGggQ5hXsystQxDQfDxxWZotyG3 PbSoHPRTQ0ByAta3QvQ8AFKB7jWuNR+7pMA7AQ76vNRzL5hHZUOPBOYR6getC849A0uPLAUJt4B NHByQi3u7FKvsiWiy8K0zJ7nI= X-Received: by 2002:a17:907:2d1e:b0:b8f:6f94:a618 with SMTP id a640c23a62f3a-b93eff2e630mr179090366b.17.1772643421471; Wed, 04 Mar 2026 08:57:01 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Blake , "Michael S. Tsirkin" , Dmitry Osipenko , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Sergio Lopez Pascual , Akihiko Odaki , Pierre-Eric Pelloux-Prayer , Yiwei Zhang Subject: [PATCH 15/20] docs/system: virtio-gpu: Document host/guest requirements Date: Wed, 4 Mar 2026 16:50:37 +0000 Message-ID: <20260304165043.1437519-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304165043.1437519-1-alex.bennee@linaro.org> References: <20260304165043.1437519-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::62d; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62d.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: 1772643450643154100 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> Signed-off-by: Alex Benn=C3=A9e --- docs/system/devices/virtio/virtio-gpu.rst | 105 +++++++++++++++++++++- 1 file changed, 102 insertions(+), 3 deletions(-) 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 Sat Apr 11 23:04:26 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=1772643139; cv=none; d=zohomail.com; s=zohoarc; b=VfZ/OFOgNNTgLeQcS2UvgyxFelaKwIVEsnv+4Bt4Xl1BgHGxTCv4n7PG/P+Jtwxuo4h3AURA5kTArGwtYCfOdHOPpC6+Qc+b5fkNmk88WLd6WoCyAaQRkkFcyEagEW7Y85FUv1BEAt1+HxCaL6R2Mp5UMwZCHG2aT5FkwYhFlhk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772643139; 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=FVqtGVIEK9vja40Xgli2/kgvV58XTVhVk4cWJgJ+jnE=; b=cV9yzfwgTfldPhLzYnask6vc8RfQb1WzEUVwS+LRw7uOcOQnxo5OlHmvxk9a+NUmqCLPBZmSDRSSiXkf3yzDObcFZ9b//iXmKD3YHupaYUPX49g/KTKHl4QngcwEwAEJDDwQ6OwACpqt6QJCq+ApDObLxW5UCs7dTmVLT+SybSA= 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 1772643139237761.0955393497247; Wed, 4 Mar 2026 08: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 1vxpR8-0003wn-47; Wed, 04 Mar 2026 11: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 1vxpR4-0003td-BS for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:58 -0500 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vxpR2-0002SB-Pa for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:58 -0500 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-6610bd5f322so1127564a12.1 for ; Wed, 04 Mar 2026 08:50:56 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b93973d3ec4sm558572266b.66.2026.03.04.08.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:50:51 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 2E94062D9A; Wed, 04 Mar 2026 16:50:45 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772643055; x=1773247855; 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=FVqtGVIEK9vja40Xgli2/kgvV58XTVhVk4cWJgJ+jnE=; b=poWnQjkrisD6UEb/MpEdwx6pJoXyEngXursLg21i/epan3J9/kQMY1oXmDlIbiOVuY Cmg6h9kFtrMmd8EEUxgK/AA6oPbCt27lUZXc1VNJ72GVTpbAPmcN1ewzdEPypMv1qm4y 497STNdZUAVG8tmYqD3qIvFM3xEIJLqJqLNtd1tiw0lsqVP7CRN5FBN5snRP0Tgj8VPP Ftj6d2myjU4gzxZ6KJccvkoWsKov66R9KDQBVmniYIK8O4Q292Eq+JuIYk462Ca4vwap +AIIKySH+mP+axwjigU3mDw+y3+SOSxGa4HOCGwaPzUFD/Cm/KEt7CzFxpSJ+5henrVJ wycQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772643055; x=1773247855; 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=FVqtGVIEK9vja40Xgli2/kgvV58XTVhVk4cWJgJ+jnE=; b=jIxd57TxoCz98xy5/ocjE6u2jMznD45H91n4xdWQUHcQEuMvoFXohqxZI9b9KYRJlY /0BzIFnXX3OXEpXV5xCyqUZByyHGiA2E5qNZhLlQfpSACCLurQKP2LcM1mvfioOsmgp1 4FUH81OcjVaVbAiyWS3fNGM512a/CXCGrN3y7DWFxiM1zEO+otVCMg3Zx8VpqnB4e+Fc B/YgXtnk1vczq2Fwffgu+zqZzPH68fcJaUGMFRQ0PyTJAcMYWbJYPm6RtJ+DTkJKUPTR NxK8kPKeWW7noMyru31aQz8BQa4IV+yqpoJapRUFh65bzmsxGWLPV3Zzl8aRGqfh/9T+ s1Rw== X-Gm-Message-State: AOJu0Yy2fE0samuAxU7/ismBG4ziAZtCN7Ez9eeomydkrBiWUY2/Bwgf 307/YXWkCa7AYZ8OCT3i1AfDRtJqzJCLRmtM+Bc04ilkMuvA7h7xbh9xu9uCqykOjS77oopVgdp K+8G8 X-Gm-Gg: ATEYQzzFpwo1GD60viaVxV8aVXDXFIEak+O5PRfE9kfLZYQNaaSvcU1OFY0jR1x2GY/ wcoREQ2tMajnIXquB/tUbp0FXtsV5+AH22z+JClqxBjpXqc0SxHobjNurAFgfkD3WIr5F6uwjGH ynArH9wDlpUxETvI8qDdhaZ8f/f/9aNl/2bkPN8GnoeAJltyQJ+7wYglfb3nZSVkG1IwLj8lbsF Dd17bZ27i8mja+j2daXdS5XkT+ac4ivJXbLgLVfTukOVcPbAQ+2ZjBxMpPaFLk0+SXeyBOYObse lL1c3K7k8oEYQ6DPr1k64rHosidLK/u4WAxOJHeIRv+JGXOB+2w43KQaUkzdEQtB0z4C7+X6r/c KOW83dPMKqiduUGnwBqPvaR7AMK4AnT09ZCsjsDFTwTDsZTCv9pv/8Wpv5YJhYe4z1yyeZFRitH bvTooSd1x2k1mVI6n/Oc09gEU= X-Received: by 2002:a17:906:6a1a:b0:b8f:bb98:b8f6 with SMTP id a640c23a62f3a-b93f11c5ad3mr167593166b.19.1772643054950; Wed, 04 Mar 2026 08:50:54 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Blake , "Michael S. Tsirkin" , Dmitry Osipenko , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 16/20] virtio-gpu: Remove superfluous memory_region_set_enabled() Date: Wed, 4 Mar 2026 16:50:38 +0000 Message-ID: <20260304165043.1437519-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304165043.1437519-1-alex.bennee@linaro.org> References: <20260304165043.1437519-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::532; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x532.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: 1772643140411154100 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> --- hw/display/virtio-gpu-virgl.c | 2 -- 1 file changed, 2 deletions(-) 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 Sat Apr 11 23:04:26 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=1772643466; cv=none; d=zohomail.com; s=zohoarc; b=SSWmITdiZHjwdVS84+SE0zK/v9IfuPjK4666QGLxhd4LAtutGRxirL6nfTTlFZT1EL74ETceVnXiY0AJbO2IQ60tQgHYRTBTH/Yc/j/Lzw0OyVkkk4Ky8VBNECxPG/AIiCd5CLxUOQbWy2PTChYpaWF8ptQgKVYs2dca+HIeQJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772643466; h=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=dZE+DbnvVFmXd+2ruIxq3RTojaKZzSNmRAGkBSCjGF0=; b=gByJzZL0O8Db8F3hB44OMnguAEmmABMhfbk4fuUvHnuwWDdIG0gh2jq+to5mvA1Dn6bPQpOVV4/DM/VLnJ40Q7YThk4ACZL3obwo1Oa2noX5DbtXgruVysQ9PMiUchCu8BoAlVIJFNLQyyUCcOc2UYLyFUSsVDM2d59bEvHYRDc= 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 1772643466573528.3955557188474; Wed, 4 Mar 2026 08:57:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxpX5-00074j-Jm; Wed, 04 Mar 2026 11:57:11 -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 1vxpX4-000737-EM for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:57:10 -0500 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vxpX1-0003xn-8N for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:57:10 -0500 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-65f980cea07so10544936a12.0 for ; Wed, 04 Mar 2026 08:57:03 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-660ce1727d2sm1469813a12.27.2026.03.04.08.57.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:57:00 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 41A815F832; Wed, 04 Mar 2026 16:50:45 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772643422; x=1773248222; 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=dZE+DbnvVFmXd+2ruIxq3RTojaKZzSNmRAGkBSCjGF0=; b=aUa524PBYhCMQ1J9QDFCf2JMklSgmUr9dsnxXRboGwTSIejjtyT0iSqwuHAYDbTVeu nF+J98zRxZhYKDHCytJgTxdorJ4d4Ee42jPwAkAdmEWtBkKtY1NQauuKc3rjefkdsHIO wYPquJuI5bGoNzXaeMk75Ne/bl6jjIqM5G/NzjGDyvV80bGgh1tc274QSrIyEfvN8nVO d+UUVU8mgDNMoy8oKEywdEeGjmWNBhsMfDEkQb13EOWSPwsRHvKDxF/3pJwzZfi/pPN1 dt1iKlcTeABgh+6vZN0QFHhtbwOIKPTMEVFCdymxXwzniHmMs498wqlcGLexY+QUmXtw hSBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772643422; x=1773248222; 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=dZE+DbnvVFmXd+2ruIxq3RTojaKZzSNmRAGkBSCjGF0=; b=Jia5bLsrDEpQqfNZvU2gD3sZs/JZFMNbQmG8fKGUg6okfYCQC/oBtEF/WVlu8jrbFa JI89hjL+hwl7afLD1q8nyampTRf8wL4/bOrfjpIhkzc6bvlNZR1HY2ehTlBu497BIrIE xEzp7rfkEkd01shkHzBZO+O+Ggv7Agl4UmJMsdoVkv3eZ+Ia2ZrThUoOWvhzNOW9IdPx UhO/m4falzBLomba8j7Xnrc49xvhuBl7PnSKcSWXDKT0ZNt+AmAKwThHBfXx3UtwY1qs 8QLjVDdTIiwLq20vR0W5rOEQcs1kaa9DqeBn/RXVieJ4px7mov4S5Yt9d/fN7wdME6cy eALg== X-Gm-Message-State: AOJu0YxKA66OscSRw7sXnAiWfHXxyeNuvBehNPPVE9r3Q3KJja5MOehG vZGP1MQD6jCLTUxJVhqynH6Oujk8nsclMwYY/sFyE8eWBiBABIosocAw7CoKTUHF26E= X-Gm-Gg: ATEYQzxSqApEHVUZhxkiD2o17m7s11/f9W3MGmbaA+7GadgPoCkfHQNwQDr6/hpB+Oh ljJ7p1wDxS2F8cwc5PwRGzc0B/xB9zQQglIRWPCTlWudT/3Nxf5VRuuU5P/TlK37pPWUyyJVCFE HIu2X6QNtfvXq9yehjMP3M/l3B7SsxK/2ziLxboX5yXbQyC62wRCbkx8FnCETWCPAzN/a1xhhOb v5BxxVgXTF4s12wPFbkKy18nQ+Q9jBMTHTkAgIwKM0A6QNrxTNJhMEAGecRoBB9lXnyyK5WGDgU VuWwX5zYBmBCHfSdxhcL3gvU3/Iuy95ZZLJN2M5tdhwLwzB+0ZWE7N4Gir7uIYAEAQ/mxGMkAU+ onQOfeIsxXyF+qphaUOZMEvgMaGdUfPvx3QRkiVTu5LAgiNsx6zOE0KL2U6nAydMz72GGrsZ6Ey jHDrqaFB40NmjPbWaZMfAyNiA1tbkiC+uemQ== X-Received: by 2002:a05:6402:440b:b0:658:b87a:6eba with SMTP id 4fb4d7f45d1cf-660f00d29bemr1530969a12.16.1772643422461; Wed, 04 Mar 2026 08:57:02 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Blake , "Michael S. Tsirkin" , Dmitry Osipenko , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki Subject: [PATCH 17/20] virtio-gpu: Validate hostmem mapping offset Date: Wed, 4 Mar 2026 16:50:39 +0000 Message-ID: <20260304165043.1437519-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304165043.1437519-1-alex.bennee@linaro.org> References: <20260304165043.1437519-1-alex.bennee@linaro.org> MIME-Version: 1.0 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::530; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x530.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: 1772643468413154100 Content-Type: text/plain; charset="utf-8" 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> --- hw/display/virtio-gpu-virgl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 Sat Apr 11 23:04:26 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=1772643473; cv=none; d=zohomail.com; s=zohoarc; b=lEG2y2TfZWLT03819ykLuqOvaT5FiDuNi3Ou5z7Qs9cGxy9mvezxal9TVKCjklHbpomE/ghdm46+MJ3ybyXpNOU0kyH7nB2c2Uvt8rRT8zVOaBmZZddXHpfwOZRFlv2N/lNDQMolUViAkAEF9ppfOXTcxU6iEGyL0ZUcArPsWD0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772643473; h=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=+8JBFWACv1j8RnRNzU3WVG0i9zfzm4NzlWXfncEOBU0=; b=CVgAoRuF3dMATyd/XhqjRIaHNm/d4zZ8BwnwVN+lGmxWnvPufVnnQVvVQUTxpx7MRwzrEnqpells0UdbBbCO+mJyQa0jL75IjmFCAXqMqIcXEen5bFSc3+C8AqmwHnmUXZxD10PG2cYNrhHziwty7qn3fla8rJGfOMVhtt9gyzw= 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 1772643473096414.11792112975183; Wed, 4 Mar 2026 08:57:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxpX7-000760-95; Wed, 04 Mar 2026 11:57:13 -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 1vxpX4-00073w-Nn for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:57:10 -0500 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vxpX1-0003xY-9H for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:57:10 -0500 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-65b9d8d6b7dso11658598a12.2 for ; Wed, 04 Mar 2026 08:57:02 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b935ae6132asm773379966b.32.2026.03.04.08.57.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:57:00 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 5683062D9E; Wed, 04 Mar 2026 16:50:45 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772643421; x=1773248221; 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=+8JBFWACv1j8RnRNzU3WVG0i9zfzm4NzlWXfncEOBU0=; b=FqPHkR52C45AR0KXKYV9yOYNTH7Teb+T1xHjfHP8DPGLO+8qquYR8A2V2wtUVxbfjs +PDd+YU+PPDuZQV+kkEHdrMybUNcFw8fy3BugF2a6/NVs9chN/7nVaQVmodjYYIgEI2l K6KSYHAxqC1XcUfX0vIIpDwLErRivFZyl9Dgjd6M7SvIedJp+XquCnVTU8SGlpfhzbq1 J5gTjci1hbph9vgytWpdIuPaApz0UVIHuhQnbpRp/zZ1+ywN8Rf8pkZS94ON6lbVugIV 27ob4z3EwOa/Gkv3wvfKt6s4fNk8GIXDZuB8lMOYSVqjqZBumV8KniMYrBTvBkNkdlZK F1Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772643421; x=1773248221; 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=+8JBFWACv1j8RnRNzU3WVG0i9zfzm4NzlWXfncEOBU0=; b=esSPfuE5HZqTldDx4kBCeC99UFHjGnd8ubj8U/Irvh06wi/AXDSnxBILM1pownHQ33 QHBYBp6nqYO+RKwzj++fvclAL/yGIiapqL1PgRszxNN3YaJZjdmPMqqrvogsDnaOg2Dz LGztGu9ZBezeUqoaUnK/oYpWfUZwn0qtSrleDyLK+zUFTDR34CBGPzPyePKZiUaKZaWw 9X4f1/7RBQwTP5TCGKAxFsTnlmJzFqEwRCgLl2sSejQ+cVWout2X/f5fdjf7c4nPjdiN aFj9b8R4gx3zuis7hSjO/PwfBecIGdC2wgifYWMbiuEbA3DWP/sOtfuapCoV3ZzhgK5p fHkA== X-Gm-Message-State: AOJu0YxFXeCiATB2pOkFi4wFpbfOcz7+wq85VapMQb1rVj0iVYzj2jvu w+wYfdWV+1Q2T6Yij0Rp7ywNST3Hg8HSgaGlOqQr99C5k7WV5bd1ENFmJxYiZ9PaIvwmNh5EFAB nNN7v X-Gm-Gg: ATEYQzxhA0I3Zcq+jMrwphhyVAtavvHObYptviB9bH3or1V2lfjbPc0EGkWWcijakje FkJWvY+bb0NIsronlyFta5wmqLq7tSkHVIcTpbPyzqf+CKEGDehE10u3DHZns+gjqD762+LDsJJ 8q2z0P4MiPkZ8YboNQnFxrAUOPl91G6pZN/JBQzJWn1PbirCuPQo98Vi4Fw7Y7puo+g3vSzkuVm i4YoBDgXiGAUaVVpiCgiX8SX5wZkFmPHPPwE9yBE+JtrEki8ZF+g5yCls4rvHfGcNQE8x/xnkbQ tZ6OyS8X46FKbFqgiJ8+YY3vobWimoFJoFZi5yXIGL6W3vsi5eiz7mpVPNVPg6TS8lnA+qpAkkz IUZJ2qbA9DJSQf6YIl6n1hYyQ5bdPlpIuQucu35uN2KJn7eKATLVLwJjXmg26zVNozbZIUnO9na UUr7DFH6L6GXVOXVreAKUEAMg= X-Received: by 2002:a17:907:6d2a:b0:b8a:f9d7:1afe with SMTP id a640c23a62f3a-b93f159304bmr147707566b.57.1772643421094; Wed, 04 Mar 2026 08:57:01 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Blake , "Michael S. Tsirkin" , Dmitry Osipenko , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki Subject: [PATCH 18/20] virtio-gpu: Replace finish_unmapping with mapping_state Date: Wed, 4 Mar 2026 16:50:40 +0000 Message-ID: <20260304165043.1437519-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304165043.1437519-1-alex.bennee@linaro.org> References: <20260304165043.1437519-1-alex.bennee@linaro.org> MIME-Version: 1.0 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::536; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x536.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: 1772643474599154100 Content-Type: text/plain; charset="utf-8" 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> --- hw/display/virtio-gpu-virgl.c | 28 ++++++++++++++++++++++------ hw/display/trace-events | 2 +- 2 files changed, 23 insertions(+), 7 deletions(-) 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 Sat Apr 11 23:04:26 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=1772643439; cv=none; d=zohomail.com; s=zohoarc; b=YAJjfiFkuoOVwzh6L9R4d2zUHlQlWT8WzDSikKak1O6cvt54Bg/pOY9hvFAwHw2Yznki6yECDeweVECvDNmyXXYtBHLqO3uHXbJnY5oYRfcWhYoUyfXUdytQCDqnCCWEp7Qo0EeVq6RfP8WkoMw9htelKA/B68rrAcsvMzGOlRw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772643439; h=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=AYa+PK5wvAFnxYWm6ahhi41beKm1wBSZREJ0iDEKoMA=; b=jnmPimkfpHiudaLfAxROPEaf8Lu/bt0ohaRtZFsI4FT4mydfBzNp54qHjTmXHxKNYaS9gi5krCGTwvN/EwW+NWWRjj08oLhd4uomUBoOAeIqdXBIGly4N0rOFGovOgWmvngwbg3s7ksZQrsEDVhp0JZMz6QOqaTvO0r9lt7rhFc= 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 1772643439140627.984216978479; Wed, 4 Mar 2026 08:57:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxpX6-00075P-LI; Wed, 04 Mar 2026 11:57:12 -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 1vxpX4-00073x-Qd for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:57:10 -0500 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vxpX1-0003xg-9L for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:57:10 -0500 Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-660a293515fso4205999a12.1 for ; Wed, 04 Mar 2026 08:57:03 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-660a96af982sm1794099a12.26.2026.03.04.08.57.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:57:00 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 6F08E62DA9; Wed, 04 Mar 2026 16:50:45 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772643422; x=1773248222; 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=AYa+PK5wvAFnxYWm6ahhi41beKm1wBSZREJ0iDEKoMA=; b=XJSPapKA6GY9aeMBqNeZb/c3vlXxbhZL18Gwbtz4Tee8Ni7MX+6DFJGJLsWtNqgyJH 1NoKWobvP88QKxFONHdjIiyNDWkHM+KQQ9+qv4l2cV7SJDAn3EGMi0tkAAeAL1ZFz8/1 55BsrI1rQz+LCpu21IUvHSNfCTMwgsZebvccfbe0+5h4J7Wjx3az28+OU5v6rnGIN3+U +FTVtYt/YWXrFSibrExIXCV/CTjz/7FnGxzdMLEq6YJ/WaQviA5UJCXNsXFFypb2j+zO O8Co2mzjuwlAzwsYhcWRNPGjNAOmfJYyXnPhyTpGQ3Ln2kCaJfGUQbKMCecaDYK/znke wP4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772643422; x=1773248222; 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=AYa+PK5wvAFnxYWm6ahhi41beKm1wBSZREJ0iDEKoMA=; b=ripOai+FCuHYK0O+AR8YDlAWCeWH6AsNy9VV7RArnJgnItPF5z7gdFUdZSVLCR/DPr yK6tiGrx5h3MmgpUcSl4lWb+JHJeQmkgvMBY8E5Tfvh7KqB86nvDGWrh+OqspuKfj4bS gqM+ucOomNp336oz8GK90Uqx+yI3TZngQcX4na7m/jVScOURwKj7lCdmyAz//RAepPSC 5c9rAH6Yi/GC8ltcy/pFKdi/8fI8gsTmePUPgtMZR0dZApPDO/Uuq7sE6YLf5UKT3VA6 Gz1KeKvRHFdsqjVUmuNEOPND+d3TfrjOFT0pIV0KmOqeOXC0LJbUdo2lc7Agr3TFwpRQ Pt2g== X-Gm-Message-State: AOJu0YyMb+nUTkJKNqz15cP+nUPVTY8klhmjCRPC8jNGNCL4SDCVr5Xb PR72h6zM9bbGSSIJNM7kXi9AsALKVsL23417OICWSQ2KBGKyNvFl0BlwKEJGP+KBjOc= X-Gm-Gg: ATEYQzwUXcyzls7BdDmJB6hLp65z2IF3bp6FEnQdxPoCmClUqiNc82AXs6hBJ34eBmD BSm5d1XQtV0FWUBF7JIu9nEpvOQ5EuQCEwBXqXHnGpfcuV7c3D9Xw//4t/vzgoxEQYWsSO6LB0v 0jo7m0vwAfsZLfhNasoALGZhSLfDCgBjDzHEOJnRAtLUJawLDOCtQUHweldn0HkwSNCjbJx8O1b y3Wk8yYDZR1DFDLYlH5f2MsfxZMMbKrFQzG3AemfKozjnV1jFn7IxgmSuW7aQg8ZPni9h+YP1Lw HDNj264XJowhWeEbv7d83Q8Pr1Ozx0vguZcDBoqJVrFU48gNCmoFy/UTlIVfcORxu8nAmOnLgEX rjB72ydDf4ufnwtnOcjfsFMkUC3YCZp2yTA6rZxWwkF4oh0/DxyNS1IMue/4EpAuHW5Xp3wcCKd diBIOy2DI/++O8MS3BN/YZtMY= X-Received: by 2002:a05:6402:34d4:b0:659:3ed2:13fe with SMTP id 4fb4d7f45d1cf-660efb94a7fmr1547294a12.6.1772643421854; Wed, 04 Mar 2026 08:57:01 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Blake , "Michael S. Tsirkin" , Dmitry Osipenko , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki Subject: [PATCH 19/20] virtio-gpu: Destroy virgl resources on virtio-gpu reset Date: Wed, 4 Mar 2026 16:50:41 +0000 Message-ID: <20260304165043.1437519-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304165043.1437519-1-alex.bennee@linaro.org> References: <20260304165043.1437519-1-alex.bennee@linaro.org> MIME-Version: 1.0 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::52f; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52f.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: 1772643442336154100 Content-Type: text/plain; charset="utf-8" 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> --- include/hw/virtio/virtio-gpu.h | 6 +- hw/display/virtio-gpu-gl.c | 18 +---- hw/display/virtio-gpu-virgl.c | 123 +++++++++++++++++++++++++++------ 3 files changed, 107 insertions(+), 40 deletions(-) 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 Sat Apr 11 23:04:26 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=1772643075; cv=none; d=zohomail.com; s=zohoarc; b=ArIigqaebILwzd5vvzkCXDWtJ7c9oKaLcw8fPbrVSZQQJNPkZGl0TmzAE2ti8VE2LaERCyeB7hE+DFUjYajytwuwMs3aLvnZxp1HneHNpEM2MFo1YVcnoqwxA9uDgsgJO0sdRojkcfOS+5vXexiG+W+SieHlKgizk+5mlYBcX8o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772643075; h=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=U0gctoCs5t//bM1s9oVaZawXqSrhxbVS02uOrAaRAIA=; b=HIwxIJ4DSMSwTQMi9ITd1LYRKElp4ppHHVqh3s25cWttfToQieEQtaw8JurkMXOf1k/bqREMp4iPrO7a0CZJVaejT3xEsUmWd69LGvvT1a/9Zg3igNJm8EOgGxZ+xzGwab2UVi4ckiC+I6r6NNolYJ6bMmQBtEp8/3GqqQP5a1Q= 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 1772643075593789.6064293339352; Wed, 4 Mar 2026 08:51:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vxpR8-0003xE-JQ; Wed, 04 Mar 2026 11: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 1vxpR5-0003uR-Ow for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:59 -0500 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vxpR3-0002SV-Tf for qemu-devel@nongnu.org; Wed, 04 Mar 2026 11:50:59 -0500 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-65c5a778923so10688592a12.2 for ; Wed, 04 Mar 2026 08:50:57 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-65fabd46753sm5747120a12.8.2026.03.04.08.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 08:50:55 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 87DB762DAA; Wed, 04 Mar 2026 16:50:45 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772643056; x=1773247856; 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=U0gctoCs5t//bM1s9oVaZawXqSrhxbVS02uOrAaRAIA=; b=x+/mEeSg1Fhn8CFSSyklnY2bx/MCdAHDdDKoDTBHU6Ho8XeNrjsK1m07ofgaWip3Lf niQ3UnpixKjmDy1URHzhkZjZ+csLLcj4r3eJq/CAU4QhH/l7ClZFZK6nOw7YKQjiH6mj 5QMqTlCfg8JcecKheKVUFjLr1p5tvDPGsm3ZwsVC1kFmoZcZF0s/UXLPcyyA3BycFblM 3/AmB+m5RBQbEp+sWzWjYXaNSwvcROCdua5SgxIRTOTGsh/wYptAyxZfgaDpIAsPt2YM D49zy584bW0VBpp2/y/s54aGFvKnRKuS400G9SoeZ+gcxvuTU2P7McUoG6rIEaR/5SZq Iskg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772643056; x=1773247856; 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=U0gctoCs5t//bM1s9oVaZawXqSrhxbVS02uOrAaRAIA=; b=taQjuChvXnpoPfniDD8eC8G5mlLWJB6YJXhR1sp+Ugzft1iC8upV7flNSkEWmoHpcR VrMHmqr8luVWj/2Z6Eou8jC9zNuVlpVNDhHjoxLuFxxwFDm1R/X5//hkrbeH/DKA/L/q nk3fP64r/5SazeUNZIu+9/HKpt6983S1+uR6CdaH7ODdbhn881pZV/5hyrpQA+zmqPA8 WekJ06VUk+EK2DbfPk7eMMrIAftoeGt5QAOEJAKaOb+th0DDP3Kh3EYWb47jjgmoLU8L iq9MdnSFQc2cdKABaaLrsItHq5yFEDlpYm/DojTNbdqyODgSgsBgyrx2wr0lZOGlCwy5 0RxQ== X-Gm-Message-State: AOJu0YxU6QrT3g8U6Vi4AZs0HwbohkOusHMjQEH8atpeJcOoxOApYmmu K4x8giqc4XgMYJUf//FBoZPJYTLUjzi4ur8qhtXm0hS+UPsAzsjQJ0x1DUaGCKsXUk4= X-Gm-Gg: ATEYQzxmYALF63QNYhkw5tL3fowcUJEK4I/41W1KWgGUfIRxBFILLwJUEk4PKj9L6Ik Im6dubngtiVcyJZF4pf/ubA8ioot5YmHc9pX+Wi8IrtdbCqRkzgBHmTTsZ1hLoVz4Ym/m4/5crs p/jDb6MYcI2To2Ko74WKCaZlpI3S2fGdNjQAj9mnKxa+2WEdZDB2DP2di89iej+bi4tSEEwNwNr CXwmQyJPS3k9PXzZPCJkpPTqBpoRbVQUL8plj1gsczcrj4fxna8nB37QvbEc1fi2P6DCb+SgkE3 A/GsZw9kct4Q6VnARGWVR4rYiU55w6IV0Ra02eQiqNTyC9cIBq5lYX1iZ6M0HCVDr9YGCexsg7O eyGbiaUieAFDaTDUtSZ/cfBLlJMARH3AVRaAEcukL1L3HR/tcCmA4Nyy0Nys6qmCVBLNYuqXuo9 CN+ztfzrvncBlDQjkCR9G4lYM= X-Received: by 2002:a05:6402:5188:b0:660:af39:2d15 with SMTP id 4fb4d7f45d1cf-660efec5fd7mr1853548a12.17.1772643056328; Wed, 04 Mar 2026 08:50:56 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Akihiko Odaki , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Eric Blake , "Michael S. Tsirkin" , Dmitry Osipenko , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yiwei Zhang , Akihiko Odaki Subject: [PATCH 20/20] virtio-gpu: Support mapping hostmem blobs with map_fixed Date: Wed, 4 Mar 2026 16:50:42 +0000 Message-ID: <20260304165043.1437519-21-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304165043.1437519-1-alex.bennee@linaro.org> References: <20260304165043.1437519-1-alex.bennee@linaro.org> MIME-Version: 1.0 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::52e; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52e.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: 1772643077399158500 Content-Type: text/plain; charset="utf-8" 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> --- include/hw/virtio/virtio-gpu.h | 3 ++ hw/display/virtio-gpu-gl.c | 37 ++++++++++++++++++++- hw/display/virtio-gpu-virgl.c | 59 +++++++++++++++++++++++++++++++++- 3 files changed, 97 insertions(+), 2 deletions(-) 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