From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047073; cv=none; d=zohomail.com; s=zohoarc; b=A4En7OavtIkw9AFWDCmgMAeVmdFk908zupm8+8hdyjVDiJBqGFVWp4kRc0FpW7HKuEo//9xV7F5xaVOBAMSB3SiuZCE8GexhRPfGZSMn35g2j6ICIQhUiTYGJ22Im0LLtt5x5KjRssGa6yZe8ed81wOy7tsWEAiIx8WGZhBEnoY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047073; 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=b+HQTuN6Q4eCJXLMuX75gYL+WGKDMaLS7r6L7oKslj8=; b=BR98BkUDBJ6bUtxINrr+LJdeHcM792n2a8hdAf3ErGIkwug34ua7pf9QtVkEoB9FPiSKUe1ZQUGhsZN/3e+R81VxiBOsNdm+4QNU6HW2Q44QdYkiMADOIZTLfGavGjp1aApKBPDCQtK6UfkZOO+owL9rW76OTAJ30j9WA/hupm0= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17890470735311001.1531695138892; Thu, 10 Sep 2026 06:31:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4erL-000212-BI; Thu, 10 Sep 2026 09:30:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4erD-0001tj-Qe for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:30:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4erC-0003bT-Ab for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:30:27 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-76-sMKRk6hUMniruTVudMOYIQ-1; Thu, 10 Sep 2026 09:30:21 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9651718001E1; Thu, 10 Sep 2026 13:30:20 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DED1877F; Thu, 10 Sep 2026 13:30:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047025; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b+HQTuN6Q4eCJXLMuX75gYL+WGKDMaLS7r6L7oKslj8=; b=Yk1AgGLPfqtQBUGu6hcSop6ab5iq0B1zIOh4Woqry2IPpzUt1b6Hwk9E2RDTkzf5ZfUjgv Fs5tPH+jH27qh2tRoO5RLklUI0ZIM7CtRNRYcrzk3741xluap2eg/5oXmj6DZ0+SvQVnlQ NBgNze8ETYYUXvr3uMq+veg9aQkCuxk= X-MC-Unique: sMKRk6hUMniruTVudMOYIQ-1 X-Mimecast-MFC-AGG-ID: sMKRk6hUMniruTVudMOYIQ_1789047020 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:29:56 +0400 Subject: [GIT PULL 01/24] virtio-gpu: disable blob scanouts on mapping cleanup MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-1-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko X-Developer-Signature: v=1; a=openpgp-sha256; l=1360; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=R9p5LQIIzRohkvwfRNtuO/PatWCNeFmPWXK+hMXTuqM=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDbkQ0YgfTnaRKPUdjvjIluHKKdmKcNyWoXa 8g9XcEt7wqJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw2wAKCRDa6OEJdZac 5SxuEAClvRUu12G4rdypZ16AmzsYqnTFwGDl1AONfGXLeSHhBzKska2nkAydjgRRR+ZGnXwjzYb 9tqo2zsB4w5uigpGLjIxemleyGdzxE3yYD0mPkk7y0e6u4zLRHXnVDNYyhQdFPzS6EgDItO88Dx ZS4nRgAAC/X6uE9pu4W3HJIIMHxLQED84YkafO4nmRmEbL8To0IDTv8P4B9izG+AgYCK5lEKw96 B15Zv+oguUwJscyVqw8x0+ehjvvi4k1iPRIu6TvfKkGU58mZeiN4GS1UfVF9m+ovey1/1dpa7BP Qk1po58BVnxeZ3b8ex1WRR8ukKcbk2sT/rLqhMN2Uf6HXs/29M7d5xcxk0em+3Tp2mm+IeTMkVA qrDg8NsGaQiSKN/LlkkivloMmHn8oYqnu6fZlimiML0atKwCcUscdk9Z0xtqF4DZ7MZql75PFn/ KI2HAh0QwIwjGkvrLLSg91xgl3UDKknF37b43Ncamn4BGgpEWDnMIG1M6A4RcEyS46PlZg+01q9 h+2r66mCF/dTINHeJEV1l+OaEUSDEEKq2rnIgihXNj/NuF07ygkD18rzcBzTY4k2zFPTAK4eIDh ZFPrlu2ynRLcl6b6jYcQ3TE3gXRkNTOyifXXFy0v0WipqhorECyMhEizOsTNWZMJ6/AO/iAw8PC iSexMKbKj4PeLsg== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1789047076051158500 When a blob resource backing is cleaned up (for ex via detach_backing), any scanouts referencing it must be disabled first to prevent the dmabuf from outliving its backing memory. Fixes: CVE-2026-66020 Fixes: 32db3c63ae11 ("virtio-gpu: Add virtio_gpu_set_scanout_blob") Reported-by: Akihiko Odaki Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/display/virtio-gpu.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 55a1c7f80fb8..5b63a292933a 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1022,6 +1022,16 @@ void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, void virtio_gpu_cleanup_mapping(VirtIOGPU *g, struct virtio_gpu_simple_resource *res) { + if (res->blob) { + int i, max_outputs =3D g->parent_obj.conf.max_outputs; + + for (i =3D 0; i < max_outputs; i++) { + if (g->parent_obj.scanout[i].resource_id =3D=3D res->resource_= id) { + virtio_gpu_disable_scanout(g, i); + } + } + } + virtio_gpu_cleanup_mapping_iov(g, res->iov, res->iov_cnt); res->iov =3D NULL; res->iov_cnt =3D 0; --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047067; cv=none; d=zohomail.com; s=zohoarc; b=Ov9Agm6hZ062W9/e/NXEYUIwGW3CDff56cuNT5xI37tWd8Cl02VAO9D9k/b2CtTLB3cLBs5JLo+O4bEA+FeUKcUBWC0nOLUoE/KzIindT2B+uGE67REEtRvr4Od7ihvWgDRj3oAqwD+eyUzx1B1rUjTAzKKjGUffPqcFIqFCYBQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047067; 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=TikkYz8c3/fNENa6pL9yhbMSpzGUiYvvtS6AgjEfV9k=; b=it8w436CPVWO+OcTRbzyHtGuCHCVXG5ChQZSvxRMnMwsOm5LK0ZtOZ/aFY7T/C033SEQjtW4VSf16Id5wQfmZYHv5HQyTyyHJwdfRLUAFWgiWRAzVIRVBS9/rztsM+Sha3HciM92OzsTY0krPdCSINEazxWwPQwR2JCe+pmMbkQ= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047067208725.9727358273282; Thu, 10 Sep 2026 06:31:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4erR-00024x-Ve; Thu, 10 Sep 2026 09:30:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4erL-00021O-Fs for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:30:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4erJ-0003c8-7m for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:30:35 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-664-8B61Bo0vO9eca2bTO6gxZg-1; Thu, 10 Sep 2026 09:30:29 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 01D371954120; Thu, 10 Sep 2026 13:30:26 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 32CBA418; Thu, 10 Sep 2026 13:30:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047032; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TikkYz8c3/fNENa6pL9yhbMSpzGUiYvvtS6AgjEfV9k=; b=dxxj73Ov3hBjtROWjvzgDoB24GzKbZuScRNR6vFwUIJ22eSxBu6cTboHGq+9drQnIQBDGc nYqJy6KF4TXdGrUrwqDVE46vvqnlsRj1gBFliycLxbyBCC5bwh8nExnfOMvmlzBinHXctV vTDXb/uS9ExxdbDuGlhVVVjgApS/L08= X-MC-Unique: 8B61Bo0vO9eca2bTO6gxZg-1 X-Mimecast-MFC-AGG-ID: 8B61Bo0vO9eca2bTO6gxZg_1789047027 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:29:57 +0400 Subject: [GIT PULL 02/24] virtio-gpu: clear res->blob on mapping cleanup MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-2-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko X-Developer-Signature: v=1; a=openpgp-sha256; l=2329; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=PrgX7l2qQPAdPLNhPkM5aNrYf4ZSg/Qi9smSw4mXwxk=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDbDEpXphDoWgugdhmZDyxSixfM252LuX5xu ex6ahSRtguJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw2wAKCRDa6OEJdZac 5c6tD/sGOc+5EdoeIAUlcHpGcCOki+2n9ROuhk8xk8uNshfVTOw8JedNfuPjCzkc6pza53cmXWN o8nBoeXtNvl4H/Qtm+ee4IGzGLV9NGpnSzRFbR4LrT7yQ+kx8Or7JBm6tOkOyx5LZLzLskzavG1 TLh/6cVsKe0XA7o77oDEM8r++hKivgOUZNOaQiEvwONK+qku8UDwYMklQP37ixtGxO9gAT2GeD9 SlpuNeRZ2QVg8DS6CGO55x92FwIsm9sj7GAldJ/8yVECljcMrR4nF23uy6UGYDuuLBT5Y1DR7A/ EMPvQUu9bL+jqAEhSKy6trVOTX3n28rKvG1UepytY7GRRF6WRtfTH+tgZkaIMH8/524ybbKX998 3DlJMJWrPO+Y+lZpHK6MleGjblkYWs2I3JgLSI50tBC4iSrRDGYn43u7HON4R/a3FD+ghmV8Dp4 892Rfznv7jrPIv9jGOVmsyAPhSUVWaTGGm2MkselmMh86E4mPZPRnw7BorhtggrTX3CKyZ6nxj5 VGn/61p4B2wp/0nF2AJMn8KZnEt4cQOyLCLsGnozfJuZaNgis+AVLpr/wtxAy7a3gw/TpS+/gar TqkblX3NY/qBJUUZttP4+UJbC+e+7xXqTiaGRHR9n8eolZetVe01oxIlK3TSiE/QM2pLhdgWBit /FclK2r1ITfbIwA== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1789047069588158500 d3c2da174ca6 ("hw/display/virtio-gpu: Check cursor data presence") already prevents the use-after-free on blob cursor after detach. Clear res->blob in virtio_gpu_destroy_udmabuf() to keep init/fini symmetric, and add LOG_GUEST_ERROR messages in virtio_gpu_update_cursor_data() for missing or undersized blobs. Fixes: bdd53f739273 ("virtio-gpu: Update cursor data using blob") Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3881 Reported-by: =E7=AB=A0=E9=B1=BC=E5=93=A5@aipy (www.aipyaipy.com) Reported-by: swing Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/display/virtio-gpu-udmabuf.c | 1 + hw/display/virtio-gpu.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabu= f.c index c230509852ff..03f0b29754e1 100644 --- a/hw/display/virtio-gpu-udmabuf.c +++ b/hw/display/virtio-gpu-udmabuf.c @@ -92,6 +92,7 @@ static void virtio_gpu_destroy_udmabuf(struct virtio_gpu_= simple_resource *res) close(res->dmabuf_fd); res->dmabuf_fd =3D -1; } + res->blob =3D NULL; } =20 static int find_memory_backend_type(Object *obj, void *opaque) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 5b63a292933a..3c3539e337fb 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -61,8 +61,16 @@ void virtio_gpu_update_cursor_data(VirtIOGPU *g, } data =3D pixman_image_get_data(res->image); } else { - if (!res->iov || res->blob_size < (s->current_cursor->width * - s->current_cursor->height * 4))= { + if (!res->blob) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource %d has no blob\n", + __func__, resource_id); + return; + } + if (res->blob_size < (s->current_cursor->width * + s->current_cursor->height * 4)) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: blob size too small for resource %d\n", + __func__, resource_id); return; } data =3D res->blob; --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047067; cv=none; d=zohomail.com; s=zohoarc; b=Oj+t4O2k794nCUnoe31aSoad80uEkxdhGpLAI+flQ+phWvUJI8/iXPcfyX7QPXzt2GYk+91NuG/2GjwRmiXBM2PXocCsPcUijrpOGBgxKj8Vy5y5616qcb7HBkuiaAhktaHEa+EW2EGiSGcyfJRtu8eVAbBP75kYnCwgRUNqEys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047067; 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=0ngT2cCLD1QZ+H2eW9Nvud+V6k97Yyz3vx5HyUPP+dw=; b=JKwKFJHwwnGpEi9XSIPymooiuHwPD4cQR/iebuLnBFC8xOUQTorV5lV+E/4fnDraTq1VX4pkCHqpUH6/o7w3/Orz+D5a/HDJs0DyuXtBGCbnlqrx/pniOzsOO6dX3bLY6SDKPY0pIrQ7gfF2yl8Rl9MUaYRDFXsz7WAqHi1hE8c= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047067137922.3758004999888; Thu, 10 Sep 2026 06:31:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4erV-00028u-2F; Thu, 10 Sep 2026 09:30:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4erR-00024y-EC for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:30:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4erO-0003cv-Js for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:30:40 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-452-I4zQydu_OdqK72qvyR2ZCA-1; Thu, 10 Sep 2026 09:30:32 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 073661800107; Thu, 10 Sep 2026 13:30:31 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5A12D3000239; Thu, 10 Sep 2026 13:30:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047038; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0ngT2cCLD1QZ+H2eW9Nvud+V6k97Yyz3vx5HyUPP+dw=; b=etsVOKkoCxLoGwgSUvIIqskLOIDiq0obG7hawMe5SPIb3V/EcJ+xCP0Ev3LkzqJkb1L53N zHW4NAz4wAdoF7Yw85gmWnjxKYWq3HINrVmXwLMj9wpOzkA2vqF1vnukY50ywIcFM50mgc hPD74WbHufveqgn4UG6epXpnCl0/9K8= X-MC-Unique: I4zQydu_OdqK72qvyR2ZCA-1 X-Mimecast-MFC-AGG-ID: I4zQydu_OdqK72qvyR2ZCA_1789047031 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:29:58 +0400 Subject: [GIT PULL 03/24] hw/display/virtio-gpu: introduce virtio_gpu_{simple,virgl}_resource_new() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-3-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko X-Developer-Signature: v=1; a=openpgp-sha256; l=10567; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=w3w7Q50Jg6Ng9Xo0v3C94n/99pxWsT7TSnCepItsbx4=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDbtkLhtgCnjeT4zxJDCZKjXZHgdvzEjHF7V SnlQup+bdOJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw2wAKCRDa6OEJdZac 5cYcD/kBFXagf1qBLFF6bG6l2GhES+atGUh8WiyxHrETemgPKrrJRMlWzxUWT61fOVsM7PCIHVz ddojw8d2gAP53pzrl8c2UgMIxIrRuOzHh9g7p+1c8uw9WHBrS4mUqBM9BeO99DZmg3L9NzHBjCm 0XOG8eExcXcLORlr+UZbEitcaj79wKzbd+vAKU8Emkdh0usLQg1hH+iZ+kQLNKOerZa+gT2FJnb a6E0RxuIGFquAxAGEtBqfweWo2Xt6/98zj9v+NfAJLipxiS7EnuVEXGZV7bM2HPA8gPP7hDVMlh iKMLDPaftCueD/HTEDloRwtbkkqdEI75E7/KMm5XjrJj6Kaztr13+opZcW+3dxo4CUpASK89CBg O0IfpnBkpaO8EYeS1eS50HlhZAXkNy2IRdYj3ubjO08m2U0tGfXs0AOEuCAN9L3iy0X0yd7PnDz Y+TfwUVZKZ7XXbSEsvbGDtXUd5H8bKJIsf965bAI+qA3xJABe8vPBIGhujgy+Mr9wVCxruzPPEt vGjq7jomwn62nC1mqbXIQyQHyYk0mRUzK1Te4ZckD6JEesW3h6mXgHsFmXGQQShW5gxOMtsQiif cjDGrcqg+BA5jA8UQF27wNoau0TD2P429cQbl3FfEbc7sAa0LFsTFGQOIwNOY0IpInTDpTZ6K+s qAoVs36oDN/Fimw== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1789047069738158500 All allocation sites used g_new0() which zero-initializes fields. However share_handle must be SHAREABLE_NONE (-1 on Unix, NULL on Windows) and dmabuf_fd must be -1, not 0. Centralize allocation and field initialization in new constructors fix this and reduce code duplication. This fixes -display dbus with virtio-gpu blob resources. The other end is currently receiving qemu fd 0. Fixes: 5f899c34af1d (=E2=80=9Cvirtio-gpu: allocate shareable 2d resources o= n !win32=E2=80=9D) Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/display/virtio-gpu-rutabaga.c | 21 +++---------- hw/display/virtio-gpu-virgl.c | 48 +++++++++++++++++++---------- hw/display/virtio-gpu.c | 66 +++++++++++++++++++++++++++++-------= ---- include/hw/virtio/virtio-gpu.h | 11 +++++++ 4 files changed, 97 insertions(+), 49 deletions(-) diff --git a/hw/display/virtio-gpu-rutabaga.c b/hw/display/virtio-gpu-rutab= aga.c index 041216a10d04..b8f8a2068d0b 100644 --- a/hw/display/virtio-gpu-rutabaga.c +++ b/hw/display/virtio-gpu-rutabaga.c @@ -100,12 +100,8 @@ rutabaga_cmd_create_resource_2d(VirtIOGPU *g, result =3D rutabaga_resource_create_3d(vr->rutabaga, c2d.resource_id, = &rc_3d); CHECK(!result, cmd); =20 - res =3D g_new0(struct virtio_gpu_simple_resource, 1); - res->width =3D c2d.width; - res->height =3D c2d.height; - res->format =3D c2d.format; - res->resource_id =3D c2d.resource_id; - + res =3D virtio_gpu_simple_resource_new(c2d.resource_id, c2d.width, + c2d.height, c2d.format); QTAILQ_INSERT_HEAD(&g->reslist, res, next); } =20 @@ -139,12 +135,8 @@ rutabaga_cmd_create_resource_3d(VirtIOGPU *g, result =3D rutabaga_resource_create_3d(vr->rutabaga, c3d.resource_id, = &rc_3d); CHECK(!result, cmd); =20 - res =3D g_new0(struct virtio_gpu_simple_resource, 1); - res->width =3D c3d.width; - res->height =3D c3d.height; - res->format =3D c3d.format; - res->resource_id =3D c3d.resource_id; - + res =3D virtio_gpu_simple_resource_new(c3d.resource_id, c3d.width, + c3d.height, c3d.format); QTAILQ_INSERT_HEAD(&g->reslist, res, next); } =20 @@ -634,10 +626,7 @@ rutabaga_cmd_resource_create_blob(VirtIOGPU *g, =20 CHECK(cblob.resource_id !=3D 0, cmd); =20 - res =3D g_new0(struct virtio_gpu_simple_resource, 1); - - res->resource_id =3D cblob.resource_id; - res->blob_size =3D cblob.size; + res =3D virtio_gpu_simple_resource_new_blob(cblob.resource_id, cblob.s= ize); =20 if (cblob.blob_mem !=3D VIRTIO_GPU_BLOB_MEM_HOST3D) { result =3D virtio_gpu_create_mapping_iov(g, cblob.nr_entries, diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 9bda572426b2..742d9dde4a32 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -309,6 +309,33 @@ virtio_gpu_virgl_unmap_resource_blob(VirtIOGPU *g, } #endif =20 +static struct virtio_gpu_virgl_resource * +virtio_gpu_virgl_resource_new(uint32_t resource_id, uint32_t width, + uint32_t height, uint32_t format) +{ + struct virtio_gpu_virgl_resource *res; + + res =3D g_new0(struct virtio_gpu_virgl_resource, 1); + virtio_gpu_simple_resource_init(&res->base, resource_id); + res->base.width =3D width; + res->base.height =3D height; + res->base.format =3D format; + + return res; +} + +static struct virtio_gpu_virgl_resource * +virtio_gpu_virgl_resource_new_blob(uint32_t resource_id, uint64_t blob_siz= e) +{ + struct virtio_gpu_virgl_resource *res; + + res =3D g_new0(struct virtio_gpu_virgl_resource, 1); + virtio_gpu_simple_resource_init(&res->base, resource_id); + res->base.blob_size =3D blob_size; + + return res; +} + static void virgl_cmd_create_resource_2d(VirtIOGPU *g, struct virtio_gpu_ctrl_command *c= md) { @@ -335,12 +362,8 @@ static void virgl_cmd_create_resource_2d(VirtIOGPU *g, return; } =20 - res =3D g_new0(struct virtio_gpu_virgl_resource, 1); - res->base.width =3D c2d.width; - res->base.height =3D c2d.height; - res->base.format =3D c2d.format; - res->base.resource_id =3D c2d.resource_id; - res->base.dmabuf_fd =3D -1; + res =3D virtio_gpu_virgl_resource_new(c2d.resource_id, c2d.width, + c2d.height, c2d.format); QTAILQ_INSERT_HEAD(&g->reslist, &res->base, next); =20 args.handle =3D c2d.resource_id; @@ -383,12 +406,8 @@ static void virgl_cmd_create_resource_3d(VirtIOGPU *g, return; } =20 - res =3D g_new0(struct virtio_gpu_virgl_resource, 1); - res->base.width =3D c3d.width; - res->base.height =3D c3d.height; - res->base.format =3D c3d.format; - res->base.resource_id =3D c3d.resource_id; - res->base.dmabuf_fd =3D -1; + res =3D virtio_gpu_virgl_resource_new(c3d.resource_id, c3d.width, + c3d.height, c3d.format); QTAILQ_INSERT_HEAD(&g->reslist, &res->base, next); =20 args.handle =3D c3d.resource_id; @@ -853,10 +872,7 @@ static void virgl_cmd_resource_create_blob(VirtIOGPU *= g, return; } =20 - res =3D g_new0(struct virtio_gpu_virgl_resource, 1); - res->base.resource_id =3D cblob.resource_id; - res->base.blob_size =3D cblob.size; - res->base.dmabuf_fd =3D -1; + res =3D virtio_gpu_virgl_resource_new_blob(cblob.resource_id, cblob.si= ze); =20 if (cblob.blob_mem !=3D VIRTIO_GPU_BLOB_MEM_HOST3D) { ret =3D virtio_gpu_create_mapping_iov(g, cblob.nr_entries, sizeof(= cblob), diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 3c3539e337fb..cb45360e769e 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -41,6 +41,42 @@ virtio_gpu_find_check_resource(VirtIOGPU *g, uint32_t re= source_id, =20 static void virtio_gpu_reset_bh(void *opaque); =20 +void +virtio_gpu_simple_resource_init(struct virtio_gpu_simple_resource *res, + uint32_t resource_id) +{ + res->share_handle =3D SHAREABLE_NONE; + res->dmabuf_fd =3D -1; + res->resource_id =3D resource_id; +} + +struct virtio_gpu_simple_resource * +virtio_gpu_simple_resource_new(uint32_t resource_id, uint32_t width, + uint32_t height, uint32_t format) +{ + struct virtio_gpu_simple_resource *res; + + res =3D g_new0(struct virtio_gpu_simple_resource, 1); + virtio_gpu_simple_resource_init(res, resource_id); + res->width =3D width; + res->height =3D height; + res->format =3D format; + + return res; +} + +struct virtio_gpu_simple_resource * +virtio_gpu_simple_resource_new_blob(uint32_t resource_id, uint64_t blob_si= ze) +{ + struct virtio_gpu_simple_resource *res; + + res =3D g_new0(struct virtio_gpu_simple_resource, 1); + virtio_gpu_simple_resource_init(res, resource_id); + res->blob_size =3D blob_size; + + return res; +} + void virtio_gpu_update_cursor_data(VirtIOGPU *g, struct virtio_gpu_scanout *s, uint32_t resource_id) @@ -267,12 +303,8 @@ static void virtio_gpu_resource_create_2d(VirtIOGPU *g, return; } =20 - res =3D g_new0(struct virtio_gpu_simple_resource, 1); - - res->width =3D c2d.width; - res->height =3D c2d.height; - res->format =3D c2d.format; - res->resource_id =3D c2d.resource_id; + res =3D virtio_gpu_simple_resource_new(c2d.resource_id, c2d.width, + c2d.height, c2d.format); =20 pformat =3D virtio_gpu_get_pixman_format(c2d.format); if (!pformat) { @@ -353,9 +385,7 @@ static void virtio_gpu_resource_create_blob(VirtIOGPU *= g, return; } =20 - res =3D g_new0(struct virtio_gpu_simple_resource, 1); - res->resource_id =3D cblob.resource_id; - res->blob_size =3D cblob.size; + res =3D virtio_gpu_simple_resource_new_blob(cblob.resource_id, cblob.s= ize); =20 if (cblob.nr_entries) { ret =3D virtio_gpu_create_mapping_iov(g, cblob.nr_entries, sizeof(= cblob), @@ -1455,16 +1485,17 @@ static int virtio_gpu_load(QEMUFile *f, void *opaqu= e, size_t size, =20 resource_id =3D qemu_get_be32(f); while (resource_id !=3D 0) { + uint32_t width, height, format; + res =3D virtio_gpu_find_resource(g, resource_id); if (res) { return -EINVAL; } =20 - res =3D g_new0(struct virtio_gpu_simple_resource, 1); - res->resource_id =3D resource_id; - res->width =3D qemu_get_be32(f); - res->height =3D qemu_get_be32(f); - res->format =3D qemu_get_be32(f); + width =3D qemu_get_be32(f); + height =3D qemu_get_be32(f); + format =3D qemu_get_be32(f); + res =3D virtio_gpu_simple_resource_new(resource_id, width, height,= format); res->iov_cnt =3D qemu_get_be32(f); =20 /* allocate */ @@ -1568,14 +1599,15 @@ static int virtio_gpu_blob_load(QEMUFile *f, void *= opaque, size_t size, =20 resource_id =3D qemu_get_be32(f); while (resource_id !=3D 0) { + uint32_t blob_size; + res =3D virtio_gpu_find_resource(g, resource_id); if (res) { return -EINVAL; } =20 - res =3D g_new0(struct virtio_gpu_simple_resource, 1); - res->resource_id =3D resource_id; - res->blob_size =3D qemu_get_be32(f); + blob_size =3D qemu_get_be32(f); + res =3D virtio_gpu_simple_resource_new_blob(resource_id, blob_size= ); res->iov_cnt =3D qemu_get_be32(f); =20 if (res->iov_cnt) { diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 69b5ee2e382f..8c0df60b3b7e 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -64,6 +64,17 @@ struct virtio_gpu_simple_resource { QTAILQ_ENTRY(virtio_gpu_simple_resource) next; }; =20 +void +virtio_gpu_simple_resource_init(struct virtio_gpu_simple_resource *res, + uint32_t resource_id); + +struct virtio_gpu_simple_resource * +virtio_gpu_simple_resource_new(uint32_t resource_id, uint32_t width, + uint32_t height, uint32_t format); + +struct virtio_gpu_simple_resource * +virtio_gpu_simple_resource_new_blob(uint32_t resource_id, uint64_t blob_si= ze); + struct virtio_gpu_framebuffer { pixman_format_code_t format; uint32_t width, height; --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047132; cv=none; d=zohomail.com; s=zohoarc; b=AK7evL8fbv2DTTnhNg0f3EYZnNch5/tlYauT3SXrKjS44J9xVqPJWVMNoOJ+v/DONjjQ4T/BDupWQou6lWmrHfOkQTgTPNl78GP5G/YfV9rcj3lh7SGwAmULjqJHQrR0doae/67kGFPEekhm4wH2Gm7gai5TF7mqjsZGQINEjyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047132; 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=wjrug66JF7sj2Em1iOXDLtWW+CYxXnfe2H2hXOKSaUU=; b=SRI90WFGUa7yTYR1kF8DrlibP3mj4+g5PQOb0XowssVS5E4cP2dmBbBsSzW0bIJoEwbe6S5qlfw3lD2OV3OBiAjSxS3EzZKQhvH/5b/zCiyxturmHeS7kjbn5/ttK2vYtskC3SGM1sThezoiogahOPAiEQnmyQ9CnxjkSubqOR0= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047132497837.6156222270145; Thu, 10 Sep 2026 06:32:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4erU-00028R-HP; Thu, 10 Sep 2026 09:30:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4erR-00024z-Dv for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:30:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4erP-0003cz-9D for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:30:40 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-414-Xv60WpmRNCe-lnI_Jfu1Ag-1; Thu, 10 Sep 2026 09:30:36 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 593111955EB7; Thu, 10 Sep 2026 13:30:35 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CD8761955F19; Thu, 10 Sep 2026 13:30:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047038; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wjrug66JF7sj2Em1iOXDLtWW+CYxXnfe2H2hXOKSaUU=; b=hIDfe4w+HuvS9aUQz9/MHLJ/yz8W6kwCR64d7IaG0RMssKbHQmXzzX9WRbMEEwJysy03y1 5GHuz32RaoBc3vWLZ9UrVKMCwcMgAaZePsQ4/nimA2jkANk19haQv3bOWqG6yhBQxzOsAr Lfg6ReDDZPOFoJBvDvnuFtauJyjzThc= X-MC-Unique: Xv60WpmRNCe-lnI_Jfu1Ag-1 X-Mimecast-MFC-AGG-ID: Xv60WpmRNCe-lnI_Jfu1Ag_1789047035 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:29:59 +0400 Subject: [GIT PULL 04/24] virtio-gpu/virgl: free BHs and timers on renderer reset MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-4-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , "Michael S. Tsirkin" X-Developer-Signature: v=1; a=openpgp-sha256; l=1353; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=pjazvMH3OTm4G/gkcv4HVSFx91Q4hZxlcUF0x0N0LS8=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDbFzvr5aOPCondX5x3+RYdECq6ApO299KBz B9xZBvA1ZaJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw2wAKCRDa6OEJdZac 5Vx0EACpvGUrBpoLga/bHPvY/hHNVWfSeG5cesMW3pKNr9RL6Kg7PbtwyZDIbCV9wv52eCHgzXi I9rnISNwJQeoiLZErMFSi1HsfzCpOKJJWLERPvCGw1PkjLrlReh2Y/FIiMApriJyNoXwUxBiDed gWIbwg2Q35ZHM3ZA6ExJ67I9+GpMgLQG6gvJq2cf9DQ0BSEEiaYC3Lnkd7lBdOKDz+Pd1cbamSA eS3RNYAaTxN90gygH6uwGEDav9RFop3KPTerYrzbeAAaiNHFbceIcEzLrbu3UeGbtpEhCs1+5Uk YcFcO5OB2FgbJBwv+a1J16XTdDxwHu1G81rzxR7HaugobxYwlxUgv90C3tiDAIGRxHQnSV8ZT3b rH7Fw0dHAiKTMORQQAZOXU+L2JJVJprqCiqgBGTMKtgraJ+S1P/mIxTZ4JDdwC6Q0aGbB7aOh2T mJGoG6bOk9H36AvdTFXcg0RvEHV6QcTPDlMM/9RaJq0n37ZRUUoR2NDiFQzJSQ5PIGwL7q6OuGO e5iEVIwMRvSoex5EOWAH6UIKsVmFP45AHhRNPc1NE30TBqFKnQiQ0mUP3EpSFNUB1qtKMyi1s3Z eSz5mOCm8InOewD4eS4VrcTX7UYSvUkIZe8PEfodjXEXkXsIBxRmBZaRKsWzdTHB3dqAMwVN1p/ 0o+C76jH6tmhSMw== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1789047134206158500 virtio_gpu_virgl_reset() does not free the bottom halves or timers allocated by the previous virtio_gpu_virgl_init() call. A subsequent virtio_gpu_virgl_init() overwrites the old pointers, leaking the previous allocations. Fixes: 7e688d1bf515 ("virtio-gpu: Handle virtio_gpu_virgl_init() failure") Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/display/virtio-gpu-virgl.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 742d9dde4a32..7f1d1e0c3276 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -1430,6 +1430,7 @@ void virtio_gpu_virgl_reset_scanout(VirtIOGPU *g) =20 static bool virtio_gpu_virgl_reset(VirtIOGPU *g) { + VirtIOGPUGL *gl =3D VIRTIO_GPU_GL(g); struct virtio_gpu_simple_resource *res, *tmp; =20 /* @@ -1448,6 +1449,11 @@ static bool virtio_gpu_virgl_reset(VirtIOGPU *g) =20 virtio_gpu_virgl_reset_async_fences(g); =20 + g_clear_pointer(&gl->cmdq_resume_bh, qemu_bh_delete); + g_clear_pointer(&gl->async_fence_bh, qemu_bh_delete); + g_clear_pointer(&gl->print_stats, timer_free); + g_clear_pointer(&gl->fence_poll, timer_free); + return true; } =20 --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047099; cv=none; d=zohomail.com; s=zohoarc; b=SreifUB1VrcebqRttZ9jNlZ8rYDVg7qiiZy+NqmJDQg9p8c8i7CXv6Qbriyg31DczpnOoeFGBzXaR7oBkhGWQqTiS2JxKGvZ0R9Aa6LQYxCnRDM7ggoJl/gc78DW6gLFWZmGvWXgCb2BMaMGqh2z2iN+F0UCtpPOXg6kZgb6Mu0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047099; 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=oTwr7eiOmBFT4ak8x97KiBe6gCvMvmT8l8RQTmrq2YU=; b=Vr1bEK47uRgqpV8BOBgocnZrfszeWTNc04W526Pzk4i/R3D+QDyFdvBMZdNezsyZvvNT68q3DLHF129N43Ca1zN6j+BY0d8bivRowNF0cdttBtcXrCPuFdtidjPHQLvGq/iPv7M6YPK2quf3GQtns8gLzCT6iEAX7wWmo9aJbWI= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047099454695.6862409606239; Thu, 10 Sep 2026 06:31:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4erX-00029Z-VK; Thu, 10 Sep 2026 09:30:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4erW-000294-5v for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:30:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4erU-0003dX-PU for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:30:45 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-112-jdmeCGHkONG5dfuorrXYvQ-1; Thu, 10 Sep 2026 09:30:40 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 76249180062C; Thu, 10 Sep 2026 13:30:39 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A8A411956040; Thu, 10 Sep 2026 13:30:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047044; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oTwr7eiOmBFT4ak8x97KiBe6gCvMvmT8l8RQTmrq2YU=; b=hS+9ymXoGQlj/D+79DUT6+2b0ZPaCVe27ndo+b6ICt4d7sQCi1vHDSrvTN5hYmNctLXPuh /MRSozE/cUfzOxvYxkP8aGpaDFXt6KuHNNGmvr8gHfbdxVS7XtAuulkyMsvXyyKZnNG1Z4 iud5KhIbqzUWZvFIzQNYp7eVtbLAKxE= X-MC-Unique: jdmeCGHkONG5dfuorrXYvQ-1 X-Mimecast-MFC-AGG-ID: jdmeCGHkONG5dfuorrXYvQ_1789047039 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:30:00 +0400 Subject: [GIT PULL 05/24] hw/display/virtio-gpu: set share_handle for udmabuf blob resources MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-5-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , "Michael S. Tsirkin" X-Developer-Signature: v=1; a=openpgp-sha256; l=1529; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=uiiPrlH+Ljd7fNaQGlC+cwmjR9XSCfSA45QXLM5Je68=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDc+/nyHjjwd06Y4ln7nzFXOgghazR/BjnKw s8liIysuJaJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw3AAKCRDa6OEJdZac 5b63D/9elAzBJhqw343+hywmFAUbmIXehUSNl6SrplKH/a9p0zIzS5m05AYorJks1yhi27egkhQ sH1jwwTyTBIvU19aOswzqzCEyRels4w1mA46kNQJGdYgphvR3PG15Clhs1NU1cWjdoL6k8UW0LM 5k1i6UI9FnI2eGxqrwmkBoFB1JYUlFMECiHD8bQv3u94ktlKjrzCwkzxiCy7ETe6TUdgMuCXJ7K oJ9WhD27LLL9qnDEzKdLL0/WOxKmQ912q+4Y98hElKzGow3ujzQS+RTQVf3ugXqt+YnENkFoKVr YabcWNybULkx0nWxnO1/CF8f36McaJO6A556qcgLlZ4jrt9ahzaxFGTVdMuki4tWeXZ8RbiV0YU i4b3rcU7uJ/omZfF23gE2bBfmyVRAX+N565gKNi+u4XYuK7XKSD0bGb5a9zO2bhCjidHSxmTOhL UlU2APBVsIKsSXLn/hObtsQdjYMhwI2oPNb+R7L12KNbGmDzSgs7a2F0U9c6KTMJcWPxsU2N8VX rh3/PxO1nKRljK97pjF17UgX84LD86+/fLcgoJKT7clRe8IkoHZezZZQ4lwlQZIiPLsMtT0I6Of If0aaLrZ1k0AC7uEH77vBPSZVG1h23TNZTBlUknXaJ3M7eotAMjGa4NWIxcBMn6FhcFYSg+qq9R 4o99TIy+91zLqdw== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1789047101994158501 Set share_handle to the dmabuf fd after successful udmabuf creation, and reset it to SHAREABLE_NONE on teardown. Fixes: 5f899c34af1d ("virtio-gpu: allocate shareable 2d resources on !win32= ") Reviewed-by: Akihiko Odaki Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/display/virtio-gpu-udmabuf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabu= f.c index 03f0b29754e1..fc63f2c4ec21 100644 --- a/hw/display/virtio-gpu-udmabuf.c +++ b/hw/display/virtio-gpu-udmabuf.c @@ -91,6 +91,7 @@ static void virtio_gpu_destroy_udmabuf(struct virtio_gpu_= simple_resource *res) if (res->dmabuf_fd >=3D 0) { close(res->dmabuf_fd); res->dmabuf_fd =3D -1; + res->share_handle =3D SHAREABLE_NONE; } res->blob =3D NULL; } @@ -150,6 +151,7 @@ bool virtio_gpu_init_udmabuf(struct virtio_gpu_simple_r= esource *res) virtio_gpu_destroy_udmabuf(res); return false; } + res->share_handle =3D res->dmabuf_fd; pdata =3D res->remapped; } =20 @@ -183,6 +185,7 @@ void virtio_gpu_fini_udmabuf(VirtIOGPU *g, struct virti= o_gpu_simple_resource *re res->dmabuf_fd !=3D -1) { qemu_dmabuf_close(dmabuf->buf); res->dmabuf_fd =3D -1; + res->share_handle =3D SHAREABLE_NONE; } } =20 --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047117; cv=none; d=zohomail.com; s=zohoarc; b=aAzcT7E0dPJu4Jccfj67FIs0Ds7dhIjPL1S6O0LyGYZmA5qTgTLZCv6NjxJSwt089BUgn/noOVhsPAbZOAdb+O3wXCtQ4YLK2UFzoqcTeZgnkuu5ptmHdDA2rY1oGrCatF2F8rA5G1UrEy3XkHR6j5evsQXKVr38GOuSOkCMYxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047117; 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=XfKFdFJfcbMoiYxQvXfquedqLV/zBY+cdNQGkjppDZw=; b=QjixNhgJ4KiwAYDD9B7cAogvfiIM+p7NbJqhyK6/V0EqbpmhBF/YAh6PWRWV9vDTV3EMvLMvlxkN71JU7EBTORljxWpsT4S9L6pId6qXV7BlwToYpTjgozTCmLwhUFtcS/DiSo2tDtIli/ArDn4Igo20FP6wO2yEONdsqsDo1ek= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047117553329.0566673862361; Thu, 10 Sep 2026 06:31:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4erd-0002D7-Ft; Thu, 10 Sep 2026 09:30:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4erb-0002Ce-SF for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:30:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4erZ-0003dt-LA for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:30:51 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-379-PtDEEKPAMzyojvDOmo2jsw-1; Thu, 10 Sep 2026 09:30:45 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 562DE195420D; Thu, 10 Sep 2026 13:30:44 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3EA8B30002C7; Thu, 10 Sep 2026 13:30:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XfKFdFJfcbMoiYxQvXfquedqLV/zBY+cdNQGkjppDZw=; b=NRwIuVPvsq0WbB9galThlpz5UFFAlatwNU3AmfQ/suTELPHb2gltALmeATEGK39O9ncQ+H nRVWjg9xcNHNavc8BqLX0Bq5qihkQyJ1sOmnJdm6b6dgg1j3667kXr+oA0xjTOyaI/Frjw 9vEn1qesBumnKm8Kq1TBMRRTL0FJ/r8= X-MC-Unique: PtDEEKPAMzyojvDOmo2jsw-1 X-Mimecast-MFC-AGG-ID: PtDEEKPAMzyojvDOmo2jsw_1789047044 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:30:01 +0400 Subject: [GIT PULL 06/24] ui/gtk: move GL fence tracking from QemuDmaBuf to VirtualGfxConsole MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-6-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=12750; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=GrLY66SgcaNrIHDQCb0KBFVORGuSE1UuoSZdIHkQTbg=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDcTxGe8cZAlGXUm3Hm1DrIUK1cRyrjix2pJ qsmJPR7m6SJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw3AAKCRDa6OEJdZac 5b2fD/9+EhRPqG3GDDEYnxjlL9EOC95ohs+viiHrACafLefJgaHo5v0RJfVjT57tds52CD/FB94 t7X8buEYpM1teqtZCMrOTK6nIMeI6dtLVmePDCVRQQhNMpvxwRr5jSgKAsgBZSlItojVgzOiYlJ kKGqY8+IRCFSIvFURGe7NZ5h2+uEmlbEiNRaXh5sNao68u4uHgNKfDDRzmXnBlz2v49rU+SAe2t GBahtKonK+Bdo5d3qA46TnsSDy3luV0/q6zHSe9UGIp1KmE4/OczNPwXb2XNbdlanHNSRUAFgv4 Gss/QhZNXs/AB9vRvhIvQ4KOYNAIzRToWHgzHo6FQEZHLO3RBKoj8JsgBwbBxayMRwt8nZjJKXT gVnrw2fkNuULHDbsoea+bTtpB9jAgjo3FCVmVYWqkOGDxXc1WkuCiAYkafYnLl8ZtL+7tchHeFL L/dMUbYegYweGxtpGo37LIjWRdw7RepXu+3Hf9Y1s54kVpd18Xqv3FmPom/sPuB5WtEbWUR/tds s8f+Q5PUMobsBhGFlpLQPmpcEGB7aVh3+v4LJ6inxyyHfRv+w6mYyUaEiIqFdS2GMABQYGV5x+w MUmov4q3bVglJj+qfEpxpzDqb3UPSNs/DY/A1Q6pn4gmXOLnsyUcRy0Q2Jz4I7l6T/yZK/6kA4t gjQF/D7yxNGDcyA== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1789047118227158500 The sync and fence_fd fields on QemuDmaBuf are only used by the GTK display backend for GPU fence synchronization during draw. They are not intrinsic properties of the DMA-BUF itself but transient GL state tied to the display listener. Move fence_fd to VirtualGfxConsole and keep the EGL sync local to the draw operation. Change egl_dmabuf_create_sync() and egl_dmabuf_create_fence() to return values instead of storing them on the dmabuf. This makes the fence lifecycle independent of the dmabuf lifetime. Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/dmabuf.h | 4 ---- include/ui/egl-helpers.h | 4 ++-- include/ui/gtk.h | 8 +++++--- ui/dmabuf.c | 29 ----------------------------- ui/egl-helpers.c | 15 ++++++++------- ui/gtk-egl.c | 30 ++++++++++++++++-------------- ui/gtk-gl-area.c | 12 +++--------- ui/gtk.c | 31 +++++++++++++++++++++++-------- 8 files changed, 57 insertions(+), 76 deletions(-) diff --git a/include/ui/dmabuf.h b/include/ui/dmabuf.h index 3decdca4979c..381583bd536c 100644 --- a/include/ui/dmabuf.h +++ b/include/ui/dmabuf.h @@ -41,13 +41,9 @@ uint32_t qemu_dmabuf_get_y(QemuDmaBuf *dmabuf); uint32_t qemu_dmabuf_get_backing_width(QemuDmaBuf *dmabuf); uint32_t qemu_dmabuf_get_backing_height(QemuDmaBuf *dmabuf); bool qemu_dmabuf_get_y0_top(QemuDmaBuf *dmabuf); -void *qemu_dmabuf_get_sync(QemuDmaBuf *dmabuf); -int32_t qemu_dmabuf_get_fence_fd(QemuDmaBuf *dmabuf); bool qemu_dmabuf_get_allow_fences(QemuDmaBuf *dmabuf); bool qemu_dmabuf_get_draw_submitted(QemuDmaBuf *dmabuf); void qemu_dmabuf_set_texture(QemuDmaBuf *dmabuf, uint32_t texture); -void qemu_dmabuf_set_fence_fd(QemuDmaBuf *dmabuf, int32_t fence_fd); -void qemu_dmabuf_set_sync(QemuDmaBuf *dmabuf, void *sync); void qemu_dmabuf_set_draw_submitted(QemuDmaBuf *dmabuf, bool draw_submitte= d); =20 #endif diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index 679c79eacd54..533d9afc37ba 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -54,8 +54,8 @@ bool egl_dmabuf_export_texture(uint32_t tex_id, int *fd, = EGLint *offset, =20 void egl_dmabuf_import_texture(QemuDmaBuf *dmabuf); void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf); -void egl_dmabuf_create_sync(QemuDmaBuf *dmabuf); -void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf); +EGLSyncKHR egl_create_sync(void); +int egl_create_fence(EGLSyncKHR sync); =20 #endif =20 diff --git a/include/ui/gtk.h b/include/ui/gtk.h index 5c9c34a069ea..4b4ef50e3701 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -58,6 +58,7 @@ typedef struct VirtualGfxConsole { bool y0_top; bool scanout_mode; bool has_dmabuf; + int gl_fence_fd; #endif } VirtualGfxConsole; =20 @@ -160,7 +161,7 @@ extern bool gtk_use_gl_area; /* ui/gtk.c */ void gd_update_windowsize(VirtualConsole *vc); void gd_update_monitor_refresh_rate(VirtualConsole *vc, GtkWidget *widget); -void gd_hw_gl_flushed(void *vc); +void gd_gl_wait_sync(VirtualConsole *vc, void *sync); =20 /* ui/gtk-egl.c */ void gd_egl_init(VirtualConsole *vc); @@ -190,8 +191,9 @@ void gd_egl_cursor_position(DisplayChangeListener *dcl, uint32_t pos_x, uint32_t pos_y); void gd_egl_flush(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t h); -void gd_egl_scanout_flush(DisplayChangeListener *dcl, - uint32_t x, uint32_t y, uint32_t w, uint32_t h); +void *gd_egl_scanout_flush(DisplayChangeListener *dcl, + uint32_t x, uint32_t y, + uint32_t w, uint32_t h); void gtk_egl_init(DisplayGLMode mode); int gd_egl_make_current(DisplayGLCtx *dgc, QEMUGLContext ctx); diff --git a/ui/dmabuf.c b/ui/dmabuf.c index 7433a268f0df..b61dc7ad2783 100644 --- a/ui/dmabuf.c +++ b/ui/dmabuf.c @@ -25,8 +25,6 @@ struct QemuDmaBuf { uint32_t backing_width; uint32_t backing_height; bool y0_top; - void *sync; - int fence_fd; bool allow_fences; bool draw_submitted; }; @@ -57,7 +55,6 @@ QemuDmaBuf *qemu_dmabuf_new(uint32_t width, uint32_t heig= ht, memcpy(dmabuf->fd, dmabuf_fd, num_planes * sizeof(*dmabuf_fd)); dmabuf->allow_fences =3D allow_fences; dmabuf->y0_top =3D y0_top; - dmabuf->fence_fd =3D -1; dmabuf->num_planes =3D num_planes; =20 return dmabuf; @@ -208,20 +205,6 @@ bool qemu_dmabuf_get_y0_top(QemuDmaBuf *dmabuf) return dmabuf->y0_top; } =20 -void *qemu_dmabuf_get_sync(QemuDmaBuf *dmabuf) -{ - assert(dmabuf !=3D NULL); - - return dmabuf->sync; -} - -int32_t qemu_dmabuf_get_fence_fd(QemuDmaBuf *dmabuf) -{ - assert(dmabuf !=3D NULL); - - return dmabuf->fence_fd; -} - bool qemu_dmabuf_get_allow_fences(QemuDmaBuf *dmabuf) { assert(dmabuf !=3D NULL); @@ -242,18 +225,6 @@ void qemu_dmabuf_set_texture(QemuDmaBuf *dmabuf, uint3= 2_t texture) dmabuf->texture =3D texture; } =20 -void qemu_dmabuf_set_fence_fd(QemuDmaBuf *dmabuf, int32_t fence_fd) -{ - assert(dmabuf !=3D NULL); - dmabuf->fence_fd =3D fence_fd; -} - -void qemu_dmabuf_set_sync(QemuDmaBuf *dmabuf, void *sync) -{ - assert(dmabuf !=3D NULL); - dmabuf->sync =3D sync; -} - void qemu_dmabuf_set_draw_submitted(QemuDmaBuf *dmabuf, bool draw_submitte= d) { assert(dmabuf !=3D NULL); diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index 8e3729a54d15..cb9c1e839cf9 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -432,7 +432,7 @@ void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf) qemu_dmabuf_set_texture(dmabuf, 0); } =20 -void egl_dmabuf_create_sync(QemuDmaBuf *dmabuf) +EGLSyncKHR egl_create_sync(void) { EGLSyncKHR sync; =20 @@ -443,23 +443,24 @@ void egl_dmabuf_create_sync(QemuDmaBuf *dmabuf) sync =3D eglCreateSyncKHR(qemu_egl_display, EGL_SYNC_NATIVE_FENCE_ANDROID, NULL); if (sync !=3D EGL_NO_SYNC_KHR) { - qemu_dmabuf_set_sync(dmabuf, sync); + return sync; } } + + return NULL; } =20 -void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf) +int egl_create_fence(EGLSyncKHR sync) { - void *sync =3D qemu_dmabuf_get_sync(dmabuf); - int fence_fd; + int fence_fd =3D -1; =20 if (sync) { fence_fd =3D eglDupNativeFenceFDANDROID(qemu_egl_display, sync); - qemu_dmabuf_set_fence_fd(dmabuf, fence_fd); eglDestroySyncKHR(qemu_egl_display, sync); - qemu_dmabuf_set_sync(dmabuf, NULL); } + + return fence_fd; } =20 #endif /* CONFIG_GBM */ diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index adc81f34b1c8..c671aabd11b3 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -68,7 +68,7 @@ void gd_egl_draw(VirtualConsole *vc) GdkWindow *window; #ifdef CONFIG_GBM QemuDmaBuf *dmabuf =3D vc->gfx.guest_fb.dmabuf; - int fence_fd; + EGLSyncKHR sync; #endif int ww, wh, pw, ph, gs; =20 @@ -94,7 +94,11 @@ void gd_egl_draw(VirtualConsole *vc) qemu_console_hw_gl_block(vc->gfx.dcl.con, true); } #endif - gd_egl_scanout_flush(&vc->gfx.dcl, 0, 0, vc->gfx.w, vc->gfx.h); +#ifdef CONFIG_GBM + sync =3D +#endif + gd_egl_scanout_flush(&vc->gfx.dcl, 0, 0, + vc->gfx.w, vc->gfx.h); =20 gd_update_scale(vc, ww, wh, surface_width(vc->gfx.ds), @@ -103,13 +107,7 @@ void gd_egl_draw(VirtualConsole *vc) glFlush(); #ifdef CONFIG_GBM if (dmabuf) { - egl_dmabuf_create_fence(dmabuf); - fence_fd =3D qemu_dmabuf_get_fence_fd(dmabuf); - if (fence_fd >=3D 0) { - qemu_set_fd_handler(fence_fd, gd_hw_gl_flushed, NULL, vc); - return; - } - qemu_console_hw_gl_block(vc->gfx.dcl.con, false); + gd_gl_wait_sync(vc, sync); } #endif } else { @@ -330,10 +328,12 @@ void gd_egl_cursor_position(DisplayChangeListener *dc= l, vc->gfx.cursor_y =3D pos_y * vc->gfx.scale_y; } =20 -void gd_egl_scanout_flush(DisplayChangeListener *dcl, - uint32_t x, uint32_t y, uint32_t w, uint32_t h) +EGLSyncKHR gd_egl_scanout_flush(DisplayChangeListener *dcl, + uint32_t x, uint32_t y, + uint32_t w, uint32_t h) { VirtualConsole *vc =3D container_of(dcl, VirtualConsole, gfx.dcl); + EGLSyncKHR sync =3D EGL_NO_SYNC_KHR; GdkWindow *window; int px_offset, py_offset; int gs; @@ -342,10 +342,10 @@ void gd_egl_scanout_flush(DisplayChangeListener *dcl, int fbw, fbh; =20 if (!vc->gfx.scanout_mode) { - return; + return sync; } if (!vc->gfx.guest_fb.framebuffer) { - return; + return sync; } =20 eglMakeCurrent(qemu_egl_display, vc->gfx.esurface, @@ -391,11 +391,13 @@ void gd_egl_scanout_flush(DisplayChangeListener *dcl, =20 #ifdef CONFIG_GBM if (vc->gfx.guest_fb.dmabuf) { - egl_dmabuf_create_sync(vc->gfx.guest_fb.dmabuf); + sync =3D egl_create_sync(); } #endif =20 eglSwapBuffers(qemu_egl_display, vc->gfx.esurface); + + return sync; } =20 void gd_egl_flush(DisplayChangeListener *dcl, diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index 29497019ee46..29d1b1e4116f 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -41,6 +41,7 @@ void gd_gl_area_draw(VirtualConsole *vc) { #ifdef CONFIG_GBM QemuDmaBuf *dmabuf =3D vc->gfx.guest_fb.dmabuf; + EGLSyncKHR sync =3D EGL_NO_SYNC_KHR; #endif int pw, ph, gs, y1, y2; int ww, wh; @@ -119,20 +120,13 @@ void gd_gl_area_draw(VirtualConsole *vc) GL_COLOR_BUFFER_BIT, GL_NEAREST); #ifdef CONFIG_GBM if (dmabuf) { - egl_dmabuf_create_sync(dmabuf); + sync =3D egl_create_sync(); } #endif glFlush(); #ifdef CONFIG_GBM if (dmabuf) { - int fence_fd; - egl_dmabuf_create_fence(dmabuf); - fence_fd =3D qemu_dmabuf_get_fence_fd(dmabuf); - if (fence_fd >=3D 0) { - qemu_set_fd_handler(fence_fd, gd_hw_gl_flushed, NULL, vc); - return; - } - qemu_console_hw_gl_block(vc->gfx.dcl.con, false); + gd_gl_wait_sync(vc, sync); } #endif } else { diff --git a/ui/gtk.c b/ui/gtk.c index 7078d89d6797..1c75b9ea3c4d 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -597,21 +597,32 @@ static void gd_gl_release_dmabuf(DisplayChangeListene= r *dcl, #endif } =20 -void gd_hw_gl_flushed(void *vcon) +#ifdef CONFIG_GBM +static void gd_gl_fence_cb(void *vcon) { VirtualConsole *vc =3D vcon; - QemuDmaBuf *dmabuf =3D vc->gfx.guest_fb.dmabuf; - int fence_fd; =20 - fence_fd =3D qemu_dmabuf_get_fence_fd(dmabuf); - if (fence_fd >=3D 0) { - qemu_set_fd_handler(fence_fd, NULL, NULL, NULL); - close(fence_fd); - qemu_dmabuf_set_fence_fd(dmabuf, -1); + if (vc->gfx.gl_fence_fd >=3D 0) { + qemu_set_fd_handler(vc->gfx.gl_fence_fd, NULL, NULL, NULL); + g_clear_fd(&vc->gfx.gl_fence_fd, NULL); qemu_console_hw_gl_block(vc->gfx.dcl.con, false); } } =20 +void gd_gl_wait_sync(VirtualConsole *vc, EGLSyncKHR sync) +{ + assert(vc->gfx.gl_fence_fd < 0); + + vc->gfx.gl_fence_fd =3D egl_create_fence(sync); + if (vc->gfx.gl_fence_fd >=3D 0) { + qemu_set_fd_handler(vc->gfx.gl_fence_fd, + gd_gl_fence_cb, NULL, vc); + } else { + qemu_console_hw_gl_block(vc->gfx.dcl.con, false); + } +} +#endif + /** DisplayState Callbacks (opengl version) **/ =20 static const DisplayChangeListenerOps dcl_gl_area_ops =3D { @@ -2355,6 +2366,7 @@ add_gfx_console(GtkDisplayState *s, QemuConsole *con) vc->gfx.scale_y =3D vc->gfx.preferred_scale; =20 #if defined(CONFIG_OPENGL) + vc->gfx.gl_fence_fd =3D -1; if (display_opengl) { if (gtk_use_gl_area) { vc->gfx.drawing_area =3D gtk_gl_area_new(); @@ -2647,6 +2659,9 @@ static void gd_vc_free(void *p) =20 switch (vc->type) { case GD_VC_GFX: +#if defined(CONFIG_OPENGL) && defined(CONFIG_GBM) + gd_gl_fence_cb(vc); +#endif qemu_console_unregister_listener(&vc->gfx.dcl); #if defined(CONFIG_OPENGL) if (display_opengl) { --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047075; cv=none; d=zohomail.com; s=zohoarc; b=du/qAoMDO8Evmqod0TPTwfuihMTCQxvtwi4uLPun0R9p9BRkV7+MjsC2pbzzF5mztDeRpnbKXk3l9f7wYvcnKERtyeZVBDAd62sVBpLocDZbkJoz+0ASHmKA0N44HXKA8o9GKj1RekNaD7S4drK3qtzyLADMkkdJp9bJGmh5X5g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047075; 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=O82sAP5Hj+bGeZK3beOKC9TNFaKpvhY6RCKuJLTbO1I=; b=kpLVcYLq5cHiD9FWFJhr/k6nxvwHw7vlbhbtEjes8gZ+9WykFY9VY2Dt0YoNXyneMISLXZLmM80lcXP/ODCKBnX7/ETae+uZoqlYpbZtu6L8NsAQiZtaWrsKWkn/6anJcbqF626zEzP/NH+1lew7tlZFb3DTXmYTxQjltG8IbYI= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17890470755714.794956755942735; Thu, 10 Sep 2026 06:31:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4erh-0002Wt-L6; Thu, 10 Sep 2026 09:30:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4erg-0002NU-23 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:30:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4ere-0003e7-9G for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:30:55 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-351-IGcTVQc7McGly9wsvkziLQ-1; Thu, 10 Sep 2026 09:30:49 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E394C195419B; Thu, 10 Sep 2026 13:30:48 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E00DF1956095; Thu, 10 Sep 2026 13:30:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047053; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O82sAP5Hj+bGeZK3beOKC9TNFaKpvhY6RCKuJLTbO1I=; b=DfzxiQgsqYW4gKrzEylNJfcUkRWqE4Q+1qmRuXIO62br3DLeKC+NGyJmUsqID8NaQJFVBI kDBwXSdgJjqdAxA9bd5AOEFKqJzNorjTigmqbS+mzPEhSTbdNPRh10V9a04bi2mIMuxBtm KDB8EyZiY9wjyRSRnIeXJ4wokHoKBaI= X-MC-Unique: IGcTVQc7McGly9wsvkziLQ-1 X-Mimecast-MFC-AGG-ID: IGcTVQc7McGly9wsvkziLQ_1789047049 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:30:02 +0400 Subject: [GIT PULL 07/24] ui/gtk: move draw_submitted from QemuDmaBuf to VirtualGfxConsole MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-7-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=6254; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=gBqWaKJgA4/yz9sjt8xtm7yhbFIUll6dO32lThJ4IRw=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDcESJBmGuNqOKrVWeLn/G+T98Ma18gNuBZ7 Bcqo7f8gryJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw3AAKCRDa6OEJdZac 5U1oD/45xB/b0KjpffrY1sUyIqdS+E96TAQeAzZEkhaGj/jrR9v9S9RDwDMVVEQz0OPbAigQrse qlIc0ya28UY9Xtg9MVdf/zFzEquvwnBIOJ1Us6HAm48XrlUz01DaSe01KSg6IrdhaSH1GUQWYgB th15mC9REZWlVkDF2aD7fgLqLd+W17cmFhGy4hZdX/VIW8dZDfI+IZUYk+dlT+jN6fO1C2Vq3BT VaQm1cZCnwUmPA/PIQZyxnjzb0hhK6GIb8v/6JXSAF1L6buBDXLYL3bX3Q4XsfkBAPKjFZJxXWg NU99dP4Xs5bJhm+l8y1L53/ix1pbQHKgaSDP7WnCwAm7BJzOY6DcvRkSO5JKxlzD55Bq3jZkfZ/ 0Y7plyuK76fLfAcc9eJ+quoTFYzGE2plJUaXt2T5unYoaEoZV1z3q6FBa4ICvqix2cjt+390BAi s1BmM/MDPXbIrRG8BbDbEvyzG+VTBthYNQa4vBIg5qvShBDdtUIHZNEivuQ9BMm/uTYv/FDGucL Z2+/y4yQ5ldrbPHf8JXnMuk2Us7duZ9t+l513NDeK1Y2Frmg3SfTRG5BJKY8n0uWWHLI5IpDWOA xUWC2/6aQLeF5TyJ0ti1tqVxgDJtwsK4OyjLfjK9kddYKUjpAuXPInMoel3gZY7/cU5hmHd14b0 UotBI4/zX+v3DDg== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1789047077793158500 The draw_submitted flag on QemuDmaBuf is only used by the GTK display backend to gate the draw pipeline and prevent gl_block refcount imbalance when the guest submits frames faster than GTK draws them. It is not an intrinsic property of the DMA-BUF but transient display listener state. Move it to VirtualGfxConsole, replacing the getter/setter calls with direct struct member access. Reset the flag when the active dmabuf is released in gd_gl_release_dmabuf(). Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/dmabuf.h | 2 -- include/ui/gtk.h | 1 + ui/dmabuf.c | 14 -------------- ui/gtk-egl.c | 13 ++++++------- ui/gtk-gl-area.c | 10 +++++----- ui/gtk.c | 1 + 6 files changed, 13 insertions(+), 28 deletions(-) diff --git a/include/ui/dmabuf.h b/include/ui/dmabuf.h index 381583bd536c..b972099859f2 100644 --- a/include/ui/dmabuf.h +++ b/include/ui/dmabuf.h @@ -42,8 +42,6 @@ uint32_t qemu_dmabuf_get_backing_width(QemuDmaBuf *dmabuf= ); uint32_t qemu_dmabuf_get_backing_height(QemuDmaBuf *dmabuf); bool qemu_dmabuf_get_y0_top(QemuDmaBuf *dmabuf); bool qemu_dmabuf_get_allow_fences(QemuDmaBuf *dmabuf); -bool qemu_dmabuf_get_draw_submitted(QemuDmaBuf *dmabuf); void qemu_dmabuf_set_texture(QemuDmaBuf *dmabuf, uint32_t texture); -void qemu_dmabuf_set_draw_submitted(QemuDmaBuf *dmabuf, bool draw_submitte= d); =20 #endif diff --git a/include/ui/gtk.h b/include/ui/gtk.h index 4b4ef50e3701..b66b9ca5c519 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -59,6 +59,7 @@ typedef struct VirtualGfxConsole { bool scanout_mode; bool has_dmabuf; int gl_fence_fd; + bool draw_submitted; #endif } VirtualGfxConsole; =20 diff --git a/ui/dmabuf.c b/ui/dmabuf.c index b61dc7ad2783..495270f29bd6 100644 --- a/ui/dmabuf.c +++ b/ui/dmabuf.c @@ -26,7 +26,6 @@ struct QemuDmaBuf { uint32_t backing_height; bool y0_top; bool allow_fences; - bool draw_submitted; }; =20 QemuDmaBuf *qemu_dmabuf_new(uint32_t width, uint32_t height, @@ -212,21 +211,8 @@ bool qemu_dmabuf_get_allow_fences(QemuDmaBuf *dmabuf) return dmabuf->allow_fences; } =20 -bool qemu_dmabuf_get_draw_submitted(QemuDmaBuf *dmabuf) -{ - assert(dmabuf !=3D NULL); - - return dmabuf->draw_submitted; -} - void qemu_dmabuf_set_texture(QemuDmaBuf *dmabuf, uint32_t texture) { assert(dmabuf !=3D NULL); dmabuf->texture =3D texture; } - -void qemu_dmabuf_set_draw_submitted(QemuDmaBuf *dmabuf, bool draw_submitte= d) -{ - assert(dmabuf !=3D NULL); - dmabuf->draw_submitted =3D draw_submitted; -} diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index c671aabd11b3..8623181336e9 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -86,10 +86,10 @@ void gd_egl_draw(VirtualConsole *vc) if (vc->gfx.scanout_mode) { #ifdef CONFIG_GBM if (dmabuf) { - if (!qemu_dmabuf_get_draw_submitted(dmabuf)) { + if (!vc->gfx.draw_submitted) { return; } else { - qemu_dmabuf_set_draw_submitted(dmabuf, false); + vc->gfx.draw_submitted =3D false; } qemu_console_hw_gl_block(vc->gfx.dcl.con, true); } @@ -169,8 +169,7 @@ void gd_egl_refresh(DisplayChangeListener *dcl) #endif } =20 - if (vc->gfx.guest_fb.dmabuf && - qemu_dmabuf_get_draw_submitted(vc->gfx.guest_fb.dmabuf)) { + if (vc->gfx.guest_fb.dmabuf && vc->gfx.draw_submitted) { gd_egl_draw(vc); return; } @@ -290,6 +289,7 @@ void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl, =20 if (qemu_dmabuf_get_allow_fences(dmabuf)) { vc->gfx.guest_fb.dmabuf =3D dmabuf; + vc->gfx.draw_submitted =3D false; } #endif } @@ -406,9 +406,8 @@ void gd_egl_flush(DisplayChangeListener *dcl, VirtualConsole *vc =3D container_of(dcl, VirtualConsole, gfx.dcl); GtkWidget *area =3D vc->gfx.drawing_area; =20 - if (vc->gfx.guest_fb.dmabuf && - !qemu_dmabuf_get_draw_submitted(vc->gfx.guest_fb.dmabuf)) { - qemu_dmabuf_set_draw_submitted(vc->gfx.guest_fb.dmabuf, true); + if (vc->gfx.guest_fb.dmabuf && !vc->gfx.draw_submitted) { + vc->gfx.draw_submitted =3D true; gtk_egl_set_scanout_mode(vc, true); } =20 diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index 29d1b1e4116f..45c0c8c81a11 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -82,10 +82,10 @@ void gd_gl_area_draw(VirtualConsole *vc) =20 #ifdef CONFIG_GBM if (dmabuf) { - if (!qemu_dmabuf_get_draw_submitted(dmabuf)) { + if (!vc->gfx.draw_submitted) { return; } else { - qemu_dmabuf_set_draw_submitted(dmabuf, false); + vc->gfx.draw_submitted =3D false; } qemu_console_hw_gl_block(vc->gfx.dcl.con, true); } @@ -319,9 +319,8 @@ void gd_gl_area_scanout_flush(DisplayChangeListener *dc= l, { VirtualConsole *vc =3D container_of(dcl, VirtualConsole, gfx.dcl); =20 - if (vc->gfx.guest_fb.dmabuf && - !qemu_dmabuf_get_draw_submitted(vc->gfx.guest_fb.dmabuf)) { - qemu_dmabuf_set_draw_submitted(vc->gfx.guest_fb.dmabuf, true); + if (vc->gfx.guest_fb.dmabuf && !vc->gfx.draw_submitted) { + vc->gfx.draw_submitted =3D true; gtk_gl_area_set_scanout_mode(vc, true); } gtk_gl_area_queue_render(GTK_GL_AREA(vc->gfx.drawing_area)); @@ -356,6 +355,7 @@ void gd_gl_area_scanout_dmabuf(DisplayChangeListener *d= cl, =20 if (qemu_dmabuf_get_allow_fences(dmabuf)) { vc->gfx.guest_fb.dmabuf =3D dmabuf; + vc->gfx.draw_submitted =3D false; } #endif } diff --git a/ui/gtk.c b/ui/gtk.c index 1c75b9ea3c4d..55e45e8445bc 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -593,6 +593,7 @@ static void gd_gl_release_dmabuf(DisplayChangeListener = *dcl, egl_dmabuf_release_texture(dmabuf); if (vc->gfx.guest_fb.dmabuf =3D=3D dmabuf) { vc->gfx.guest_fb.dmabuf =3D NULL; + vc->gfx.draw_submitted =3D false; } #endif } --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047188; cv=none; d=zohomail.com; s=zohoarc; b=jmvEioEb08Px7rooABh++7Wrips0kzRZQIF7nTkqd/6LDFCNFYIUq8k32q4HhwRZrWKpwql6lxmNNfmPhQx2m0pFCGrV2mkvb2RzOYQ9aNfU6SPOZoiBTiRiTqFqyNTGvMr0CwQsR8RZAmn1hyi7J+mXqnS+SNJYwruGWP/cGs8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047188; 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=0aCO0uNFxJDrfHiJBs8AT6lTkMw8C7vlFldvNwsdGSk=; b=k687dgPit0uAMmvZVcCVjz8C8WbuG8Cvvx39qhQw4nHrcaNIkD3tgefJLgSrftV4QwIa+XNX/jfV0VzyOrC3rFgkMzdxT/ZaURzCdugzbBRc5e6YKokbKo1LW7GIEgOsvR5ckR94pQ0pRSTrq9rb7u/Met02A+lltthg2YiCSCA= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047187993720.1638281896579; Thu, 10 Sep 2026 06:33:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4erm-0002ok-Kd; Thu, 10 Sep 2026 09:31:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4erk-0002f0-D9 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4eri-0003eP-GH for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:00 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-466-uqNzxYP4Ne-61opTVjyS2Q-1; Thu, 10 Sep 2026 09:30:54 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9EEDB180057B; Thu, 10 Sep 2026 13:30:53 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 82B223000239; Thu, 10 Sep 2026 13:30:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047057; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0aCO0uNFxJDrfHiJBs8AT6lTkMw8C7vlFldvNwsdGSk=; b=eCBgrXYHjmJJmW4CNq9EsHQhu2M+Z90hWR6tRtgrAAGCZ5H7RLdMzu0QsmIjDxIEjS3zMB Gq5LF2wAkgOczvVpJxT72Oa3ltQ3ZN4eZWDbxwSXLNKDu8MyD9JBdCOHCcZJOs05caR+rE B5AXSEHzmgOnw9nNFj8ysmJ7ErVl9mg= X-MC-Unique: uqNzxYP4Ne-61opTVjyS2Q-1 X-Mimecast-MFC-AGG-ID: uqNzxYP4Ne-61opTVjyS2Q_1789047053 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:30:03 +0400 Subject: [GIT PULL 08/24] ui/dbus: disable scanout iff dmabuf is current MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-8-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=6106; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=gSMT+0AOJarhtVwNErFLIpySAW7A6q8MDifZCjlShj0=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDclzsLpPz/CTkv1Q0K/WuoFHg4ZSf4YLGmW WPwPNf1OtSJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw3AAKCRDa6OEJdZac 5U/2EACJNEXPUYRKERC/yqpGbBroBEww7cS5Qz03GuHnFDnGglCNf8vU8eOY42T9Bg4LP9zyY74 eZ+NgNcYs7Da3BIyTqsUX9xQiLeJLePTKv0iXyckzD4ZKn1eZCC2oRfx75RZ0sGfut4kp2WNeIB Gqwz3N9w/dURX3xL7Y1GPrxWQvmocelNv3NlzulAzpbI35yiY1R+gHnXzJ+4iWcm8Ej8S2AGCC1 2aijB6iSkpyRHrjIf+pCxmoknBTTUEuZ91IZYNrzEBjsZCsBef9bwZa/6QZLJB6SalnJgZzTR3e AzVcqSruYBv7FeqFkQOjADWXiRsoXDbeK/9NG6eZJJa4C97F4go0EpljJX/xcMw0qdycPbIWY8H ZE9ZAeaPslcP0QPZeboeLcrE7aNZFYQb4cKCvwv4LpESJUF5TI1TyFzBhqtf4TlVaGVV8NHH6oh ipwe5uVP9gHN9OXfnpoqk7knGpIQ7ybaPJ+0b/yZDZSKUZLIm5o6XkiAiP0e81nCXfV9obrKGJh PkmiFBCF80S3bXltSxQDIhekH4I/5/2UiHIXct/XyxlZ/UUPYjnyY4aeCWpYJ4vu4lc75ibJgIU 8GnKEl/nFsQDYLtQUs7+LPNHr6k37VR6BDkU3WVUDWoMbtRSGXhe5uyKWiGaHU/T/74le4W0dB1 zq+RzW5mSC9SBVg== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1789047190917158500 Narrows release_dmabuf to the active scanout, as the device & console may interleave new scanouts before releasing old ones. Fixes: 142ca628a733 ("ui: add a D-Bus display backend") Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/dbus-listener.c | 68 ++++++++++++++++++++++++++++++++++++++------------= ---- 1 file changed, 48 insertions(+), 20 deletions(-) diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c index 2e2f6ba4183a..5a72c7eeae59 100644 --- a/ui/dbus-listener.c +++ b/ui/dbus-listener.c @@ -91,6 +91,8 @@ struct _DBusDisplayListener { guint dbus_filter; guint32 display_serial_to_discard; guint32 cursor_serial_to_discard; + + QemuDmaBuf *scanout_dmabuf; }; =20 G_DEFINE_TYPE(DBusDisplayListener, dbus_display_listener, G_TYPE_OBJECT) @@ -119,6 +121,7 @@ static void dbus_scanout_disable(DisplayChangeListener = *dcl) { DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); =20 + ddl->scanout_dmabuf =3D NULL; ddl_discard_display_messages(ddl); =20 qemu_dbus_display1_listener_call_disable( @@ -298,9 +301,9 @@ static void dbus_call_update_gl(DisplayChangeListener *= dcl, =20 #ifdef CONFIG_GBM static void dbus_scanout_dmabuf_v1(DBusDisplayListener *ddl, - QemuDmaBuf *dmabuf) + QemuDmaBuf *dmabuf, + GError **err) { - g_autoptr(GError) err =3D NULL; g_autoptr(GUnixFDList) fd_list =3D NULL; int fd; uint32_t width, height, stride, fourcc; @@ -309,8 +312,7 @@ static void dbus_scanout_dmabuf_v1(DBusDisplayListener = *ddl, =20 fd =3D qemu_dmabuf_get_fds(dmabuf, NULL)[0]; fd_list =3D g_unix_fd_list_new(); - if (g_unix_fd_list_append(fd_list, fd, &err) !=3D 0) { - error_report("Failed to setup dmabuf fdlist: %s", err->message); + if (g_unix_fd_list_append(fd_list, fd, err) !=3D 0) { return; } =20 @@ -332,9 +334,9 @@ static void dbus_scanout_dmabuf_v1(DBusDisplayListener = *ddl, } =20 static void dbus_scanout_dmabuf_v2(DBusDisplayListener *ddl, - QemuDmaBuf *dmabuf) + QemuDmaBuf *dmabuf, + GError **err) { - g_autoptr(GError) err =3D NULL; g_autoptr(GUnixFDList) fd_list =3D NULL; int i, fd_index[DMABUF_MAX_PLANES], num_fds; uint32_t x, y, width, height, fourcc, backing_width, backing_height; @@ -360,9 +362,8 @@ static void dbus_scanout_dmabuf_v2(DBusDisplayListener = *ddl, break; } =20 - fd_index[num_fds] =3D g_unix_fd_list_append(fd_list, plane_fd, &er= r); + fd_index[num_fds] =3D g_unix_fd_list_append(fd_list, plane_fd, err= ); if (fd_index[num_fds] < 0) { - error_report("Failed to setup dmabuf fdlist: %s", err->message= ); return; } } @@ -395,20 +396,36 @@ static void dbus_scanout_dmabuf_v2(DBusDisplayListene= r *ddl, G_DBUS_CALL_FLAGS_NONE, -1, fd_list, NULL, NULL, NULL); } =20 +static bool dbus_call_scanout_dmabuf(DBusDisplayListener *ddl, + QemuDmaBuf *dmabuf) +{ + g_autoptr(GError) err =3D NULL; + + if (ddl->scanout_dmabuf_v2_proxy) { + dbus_scanout_dmabuf_v2(ddl, dmabuf, &err); + } else { + if (qemu_dmabuf_get_num_planes(dmabuf) > 1) { + error_report("Peer does not support multi plane dmabuf"); + return false; + } + dbus_scanout_dmabuf_v1(ddl, dmabuf, &err); + } + + if (err) { + error_report("Failed to scanout dmabuf: %s", err->message); + return false; + } + + return true; +} + static void dbus_scanout_dmabuf(DisplayChangeListener *dcl, QemuDmaBuf *dmabuf) { DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); =20 - if (ddl->scanout_dmabuf_v2_proxy) { - dbus_scanout_dmabuf_v2(ddl, dmabuf); - } else { - if (qemu_dmabuf_get_num_planes(dmabuf) > 1) { - g_debug("org.qemu.Display1.Listener.ScanoutDMABUF " - "does not support mutli plane"); - return; - } - dbus_scanout_dmabuf_v1(ddl, dmabuf); + if (dbus_call_scanout_dmabuf(ddl, dmabuf)) { + ddl->scanout_dmabuf =3D dmabuf; } } #endif /* GBM */ @@ -589,6 +606,10 @@ static void dbus_scanout_texture(DisplayChangeListener= *dcl, uint32_t w, uint32_t h, void *d3d_tex2d) { +#if defined(CONFIG_GBM) || defined(WIN32) + DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); +#endif + trace_dbus_scanout_texture(tex_id, backing_y_0_top, backing_width, backing_height, x, y, w, h); #ifdef CONFIG_GBM @@ -607,13 +628,13 @@ static void dbus_scanout_texture(DisplayChangeListene= r *dcl, backing_height, fourcc, modifier, fd, num_pla= nes, false, backing_y_0_top); =20 - dbus_scanout_dmabuf(dcl, dmabuf); + if (dbus_call_scanout_dmabuf(ddl, dmabuf)) { + ddl->scanout_dmabuf =3D NULL; + } qemu_dmabuf_close(dmabuf); #endif =20 #ifdef WIN32 - DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); - /* there must be a matching gfx_switch before */ assert(surface_width(ddl->ds) =3D=3D w); assert(surface_height(ddl->ds) =3D=3D h); @@ -686,7 +707,14 @@ static void dbus_cursor_dmabuf(DisplayChangeListener *= dcl, static void dbus_release_dmabuf(DisplayChangeListener *dcl, QemuDmaBuf *dmabuf) { + DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); + + if (ddl->scanout_dmabuf !=3D dmabuf) { + return; + } + dbus_scanout_disable(dcl); + ddl->scanout_dmabuf =3D NULL; } #endif /* GBM */ =20 --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047074; cv=none; d=zohomail.com; s=zohoarc; b=ZzxS3z3F6PpM+4DlPLzZ8YOorHTGbS9Fr/mTxTWOeZiJikLF743bQbLuaOhZD1upRcK1/Hf91C2IhEDARVGbcRhACxacbwgIEOwLiL3N1+BAgsTO5sYSMtb4qKIblEQIroyl+gyZvGP/zMm4EPqvw6iHF9FqeUjP1mdEEPROCoU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047074; 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=8eKUMoZq5XV11is/tjts9lB3sVWqkFifCCJ5vtFi2hw=; b=cwuhrdZMTnwPMn2iZrjpWRvj9mvkVCZ5Q0Gs1XPM9HZyJVQup8SVhByJqo606rReiqhNARwkAFKor8+BV5tsGyAv16MOD7umG5RybLrutrrbaYyhkAvavBgRVjVULmLfIWoFWEL4/RqHzrFk2cYKbIC9xJdYOZZIR/lwqMGlquk= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047074760629.309084912005; Thu, 10 Sep 2026 06:31:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4ert-0003GH-9r; Thu, 10 Sep 2026 09:31:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4err-00039e-U2 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4erp-0003fq-S0 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:07 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-474-xgkuTIZTNzqLBRCJ8ok1UQ-1; Thu, 10 Sep 2026 09:31:00 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A681119540CC; Thu, 10 Sep 2026 13:30:58 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 46EE6180034F; Thu, 10 Sep 2026 13:30:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047065; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8eKUMoZq5XV11is/tjts9lB3sVWqkFifCCJ5vtFi2hw=; b=W+5fS7oHvfwpPq0e1W9OHeR6fiv5J2LosWNl3SRDXu0n2B/0aqtUaXxXY7eJ1LzydFDBkt akBjD/fs6PY5Ee6cmzEhERpuN7EiKa3EcFG/qt3R5+JCo15pqt4zJVoM7PsFEuH3GcnBBP jRYQTB5TNa4uRCp+dhE/KBSjDWaY08U= X-MC-Unique: xgkuTIZTNzqLBRCJ8ok1UQ-1 X-Mimecast-MFC-AGG-ID: xgkuTIZTNzqLBRCJ8ok1UQ_1789047058 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:30:04 +0400 Subject: [GIT PULL 09/24] virtio-gpu: store the scanout DMABUF in virtio_gpu_scanout MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-9-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko X-Developer-Signature: v=1; a=openpgp-sha256; l=6595; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=uctf6lHwlbTWsPKln7Zc5X4gjngr0Ppzs4eUPV26194=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDcRRoJs6azc097ETI+SfgioI8reSE/Vyf19 uV1OiPHxjaJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw3AAKCRDa6OEJdZac 5d4lD/4z+aYB3L3tj8S1gYHw5M/+HjXChi6CDWAyHqAo+8q6kFqeW3kwbH8HckdxJw/owbCdXAJ X04N+elumOfnHVbbR+hcqkC2jE3zeMgz7i35/1CWsXLQL3+8XaH7MFgfo1wJnJCCthXva13l7j3 plUusZbCO3YP0y0TXSN6+z7l6U03o7qnfX5+9II6gkAfTep71TjSaQQic6wmhS5kplbloihg8Ts 9K/jRLtcv+ZnvdnHMTEMkyioml3K1JOLjlAoOHp4ZUhAA/tGXChbATDXNyterW3gOfrmq8PWMd7 DctJ3v1AV+Edv59O3oHJJ4PFXz7y2IByfIkNjOCpnOFPc3MiAnJO0YovKagNnBfSmNmteMRGuCP QawqwXbG8MUzLZJu8FBUNcPWbHHPPXZUykWN2k5zkvJjVl/OTnLssvXpSfmHrv2sdQv0AOgdUwf 7mPNWoxeZLITLc/e9P7kH+A4GFeZrZEIVDtgn1QZbu+LkXF2A9/0LSWqOR0p3Z0JKoKLHs1a5Tf LawqKDsSfjPkhCD4e4TtmOZPHatwcUCLv4ePvt0HwXVzOGlz/f2Xklh7p1X8+Zq/M//gFWIk670 unPCeIoLhEJdivfLE4YfsByfajKmLj42ftK8IqJhhwInX9yFKIRf4iWSDqFM1si02EE5SNR9ASC Z20AaFylq+GLfjQ== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1789047076111158500 VirtIOGPU tracks presented dmabufs both through a per-scanout primary pointer and a device-wide list of VGPUDMABuf wrappers. Only the current DMA-BUF for a scanout can ever be presented, so the list and the wrapper struct are redundant bookkeeping. Store the QemuDmaBuf directly in virtio_gpu_scanout and drop VGPUDMABuf and the device-wide list. The wrapper only carried the buffer and its scanout id; the id is now implicit in the owning scanout. No functional change intended. Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/display/virtio-gpu-udmabuf.c | 68 +++++++++++++++----------------------= ---- include/hw/virtio/virtio-gpu.h | 12 +------- 2 files changed, 25 insertions(+), 55 deletions(-) diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabu= f.c index fc63f2c4ec21..a38afb24c71f 100644 --- a/hw/display/virtio-gpu-udmabuf.c +++ b/hw/display/virtio-gpu-udmabuf.c @@ -160,30 +160,19 @@ bool virtio_gpu_init_udmabuf(struct virtio_gpu_simple= _resource *res) return true; } =20 -static void virtio_gpu_free_dmabuf(VirtIOGPU *g, VGPUDMABuf *dmabuf) -{ - struct virtio_gpu_scanout *scanout; - - scanout =3D &g->parent_obj.scanout[dmabuf->scanout_id]; - qemu_console_gl_release_dmabuf(scanout->con, dmabuf->buf); - g_clear_pointer(&dmabuf->buf, qemu_dmabuf_free); - QTAILQ_REMOVE(&g->dmabuf.bufs, dmabuf, next); - g_free(dmabuf); -} - 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; =20 for (i =3D 0; i < max_outputs; i++) { - VGPUDMABuf *dmabuf =3D g->dmabuf.primary[i]; + struct virtio_gpu_scanout *scanout =3D &g->parent_obj.scanout[i]; =20 - if (dmabuf && - qemu_dmabuf_get_num_planes(dmabuf->buf) > 0 && - qemu_dmabuf_get_fds(dmabuf->buf, NULL)[0] =3D=3D res->dmabuf_f= d && + if (scanout->dmabuf && + qemu_dmabuf_get_num_planes(scanout->dmabuf) > 0 && + qemu_dmabuf_get_fds(scanout->dmabuf, NULL)[0] =3D=3D res->dmab= uf_fd && res->dmabuf_fd !=3D -1) { - qemu_dmabuf_close(dmabuf->buf); + qemu_dmabuf_close(scanout->dmabuf); res->dmabuf_fd =3D -1; res->share_handle =3D SHAREABLE_NONE; } @@ -192,31 +181,23 @@ void virtio_gpu_fini_udmabuf(VirtIOGPU *g, struct vir= tio_gpu_simple_resource *re virtio_gpu_destroy_udmabuf(res); } =20 -static VGPUDMABuf -*virtio_gpu_create_dmabuf(VirtIOGPU *g, - uint32_t scanout_id, - struct virtio_gpu_simple_resource *res, - struct virtio_gpu_framebuffer *fb, - struct virtio_gpu_rect *r) +static QemuDmaBuf * +virtio_gpu_create_dmabuf(struct virtio_gpu_simple_resource *res, + struct virtio_gpu_framebuffer *fb, + struct virtio_gpu_rect *r) { - VGPUDMABuf *dmabuf; uint32_t offset =3D 0; =20 if (res->dmabuf_fd < 0) { return NULL; } =20 - dmabuf =3D g_new0(VGPUDMABuf, 1); - dmabuf->buf =3D qemu_dmabuf_new(r->width, r->height, - &offset, &fb->stride, - r->x, r->y, fb->width, fb->height, - qemu_pixman_to_drm_format(fb->format), - DRM_FORMAT_MOD_INVALID, &res->dmabuf_fd, - 1, true, false); - dmabuf->scanout_id =3D scanout_id; - QTAILQ_INSERT_HEAD(&g->dmabuf.bufs, dmabuf, next); - - return dmabuf; + return qemu_dmabuf_new(r->width, r->height, + &offset, &fb->stride, + r->x, r->y, fb->width, fb->height, + qemu_pixman_to_drm_format(fb->format), + DRM_FORMAT_MOD_INVALID, &res->dmabuf_fd, + 1, true, false); } =20 int virtio_gpu_update_dmabuf(VirtIOGPU *g, @@ -226,26 +207,25 @@ int virtio_gpu_update_dmabuf(VirtIOGPU *g, struct virtio_gpu_rect *r) { struct virtio_gpu_scanout *scanout =3D &g->parent_obj.scanout[scanout_= id]; - VGPUDMABuf *new_primary, *old_primary =3D NULL; + QemuDmaBuf *new_primary, *old_primary; uint32_t width, height; =20 - new_primary =3D virtio_gpu_create_dmabuf(g, scanout_id, res, fb, r); + new_primary =3D virtio_gpu_create_dmabuf(res, fb, r); if (!new_primary) { return -EINVAL; } =20 - if (g->dmabuf.primary[scanout_id]) { - old_primary =3D g->dmabuf.primary[scanout_id]; - } + old_primary =3D scanout->dmabuf; =20 - width =3D qemu_dmabuf_get_width(new_primary->buf); - height =3D qemu_dmabuf_get_height(new_primary->buf); - g->dmabuf.primary[scanout_id] =3D new_primary; + width =3D qemu_dmabuf_get_width(new_primary); + height =3D qemu_dmabuf_get_height(new_primary); + scanout->dmabuf =3D new_primary; qemu_console_resize(scanout->con, width, height); - qemu_console_gl_scanout_dmabuf(scanout->con, new_primary->buf); + qemu_console_gl_scanout_dmabuf(scanout->con, new_primary); =20 if (old_primary) { - virtio_gpu_free_dmabuf(g, old_primary); + qemu_console_gl_release_dmabuf(scanout->con, old_primary); + qemu_dmabuf_free(old_primary); } =20 return 0; diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 8c0df60b3b7e..ee5f6f2f2375 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -85,6 +85,7 @@ struct virtio_gpu_framebuffer { struct virtio_gpu_scanout { QemuConsole *con; DisplaySurface *ds; + QemuDmaBuf *dmabuf; uint32_t width, height; int x, y; int invalidate; @@ -189,12 +190,6 @@ struct VirtIOGPUBaseClass { DEFINE_PROP_UINT32("xres", _state, _conf.xres, 1280), \ DEFINE_PROP_UINT32("yres", _state, _conf.yres, 800) =20 -typedef struct VGPUDMABuf { - QemuDmaBuf *buf; - uint32_t scanout_id; - QTAILQ_ENTRY(VGPUDMABuf) next; -} VGPUDMABuf; - struct VirtIOGPU { VirtIOGPUBase parent_obj; =20 @@ -226,11 +221,6 @@ struct VirtIOGPU { uint32_t bytes_3d; } stats; =20 - struct { - QTAILQ_HEAD(, VGPUDMABuf) bufs; - VGPUDMABuf *primary[VIRTIO_GPU_MAX_SCANOUTS]; - } dmabuf; - GArray *capset_ids; }; =20 --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047098; cv=none; d=zohomail.com; s=zohoarc; b=emDK1ttx+IcEZZwGLVSvLmOKNng/YybSPHZnlkBMhzPtFeV+coS3j6eTBNY+OA4vhJkwynpeSzjpyOIw9V4ZwG8lh0cHkq3HVMTIwARcVcEkkvh5Mb1BIRrxhUFQ+YdKPwj1rL3Y30l4ykU0N5hlsP9Dyvdvf7nvTlngkU1jwjs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047098; 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=ab79tc0wP1jslXYpwrccZQdhGgSRbeaIJ1DfJSrtXZY=; b=K73AzmjHOiiXmbOH42g5qtK4NuOELU9ENBOeGvlXuFW5av6i1tGWqEP7f/QiRD4JOSr7NFmL8713WUIkILPj/8wTRkAGUFJKPrb4wJwXPIA0BxxaNhBWOIBEdl4jbb9xnryFu5o24oNDl/sr3m1eizsVFcrbDJZYsuBdJOzfC9w= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047098799879.50168581692; Thu, 10 Sep 2026 06:31:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4erw-0003RZ-Jz; Thu, 10 Sep 2026 09:31:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4ert-0003Fx-4w for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4err-0003g8-L4 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:08 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-346-CwCAJqfQMK6BHuR3q1knLQ-1; Thu, 10 Sep 2026 09:31:04 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 92D801954AE4; Thu, 10 Sep 2026 13:31:03 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 816CB1956095; Thu, 10 Sep 2026 13:31:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047066; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ab79tc0wP1jslXYpwrccZQdhGgSRbeaIJ1DfJSrtXZY=; b=WhMcWFrC8a00dyVCyr1qCQPNxKyBfPcrRmAV1hBMaYw6g38jBg/Lt3UM2faok8K3O4HlBR vyKiNe5pauO8G0UNSlr1k+Ppj3T1yObh5kpThoSd2Gm94LFeVUstAMK50JuNPPw3mJi+vB POcPta8kNu8+lvAbbu2fZcAgDRlpdlo= X-MC-Unique: CwCAJqfQMK6BHuR3q1knLQ-1 X-Mimecast-MFC-AGG-ID: CwCAJqfQMK6BHuR3q1knLQ_1789047063 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:30:05 +0400 Subject: [GIT PULL 10/24] ui/console: disable GL scanout when dmabuf is the active one MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-10-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=1052; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=OQduuPEP/YmWbLpH074hRz03Ee7qLxiHWTT26EkF3go=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDcK9Tf3GGCXwNEQvE8varUVI5HWKZQ1n1cq coiIHOrnKqJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw3AAKCRDa6OEJdZac 5UfCD/9OEAPlkLsBx1+NcU2tUdRFENNrxtfUEbdL0gHIML34fEQmFF0wyp/JME9od42doe1KXee YD1igE1lvISTkLiYsEGch3oYrVztsy7FG/43XeV6If9tKPbvJ0DStKee6xfkpkRMY7p37sLm0Uv 6YIk6SjiZJJoorOLolcD9YxTCs8cMZqXYlIa1xGb8/k7TaztrGfHJgvHwhesJNqsV36QVn9CGk9 Bb1zvWLWQYdk46anUMECH7fyNadl8zZOHVVBDlpazkZATcua/XqKT6YVAHEMAkNN7uYZ4yngqgj 7EaQHkPZF9JyYruFAla0MsIV+aqs/iADwDHW0Y4/FnVufxp0CEbo8+CQlT0ZhWwN0Z0mlrkVRlF z9xce81biStww9B2w6MbuGhbdOSwZU3TZG4jmiEOYeK55Vgp2zZ/Z2XqdymrVZnnhLt32pYNlWU TSsAhtGfFmKyrX1SjfMTjztmge/DTQRJGOMmA2ocOZMneTY6LZDfTjQyBcHPw11Wb9YnPm4xpUi DI9av+nuCZCfCHef0g0Vo5PsYRqo+jcvVlfnUUHM5TIbcbsSj42bI7MoZ12nYtR1+pk5CDUJQCp J9y7p+EauU+fyWZMZWvewmqtj6lRZS9lOvRyqOW9+U6N0cFwhfEgO1YLg38eACnTE4gX83CNa0c 38J28c6VsKkLk9A== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1789047100075158500 Disable the GL scanout when the actively-displayed dmabuf is released, so the console does not retain a stale reference. The VFIO commit changes to call qemu_console_gl_release_dmabuf() before qemu_graphic_console_close(), which dereferences the active scanout. Fixes: 239b7c5705a4 ("vfio/pci: close display console during unrealize, not= finalize") Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/console.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/console.c b/ui/console.c index a8a2a247d8f4..14f148118e37 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1049,6 +1049,9 @@ void qemu_console_gl_release_dmabuf(QemuConsole *con, dcl->ops->dpy_gl_release_dmabuf(dcl, dmabuf); } } + if (con->scanout.kind =3D=3D SCANOUT_DMABUF && dmabuf =3D=3D con->scan= out.dmabuf) { + qemu_console_gl_scanout_disable(con); + } } =20 void qemu_console_gl_update(QemuConsole *con, --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047092; cv=none; d=zohomail.com; s=zohoarc; b=TO6gZEbhGppiaAhkaQxIxZQzwQ1rA5BnUKFsNEsROVRxB7TDXeN8g4ctAM2Ky5hfbuOaci/eZEzm4REBy4YpOHrGWPcMJinL/57AdUvgdmi4RedNJlZkfayaxVz21Hl5gq1PkHI5EobcjqKGezzXMoYeV//sFDAYpR2bD2goeA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047092; 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=XHHwspiJ/RpBE0HEPqNXG0+MxDXPOfiZVbdO3BXZFm0=; b=C8caYcSPSGP7R8BUsLYOVLV5kMtNRdXo1/nJUfIcHs1sRUStbY8Gb9TZjtpRQbG6jH1vRtEuivloqb8wQ/n+pz4/x436FoDMvJA5IJ+/3WJth9CyL2FSEVUE4XtYtSREGDsKFpd5VgkUfFD4i1eY03veRNAJSMy/xipWic8tC2o= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047092582269.01132916377196; Thu, 10 Sep 2026 06:31:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4erz-0003Zz-IU; Thu, 10 Sep 2026 09:31:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4ery-0003Uk-2p for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4erw-0003hK-MU for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:13 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-205-hb9q2xo7NS2vhaNhsJRybw-1; Thu, 10 Sep 2026 09:31:08 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CA0071955E7B; Thu, 10 Sep 2026 13:31:07 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E8A4A3000239; Thu, 10 Sep 2026 13:31:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047072; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XHHwspiJ/RpBE0HEPqNXG0+MxDXPOfiZVbdO3BXZFm0=; b=JIJyEjHUf++/WOKIvIm+JBUdtJnwPixBfy4b1o5yCVKuDPAIzn63s1fDV4Jtp/PjkmlTIw Xiqmkd0KOcWQ/ZJ1o5FPjHA8HfsHF7XzAPswBqIT2P2cbCHRsqbpMR65Bx56Yqo/U+Gfpl LRtUOzR+png19ypWcoJ9QT3Vv092M9w= X-MC-Unique: hb9q2xo7NS2vhaNhsJRybw-1 X-Mimecast-MFC-AGG-ID: hb9q2xo7NS2vhaNhsJRybw_1789047067 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:30:06 +0400 Subject: [GIT PULL 11/24] ui/sdl2: clear guest_fb.dmabuf on release MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-11-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=1043; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=ckwb6WKTNIogQkoKNEFb6W6xtaAoBV7HCY+xp/SqEdE=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDcjt94lYYCHnIMxTQ7LUwEQQ+PhJ1gUA12n +Ja7SwpdviJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw3AAKCRDa6OEJdZac 5SRjD/4qSIApWTuBEbFDj0X3FnDv/4lKWq8sOOHyEG2cwEkVWK7af+iiacRA3TpDl6hoIh++wRI V2Y53opWuk6maFofeV5X6ZrJ6O//+g73zZCPjahWRzpfa+w4fktNkMGLo8FRM6p+vtUpTX6LWm/ 7obnFhaey7eqj9iBLmrosC4SlnCOyVN2iPijjO8m+m8oNLlTG0n44E5ldyiBPo80aPfm2IlnJoT kaJpA4FMYcHTSt3dk7zsLf6uMnPr48nKsm0QhOSspO2iiEPJi65W0h0Q65qTh9LK9loTjhdygLk ualTwQ+VL5/AGONHZ8GssdIb3gsd9m6wjryDGM8RXvyH7oRtMu8Fi6U8Q/d1C8fbQyPCXGf5wjJ S1KIz96YNSnyljlEHbs0xQIiMDrcbymd7kWVkEOT755qxZdjisVphiVeFq7hrYcoABfkFcLb44h 5rVBLOc2rUQRvYcASlenW4ktTuSAUALIVsfEtdFGAMbty+NXuzwE34/MRFAICN6c0CjWsmWGFiE GjyVEk3pLXR3o4G/yyKFCZFLmYM5jL6TLLbZXq3+5D1Ivp+qZVggI3lUNC2H4Qx19XLkHusmwO5 9n27WB0p7zabNZE6yi2DDtJFOo9M3lg7GF04WhTyugHbFVjk9cVUFlqeSoTosogvll0oWmXG3tu Kwhm2FN/MoLLskw== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1789047094058158500 sdl2_gl_release_dmabuf() releases the texture but leaves the guest_fb.dmabuf pointer dangling. Clear it to prevent stale references after the dmabuf is freed. Fixes: 52053b7e0a0e ("ui/sdl2: Implement dpy dmabuf functions") Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/sdl2-gl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c index 1547ad2f6f80..46eff768c968 100644 --- a/ui/sdl2-gl.c +++ b/ui/sdl2-gl.c @@ -286,7 +286,12 @@ void sdl2_gl_scanout_dmabuf(DisplayChangeListener *dcl, void sdl2_gl_release_dmabuf(DisplayChangeListener *dcl, QemuDmaBuf *dmabuf) { + struct sdl2_console *scon =3D container_of(dcl, struct sdl2_console, d= cl); + egl_dmabuf_release_texture(dmabuf); + if (scon->guest_fb.dmabuf =3D=3D dmabuf) { + scon->guest_fb.dmabuf =3D NULL; + } } =20 bool sdl2_gl_has_dmabuf(DisplayChangeListener *dcl) --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047115; cv=none; d=zohomail.com; s=zohoarc; b=oExmTw9q/rrJrLyCs21+sB0UxC44pPqcjXea4h5zAD9p7TcTTREoAnIf7ubOcCgTa7vWkqjWJbAiqknSo1zzXSXPLVnKQ33SZ4aMIabq3oDAf2S+7IOGS0HroZzmfbzWAcJ3LBM3qPb2pfEESKf43d77HSenXzcSgP9+2+Ho5yo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047115; 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=VZnshOqku4FavFQORr10V8m874qk9cgcha/ptLZZv0A=; b=fm97uMs2UpzNchoYnFDDl7IpZSsWdKGxTzBzauNo/+BdWFBIG5MDMnlH9KvmqAfVOJHkPXGUYRZbKGy7+cEoXxBPes8/554k5972LL5eMMa7k+MPGWQM9N9jUZQZ6F+w72h80I5lAaa2Ow6PGFBtg0AkQ0Q0ejARgRuTgamHjyo= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178904711529683.96308899762016; Thu, 10 Sep 2026 06:31:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4es8-0003kr-U5; Thu, 10 Sep 2026 09:31:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4es7-0003gN-93 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4es5-0003hn-81 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:23 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-645-EIkfqqdfP1inCrB97WNFHQ-1; Thu, 10 Sep 2026 09:31:17 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 936631954B08; Thu, 10 Sep 2026 13:31:15 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9BCC01956040; Thu, 10 Sep 2026 13:31:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047080; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VZnshOqku4FavFQORr10V8m874qk9cgcha/ptLZZv0A=; b=QM2aRjuHeq4iC7SJU9cZjq4RXIlr6WLMUR1RSDVNbIbyBUNGO2Hw6WA7vSJQ1DHPXbhCrS O3rt9KouBRC6jSqUDbw+2EACJSXLjz+xtmlC4sG9uTUuSSHnPf53LAw155yMkt9JeU1y9/ vlsL66+uJRwZeDxoX7s5K0Cb5cBdeUg= X-MC-Unique: EIkfqqdfP1inCrB97WNFHQ-1 X-Mimecast-MFC-AGG-ID: EIkfqqdfP1inCrB97WNFHQ_1789047075 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:30:07 +0400 Subject: [GIT PULL 12/24] ui/dmabuf: own and close fds on free MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-12-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , "Michael S. Tsirkin" , Stefano Garzarella , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Developer-Signature: v=1; a=openpgp-sha256; l=8315; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=Rpjn/T9FKWIsPe+2tcKGUZHI81cTdeyhzq1ZW8DwiI4=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDcNNjdyMnhwxKBRij4M4eQ3q7u8xZ5aPVN4 UU9wZfTRxSJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw3AAKCRDa6OEJdZac 5WNUEAChO8Zl77WyU3QLEjbxbN9oNR30+G09JcT+l7iorTsvMymOvvwzZVaQWigTQZvXnifM6nK boL/h+77C5WQRnXNjYNsdfVUOaTPAGaf9jSgFFcEEOAVnu/KJofcWUfHi7TOCtRr6kfJT9MpsIR Wo3T5q0oLLVoNWCaTC0YzILiznLgd4lfQ2hDwcuSW2WfjFX2gV5CJeUMfzaphQl2jI5Wo97S/sC sB9bnBKwYoqqNs7U3A6u1vBOWHZrOhwX57tV5Gp3kNtXwBqQOZYAmXbTPiyI8f2hdc5vGZAbX71 YiGUhMq0rFqq8dtmIBcQBuyZAOeQ0x5jiTLRvzthWgnR7QKKKBqw6uNx07kWiOYOmqhsHIbSUNN 53pVFlBsZgnTeDRH10B0Y6eE9zt9TgBwFLY2H74pZyrypW0MYV3LS+N1E3zgCm9Uo5V4dlcYpSK j5sevqkIcYWAgvgrGwzdUe2kTVhLJ2EaGKqjpZeGJo64MLBFYFYB8VMyH6yTzMePwkjVJ69qwEm lYFPv/eaJU10T3zXPca7u00rE3jNHCTc4Xb+uv3VMpKaxyGLMfhwIAZ+gZw4v4uKom7dynWitp0 qqOhn4bSMzlGu7HmTUr7iMiWiuB1oo/cn1+g3i6mziftx2AHpPLjwyl9b38t4rFw3M0r+NgMWer 7Onqax6XIZZd89g== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1789047116326158500 Make qemu_dmabuf_free() call qemu_dmabuf_close(), so the dmabuf always owns and closes its fds. This removes the need for callers to explicitly close fds before freeing and simplify the code. To support this, virtio_gpu_create_dmabuf() now dup()s the resource fd so each QemuDmaBuf has an independent copy. The scanout-matching loop in virtio_gpu_fini_udmabuf() is no longer needed and is removed. Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/display/vhost-user-gpu.c | 1 - hw/display/virtio-gpu-udmabuf-stubs.c | 2 +- hw/display/virtio-gpu-udmabuf.c | 33 +++++++++----------------------= -- hw/display/virtio-gpu.c | 2 +- hw/vfio/display.c | 1 - include/hw/virtio/virtio-gpu.h | 3 +-- include/ui/dmabuf.h | 1 - ui/dbus-listener.c | 1 - ui/dmabuf.c | 22 ++++++++-------------- 9 files changed, 20 insertions(+), 46 deletions(-) diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index cd684d63639e..c09aca041135 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -293,7 +293,6 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUse= rGpuMsg *msg) dmabuf =3D g->dmabuf[m->scanout_id]; =20 if (dmabuf) { - qemu_dmabuf_close(dmabuf); qemu_console_gl_release_dmabuf(con, dmabuf); g_clear_pointer(&dmabuf, qemu_dmabuf_free); } diff --git a/hw/display/virtio-gpu-udmabuf-stubs.c b/hw/display/virtio-gpu-= udmabuf-stubs.c index 0883bf05fac1..1a9dfbdec109 100644 --- a/hw/display/virtio-gpu-udmabuf-stubs.c +++ b/hw/display/virtio-gpu-udmabuf-stubs.c @@ -13,7 +13,7 @@ bool virtio_gpu_init_udmabuf(struct virtio_gpu_simple_res= ource *res) return false; } =20 -void virtio_gpu_fini_udmabuf(VirtIOGPU *g, struct virtio_gpu_simple_resour= ce *res) +void virtio_gpu_fini_udmabuf(struct virtio_gpu_simple_resource *res) { /* nothing (stub) */ } diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabu= f.c index a38afb24c71f..6d2bc8d9771f 100644 --- a/hw/display/virtio-gpu-udmabuf.c +++ b/hw/display/virtio-gpu-udmabuf.c @@ -82,7 +82,7 @@ static void virtio_gpu_remap_udmabuf(struct virtio_gpu_si= mple_resource *res) } } =20 -static void virtio_gpu_destroy_udmabuf(struct virtio_gpu_simple_resource *= res) +void virtio_gpu_fini_udmabuf(struct virtio_gpu_simple_resource *res) { if (res->remapped) { munmap(res->remapped, res->blob_size); @@ -148,7 +148,7 @@ bool virtio_gpu_init_udmabuf(struct virtio_gpu_simple_r= esource *res) } virtio_gpu_remap_udmabuf(res); if (!res->remapped) { - virtio_gpu_destroy_udmabuf(res); + virtio_gpu_fini_udmabuf(res); return false; } res->share_handle =3D res->dmabuf_fd; @@ -160,43 +160,28 @@ bool virtio_gpu_init_udmabuf(struct virtio_gpu_simple= _resource *res) return true; } =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++) { - struct virtio_gpu_scanout *scanout =3D &g->parent_obj.scanout[i]; - - if (scanout->dmabuf && - qemu_dmabuf_get_num_planes(scanout->dmabuf) > 0 && - qemu_dmabuf_get_fds(scanout->dmabuf, NULL)[0] =3D=3D res->dmab= uf_fd && - res->dmabuf_fd !=3D -1) { - qemu_dmabuf_close(scanout->dmabuf); - res->dmabuf_fd =3D -1; - res->share_handle =3D SHAREABLE_NONE; - } - } - - virtio_gpu_destroy_udmabuf(res); -} - static QemuDmaBuf * virtio_gpu_create_dmabuf(struct virtio_gpu_simple_resource *res, struct virtio_gpu_framebuffer *fb, struct virtio_gpu_rect *r) { uint32_t offset =3D 0; + int fd; =20 if (res->dmabuf_fd < 0) { return NULL; } =20 + fd =3D qemu_dup(res->dmabuf_fd); + if (fd < 0) { + return NULL; + } + return qemu_dmabuf_new(r->width, r->height, &offset, &fb->stride, r->x, r->y, fb->width, fb->height, qemu_pixman_to_drm_format(fb->format), - DRM_FORMAT_MOD_INVALID, &res->dmabuf_fd, + DRM_FORMAT_MOD_INVALID, &fd, 1, true, false); } =20 diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index cb45360e769e..ecf3cbc4893c 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1077,7 +1077,7 @@ void virtio_gpu_cleanup_mapping(VirtIOGPU *g, res->addrs =3D NULL; =20 if (res->blob) { - virtio_gpu_fini_udmabuf(g, res); + virtio_gpu_fini_udmabuf(res); } } =20 diff --git a/hw/vfio/display.c b/hw/vfio/display.c index cb83d98e9af6..89854eceb43c 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -263,7 +263,6 @@ static void vfio_display_free_one_dmabuf(VFIODisplay *d= py, VFIODMABuf *dmabuf) { QTAILQ_REMOVE(&dpy->dmabuf.bufs, dmabuf, next); =20 - qemu_dmabuf_close(dmabuf->buf); qemu_console_gl_release_dmabuf(dpy->con, dmabuf->buf); g_clear_pointer(&dmabuf->buf, qemu_dmabuf_free); g_free(dmabuf); diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index ee5f6f2f2375..c2018b41056f 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -390,8 +390,7 @@ bool virtio_gpu_scanout_blob_to_fb(struct virtio_gpu_fr= amebuffer *fb, /* virtio-gpu-udmabuf.c */ bool virtio_gpu_have_udmabuf(void); bool virtio_gpu_init_udmabuf(struct virtio_gpu_simple_resource *res); -void virtio_gpu_fini_udmabuf(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res); +void virtio_gpu_fini_udmabuf(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/include/ui/dmabuf.h b/include/ui/dmabuf.h index b972099859f2..968f3f9c8d48 100644 --- a/include/ui/dmabuf.h +++ b/include/ui/dmabuf.h @@ -27,7 +27,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(QemuDmaBuf, qemu_dmabuf_fre= e); =20 const int *qemu_dmabuf_get_fds(QemuDmaBuf *dmabuf, int *nfds); void qemu_dmabuf_dup_fds(QemuDmaBuf *dmabuf, int *fds, int nfds); -void qemu_dmabuf_close(QemuDmaBuf *dmabuf); uint32_t qemu_dmabuf_get_width(QemuDmaBuf *dmabuf); uint32_t qemu_dmabuf_get_height(QemuDmaBuf *dmabuf); const uint32_t *qemu_dmabuf_get_offsets(QemuDmaBuf *dmabuf, int *noffsets); diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c index 5a72c7eeae59..c1e86648384c 100644 --- a/ui/dbus-listener.c +++ b/ui/dbus-listener.c @@ -631,7 +631,6 @@ static void dbus_scanout_texture(DisplayChangeListener = *dcl, if (dbus_call_scanout_dmabuf(ddl, dmabuf)) { ddl->scanout_dmabuf =3D NULL; } - qemu_dmabuf_close(dmabuf); #endif =20 #ifdef WIN32 diff --git a/ui/dmabuf.c b/ui/dmabuf.c index 495270f29bd6..497f82cc61f2 100644 --- a/ui/dmabuf.c +++ b/ui/dmabuf.c @@ -61,10 +61,18 @@ QemuDmaBuf *qemu_dmabuf_new(uint32_t width, uint32_t he= ight, =20 void qemu_dmabuf_free(QemuDmaBuf *dmabuf) { + int i; + if (dmabuf =3D=3D NULL) { return; } =20 + for (i =3D 0; i < dmabuf->num_planes; i++) { + if (dmabuf->fd[i] >=3D 0) { + close(dmabuf->fd[i]); + dmabuf->fd[i] =3D -1; + } + } g_free(dmabuf); } =20 @@ -91,20 +99,6 @@ void qemu_dmabuf_dup_fds(QemuDmaBuf *dmabuf, int *fds, i= nt nfds) } } =20 -void qemu_dmabuf_close(QemuDmaBuf *dmabuf) -{ - int i; - - assert(dmabuf !=3D NULL); - - for (i =3D 0; i < dmabuf->num_planes; i++) { - if (dmabuf->fd[i] >=3D 0) { - close(dmabuf->fd[i]); - dmabuf->fd[i] =3D -1; - } - } -} - uint32_t qemu_dmabuf_get_width(QemuDmaBuf *dmabuf) { assert(dmabuf !=3D NULL); --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047188; cv=none; d=zohomail.com; s=zohoarc; b=c9Jiu4ZPms6a2B8oeQgOmzYnhbnt5tf8onjSqS6Q2ancEaFh0FfHDKBqn8JD8LXp21ChgCMHi/JfTQ4GDmAn2R4lqEspveiTHp+47iFj3ltM+MGE7BgYxVHjFzU6e1D6sULPM8zASlLec+XmQvoOgrr0AJwmAtV0Y48/yFTrCfE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047188; 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=rz3cRjEGnveKnwufJJi2+HGkcMFpRaSK4bgbFJpIYJA=; b=SefVAzgt2uZUIc3tKyJRVUcVDSesR1M7DWOioCIH/xzAKJx3so48yilsP/cgbN3kZiH/DEO+FG4V/x0soopQE0yTGCQiZNsNC3BDIBPWPYbYn385CtP1j1UqsbxQDLUcM8enFt7XD/LN+hRnKmD3VouA5MfjuRnUSXvMcxcvtyw= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047188478573.0358888520608; Thu, 10 Sep 2026 06:33:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4esK-0004Qy-5t; Thu, 10 Sep 2026 09:31:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4esH-0004Dt-8m for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4esE-0003iq-Pe for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:32 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-421-k-YEAbyXPluGAm71tkJkfw-1; Thu, 10 Sep 2026 09:31:23 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5B24C1956072; Thu, 10 Sep 2026 13:31:22 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DFDB118004D4; Thu, 10 Sep 2026 13:31:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047090; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rz3cRjEGnveKnwufJJi2+HGkcMFpRaSK4bgbFJpIYJA=; b=YEGwzxxG0/rXUe3lNRvs2+YzHd5E3Nxxf2zMlKR0oNhxaX1WZ3aexG+vKhmavSy5V0OJDF OiKznTjjpZcAXncJS0qAOk/U2jV25IhDlBKyqsVWbjeUZN05SZ0FhaeeECClJc9MPYb7cc 6NJ6jO4aSrAXbEN12ce1/69XGT5k77U= X-MC-Unique: k-YEAbyXPluGAm71tkJkfw-1 X-Mimecast-MFC-AGG-ID: k-YEAbyXPluGAm71tkJkfw_1789047082 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:30:08 +0400 Subject: [GIT PULL 13/24] ui: make GL context current in display backend callbacks MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-13-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , "Michael S. Tsirkin" , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=11389; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=1N0CPgj7fFx3zSyApzb8lq0OZjP8DnXs/DzRZkuaWoM=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDceWapbGNaQzpMySmq0LlyH587XTDKH1+ZN xJWiaTpcMCJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw3AAKCRDa6OEJdZac 5VqnD/4uJMk4XDMuFjbbZTVjTYtkfgWrmObRlJlpFZ1u2yPgiO4VM8d5sXAAQ0yC5Ttwr53UuN9 Uk3wvhiHH9YwUcUVwQLdRTRFLEwfWapyglsZfxsEgfg0M+V/3vpEckJAiAECG+V16Vdjp2IE95O FexL6wF3MZ81v/7CwBRIc00wPZrrw2PAOf2BhmhM8NyFxCVeJWebWli7xvt19JFZlyn2Z3/0oO8 42UCnmJ1nCEt7SnHCXzoyirkzAYAchKnzayWqjFse/JLiHiT3x4dovtDHvSLMpL/1SVhIFZfOcr Y0Am2MUlL39NKGYgtdISuUL5Txmzzrgp4dfDbOHXiQE4sl2gpi3pMF8cOg32cmgM6bVjtb/PIMK BQU1I3RkDQPTU3AAZBRrfFiNxl8utEM7HG/QTvlDruid5GZJh4UnvOyG+oGHVX54KRaagf+TLqU WlQSfj2nPMQ3TS9sPHhgiSEEfhsQ3r9/VsHLazVqAMbDkQoKqwD6XljFNuveBrNLRR16yPcx92p wnBviVLE0Chh7mcc8DQDznDMCDrKKv5XucdDXriP6NQu9fjmJpp/vH3Yi+VhOwq7I6p26LOOXxc +rLaeYYu+BBD5DS7slrsgkCQep5gz0kx35ykgIKkMGnweLJgrWNYaSir2xvEieckrMVYy0m6RMg oGNmtr018ZpF5yA== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1789047190963158500 Display backend GL callbacks (scanout, flush, release, etc.) may be invoked from a different GL context, like virgl. Since framebuffer objects are per-context and textures require a valid context for deletion, each callback must ensure the correct context is active before performing GL operations. Make each backend's own GL context current at the entry of every callback that performs GL work. For GTK, the previously shared gd_gl_release_dmabuf is split into backend-specific gd_egl_release_dmabuf and gd_gl_area_release_dmabuf, matching the existing pattern where each backend manages its own context. On the virgl side, restore ctx0 with virgl_renderer_force_ctx_0() after SET_SCANOUT, RESOURCE_FLUSH, and SET_SCANOUT_BLOB command handlers, since their display callbacks may have changed the current GL context. Note: restoring virgl ctx0 current is not necessarily correct, fences may not work. We will follow-up with a complementary fix. Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/display/virtio-gpu-virgl.c | 4 ++++ include/ui/gtk.h | 5 +++++ ui/egl-headless.c | 17 +++++++++++++++++ ui/gtk-egl.c | 12 ++++++++++++ ui/gtk-gl-area.c | 11 +++++++++++ ui/gtk.c | 13 ++++--------- ui/sdl2-gl.c | 2 ++ ui/spice-display.c | 2 ++ 8 files changed, 57 insertions(+), 9 deletions(-) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 7f1d1e0c3276..0e43eacca406 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -1091,9 +1091,12 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, break; case VIRTIO_GPU_CMD_SET_SCANOUT: virgl_cmd_set_scanout(g, cmd); + /* Display callbacks may change the current GL context. */ + virgl_renderer_force_ctx_0(); break; case VIRTIO_GPU_CMD_RESOURCE_FLUSH: virgl_cmd_resource_flush(g, cmd); + virgl_renderer_force_ctx_0(); break; case VIRTIO_GPU_CMD_RESOURCE_UNREF: virgl_cmd_resource_unref(g, cmd, &cmd_suspended); @@ -1130,6 +1133,7 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, break; case VIRTIO_GPU_CMD_SET_SCANOUT_BLOB: virgl_cmd_set_scanout_blob(g, cmd); + virgl_renderer_force_ctx_0(); break; #endif default: diff --git a/include/ui/gtk.h b/include/ui/gtk.h index b66b9ca5c519..6b62e9758813 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -163,6 +163,7 @@ extern bool gtk_use_gl_area; void gd_update_windowsize(VirtualConsole *vc); void gd_update_monitor_refresh_rate(VirtualConsole *vc, GtkWidget *widget); void gd_gl_wait_sync(VirtualConsole *vc, void *sync); +void gd_release_dmabuf(VirtualConsole *vc, QemuDmaBuf *dmabuf); =20 /* ui/gtk-egl.c */ void gd_egl_init(VirtualConsole *vc); @@ -190,6 +191,8 @@ void gd_egl_cursor_dmabuf(DisplayChangeListener *dcl, uint32_t hot_x, uint32_t hot_y); void gd_egl_cursor_position(DisplayChangeListener *dcl, uint32_t pos_x, uint32_t pos_y); +void gd_egl_release_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf); void gd_egl_flush(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t h); void *gd_egl_scanout_flush(DisplayChangeListener *dcl, @@ -221,6 +224,8 @@ void gd_gl_area_scanout_texture(DisplayChangeListener *= dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t h, void *d3d_tex2d); +void gd_gl_area_release_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf); void gd_gl_area_scanout_disable(DisplayChangeListener *dcl); void gd_gl_area_scanout_flush(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t= h); diff --git a/ui/egl-headless.c b/ui/egl-headless.c index ba27efcf4c3e..c3f319c0960b 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -52,6 +52,8 @@ static void egl_scanout_disable(DisplayChangeListener *dc= l) { egl_dpy *edpy =3D container_of(dcl, egl_dpy, dcl); =20 + eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, + EGL_NO_SURFACE, qemu_egl_rn_ctx); egl_fb_destroy(&edpy->guest_fb); egl_fb_destroy(&edpy->blit_fb); } @@ -69,6 +71,9 @@ static void egl_scanout_texture(DisplayChangeListener *dc= l, =20 edpy->y_0_top =3D backing_y_0_top; =20 + eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, + EGL_NO_SURFACE, qemu_egl_rn_ctx); + /* source framebuffer */ egl_fb_setup_for_tex(&edpy->guest_fb, backing_width, backing_height, backing_id, false); @@ -88,6 +93,8 @@ static void egl_scanout_dmabuf(DisplayChangeListener *dcl, { uint32_t width, height, texture; =20 + eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, + EGL_NO_SURFACE, qemu_egl_rn_ctx); egl_dmabuf_import_texture(dmabuf); texture =3D qemu_dmabuf_get_texture(dmabuf); if (!texture) { @@ -108,6 +115,8 @@ static void egl_cursor_dmabuf(DisplayChangeListener *dc= l, uint32_t width, height, texture; egl_dpy *edpy =3D container_of(dcl, egl_dpy, dcl); =20 + eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, + EGL_NO_SURFACE, qemu_egl_rn_ctx); if (dmabuf) { egl_dmabuf_import_texture(dmabuf); texture =3D qemu_dmabuf_get_texture(dmabuf); @@ -126,6 +135,8 @@ static void egl_cursor_dmabuf(DisplayChangeListener *dc= l, static void egl_release_dmabuf(DisplayChangeListener *dcl, QemuDmaBuf *dmabuf) { + eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, + EGL_NO_SURFACE, qemu_egl_rn_ctx); egl_dmabuf_release_texture(dmabuf); } =20 @@ -151,6 +162,8 @@ static void egl_scanout_flush(DisplayChangeListener *dc= l, } assert(surface_format(edpy->ds) =3D=3D PIXMAN_x8r8g8b8); =20 + eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, + EGL_NO_SURFACE, qemu_egl_rn_ctx); if (edpy->cursor_fb.texture) { /* have cursor -> render using textures */ egl_texture_blit(edpy->gls, &edpy->blit_fb, &edpy->guest_fb, @@ -225,6 +238,8 @@ static void egl_headless_init(DisplayState *ds, Display= Options *opts) =20 egl_dpys =3D g_ptr_array_new(); =20 + eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, + EGL_NO_SURFACE, qemu_egl_rn_ctx); for (idx =3D 0;; idx++) { DisplayGLCtx *ctx; =20 @@ -250,6 +265,8 @@ static void egl_headless_cleanup(void) return; } =20 + eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, + EGL_NO_SURFACE, qemu_egl_rn_ctx); for (guint i =3D 0; i < egl_dpys->len; i++) { egl_dpy *edpy =3D g_ptr_array_index(egl_dpys, i); =20 diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index 8623181336e9..d595916476d9 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -426,6 +426,18 @@ void gtk_egl_init(DisplayGLMode mode) display_opengl =3D 1; } =20 +void gd_egl_release_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf) +{ +#ifdef CONFIG_GBM + VirtualConsole *vc =3D container_of(dcl, VirtualConsole, gfx.dcl); + + eglMakeCurrent(qemu_egl_display, vc->gfx.esurface, + vc->gfx.esurface, vc->gfx.ectx); + gd_release_dmabuf(vc, dmabuf); +#endif +} + int gd_egl_make_current(DisplayGLCtx *dgc, QEMUGLContext ctx) { diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index 45c0c8c81a11..effd88f28721 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -360,6 +360,17 @@ void gd_gl_area_scanout_dmabuf(DisplayChangeListener *= dcl, #endif } =20 +void gd_gl_area_release_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf) +{ +#ifdef CONFIG_GBM + VirtualConsole *vc =3D container_of(dcl, VirtualConsole, gfx.dcl); + + gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area)); + gd_release_dmabuf(vc, dmabuf); +#endif +} + void gtk_gl_area_init(void) { display_opengl =3D 1; diff --git a/ui/gtk.c b/ui/gtk.c index 55e45e8445bc..c615d35451b6 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -584,21 +584,16 @@ static bool gd_has_dmabuf(DisplayChangeListener *dcl) return vc->gfx.has_dmabuf; } =20 -static void gd_gl_release_dmabuf(DisplayChangeListener *dcl, - QemuDmaBuf *dmabuf) -{ #ifdef CONFIG_GBM - VirtualConsole *vc =3D container_of(dcl, VirtualConsole, gfx.dcl); - +void gd_release_dmabuf(VirtualConsole *vc, QemuDmaBuf *dmabuf) +{ egl_dmabuf_release_texture(dmabuf); if (vc->gfx.guest_fb.dmabuf =3D=3D dmabuf) { vc->gfx.guest_fb.dmabuf =3D NULL; vc->gfx.draw_submitted =3D false; } -#endif } =20 -#ifdef CONFIG_GBM static void gd_gl_fence_cb(void *vcon) { VirtualConsole *vc =3D vcon; @@ -639,7 +634,7 @@ static const DisplayChangeListenerOps dcl_gl_area_ops = =3D { .dpy_gl_scanout_disable =3D gd_gl_area_scanout_disable, .dpy_gl_update =3D gd_gl_area_scanout_flush, .dpy_gl_scanout_dmabuf =3D gd_gl_area_scanout_dmabuf, - .dpy_gl_release_dmabuf =3D gd_gl_release_dmabuf, + .dpy_gl_release_dmabuf =3D gd_gl_area_release_dmabuf, .dpy_has_dmabuf =3D gd_has_dmabuf, }; =20 @@ -673,7 +668,7 @@ static const DisplayChangeListenerOps dcl_egl_ops =3D { .dpy_gl_cursor_dmabuf =3D gd_egl_cursor_dmabuf, .dpy_gl_cursor_position =3D gd_egl_cursor_position, .dpy_gl_update =3D gd_egl_flush, - .dpy_gl_release_dmabuf =3D gd_gl_release_dmabuf, + .dpy_gl_release_dmabuf =3D gd_egl_release_dmabuf, .dpy_has_dmabuf =3D gd_has_dmabuf, }; =20 diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c index 46eff768c968..f41fc8bb9634 100644 --- a/ui/sdl2-gl.c +++ b/ui/sdl2-gl.c @@ -200,6 +200,7 @@ void sdl2_gl_scanout_disable(DisplayChangeListener *dcl) struct sdl2_console *scon =3D container_of(dcl, struct sdl2_console, d= cl); =20 assert(scon->opengl); + SDL_GL_MakeCurrent(scon->real_window, scon->winctx); scon->w =3D 0; scon->h =3D 0; sdl2_set_scanout_mode(scon, false); @@ -288,6 +289,7 @@ void sdl2_gl_release_dmabuf(DisplayChangeListener *dcl, { struct sdl2_console *scon =3D container_of(dcl, struct sdl2_console, d= cl); =20 + SDL_GL_MakeCurrent(scon->real_window, scon->winctx); egl_dmabuf_release_texture(dmabuf); if (scon->guest_fb.dmabuf =3D=3D dmabuf) { scon->guest_fb.dmabuf =3D NULL; diff --git a/ui/spice-display.c b/ui/spice-display.c index 75c7df7bb5e0..22cd1e266caa 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -1176,6 +1176,8 @@ static void qemu_spice_gl_release_dmabuf(DisplayChang= eListener *dcl, ssd->guest_dmabuf =3D NULL; ssd->guest_dmabuf_refresh =3D false; } + eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, + EGL_NO_SURFACE, qemu_egl_rn_ctx); egl_dmabuf_release_texture(dmabuf); } =20 --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047164; cv=none; d=zohomail.com; s=zohoarc; b=ac7bsApCX/WO9JDV9okOWfJzVwOhR3e14nY9gX6YLdC3RlXTPkNGiqfJfZL517r9Z/6Oud4wZJsudUYgT31Ker1JLsiF2wibU2EVbDJXFHvfL2812uWVamctpt5rpZ1kyjT8cbrH2KrKJEsVfox49/zxsrxtT7wzZhvuzQbOAtQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047164; 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=lIuJGnpVD5GH145GXgMfkdNa/VC4U9/ZZqHeHcYrX50=; b=UKPcLFEkoxvtF9WqsJx1Z8eJhzK9sElTK0I0QvQSNiZDOFlkK6Hi8OX9DktvADPZmXdwy5eLlMfikuElyR9rkxeh6qpZQI6dv8z70XlOiWYZGgyA1J8UGydIs9OSMBtZSItU4QX+CuxWWc9/zBHTz0PW+YYljQczwswdn3rFINE= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047164002776.2905791962838; Thu, 10 Sep 2026 06:32:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4esK-0004Vg-VI; Thu, 10 Sep 2026 09:31:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4esJ-0004MR-8y for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4esH-0003jH-So for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:35 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-195-GtbyktVrM1y0OT6PKxtMLg-1; Thu, 10 Sep 2026 09:31:27 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AE4FB1800767; Thu, 10 Sep 2026 13:31:25 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9A4B946E; Thu, 10 Sep 2026 13:31:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047093; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lIuJGnpVD5GH145GXgMfkdNa/VC4U9/ZZqHeHcYrX50=; b=J6lmdRDJ9RI1ls6Nrh1EHVpFm6TR1Roggo/JdHEdnUj0UWdFTy0oHj7GRE5XMwDtGMkPfi BcarmhBOFdBEou3ITZsHR7j4DkEm8NSQVyWuRuk/wjLecRtODZW3sc3XIRSMdog8V84n4E P/0QLOwymxf9FM/i6jyCrDKq7MnHX30= X-MC-Unique: GtbyktVrM1y0OT6PKxtMLg-1 X-Mimecast-MFC-AGG-ID: GtbyktVrM1y0OT6PKxtMLg_1789047085 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:30:09 +0400 Subject: [GIT PULL 14/24] virtio-gpu: release the dmabuf when a scanout is disabled MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-14-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko X-Developer-Signature: v=1; a=openpgp-sha256; l=1596; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=dZ2+WlnJ+Ih2ml2xkL8dChK2pCVpDNOwJQ4Wrb16+6s=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDcRcQrt47SiwbP8TsdhSdV8m3GqfqBwCzak NYjo3tXtr+JAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw3AAKCRDa6OEJdZac 5cLGD/9+ZhiSmfSVvxVuW/QMkpqZYLLV2T1y64YF5CPYoHQ5WetVPRu/NhW6NyIpy4+PrO1mbfY uuaoZUKgfacjQdAhoa+oGo8Gk6LVLwIyXz6Q0TCEBz8/jM9BVrGLAeOzpLwsc1IRgEXpvYSgv1e NFx0LInJ8bA9Dt6HbGzxNgBajcu+E2D4bInSo8VjsnzkMIu4a8Cn8z8sX75GDeWsYzWplYGFsFz wgFd7hnwte7XSCCU1SgmNiPswlJqPlBCNMd+h91t2tqPARLJaByKMez/stvhlZTZQ+hZ/nKZNEb ct2RVTPTIf0rERWtmOv6t9D4U2k9oURn622KEPwGxUQkt2RXXsniG9tY5yF41UoKh9E21DuPlhg PM/8/ySqMh0J4NZJDWmZdWuDEecGZD+NY3cVGQsGrWmP6rBf/NXdEiCGNdO0tZA7A4k4vSM2Ha4 4aJhTvpOYbOdcztlJr3fI4Xc+VZK+7PFNaI1qZn5YwCQFsc4LnheJ8liMP6CEppQfvO5b6DArw/ 6FJMvsYNRrw0duYXVIbI1/Ilt9oQS4+1hWEWQDleDTog/aBzMtYt5JHBqSxb1eoyDellMP8lB// efhaZHKcHO7VhfEsg9WOmwqC3ip3oF3hISpFV5KU71jYh+W7r7S0iqBnVMzYNmDGS+a6NlomvqV /BTf6ScEl7NlWHA== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1789047166519158500 Rather than waiting for the next set_scanout()/update_dmabuf() to replace it. Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/display/virtio-gpu.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index ecf3cbc4893c..bcde65b50349 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -418,20 +418,31 @@ static void virtio_gpu_resource_create_blob(VirtIOGPU= *g, QTAILQ_INSERT_HEAD(&g->reslist, res, next); } =20 +static void virtio_gpu_release_scanout_dmabuf(VirtIOGPU *g, int scanout_id) +{ + struct virtio_gpu_scanout *scanout =3D &g->parent_obj.scanout[scanout_= id]; + g_autoptr(QemuDmaBuf) dmabuf =3D scanout->dmabuf; + + if (!dmabuf) { + return; + } + + scanout->dmabuf =3D NULL; + qemu_console_gl_release_dmabuf(scanout->con, dmabuf); +} + void virtio_gpu_disable_scanout(VirtIOGPU *g, int scanout_id) { struct virtio_gpu_scanout *scanout =3D &g->parent_obj.scanout[scanout_= id]; struct virtio_gpu_simple_resource *res; =20 - if (scanout->resource_id =3D=3D 0) { - return; - } - res =3D virtio_gpu_find_resource(g, scanout->resource_id); if (res) { res->scanout_bitmask &=3D ~(1 << scanout_id); } =20 + virtio_gpu_release_scanout_dmabuf(g, scanout_id); + qemu_console_set_surface(scanout->con, NULL); scanout->resource_id =3D 0; scanout->ds =3D NULL; --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047132; cv=none; d=zohomail.com; s=zohoarc; b=G3CXP7k0tqdskEIABY9iWkg1Jmjq4EfUaPxK8HG1P81D1LU3zjtPHJLCUMc/bMZ3andvERb7KPqgD0sHLNNiP7Chba1c9aosDW4exW+bJYihK6B8zn+ziICVNvos8RbvPR9pCenrD1eJ7frw4RCmT4mjstWl5JG/2CQ8xRbQ+GU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047132; 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=tTpKPp9bmfG57LODxp6RB5dmZ5vLEDP1G4fJc7F1tIc=; b=K2uFzW4VY4MZfc9Ms4FfuDeBxaQyhtfgL49o6TNvLoZLooz+haZkVFtObvWYbRPNH6m7tcLb4fa10ivG3sG9yQYEQba+vfC1WhaQFPuiGIhjtVsa/d+yo0GWrmF8zTpnsauEuPc9bUwsxH6flC5KVz0oubFgWAOHkIgTG2y6a2Y= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047132156766.9157881832056; Thu, 10 Sep 2026 06:32:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4esM-0004gC-R9; Thu, 10 Sep 2026 09:31:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4esK-0004W1-Vx for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4esJ-0003jN-Fb for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:36 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-692-MO0PGOZJMdS8vRSs5Y4ENw-1; Thu, 10 Sep 2026 09:31:32 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 37A341955E79; Thu, 10 Sep 2026 13:31:31 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 61C7846E; Thu, 10 Sep 2026 13:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047094; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tTpKPp9bmfG57LODxp6RB5dmZ5vLEDP1G4fJc7F1tIc=; b=M3dvtdLsmrYACo+JMSjSem4NrsgsFrfv1z0L0YWJa9iZ1Yu+3GorSztwILHOA4LzsBMkol x/Yalm1yTvF4X7cykqsdBe3uMc8chPatn6zisb5GGYumjBDuUsCg4cdnep7Mt2C0P9tWPM 7nTaaNXPpr6LiIdUGFfMQZvE6iFS/X4= X-MC-Unique: MO0PGOZJMdS8vRSs5Y4ENw-1 X-Mimecast-MFC-AGG-ID: MO0PGOZJMdS8vRSs5Y4ENw_1789047091 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:30:10 +0400 Subject: [GIT PULL 15/24] contrib/vhost-user-gpu: drop scanout_bitmask bookkeeping MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-15-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , "Michael S. Tsirkin" , Stefano Garzarella X-Developer-Signature: v=1; a=openpgp-sha256; l=3153; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=6B5EZCR/TOMDpLrG+wIPlLqHW5uL7luP1S9QLKLFUPM=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDcxL8qF8e9Ko0TqTkI+b6iOSH1OLz6IjyaA /tDZc5VZHGJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw3AAKCRDa6OEJdZac 5X67EACyybLiSOWMUrA0SBYKs4SFD9I92nz3wL7lynqPhvoddWqcOwrA8UpUP/XJx2voM177tzy MavaMcHpyra2KioTXdZodr6ruK6zLs19l0iHwZtYd1t2Hmd8ZdGkJl7aBCW92EBSJ8rzedKUgHA 1i04RV0gx0xDhwTzbqgQntUp5WotVHGLoy/0BMNY+ILF4ABQmVwV0PCEpeeNRZBGOhwyhh1fpCf 7L+9xY5qA/YBc5t/rYwD82eyRa5214SV5xmDz0Flstg8fEZKD3zMC2e2I8yGxI1nbTkQkWhoJ6U RvG2twFRnauVloRY+3CDoQiALniHhj+1mr3jJ6CfekaT23th4E8uacueSwVmojLMTaTpevo4HW1 mOm7Qwv3jpvsc1SYnc44KMmPC7A3nREzhVUaeZXsOezR/zjJ9XWLc1QkfggGadjTRtbwkgIJyYt 1vBdGlrsdWuYOSNHtK7e6YDPyI+EAomQHE7kCfVFvEbkOCu4Zdmr9jRItHWvKKnD2b4vzEaH64i MfT9ZolZFBBV7lGKX48pWYawOIawKBkkKROcuHHUzvgL1jDfOSfJBx33aJHR1y1K599lzOcXqHB NgIMhgxuFJUAXdZxk9q0iZr9L6keycNn5IocOfYCsIrdDJ6P727V6/MPNa7no/Ku6ib5L62sF6O 201cCzkg1EK2MFQ== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1789047134240158500 The per-resource scanout_bitmask is a reverse index of which scanouts reference a given resource. The information is already available from scanout->resource_id. Performance impact should be negligible. Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- contrib/vhost-user-gpu/vhost-user-gpu.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/contrib/vhost-user-gpu/vhost-user-gpu.c b/contrib/vhost-user-g= pu/vhost-user-gpu.c index 933bdbb671c0..f70b34c179f3 100644 --- a/contrib/vhost-user-gpu/vhost-user-gpu.c +++ b/contrib/vhost-user-gpu/vhost-user-gpu.c @@ -36,7 +36,6 @@ struct virtio_gpu_simple_resource { uint32_t format; struct iovec *iov; unsigned int iov_cnt; - uint32_t scanout_bitmask; pixman_image_t *image; struct vugbm_buffer buffer; QTAILQ_ENTRY(virtio_gpu_simple_resource) next; @@ -416,17 +415,12 @@ static void vg_disable_scanout(VuGpu *g, int scanout_id) { struct virtio_gpu_scanout *scanout =3D &g->scanout[scanout_id]; - struct virtio_gpu_simple_resource *res; =20 if (scanout->resource_id =3D=3D 0) { return; } =20 - res =3D virtio_gpu_find_resource(g, scanout->resource_id); - if (res) { - res->scanout_bitmask &=3D ~(1 << scanout_id); - } - + scanout->resource_id =3D 0; scanout->width =3D 0; scanout->height =3D 0; =20 @@ -446,11 +440,9 @@ vg_resource_destroy(VuGpu *g, { int i; =20 - if (res->scanout_bitmask) { - for (i =3D 0; i < VIRTIO_GPU_MAX_SCANOUTS; i++) { - if (res->scanout_bitmask & (1 << i)) { - vg_disable_scanout(g, i); - } + for (i =3D 0; i < VIRTIO_GPU_MAX_SCANOUTS; i++) { + if (g->scanout[i].resource_id =3D=3D res->resource_id) { + vg_disable_scanout(g, i); } } =20 @@ -662,7 +654,7 @@ static void vg_set_scanout(VuGpu *g, struct virtio_gpu_ctrl_command *cmd) { - struct virtio_gpu_simple_resource *res, *ores; + struct virtio_gpu_simple_resource *res; struct virtio_gpu_scanout *scanout; struct virtio_gpu_set_scanout ss; int fd; @@ -707,12 +699,6 @@ vg_set_scanout(VuGpu *g, =20 scanout =3D &g->scanout[ss.scanout_id]; =20 - ores =3D virtio_gpu_find_resource(g, scanout->resource_id); - if (ores) { - ores->scanout_bitmask &=3D ~(1 << ss.scanout_id); - } - - res->scanout_bitmask |=3D (1 << ss.scanout_id); scanout->resource_id =3D ss.resource_id; scanout->x =3D ss.r.x; scanout->y =3D ss.r.y; @@ -797,10 +783,10 @@ vg_resource_flush(VuGpu *g, pixman_region16_t region, finalregion; pixman_box16_t *extents; =20 - if (!(res->scanout_bitmask & (1 << i))) { + scanout =3D &g->scanout[i]; + if (scanout->resource_id !=3D res->resource_id) { continue; } - scanout =3D &g->scanout[i]; =20 pixman_region_init(&finalregion); pixman_region_init_rect(®ion, scanout->x, scanout->y, --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047115; cv=none; d=zohomail.com; s=zohoarc; b=AJa11ziojyD1u24wv3iUb8VCUfz79ftmefXIB19mIWG7ArdJwOABzfuGDAwbh2gcQJUwE2vLkziEfziExHzzX1zt/xHduj1qB3ytvNnek4czue4mwN0dcWrKONaQ6foDKR7ZU/gDmxKmG51RtbgeRdK+NddxHbexab2k//hOaGA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047115; 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=9CEkb1pbqvdSjaTl5T02aLz3SneBoJfy3quphqY3VaY=; b=ZLBUvGumpf+N03WxYy+/FT5CehpxSiaiIJRMKNnm9ZPSkqJl4hv35qUAk9k/zavE66V7cjS66qYDYRRM6EJVC/g+msWo/wBaYGKgcwuBDS8ckd2vy/KbJTjsUXsNBbvaYhHDwr4/FIKkG+Z3wuvFThyU9sDUAt7rDEAj7lnH2WM= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047115213769.7306956849192; Thu, 10 Sep 2026 06:31:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4esS-0004xo-SL; Thu, 10 Sep 2026 09:31:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4esQ-0004sU-O8 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4esP-0003kK-8n for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:42 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-154-9EgUvoMwNiW4KeMH5CNgDQ-1; Thu, 10 Sep 2026 09:31:38 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8BB461954B0B; Thu, 10 Sep 2026 13:31:36 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BF3E91800473; Thu, 10 Sep 2026 13:31:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047100; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9CEkb1pbqvdSjaTl5T02aLz3SneBoJfy3quphqY3VaY=; b=JQSJRt9gFogNq9c3WzhlpAF1frCEYvDbS0yfC972K60+6FS6FzfIx5iukgKujiwunYDMyS 9bEsV9lHRehQMBfcW4KoS4YGoB6yZ6HwuG0zbDU6f/R0+5zAEjGueIigeb5RrzzjQa9jM3 /UZe3rQIBXttB6igHf1kFe1tkzVGLUM= X-MC-Unique: 9EgUvoMwNiW4KeMH5CNgDQ-1 X-Mimecast-MFC-AGG-ID: 9EgUvoMwNiW4KeMH5CNgDQ_1789047096 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:30:11 +0400 Subject: [GIT PULL 16/24] virtio-gpu-rutabaga: fix scanout handling MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-16-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko X-Developer-Signature: v=1; a=openpgp-sha256; l=3051; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=Y+x8YicNAXC2XmwidfmyoGEqbosScCND9O6ybcjTOno=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDdfFL36d0uY06d3ZyfQjTfTR2X0WEYE6YXi EW5a/3NvTSJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw3QAKCRDa6OEJdZac 5U2/D/9foSEvUMvIBRJBvl0hBXiFJ2JFpW6C6+dymDeGPNxbjpOF4LEzT4ro6f7J4MfPXtb2Jl+ SSex5BTU29NI7mpA5GxNfH2kVchAdSP58OnZZ9NUY/dbJDjONV38OwArNnvzHw0Q5OchK2+73Pt T10e4IFIAUFQTi1JZzloZAkTYrgZukC9gySrIg+rJbmYwVcSdbTX2Jm/7P0L6zdNIjByRfEXqk8 FUiwtPe2xHKtWfFAchzU8X5OIFqu5EmpLuDLfJy99JVXV8AAaX/vIyRyoImrpIhitGTKyyVTXin in37RukrIsP/Kp9IkuIN+2C/O2+wgBagjzW4CeD1O7pXP+M8IDiyx9jQjtgyvffJ6SCS7Dusiwp 0wlKpazKVTKbwND07tn5FM9tGKUd9uRSE9mubPdwhuDIJdMv9GCuH8XeaUO/Mc6TK+AcA5md2c+ zjWjOxNHboN6ZRwoNTvt4zmSVetpxvfsc3wPv00DwK4xNKddIhs/KyUVnIZKdyZl0b97U0w9+T+ HtyHggwaKJQwLT2rZPXx879+kKxxAvD/Mms0V3I9mpl3ALzVXME3xKbHZT8yPcm0XhRYcAGQ5WS lJITioVsOC6tjlY5pF767t808fnGlULPnLT3DjEM3XLgS1Ww9fMJ8eoO4FeeS5pQ5HntNISCy26 w2Vx4Ycjj2vpHwA== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1789047116147158500 The rutabaga backend was misusing the scanout_bitmask field as a plain scanout ID instead of a bitmask. Fix the scanout lookup to use scanout->resource_id directly. Also fix the missing resource_id clear when disabling a scanout, and flush all matching scanouts instead of just the first one. Fixes: 1dcc6adbc168 ("gfxstream + rutabaga: add initial support for gfxstre= am") Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/display/virtio-gpu-rutabaga.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/hw/display/virtio-gpu-rutabaga.c b/hw/display/virtio-gpu-rutab= aga.c index b8f8a2068d0b..8a82e96b7461 100644 --- a/hw/display/virtio-gpu-rutabaga.c +++ b/hw/display/virtio-gpu-rutabaga.c @@ -146,8 +146,15 @@ virtio_gpu_rutabaga_resource_unref(VirtIOGPU *g, Error **errp) { int32_t result; + int i; VirtIOGPURutabaga *vr =3D VIRTIO_GPU_RUTABAGA(g); =20 + for (i =3D 0; i < g->parent_obj.conf.max_outputs; i++) { + if (g->parent_obj.scanout[i].resource_id =3D=3D res->resource_id) { + virtio_gpu_disable_scanout(g, i); + } + } + result =3D rutabaga_resource_unref(vr->rutabaga, res->resource_id); if (result) { error_setg_errno(errp, @@ -251,7 +258,7 @@ rutabaga_cmd_resource_flush(VirtIOGPU *g, struct virtio= _gpu_ctrl_command *cmd) =20 for (i =3D 0; i < vb->conf.max_outputs; i++) { scanout =3D &vb->scanout[i]; - if (i =3D=3D res->scanout_bitmask) { + if (scanout->resource_id =3D=3D res->resource_id) { found =3D true; break; } @@ -275,7 +282,13 @@ rutabaga_cmd_resource_flush(VirtIOGPU *g, struct virti= o_gpu_ctrl_command *cmd) rf.resource_id, &transfer, &transfer_iovec); CHECK(!result, cmd); - qemu_console_update_full(scanout->con); + + for (i =3D 0; i < vb->conf.max_outputs; i++) { + scanout =3D &vb->scanout[i]; + if (scanout->resource_id =3D=3D res->resource_id) { + qemu_console_update_full(scanout->con); + } + } } =20 static void @@ -299,6 +312,7 @@ rutabaga_cmd_set_scanout(VirtIOGPU *g, struct virtio_gp= u_ctrl_command *cmd) scanout =3D &vb->scanout[ss.scanout_id]; =20 if (ss.resource_id =3D=3D 0) { + scanout->resource_id =3D 0; qemu_console_set_surface(scanout->con, NULL); qemu_console_gl_scanout_disable(scanout->con); return; @@ -332,7 +346,7 @@ rutabaga_cmd_set_scanout(VirtIOGPU *g, struct virtio_gp= u_ctrl_command *cmd) scanout->ds =3D qemu_create_displaysurface_pixman(res->image); qemu_console_set_surface(scanout->con, NULL); qemu_console_set_surface(scanout->con, scanout->ds); - res->scanout_bitmask =3D ss.scanout_id; + scanout->resource_id =3D ss.resource_id; } =20 static void --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047141; cv=none; d=zohomail.com; s=zohoarc; b=YEqxnrfEdDWDQnU2faXfVEHwIUp1nlYVgZzX5ZbzOyTRD9q+nY/fm9NlurV9T31Qq55kUAgj9kH8fZ3FxmC8wEf19LDtL1YgbGKGZ3RJBKHshxPnz8N2z/Rqdhw+Ml6NTiPfJN4nbB+r6xpiFzimXyyHoDiVPbXJ4/JrvjHwDhU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047141; 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=TYeXAmDf1Odc7i8PeL79UpH2Py/hNhTm0ExEtDUltCQ=; b=FvOplvGEMqIGhSdH5g8yNQFOTgiaiAYQMwQpPDOnDG/XGWw3BITW/dXdG4ELRHrCiqiBx6w3XVLYhoBC6AMK55FIaWMuxULuUZbCSKvrYGVZr6+0iYfg2ytOHl9SAdnWaggt9UfYqQ6zTjk6pRrq0kXwsP3+oufqiSXuSXDQH+Y= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047141488236.96714614586404; Thu, 10 Sep 2026 06:32:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4esY-0005AT-7G; Thu, 10 Sep 2026 09:31:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4esW-00056H-Ha for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4esU-0003l0-Od for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:48 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-676-uu_2x35qM66Hbnl7WTPUyQ-1; Thu, 10 Sep 2026 09:31:43 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3EB3B1954123; Thu, 10 Sep 2026 13:31:42 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D1C271800473; Thu, 10 Sep 2026 13:31:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047106; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TYeXAmDf1Odc7i8PeL79UpH2Py/hNhTm0ExEtDUltCQ=; b=RUT7ITTu1955QsSBnjcZDRrgeRDya9gIuqV1CZ2Meh+USABRc1fp4WiDTLU/nqh7L8TQ28 9vKZLrYDfoFg0P8owiUGZAOlN2XKrmvxSSlznWpyCazwZYweTw2ZZUE3f1upa2AaRm5Try yV0iNZorKEhwxWXa7HfFVUXpNQOmB9w= X-MC-Unique: uu_2x35qM66Hbnl7WTPUyQ-1 X-Mimecast-MFC-AGG-ID: uu_2x35qM66Hbnl7WTPUyQ_1789047102 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:30:12 +0400 Subject: [GIT PULL 17/24] virtio-gpu: drop scanout_bitmask bookkeeping MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-17-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko X-Developer-Signature: v=1; a=openpgp-sha256; l=3592; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=7Xe5PKyYiFdYI1lfnr9DrXWRq+TC3ng9j+1LCsQI3Lo=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDdLs88Uu7oiOykgI8Lzx3PkWVccMyRWW6vF /Iux+bvJUyJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw3QAKCRDa6OEJdZac 5RXHD/9n0UIxTe+hhQt+L8oFAPw8+eGytT3uT+Ql9PO36QtYKZuBJkTXbnEDBYR5RSITwkHfYOu 8PpWKd7sIAooUmv4PahBw9z/EbKhSojP/BahM/uQZrMuIEB/MYaJWwPIVK+MAywgIdpqmehvS86 8ACtJWwILg4Jd5sk0KdW6oTheE7Z9kdxBfaZEuP2UIg3//jZ3S68rDXwmyY+CkniCM0zRseXGYC Knfkn4ANzCK7PHEPFnE/EgRqG12l9WxKobS275WEg9P9Iso2xGXP7ta2QphFVykF+xYmJq2xgZn 3oq/CnpR3Ns7VJCBTeYCmbthA/cSj/pmJE9WxZ9nkk/L3T7NR81L1/A/RiWweQ7MPSm4eszak+X Wx3s/Ac29GnhLyYNSvPES5DokucbqF4yXEKPBzIbDojjPQF8FaKEXLamXMpAvNeyh2RckHBP/SG ii+brXhSvFQI6TS9ifKbEKU5nG8yeHgusWRkWUVUvgjDjiRk6MTsXq7TQF2RSNjg2Sneev/uDQe fnTNkVpyq63b5Eh3Ko0fAFDcQMt0TyC3iiZgE3CduM5ISylo4xkaAvmqbmwLMXSc3ctMspjvYyQ a52cZ8EE5pULXy65bPd+Xuk0bYTlshK5O9oaS2gHqSk2SYGM2MsGTzXGNZvxx+nXhWe9CMwdyhh HLL6lQTKZQErl+A== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1789047142422158500 The per-resource scanout_bitmask is a reverse index of which scanouts reference a given resource. The information is already available from scanout->resource_id. Performance impact should be negligible. Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/display/virtio-gpu.c | 26 +++++--------------------- include/hw/virtio/virtio-gpu.h | 1 - 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index bcde65b50349..6e021b78b890 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -434,12 +434,6 @@ static void virtio_gpu_release_scanout_dmabuf(VirtIOGP= U *g, int scanout_id) void virtio_gpu_disable_scanout(VirtIOGPU *g, int scanout_id) { struct virtio_gpu_scanout *scanout =3D &g->parent_obj.scanout[scanout_= id]; - struct virtio_gpu_simple_resource *res; - - res =3D virtio_gpu_find_resource(g, scanout->resource_id); - if (res) { - res->scanout_bitmask &=3D ~(1 << scanout_id); - } =20 virtio_gpu_release_scanout_dmabuf(g, scanout_id); =20 @@ -456,11 +450,9 @@ static void virtio_gpu_resource_destroy(VirtIOGPU *g, { int i; =20 - if (res->scanout_bitmask) { - for (i =3D 0; i < g->parent_obj.conf.max_outputs; i++) { - if (res->scanout_bitmask & (1 << i)) { - virtio_gpu_disable_scanout(g, i); - } + for (i =3D 0; i < g->parent_obj.conf.max_outputs; i++) { + if (g->parent_obj.scanout[i].resource_id =3D=3D res->resource_id) { + virtio_gpu_disable_scanout(g, i); } } =20 @@ -639,10 +631,10 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g, for (i =3D 0; i < g->parent_obj.conf.max_outputs; i++) { QemuRect rect; =20 - if (!(res->scanout_bitmask & (1 << i))) { + scanout =3D &g->parent_obj.scanout[i]; + if (scanout->resource_id !=3D res->resource_id) { continue; } - scanout =3D &g->parent_obj.scanout[i]; =20 qemu_rect_init(&rect, scanout->x, scanout->y, scanout->width, scanout->height); @@ -667,16 +659,9 @@ void virtio_gpu_update_scanout(VirtIOGPU *g, struct virtio_gpu_framebuffer *fb, struct virtio_gpu_rect *r) { - struct virtio_gpu_simple_resource *ores; struct virtio_gpu_scanout *scanout; =20 scanout =3D &g->parent_obj.scanout[scanout_id]; - ores =3D virtio_gpu_find_resource(g, scanout->resource_id); - if (ores) { - ores->scanout_bitmask &=3D ~(1 << scanout_id); - } - - res->scanout_bitmask |=3D (1 << scanout_id); scanout->resource_id =3D res->resource_id; scanout->x =3D r->x; scanout->y =3D r->y; @@ -1707,7 +1692,6 @@ static int virtio_gpu_post_load(void *opaque, int ver= sion_id) if (scanout->cursor.resource_id) { update_cursor(g, &scanout->cursor); } - res->scanout_bitmask |=3D (1 << i); } =20 return 0; diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index c2018b41056f..071cbbb6113e 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -51,7 +51,6 @@ struct virtio_gpu_simple_resource { uint64_t *addrs; struct iovec *iov; unsigned int iov_cnt; - uint32_t scanout_bitmask; pixman_image_t *image; qemu_pixman_shareable share_handle; uint64_t hostmem; --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047171; cv=none; d=zohomail.com; s=zohoarc; b=afUtDZNZHG8TO9nwYZoyskXk3IzaBAdhw5tBQnveIvCryfkHlkbSxwEReiXjld7/yyh3P8HdXm7IkUjBoO71P5csqnnK7eAXBVt12kwfDtPTqnH0VV2FB8pg1bP1Oai7siYjArs+mqEvNH6e16ixbSwBAlDiqipxE5RjRu005yc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047171; 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=khbpV+xiZresNyGTZT3mIZWPgj/akniR2wAoczGH8Xs=; b=ia32rMXSNe9xic7y04YqPhukPqiAO/FEqsfQg7DrKAWwFTLxyuuH6oknctiUIZmwGcZvDmAw7SrPnfbvJhdM8dbHynmKQfXViJ4gqule/FF7VOXo5aP0ZzkuqiDCGWPSbYjklaO+o2Bg4J9W8R/2f0+ZT3l134GqMBS2DmaozYI= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047171753337.6409297303733; Thu, 10 Sep 2026 06:32:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4etB-0007Pc-KH; Thu, 10 Sep 2026 09:32:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4etA-0007Js-1K for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:32:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4et7-00045F-Oq for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:32:27 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-620-VTDDq6aCNUiYXEqLll2G1w-1; Thu, 10 Sep 2026 09:31:57 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1CBFD1800644; Thu, 10 Sep 2026 13:31:46 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E78261800473; Thu, 10 Sep 2026 13:31:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047142; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=khbpV+xiZresNyGTZT3mIZWPgj/akniR2wAoczGH8Xs=; b=J+YuaQ4OT7zKpxYzHctDOvNtEl16cbSpeogr8AiT7gwJc9FucnAZn4NTIjzTDfb1izqLY0 4e0VQqu59gE96l5SWrOCQcNMNUihoUdhjmSgaOFhZvldl206l/iPFaRog2cciu591pw+yw UeCER5WJMbK/ED8EfCz88vF9Mwu+mh0= X-MC-Unique: VTDDq6aCNUiYXEqLll2G1w-1 X-Mimecast-MFC-AGG-ID: VTDDq6aCNUiYXEqLll2G1w_1789047106 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:30:13 +0400 Subject: [GIT PULL 18/24] virtio-gpu: release dmabuf when switching to a surface MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-18-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , "Michael S. Tsirkin" X-Developer-Signature: v=1; a=openpgp-sha256; l=2604; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=pgJLh95j61L6xCFJ/JYnj7bpQvTkIQF1Ao6BM4GA2P8=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDdBPuwFNvh7nR2nYA/z/8m2VBRIy588vBZ2 hHaGojJO2GJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw3QAKCRDa6OEJdZac 5ZifD/9pnLx+JIDzvOZQeWQtNbiLZz732u8FfmoBb6+b3Rk1wi42SFZjl9H1GoYDj4WgffTP69D j/zmwg5S4KjB3wJBYd2yKBrmmEyM3/V3wDTEKrSsiocK6fWgJsQaQ/tt98ZbOGlg6jA6tD5ip6Z 0sBTXAh0XvMQfVmLwvvZp+d93V3T6IslSg1Uebib+RzIz1d89UOl0n9JuB9Ebu3ndOeV8h5KHGw EnGaGLIdwfniPCBkaVZ96HRFDdS0BdeU9Kt7a+dtOTGzwjnX9+35ynFN+WMUAWm5hNeArTpW7vR WZP9dVoHmFluXCz20pOMCw9GKQ9xUJITlvYYZUOd2VTutt5yPFP27dR3G8AwkpSJm6ydiflPqev IMxnfpYrlp4kPhHyL+ZWf2VhNtdjaqdRZ+G8quHLiY569j2dofXJ7npbF+55DjwkP4smBAO7q49 Jm8sX80lbG/FqxRztntJ6tGKutycedxMxLgl8zdXaSyEh2VdqxWoPvMpU6DwDOY24400omKnhd7 UBQYgQE05kpW7ztOYOqHA8kgTdyp2TROaDGAn9Ox6W0HdyQkrIB45HmcN+lPaLCjcX0Hj8gko3Z RptbLEJvSUmhX8qDlVgMYGlxtmUbaTVoITfRJ0CQV2FhzzSEAwMx+3i20W20A9HAPc/icm2a46F YxsNqwZlJXi2/Og== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1789047172497158500 A scanout may hold an active QemuDmaBuf when a SET_SCANOUT switches to CPU-backed display data. Force surface recreation and release the old buffer in this case. Fixes: 32db3c63ae11 ("virtio-gpu: Add virtio_gpu_set_scanout_blob") Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/display/virtio-gpu.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 6e021b78b890..b2cba26405c5 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -704,9 +704,11 @@ static bool virtio_gpu_do_set_scanout(VirtIOGPU *g, { struct virtio_gpu_scanout *scanout; uint32_t bytes_pp =3D virtio_gpu_format_bytes_pp(fb->format); + bool was_dmabuf; uint8_t *data; =20 scanout =3D &g->parent_obj.scanout[scanout_id]; + was_dmabuf =3D scanout->dmabuf !=3D NULL; =20 if (!virtio_gpu_check_scanout_bounds(scanout_id, res->resource_id, fb->width, fb->height, r, error))= { @@ -733,12 +735,11 @@ static bool virtio_gpu_do_set_scanout(VirtIOGPU *g, =20 if (res->blob) { if (qemu_console_has_gl(scanout->con)) { - if (!virtio_gpu_update_dmabuf(g, scanout_id, res, fb, r)) { - virtio_gpu_update_scanout(g, scanout_id, res, fb, r); - } else { + if (virtio_gpu_update_dmabuf(g, scanout_id, res, fb, r)) { *error =3D VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY; return false; } + virtio_gpu_update_scanout(g, scanout_id, res, fb, r); return true; } =20 @@ -748,7 +749,8 @@ static bool virtio_gpu_do_set_scanout(VirtIOGPU *g, } =20 /* create a surface for this scanout */ - if ((res->blob && !qemu_console_has_gl(scanout->con)) || + if (was_dmabuf || + (res->blob && !qemu_console_has_gl(scanout->con)) || !scanout->ds || surface_data(scanout->ds) !=3D data + fb->offset || scanout->width !=3D r->width || @@ -773,6 +775,9 @@ static bool virtio_gpu_do_set_scanout(VirtIOGPU *g, qemu_displaysurface_set_share_handle(scanout->ds, res->share_handl= e, fb->offset); =20 pixman_image_unref(rect); + if (was_dmabuf) { + virtio_gpu_release_scanout_dmabuf(g, scanout_id); + } qemu_console_set_surface(g->parent_obj.scanout[scanout_id].con, scanout->ds); } --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047177; cv=none; d=zohomail.com; s=zohoarc; b=hvijmNhB1APSRaUzLPESnGhfFYNry6rILMaTgqkrHhYD9pSw2SKlF1MnxH15182GdBLPu5vJaedd1JVpMyEit+9pCj5QyM6DiRq4U2vPfjNBd3/7kMBYS+TJ8mSK2rfgZfyAZ5Ljaa207sH30Q3Wb9nLjNO5kTjWnzcrr4t+OTQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047177; 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=Qzuszcrbg6cohD5Tu05YF9g7VRkT6a8sFno1QxC857s=; b=MHZY3SzH9tggOEOokwlUY1lB3tXk8rJywW0nMG1HY7BZaoxtDRccFqoBU3H0DAydvwNTP7sJiIuMZm/ZSKxPlClkkAsGK65hdj0U87JGMkNr8bMsl17wRuOECQNU6ItksvmmcWjdXb1zBxDh0xVOxD4g70BA2968Hk+hrhAXRSw= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047177936608.9766850711364; Thu, 10 Sep 2026 06:32:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4esf-0005UW-7Q; Thu, 10 Sep 2026 09:31:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4esd-0005OH-8x for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4esb-0003q2-Qb for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:31:55 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-374-HQHLI3S9MHSfZGBFEDOkrw-1; Thu, 10 Sep 2026 09:31:50 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8199D19540D3; Thu, 10 Sep 2026 13:31:49 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 73EAB1955F19; Thu, 10 Sep 2026 13:31:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047113; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Qzuszcrbg6cohD5Tu05YF9g7VRkT6a8sFno1QxC857s=; b=SwGwx1uCLknUX6l7NK0eK3Cqs3VqlNR8NbkMop02IsO6G9vkucXRr0TN3mSFdGK852kh8a QeOo6bh3jLDs9jKagwee8Gbs2B62aomkC1rPXuSzY/kamwBaHWFswEENfHYCU7Txr/diAs 3dEpODVYpNbjVtDWKaMvHS2y46Ny5aA= X-MC-Unique: HQHLI3S9MHSfZGBFEDOkrw-1 X-Mimecast-MFC-AGG-ID: HQHLI3S9MHSfZGBFEDOkrw_1789047109 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:30:14 +0400 Subject: [GIT PULL 19/24] virtio-gpu/virgl: release dmabuf when a texture replaces a scanout MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-19-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko X-Developer-Signature: v=1; a=openpgp-sha256; l=2385; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=1ZzvdpWhDv1qIdQGLav3DavQ9DdkXg1Nj4VP5JBHZlI=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDdgf9hqR8F67p26zPvZHHcJo1IBpFnC21Ru RTnyPA4rbWJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw3QAKCRDa6OEJdZac 5Y5DD/0WhvJ0V+MpVFALK4VRA4KjHr7ZpLHsTd+0C8c8nhqHSV+qddOq/Wkvtn96zkFjOyH9biV 4daM0lv+Ge5HtW8T7ojDXccZhi4aIWgsHvaBtD0IjbAbSSTTTp9HC+iWAYIDvYsXdFaQWfhDwKH jidHbtWAq+oGQ8dT/J99m2rYcpaFW8fazTBrZOCXc5NnpIMwI5IxhjoGzoEwPCcvwtr81zhgyEM cBjNRkmpW2U32Tf/2Gg3dNfrOvzwRr2vBfENJjSllMIpb6bt4hbHtDf8fKAuMSXdMr9Iyg9qfUh J8Ific9aHRWKY6zdN2ANlL/QYJ6DKJ2xVZD9pojZk80RbRxqiHsLv4IOFxIvvuKbQoH1/b3I/DX PkMFru+3H8jbMv131dEhAOt2Gjpxn9J5s/NpYA2TjWu8xjwpSw8s+AVnzQL3H/Ye3LYCfxK6nUQ L4ITraJIaq4tu3Mab6QuOsRv2rd91Y1A+5KkfxBMzC/KSQlkciO4hGgD29mXRQA++RYhKi71gUB rnZGf1XI/TVYkXXkCAR32j/zOj3mGJN8ID1juMhN85+4lL1N2rL2vfqSJcfLdLIo8w1IpFCKkT7 ymCTdD3RER/1DOVKlkGaMV0PKpP8ctIDXzu6sC6JOQqbSbO0yzJykNVL7RPCWmhDfZSJMPn/Hqq MHxdtjolPdmYzwQ== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1789047178502158500 Release the scanout dmabuf before installing the texture. A full virtio_gpu_disable_scanout() is not used because the scanout is reassigned immediately afterwards. Fixes: 7c092f17ccee ("virtio-gpu: Handle resource blob commands") Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/display/virtio-gpu-virgl.c | 3 +++ hw/display/virtio-gpu.c | 2 +- include/hw/virtio/virtio-gpu.h | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 0e43eacca406..07349c5c5502 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -605,6 +605,9 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g, &cmd->error)) { return; } + + virtio_gpu_release_scanout_dmabuf(g, ss.scanout_id); + qemu_console_resize(g->parent_obj.scanout[ss.scanout_id].con, ss.r.width, ss.r.height); virgl_renderer_force_ctx_0(); diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index b2cba26405c5..f9083e9577c3 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -418,7 +418,7 @@ static void virtio_gpu_resource_create_blob(VirtIOGPU *= g, QTAILQ_INSERT_HEAD(&g->reslist, res, next); } =20 -static void virtio_gpu_release_scanout_dmabuf(VirtIOGPU *g, int scanout_id) +void virtio_gpu_release_scanout_dmabuf(VirtIOGPU *g, int scanout_id) { struct virtio_gpu_scanout *scanout =3D &g->parent_obj.scanout[scanout_= id]; g_autoptr(QemuDmaBuf) dmabuf =3D scanout->dmabuf; diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 071cbbb6113e..2f18d839ccd3 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -371,6 +371,8 @@ bool virtio_gpu_check_scanout_bounds(uint32_t scanout_i= d, uint32_t resource_id, const struct virtio_gpu_rect *r, uint32_t *error); =20 +void virtio_gpu_release_scanout_dmabuf(VirtIOGPU *g, int scanout_id); + /** * virtio_gpu_scanout_blob_to_fb() - fill out fb based on scanout data * fb: the frame-buffer descriptor to fill out --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047149; cv=none; d=zohomail.com; s=zohoarc; b=RMCA0MGr9njx8Mdn/tUyo9TChZ1mNz4BFHLMCEwIufEOo6j5qBnEUlWkDSbOc6/bv84SipwHEXt+YyWqNeNpwRLuxnkEXeREvZvsc1gXo0VB2JwIefZVZ+ZfJ2GTm3PwWPw7CGzF5YHu7qDCw08QfhbocFFOTfXuUABjW8g6flU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047149; 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=MvNyUJjuFzcqC2iFaLkKRxphw3kHwaQNe4NAJWBqFPA=; b=c4sKmBoUxU1p4YgdHY8AqySCWZ6LBK/mhPCxS45EITNlUlUPs8ivBVRuQXHnTDl6pWEbGvF4DNjsPq+Midf139s7ytjDgbnGZEPGXgKBCMED2bDzbBnzM7IddNf/dqZKCaqgFFMUUc8ZWnvHJViZeJ+XBMk/8zfE3oBXU2DccvY= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047149864256.59794996577716; Thu, 10 Sep 2026 06:32:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4est-0006Uq-Ig; Thu, 10 Sep 2026 09:32:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4esq-00068h-66 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:32:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4esm-0003zC-R0 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:32:07 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-154-FroBou5PPC-PNzmLIr58KA-1; Thu, 10 Sep 2026 09:32:00 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AEE401800107; Thu, 10 Sep 2026 13:31:57 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 418171800473; Thu, 10 Sep 2026 13:31:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047124; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MvNyUJjuFzcqC2iFaLkKRxphw3kHwaQNe4NAJWBqFPA=; b=YZr1J0AzfMeq4h0gHszUOOlpCCXkPVNn4Sx/OkeUqE1nm9TApm5ZsJ2UUYNJ9DKvWwGDuM MTN1+GMZig+tuO+NC0u2ZBKmlG1vLQOLRYpAZqXKimR5jA2wJktuK+HspT3yS23ndU9VxD D1uExCevrXZWXyM8dIgMGcdZ+u2Uwrs= X-MC-Unique: FroBou5PPC-PNzmLIr58KA-1 X-Mimecast-MFC-AGG-ID: FroBou5PPC-PNzmLIr58KA_1789047117 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:30:15 +0400 Subject: [GIT PULL 20/24] virtio-gpu: consolidate disabling scanout MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-20-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko X-Developer-Signature: v=1; a=openpgp-sha256; l=2706; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=7XLRL3MdrOOrKTPpYXgRLHhm68Cq391ch99tcYm3POg=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDdFdvz7vclGkwsM6vrF7X6wU/bv/GLny2hM jZU2V8r3/CJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw3QAKCRDa6OEJdZac 5ToMD/0RP9n02V6/IICJ6UgeG3rn8wUo/dyXiLKezt+HrjCNzjmf0TCqWSU73EH/p0Yaal+Guir bbaSjLyshwn49HsO4auP+tswpBO5NWTWLs4OV+R3VDp/hrGgtld2GyHpXz/+Ln9C318yA7wUHyt VcCZxoXon340EOl3+Wr0plOU/ky99ter4hU8GzAXJ1OeAF8VEJGB+wFTI6pIOYM7m2LNvbjwKXN cPycoqLO+DcGZWfE5G76iRlnShltqJG32rAQAicDNfG73tTWIidBY1sarS74CjPKDR9jI9t9kWE KwiVatGXdrMh7WSBLeL7SZbO9ZRR4ZFgN0FColSwKH2hWFG4nCVn02CUXvRe120i8Ol7aM/+SHX oDYXOHEaOCyMULCgjogXksmwrf1LwVSJg8xfTp/AIlWqC2y0snFk0aba5sj89ttIh/4h3xtgZVX wf9pVZ3f1qt4vlby8N9JwDSg0lGxS1xqKPdVQ1f911JRVd0IrVubERDBe4sy/ZNBPOTBAwGEUaJ JIASnmoj5kirv4w8VGXfZPUmBVxdNeN3XV3wvkW3uvfq79WwVsThxZ+EYsedUPz1szZsAsOuiny qIfL6ZwkCevz06pDusyd8V18DLaT27B5AFaoMkKGG98VghhLvcz4zJ5IHSmSlmNCO0sVabh+XXq bIMlUp7x5xyf6/Q== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1789047150438158500 Use the common virtio_gpu_disable_scanout() to reset the scanout state, including GL state if any. Fixes: 7c092f17ccee ("virtio-gpu: Handle resource blob commands") Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/display/virtio-gpu-rutabaga.c | 4 +--- hw/display/virtio-gpu-virgl.c | 6 ++---- hw/display/virtio-gpu.c | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/hw/display/virtio-gpu-rutabaga.c b/hw/display/virtio-gpu-rutab= aga.c index 8a82e96b7461..8697dd6936ba 100644 --- a/hw/display/virtio-gpu-rutabaga.c +++ b/hw/display/virtio-gpu-rutabaga.c @@ -312,9 +312,7 @@ rutabaga_cmd_set_scanout(VirtIOGPU *g, struct virtio_gp= u_ctrl_command *cmd) scanout =3D &vb->scanout[ss.scanout_id]; =20 if (ss.resource_id =3D=3D 0) { - scanout->resource_id =3D 0; - qemu_console_set_surface(scanout->con, NULL); - qemu_console_gl_scanout_disable(scanout->con); + virtio_gpu_disable_scanout(g, ss.scanout_id); return; } =20 diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 07349c5c5502..9ca7b946ac65 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -618,8 +618,7 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g, ss.r.x, ss.r.y, ss.r.width, ss.r.height, d3d_tex2d); } else { - qemu_console_set_surface(g->parent_obj.scanout[ss.scanout_id].con,= NULL); - qemu_console_gl_scanout_disable(g->parent_obj.scanout[ss.scanout_i= d].con); + virtio_gpu_disable_scanout(g, ss.scanout_id); } g->parent_obj.scanout[ss.scanout_id].resource_id =3D ss.resource_id; } @@ -1430,8 +1429,7 @@ void virtio_gpu_virgl_reset_scanout(VirtIOGPU *g) int i; =20 for (i =3D 0; i < g->parent_obj.conf.max_outputs; i++) { - qemu_console_set_surface(g->parent_obj.scanout[i].con, NULL); - qemu_console_gl_scanout_disable(g->parent_obj.scanout[i].con); + virtio_gpu_disable_scanout(g, i); } } =20 diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index f9083e9577c3..e8a0dd24c873 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -436,7 +436,7 @@ void virtio_gpu_disable_scanout(VirtIOGPU *g, int scano= ut_id) struct virtio_gpu_scanout *scanout =3D &g->parent_obj.scanout[scanout_= id]; =20 virtio_gpu_release_scanout_dmabuf(g, scanout_id); - + qemu_console_gl_scanout_disable(scanout->con); qemu_console_set_surface(scanout->con, NULL); scanout->resource_id =3D 0; scanout->ds =3D NULL; --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047140; cv=none; d=zohomail.com; s=zohoarc; b=DOzPYY6xByWLMAEcJ0O/Z7ctS0xdEg0GTxgn+2K/Zhx+dBfOZ2otqp5xZpH62b5F8G3FBR/oXMWuz6oZcXvQCLGyvu7+pH9tUpCxYV5d1ho5UA+9fpBNQatESpnndZe6xC+75ZD6845s1vpZr6ZiEzBo/PDKctpp611Dgao2ST4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047140; 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=902u+6hgzHqWrogcJHQVHdXlrrsugRKXQmYtn6d7nPM=; b=X8T0oe2pc0P3aueUuSavVybyETy3Q47ws5zkMGBUBKEEHB9LUbrd3GYW3I3zvky/9KDwS6mWLmpAsyshDruXFl2jsN0cjVbK3TeYSoHJWKQYsTmzy9Aa7eTPiobfLaxVnJhl2lSdHan3Qzn1XSBYD05rRhWySqzwp133omPG1L0= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047140781885.9882077559037; Thu, 10 Sep 2026 06:32:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4esw-0006mn-O2; Thu, 10 Sep 2026 09:32:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4est-0006Wz-Qb for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:32:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4ess-00041H-58 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:32:11 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-257-idcFF5aGPLWeMgMAZ_JS3Q-1; Thu, 10 Sep 2026 09:32:06 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 034F61800868; Thu, 10 Sep 2026 13:32:05 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B2B5C1956095; Thu, 10 Sep 2026 13:32:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047129; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=902u+6hgzHqWrogcJHQVHdXlrrsugRKXQmYtn6d7nPM=; b=IQ89JZcKHh+Bu4Wzkm3Oe1zPdpGTxWTnZSzVbz+2yeVcT6hvIGjdFetRehipzvGBlT6Vxb LVntCUxd4SbWbIGGFRKgCYKn3htMxPDY/hNRs3/FsvhQbALxCw+7RzRMX6m5+JHBSbS6tW R86jlN7ckNka9bSRLDulBmSCBW9gywI= X-MC-Unique: idcFF5aGPLWeMgMAZ_JS3Q-1 X-Mimecast-MFC-AGG-ID: idcFF5aGPLWeMgMAZ_JS3Q_1789047125 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:30:16 +0400 Subject: [GIT PULL 21/24] virtio-gpu: minor refactoring MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-21-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko X-Developer-Signature: v=1; a=openpgp-sha256; l=4171; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=IklnvtowgSiW7XcZhDXrwO6dFmeBIZQTUPYB+WJoMZk=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDdxUzbbNjoNa3APgmr+De+w6dIJl5xefpIg cfupBN1U36JAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw3QAKCRDa6OEJdZac 5XLnD/9IEmx7hO0CqgqoKf8do0R75M/Z9MELKtTXBtDZCAYL2n64lVRBrvFpch6oH9nb1cj7SGp n33V0p3RU46GsjObTgHDM+AcJiE1rFs+nq1K4CKNw3a4VFTSr5IpqEbVlzaGe5bF3dpivc27/M5 nifsn1xvbEZrUe44uVVHT2CeGzraaAHp56CM1pDCWSD630/tWGqvAyQ/k9CB5/K3ril09qLeEbW MJWM7blz2z7BJw+UUh3ZPJzN3Xkf+jqHouKiDqHNsWn5BEmO6PFSEwuCi3zCg7ugAkmu6/nAKax nzMPWRvxlj3nTejgyGk+yBVceqMU4o34Y9GsFYyv/5tEhu8AiMb2NwTGJZ9p9MMuNZ5CJdvL8HA sQG8hvCN/wOmeSInTpWAyxJ0bChanAed9DnxsMp+veT9Ms3+ujnibl1DLj6Af4MMuY3lplKFoj3 1OZYXNN6Ng2+Cmro/pjaGSzN9aV+Unfo1Pmzm09I1Af3r1GKlSmzwpQd/wc5y8Hwuu7GOV2kkK6 U4jJ2Xvm74HuViAisUHtuLOCDwNa07vZZON5U0SNghY8OtnJZPUapoD365uTqWWNq095BWq6xoi BHCNIFVv8NbjWIaL4FmXLTkGIrjdVzL2iZHdjC04EVWMyfqvjQo/rWSYt1ltAZxlmk4t6DrZgea cgnNqXI5aiZ80bA== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1789047142433158500 Move disable_scanout() branch earlier, return early. (scanout->resource_id is cleared there) Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/display/virtio-gpu-virgl.c | 71 ++++++++++++++++++++++-----------------= ---- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 9ca7b946ac65..439a6e1c1cff 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -565,6 +565,8 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_set_scanout ss; + struct virgl_renderer_resource_info info; + void *d3d_tex2d =3D NULL; int ret; =20 VIRTIO_GPU_FILL_CMD(ss); @@ -579,47 +581,46 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g, } g->parent_obj.enable =3D 1; =20 - if (ss.resource_id) { - struct virgl_renderer_resource_info info; - void *d3d_tex2d =3D NULL; + if (!ss.resource_id) { + virtio_gpu_disable_scanout(g, ss.scanout_id); + return; + } =20 #if VIRGL_VERSION_MAJOR >=3D 1 - struct virgl_renderer_resource_info_ext ext; - memset(&ext, 0, sizeof(ext)); - ret =3D virgl_renderer_resource_get_info_ext(ss.resource_id, &ext); - info =3D ext.base; - d3d_tex2d =3D ext.d3d_tex2d; + struct virgl_renderer_resource_info_ext ext; + memset(&ext, 0, sizeof(ext)); + ret =3D virgl_renderer_resource_get_info_ext(ss.resource_id, &ext); + info =3D ext.base; + d3d_tex2d =3D ext.d3d_tex2d; #else - memset(&info, 0, sizeof(info)); - ret =3D virgl_renderer_resource_get_info(ss.resource_id, &info); + memset(&info, 0, sizeof(info)); + ret =3D virgl_renderer_resource_get_info(ss.resource_id, &info); #endif - if (ret) { - qemu_log_mask(LOG_GUEST_ERROR, - "%s: illegal resource specified %d\n", - __func__, ss.resource_id); - cmd->error =3D VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; - return; - } - if (!virtio_gpu_check_scanout_bounds(ss.scanout_id, ss.resource_id, - info.width, info.height, &ss.= r, - &cmd->error)) { - return; - } =20 - virtio_gpu_release_scanout_dmabuf(g, ss.scanout_id); - - qemu_console_resize(g->parent_obj.scanout[ss.scanout_id].con, - ss.r.width, ss.r.height); - virgl_renderer_force_ctx_0(); - qemu_console_gl_scanout_texture( - g->parent_obj.scanout[ss.scanout_id].con, info.tex_id, - info.flags & VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP, - info.width, info.height, - ss.r.x, ss.r.y, ss.r.width, ss.r.height, - d3d_tex2d); - } else { - virtio_gpu_disable_scanout(g, ss.scanout_id); + if (ret) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: illegal resource specified %d\n", + __func__, ss.resource_id); + cmd->error =3D VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + return; } + if (!virtio_gpu_check_scanout_bounds(ss.scanout_id, ss.resource_id, + info.width, info.height, &ss.r, + &cmd->error)) { + return; + } + + virtio_gpu_release_scanout_dmabuf(g, ss.scanout_id); + + qemu_console_resize(g->parent_obj.scanout[ss.scanout_id].con, + ss.r.width, ss.r.height); + virgl_renderer_force_ctx_0(); + qemu_console_gl_scanout_texture( + g->parent_obj.scanout[ss.scanout_id].con, info.tex_id, + info.flags & VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP, + info.width, info.height, + ss.r.x, ss.r.y, ss.r.width, ss.r.height, + d3d_tex2d); g->parent_obj.scanout[ss.scanout_id].resource_id =3D ss.resource_id; } =20 --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047182; cv=none; d=zohomail.com; s=zohoarc; b=X19EeFdvC2uAqgHX01wAXkVESICE/AGjXFQUQgn5rBtqgQUqGtxdZZa1ceEVEjNJjtcq8c/AinCBcxuxxMeQUH1w9PSTsUn6nPbcm4dlEeSJiCwd9hUgm/NJOGw7PqyPmMDQR+aAAjcE7vOPKdc/P5vki6GLu9It4mqT1ftyM8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047182; 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=ciD/ZVt5jW5QMxT+f6uRd+L51Y2xcWI2H63rFBdrxlU=; b=EXG51R4NaHfNYiZWETuxyn4YzbMsI/Co2zdWjEgASa7f6psLwNtC18Q3M0xVXffiEwCtSl/54kJLSK1KNigmMYQuq/P/xf+0YeXjvJP0SKZh63G5gsPIxFeusKV0B3IdicGyPzkvozZxQremYiqU78p87Nel7zEmgRQUoeqUMUQ= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047182763964.4893941721974; Thu, 10 Sep 2026 06:33:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4et0-0006uV-1H; Thu, 10 Sep 2026 09:32:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4esy-0006si-9b for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:32:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4esw-00041t-TJ for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:32:16 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-227-cAO4OFpzPnaJLlAY-30fXg-1; Thu, 10 Sep 2026 09:32:12 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 02DCA195607D; Thu, 10 Sep 2026 13:32:11 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7FC2D1955F19; Thu, 10 Sep 2026 13:32:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ciD/ZVt5jW5QMxT+f6uRd+L51Y2xcWI2H63rFBdrxlU=; b=BZtwn02oOGE5l3noj6z9EXKNfUfV56fKOqPgiuI530TKeQfVWEkcuC+3SQmpm+22No+Bt4 JZ//i7iR5B5jALCqNlE2t2oPZXEshA6/eAxyJhIp19jUTvmde7UMdMKChsdR6/0XiNakVy YI0wFFEUtj9lPhLak7kpjZXuYsk54w0= X-MC-Unique: cAO4OFpzPnaJLlAY-30fXg-1 X-Mimecast-MFC-AGG-ID: cAO4OFpzPnaJLlAY-30fXg_1789047131 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:30:17 +0400 Subject: [GIT PULL 22/24] virtio-gpu/virgl: disable scanouts on resource unref MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-22-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko X-Developer-Signature: v=1; a=openpgp-sha256; l=1424; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=n0CW0Sj52YaRlzK5eDiTgnftbv+1PgAfeZqW5A1Onl0=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDdU1u8lAIcAeYt12oqngZMi3TBfiF1U6N3f kwoOBDtDQGJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw3QAKCRDa6OEJdZac 5UZqD/4pdaeo7FS0NiWF66GMY6iiePdzzzAMWMawUHU/GsfczP7aI7oQICDo6bp0MKwc3pWB3eq 0Ddbdzg/QLys95bcgV7Dd8X4SgPg3yvt+gTISolvp/4G5V6h+pAb2hUzD8LSGmBi/dLI9ExKL1n ZPNVqFqYFQhxNMwaH53tvDpAiXlhuaYd+LynxM7hI5zPuo7lIyQ2Md0moxVwqHOtrOLqosIpHq3 iex/JqXF0lZwGJX5yRf/stpXRL67CDZv1Q/S7vR0y/o8sG343pgxxysGkl+b+vOK8Mcf/mbXiFZ k2EWJhLKrpbNN3RrayXeXOmZs0AWv+U7/4/uLQuiCkieH17wPfWwTYWPSSVFeLUeBcgZdQIw7vs jSxVx3UcLrzO9YV9TylRPLD9s/LCAxn72De38xaSOUPR1WS3uyyEW+euXwD+VDbupZL1UwFhhA7 +M+JeIIXaFdJ/YwmY1goMO0w6PwVDDE6NEuZRKKspu6LgnOpQKUfJPnCaslFmkyThOYyKS1Qfq9 FDHSb8Ro9UyPopP93zos3zSSUmbqpiJREOjGgy+gHWHJF1kxpgwB4NTN36RtibZT+NN100qu9ow RC2oZvQuc/nzdFnaKtHdfJpvdhQQ63uP1FDiiILuXDqkaOmyYGukujHT5LS6/MKyG+MN3KoyaLf rOyTwV2wUqtqHAg== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1789047184723158500 Disable scanouts referencing a resource being unreferenced. The scanout disable callbacks may change the current GL context, so restore the renderer context before detaching and unreferencing the resource. Reviewed-by: Akihiko Odaki Fixes: 9d9e152136bd ("virtio-gpu: add 3d mode and virgl rendering support.") Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/display/virtio-gpu-virgl.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 439a6e1c1cff..494be3fb4f8d 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -431,6 +431,7 @@ virtio_gpu_virgl_resource_unref(VirtIOGPU *g, { struct iovec *res_iovs =3D NULL; int num_iovs =3D 0; + int i; #if VIRGL_VERSION_MAJOR >=3D 1 int ret; =20 @@ -443,6 +444,13 @@ virtio_gpu_virgl_resource_unref(VirtIOGPU *g, } #endif =20 + for (i =3D 0; i < g->parent_obj.conf.max_outputs; i++) { + if (g->parent_obj.scanout[i].resource_id =3D=3D res->base.resource= _id) { + virtio_gpu_disable_scanout(g, i); + } + } + + virgl_renderer_force_ctx_0(); virgl_renderer_resource_detach_iov(res->base.resource_id, &res_iovs, &num_iovs); --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047169; cv=none; d=zohomail.com; s=zohoarc; b=KJdBoIqHoXit+W1aiBFjz13oxFmuiKXLXoxMyjm2TXl6LEImdnkBUCI4NsN/s1+4XZSD/mDRvztcCLTsTUIs+aJZVqRbOJDDrRWTPDqE9apiPnyqtA8M4WL4RLtwB/uoEidThj9Um//oeX3xC0TrNDJVNZY47RVxlA74d+0jz0E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047169; 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=V84QzPH/ZEq2TiJ9XyXdltoKoWTWmtnH7WW8clVTLuY=; b=JHt/jSWvrN9ZWLR093KzXHvZdKWe22v4AALq55a+PM4dU2RyMsEoA/ALTkzXtyGPp/70XL0W2+1nHUtjM+/t79hR5de1Vbd4A6zo7yDJcky69NrBNmLLnvKO2tWIvl02lqBkd96iXaO6Q8Fn4rXbaErtLcM/W67sg1hE2zVDCBA= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047169816626.1730162692693; Thu, 10 Sep 2026 06:32:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4et6-0007Ei-Ug; Thu, 10 Sep 2026 09:32:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4et5-0007Do-5X for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:32:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4et3-00044D-Ci for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:32:22 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-680-bUaCtbzbPGC2X3S5C0mXyg-1; Thu, 10 Sep 2026 09:32:16 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8F9AC18007FE; Thu, 10 Sep 2026 13:32:15 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 61B541956095; Thu, 10 Sep 2026 13:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047140; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V84QzPH/ZEq2TiJ9XyXdltoKoWTWmtnH7WW8clVTLuY=; b=FUiAA9zynmwvfHlRuP/cXo3WIB5TOAgiie+tXZa3pcjVrcBVFqtQ2kmBrF6C16WyPl8IWl sK0zuSGncNAKDmNhmbLroCyZfDPeQc/fA/XD2FHA8kpD5xc0hkifsqNAlIOdpVr46O5v2+ aAlQ1nghwgB76Q4wATaHk3p6pW4U/NY= X-MC-Unique: bUaCtbzbPGC2X3S5C0mXyg-1 X-Mimecast-MFC-AGG-ID: bUaCtbzbPGC2X3S5C0mXyg_1789047135 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:30:18 +0400 Subject: [GIT PULL 23/24] virtio-gpu: extract virtio_gpu_disable_scanout_for_resource helper MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-23-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko X-Developer-Signature: v=1; a=openpgp-sha256; l=4697; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=RamBfzyG9xTGsBDqH0oHs3capJBKx8ywVXh3V5ZPY1w=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDdiGr4MhL4ZAGek/4z2wHm8QgNnyrZchqfL XWfVg/RJpiJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw3QAKCRDa6OEJdZac 5UuvD/9G2zNZnml4w9bojLZI+3Mh+qE3O8z4i/cZA1hU7nClqg7LKzyg79deN0Ndme6C6R33Sfu 56OC9qFJJb0nPficLBAvpLoN5rK+0OJgYezQT68LIsRgDCZo6VN7Ox2ZncmhjmXWVN/mVW/XZsz fTlgck+NipCArdKFI2EaTfBWnHJFYnNbAJDSgD1nJMd0nsBsGdcsNxFeDoE1taEvUJRQ4rFhzBE OOAYrN/k0yGE15Tl8SI+XNBz987WGsETGVSsm8PdNFwMmfafcTopYF3PHRKBuGYHkL/XFSP//A6 BfEoDGBAU+Ax5L/IgJxhTzTbL6Yp81DNVuD8zp3INiC7fPZF9/B2c49t3anJuNngxbznHn/oAp7 rBDINIWnC+6l+QlVp3LEI6GlDi1HfHqhJ/26KP63NjfTDtwsOXR1/XY9HZmm/W0SMYtt58ml0TV Ptrv09fpR8D5GpLQfEIMn/ahXSbQTGkAQi5UTUFon/6pl6cUeHdqsVKA2R2Y8Ddf6ytibY1eznt bodZNmu99OSZ8u1xkBaBlUats3+98SRqLkQM112QhxMJtsic9BWSvarSYAmVwQwOZAEIVdTG9Oo vVk7NpI+Z2tGZ8MrVYhvVErp9A8MkhCVH0wQ/uWFvIGfkbM7rpV37UDQYtd6Bqt2xeSDbX31AaI MAIcBbzeOXP+MTw== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1789047170529158500 The same loop iterating scanouts and disabling those matching a given resource_id was duplicated across four call sites in three backends. Factor it into a shared helper. Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/display/virtio-gpu-rutabaga.c | 7 +------ hw/display/virtio-gpu-virgl.c | 7 +------ hw/display/virtio-gpu.c | 26 ++++++++++++-------------- include/hw/virtio/virtio-gpu.h | 2 ++ 4 files changed, 16 insertions(+), 26 deletions(-) diff --git a/hw/display/virtio-gpu-rutabaga.c b/hw/display/virtio-gpu-rutab= aga.c index 8697dd6936ba..3aafa4dc66cd 100644 --- a/hw/display/virtio-gpu-rutabaga.c +++ b/hw/display/virtio-gpu-rutabaga.c @@ -146,14 +146,9 @@ virtio_gpu_rutabaga_resource_unref(VirtIOGPU *g, Error **errp) { int32_t result; - int i; VirtIOGPURutabaga *vr =3D VIRTIO_GPU_RUTABAGA(g); =20 - for (i =3D 0; i < g->parent_obj.conf.max_outputs; i++) { - if (g->parent_obj.scanout[i].resource_id =3D=3D res->resource_id) { - virtio_gpu_disable_scanout(g, i); - } - } + virtio_gpu_disable_scanout_for_resource(g, res->resource_id); =20 result =3D rutabaga_resource_unref(vr->rutabaga, res->resource_id); if (result) { diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 494be3fb4f8d..1c9380e2a6d2 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -431,7 +431,6 @@ virtio_gpu_virgl_resource_unref(VirtIOGPU *g, { struct iovec *res_iovs =3D NULL; int num_iovs =3D 0; - int i; #if VIRGL_VERSION_MAJOR >=3D 1 int ret; =20 @@ -444,11 +443,7 @@ virtio_gpu_virgl_resource_unref(VirtIOGPU *g, } #endif =20 - for (i =3D 0; i < g->parent_obj.conf.max_outputs; i++) { - if (g->parent_obj.scanout[i].resource_id =3D=3D res->base.resource= _id) { - virtio_gpu_disable_scanout(g, i); - } - } + virtio_gpu_disable_scanout_for_resource(g, res->base.resource_id); =20 virgl_renderer_force_ctx_0(); virgl_renderer_resource_detach_iov(res->base.resource_id, diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index e8a0dd24c873..bb0f41bb1e05 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -444,17 +444,21 @@ void virtio_gpu_disable_scanout(VirtIOGPU *g, int sca= nout_id) scanout->height =3D 0; } =20 +void virtio_gpu_disable_scanout_for_resource(VirtIOGPU *g, + uint32_t resource_id) +{ + for (int i =3D 0; i < g->parent_obj.conf.max_outputs; i++) { + if (g->parent_obj.scanout[i].resource_id =3D=3D resource_id) { + virtio_gpu_disable_scanout(g, i); + } + } +} + static void virtio_gpu_resource_destroy(VirtIOGPU *g, struct virtio_gpu_simple_resource = *res, Error **errp) { - int i; - - for (i =3D 0; i < g->parent_obj.conf.max_outputs; i++) { - if (g->parent_obj.scanout[i].resource_id =3D=3D res->resource_id) { - virtio_gpu_disable_scanout(g, i); - } - } + virtio_gpu_disable_scanout_for_resource(g, res->resource_id); =20 qemu_pixman_image_unref(res->image); virtio_gpu_cleanup_mapping(g, res); @@ -1062,13 +1066,7 @@ void virtio_gpu_cleanup_mapping(VirtIOGPU *g, struct virtio_gpu_simple_resource *res) { if (res->blob) { - int i, max_outputs =3D g->parent_obj.conf.max_outputs; - - for (i =3D 0; i < max_outputs; i++) { - if (g->parent_obj.scanout[i].resource_id =3D=3D res->resource_= id) { - virtio_gpu_disable_scanout(g, i); - } - } + virtio_gpu_disable_scanout_for_resource(g, res->resource_id); } =20 virtio_gpu_cleanup_mapping_iov(g, res->iov, res->iov_cnt); diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 2f18d839ccd3..631dfc63a4d4 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -404,6 +404,8 @@ void virtio_gpu_update_scanout(VirtIOGPU *g, struct virtio_gpu_framebuffer *fb, struct virtio_gpu_rect *r); void virtio_gpu_disable_scanout(VirtIOGPU *g, int scanout_id); +void virtio_gpu_disable_scanout_for_resource(VirtIOGPU *g, + uint32_t resource_id); =20 /* virtio-gpu-3d.c */ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, --=20 2.55.0.543.g5ebe2ebe4ea8 From nobody Sat Sep 26 20:50:56 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789047156; cv=none; d=zohomail.com; s=zohoarc; b=ONiD5S/umw+f1/KhiLQB48SRwUm3pPiPZASA6Dgx1GGNjJABw0ZFVK7gSBDAUdJPUP1T7c79HOcfiRPtYs35LlDnVSGtI0GBO3X+iBYmWD8H1kvn7eYKFhSc+LTuLq4mY/4QNoeo6EVqi2hdfuFOkgUl2qEXGr0MgY038UgK4ys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789047156; 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=/Wj5VzWeDqCex6YztU5VwVvg7TaKkgsfcJttpxYa4aU=; b=YclPMYU2lLz9cDY+sB1vqMmaLcuXIQTZm1/XaO+ggrpDCwXwhMy1Uc+FUewF2HxYHEx3Y9ivtHX1STmc/5y74QRetgIeIIB60w90Wh5w0kOTFn8zWX2ND8+dHloMCvZc5R5mtf+l19zQCU3ZV8BPULbBB2L8pO5ejbu0843KZEQ= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789047156278225.0276430734284; Thu, 10 Sep 2026 06:32:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4et9-0007Im-UF; Thu, 10 Sep 2026 09:32:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4et7-0007Ez-DL for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:32:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4et5-000457-TN for qemu-devel@nongnu.org; Thu, 10 Sep 2026 09:32:25 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-255-ao1h7jJnNma765Ij-3VqLw-1; Thu, 10 Sep 2026 09:32:21 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1BD9B1800639; Thu, 10 Sep 2026 13:32:21 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 482DA1800351; Thu, 10 Sep 2026 13:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789047143; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/Wj5VzWeDqCex6YztU5VwVvg7TaKkgsfcJttpxYa4aU=; b=edCdFlQmdB3KIXMOltUgMV/S2TlWR1DujLHFUd1TDZMTGmasUBTE3UOJtLdm4OkfO7jmmA fGjcFmyZy6ccwiDLIeOAKdPyCY+Dd9v0Dy6fvIobiiTfVU3Y/1voR5tY/NmyEW4aJlTTer Yu3SEL9rN2PvnJTIeazbOlxbWexBUhY= X-MC-Unique: ao1h7jJnNma765Ij-3VqLw-1 X-Mimecast-MFC-AGG-ID: ao1h7jJnNma765Ij-3VqLw_1789047141 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 10 Sep 2026 17:30:19 +0400 Subject: [GIT PULL 24/24] contrib/vhost-user-gpu: disable scanouts on resource unref MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260910-virtio-gpu-cleanup-v1-24-ccb8927a671e@redhat.com> References: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> In-Reply-To: <20260910-virtio-gpu-cleanup-v1-0-ccb8927a671e@redhat.com> To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , Stefano Garzarella , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=1543; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=iZ+oUugkx5oY5Po2y4/QVsUJmAP+CsizW5ruoANWJxA=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqorDdL163ZseZkprsRoR1LEcH61ifXgP8IZdYA V6nVE/KaCGJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaqKw3QAKCRDa6OEJdZac 5U63D/9MgwjFETu9twn1bwICcGX55IcMGoTdKaf3yYtYvOLKPWZzegQQfD6iIz+RnRi8uJb6C/T n+X8LtBzfwf2XCOFmFkG3NIOk7g+SU8+zHOyDuh2Ys/jPxNGVnviDiKFx1Z/JmawQiMVNcHFo4U DqmlQNrKZ5g85plpSiTTTDKKE65vk6h7oESKDmNqigtp/oTpsMLRkrTSVr+nBVOet2VIpzG7eWT DiAwjhFa7Kdxt9lInnX7C+v8B+LfRazKXcMRNGPrupzWieU4QO/zgNsrTjxCTxr8RTJGNsCjC8P cPzfcCLf0kWjw9fYFnHhEHwNVDPpNl/KmoW8wGyefVrv1kmMWX0ktAKF7Qv7Ud6PvfwsQqnvxPR PF0l46+v6BjlmsA8qgByUKcVTESh5ATTokREWdIskNYjZJJD2CXYqgI+BaolZtGsmwoCGDBgTNo XgA+oh5ro1x/e4x38eLGX8YclZPEpX1R0CFvlSd74dVvDuKYvh6aXmC6ohOJL9x9itOM3WC9NT8 ZrZV9OYmxCETAmQVvt4UB+GKilpMc4I4yZijEaHIZQLIqPC/rdSSTEFyEZw9Ovntn/8dR1Lwfbe XvbBo7Csxgw2nPMMmALucoaEAVAUJNDoCPslDyRZ39h0sLxLxS9bWovuWJCy6yI0smyTxKGS8+h eMP8Y/5hEfrpX4w== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1789047158590158500 virgl_cmd_resource_unref() destroys the virgl renderer resource without first disabling any scanouts that reference it. The QEMU frontend then holds a stale DMA-BUF until another DMABUF_SCANOUT message arrives. Send a DMABUF_SCANOUT disable message (fd=3D-1) for each affected scanout before destroying the resource. Reviewed-by: Akihiko Odaki Fixes: d52c454aadcd ("contrib: add vhost-user-gpu") Signed-off-by: Marc-Andr=C3=A9 Lureau --- contrib/vhost-user-gpu/virgl.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/contrib/vhost-user-gpu/virgl.c b/contrib/vhost-user-gpu/virgl.c index 20bae57d0fe4..5a5f9f14c80c 100644 --- a/contrib/vhost-user-gpu/virgl.c +++ b/contrib/vhost-user-gpu/virgl.c @@ -113,6 +113,18 @@ virgl_cmd_resource_unref(VuGpu *g, =20 VUGPU_FILL_CMD(unref); =20 + for (int i =3D 0; i < VIRTIO_GPU_MAX_SCANOUTS; i++) { + if (g->scanout[i].resource_id =3D=3D unref.resource_id) { + VhostUserGpuMsg msg =3D { + .request =3D VHOST_USER_GPU_DMABUF_SCANOUT, + .size =3D sizeof(VhostUserGpuDMABUFScanout), + .payload.dmabuf_scanout.scanout_id =3D i, + }; + vg_send_msg(g, &msg, -1); + g->scanout[i].resource_id =3D 0; + } + } + virgl_renderer_resource_detach_iov(unref.resource_id, &res_iovs, &num_iovs); --=20 2.55.0.543.g5ebe2ebe4ea8