thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-virtio-gpu-pass-down-VirtIOGPU-pointer-to-a-bunch-of.patch

4ec855
From 5b896af413dae0e4933a6e5c277bfe7b4f2f9bb4 Mon Sep 17 00:00:00 2001
4ec855
From: Gerd Hoffmann <kraxel@redhat.com>
4ec855
Date: Thu, 4 Jul 2019 10:32:05 +0200
4ec855
Subject: [PATCH 2/4] virtio-gpu: pass down VirtIOGPU pointer to a bunch of
4ec855
 functions
4ec855
MIME-Version: 1.0
4ec855
Content-Type: text/plain; charset=UTF-8
4ec855
Content-Transfer-Encoding: 8bit
4ec855
4ec855
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
4ec855
Message-id: <20190704103207.29158-2-kraxel@redhat.com>
4ec855
Patchwork-id: 89374
4ec855
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH v2 1/3] virtio-gpu: pass down VirtIOGPU pointer to a bunch of functions
4ec855
Bugzilla: 1531543
4ec855
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4ec855
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
4ec855
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
4ec855
4ec855
No functional change, just preparation for a followup patch
4ec855
which needs a VirtIOGPU pointer.
4ec855
4ec855
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
4ec855
Message-Id: <20180829122101.29852-2-kraxel@redhat.com>
4ec855
(cherry picked from commit 3bb68f798da0234d5ca0ac6062aaa084afc83069)
4ec855
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4ec855
---
4ec855
 hw/display/virtio-gpu-3d.c     |  8 ++++----
4ec855
 hw/display/virtio-gpu.c        | 25 +++++++++++++++----------
4ec855
 include/hw/virtio/virtio-gpu.h |  6 ++++--
4ec855
 3 files changed, 23 insertions(+), 16 deletions(-)
4ec855
4ec855
diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-3d.c
4ec855
index 3558f38..55d7640 100644
4ec855
--- a/hw/display/virtio-gpu-3d.c
4ec855
+++ b/hw/display/virtio-gpu-3d.c
4ec855
@@ -86,7 +86,7 @@ static void virgl_cmd_resource_unref(VirtIOGPU *g,
4ec855
                                        &res_iovs,
4ec855
                                        &num_iovs);
4ec855
     if (res_iovs != NULL && num_iovs != 0) {
4ec855
-        virtio_gpu_cleanup_mapping_iov(res_iovs, num_iovs);
4ec855
+        virtio_gpu_cleanup_mapping_iov(g, res_iovs, num_iovs);
4ec855
     }
4ec855
     virgl_renderer_resource_unref(unref.resource_id);
4ec855
 }
4ec855
@@ -291,7 +291,7 @@ static void virgl_resource_attach_backing(VirtIOGPU *g,
4ec855
     VIRTIO_GPU_FILL_CMD(att_rb);
4ec855
     trace_virtio_gpu_cmd_res_back_attach(att_rb.resource_id);
4ec855
 
4ec855
-    ret = virtio_gpu_create_mapping_iov(&att_rb, cmd, NULL, &res_iovs);
4ec855
+    ret = virtio_gpu_create_mapping_iov(g, &att_rb, cmd, NULL, &res_iovs);
4ec855
     if (ret != 0) {
4ec855
         cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
4ec855
         return;
4ec855
@@ -301,7 +301,7 @@ static void virgl_resource_attach_backing(VirtIOGPU *g,
4ec855
                                              res_iovs, att_rb.nr_entries);
4ec855
 
4ec855
     if (ret != 0)
4ec855
-        virtio_gpu_cleanup_mapping_iov(res_iovs, att_rb.nr_entries);
4ec855
+        virtio_gpu_cleanup_mapping_iov(g, res_iovs, att_rb.nr_entries);
4ec855
 }
4ec855
 
4ec855
 static void virgl_resource_detach_backing(VirtIOGPU *g,
4ec855
@@ -320,7 +320,7 @@ static void virgl_resource_detach_backing(VirtIOGPU *g,
4ec855
     if (res_iovs == NULL || num_iovs == 0) {
4ec855
         return;
4ec855
     }
4ec855
-    virtio_gpu_cleanup_mapping_iov(res_iovs, num_iovs);
4ec855
+    virtio_gpu_cleanup_mapping_iov(g, res_iovs, num_iovs);
4ec855
 }
4ec855
 
4ec855
 
4ec855
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
4ec855
index 08cd567..cb77ece 100644
4ec855
--- a/hw/display/virtio-gpu.c
4ec855
+++ b/hw/display/virtio-gpu.c
4ec855
@@ -28,7 +28,8 @@
4ec855
 static struct virtio_gpu_simple_resource*
4ec855
 virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id);
4ec855
 
4ec855
-static void virtio_gpu_cleanup_mapping(struct virtio_gpu_simple_resource *res);
4ec855
+static void virtio_gpu_cleanup_mapping(VirtIOGPU *g,
4ec855
+                                       struct virtio_gpu_simple_resource *res);
4ec855
 
4ec855
 static void
4ec855
 virtio_gpu_ctrl_hdr_bswap(struct virtio_gpu_ctrl_hdr *hdr)
4ec855
@@ -441,7 +442,7 @@ static void virtio_gpu_resource_destroy(VirtIOGPU *g,
4ec855
     }
4ec855
 
4ec855
     pixman_image_unref(res->image);
4ec855
-    virtio_gpu_cleanup_mapping(res);
4ec855
+    virtio_gpu_cleanup_mapping(g, res);
4ec855
     QTAILQ_REMOVE(&g->reslist, res, next);
4ec855
     g->hostmem -= res->hostmem;
4ec855
     g_free(res);
4ec855
@@ -687,7 +688,8 @@ static void virtio_gpu_set_scanout(VirtIOGPU *g,
4ec855
     scanout->height = ss.r.height;
4ec855
 }
4ec855
 
4ec855
-int virtio_gpu_create_mapping_iov(struct virtio_gpu_resource_attach_backing *ab,
4ec855
+int virtio_gpu_create_mapping_iov(VirtIOGPU *g,
4ec855
+                                  struct virtio_gpu_resource_attach_backing *ab,
4ec855
                                   struct virtio_gpu_ctrl_command *cmd,
4ec855
                                   uint64_t **addr, struct iovec **iov)
4ec855
 {
4ec855
@@ -731,7 +733,7 @@ int virtio_gpu_create_mapping_iov(struct virtio_gpu_resource_attach_backing *ab,
4ec855
             qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to map MMIO memory for"
4ec855
                           " resource %d element %d\n",
4ec855
                           __func__, ab->resource_id, i);
4ec855
-            virtio_gpu_cleanup_mapping_iov(*iov, i);
4ec855
+            virtio_gpu_cleanup_mapping_iov(g, *iov, i);
4ec855
             g_free(ents);
4ec855
             *iov = NULL;
4ec855
             if (addr) {
4ec855
@@ -745,7 +747,8 @@ int virtio_gpu_create_mapping_iov(struct virtio_gpu_resource_attach_backing *ab,
4ec855
     return 0;
4ec855
 }
4ec855
 
4ec855
-void virtio_gpu_cleanup_mapping_iov(struct iovec *iov, uint32_t count)
4ec855
+void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g,
4ec855
+                                    struct iovec *iov, uint32_t count)
4ec855
 {
4ec855
     int i;
4ec855
 
4ec855
@@ -756,9 +759,10 @@ void virtio_gpu_cleanup_mapping_iov(struct iovec *iov, uint32_t count)
4ec855
     g_free(iov);
4ec855
 }
4ec855
 
4ec855
-static void virtio_gpu_cleanup_mapping(struct virtio_gpu_simple_resource *res)
4ec855
+static void virtio_gpu_cleanup_mapping(VirtIOGPU *g,
4ec855
+                                       struct virtio_gpu_simple_resource *res)
4ec855
 {
4ec855
-    virtio_gpu_cleanup_mapping_iov(res->iov, res->iov_cnt);
4ec855
+    virtio_gpu_cleanup_mapping_iov(g, res->iov, res->iov_cnt);
4ec855
     res->iov = NULL;
4ec855
     res->iov_cnt = 0;
4ec855
     g_free(res->addrs);
4ec855
@@ -790,7 +794,7 @@ virtio_gpu_resource_attach_backing(VirtIOGPU *g,
4ec855
         return;
4ec855
     }
4ec855
 
4ec855
-    ret = virtio_gpu_create_mapping_iov(&ab, cmd, &res->addrs, &res->iov);
4ec855
+    ret = virtio_gpu_create_mapping_iov(g, &ab, cmd, &res->addrs, &res->iov);
4ec855
     if (ret != 0) {
4ec855
         cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
4ec855
         return;
4ec855
@@ -817,7 +821,7 @@ virtio_gpu_resource_detach_backing(VirtIOGPU *g,
4ec855
         cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;
4ec855
         return;
4ec855
     }
4ec855
-    virtio_gpu_cleanup_mapping(res);
4ec855
+    virtio_gpu_cleanup_mapping(g, res);
4ec855
 }
4ec855
 
4ec855
 static void virtio_gpu_simple_process_cmd(VirtIOGPU *g,
4ec855
@@ -1143,6 +1147,7 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size,
4ec855
             hwaddr len = res->iov[i].iov_len;
4ec855
             res->iov[i].iov_base =
4ec855
                 cpu_physical_memory_map(res->addrs[i], &len, 1);
4ec855
+
4ec855
             if (!res->iov[i].iov_base || len != res->iov[i].iov_len) {
4ec855
                 /* Clean up the half-a-mapping we just created... */
4ec855
                 if (res->iov[i].iov_base) {
4ec855
@@ -1151,7 +1156,7 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size,
4ec855
                 }
4ec855
                 /* ...and the mappings for previous loop iterations */
4ec855
                 res->iov_cnt = i;
4ec855
-                virtio_gpu_cleanup_mapping(res);
4ec855
+                virtio_gpu_cleanup_mapping(g, res);
4ec855
                 pixman_image_unref(res->image);
4ec855
                 g_free(res);
4ec855
                 return -EINVAL;
4ec855
diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
4ec855
index 22ac3c2..f95f8ce 100644
4ec855
--- a/include/hw/virtio/virtio-gpu.h
4ec855
+++ b/include/hw/virtio/virtio-gpu.h
4ec855
@@ -158,10 +158,12 @@ void virtio_gpu_ctrl_response_nodata(VirtIOGPU *g,
4ec855
                                      enum virtio_gpu_ctrl_type type);
4ec855
 void virtio_gpu_get_display_info(VirtIOGPU *g,
4ec855
                                  struct virtio_gpu_ctrl_command *cmd);
4ec855
-int virtio_gpu_create_mapping_iov(struct virtio_gpu_resource_attach_backing *ab,
4ec855
+int virtio_gpu_create_mapping_iov(VirtIOGPU *g,
4ec855
+                                  struct virtio_gpu_resource_attach_backing *ab,
4ec855
                                   struct virtio_gpu_ctrl_command *cmd,
4ec855
                                   uint64_t **addr, struct iovec **iov);
4ec855
-void virtio_gpu_cleanup_mapping_iov(struct iovec *iov, uint32_t count);
4ec855
+void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g,
4ec855
+                                    struct iovec *iov, uint32_t count);
4ec855
 void virtio_gpu_process_cmdq(VirtIOGPU *g);
4ec855
 
4ec855
 /* virtio-gpu-3d.c */
4ec855
-- 
4ec855
1.8.3.1
4ec855