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.
This commit is contained in:
Ville Juven 2024-10-15 10:47:11 +03:00 • committed by Xiang Xiao
parent e384a6a625
commit f47c0a1953
4 changed files with 4 additions and 7 deletions

View file

@ -45,5 +45,5 @@
int up_cpu_index(void)
{
return (int)riscv_mhartid();
return (int)riscv_mhartid() - CONFIG_ARCH_RV_HARTID_BASE;
}

View file

@ -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

View file

@ -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

View file

@ -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