[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 58/60] virtio-gpu.c: add resource_destroy class method
From: |
Michael S. Tsirkin |
Subject: |
[PULL 58/60] virtio-gpu.c: add resource_destroy class method |
Date: |
Wed, 14 Feb 2024 06:16:17 -0500 |
From: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
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é Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Message-Id:
<b0a86630c4d601f3a269fd7e08cfefc13bd4e219.1706626470.git.manos.pitsidianakis@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
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);
};
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, int
scanout_id)
}
static void virtio_gpu_resource_destroy(VirtIOGPU *g,
- struct virtio_gpu_simple_resource *res)
+ struct virtio_gpu_simple_resource *res,
+ Error **errp)
{
int i;
@@ -438,7 +439,11 @@ static void virtio_gpu_resource_unref(VirtIOGPU *g,
cmd->error = 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);
}
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 = VIRTIO_GPU(opaque);
+ VirtIOGPUClass *vgc = VIRTIO_GPU_GET_CLASS(g);
struct virtio_gpu_simple_resource *res, *tmp;
+ uint32_t resource_id;
+ Error *local_err = NULL;
int i = 0;
QTAILQ_FOREACH_SAFE(res, &g->reslist, next, tmp) {
- virtio_gpu_resource_destroy(g, res);
+ resource_id = 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 = %"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 = NULL;
+ }
}
for (i = 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 = virtio_gpu_handle_ctrl;
vgc->process_cmd = virtio_gpu_simple_process_cmd;
vgc->update_cursor_data = virtio_gpu_update_cursor_data;
+ vgc->resource_destroy = virtio_gpu_resource_destroy;
vgbc->gl_flushed = virtio_gpu_handle_gl_flushed;
vdc->realize = virtio_gpu_device_realize;
--
MST
- [PULL 45/60] hw/mem/cxl_type3: Fix potential divide by zero reported by coverity, (continued)
- [PULL 45/60] hw/mem/cxl_type3: Fix potential divide by zero reported by coverity, Michael S. Tsirkin, 2024/02/14
- [PULL 48/60] tests/acpi: Update DSDT.cxl to reflect change _STA return value., Michael S. Tsirkin, 2024/02/14
- [PULL 50/60] hw/cxl: Update link register definitions., Michael S. Tsirkin, 2024/02/14
- [PULL 54/60] virtio-gpu: Correct virgl_renderer_resource_get_info() error check, Michael S. Tsirkin, 2024/02/14
- [PULL 53/60] hw/cxl: Standardize all references on CXL r3.1 and minor updates, Michael S. Tsirkin, 2024/02/14
- [PULL 55/60] hw/smbios: Fix OEM strings table option validation, Michael S. Tsirkin, 2024/02/14
- [PULL 56/60] hw/smbios: Fix port connector option validation, Michael S. Tsirkin, 2024/02/14
- [PULL 51/60] hw/cxl: Update RAS Capability Definitions for version 3., Michael S. Tsirkin, 2024/02/14
- [PULL 49/60] hw/cxl: Update HDM Decoder capability to version 3, Michael S. Tsirkin, 2024/02/14
- [PULL 52/60] hw/cxl: Update mailbox status registers., Michael S. Tsirkin, 2024/02/14
- [PULL 58/60] virtio-gpu.c: add resource_destroy class method,
Michael S. Tsirkin <=
- [PULL 57/60] hw/display/virtio-gpu.c: use reset_bh class method, Michael S. Tsirkin, 2024/02/14
- [PULL 59/60] virtio-gpu-rutabaga.c: override resource_destroy method, Michael S. Tsirkin, 2024/02/14
- [PULL 60/60] MAINTAINERS: Switch to my Enfabrica email, Michael S. Tsirkin, 2024/02/14
- Re: [PULL 00/60] virtio,pc,pci: features, cleanups, fixes, Michael S. Tsirkin, 2024/02/14
- [PULL 22/60] hw/block/fdc-isa: Move portio_list from FDCtrl to FDCtrlISABus, Michael S. Tsirkin, 2024/02/14
- Re: [PULL 00/60] virtio,pc,pci: features, cleanups, fixes, Michael Tokarev, 2024/02/15