From nobody Tue Nov 26 14:42:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1706626831; cv=none; d=zohomail.com; s=zohoarc; b=jGa8ZxMyv0AA+VgTJ+PO8Eg7zi80YfneXD8e+jiaOYC+0W5aR43AOdvjdJNnJs53miXjV8K8ajDlFiPWpx/P0mpujzkbWSOa04TmGfuUBvvR/2skzaYeMnwFxU2LPZMz7c/QO/JhlUrEM3m6Yt8Z6+HK0fDxhTiA9v+cc0JsqWg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706626831; 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=3zRxwzBg1JPAeksvDXKolStU0KP7INqkx8/kV22Vx3g=; b=LzNlSBsTZocDdun77/X1dk923o7PNa+zTcxvJ7rRytFCP+vG0D7ntyCiI75DnC2a7fa/PNAlGW0LLYPmi1OazqEk3ANIWRCrKoRK/RZMVuuqhChKtqkXrZAOvgyRA9h5Cs8ILbFE0uy0EER8st800/ysMnPZJwMdMefSTghERg4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170662683157250.32437642667003; Tue, 30 Jan 2024 07:00:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUpal-0000nK-5N; Tue, 30 Jan 2024 10:00:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUpaj-0000mj-DD for qemu-devel@nongnu.org; Tue, 30 Jan 2024 10:00:01 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rUpah-0008GK-J9 for qemu-devel@nongnu.org; Tue, 30 Jan 2024 10:00:01 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-40ef6f10b56so16773185e9.2 for ; Tue, 30 Jan 2024 06:59:59 -0800 (PST) Received: from localhost.localdomain (adsl-125.37.6.3.tellas.gr. [37.6.3.125]) by smtp.gmail.com with ESMTPSA id fa7-20020a05600c518700b0040ec6d7420csm17078648wmb.14.2024.01.30.06.59.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 06:59:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706626797; x=1707231597; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3zRxwzBg1JPAeksvDXKolStU0KP7INqkx8/kV22Vx3g=; b=LrGTOGEd6vYoxjdpcUAmrTOJ3oz88iDpRr8CnntZlNd11NN2KvxnC4qWKWzlis8NDE LrvZpEmCrQwqGexJGmR3Eq9wtdtXCaIuadFnZwHzVN5wvMQfEp8nwUoRa17fS8UZ+9Yc K5v9XERcUaZoLOaU5csQ7Elp7yNBev+gncq9TZUcjjdl7faiixzYJ2kYzIBULQUf8BNL +xtRHOJKwCPiSumR0aedViKu/ClbUprUd/K0OqcOT4UM8tKCmIXHEd5XvobGoJIgTdMV 6BkGptOagm8XrRjN/1yODa9/7gGfbj+qrAA4AeimUiMYl5vF0lB2/X1SOw24TtJVitQ5 sSRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706626797; x=1707231597; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3zRxwzBg1JPAeksvDXKolStU0KP7INqkx8/kV22Vx3g=; b=JBJIW7+l0eyxp6TZ+c+Ku0J4Wg0icImaRYN2REcPJWeluoy8kseEwkKB2kO4AExfpO Kpv9aKh4gljp41TR69gmklMNoZydyk0DEyqxZ5JMXlPEPzYw23uZ4RfzCxS+ds+oB5mb ERqpb39KQ0VZFdUdCL6HaOA2DkyCU7qHAB+NojrLiSlSsFcn6vugvuTKcly167z/Aaio H94HJhEFnmW9z3Kjz5B5u25vAJNrj8+Cah2SvHRANqFMgAv5GErmL+U4f2RIgWM/XARR 82hBvdKKpkevuBWpS5iPoHqQz7u3ttP5BdLlwoK9/R8P3XfLcjI1FsrsMvk4ibMB37z8 TOPw== X-Gm-Message-State: AOJu0Yy7cgfkyCTZttNnBIPyjsuTZCqy72Rg7+X0/7O2ik0PdRAEZ+Sl h3+5yvQbEwcYV2DAcw1gqK7Q6K8sPdeadJVrqIJHjv97xkWTlAXdxu+XwEerDBuWUR0n9vv4Zco /UoQ= X-Google-Smtp-Source: AGHT+IGEntHLwr3UyB+ordx9X5bXLEWpQOfPw0oq4o+YZ5M4uPsmPNdluo68E1gW6wLPK6dScFjwmQ== X-Received: by 2002:a05:600c:3151:b0:40f:afd6:b266 with SMTP id h17-20020a05600c315100b0040fafd6b266mr625053wmo.18.1706626797413; Tue, 30 Jan 2024 06:59:57 -0800 (PST) From: Manos Pitsidianakis To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , "Michael S. Tsirkin" , Gurchetan Singh , Alyssa Ross , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 1/3] hw/display/virtio-gpu.c: use reset_bh class method Date: Tue, 30 Jan 2024 16:59:19 +0200 Message-Id: <87fb4fa72ce5b341a6f957513a00dcb79fd5997f.1706626470.git.manos.pitsidianakis@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=manos.pitsidianakis@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1706626834267100006 While the VirtioGPU type has a reset_bh field to specify a reset callback, it's never used. virtio_gpu_reset() calls the general virtio_gpu_reset_bh() function for all devices that inherit from VirtioGPU. While no devices override reset_bh at the moment, a device reset might require special logic for implementations in the future. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Manos Pitsidianakis --- hw/display/virtio-gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index f8a675eb30..2b73ae585b 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1515,7 +1515,7 @@ void virtio_gpu_reset(VirtIODevice *vdev) qemu_cond_wait_bql(&g->reset_cond); } } else { - virtio_gpu_reset_bh(g); + aio_bh_call(g->reset_bh); } =20 while (!QTAILQ_EMPTY(&g->cmdq)) { --=20 =CE=B3=CE=B1=E1=BF=96=CE=B1 =CF=80=CF=85=CF=81=CE=AF =CE=BC=CE=B9=CF=87=CE= =B8=CE=AE=CF=84=CF=89 From nobody Tue Nov 26 14:42:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1706626882; cv=none; d=zohomail.com; s=zohoarc; b=harxIoDHr36XQWFtK9VV2hJb9GHO8ay7yIX59FveFKRFVj2itg+2KRkrj3fXol92TGtIyObsiuL/SwKWvXoypqwexc9ag9vImnLZHbU22C9n4hoMZq3TGlSVSP3O7yA/wpjJTH81kiDq0hFvd9TEDHSWEMlSZncGRQpLgxQv6sU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706626882; 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=N7Tw5saUZzmnNQBl5imy1iUGuwf5cjAMj6TuehOa0+w=; b=MS7N+Jm5FK/NAHnvuKHHJ6GCDkNmB0ono3vG1wTEQrL/Fn4oiLb9A6E2oHVCBY1xsMx3vOxB4TF7d1cHu2ZPzhWobKjH+H5+NRRdLkiejsF+rti0foUZrgeiyUEGohzTZJh3WDr8M0asRz5PuotCiObGnFTmDZaLkeuy0LzGPwI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706626882120632.8578193165749; Tue, 30 Jan 2024 07:01:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUpay-0000qT-65; Tue, 30 Jan 2024 10:00:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUpar-0000pO-6a for qemu-devel@nongnu.org; Tue, 30 Jan 2024 10:00:09 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rUpao-0008TH-Bf for qemu-devel@nongnu.org; Tue, 30 Jan 2024 10:00:08 -0500 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-40e80046246so22490075e9.1 for ; Tue, 30 Jan 2024 07:00:05 -0800 (PST) Received: from localhost.localdomain (adsl-125.37.6.3.tellas.gr. [37.6.3.125]) by smtp.gmail.com with ESMTPSA id fa7-20020a05600c518700b0040ec6d7420csm17078648wmb.14.2024.01.30.07.00.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 07:00:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706626804; x=1707231604; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=N7Tw5saUZzmnNQBl5imy1iUGuwf5cjAMj6TuehOa0+w=; b=sSbpIcQFveZ+N5fD7I1/el98tAZbt+j4WMezM04jm5WKybB8uMBtwZaMK8i6Zq3imf nKsLH6VFPsBGgbpuxjTyVdNY7u/5s/+/4uzftjD0Sg5Y6feCbS8MgHRqBACmb1Rglq2+ dS9ew7i4jBilsH/54kSqmDl+IltSf9C9Vu+Y6BE58YufcrwG6nM1vxQk05DCiwo+xRWp cO7dOhDyY8rIngW2eHOR9yhweM0oNqPpftE03FLunex5c246UkCSbBQYmw9o70dTO542 XEWLQ9Z7j9nR8Ruwoa8nzCNcoyn5I0JUq/PtuvfdbH29LXJB/L0U2/3LXVe+Qozo8MTN bDnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706626804; x=1707231604; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N7Tw5saUZzmnNQBl5imy1iUGuwf5cjAMj6TuehOa0+w=; b=CBzkkX15RDJ2HkDoBfLZTMuu/b507eyiIVYGP8DfesmkTzxfJctK0ABZg7ycBawzdm 9qVdjEtlbbkLNaASxTioEr1SpGF0qFI5rpc1fxmln4q/E9NGyR5m64UV9rs7dboKs59V vr52k3JZ2fx/hmiovoYg5m7fdkDof7/hlcV5Jo3JZIirPRsa6yE9Wc8+75vft7BI27l7 eITKH78JUXeyd6W+GrP7krKdVQSbDhJ5TFn7grbhXnw27pvjlFXk8xWNJqOOEU1Zt9+P R9Q2rM8HempSUnOAFQccuKlCLAw77Gnl86dlOWDIY4U6fSyLZGqy2xvGfp+lumE8zcLX U6iA== X-Gm-Message-State: AOJu0Yx25ooYoKWh6FY2HYxH1mI7pXBfDP9FipXXxhZoz5CHZjLinMEy ZSRZfZjNYM0ISLMWD/7eMv4MNYY0Y41VneVL6a3TgPpi5be+sdkRxfAcJSNwrqrmNBSWzehWcDg fEW8= X-Google-Smtp-Source: AGHT+IFxTWEmXoWL04YQGawW/0qlLCW4Bl2ZzdCXScfxlqiSnFroX/yow9RlJRQC31wWxfqoIEzGvw== X-Received: by 2002:a05:600c:5250:b0:40e:bf71:f6db with SMTP id fc16-20020a05600c525000b0040ebf71f6dbmr1722396wmb.17.1706626804053; Tue, 30 Jan 2024 07:00:04 -0800 (PST) From: Manos Pitsidianakis To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , "Michael S. Tsirkin" , Gurchetan Singh , Alyssa Ross , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 2/3] virtio-gpu.c: add resource_destroy class method Date: Tue, 30 Jan 2024 16:59:20 +0200 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=manos.pitsidianakis@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1706626884096100003 When destroying/unrefing resources, devices such as virtio-gpu-rutabaga need to do their own bookkeeping (free rutabaga resources that are associated with the virtio_gpu_simple_resource). This commit adds a class method so that virtio-gpu-rutabaga can override it in the next commit. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Manos Pitsidianakis --- include/hw/virtio/virtio-gpu.h | 3 +++ hw/display/virtio-gpu.c | 25 ++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 584ba2ed73..b28e7ef0d2 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -219,6 +219,9 @@ struct VirtIOGPUClass { void (*update_cursor_data)(VirtIOGPU *g, struct virtio_gpu_scanout *s, uint32_t resource_id); + void (*resource_destroy)(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res, + Error **errp); }; =20 struct VirtIOGPUGL { diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 2b73ae585b..1c1ee230b3 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -402,7 +402,8 @@ static void virtio_gpu_disable_scanout(VirtIOGPU *g, in= t scanout_id) } =20 static void virtio_gpu_resource_destroy(VirtIOGPU *g, - struct virtio_gpu_simple_resource = *res) + struct virtio_gpu_simple_resource = *res, + Error **errp) { int i; =20 @@ -438,7 +439,11 @@ static void virtio_gpu_resource_unref(VirtIOGPU *g, cmd->error =3D VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; return; } - virtio_gpu_resource_destroy(g, res); + /* + * virtio_gpu_resource_destroy does not set any errors, so pass a NULL= errp + * to ignore them. + */ + virtio_gpu_resource_destroy(g, res, NULL); } =20 static void virtio_gpu_transfer_to_host_2d(VirtIOGPU *g, @@ -1488,11 +1493,24 @@ static void virtio_gpu_device_unrealize(DeviceState= *qdev) static void virtio_gpu_reset_bh(void *opaque) { VirtIOGPU *g =3D VIRTIO_GPU(opaque); + VirtIOGPUClass *vgc =3D VIRTIO_GPU_GET_CLASS(g); struct virtio_gpu_simple_resource *res, *tmp; + uint32_t resource_id; + Error *local_err =3D NULL; int i =3D 0; =20 QTAILQ_FOREACH_SAFE(res, &g->reslist, next, tmp) { - virtio_gpu_resource_destroy(g, res); + resource_id =3D res->resource_id; + vgc->resource_destroy(g, res, &local_err); + if (local_err) { + error_append_hint(&local_err, "%s: %s resource_destroy" + "for resource_id =3D %"PRIu32" failed.\n", + __func__, object_get_typename(OBJECT(g)), + resource_id); + /* error_report_err frees the error object for us */ + error_report_err(local_err); + local_err =3D NULL; + } } =20 for (i =3D 0; i < g->parent_obj.conf.max_outputs; i++) { @@ -1632,6 +1650,7 @@ static void virtio_gpu_class_init(ObjectClass *klass,= void *data) vgc->handle_ctrl =3D virtio_gpu_handle_ctrl; vgc->process_cmd =3D virtio_gpu_simple_process_cmd; vgc->update_cursor_data =3D virtio_gpu_update_cursor_data; + vgc->resource_destroy =3D virtio_gpu_resource_destroy; vgbc->gl_flushed =3D virtio_gpu_handle_gl_flushed; =20 vdc->realize =3D virtio_gpu_device_realize; --=20 =CE=B3=CE=B1=E1=BF=96=CE=B1 =CF=80=CF=85=CF=81=CE=AF =CE=BC=CE=B9=CF=87=CE= =B8=CE=AE=CF=84=CF=89 From nobody Tue Nov 26 14:42:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1706626862; cv=none; d=zohomail.com; s=zohoarc; b=CTvS0sGQsP5WhDNTEQbX51J/vb46gPBtRfJ6FQwf948jZD2Fcga+BJ+/Q/18G8BAOZiVlN5IqwTr21b3mVcXvsfdO+ApbJUof3epVt59jpc5Ju4Ygf+fX1ROxK2XytUlwSdUxQwOv3dMbGCG/5a72POIk2JhVFt3YE/+o3xpFK4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706626862; 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=8rjZNbSKagVpk27PIGKUkuf1AY4K8nKgFwbZ9fsBYzs=; b=McVLiOGqZAf0c7+VqKxcC/QL7Ejk5piQbpdaMsxynnjJANG9eWcaENm2NNKxAT3bqtuM2iAv+sp9k9vcCUxstZx1Pdsv1QPK2C9TMwmWQxL6ZqCBOE4StpeDd5iEl3Jg9G8eSwmUXqhPEaQcwqC1b1rncOao2m2/+fKoI4WMLN4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170662686267448.034152967243585; Tue, 30 Jan 2024 07:01:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUpb6-0000vt-8g; Tue, 30 Jan 2024 10:00:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUpb0-0000sF-Sk for qemu-devel@nongnu.org; Tue, 30 Jan 2024 10:00:20 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rUpaq-0008Tw-O2 for qemu-devel@nongnu.org; Tue, 30 Jan 2024 10:00:11 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40e9101b5f9so44750995e9.3 for ; Tue, 30 Jan 2024 07:00:08 -0800 (PST) Received: from localhost.localdomain (adsl-125.37.6.3.tellas.gr. [37.6.3.125]) by smtp.gmail.com with ESMTPSA id fa7-20020a05600c518700b0040ec6d7420csm17078648wmb.14.2024.01.30.07.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 07:00:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706626806; x=1707231606; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8rjZNbSKagVpk27PIGKUkuf1AY4K8nKgFwbZ9fsBYzs=; b=qwqcktDw9qKwgOTz/NiSwclvKsZbbF6xj8uYaPXwasvad15p2hx1zxan0maSade8dN rswW1SLdbySswpKIFTJ923ufpMnEGdW8Mi/C+9bRFu2z5akwY/OBJZAgCmANJTyJdejC mFgiIAXa57empY3jnd1OnX+OZsWN4p5VQVfajMqCAl8DoUriY6e7+H2j5Yr8cC6ZVt3Y MN/i7FXoy7F7D8HX3zuxo42QM+QQrhTujEIHfusC1SuZGtUix8jQyTpwOwIX0f1EPumb INfzQEE2bTSWGZZHYU7mfb3rUtqTiS4Owq2BfzMaya0bpohP4Xii607jhx8b8XRvJmF0 QiKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706626806; x=1707231606; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8rjZNbSKagVpk27PIGKUkuf1AY4K8nKgFwbZ9fsBYzs=; b=PZcReZFFMEWyVL9ZBKV02Xp0qO3JuM89phaSIHCsLlokPY86+yn56ep9BHjSho54CF qjhrixjjcgeBCfinYX49APa4RPBU7DsyQ/Cl7Q+LWAPLyOdUCYuT/DKeqfkEf09Vc/Q+ rb6NOfANepNEkeTvGAg0O1NuH8/iQbMpJXVaiL6u0ort/pHGPbrt+FiXIXrUov4fWCP7 UfKC37mKofD+PvA+eWA0W+bU9EhUG4XcJgSV0wbgVCR/BIEcUjHhNgKsDKtrbW22oYvx qhBNRA4rnMpbRwQwiIf6WaF7giaVqk7YkoBB1Yf8euAJKWZJB9+negyIT//Icklh1sl/ OqCA== X-Gm-Message-State: AOJu0YzM5auU8pctEVapgSpB7njJjY87PAGSQqaQX2PAw/NKlsAec4D3 IVz8rycXhuqwYNUhcrgTQvhRzu0vC7a7jFbXOC6IX3T5CnQW/0Qjo1mlyXc7/3SlNkx/4n8W1Ry BHV8= X-Google-Smtp-Source: AGHT+IFTJ2neJwlX9DIn8CcretI9x4KupMnOBvM0FhKqxYhPxm2S8EOdP+D6NDikNNMuEIoxOHBB8Q== X-Received: by 2002:a05:600c:1396:b0:40e:d425:85a with SMTP id u22-20020a05600c139600b0040ed425085amr7978785wmf.17.1706626806620; Tue, 30 Jan 2024 07:00:06 -0800 (PST) From: Manos Pitsidianakis To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , "Michael S. Tsirkin" , Gurchetan Singh , Alyssa Ross , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH v3 3/3] virtio-gpu-rutabaga.c: override resource_destroy method Date: Tue, 30 Jan 2024 16:59:21 +0200 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=manos.pitsidianakis@linaro.org; helo=mail-wm1-x330.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1706626863891100002 Content-Type: text/plain; charset="utf-8" When the Rutabaga GPU device frees resources, it calls rutabaga_resource_unref for that resource_id. However, when the generic VirtIOGPU functions destroys resources, it only removes the virtio_gpu_simple_resource from the device's VirtIOGPU->reslist list. The rutabaga resource associated with that resource_id is then leaked. This commit overrides the resource_destroy class method introduced in the previous commit to fix this. Signed-off-by: Manos Pitsidianakis Reviewed-by: Gurchetan Singh --- hw/display/virtio-gpu-rutabaga.c | 47 ++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/hw/display/virtio-gpu-rutabaga.c b/hw/display/virtio-gpu-rutab= aga.c index 9e67f9bd51..17bf701a21 100644 --- a/hw/display/virtio-gpu-rutabaga.c +++ b/hw/display/virtio-gpu-rutabaga.c @@ -148,14 +148,38 @@ rutabaga_cmd_create_resource_3d(VirtIOGPU *g, } =20 static void +virtio_gpu_rutabaga_resource_unref(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res, + Error **errp) +{ + int32_t result; + VirtIOGPURutabaga *vr =3D VIRTIO_GPU_RUTABAGA(g); + + result =3D rutabaga_resource_unref(vr->rutabaga, res->resource_id); + if (result) { + error_setg_errno(errp, + (int)result, + "%s: rutabaga_resource_unref returned %"PRIi32 + " for resource_id =3D %"PRIu32, __func__, result, + res->resource_id); + } + + if (res->image) { + pixman_image_unref(res->image); + } + + QTAILQ_REMOVE(&g->reslist, res, next); + g_free(res); +} + +static void rutabaga_cmd_resource_unref(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { - int32_t result; + int32_t result =3D 0; struct virtio_gpu_simple_resource *res; struct virtio_gpu_resource_unref unref; - - VirtIOGPURutabaga *vr =3D VIRTIO_GPU_RUTABAGA(g); + Error *local_err =3D NULL; =20 VIRTIO_GPU_FILL_CMD(unref); =20 @@ -164,15 +188,14 @@ rutabaga_cmd_resource_unref(VirtIOGPU *g, res =3D virtio_gpu_find_resource(g, unref.resource_id); CHECK(res, cmd); =20 - result =3D rutabaga_resource_unref(vr->rutabaga, unref.resource_id); - CHECK(!result, cmd); - - if (res->image) { - pixman_image_unref(res->image); + virtio_gpu_rutabaga_resource_unref(g, res, &local_err); + if (local_err) { + error_report_err(local_err); + /* local_err was freed, do not reuse it. */ + local_err =3D NULL; + result =3D 1; } - - QTAILQ_REMOVE(&g->reslist, res, next); - g_free(res); + CHECK(!result, cmd); } =20 static void @@ -1099,7 +1122,7 @@ static void virtio_gpu_rutabaga_class_init(ObjectClas= s *klass, void *data) vgc->handle_ctrl =3D virtio_gpu_rutabaga_handle_ctrl; vgc->process_cmd =3D virtio_gpu_rutabaga_process_cmd; vgc->update_cursor_data =3D virtio_gpu_rutabaga_update_cursor; - + vgc->resource_destroy =3D virtio_gpu_rutabaga_resource_unref; vdc->realize =3D virtio_gpu_rutabaga_realize; device_class_set_props(dc, virtio_gpu_rutabaga_properties); } --=20 =CE=B3=CE=B1=E1=BF=96=CE=B1 =CF=80=CF=85=CF=81=CE=AF =CE=BC=CE=B9=CF=87=CE= =B8=CE=AE=CF=84=CF=89