aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1154-drm-amdkfd-Ignore-CPU-Node-if-no-cores-are-online.patch
blob: 8fcbfea1c96d953c42e946e1275741a97131536e (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
From bb73fc952dc74b823531c5f612c8b62fe017bfd5 Mon Sep 17 00:00:00 2001
From: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
Date: Wed, 29 Jun 2016 17:57:10 -0400
Subject: [PATCH 1154/4131] drm/amdkfd: Ignore CPU Node if no cores are online

Change-Id: Ib5a6c3b291fe18faeaada29973fc4d1270486fda
Signed-off-by: Jay Cornwall <jay.cornwall@amd.com>
Signed-off-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_crat.c     | 3 +++
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 8 +++++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
index 2583ab1..e4d7375 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
@@ -822,6 +822,9 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size)
 	sub_type_hdr = (struct crat_subtype_generic *)(crat_table+1);
 
 	for_each_online_node(numa_node_id) {
+		if (kfd_numa_node_to_apic_id(numa_node_id) == -1)
+			continue;
+
 		/* Fill in Subtype: Compute Unit */
 		ret = kfd_fill_cu_for_cpu(numa_node_id, &avail_size,
 			crat_table->num_domains,
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
index 0ffb528..67b9e16 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
@@ -1204,12 +1204,14 @@ int kfd_topology_enum_kfd_devices(uint8_t idx, struct kfd_dev **kdev)
 static int kfd_cpumask_to_apic_id(const struct cpumask *cpumask)
 {
 	const struct cpuinfo_x86 *cpuinfo;
-	int first_cpu_of_nuna_node;
+	int first_cpu_of_numa_node;
 
 	if (cpumask == NULL || cpumask == cpu_none_mask)
 		return -1;
-	first_cpu_of_nuna_node = cpumask_first(cpumask);
-	cpuinfo = &cpu_data(first_cpu_of_nuna_node);
+	first_cpu_of_numa_node = cpumask_first(cpumask);
+	if (first_cpu_of_numa_node >= nr_cpu_ids)
+		return -1;
+	cpuinfo = &cpu_data(first_cpu_of_numa_node);
 
 	return cpuinfo->apicid;
 }
-- 
2.7.4