aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/linux-yocto-4.19.8/1621-drm-amdgpu-wait-for-VM-to-become-idle-during-flush.patch
diff options
context:
space:
mode:
Diffstat (limited to 'common/recipes-kernel/linux/linux-yocto-4.19.8/1621-drm-amdgpu-wait-for-VM-to-become-idle-during-flush.patch')
-rw-r--r--common/recipes-kernel/linux/linux-yocto-4.19.8/1621-drm-amdgpu-wait-for-VM-to-become-idle-during-flush.patch128
1 files changed, 128 insertions, 0 deletions
diff --git a/common/recipes-kernel/linux/linux-yocto-4.19.8/1621-drm-amdgpu-wait-for-VM-to-become-idle-during-flush.patch b/common/recipes-kernel/linux/linux-yocto-4.19.8/1621-drm-amdgpu-wait-for-VM-to-become-idle-during-flush.patch
new file mode 100644
index 00000000..91811855
--- /dev/null
+++ b/common/recipes-kernel/linux/linux-yocto-4.19.8/1621-drm-amdgpu-wait-for-VM-to-become-idle-during-flush.patch
@@ -0,0 +1,128 @@
+From e10ef05e622dd756be1cf9d3be844e54afb687c9 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koenig@amd.com>
+Date: Thu, 10 Jan 2019 16:48:23 +0100
+Subject: [PATCH 1621/2940] drm/amdgpu: wait for VM to become idle during flush
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Make sure that not only the entities are flush, but that
+we also wait for the HW to finish all processing.
+
+Signed-off-by: Christian König <christian.koenig@amd.com>
+Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
+Signed-off-by: Chaudhary Amit Kumar <Chaudharyamit.Kumar@amd.com>
+---
+ drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 6 +++---
+ drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h | 2 +-
+ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 7 ++++---
+ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 ++++++++++++
+ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 2 ++
+ 5 files changed, 22 insertions(+), 7 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+index 67c154c775b0..871b591cf64a 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+@@ -560,13 +560,12 @@ void amdgpu_ctx_mgr_init(struct amdgpu_ctx_mgr *mgr)
+ idr_init(&mgr->ctx_handles);
+ }
+
+-void amdgpu_ctx_mgr_entity_flush(struct amdgpu_ctx_mgr *mgr)
++long amdgpu_ctx_mgr_entity_flush(struct amdgpu_ctx_mgr *mgr, long timeout)
+ {
+ unsigned num_entities = amdgput_ctx_total_num_entities();
+ struct amdgpu_ctx *ctx;
+ struct idr *idp;
+ uint32_t id, i;
+- long max_wait = MAX_WAIT_SCHED_ENTITY_Q_EMPTY;
+
+ idp = &mgr->ctx_handles;
+
+@@ -576,10 +575,11 @@ void amdgpu_ctx_mgr_entity_flush(struct amdgpu_ctx_mgr *mgr)
+ struct drm_sched_entity *entity;
+
+ entity = &ctx->entities[0][i].entity;
+- max_wait = drm_sched_entity_flush(entity, max_wait);
++ timeout = drm_sched_entity_flush(entity, timeout);
+ }
+ }
+ mutex_unlock(&mgr->lock);
++ return timeout;
+ }
+
+ void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr)
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h
+index 934780c3140c..f22da13dfffd 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h
+@@ -86,7 +86,7 @@ int amdgpu_ctx_wait_prev_fence(struct amdgpu_ctx *ctx,
+
+ void amdgpu_ctx_mgr_init(struct amdgpu_ctx_mgr *mgr);
+ void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr);
+-void amdgpu_ctx_mgr_entity_flush(struct amdgpu_ctx_mgr *mgr);
++long amdgpu_ctx_mgr_entity_flush(struct amdgpu_ctx_mgr *mgr, long timeout);
+ void amdgpu_ctx_mgr_fini(struct amdgpu_ctx_mgr *mgr);
+
+ #endif
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+index b0bea690489e..5d686e4aa4ae 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+@@ -1094,13 +1094,14 @@ static int amdgpu_flush(struct file *f, fl_owner_t id)
+ {
+ struct drm_file *file_priv = f->private_data;
+ struct amdgpu_fpriv *fpriv = file_priv->driver_priv;
++ long timeout = MAX_WAIT_SCHED_ENTITY_Q_EMPTY;
+
+- amdgpu_ctx_mgr_entity_flush(&fpriv->ctx_mgr);
++ timeout = amdgpu_ctx_mgr_entity_flush(&fpriv->ctx_mgr, timeout);
++ timeout = amdgpu_vm_wait_idle(&fpriv->vm, timeout);
+
+- return 0;
++ return timeout >= 0 ? 0 : timeout;
+ }
+
+-
+ static const struct file_operations amdgpu_driver_kms_fops = {
+ .owner = THIS_MODULE,
+ .open = drm_open,
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+index 43e34b0f4a0b..688ebc71c6c1 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+@@ -2942,6 +2942,18 @@ void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint32_t min_vm_size,
+ adev->vm_manager.fragment_size);
+ }
+
++/**
++ * amdgpu_vm_wait_idle - wait for the VM to become idle
++ *
++ * @vm: VM object to wait for
++ * @timeout: timeout to wait for VM to become idle
++ */
++long amdgpu_vm_wait_idle(struct amdgpu_vm *vm, long timeout)
++{
++ return reservation_object_wait_timeout_rcu(vm->root.base.bo->tbo.resv,
++ true, true, timeout);
++}
++
+ /**
+ * amdgpu_vm_init - initialize a vm instance
+ *
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+index f3021f01f5a6..af5bb52cc148 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+@@ -281,6 +281,8 @@ struct amdgpu_vm_manager {
+
+ void amdgpu_vm_manager_init(struct amdgpu_device *adev);
+ void amdgpu_vm_manager_fini(struct amdgpu_device *adev);
++
++long amdgpu_vm_wait_idle(struct amdgpu_vm *vm, long timeout);
+ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
+ int vm_context, unsigned int pasid);
+ int amdgpu_vm_make_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm);
+--
+2.17.1
+