Skip to content

Commit

Permalink
arch/riscv: Remove CONFIG_ARCH_RV_HARTID_BASE offset from riscv_mhartid
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pussuw committed Oct 15, 2024
1 parent 9de0465 commit f171854
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion arch/risc-v/src/common/riscv_cpuindex.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@

int up_cpu_index(void)
{
return (int)riscv_mhartid();
return (int)riscv_mhartid() - CONFIG_ARCH_RV_HARTID_BASE;
}
2 changes: 1 addition & 1 deletion arch/risc-v/src/common/riscv_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions arch/risc-v/src/common/riscv_macros.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion arch/risc-v/src/common/riscv_mhartid.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f171854

Please sign in to comment.