diff options
author | Jiandi An <jiandi.an@amd.com> | 2018-09-19 03:09:53 -0400 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2018-09-19 07:33:06 -0400 |
commit | 8f44ca223345a7d02e18ed4e70ff95178434e137 (patch) | |
tree | a7c73784d3c2f6782bd0d41f86468795960cb49f | |
parent | 3536faefc03d48e97891ed7fc542ff85ce00a4e1 (diff) |
drm/virtio: add dma sync for dma mapped virtio gpu framebuffer pages
With virtio gpu ttm-pages being dma mapped, dma sync is needed when
swiotlb is used as bounce buffers, before TRANSFER_TO_HOST_2D/3D
commands are sent.
Signed-off-by: Jiandi An <jiandi.an@amd.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20180919070931.91168-1-jiandi.an@amd.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
-rw-r--r-- | drivers/gpu/drm/virtio/virtgpu_drv.h | 8 | ||||
-rw-r--r-- | drivers/gpu/drm/virtio/virtgpu_fb.c | 7 | ||||
-rw-r--r-- | drivers/gpu/drm/virtio/virtgpu_vq.c | 18 |
3 files changed, 26 insertions, 7 deletions
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index f8f4a40dd1b8..a2d79e18bda7 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <drm/drm_atomic.h> | 36 | #include <drm/drm_atomic.h> |
37 | #include <drm/drm_crtc_helper.h> | 37 | #include <drm/drm_crtc_helper.h> |
38 | #include <drm/drm_encoder.h> | 38 | #include <drm/drm_encoder.h> |
39 | #include <drm/drm_fb_helper.h> | ||
39 | #include <drm/ttm/ttm_bo_api.h> | 40 | #include <drm/ttm/ttm_bo_api.h> |
40 | #include <drm/ttm/ttm_bo_driver.h> | 41 | #include <drm/ttm/ttm_bo_driver.h> |
41 | #include <drm/ttm/ttm_placement.h> | 42 | #include <drm/ttm/ttm_placement.h> |
@@ -133,6 +134,13 @@ struct virtio_gpu_framebuffer { | |||
133 | #define to_virtio_gpu_framebuffer(x) \ | 134 | #define to_virtio_gpu_framebuffer(x) \ |
134 | container_of(x, struct virtio_gpu_framebuffer, base) | 135 | container_of(x, struct virtio_gpu_framebuffer, base) |
135 | 136 | ||
137 | struct virtio_gpu_fbdev { | ||
138 | struct drm_fb_helper helper; | ||
139 | struct virtio_gpu_framebuffer vgfb; | ||
140 | struct virtio_gpu_device *vgdev; | ||
141 | struct delayed_work work; | ||
142 | }; | ||
143 | |||
136 | struct virtio_gpu_mman { | 144 | struct virtio_gpu_mman { |
137 | struct ttm_bo_global_ref bo_global_ref; | 145 | struct ttm_bo_global_ref bo_global_ref; |
138 | struct drm_global_reference mem_global_ref; | 146 | struct drm_global_reference mem_global_ref; |
diff --git a/drivers/gpu/drm/virtio/virtgpu_fb.c b/drivers/gpu/drm/virtio/virtgpu_fb.c index b5cebc9a179a..b9678c4082ac 100644 --- a/drivers/gpu/drm/virtio/virtgpu_fb.c +++ b/drivers/gpu/drm/virtio/virtgpu_fb.c | |||
@@ -29,13 +29,6 @@ | |||
29 | 29 | ||
30 | #define VIRTIO_GPU_FBCON_POLL_PERIOD (HZ / 60) | 30 | #define VIRTIO_GPU_FBCON_POLL_PERIOD (HZ / 60) |
31 | 31 | ||
32 | struct virtio_gpu_fbdev { | ||
33 | struct drm_fb_helper helper; | ||
34 | struct virtio_gpu_framebuffer vgfb; | ||
35 | struct virtio_gpu_device *vgdev; | ||
36 | struct delayed_work work; | ||
37 | }; | ||
38 | |||
39 | static int virtio_gpu_dirty_update(struct virtio_gpu_framebuffer *fb, | 32 | static int virtio_gpu_dirty_update(struct virtio_gpu_framebuffer *fb, |
40 | bool store, int x, int y, | 33 | bool store, int x, int y, |
41 | int width, int height) | 34 | int width, int height) |
diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index 5784c3ea8767..df32811f2c3e 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c | |||
@@ -490,6 +490,15 @@ void virtio_gpu_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev, | |||
490 | { | 490 | { |
491 | struct virtio_gpu_transfer_to_host_2d *cmd_p; | 491 | struct virtio_gpu_transfer_to_host_2d *cmd_p; |
492 | struct virtio_gpu_vbuffer *vbuf; | 492 | struct virtio_gpu_vbuffer *vbuf; |
493 | struct virtio_gpu_fbdev *vgfbdev = vgdev->vgfbdev; | ||
494 | struct virtio_gpu_framebuffer *fb = &vgfbdev->vgfb; | ||
495 | struct virtio_gpu_object *obj = gem_to_virtio_gpu_obj(fb->base.obj[0]); | ||
496 | bool use_dma_api = !virtio_has_iommu_quirk(vgdev->vdev); | ||
497 | |||
498 | if (use_dma_api) | ||
499 | dma_sync_sg_for_device(vgdev->vdev->dev.parent, | ||
500 | obj->pages->sgl, obj->pages->nents, | ||
501 | DMA_TO_DEVICE); | ||
493 | 502 | ||
494 | cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p)); | 503 | cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p)); |
495 | memset(cmd_p, 0, sizeof(*cmd_p)); | 504 | memset(cmd_p, 0, sizeof(*cmd_p)); |
@@ -789,6 +798,15 @@ void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev, | |||
789 | { | 798 | { |
790 | struct virtio_gpu_transfer_host_3d *cmd_p; | 799 | struct virtio_gpu_transfer_host_3d *cmd_p; |
791 | struct virtio_gpu_vbuffer *vbuf; | 800 | struct virtio_gpu_vbuffer *vbuf; |
801 | struct virtio_gpu_fbdev *vgfbdev = vgdev->vgfbdev; | ||
802 | struct virtio_gpu_framebuffer *fb = &vgfbdev->vgfb; | ||
803 | struct virtio_gpu_object *obj = gem_to_virtio_gpu_obj(fb->base.obj[0]); | ||
804 | bool use_dma_api = !virtio_has_iommu_quirk(vgdev->vdev); | ||
805 | |||
806 | if (use_dma_api) | ||
807 | dma_sync_sg_for_device(vgdev->vdev->dev.parent, | ||
808 | obj->pages->sgl, obj->pages->nents, | ||
809 | DMA_TO_DEVICE); | ||
792 | 810 | ||
793 | cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p)); | 811 | cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p)); |
794 | memset(cmd_p, 0, sizeof(*cmd_p)); | 812 | memset(cmd_p, 0, sizeof(*cmd_p)); |