aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/linux-yocto-4.14.71/5386-drm-amdgpu-improve-VM-state-machine-documentation-v2.patch
diff options
context:
space:
mode:
Diffstat (limited to 'common/recipes-kernel/linux/linux-yocto-4.14.71/5386-drm-amdgpu-improve-VM-state-machine-documentation-v2.patch')
-rw-r--r--common/recipes-kernel/linux/linux-yocto-4.14.71/5386-drm-amdgpu-improve-VM-state-machine-documentation-v2.patch192
1 files changed, 192 insertions, 0 deletions
diff --git a/common/recipes-kernel/linux/linux-yocto-4.14.71/5386-drm-amdgpu-improve-VM-state-machine-documentation-v2.patch b/common/recipes-kernel/linux/linux-yocto-4.14.71/5386-drm-amdgpu-improve-VM-state-machine-documentation-v2.patch
new file mode 100644
index 00000000..7e5cece0
--- /dev/null
+++ b/common/recipes-kernel/linux/linux-yocto-4.14.71/5386-drm-amdgpu-improve-VM-state-machine-documentation-v2.patch
@@ -0,0 +1,192 @@
+From f09a38bf9995b395d2553e91704b7d4e620287fa Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koenig@amd.com>
+Date: Thu, 30 Aug 2018 10:27:15 +0200
+Subject: [PATCH 5386/5725] drm/amdgpu: improve VM state machine documentation
+ v2
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Since we have a lot of FAQ on the VM state machine try to improve the
+documentation by adding functions for each state move.
+
+v2: fix typo in amdgpu_vm_bo_invalidated, use amdgpu_vm_bo_relocated in
+ one more place as well.
+
+Signed-off-by: Christian König <christian.koenig@amd.com>
+Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
+Signed-off-by: Raveendra Talabattula <raveendra.talabattula@amd.com>
+---
+ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 91 +++++++++++++++++++++++++++-------
+ 1 file changed, 72 insertions(+), 19 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+index adb61a2..b54870f 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+@@ -205,6 +205,64 @@ static unsigned amdgpu_vm_bo_size(struct amdgpu_device *adev, unsigned level)
+ }
+
+ /**
++ * amdgpu_vm_bo_evicted - vm_bo is evicted
++ *
++ * @vm_bo: vm_bo which is evicted
++ *
++ * State for PDs/PTs and per VM BOs which are not at the location they should
++ * be.
++ */
++static void amdgpu_vm_bo_evicted(struct amdgpu_vm_bo_base *vm_bo)
++{
++ struct amdgpu_vm *vm = vm_bo->vm;
++ struct amdgpu_bo *bo = vm_bo->bo;
++
++ vm_bo->moved = true;
++ if (bo->tbo.type == ttm_bo_type_kernel)
++ list_move(&vm_bo->vm_status, &vm->evicted);
++ else
++ list_move_tail(&vm_bo->vm_status, &vm->evicted);
++}
++
++/**
++ * amdgpu_vm_bo_relocated - vm_bo is reloacted
++ *
++ * @vm_bo: vm_bo which is relocated
++ *
++ * State for PDs/PTs which needs to update their parent PD.
++ */
++static void amdgpu_vm_bo_relocated(struct amdgpu_vm_bo_base *vm_bo)
++{
++ list_move(&vm_bo->vm_status, &vm_bo->vm->relocated);
++}
++
++/**
++ * amdgpu_vm_bo_moved - vm_bo is moved
++ *
++ * @vm_bo: vm_bo which is moved
++ *
++ * State for per VM BOs which are moved, but that change is not yet reflected
++ * in the page tables.
++ */
++static void amdgpu_vm_bo_moved(struct amdgpu_vm_bo_base *vm_bo)
++{
++ list_move(&vm_bo->vm_status, &vm_bo->vm->moved);
++}
++
++/**
++ * amdgpu_vm_bo_done - vm_bo is done
++ *
++ * @vm_bo: vm_bo which is now done
++ *
++ * State for normal BOs which are invalidated and that change has been updated
++ * in the PTs.
++ */
++static void amdgpu_vm_bo_done(struct amdgpu_vm_bo_base *vm_bo)
++{
++ list_del_init(&vm_bo->vm_status);
++}
++
++/**
+ * amdgpu_vm_bo_base_init - Adds bo to the list of bos associated with the vm
+ *
+ * @base: base structure for tracking BO usage in a VM
+@@ -228,7 +286,7 @@ static void amdgpu_vm_bo_base_init(struct amdgpu_vm_bo_base *base,
+ list_add_tail(&base->bo_list, &bo->va);
+
+ if (bo->tbo.type == ttm_bo_type_kernel)
+- list_move(&base->vm_status, &vm->relocated);
++ amdgpu_vm_bo_relocated(base);
+
+ if (bo->tbo.resv != vm->root.base.bo->tbo.resv)
+ return;
+@@ -242,8 +300,7 @@ static void amdgpu_vm_bo_base_init(struct amdgpu_vm_bo_base *base,
+ * is currently evicted. add the bo to the evicted list to make sure it
+ * is validated on next vm use to avoid fault.
+ * */
+- list_move_tail(&base->vm_status, &vm->evicted);
+- base->moved = true;
++ amdgpu_vm_bo_evicted(base);
+ }
+
+ /**
+@@ -306,7 +363,7 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm,
+
+ if (bo->tbo.type != ttm_bo_type_kernel) {
+ spin_lock(&vm->moved_lock);
+- list_move(&bo_base->vm_status, &vm->moved);
++ amdgpu_vm_bo_moved(bo_base);
+ spin_unlock(&vm->moved_lock);
+ } else {
+ if (vm->use_cpu_for_update)
+@@ -315,7 +372,7 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm,
+ r = amdgpu_ttm_alloc_gart(&bo->tbo);
+ if (r)
+ break;
+- list_move(&bo_base->vm_status, &vm->relocated);
++ amdgpu_vm_bo_relocated(bo_base);
+ }
+ }
+
+@@ -1031,7 +1088,7 @@ static void amdgpu_vm_invalidate_level(struct amdgpu_device *adev,
+ continue;
+
+ if (!entry->base.moved)
+- list_move(&entry->base.vm_status, &vm->relocated);
++ amdgpu_vm_bo_relocated(&entry->base);
+ amdgpu_vm_invalidate_level(adev, vm, entry, level + 1);
+ }
+ }
+@@ -1206,7 +1263,7 @@ static void amdgpu_vm_handle_huge_pages(struct amdgpu_pte_update_params *p,
+ if (entry->huge) {
+ /* Add the entry to the relocated list to update it. */
+ entry->huge = false;
+- list_move(&entry->base.vm_status, &p->vm->relocated);
++ amdgpu_vm_bo_relocated(&entry->base);
+ }
+ return;
+ }
+@@ -1737,7 +1794,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev,
+ if (bo && bo->tbo.resv == vm->root.base.bo->tbo.resv &&
+ !(bo->preferred_domains &
+ amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type)))
+- list_add_tail(&bo_va->base.vm_status, &vm->evicted);
++ amdgpu_vm_bo_evicted(&bo_va->base);
+
+ list_splice_init(&bo_va->invalids, &bo_va->valids);
+ bo_va->cleared = clear;
+@@ -2461,26 +2518,22 @@ void amdgpu_vm_bo_invalidate(struct amdgpu_device *adev,
+
+ list_for_each_entry(bo_base, &bo->va, bo_list) {
+ struct amdgpu_vm *vm = bo_base->vm;
+- bool was_moved = bo_base->moved;
+
+- bo_base->moved = true;
+ if (evicted && bo->tbo.resv == vm->root.base.bo->tbo.resv) {
+- if (bo->tbo.type == ttm_bo_type_kernel)
+- list_move(&bo_base->vm_status, &vm->evicted);
+- else
+- list_move_tail(&bo_base->vm_status,
+- &vm->evicted);
++ amdgpu_vm_bo_evicted(bo_base);
+ continue;
+ }
+
+- if (was_moved)
+- continue;
++ if (bo_base->moved)
++ continue;
++
++ bo_base->moved = true;
+
+ if (bo->tbo.type == ttm_bo_type_kernel) {
+- list_move(&bo_base->vm_status, &vm->relocated);
++ amdgpu_vm_bo_relocated(bo_base);
+ } else {
+ spin_lock(&bo_base->vm->moved_lock);
+- list_move(&bo_base->vm_status, &vm->moved);
++ amdgpu_vm_bo_moved(bo_base);
+ spin_unlock(&bo_base->vm->moved_lock);
+ }
+ }
+--
+2.7.4
+