From 24d048be7aae10e101596bd0d0f09a901a6f97f0 Mon Sep 17 00:00:00 2001 From: Justin Hibbits Date: Tue, 20 Jan 2026 23:16:17 -0500 Subject: [PATCH] powerpc/mpc85xx: Set pc_hwref to the primary thread ID On multithreaded cores (e6500) the CPU ID in the device tree (reg[0]) is the primary core, which may not match the cpuid, until Book-E threading is added. --- sys/powerpc/mpc85xx/platform_mpc85xx.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sys/powerpc/mpc85xx/platform_mpc85xx.c b/sys/powerpc/mpc85xx/platform_mpc85xx.c index 6653c40b01a..cc2ad829eb0 100644 --- a/sys/powerpc/mpc85xx/platform_mpc85xx.c +++ b/sys/powerpc/mpc85xx/platform_mpc85xx.c @@ -302,14 +302,26 @@ mpc85xx_smp_first_cpu(platform_t plat, struct cpuref *cpuref) static int mpc85xx_smp_next_cpu(platform_t plat, struct cpuref *cpuref) { + phandle_t node; + pcell_t reg; + int i; if (cpu >= maxcpu) return (ENOENT); cpuref->cr_cpuid = cpu++; - cpuref->cr_hwref = cpuref->cr_cpuid; + + node = OF_finddevice("/cpus"); + for (i = 0, node = OF_child(node); i < cpuref->cr_cpuid; + i++, node = OF_peer(node)) + ; + if (OF_getencprop(node, "reg", ®, sizeof(reg)) > 0) + cpuref->cr_hwref = reg; + else + cpuref->cr_hwref = cpuref->cr_cpuid; if (bootverbose) - printf("powerpc_smp_next_cpu: cpuid %d\n", cpuref->cr_cpuid); + printf("powerpc_smp_next_cpu: cpuid %d, hwref %d\n", + cpuref->cr_cpuid, (int)cpuref->cr_hwref); return (0); }