From nobody Tue Nov 26 14:48:39 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=1706280151; cv=none; d=zohomail.com; s=zohoarc; b=Z18Or3Mqg3Lttks8co1tRqx4wMTpGqXa/sL9nsBCk54kHmszCbpYYHZSWb7WUTpQWg/JmJGlvdE8W7D94JzGLpznbNbI5/D/vik7jRb27y/oH8saVK8QJyyxnpiDI6/Olt79JzB6SGqY3FdPyAuuSrLxkysLXTs3i+fBYEAnHF8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706280151; 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=CHxMCRnEljW/h+q6H+cTZi0z1+riOoBx0yCYJzMalqA=; b=Xb+ZkX7Zy2nOgZEA8pPXkdkKNGEQTRuv5j3XHabRAIJWzCkp6P3YUROyiL58H3JnOIA516O/Eum3pL4o1pdqmZnkzQlTQ6NXw83sjCeqYBDfE4TSPeSgdP00MVhOMf2CSPnInw7t7rJetoup3PKytQOJUz8jKqheV+lTyaxraUY= 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 1706280151352138.39821194599506; Fri, 26 Jan 2024 06:42:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rTNPU-0002rf-NE; Fri, 26 Jan 2024 09:42: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 1rTNPR-0002iw-8a for qemu-devel@nongnu.org; Fri, 26 Jan 2024 09:42:22 -0500 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rTNPO-0001RB-CW for qemu-devel@nongnu.org; Fri, 26 Jan 2024 09:42:19 -0500 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a3510d79ae9so26146266b.0 for ; Fri, 26 Jan 2024 06:42:17 -0800 (PST) Received: from localhost.localdomain (adsl-114.109.242.225.tellas.gr. [109.242.225.114]) by smtp.gmail.com with ESMTPSA id ox27-20020a170907101b00b00a3221b95ce8sm699168ejb.77.2024.01.26.06.42.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 06:42:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706280136; x=1706884936; 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=CHxMCRnEljW/h+q6H+cTZi0z1+riOoBx0yCYJzMalqA=; b=GGHW4nJNFs3nHZUHxJgrfGOaC5val6sksSriZuiJdlUJd4qYW8sHuRk8u2LltMkmFt Tpdsd3/qfbVHLCxzpDvPoWqqtMtyiKHh7gVOMkPJqIzIuGcTwi3l0H5tw33IU0zsRwQg dYq0lw9AsgHnVaHPaYGWOx59GQTwTrcRN2erMMaOw4EVkUKnVC3/f+nF3L/KCrWp0rFA JCTycsIK0NHtxssm9BH0gZr0LdI69GAQMQ/BmucN6Q5aMS5i/QfIE8aNl9AvSnLDU+YJ ckGjUmeIO6UIxX9EtqPLHeDE4gbpZPcl+LSvnc6zXr11epS1dynt+DuohLS5yhO9tzpb RNHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706280136; x=1706884936; 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=CHxMCRnEljW/h+q6H+cTZi0z1+riOoBx0yCYJzMalqA=; b=h51AVG2Csndmyntwb+fKAg1nouPKwtzKNQ9+dByMytpw2e62P92p7vOCIdUuAXCwJW W5IU2u9+oe2qLGfmJcT7fXYJ5bIHkNhR1AqN+M8kpk7dgrpGvShFZtLqEvhodNEGGWbo 9yyFfm0Xc3EEm/Rl9Iy5YcfMQbZfExYlOB4YjnCBBA1SZ1gCE9K1jKgPwl+Q7utcGJ1/ T845FCbsQu9g1zN+AUDqhGqPRAxoUFwPUapfnU6Cr1QKfw60MBJ65Ar64cJLhj8hYsGS VyXkoO1eiBNR2oLtNp/6Kphxuy8pQSpM1z2KymonCxpl2x+o2sdJCPMVOVKvqXQzciG+ oe3g== X-Gm-Message-State: AOJu0Yy8PeNTHn1clYwluqi3Kb5E6aDdLIHFxGJggl/1xa5St2WOP+is cF2RyGC3Spgzsq4+6FSN0plQ5QQ0hCM0Pm7g/REbHCct95A+9SF8JfVabPEB9/dskVB0aWki01q RJF4= X-Google-Smtp-Source: AGHT+IE/nwbDUrHd9Xycjmq2cUxBLHPYlTEVvA0xXHGyHK10r+V4+f06BIXwdHnkQmUOKk+Y44YrnQ== X-Received: by 2002:a17:906:b310:b0:a2c:298f:9057 with SMTP id n16-20020a170906b31000b00a2c298f9057mr837333ejz.68.1706280136147; Fri, 26 Jan 2024 06:42:16 -0800 (PST) From: Manos Pitsidianakis To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , "Michael S. Tsirkin" , Gurchetan Singh , Alyssa Ross Subject: [PATCH v1 1/3] hw/display/virtio-gpu.c: use reset_bh class method Date: Fri, 26 Jan 2024 16:41:48 +0200 Message-Id: <947fcb0c386e77b5ef59f4a6ca48baeee0d1a980.1706279540.git.manos.pitsidianakis@linaro.org> 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::62f; envelope-from=manos.pitsidianakis@linaro.org; helo=mail-ej1-x62f.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: 1706280151947100007 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Manos Pitsidianakis Reviewed-by: Marc-Andr=C3=A9 Lureau --- 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:48:39 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=1706280154; cv=none; d=zohomail.com; s=zohoarc; b=NJJ0j83FSY7pIqV1LUbEZNtBSY+FXr80X+duhGNw9sOg6D0zi9Bket9PXu+bZdzfwZX3SwmUvJ/h5u+Kn2kdxKU5iftoDKU5ig03L3jOooYfTFkUalbiqE89J24X8j3vVV2Xv7DPV7iDzTopsYFmGa7EK29P4mdIy5ew1KwPW5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706280154; 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=cQtopNr5vvMf8lcJyxn/yFZa/KfoJjaby+4DFvKGnn8=; b=EOe5bMfF+bQN7orwVpmMBF62BWvb/Nl4d8rePPO6G3Byvm06pa5ljgMIC9GeNdyWayS9RmcarTpDpNEM0VHwJWiitDP0rJwb4tTN/g5GOAwL7sQ3EG1iup6Q/OOowFqiw/78c2878Etywvnmo8/aG0xgvNxhWZLEQnQXBB/6FWY= 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 1706280154327848.3057590553549; Fri, 26 Jan 2024 06:42:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rTNPb-0003FJ-Gl; Fri, 26 Jan 2024 09:42:31 -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 1rTNPa-000371-1r for qemu-devel@nongnu.org; Fri, 26 Jan 2024 09:42:30 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rTNPY-0001RU-72 for qemu-devel@nongnu.org; Fri, 26 Jan 2024 09:42:29 -0500 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-339289fead2so534560f8f.3 for ; Fri, 26 Jan 2024 06:42:27 -0800 (PST) Received: from localhost.localdomain (adsl-114.109.242.225.tellas.gr. [109.242.225.114]) by smtp.gmail.com with ESMTPSA id ox27-20020a170907101b00b00a3221b95ce8sm699168ejb.77.2024.01.26.06.42.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 06:42:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706280146; x=1706884946; 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=cQtopNr5vvMf8lcJyxn/yFZa/KfoJjaby+4DFvKGnn8=; b=C0tY+8p1s5+j62icBultZP/BKwNlioJ6LxcpSvKNYzaajII/b+VVDxNndd9jSldrHl YEzbwuGaslFtoC376bhYiD1M6YyI9PymaZpLfYhvdRvsRk1wl40y/UHSaLNm0b72F721 5OK6wPuhiD6shI7K8QTgyqU006pTmPap3WI+oFjRkdrj9BvNIvt1bWys1XAAkRLmaYzQ y/+yrZQy2BCGWQyWyx5zVVw/W8RtB/7BET8oyHy+7+gpVDyiIcjfMGBe++ITrTGxsKyu 714NuHbRnbLlcQTRQUcvqOTSrUL3KLr0/XYghyZLOXhJvQi0PRqVEALNRMoaX8sBzQIZ bTEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706280146; x=1706884946; 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=cQtopNr5vvMf8lcJyxn/yFZa/KfoJjaby+4DFvKGnn8=; b=e+7pK9Phtx3J1zW5npQhX02d5SWh2PmnHE+5KJ0b7uIpmNZgfIEwZlfpJR4dkfdFGC LDQpTeJMJklSQrUHXHAfLwP9mpwlOGIXrgwI5qqqrkx6he1QHuBRqHefZSsvE/Vl7dAK Y4VLDCDT1cq+C54jQDWmEDZhCaCOcGVN3sBzYwXhC0qoJbn+ObGzF6CWOE68Pgg3JLcT q3JpxiCuH5N1bH4kzJENunmnUpraHw26Psbf1oHZg7YVLjUSc0a/wMBjiC6AzLX+pjyA TPjrvwxqx/acXCt9KaFRAmtcHEZ763/JSHyVRNWN/AHbT5AthiUxakdTitIRYYe+OX4r hMLQ== X-Gm-Message-State: AOJu0YzdsPlS9xexS7rjOivo0A6m0TSTCLqKEBprp0f8kHSoOHItPLHE 1K8dr3ZgyIwLXtEslegt9yfBZ80xX+OG4YCHx8kWUVjCizQwa/oPCDvPKAz71y35o/78akucbcF unzE= X-Google-Smtp-Source: AGHT+IHd+6xavana+NPb/ZCsOY5jqmQEf4NX5yvfwKgTl6uDFfxmJNEZ9E6pGoIGhVIIikGPOWGvgQ== X-Received: by 2002:a05:600c:3423:b0:40e:76b7:e8e3 with SMTP id y35-20020a05600c342300b0040e76b7e8e3mr942971wmp.226.1706280146256; Fri, 26 Jan 2024 06:42:26 -0800 (PST) From: Manos Pitsidianakis To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , "Michael S. Tsirkin" , Gurchetan Singh , Alyssa Ross Subject: [PATCH v1 2/3] virtio-gpu.c: add resource_destroy class method Date: Fri, 26 Jan 2024 16:41:49 +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::431; envelope-from=manos.pitsidianakis@linaro.org; helo=mail-wr1-x431.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: 1706280155817100003 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Manos Pitsidianakis --- hw/display/virtio-gpu.c | 19 ++++++++++++++++--- include/hw/virtio/virtio-gpu.h | 2 ++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 2b73ae585b..96420ba74f 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -401,8 +401,9 @@ static void virtio_gpu_disable_scanout(VirtIOGPU *g, in= t scanout_id) scanout->height =3D 0; } =20 -static void virtio_gpu_resource_destroy(VirtIOGPU *g, - struct virtio_gpu_simple_resource = *res) +static int32_t +virtio_gpu_resource_destroy(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res) { int i; =20 @@ -419,6 +420,8 @@ static void virtio_gpu_resource_destroy(VirtIOGPU *g, QTAILQ_REMOVE(&g->reslist, res, next); g->hostmem -=3D res->hostmem; g_free(res); + + return 0; } =20 static void virtio_gpu_resource_unref(VirtIOGPU *g, @@ -1488,11 +1491,20 @@ 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; + int32_t result, resource_id; 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; + result =3D vgc->resource_destroy(g, res); + if (result) { + error_report("%s: %s resource_destroy" + "for resource_id =3D %d failed with return value = =3D %d;", + __func__, object_get_typename(OBJECT(g)), resourc= e_id, + result); + } } =20 for (i =3D 0; i < g->parent_obj.conf.max_outputs; i++) { @@ -1632,6 +1644,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; diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 584ba2ed73..5683354236 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -219,6 +219,8 @@ struct VirtIOGPUClass { void (*update_cursor_data)(VirtIOGPU *g, struct virtio_gpu_scanout *s, uint32_t resource_id); + int32_t (*resource_destroy)(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res); }; =20 struct VirtIOGPUGL { --=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:48:39 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=1706280172; cv=none; d=zohomail.com; s=zohoarc; b=AXjPKOX7WvPmO6msVCDN4xTo73T1xLEMWYNpuFrVpoQf+MOD+XYJgV+nrrUfwIFzgbVoGlE7NXitcqUC7P/sxodYLWUaOwbgEeYa1dk7LwijMD1yzE8BIUJZ/Yhr7mjS60DtLzm2PvEi3wwf1DdVDO0cQU3Vgf3TDEHOsR7L8a8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706280172; 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=YRomrCy8IeTekhDJYOH7WoAUevPbXUg88RTgcJFKTB0=; b=dErY3FQiWVBF9G+wdSHqQQU3Oos7BcH4dwphHHPF1OpxpWXM9y8cqg5LqHs8Pg5Ag8oC5OXkyZPvrC6Hs6lRrZlGNXj1fznsTtTjqA2Q6dslrifXuBy7fan+p1in9yJ+o3dKXSNxzyMK/3lpneHQ+18IF86cMid5I4uc+TmGplM= 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 1706280172693848.960949100786; Fri, 26 Jan 2024 06:42:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rTNPi-0003sb-CL; Fri, 26 Jan 2024 09:42:38 -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 1rTNPg-0003nD-5b for qemu-devel@nongnu.org; Fri, 26 Jan 2024 09:42:36 -0500 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rTNPe-0001Sb-Dg for qemu-devel@nongnu.org; Fri, 26 Jan 2024 09:42:35 -0500 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-55817a12ad8so341684a12.2 for ; Fri, 26 Jan 2024 06:42:33 -0800 (PST) Received: from localhost.localdomain (adsl-114.109.242.225.tellas.gr. [109.242.225.114]) by smtp.gmail.com with ESMTPSA id ox27-20020a170907101b00b00a3221b95ce8sm699168ejb.77.2024.01.26.06.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 06:42:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706280152; x=1706884952; 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=YRomrCy8IeTekhDJYOH7WoAUevPbXUg88RTgcJFKTB0=; b=nGyEa9rat7slr0PqpIaTxu2aSdLe2/7gdhpdqTCFz4UEBU3nK96In4bky7ID9gi4T5 zQMigDNmbtrrKI7XM8Sr/4DbzwOmYWZXZalwXh51cqM+5wRkn96UikIEcKgrwLq7OS7q 38aanHYry38udct9SmriWhxlkxUabIf8fOhI97ckp5nAU/eeRi2EQt5SOMi7M2KUtRp9 MgYfrxy083C00lV0ItRbZOfJOxFLVJJMvgH5qaZh79vglledSuw6BlklW50Sq0aaaS+D 2bUIm97U3wiskRAT357SBRJWK2UqKYpjWnuTrIT1XGpN643hAluvx7JjTfVuYmN7/M9W W62g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706280152; x=1706884952; 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=YRomrCy8IeTekhDJYOH7WoAUevPbXUg88RTgcJFKTB0=; b=r9MC0bIYrAfAKDeFYqGZ9pDCjqp//FmYdmBOteDn9CY+hg6JAUftTOVaIQwM4UYuTm nEKhqU1iN3o5VkFoxOoILQ9WPZ1pWhR5Spw1qPhGnLcL7IG3TZSsh04ZrW+35L5Ml1XA 1wrx8tOyRoQt4xXu2Inx5EgqtCFgrJqua293boy8A+aUBNHjlsGijoaFxyqninojQ8eB AfdzmUHYH2mvO3PtgjbzfxrmnTGqpFWIPMS2AwIOueOJ785Umm2ZCkk2HeoMtQ3RDzYT YIlmnY5Fg2TNmTuuW1LyA9TdHUCcH2sGq4kFuL8LLaEdqsGGshKYsILFlT6l5ssYI2C+ YX8g== X-Gm-Message-State: AOJu0YwbVE7QjF8rU+rWciMI9zHAGBfQg+yarjW/yU3Wz1Uf/8R3FM5p SErxgmBwz67gfVHefXseKFGQ4NpmW+evtSbu+cacRqSQiEJzINgFNMxOhMlu1rchNK1kjAFQfS8 ALIA= X-Google-Smtp-Source: AGHT+IHNIWgmlYJeROz+iV92mYwBMd78GXiTOKu5EbTU6koJT/9Gh88Sg3EDtSfD9Ar2GzY/JenQ+w== X-Received: by 2002:a17:906:7fd5:b0:a30:a9bc:5a15 with SMTP id r21-20020a1709067fd500b00a30a9bc5a15mr907517ejs.20.1706280152018; Fri, 26 Jan 2024 06:42:32 -0800 (PST) From: Manos Pitsidianakis To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , "Michael S. Tsirkin" , Gurchetan Singh , Alyssa Ross Subject: [PATCH v1 3/3] virtio-gpu-rutabaga.c: override resource_destroy method Date: Fri, 26 Jan 2024 16:41:50 +0200 Message-Id: <5dc2d365fa4f88c7b5761f1032e1ea505d6b7e86.1706279540.git.manos.pitsidianakis@linaro.org> 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::530; envelope-from=manos.pitsidianakis@linaro.org; helo=mail-ed1-x530.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, 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: 1706280173869100003 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 --- hw/display/virtio-gpu-rutabaga.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/hw/display/virtio-gpu-rutabaga.c b/hw/display/virtio-gpu-rutab= aga.c index 9e67f9bd51..66b5a115ac 100644 --- a/hw/display/virtio-gpu-rutabaga.c +++ b/hw/display/virtio-gpu-rutabaga.c @@ -147,6 +147,24 @@ rutabaga_cmd_create_resource_3d(VirtIOGPU *g, QTAILQ_INSERT_HEAD(&g->reslist, res, next); } =20 +static int32_t +virtio_gpu_rutabaga_resource_unref(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res) +{ + int32_t result; + VirtIOGPURutabaga *vr =3D VIRTIO_GPU_RUTABAGA(g); + + result =3D rutabaga_resource_unref(vr->rutabaga, res->resource_id); + + if (res->image) { + pixman_image_unref(res->image); + } + + QTAILQ_REMOVE(&g->reslist, res, next); + g_free(res); + return result; +} + static void rutabaga_cmd_resource_unref(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) @@ -155,8 +173,6 @@ rutabaga_cmd_resource_unref(VirtIOGPU *g, struct virtio_gpu_simple_resource *res; struct virtio_gpu_resource_unref unref; =20 - VirtIOGPURutabaga *vr =3D VIRTIO_GPU_RUTABAGA(g); - VIRTIO_GPU_FILL_CMD(unref); =20 trace_virtio_gpu_cmd_res_unref(unref.resource_id); @@ -164,15 +180,8 @@ 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); + result =3D virtio_gpu_rutabaga_resource_unref(g, res); CHECK(!result, cmd); - - if (res->image) { - pixman_image_unref(res->image); - } - - QTAILQ_REMOVE(&g->reslist, res, next); - g_free(res); } =20 static void @@ -1099,7 +1108,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