aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/3051-drm-amdkfd-Simplify-tlb-invalidation-for-non-HWS-cas.patch
blob: 87f53c65dae0b23fccd420361ee37ba02bb28c8d (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
From 8c398abee7bbece2a44d3c1a45ac3f3eb3c5e3b3 Mon Sep 17 00:00:00 2001
From: Yong Zhao <yong.zhao@amd.com>
Date: Tue, 2 Jan 2018 14:55:08 -0500
Subject: [PATCH 3051/4131] drm/amdkfd: Simplify tlb invalidation for non-HWS
 case

For non-HWS case, we can not use KIQ to invalidate tlbs. Because we
already know the vmid that is associated with pasid on each device,
we do not need to get VMID through querying pasid.

Change-Id: I02fc13b0703dfc099a20f372adbf06152d967189
Signed-off-by: Yong Zhao <yong.zhao@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c              |  6 +++---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c |  6 +++---
 drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c          |  7 -------
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h                 |  3 ++-
 drivers/gpu/drm/amd/amdkfd/kfd_process.c              | 17 +++++++++++++++++
 5 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index aba0291..afc4ce2 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -1374,10 +1374,10 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep,
 			peer = kfd_device_by_id(devices_arr[i]);
 			if (WARN_ON_ONCE(!peer))
 				continue;
-			kfd_flush_tlb(peer, p->pasid);
+			kfd_flush_tlb(peer, p);
 		}
 	} else {
-		kfd_flush_tlb(dev, p->pasid);
+		kfd_flush_tlb(dev, p);
 	}
 
 	if (args->device_ids_array_size > 0 && devices_arr)
@@ -1408,7 +1408,7 @@ int kfd_unmap_memory_from_gpu(void *mem, struct kfd_process_device *pdd)
 	if (err != 0)
 		return err;
 
-	kfd_flush_tlb(dev, pdd->process->pasid);
+	kfd_flush_tlb(dev, pdd->process);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index 0b1454c..a628a0d 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -198,7 +198,7 @@ static int allocate_vmid(struct device_queue_manager *dqm,
 			qpd->vmid,
 			qpd->page_table_base);
 	/*invalidate the VM context after pasid and vmid mapping is set up*/
-	kfd_flush_tlb(dqm->dev, qpd->pqm->process->pasid);
+	kfd_flush_tlb(dqm->dev, qpd->pqm->process);
 
 	return 0;
 }
@@ -229,7 +229,7 @@ static void deallocate_vmid(struct device_queue_manager *dqm,
 		if (flush_texture_cache_nocpsch(q->device, qpd))
 			pr_err("Failed to flush TC\n");
 
-	kfd_flush_tlb(dqm->dev, qpd->pqm->process->pasid);
+	kfd_flush_tlb(dqm->dev, qpd->pqm->process);
 
 	/* Release the vmid mapping */
 	set_pasid_vmid_mapping(dqm, 0, qpd->vmid);
@@ -661,7 +661,7 @@ int process_restore_queues(struct device_queue_manager *dqm,
 				qpd->vmid,
 				qpd->page_table_base);
 
-		kfd_flush_tlb(dqm->dev, pdd->process->pasid);
+		kfd_flush_tlb(dqm->dev, pdd->process);
 	}
 
 	/* activate all active queues on the qpd */
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c b/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
index be2d072..499efa1 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
@@ -416,10 +416,3 @@ int kfd_init_apertures(struct kfd_process *process)
 
 	return 0;
 }
-
-void kfd_flush_tlb(struct kfd_dev *dev, uint32_t pasid)
-{
-	const struct kfd2kgd_calls *f2g = dev->kfd2kgd;
-
-	f2g->invalidate_tlbs(dev->kgd, pasid);
-}
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
index 5914f93..6b2e1e6 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
@@ -556,6 +556,7 @@ struct qcm_process_device {
 	struct list_head priv_queue_list;
 
 	unsigned int queue_count;
+	/* a data field only meaningful for non-HWS case */
 	unsigned int vmid;
 	bool is_debug;
 	unsigned int evicted; /* eviction counter, 0=active */
@@ -1080,7 +1081,7 @@ int kfd_event_destroy(struct kfd_process *p, uint32_t event_id);
 void kfd_signal_vm_fault_event(struct kfd_dev *dev, unsigned int pasid,
 				struct kfd_vm_fault_info *info);
 
-void kfd_flush_tlb(struct kfd_dev *dev, uint32_t pasid);
+void kfd_flush_tlb(struct kfd_dev *dev, struct kfd_process *p);
 
 int dbgdev_wave_reset_wavefronts(struct kfd_dev *dev, struct kfd_process *p);
 
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index e178dda..3d663d31 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
@@ -1171,3 +1171,20 @@ int kfd_debugfs_mqds_by_process(struct seq_file *m, void *data)
 }
 
 #endif
+
+void kfd_flush_tlb(struct kfd_dev *dev, struct kfd_process *p)
+{
+	const struct kfd2kgd_calls *f2g = dev->kfd2kgd;
+
+	if (dev->dqm->sched_policy == KFD_SCHED_POLICY_NO_HWS) {
+		struct kfd_process_device *pdd =
+				kfd_get_process_device_data(dev, p);
+		if (!pdd) {
+			pr_err("could not find pdd for pasid %d\n", p->pasid);
+			return;
+		}
+
+		f2g->invalidate_tlbs_vmid(dev->kgd, pdd->qpd.vmid);
+	} else
+		f2g->invalidate_tlbs(dev->kgd, p->pasid);
+}
-- 
2.7.4