aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1566-drm-amdkfd-Reject-devices-without-host-atomic-suppor.patch
blob: 49e7f11736ba6bb54da4e84980e11e8a0168e0de (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
From 4a7f84e2f79ee37d0d72b6705d57de5e09e31499 Mon Sep 17 00:00:00 2001
From: Jay Cornwall <Jay.Cornwall@amd.com>
Date: Thu, 1 Dec 2016 19:39:17 -0600
Subject: [PATCH 1566/4131] drm/amdkfd: Reject devices without host atomic
 support

HSA requires atomic operations from device to host for all ASICs from
Gfx8 onwards. APUs implicitly support this through ATS. Discrete GPUs
require PCI support to route atomics to the host bridge and complete
them.

Do not bind to PCI devices which cannot route atomics to the host.

Change-Id: Ieea113713229a81296a8f2565762b422eaf7122c
Signed-off-by: Jay Cornwall <Jay.Cornwall@amd.com>

 Conflicts:
	drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
---
 drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c   |  4 ----
 drivers/gpu/drm/amd/amdkfd/kfd_device.c | 18 ++++++++++++++++++
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h   |  1 +
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
index b0d094a..4e5003c 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
@@ -1160,10 +1160,6 @@ static int gmc_v8_0_sw_init(void *handle)
 		return -ENOMEM;
 	atomic_set(&adev->mc.vm_fault_info_updated, 0);
 
-	/* Allow BIF to recode atomics to PCIe 3.0 AtomicOps.
-	 */
-	pci_enable_atomic_ops_to_root(adev->pdev);
-
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
index e426663..5aae159 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
@@ -44,6 +44,7 @@ static const struct kfd_device_info kaveri_device_info = {
 	.mqd_size_aligned = MQD_SIZE_ALIGNED,
 	.is_need_iommu_device = true,
 	.supports_cwsr = false,
+	.needs_pci_atomics = false,
 };
 
 static const struct kfd_device_info hawaii_device_info = {
@@ -57,6 +58,7 @@ static const struct kfd_device_info hawaii_device_info = {
 	.mqd_size_aligned = MQD_SIZE_ALIGNED,
 	.is_need_iommu_device = false,
 	.supports_cwsr = false,
+	.needs_pci_atomics = false,
 };
 
 static const struct kfd_device_info carrizo_device_info = {
@@ -70,6 +72,7 @@ static const struct kfd_device_info carrizo_device_info = {
 	.mqd_size_aligned = MQD_SIZE_ALIGNED,
 	.is_need_iommu_device = true,
 	.supports_cwsr = true,
+	.needs_pci_atomics = false,
 };
 
 static const struct kfd_device_info tonga_device_info = {
@@ -82,6 +85,7 @@ static const struct kfd_device_info tonga_device_info = {
 	.mqd_size_aligned = MQD_SIZE_ALIGNED,
 	.is_need_iommu_device = false,
 	.supports_cwsr = false,
+	.needs_pci_atomics = true,
 };
 
 static const struct kfd_device_info fiji_device_info = {
@@ -94,6 +98,7 @@ static const struct kfd_device_info fiji_device_info = {
 	.mqd_size_aligned = MQD_SIZE_ALIGNED,
 	.is_need_iommu_device = false,
 	.supports_cwsr = true,
+	.needs_pci_atomics = true,
 };
 
 static const struct kfd_device_info polaris10_device_info = {
@@ -106,6 +111,7 @@ static const struct kfd_device_info polaris10_device_info = {
 	.mqd_size_aligned = MQD_SIZE_ALIGNED,
 	.is_need_iommu_device = false,
 	.supports_cwsr = true,
+	.needs_pci_atomics = true,
 };
 
 static const struct kfd_device_info polaris11_device_info = {
@@ -118,6 +124,7 @@ static const struct kfd_device_info polaris11_device_info = {
 	.mqd_size_aligned = MQD_SIZE_ALIGNED,
 	.is_need_iommu_device = false,
 	.supports_cwsr = true,
+	.needs_pci_atomics = true,
 };
 
 struct kfd_deviceid {
@@ -226,6 +233,17 @@ struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd,
 	if (!device_info)
 		return NULL;
 
+	if (device_info->needs_pci_atomics) {
+		/* Allow BIF to recode atomics to PCIe 3.0 AtomicOps.
+		 */
+		if (pci_enable_atomic_ops_to_root(pdev) < 0) {
+			dev_info(kfd_device,
+				"skipped device (%x:%x), PCI rejects atomics",
+				 pdev->vendor, pdev->device);
+			return NULL;
+		}
+	}
+
 	BUG_ON(!f2g);
 
 	kfd = kzalloc(sizeof(*kfd), GFP_KERNEL);
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
index 40dd5db..30bc546 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
@@ -190,6 +190,7 @@ struct kfd_device_info {
 	uint16_t mqd_size_aligned;
 	bool is_need_iommu_device;
 	bool supports_cwsr;
+	bool needs_pci_atomics;
 };
 
 struct kfd_mem_obj {
-- 
2.7.4