aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1312-drm-amdkfd-Reuse-CHIP_-from-amdgpu.patch
blob: 6d0a361cd07c417a6dd355dfa4bd21738e08ede5 (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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
From ba32b59c7682364c12b898dc2891edfd71e8046a Mon Sep 17 00:00:00 2001
From: Yong Zhao <Yong.Zhao@amd.com>
Date: Fri, 21 Jul 2017 20:47:50 -0400
Subject: [PATCH 1312/4131] drm/amdkfd: Reuse CHIP_* from amdgpu

There are already CHIP_* definitions under amd_shared.h file on amdgpu
side, so KFD should reuse them rather than defining new ones.

Change-Id: I78d8ab5b13f62bb7d64d4713f8a83756ac471c9e
Signed-off-by: Yong Zhao <Yong.Zhao@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c              |  4 ++--
 drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c               |  8 ++++----
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c |  2 ++
 drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c          |  2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c         |  2 ++
 drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c          |  2 ++
 drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c       |  3 ++-
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h                 | 18 ++----------------
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c             |  2 ++
 9 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index c2eda25..99238f1 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -1041,7 +1041,7 @@ kfd_ioctl_create_event(struct file *filp, struct kfd_process *p, void *data)
 			pr_err("Getting device by id failed in %s\n", __func__);
 			return -EFAULT;
 		}
-		if (KFD_IS_DGPU(kfd->device_info->asic_family)) {
+		if (!kfd->device_info->is_need_iommu_device) {
 			down_write(&p->lock);
 			pdd = kfd_bind_process_to_device(kfd, p);
 			if (IS_ERR(pdd)) {
@@ -1175,7 +1175,7 @@ bool kfd_is_large_bar(struct kfd_dev *dev)
 		return true;
 	}
 
-	if (!KFD_IS_DGPU(dev->device_info->asic_family))
+	if (dev->device_info->is_need_iommu_device)
 		return false;
 
 	dev->kfd2kgd->get_local_mem_info(dev->kgd, &mem_info);
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c b/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
index bf390b3..942d863 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
@@ -250,7 +250,7 @@ static void dbgdev_address_watch_set_registers(
 			union TCP_WATCH_ADDR_L_BITS *addrLo,
 			union TCP_WATCH_CNTL_BITS *cntl,
 			unsigned int index, unsigned int vmid,
-			unsigned int asic_family)
+			bool is_apu)
 {
 	union ULARGE_INTEGER addr;
 
@@ -276,7 +276,7 @@ static void dbgdev_address_watch_set_registers(
 	cntl->bitfields.mode = adw_info->watch_mode[index];
 	cntl->bitfields.vmid = (uint32_t) vmid;
 	/*  for APU assume it is an ATC address.  */
-	if (!KFD_IS_DGPU(asic_family))
+	if (is_apu)
 		cntl->u32All |= ADDRESS_WATCH_REG_CNTL_ATC_BIT;
 	pr_debug("\t\t%20s %08x\n", "set reg mask :", cntl->bitfields.mask);
 	pr_debug("\t\t%20s %08x\n", "set reg add high :",
@@ -328,7 +328,7 @@ static int dbgdev_address_watch_nodiq(struct kfd_dbgdev *dbgdev,
 			&cntl,
 			i,
 			vmid,
-			dbgdev->dev->device_info->asic_family
+			dbgdev->dev->device_info->is_need_iommu_device
 			);
 
 		pr_debug("\t\t%30s\n", "* * * * * * * * * * * * * * * * * *");
@@ -425,7 +425,7 @@ static int dbgdev_address_watch_diq(struct kfd_dbgdev *dbgdev,
 				&cntl,
 				i,
 				vmid,
-				dbgdev->dev->device_info->asic_family
+				dbgdev->dev->device_info->is_need_iommu_device
 				);
 
 		pr_debug("\t\t%30s\n", "* * * * * * * * * * * * * * * * * *");
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 e70d122..7b17979 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -1631,6 +1631,8 @@ struct device_queue_manager *device_queue_manager_init(struct kfd_dev *dev)
 	case CHIP_VEGA10:
 		device_queue_manager_init_v9_vega10(&dqm->asic_ops);
 		break;
+	default:
+		BUG();
 	}
 
 	if (dqm->ops.initialize(dqm) != 0) {
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c b/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
index 1fefacd..2e172f6 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
@@ -399,7 +399,7 @@ int kfd_init_apertures(struct kfd_process *process)
 				return -1;
 			}
 
-			if (KFD_IS_DGPU(dev->device_info->asic_family)) {
+			if (!dev->device_info->is_need_iommu_device) {
 				pdd->qpd.cwsr_base = DGPU_VM_BASE_DEFAULT;
 				pdd->qpd.ib_base = DGPU_IB_BASE_DEFAULT;
 			}
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
index fb8c859..6d70d28 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_kernel_queue.c
@@ -347,6 +347,8 @@ struct kernel_queue *kernel_queue_init(struct kfd_dev *dev,
 	case CHIP_VEGA10:
 		kernel_queue_init_v9(&kq->ops_asic_specific);
 		break;
+	default:
+		BUG();
 	}
 
 	if (!kq->ops.initialize(kq, dev, type, KFD_KERNEL_QUEUE_SIZE)) {
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c
index 046282a..3589c0b 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c
@@ -82,6 +82,8 @@ struct mqd_manager *mqd_manager_init(enum KFD_MQD_TYPE type,
 		return mqd_manager_init_vi_tonga(type, dev);
 	case CHIP_VEGA10:
 		return mqd_manager_init_v9(type, dev);
+	default:
+		BUG();
 	}
 
 	return NULL;
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c
index 3949b22..701e8e1 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c
@@ -241,7 +241,8 @@ int pm_init(struct packet_manager *pm, struct device_queue_manager *dqm,
 	case CHIP_VEGA10:
 		kfd_pm_func_init_v9(pm, fw_ver);
 		break;
-
+	default:
+		BUG();
 	}
 
 	return 0;
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
index 76c6fda..e73a651 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
@@ -40,6 +40,7 @@
 #include <kgd_kfd_interface.h>
 
 #include "amd_rdma.h"
+#include "amd_shared.h"
 
 #define KFD_SYSFS_FILE_MODE 0444
 
@@ -170,21 +171,6 @@ enum cache_policy {
 	cache_policy_noncoherent
 };
 
-enum asic_family_type {
-	CHIP_KAVERI = 0,
-	CHIP_HAWAII,
-	CHIP_CARRIZO,
-	CHIP_TONGA,
-	CHIP_FIJI,
-	CHIP_POLARIS10,
-	CHIP_POLARIS11,
-	CHIP_VEGA10
-};
-
-#define KFD_IS_VI(chip) ((chip) >= CHIP_CARRIZO && (chip) <= CHIP_POLARIS11)
-#define KFD_IS_DGPU(chip) (((chip) >= CHIP_TONGA && \
-			   (chip) <= CHIP_VEGA10) || \
-			   (chip) == CHIP_HAWAII)
 #define KFD_IS_SOC15(chip) ((chip) >= CHIP_VEGA10)
 
 struct kfd_event_interrupt_class {
@@ -196,7 +182,7 @@ struct kfd_event_interrupt_class {
 };
 
 struct kfd_device_info {
-	unsigned int asic_family;
+	enum amd_asic_type asic_family;
 	const struct kfd_event_interrupt_class *event_interrupt_class;
 	unsigned int max_pasid_bits;
 	unsigned int max_no_of_hqd;
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
index fc83141..0cfeba2 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
@@ -1329,6 +1329,8 @@ int kfd_topology_add_device(struct kfd_dev *gpu)
 			HSA_CAP_DOORBELL_TYPE_TOTALBITS_SHIFT) &
 			HSA_CAP_DOORBELL_TYPE_TOTALBITS_MASK);
 		break;
+	default:
+		BUG();
 	}
 
 	/* Fix errors in CZ CRAT.
-- 
2.7.4