drm/virtio: pass virtio_gpu_object to virtio_gpu_cmd_transfer_to_host_{2d, 3d}
authorGerd Hoffmann <kraxel@redhat.com>
Thu, 20 Sep 2018 06:29:23 +0000 (08:29 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Tue, 25 Sep 2018 12:49:49 +0000 (14:49 +0200)
Pass virtio_gpu_object down to virtio_gpu_cmd_transfer_to_host_2d and
virtio_gpu_cmd_transfer_to_host_3d functions, instead of passing just
the virtio resource handle.

This is needed to lookup the scatter list of the object, for dma sync.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiandi An <jiandi.an@amd.com>
Tested-by: Jiandi An <jiandi.an@amd.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20180920062924.6514-1-kraxel@redhat.com
drivers/gpu/drm/virtio/virtgpu_drv.h
drivers/gpu/drm/virtio/virtgpu_fb.c
drivers/gpu/drm/virtio/virtgpu_ioctl.c
drivers/gpu/drm/virtio/virtgpu_plane.c
drivers/gpu/drm/virtio/virtgpu_vq.c

index a2d79e18bda7cbe3b6b8228906ca5e1ff75ef315..253fcf018dbe02a08507d05c413bbba0b55a8d29 100644 (file)
@@ -270,7 +270,8 @@ void virtio_gpu_cmd_create_resource(struct virtio_gpu_device *vgdev,
 void virtio_gpu_cmd_unref_resource(struct virtio_gpu_device *vgdev,
                                   uint32_t resource_id);
 void virtio_gpu_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev,
-                                       uint32_t resource_id, uint64_t offset,
+                                       struct virtio_gpu_object *bo,
+                                       uint64_t offset,
                                        __le32 width, __le32 height,
                                        __le32 x, __le32 y,
                                        struct virtio_gpu_fence **fence);
@@ -316,7 +317,8 @@ void virtio_gpu_cmd_transfer_from_host_3d(struct virtio_gpu_device *vgdev,
                                          struct virtio_gpu_box *box,
                                          struct virtio_gpu_fence **fence);
 void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev,
-                                       uint32_t resource_id, uint32_t ctx_id,
+                                       struct virtio_gpu_object *bo,
+                                       uint32_t ctx_id,
                                        uint64_t offset, uint32_t level,
                                        struct virtio_gpu_box *box,
                                        struct virtio_gpu_fence **fence);
index b9678c4082ac08b5043f1ee7d615f43b14ab9faf..3364b0970dd2e82c31947bd70818b4d252f8fd31 100644 (file)
@@ -95,7 +95,7 @@ static int virtio_gpu_dirty_update(struct virtio_gpu_framebuffer *fb,
 
                offset = (y * fb->base.pitches[0]) + x * bpp;
 
-               virtio_gpu_cmd_transfer_to_host_2d(vgdev, obj->hw_res_handle,
+               virtio_gpu_cmd_transfer_to_host_2d(vgdev, obj,
                                                   offset,
                                                   cpu_to_le32(w),
                                                   cpu_to_le32(h),
index 7bdf6f0e58a5343a880470e61e69ee2292b7bd42..f16b875d6a46b32c4c8a6a3694aaec05da3727f7 100644 (file)
@@ -429,11 +429,11 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data,
        convert_to_hw_box(&box, &args->box);
        if (!vgdev->has_virgl_3d) {
                virtio_gpu_cmd_transfer_to_host_2d
-                       (vgdev, qobj->hw_res_handle, offset,
+                       (vgdev, qobj, offset,
                         box.w, box.h, box.x, box.y, NULL);
        } else {
                virtio_gpu_cmd_transfer_to_host_3d
-                       (vgdev, qobj->hw_res_handle,
+                       (vgdev, qobj,
                         vfpriv ? vfpriv->ctx_id : 0, offset,
                         args->level, &box, &fence);
                reservation_object_add_excl_fence(qobj->tbo.resv,
index 88f2fb8c61c48dfacf430b3265dac74e645a9539..682a977d68c1485cbdd29cf75576966dfe7fde48 100644 (file)
@@ -158,7 +158,7 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
                handle = bo->hw_res_handle;
                if (bo->dumb) {
                        virtio_gpu_cmd_transfer_to_host_2d
-                               (vgdev, handle, 0,
+                               (vgdev, bo, 0,
                                 cpu_to_le32(plane->state->src_w >> 16),
                                 cpu_to_le32(plane->state->src_h >> 16),
                                 cpu_to_le32(plane->state->src_x >> 16),
@@ -217,7 +217,7 @@ static void virtio_gpu_cursor_plane_update(struct drm_plane *plane,
        if (bo && bo->dumb && (plane->state->fb != old_state->fb)) {
                /* new cursor -- update & wait */
                virtio_gpu_cmd_transfer_to_host_2d
-                       (vgdev, handle, 0,
+                       (vgdev, bo, 0,
                         cpu_to_le32(plane->state->crtc_w),
                         cpu_to_le32(plane->state->crtc_h),
                         0, 0, &fence);
index df32811f2c3e21014526bb5a544bbc65f8e3348e..4e2e037aed34a22551225f2cb623f5492484c72a 100644 (file)
@@ -483,28 +483,26 @@ void virtio_gpu_cmd_resource_flush(struct virtio_gpu_device *vgdev,
 }
 
 void virtio_gpu_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev,
-                                       uint32_t resource_id, uint64_t offset,
+                                       struct virtio_gpu_object *bo,
+                                       uint64_t offset,
                                        __le32 width, __le32 height,
                                        __le32 x, __le32 y,
                                        struct virtio_gpu_fence **fence)
 {
        struct virtio_gpu_transfer_to_host_2d *cmd_p;
        struct virtio_gpu_vbuffer *vbuf;
-       struct virtio_gpu_fbdev *vgfbdev = vgdev->vgfbdev;
-       struct virtio_gpu_framebuffer *fb = &vgfbdev->vgfb;
-       struct virtio_gpu_object *obj = gem_to_virtio_gpu_obj(fb->base.obj[0]);
        bool use_dma_api = !virtio_has_iommu_quirk(vgdev->vdev);
 
        if (use_dma_api)
                dma_sync_sg_for_device(vgdev->vdev->dev.parent,
-                                      obj->pages->sgl, obj->pages->nents,
+                                      bo->pages->sgl, bo->pages->nents,
                                       DMA_TO_DEVICE);
 
        cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p));
        memset(cmd_p, 0, sizeof(*cmd_p));
 
        cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D);
-       cmd_p->resource_id = cpu_to_le32(resource_id);
+       cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle);
        cmd_p->offset = cpu_to_le64(offset);
        cmd_p->r.width = width;
        cmd_p->r.height = height;
@@ -791,21 +789,19 @@ virtio_gpu_cmd_resource_create_3d(struct virtio_gpu_device *vgdev,
 }
 
 void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev,
-                                       uint32_t resource_id, uint32_t ctx_id,
+                                       struct virtio_gpu_object *bo,
+                                       uint32_t ctx_id,
                                        uint64_t offset, uint32_t level,
                                        struct virtio_gpu_box *box,
                                        struct virtio_gpu_fence **fence)
 {
        struct virtio_gpu_transfer_host_3d *cmd_p;
        struct virtio_gpu_vbuffer *vbuf;
-       struct virtio_gpu_fbdev *vgfbdev = vgdev->vgfbdev;
-       struct virtio_gpu_framebuffer *fb = &vgfbdev->vgfb;
-       struct virtio_gpu_object *obj = gem_to_virtio_gpu_obj(fb->base.obj[0]);
        bool use_dma_api = !virtio_has_iommu_quirk(vgdev->vdev);
 
        if (use_dma_api)
                dma_sync_sg_for_device(vgdev->vdev->dev.parent,
-                                      obj->pages->sgl, obj->pages->nents,
+                                      bo->pages->sgl, bo->pages->nents,
                                       DMA_TO_DEVICE);
 
        cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p));
@@ -813,7 +809,7 @@ void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev,
 
        cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_TRANSFER_TO_HOST_3D);
        cmd_p->hdr.ctx_id = cpu_to_le32(ctx_id);
-       cmd_p->resource_id = cpu_to_le32(resource_id);
+       cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle);
        cmd_p->box = *box;
        cmd_p->offset = cpu_to_le64(offset);
        cmd_p->level = cpu_to_le32(level);