public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdkfd: Fix UML build guards for x86_64-only code
@ 2026-05-14 17:01 Alex Hung
  2026-05-14 17:19 ` Alex Deucher
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alex Hung @ 2026-05-14 17:01 UTC (permalink / raw)
  To: Felix.Kuehling, alexander.deucher, christian.koenig, airlied,
	simona, harry.wentland, amd-gfx, dri-devel
  Cc: alex.hung, kernel test robot

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")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202605140506.TI8zPIBG-lkp@intel.com/
Cc: Harry Wentland <harry.wentland@amd.com>
Assisted-by: Copilot:Claude-Sonnet-4.6
Signed-off-by: Alex Hung <alex.hung@amd.com>
---
 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(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
index a1087c13f241..cf7b1b038d5f 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
@@ -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);
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
index 46db0d65d242..87e13f021457 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
@@ -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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amdkfd: Fix UML build guards for x86_64-only code
  2026-05-14 17:01 [PATCH] drm/amdkfd: Fix UML build guards for x86_64-only code Alex Hung
@ 2026-05-14 17:19 ` Alex Deucher
  2026-05-16  0:39 ` Claude review: " Claude Code Review Bot
  2026-05-16  0:39 ` Claude Code Review Bot
  2 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2026-05-14 17:19 UTC (permalink / raw)
  To: Alex Hung
  Cc: Felix.Kuehling, alexander.deucher, christian.koenig, airlied,
	simona, harry.wentland, amd-gfx, dri-devel, kernel test robot

On Thu, May 14, 2026 at 1:03 PM Alex Hung <alex.hung@amd.com> wrote:
>
> 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")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202605140506.TI8zPIBG-lkp@intel.com/
> Cc: Harry Wentland <harry.wentland@amd.com>
> Assisted-by: Copilot:Claude-Sonnet-4.6
> Signed-off-by: Alex Hung <alex.hung@amd.com>

Acked-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  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(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
> index a1087c13f241..cf7b1b038d5f 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
> @@ -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);
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> index 46db0d65d242..87e13f021457 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Claude review: drm/amdkfd: Fix UML build guards for x86_64-only code
  2026-05-14 17:01 [PATCH] drm/amdkfd: Fix UML build guards for x86_64-only code Alex Hung
  2026-05-14 17:19 ` Alex Deucher
@ 2026-05-16  0:39 ` Claude Code Review Bot
  2026-05-16  0:39 ` Claude Code Review Bot
  2 siblings, 0 replies; 4+ messages in thread
From: Claude Code Review Bot @ 2026-05-16  0:39 UTC (permalink / raw)
  To: dri-devel-reviews

Overall Series Review

Subject: drm/amdkfd: Fix UML build guards for x86_64-only code
Author: Alex Hung <alex.hung@amd.com>
Patches: 2
Reviewed: 2026-05-16T10:39:53.035340

---

This is a single patch fixing a UML build failure in `amdkfd` by adding `!defined(CONFIG_UML)` guards alongside existing `CONFIG_X86_64` guards. The problem is that UML defines `CONFIG_X86_64` (inheriting the host architecture) but does not provide x86-specific CPU data structures like `cpu_data()` and `cpuinfo_x86`.

The patch is a straightforward and correct fix. All four `CONFIG_X86_64` guard sites that use x86-specific APIs are updated, and the existing `#else` fallback paths handle the non-x86 case appropriately (returning a default value or printing a diagnostic). No x86-specific code sites appear to be missed.

One notable observation: the current drm-next tree still has `depends on !UML` in `drivers/gpu/drm/amd/amdgpu/Kconfig:6`, which would prevent this build failure from occurring. This patch is a companion fix for `e6b71bcdc409 ("drm/amdgpu: Remove UML build exclusion from Kconfig")` — it only becomes necessary once that commit lands. The ordering dependency should be confirmed so the build doesn't break in an intermediate bisection state.

**Verdict: Patch looks correct.** Minor comments below.

---

---
Generated by Claude Code Patch Reviewer

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Claude review: drm/amdkfd: Fix UML build guards for x86_64-only code
  2026-05-14 17:01 [PATCH] drm/amdkfd: Fix UML build guards for x86_64-only code Alex Hung
  2026-05-14 17:19 ` Alex Deucher
  2026-05-16  0:39 ` Claude review: " Claude Code Review Bot
@ 2026-05-16  0:39 ` Claude Code Review Bot
  2 siblings, 0 replies; 4+ messages in thread
From: Claude Code Review Bot @ 2026-05-16  0:39 UTC (permalink / raw)
  To: dri-devel-reviews

Patch Review

**Correctness: Good.** All four sites are correctly identified:

1. **kfd_crat.c — `kfd_fill_iolink_info_for_cpu()` function definition** (line 1824): This function uses `struct cpuinfo_x86 *c = &cpu_data(0)` and checks `c->x86_vendor` — genuinely x86-only. Guarding it from UML is correct. The existing `#else` at the call site (around line 1948) prints `"IO link not available for non x86 platforms\n"`, which is the appropriate fallback.

2. **kfd_crat.c — `entries` variable** (line 1883): Only used when `kfd_fill_iolink_info_for_cpu()` is called. Guard matches correctly.

3. **kfd_crat.c — call to `kfd_fill_iolink_info_for_cpu()`** (line 1948): Guard matches the function definition.

4. **kfd_topology.c — `kfd_cpumask_to_apic_id()` return** (line 2352): Uses `cpu_data(first_cpu_of_numa_node).topo.apicid`. The `#else` returns `first_cpu_of_numa_node` as a fallback, which is reasonable.

**Minor comments:**

- **`Assisted-by: Copilot:Claude-Sonnet-4.6`** — This is not a recognized kernel trailer tag. The kernel community has discussed AI attribution but hasn't standardized a tag. The maintainer may want to drop it or use a form that's been accepted in prior merges. This is a process/policy question, not a code correctness issue.

- **Fragility consideration:** Sprinkling `!defined(CONFIG_UML)` across individual source files is somewhat fragile — future x86-specific code additions would need to remember the UML exclusion. An alternative approach would be to gate `HSA_AMD` itself on `!UML` in `drivers/gpu/drm/amd/amdkfd/Kconfig` (which already has `depends on ... X86_64 ...`), changing it to `(X86_64 && !UML)`. That would be a single-line Kconfig change that protects all KFD code at once and is harder to accidentally regress. However, this is a design tradeoff — if KFD is *intended* to partially work on UML (e.g., for unit testing paths that don't touch hardware), the per-site approach in this patch is the right one.

- **Ordering with the Fixes commit:** As noted above, the current tree still has `depends on !UML` in the AMDGPU Kconfig. If this patch lands before or without `e6b71bcdc409`, it's a no-op (harmless but unnecessary). If `e6b71bcdc409` lands first without this patch, the build breaks on UML. The two should be merged together or this patch should be applied on top of the Fixes commit.

**Code diff looks clean** — no functional changes beyond the guard update, no whitespace issues, context lines match expectations.

---
Generated by Claude Code Patch Reviewer

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-05-16  0:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-14 17:01 [PATCH] drm/amdkfd: Fix UML build guards for x86_64-only code Alex Hung
2026-05-14 17:19 ` Alex Deucher
2026-05-16  0:39 ` Claude review: " Claude Code Review Bot
2026-05-16  0:39 ` Claude Code Review Bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox