aboutsummaryrefslogtreecommitdiff
path: root/hw/display/virtio-gpu.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2018-08-29 14:21:00 +0200
committerGerd Hoffmann <kraxel@redhat.com>2018-09-03 08:31:50 +0200
commit3bb68f798da0234d5ca0ac6062aaa084afc83069 (patch)
tree765cf176677242b179c02acf3978d8b9abfc89ff /hw/display/virtio-gpu.c
parent91155f8bf723434cd22c46b12a040ebe90b0d651 (diff)
virtio-gpu: pass down VirtIOGPU pointer to a bunch of functions
No functional change, just preparation for a followup patch which needs a VirtIOGPU pointer. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-Id: <20180829122101.29852-2-kraxel@redhat.com>
Diffstat (limited to 'hw/display/virtio-gpu.c')
-rw-r--r--hw/display/virtio-gpu.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 410cf0c98a..cf31b5f710 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -29,7 +29,8 @@
static struct virtio_gpu_simple_resource*
virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id);
-static void virtio_gpu_cleanup_mapping(struct virtio_gpu_simple_resource *res);
+static void virtio_gpu_cleanup_mapping(VirtIOGPU *g,
+ struct virtio_gpu_simple_resource *res);
static void
virtio_gpu_ctrl_hdr_bswap(struct virtio_gpu_ctrl_hdr *hdr)
@@ -442,7 +443,7 @@ static void virtio_gpu_resource_destroy(VirtIOGPU *g,
}
pixman_image_unref(res->image);
- virtio_gpu_cleanup_mapping(res);
+ virtio_gpu_cleanup_mapping(g, res);
QTAILQ_REMOVE(&g->reslist, res, next);
g->hostmem -= res->hostmem;
g_free(res);
@@ -688,7 +689,8 @@ static void virtio_gpu_set_scanout(VirtIOGPU *g,
scanout->height = ss.r.height;
}
-int virtio_gpu_create_mapping_iov(struct virtio_gpu_resource_attach_backing *ab,
+int virtio_gpu_create_mapping_iov(VirtIOGPU *g,
+ struct virtio_gpu_resource_attach_backing *ab,
struct virtio_gpu_ctrl_command *cmd,
uint64_t **addr, struct iovec **iov)
{
@@ -732,7 +734,7 @@ int virtio_gpu_create_mapping_iov(struct virtio_gpu_resource_attach_backing *ab,
qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to map MMIO memory for"
" resource %d element %d\n",
__func__, ab->resource_id, i);
- virtio_gpu_cleanup_mapping_iov(*iov, i);
+ virtio_gpu_cleanup_mapping_iov(g, *iov, i);
g_free(ents);
*iov = NULL;
if (addr) {
@@ -746,7 +748,8 @@ int virtio_gpu_create_mapping_iov(struct virtio_gpu_resource_attach_backing *ab,
return 0;
}
-void virtio_gpu_cleanup_mapping_iov(struct iovec *iov, uint32_t count)
+void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g,
+ struct iovec *iov, uint32_t count)
{
int i;
@@ -757,9 +760,10 @@ void virtio_gpu_cleanup_mapping_iov(struct iovec *iov, uint32_t count)
g_free(iov);
}
-static void virtio_gpu_cleanup_mapping(struct virtio_gpu_simple_resource *res)
+static void virtio_gpu_cleanup_mapping(VirtIOGPU *g,
+ struct virtio_gpu_simple_resource *res)
{
- virtio_gpu_cleanup_mapping_iov(res->iov, res->iov_cnt);
+ virtio_gpu_cleanup_mapping_iov(g, res->iov, res->iov_cnt);
res->iov = NULL;
res->iov_cnt = 0;
g_free(res->addrs);
@@ -791,7 +795,7 @@ virtio_gpu_resource_attach_backing(VirtIOGPU *g,
return;
}
- ret = virtio_gpu_create_mapping_iov(&ab, cmd, &res->addrs, &res->iov);
+ ret = virtio_gpu_create_mapping_iov(g, &ab, cmd, &res->addrs, &res->iov);
if (ret != 0) {
cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
return;
@@ -818,7 +822,7 @@ virtio_gpu_resource_detach_backing(VirtIOGPU *g,
cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;
return;
}
- virtio_gpu_cleanup_mapping(res);
+ virtio_gpu_cleanup_mapping(g, res);
}
static void virtio_gpu_simple_process_cmd(VirtIOGPU *g,
@@ -1144,6 +1148,7 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size,
hwaddr len = res->iov[i].iov_len;
res->iov[i].iov_base =
cpu_physical_memory_map(res->addrs[i], &len, 1);
+
if (!res->iov[i].iov_base || len != res->iov[i].iov_len) {
/* Clean up the half-a-mapping we just created... */
if (res->iov[i].iov_base) {
@@ -1152,7 +1157,7 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size,
}
/* ...and the mappings for previous loop iterations */
res->iov_cnt = i;
- virtio_gpu_cleanup_mapping(res);
+ virtio_gpu_cleanup_mapping(g, res);
pixman_image_unref(res->image);
g_free(res);
return -EINVAL;