aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/files/1046-drm-amdgpu-fix-wrong-release-of-vmid-owner.patch
blob: 8f2e4173977cbff8dcdd3b62655167ed34a0072d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From 6bd1654dc4398ecfc3798b43eb265b7d06c9c903 Mon Sep 17 00:00:00 2001
From: Chunming Zhou <David1.Zhou@amd.com>
Date: Mon, 25 Apr 2016 10:28:24 +0800
Subject: [PATCH 1046/1110] drm/amdgpu: fix wrong release of vmid owner

Signed-off-by: Chunming Zhou <David1.Zhou@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Monk Liu <monk.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Kalyan Alle <kalyan.alle@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 4f16688..8650d61 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1458,6 +1458,7 @@ error_free_sched_entity:
 void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 {
 	struct amdgpu_bo_va_mapping *mapping, *tmp;
+        struct amdgpu_vm_id *id, *id_tmp;
 	int i;
 
         amd_sched_entity_fini(vm->entity.sched, &vm->entity);
@@ -1482,14 +1483,17 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 	amdgpu_bo_unref(&vm->page_directory);
 	fence_put(vm->page_directory_fence);
 
-	for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
-		struct amdgpu_vm_id *id = vm->ids[i];
-
+        mutex_lock(&adev->vm_manager.lock);
+        list_for_each_entry_safe(id, id_tmp, &adev->vm_manager.ids_lru,
+                                 list) {
 		if (!id)
 			continue;
-
-		atomic_long_cmpxchg(&id->owner, (long)vm, 0);
+                if (atomic_long_read(&id->owner) == (long)vm) {
+                        atomic_long_set(&id->owner, 0);
+                        id->pd_gpu_addr = 0;
+                }
 	}
+        mutex_unlock(&adev->vm_manager.lock);
 }
 
 /**
-- 
2.7.4