cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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