riscv_cpuindex.c: Fix usage of CONFIG_ARCH_RV_HARTID_BASE

The offset was supposed to assume hartid > cpuid, so when converting from
hartid we must subtract the offset to get the cpuid and vice versa.
This commit is contained in:
Ville Juven
2024-10-17 13:04:02 +03:00
committed by Xiang Xiao
parent 66e0e1bb7f
commit 25b33f202e
+2 -2
View File
@@ -73,7 +73,7 @@ int up_this_cpu(void)
int weak_function riscv_hartid_to_cpuid(int cpu)
{
return cpu + CONFIG_ARCH_RV_HARTID_BASE;
return cpu - CONFIG_ARCH_RV_HARTID_BASE;
}
/****************************************************************************
@@ -87,5 +87,5 @@ int weak_function riscv_hartid_to_cpuid(int cpu)
int weak_function riscv_cpuid_to_hartid(int cpu)
{
return cpu - CONFIG_ARCH_RV_HARTID_BASE;
return cpu + CONFIG_ARCH_RV_HARTID_BASE;
}