From f17185483c5108f54c8ebcddf82165625df0b6cc Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Tue, 15 Oct 2024 10:47:11 +0300 Subject: [PATCH] arch/riscv: Remove CONFIG_ARCH_RV_HARTID_BASE offset from riscv_mhartid The function is supposed to return the physical hart ID. It is needed for e.g. external interrupt acknowledgment (see mpfs_plic.c). This offset is moved initially to up_cpu_index (which is also wrong, but less wrong than the current implementation). Finally, a translation between physical <-> logical shall be provided. --- arch/risc-v/src/common/riscv_cpuindex.c | 2 +- arch/risc-v/src/common/riscv_internal.h | 2 +- arch/risc-v/src/common/riscv_macros.S | 5 +---- arch/risc-v/src/common/riscv_mhartid.S | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/arch/risc-v/src/common/riscv_cpuindex.c b/arch/risc-v/src/common/riscv_cpuindex.c index 62bcecd03e595..c5db4151e7dc8 100644 --- a/arch/risc-v/src/common/riscv_cpuindex.c +++ b/arch/risc-v/src/common/riscv_cpuindex.c @@ -45,5 +45,5 @@ int up_cpu_index(void) { - return (int)riscv_mhartid(); + return (int)riscv_mhartid() - CONFIG_ARCH_RV_HARTID_BASE; } diff --git a/arch/risc-v/src/common/riscv_internal.h b/arch/risc-v/src/common/riscv_internal.h index be3fe07ad6c1b..1846bb8708a5e 100644 --- a/arch/risc-v/src/common/riscv_internal.h +++ b/arch/risc-v/src/common/riscv_internal.h @@ -418,7 +418,7 @@ int riscv_smp_call_handler(int irq, void *c, void *arg); * Name: riscv_mhartid * * Description: - * Context aware way to query hart id + * Context aware way to query hart id (physical core ID) * * Returned Value: * Hart id diff --git a/arch/risc-v/src/common/riscv_macros.S b/arch/risc-v/src/common/riscv_macros.S index 03ddfe872d8ed..78068b482ffb8 100644 --- a/arch/risc-v/src/common/riscv_macros.S +++ b/arch/risc-v/src/common/riscv_macros.S @@ -349,7 +349,7 @@ * Name: riscv_mhartid * * Description: - * Context aware way to query hart id + * Context aware way to query hart id (physical core ID) * * Returned Value: * Hart id @@ -362,9 +362,6 @@ REGLOAD \out, RISCV_PERCPU_HARTID(\out) #else csrr \out, CSR_MHARTID -# if CONFIG_ARCH_RV_HARTID_BASE > 0 - add \out, \out, - CONFIG_ARCH_RV_HARTID_BASE -# endif #endif .endm diff --git a/arch/risc-v/src/common/riscv_mhartid.S b/arch/risc-v/src/common/riscv_mhartid.S index 0cfcfc256c785..d58ac689373a8 100644 --- a/arch/risc-v/src/common/riscv_mhartid.S +++ b/arch/risc-v/src/common/riscv_mhartid.S @@ -38,7 +38,7 @@ * Name: riscv_mhartid * * Description: - * Context aware way to query hart id + * Context aware way to query hart id (physical core ID) * * Returned Value: * Hart id