Skip to contentSkip to conversation

drm/amdkfd: Fix UML build guards for x86_64-only code

PATCH In review Alex Hung 3 participants 3 messages May 14 – May 16

Subsystems (3)
lore
Share & tools
lore

Alex Hung

author
#0 lore raw

PATCH 1/1 drm/amdkfd: Fix UML build guards for x86_64-only code

cpu_data().topo.apicid and kfd_fill_iolink_info_for_cpu() rely on x86-specific structs not present on UML. The kfd_topology.c and kfd_crat.c were guarded by CONFIG_X86_64 alone, causing build failures when CONFIG_DRM_AMDGPU is selected on UML.

Update guards to '#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)' to ensure x86_64-only paths are excluded on UML builds.

Fixes e6b71bcdc409 ("drm/amdgpu: Remove UML build exclusion from Kconfig")
Cc Harry Wentland <[email protected]>
Assisted-by Copilot:Claude-Sonnet-4.6
---
 drivers/gpu/drm/amd/amdkfd/kfd_crat.c     | 6 +++---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +3 -3
index a1087c13f241..cf7b1b038d5f 100644
@@ -1821,7 +1821,7 @@ static int kfd_fill_mem_info_for_cpu(int numa_node_id, int *avail_size,
 	return 0;
 }
 
-#ifdef CONFIG_X86_64
+#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
 static int kfd_fill_iolink_info_for_cpu(int numa_node_id, int *avail_size,
 				uint32_t *num_entries,
 				struct crat_subtype_iolink *sub_type_hdr)
@@ -1880,7 +1880,7 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size)
 	struct crat_subtype_generic *sub_type_hdr;
 	int avail_size = *size;
 	int numa_node_id;
-#ifdef CONFIG_X86_64
+#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
 	uint32_t entries = 0;
 #endif
 	int ret = 0;
@@ -1945,7 +1945,7 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size)
 			sub_type_hdr->length);
 
 		/* Fill in Subtype: IO Link */
-#ifdef CONFIG_X86_64
+#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
 		ret = kfd_fill_iolink_info_for_cpu(numa_node_id, &avail_size,
 				&entries,
 				(struct crat_subtype_iolink *)sub_type_hdr);
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1 -1
index 46db0d65d242..87e13f021457 100644
@@ -2349,7 +2349,7 @@ static int kfd_cpumask_to_apic_id(const struct cpumask *cpumask)
 	first_cpu_of_numa_node = cpumask_first(cpumask);
 	if (first_cpu_of_numa_node >= nr_cpu_ids)
 		return -1;
-#ifdef CONFIG_X86_64
+#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
 	return cpu_data(first_cpu_of_numa_node).topo.apicid;
 #else
 	return first_cpu_of_numa_node;
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Alex Hung

cpu_data().topo.apicid and kfd_fill_iolink_info_for_cpu() rely on x86-specific structs not present on UML. The kfd_topology.c and kfd_crat.c were guarded by CONFIG_X86_64 alone, causing build failures when CONFIG_DRM_AMDGPU is selected on UML.

Update guards to '#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)' to ensure x86_64-only paths are excluded on UML builds.

Quoted 6 lines
Fixes e6b71bcdc409 ("drm/amdgpu: Remove UML build exclusion from Kconfig")
Cc Harry Wentland <[email protected]>
Assisted-by Copilot:Claude-Sonnet-4.6
Quoted 52 lines
---
 drivers/gpu/drm/amd/amdkfd/kfd_crat.c     | 6 +++---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +3 -3
index a1087c13f241..cf7b1b038d5f 100644
@@ -1821,7 +1821,7 @@ static int kfd_fill_mem_info_for_cpu(int numa_node_id, int *avail_size,
        return 0;
 }
 
-#ifdef CONFIG_X86_64
+#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
 static int kfd_fill_iolink_info_for_cpu(int numa_node_id, int *avail_size,
                                uint32_t *num_entries,
                                struct crat_subtype_iolink *sub_type_hdr)
@@ -1880,7 +1880,7 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size)
        struct crat_subtype_generic *sub_type_hdr;
        int avail_size = *size;
        int numa_node_id;
-#ifdef CONFIG_X86_64
+#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
        uint32_t entries = 0;
 #endif
        int ret = 0;
@@ -1945,7 +1945,7 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size)
                        sub_type_hdr->length);
 
                /* Fill in Subtype: IO Link */
-#ifdef CONFIG_X86_64
+#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
                ret = kfd_fill_iolink_info_for_cpu(numa_node_id, &avail_size,
                                &entries,
                                (struct crat_subtype_iolink *)sub_type_hdr);
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1 -2
index 46db0d65d242..87e13f021457 100644
@@ -2349,7 +2349,7 @@ static int kfd_cpumask_to_apic_id(const struct cpumask *cpumask)
        first_cpu_of_numa_node = cpumask_first(cpumask);
        if (first_cpu_of_numa_node >= nr_cpu_ids)
                return -1;
-#ifdef CONFIG_X86_64
+#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
        return cpu_data(first_cpu_of_numa_node).topo.apicid;
 #else
        return first_cpu_of_numa_node;
--

2.43.0

maintainer Reviewed-by
#2 lore raw
Quoted 9 lines · Alex Deucher
Quoted 8 lines · Alex Hung

cpu_data().topo.apicid and kfd_fill_iolink_info_for_cpu() rely on x86-specific structs not present on UML. The kfd_topology.c and kfd_crat.c were guarded by CONFIG_X86_64 alone, causing build failures when CONFIG_DRM_AMDGPU is selected on UML.

Update guards to '#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)' to ensure x86_64-only paths are excluded on UML builds.

Quoted 7 lines
Quoted 6 lines
Fixes e6b71bcdc409 ("drm/amdgpu: Remove UML build exclusion from Kconfig")
Cc Harry Wentland <[email protected]>
Assisted-by Copilot:Claude-Sonnet-4.6
Quoted 53 lines
Quoted 53 lines
---
  drivers/gpu/drm/amd/amdkfd/kfd_crat.c     | 6 +++---
  drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 2 +-
  2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +3 -3
index a1087c13f241..cf7b1b038d5f 100644
@@ -1821,7 +1821,7 @@ static int kfd_fill_mem_info_for_cpu(int numa_node_id, int *avail_size,
         return 0;
  }
 
-#ifdef CONFIG_X86_64
+#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
  static int kfd_fill_iolink_info_for_cpu(int numa_node_id, int *avail_size,
                                 uint32_t *num_entries,
                                 struct crat_subtype_iolink *sub_type_hdr)
@@ -1880,7 +1880,7 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size)
         struct crat_subtype_generic *sub_type_hdr;
         int avail_size = *size;
         int numa_node_id;
-#ifdef CONFIG_X86_64
+#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
         uint32_t entries = 0;
  #endif
         int ret = 0;
@@ -1945,7 +1945,7 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size)
                         sub_type_hdr->length);
 
                 /* Fill in Subtype: IO Link */
-#ifdef CONFIG_X86_64
+#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
                 ret = kfd_fill_iolink_info_for_cpu(numa_node_id, &avail_size,
                                 &entries,
                                 (struct crat_subtype_iolink *)sub_type_hdr);
drivers/gpu/drm/amd/amdkfd/kfd_topology.c +1 -2
index 46db0d65d242..87e13f021457 100644
@@ -2349,7 +2349,7 @@ static int kfd_cpumask_to_apic_id(const struct cpumask *cpumask)
         first_cpu_of_numa_node = cpumask_first(cpumask);
         if (first_cpu_of_numa_node >= nr_cpu_ids)
                 return -1;
-#ifdef CONFIG_X86_64
+#if defined(CONFIG_X86_64) && !defined(CONFIG_UML)
         return cpu_data(first_cpu_of_numa_node).topo.apicid;
  #else
         return first_cpu_of_numa_node;
--

2.43.0