Skip to content

Commit

Permalink
smp: enable smp_call in all smp arch
Browse files Browse the repository at this point in the history
reason:
In subsequent implementations, we will replace up_cpu_pause with smp_call.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
  • Loading branch information
hujun260 committed Sep 3, 2024
1 parent f084685 commit b86b1c8
Show file tree
Hide file tree
Showing 23 changed files with 346 additions and 32 deletions.
19 changes: 15 additions & 4 deletions arch/arm/src/armv7-a/arm_gicv2.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,8 @@ void arm_gic0_initialize(void)

DEBUGVERIFY(irq_attach(GIC_SMP_CPUSTART, arm_start_handler, NULL));
DEBUGVERIFY(irq_attach(GIC_SMP_CPUPAUSE, arm_pause_handler, NULL));

# ifdef CONFIG_SMP_CALL
DEBUGVERIFY(irq_attach(GIC_SMP_CPUCALL,
nxsched_smp_call_handler, NULL));
# endif
#endif

arm_gic_dump("Exit arm_gic0_initialize", true, 0);
Expand Down Expand Up @@ -672,7 +669,21 @@ int arm_gic_irq_trigger(int irq, bool edge)
return -EINVAL;
}

#ifdef CONFIG_SMP_CALL
#ifdef CONFIG_SMP
/****************************************************************************
* Name: up_send_smp_call
*
* Description:
* Send smp call to target cpu.
*
* Input Parameters:
* cpuset - The set of CPUs to receive the SGI.
*
* Returned Value:
* None.
*
****************************************************************************/

void up_send_smp_call(cpu_set_t cpuset)
{
up_trigger_irq(GIC_SMP_CPUCALL, cpuset);
Expand Down
19 changes: 15 additions & 4 deletions arch/arm/src/armv7-r/arm_gicv2.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,8 @@ void arm_gic0_initialize(void)

DEBUGVERIFY(irq_attach(GIC_SMP_CPUSTART, arm_start_handler, NULL));
DEBUGVERIFY(irq_attach(GIC_SMP_CPUPAUSE, arm_pause_handler, NULL));

# ifdef CONFIG_SMP_CALL
DEBUGVERIFY(irq_attach(GIC_SMP_CPUCALL,
nxsched_smp_call_handler, NULL));
# endif
#endif

arm_gic_dump("Exit arm_gic0_initialize", true, 0);
Expand Down Expand Up @@ -662,7 +659,21 @@ int arm_gic_irq_trigger(int irq, bool edge)
return -EINVAL;
}

# ifdef CONFIG_SMP_CALL
# ifdef CONFIG_SMP
/****************************************************************************
* Name: up_send_smp_call
*
* Description:
* Send smp call to target cpu.
*
* Input Parameters:
* cpuset - The set of CPUs to receive the SGI.
*
* Returned Value:
* None.
*
****************************************************************************/

void up_send_smp_call(cpu_set_t cpuset)
{
up_trigger_irq(GIC_SMP_CPUCALL, cpuset);
Expand Down
19 changes: 15 additions & 4 deletions arch/arm/src/armv8-r/arm_gicv3.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,8 @@ static void gicv3_dist_init(void)
/* Attach SGI interrupt handlers. This attaches the handler to all CPUs. */

DEBUGVERIFY(irq_attach(GIC_SMP_CPUPAUSE, arm64_pause_handler, NULL));

# ifdef CONFIG_SMP_CALL
DEBUGVERIFY(irq_attach(GIC_SMP_CPUCALL,
nxsched_smp_call_handler, NULL));
# endif
#endif
}

Expand Down Expand Up @@ -845,7 +842,21 @@ void arm_gic_secondary_init(void)
arm_gic_init();
}

# ifdef CONFIG_SMP_CALL
# ifdef CONFIG_SMP
/***************************************************************************
* Name: up_send_smp_call
*
* Description:
* Send smp call to target cpu.
*
* Input Parameters:
* cpuset - The set of CPUs to receive the SGI.
*
* Returned Value:
* None.
*
***************************************************************************/

void up_send_smp_call(cpu_set_t cpuset)
{
up_trigger_irq(GIC_SMP_CPUCALL, cpuset);
Expand Down
27 changes: 27 additions & 0 deletions arch/arm/src/cxd56xx/cxd56_cpupause.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ int arm_pause_handler(int irq, void *c, void *arg)
int cpu = up_cpu_index();
int ret = OK;

nxsched_smp_call_handler(irq, c, arg);

DPRINTF("cpu%d will be paused\n", cpu);

/* Clear SW_INT for APP_DSP(cpu) */
Expand Down Expand Up @@ -362,6 +364,31 @@ int arm_pause_handler(int irq, void *c, void *arg)
return ret;
}

/****************************************************************************
* Name: up_send_smp_call
*
* Description:
* Send smp call to target cpu.
*
* Input Parameters:
* cpuset - The set of CPUs to receive the SGI.
*
* Returned Value:
* None.
*
****************************************************************************/

void up_send_smp_call(cpu_set_t cpuset)
{
int cpu;

for (; cpuset != 0; cpuset &= ~(1 << cpu))
{
cpu = ffs(cpuset) - 1;
up_cpu_pause_async(cpu);
}
}

/****************************************************************************
* Name: up_cpu_pause
*
Expand Down
27 changes: 27 additions & 0 deletions arch/arm/src/lc823450/lc823450_cpupause.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ int lc823450_pause_handler(int irq, void *c, void *arg)
{
int cpu = up_cpu_index();

nxsched_smp_call_handler(irq, c, arg);

/* Clear : Pause IRQ */

if (irq == LC823450_IRQ_CTXM3_01)
Expand Down Expand Up @@ -277,6 +279,31 @@ int lc823450_pause_handler(int irq, void *c, void *arg)
return OK;
}

/****************************************************************************
* Name: up_send_smp_call
*
* Description:
* Send smp call to target cpu.
*
* Input Parameters:
* cpuset - The set of CPUs to receive the SGI.
*
* Returned Value:
* None.
*
****************************************************************************/

void up_send_smp_call(cpu_set_t cpuset)
{
int cpu;

for (; cpuset != 0; cpuset &= ~(1 << cpu))
{
cpu = ffs(cpuset) - 1;
up_cpu_pause_async(cpu);
}
}

/****************************************************************************
* Name: up_cpu_pause
*
Expand Down
27 changes: 27 additions & 0 deletions arch/arm/src/rp2040/rp2040_cpupause.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ int arm_pause_handler(int irq, void *c, void *arg)
int irqreq;
uint32_t stat;

nxsched_smp_call_handler(irq, c, arg);

stat = getreg32(RP2040_SIO_FIFO_ST);
if (stat & (RP2040_SIO_FIFO_ST_ROE | RP2040_SIO_FIFO_ST_WOF))
{
Expand Down Expand Up @@ -333,6 +335,31 @@ int arm_pause_handler(int irq, void *c, void *arg)
return OK;
}

/****************************************************************************
* Name: up_send_smp_call
*
* Description:
* Send smp call to target cpu.
*
* Input Parameters:
* cpuset - The set of CPUs to receive the SGI.
*
* Returned Value:
* None.
*
****************************************************************************/

void up_send_smp_call(cpu_set_t cpuset)
{
int cpu;

for (; cpuset != 0; cpuset &= ~(1 << cpu))
{
cpu = ffs(cpuset) - 1;
up_cpu_pause_async(cpu);
}
}

/****************************************************************************
* Name: up_cpu_pause
*
Expand Down
27 changes: 27 additions & 0 deletions arch/arm/src/sam34/sam4cm_cpupause.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ int arm_pause_handler(int irq, void *c, void *arg)
{
int cpu = up_cpu_index();

nxsched_smp_call_handler(irq, c, arg);

/* Clear : Pause IRQ */

/* IPC Interrupt Clear Command Register (write-only) */
Expand Down Expand Up @@ -268,6 +270,31 @@ int arm_pause_handler(int irq, void *c, void *arg)
return OK;
}

/****************************************************************************
* Name: up_send_smp_call
*
* Description:
* Send smp call to target cpu.
*
* Input Parameters:
* cpuset - The set of CPUs to receive the SGI.
*
* Returned Value:
* None.
*
****************************************************************************/

void up_send_smp_call(cpu_set_t cpuset)
{
int cpu;

for (; cpuset != 0; cpuset &= ~(1 << cpu))
{
cpu = ffs(cpuset) - 1;
up_cpu_pause_async(cpu);
}
}

/****************************************************************************
* Name: up_cpu_pause
*
Expand Down
19 changes: 15 additions & 4 deletions arch/arm64/src/common/arm64_gicv2.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,11 +911,8 @@ static void arm_gic0_initialize(void)
/* Attach SGI interrupt handlers. This attaches the handler to all CPUs. */

DEBUGVERIFY(irq_attach(GIC_SMP_CPUPAUSE, arm64_pause_handler, NULL));

# ifdef CONFIG_SMP_CALL
DEBUGVERIFY(irq_attach(GIC_SMP_CPUCALL,
nxsched_smp_call_handler, NULL));
# endif
#endif
}

Expand Down Expand Up @@ -1487,7 +1484,21 @@ int arm64_gic_raise_sgi(unsigned int sgi, uint16_t cpuset)
return 0;
}

# ifdef CONFIG_SMP_CALL
# ifdef CONFIG_SMP
/****************************************************************************
* Name: up_send_smp_call
*
* Description:
* Send smp call to target cpu.
*
* Input Parameters:
* cpuset - The set of CPUs to receive the SGI.
*
* Returned Value:
* None.
*
****************************************************************************/

void up_send_smp_call(cpu_set_t cpuset)
{
up_trigger_irq(GIC_SMP_CPUCALL, cpuset);
Expand Down
20 changes: 15 additions & 5 deletions arch/arm64/src/common/arm64_gicv3.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,11 +656,8 @@ static void gicv3_dist_init(void)
/* Attach SGI interrupt handlers. This attaches the handler to all CPUs. */

DEBUGVERIFY(irq_attach(GIC_SMP_CPUPAUSE, arm64_pause_handler, NULL));

# ifdef CONFIG_SMP_CALL
DEBUGVERIFY(irq_attach(GIC_SMP_CPUCALL,
nxsched_smp_call_handler, NULL));
# endif
#endif
}

Expand Down Expand Up @@ -957,7 +954,6 @@ static void arm64_gic_init(void)

#ifdef CONFIG_SMP
up_enable_irq(GIC_SMP_CPUPAUSE);
# ifdef CONFIG_SMP_CALL
up_enable_irq(GIC_SMP_CPUCALL);
# endif
#endif
Expand Down Expand Up @@ -987,7 +983,21 @@ void arm64_gic_secondary_init(void)
arm64_gic_init();
}

# ifdef CONFIG_SMP_CALL
# ifdef CONFIG_SMP
/***************************************************************************
* Name: up_send_smp_call
*
* Description:
* Send smp call to target cpu.
*
* Input Parameters:
* cpuset - The set of CPUs to receive the SGI.
*
* Returned Value:
* None.
*
***************************************************************************/

void up_send_smp_call(cpu_set_t cpuset)
{
up_trigger_irq(GIC_SMP_CPUCALL, cpuset);
Expand Down
27 changes: 27 additions & 0 deletions arch/risc-v/src/common/riscv_cpupause.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ int riscv_pause_handler(int irq, void *c, void *arg)
{
int cpu = up_cpu_index();

nxsched_smp_call_handler(irq, c, arg);

/* Clear IPI (Inter-Processor-Interrupt) */

riscv_ipi_clear(cpu);
Expand Down Expand Up @@ -259,6 +261,31 @@ int riscv_pause_handler(int irq, void *c, void *arg)
return OK;
}

/****************************************************************************
* Name: up_send_smp_call
*
* Description:
* Send smp call to target cpu.
*
* Input Parameters:
* cpuset - The set of CPUs to receive the SGI.
*
* Returned Value:
* None.
*
****************************************************************************/

void up_send_smp_call(cpu_set_t cpuset)
{
int cpu;

for (; cpuset != 0; cpuset &= ~(1 << cpu))
{
cpu = ffs(cpuset) - 1;
up_cpu_pause_async(cpu);
}
}

/****************************************************************************
* Name: up_cpu_pause
*
Expand Down
1 change: 1 addition & 0 deletions arch/sim/src/sim/posix/sim_hostirq.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ void up_irqinitialize(void)
/* Register the pause handler */

sim_init_ipi(SIGUSR1);
sim_init_func_call_ipi(SIGUSR2);
#endif
}

Expand Down
Loading

0 comments on commit b86b1c8

Please sign in to comment.