@@ -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
@@ -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[];
@@ -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,
Just a straightforward conversion without any optimization. Only compile tested for now. Signed-off-by: Christian König <christian.koenig@amd.com> Cc: David Airlie <airlied@redhat.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Gurchetan Singh <gurchetansingh@chromium.org> Cc: Chia-I Wu <olvaffe@gmail.com> Cc: virtualization@lists.linux-foundation.org --- 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(-)