Skip to content

Commit 73d4b00

Browse files
committed
arch/arm64: add support to config SPI interrupt affinity routing to CPU0 by default
Signed-off-by: chao an <anchao@lixiang.com>
1 parent 1764bad commit 73d4b00

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

arch/arm64/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,13 @@ config ARM64_GICV3_SPI_EDGE
361361
---help---
362362
Configure all SPIs(Shared Peripheral Interrupts) as edge-triggered by default.
363363

364+
config ARM64_GICV3_SPI_ROUTING_CPU0
365+
bool "Configure SPI interrupt affinity routing to CPU0 by default"
366+
default y if SMP
367+
default n
368+
---help---
369+
Configure SPI interrupt affinity routing to CPU0 by default.
370+
364371
endif
365372

366373
config ARM64_SEMIHOSTING_HOSTFS

arch/arm64/src/common/arm64_arch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ void arm64_cpu_enable(void);
506506
#ifdef CONFIG_SMP
507507
uint64_t arm64_get_mpid(int cpu);
508508
#else
509-
# define arm64_get_mpid(cpu) GET_MPIDR()
509+
# define arm64_get_mpid(cpu) (GET_MPIDR() & MPIDR_ID_MASK)
510510
#endif /* CONFIG_SMP */
511511

512512
/****************************************************************************

arch/arm64/src/common/arm64_gicv3.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,12 @@ void arm64_gic_irq_enable(unsigned int intid)
254254
* SPI's affinity, now set it to be the PE on which it is enabled.
255255
*/
256256

257+
#ifndef CONFIG_ARM64_GICV3_SPI_ROUTING_CPU0
257258
if (GIC_IS_SPI(intid))
258259
{
259260
arm64_gic_write_irouter((GET_MPIDR() & MPIDR_ID_MASK), intid);
260261
}
262+
#endif
261263

262264
putreg32(mask, ISENABLER(GET_DIST_BASE(intid), idx));
263265
}
@@ -618,6 +620,17 @@ static void gicv3_dist_init(void)
618620
#endif
619621
}
620622

623+
/* Configure SPI interrupt affinity routing to CPU0 */
624+
625+
#ifdef CONFIG_ARM64_GICV3_SPI_ROUTING_CPU0
626+
uint64_t mpid = arm64_get_mpid(0);
627+
628+
for (intid = GIC_SPI_INT_BASE; intid < num_ints; intid++)
629+
{
630+
putreg64(mpid, IROUTER(base, intid));
631+
}
632+
#endif
633+
621634
/* TODO: Some arrch64 Cortex-A core maybe without security state
622635
* it has different GIC configure with standard arrch64 A or R core
623636
*/

0 commit comments

Comments
 (0)