aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1214-drm-amdkfd-Reject-devices-without-host-atomic-suppor.patch
blob: 6fb4cc9cb9ec73a27a3d92e1b7d1164f1ec4571c (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
From 0b685485cffa7afeed6c51de923c7649cc6bb72e 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 1214/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/amdkfd/kfd_device.c | 18 ++++++++++++++++++
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h   |  1 +
 2 files changed, 19 insertions(+)

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 207b5bc..de34698 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