Just a straightforward conversion without any optimization. Only compile tested for now. Signed-off-by: Christian König <christian.koenig@xxxxxxx> Cc: David Airlie <airlied@xxxxxxxxxx> Cc: Gerd Hoffmann <kraxel@xxxxxxxxxx> Cc: Gurchetan Singh <gurchetansingh@xxxxxxxxxxxx> Cc: Chia-I Wu <olvaffe@xxxxxxxxx> Cc: virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx --- drivers/gpu/drm/virtio/Kconfig | 1 + drivers/gpu/drm/virtio/virtgpu_drv.h | 3 ++- drivers/gpu/drm/virtio/virtgpu_gem.c | 28 +++++----------------------- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/virtio/Kconfig b/drivers/gpu/drm/virtio/Kconfig index ea06ff2aa4b4..a24a1ce5e666 100644 --- a/drivers/gpu/drm/virtio/Kconfig +++ b/drivers/gpu/drm/virtio/Kconfig @@ -5,6 +5,7 @@ config DRM_VIRTIO_GPU select VIRTIO select DRM_KMS_HELPER select DRM_GEM_SHMEM_HELPER + select DRM_EXEC select VIRTIO_DMA_SHARED_BUFFER help This is the virtual GPU driver for virtio. It can be used with diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index 4126c384286b..cb5d9218a3ab 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -35,6 +35,7 @@ #include <drm/drm_atomic.h> #include <drm/drm_drv.h> #include <drm/drm_encoder.h> +#include <drm/drm_exec.h> #include <drm/drm_fourcc.h> #include <drm/drm_framebuffer.h> #include <drm/drm_gem.h> @@ -116,7 +117,7 @@ struct virtio_gpu_object_vram { container_of((virtio_gpu_object), struct virtio_gpu_object_vram, base) struct virtio_gpu_object_array { - struct ww_acquire_ctx ticket; + struct drm_exec exec; struct list_head next; u32 nents, total; struct drm_gem_object *objs[]; diff --git a/drivers/gpu/drm/virtio/virtgpu_gem.c b/drivers/gpu/drm/virtio/virtgpu_gem.c index 7db48d17ee3a..bb7928e7b3b6 100644 --- a/drivers/gpu/drm/virtio/virtgpu_gem.c +++ b/drivers/gpu/drm/virtio/virtgpu_gem.c @@ -171,6 +171,7 @@ struct virtio_gpu_object_array *virtio_gpu_array_alloc(u32 nents) objs->nents = 0; objs->total = nents; + drm_exec_init(&objs->exec, DRM_EXEC_INTERRUPTIBLE_WAIT); return objs; } @@ -214,36 +215,17 @@ void virtio_gpu_array_add_obj(struct virtio_gpu_object_array *objs, int virtio_gpu_array_lock_resv(struct virtio_gpu_object_array *objs) { - unsigned int i; int ret; - if (objs->nents == 1) { - ret = dma_resv_lock_interruptible(objs->objs[0]->resv, NULL); - } else { - ret = drm_gem_lock_reservations(objs->objs, objs->nents, - &objs->ticket); - } - if (ret) - return ret; - - for (i = 0; i < objs->nents; ++i) { - ret = dma_resv_reserve_fences(objs->objs[i]->resv, 1); - if (ret) { - virtio_gpu_array_unlock_resv(objs); - return ret; - } - } + drm_exec_until_all_locked(&objs->exec) + ret = drm_exec_prepare_array(&objs->exec, objs->objs, + objs->nents, 1); return ret; } void virtio_gpu_array_unlock_resv(struct virtio_gpu_object_array *objs) { - if (objs->nents == 1) { - dma_resv_unlock(objs->objs[0]->resv); - } else { - drm_gem_unlock_reservations(objs->objs, objs->nents, - &objs->ticket); - } + drm_exec_fini(&objs->exec); } void virtio_gpu_array_add_fence(struct virtio_gpu_object_array *objs, -- 2.34.1