Skip to content

Commit f47c0a1

Browse files
pussuwxiaoxiang781216
authored andcommitted
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.
1 parent e384a6a commit f47c0a1

File tree

4 files changed

+4
-7
lines changed

4 files changed

+4
-7
lines changed

arch/risc-v/src/common/riscv_cpuindex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@
4545

4646
int up_cpu_index(void)
4747
{
48-
return (int)riscv_mhartid();
48+
return (int)riscv_mhartid() - CONFIG_ARCH_RV_HARTID_BASE;
4949
}

arch/risc-v/src/common/riscv_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ int riscv_smp_call_handler(int irq, void *c, void *arg);
418418
* Name: riscv_mhartid
419419
*
420420
* Description:
421-
* Context aware way to query hart id
421+
* Context aware way to query hart id (physical core ID)
422422
*
423423
* Returned Value:
424424
* Hart id

arch/risc-v/src/common/riscv_macros.S

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@
349349
* Name: riscv_mhartid
350350
*
351351
* Description:
352-
* Context aware way to query hart id
352+
* Context aware way to query hart id (physical core ID)
353353
*
354354
* Returned Value:
355355
* Hart id
@@ -362,9 +362,6 @@
362362
REGLOAD \out, RISCV_PERCPU_HARTID(\out)
363363
#else
364364
csrr \out, CSR_MHARTID
365-
# if CONFIG_ARCH_RV_HARTID_BASE > 0
366-
add \out, \out, - CONFIG_ARCH_RV_HARTID_BASE
367-
# endif
368365
#endif
369366
.endm
370367

arch/risc-v/src/common/riscv_mhartid.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* Name: riscv_mhartid
3939
*
4040
* Description:
41-
* Context aware way to query hart id
41+
* Context aware way to query hart id (physical core ID)
4242
*
4343
* Returned Value:
4444
* Hart id

0 commit comments

Comments
 (0)