Skip to content

Commit b28f87e

Browse files
anchaoxiaoxiang781216
authored andcommitted
arm/gicv3: replace this_cpu() to up_cpu_index()
If the core id needs to be included in the hardware register calculation, up_cpu_index() should be used instead of this_cpu(). Signed-off-by: chao an <[email protected]>
1 parent 9c97f7a commit b28f87e

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

arch/arm/src/armv8-r/arm_gicv3.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ void arm_gic_irq_enable(unsigned int intid)
250250

251251
if (GIC_IS_SPI(intid))
252252
{
253-
arm_gic_write_irouter(this_cpu(), intid);
253+
arm_gic_write_irouter(up_cpu_index(), intid);
254254
}
255255

256256
putreg32(mask, ISENABLER(GET_DIST_BASE(intid), idx));
@@ -809,7 +809,8 @@ static void arm_gic_init(void)
809809
int err;
810810

811811
cpu = this_cpu();
812-
g_gic_rdists[cpu] = CONFIG_GICR_BASE + cpu * CONFIG_GICR_OFFSET;
812+
g_gic_rdists[cpu] = CONFIG_GICR_BASE +
813+
up_cpu_index() * CONFIG_GICR_OFFSET;
813814

814815
err = gic_validate_redist_version();
815816
if (err)

arch/arm64/include/irq.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,10 @@ static inline void up_irq_restore(irqstate_t flags)
383383
****************************************************************************/
384384

385385
#ifdef CONFIG_ARCH_HAVE_MULTICPU
386+
# ifndef MPID_TO_CORE
387+
# define MPID_TO_CORE(mpid) \
388+
(((mpid) >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK)
389+
# endif
386390
# define up_cpu_index() ((int)MPID_TO_CORE(GET_MPIDR()))
387391
#endif /* CONFIG_ARCH_HAVE_MULTICPU */
388392

arch/arm64/src/common/arm64_gicv3.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ void arm64_gic_irq_enable(unsigned int intid)
257257
#ifndef CONFIG_ARM64_GICV3_SPI_ROUTING_CPU0
258258
if (GIC_IS_SPI(intid))
259259
{
260-
arm64_gic_write_irouter((GET_MPIDR() & MPIDR_ID_MASK), intid);
260+
arm64_gic_write_irouter(up_cpu_index(), intid);
261261
}
262262
#endif
263263

@@ -952,7 +952,8 @@ static void arm64_gic_init(void)
952952
int err;
953953

954954
cpu = this_cpu();
955-
g_gic_rdists[cpu] = CONFIG_GICR_BASE + cpu * CONFIG_GICR_OFFSET;
955+
g_gic_rdists[cpu] = CONFIG_GICR_BASE +
956+
up_cpu_index() * CONFIG_GICR_OFFSET;
956957

957958
err = gic_validate_redist_version();
958959
if (err)

0 commit comments

Comments
 (0)