aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/0139-drm-amdgpu-Remove-VM-based-compute-profile-switching.patch
blob: 56fb1fbf948889c336d4d9e7e2133c993b2a4fb3 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
From eaea45df8acc16b7f74453ece681798bf21328dc Mon Sep 17 00:00:00 2001
From: Felix Kuehling <Felix.Kuehling@amd.com>
Date: Sun, 15 Jul 2018 00:57:02 -0400
Subject: [PATCH 0139/2940] drm/amdgpu: Remove VM-based compute profile
 switching

VM-based compute profile switching was rejected upstream. It was
replaced with queue-based switching and a dedicated kfd2kgd interface.

Change-Id: I7c319bfe2533b29d8e5199dc2fc8fb001bbffdfd
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Kalyan Alle <kalyan.alle@amd.com>

Conflicts:
      drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
      drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 52 +-------------------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h |  5 ---
 2 files changed, 1 insertion(+), 56 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 7630e1fab9bd..11e5cc51fa34 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -2584,24 +2584,6 @@ void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint32_t min_vm_size,
 		 adev->vm_manager.fragment_size);
 }
 
-static void amdgpu_inc_compute_vms(struct amdgpu_device *adev)
-{
-	/* Temporary use only the first VM manager */
-	unsigned int vmhub = 0; /*ring->funcs->vmhub;*/
-	struct amdgpu_vmid_mgr *id_mgr = &adev->vm_manager.id_mgr[vmhub];
-
-	mutex_lock(&id_mgr->lock);
-	if ((adev->vm_manager.n_compute_vms++ == 0) &&
-	    (!amdgpu_sriov_vf(adev))) {
-		/* First Compute VM: enable compute power profile */
-		if (adev->powerplay.pp_funcs &&
-			adev->powerplay.pp_funcs->switch_power_profile)
-			amdgpu_dpm_switch_power_profile(adev,
-					PP_SMC_POWER_PROFILE_COMPUTE, true);
-	}
-	mutex_unlock(&id_mgr->lock);
-}
-
 /**
  * amdgpu_vm_init - initialize a vm instance
  *
@@ -2707,10 +2689,6 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 	INIT_KFIFO(vm->faults);
 	vm->fault_credit = 16;
 
-	vm->vm_context = vm_context;
-	if (vm_context == AMDGPU_VM_CONTEXT_COMPUTE)
-		amdgpu_inc_compute_vms(adev);
-
 	return 0;
 
 error_unreserve:
@@ -2756,13 +2734,7 @@ int amdgpu_vm_make_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 	r = amdgpu_bo_reserve(vm->root.base.bo, true);
 	if (r)
 		return r;
-	if (vm->vm_context == AMDGPU_VM_CONTEXT_COMPUTE) {
-		/* Can happen if ioctl is interrupted by a signal after
-		* this function already completed. Just return success.
-		*/
-		r = 0;
-		goto error;
-	}
+
 	/* Sanity checks */
 	if (!RB_EMPTY_ROOT(&vm->va.rb_root) || vm->root.entries) {
 		r = -EINVAL;
@@ -2781,7 +2753,6 @@ int amdgpu_vm_make_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 	}
 
 	/* Update VM state */
-	vm->vm_context = AMDGPU_VM_CONTEXT_COMPUTE;
 	vm->use_cpu_for_update = !!(adev->vm_manager.vm_update_mode &
 				    AMDGPU_VM_USE_CPU_FOR_COMPUTE);
 	vm->pte_support_ats = pte_support_ats;
@@ -2800,11 +2771,8 @@ int amdgpu_vm_make_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 		vm->pasid = 0;
 	}
 
-
 	/* Free the shadow bo for compute VM */
 	amdgpu_bo_unref(&vm->root.base.bo->shadow);
-	/* Count the new compute VM */
-	amdgpu_inc_compute_vms(adev);
 error:
 	amdgpu_bo_unreserve(vm->root.base.bo);
 	return r;
@@ -2870,23 +2838,6 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 		idr_remove(&adev->vm_manager.pasid_idr, vm->pasid);
 		spin_unlock_irqrestore(&adev->vm_manager.pasid_lock, flags);
 	}
-	if (vm->vm_context == AMDGPU_VM_CONTEXT_COMPUTE) {
-		struct amdgpu_vmid_mgr *id_mgr =
-			&adev->vm_manager.id_mgr[AMDGPU_GFXHUB];
-		mutex_lock(&id_mgr->lock);
-
-		WARN(adev->vm_manager.n_compute_vms == 0, "Unbalanced number of Compute VMs");
-
-		if ((--adev->vm_manager.n_compute_vms == 0) &&
-			(!amdgpu_sriov_vf(adev))) {
-			/* Last KFD VM: enable graphics power profile */
-			if (adev->powerplay.pp_funcs &&
-				adev->powerplay.pp_funcs->switch_power_profile)
-				amdgpu_dpm_switch_power_profile(adev,
-					PP_SMC_POWER_PROFILE_COMPUTE, true);
-		}
-		mutex_unlock(&id_mgr->lock);
-	}
 	drm_sched_entity_destroy(&vm->entity);
 
 	if (!RB_EMPTY_ROOT(&vm->va.rb_root)) {
@@ -2998,7 +2949,6 @@ void amdgpu_vm_manager_init(struct amdgpu_device *adev)
 
 	idr_init(&adev->vm_manager.pasid_idr);
 	spin_lock_init(&adev->vm_manager.pasid_lock);
-	adev->vm_manager.n_compute_vms = 0;
 }
 
 /**
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index a46e84186ba0..ab1d23e4b8ad 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -247,8 +247,6 @@ struct amdgpu_vm {
 
 	/* Some basic info about the task */
 	struct amdgpu_task_info task_info;
-	/* Whether this is a Compute or GFX Context */
-	int			vm_context;
 };
 
 struct amdgpu_vm_manager {
@@ -286,9 +284,6 @@ struct amdgpu_vm_manager {
 	 */
 	struct idr				pasid_idr;
 	spinlock_t				pasid_lock;
-
-	/* Number of Compute VMs, used for detecting Compute activity */
-	unsigned                                n_compute_vms;
 };
 
 #define amdgpu_vm_copy_pte(adev, ib, pe, src, count) ((adev)->vm_manager.vm_pte_funcs->copy_pte((ib), (pe), (src), (count)))
-- 
2.17.1