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