[PATCH 10/13] drm/virtgpu: switch to using drm_exec
Christian König
ckoenig.leichtzumerken at gmail.com
Thu May 4 11:51:56 UTC 2023
Just a straightforward conversion without any optimization.
Only compile tested for now.
Signed-off-by: Christian König <christian.koenig at amd.com>
---
drivers/gpu/drm/virtio/Kconfig | 1 +
drivers/gpu/drm/virtio/virtgpu_drv.h | 3 ++-
drivers/gpu/drm/virtio/virtgpu_gem.c | 29 +++-------------------------
3 files changed, 6 insertions(+), 27 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 af6ffb696086..c12434222e51 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..bcab407074f4 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, true);
return objs;
}
@@ -214,36 +215,12 @@ 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;
- }
- }
- return ret;
+ return drm_exec_prepare_array(&objs->exec, objs->objs, objs->nents, 1);
}
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
More information about the amd-gfx
mailing list