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 4, 2024
1 parent f084685 commit daae585
Show file tree
Hide file tree
Showing 24 changed files with 513 additions and 57 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
57 changes: 56 additions & 1 deletion 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,59 @@ int arm_pause_handler(int irq, void *c, void *arg)
return ret;
}

/****************************************************************************
* Name: up_cpu_pause_async
*
* Description:
* pause task execution on the CPU
* check whether there are tasks delivered to specified cpu
* and try to run them.
*
* Input Parameters:
* cpu - The index of the CPU to be paused.
*
* Returned Value:
* Zero on success; a negated errno value on failure.
*
* Assumptions:
* Called from within a critical section;
*
****************************************************************************/

inline_function int up_cpu_pause_async(int cpu)
{
/* Generate IRQ for CPU(cpu) */

putreg32(1, CXD56_CPU_P2_INT + (4 * cpu));

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 Expand Up @@ -410,7 +465,7 @@ int up_cpu_pause(int cpu)

/* Generate IRQ for CPU(cpu) */

putreg32(1, CXD56_CPU_P2_INT + (4 * cpu));
up_cpu_pause_async(cpu);

/* Wait for the other CPU to unlock g_cpu_paused meaning that
* it is fully paused and ready for up_cpu_resume();
Expand Down
71 changes: 63 additions & 8 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,66 @@ int lc823450_pause_handler(int irq, void *c, void *arg)
return OK;
}

/****************************************************************************
* Name: up_cpu_pause_async
*
* Description:
* pause task execution on the CPU
* check whether there are tasks delivered to specified cpu
* and try to run them.
*
* Input Parameters:
* cpu - The index of the CPU to be paused.
*
* Returned Value:
* Zero on success; a negated errno value on failure.
*
* Assumptions:
* Called from within a critical section;
*
****************************************************************************/

inline_function int up_cpu_pause_async(int cpu)
{
/* Execute Pause IRQ to CPU(cpu) */

if (cpu == 1)
{
putreg32(IPIREG_INTISR0_1, IPIREG);
}
else
{
putreg32(IPIREG_INTISR1_1, IPIREG);
}

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 Expand Up @@ -325,14 +387,7 @@ int up_cpu_pause(int cpu)

/* Execute Pause IRQ to CPU(cpu) */

if (cpu == 1)
{
putreg32(IPIREG_INTISR0_1, IPIREG);
}
else
{
putreg32(IPIREG_INTISR1_1, IPIREG);
}
up_cpu_pause_async(cpu);

/* Wait for the other CPU to unlock g_cpu_paused meaning that
* it is fully paused and ready for up_cpu_resume();
Expand Down
61 changes: 58 additions & 3 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,61 @@ int arm_pause_handler(int irq, void *c, void *arg)
return OK;
}

/****************************************************************************
* Name: up_cpu_pause_async
*
* Description:
* pause task execution on the CPU
* check whether there are tasks delivered to specified cpu
* and try to run them.
*
* Input Parameters:
* cpu - The index of the CPU to be paused.
*
* Returned Value:
* Zero on success; a negated errno value on failure.
*
* Assumptions:
* Called from within a critical section;
*
****************************************************************************/

inline_function int up_cpu_pause_async(int cpu)
{
/* Generate IRQ for CPU(cpu) */

while (!(getreg32(RP2040_SIO_FIFO_ST) & RP2040_SIO_FIFO_ST_RDY))
;
putreg32(0, RP2040_SIO_FIFO_WR);

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 Expand Up @@ -383,9 +440,7 @@ int up_cpu_pause(int cpu)

/* Generate IRQ for CPU(cpu) */

while (!(getreg32(RP2040_SIO_FIFO_ST) & RP2040_SIO_FIFO_ST_RDY))
;
putreg32(0, RP2040_SIO_FIFO_WR);
up_cpu_pause_async(cpu);

/* Wait for the other CPU to unlock g_cpu_paused meaning that
* it is fully paused and ready for up_cpu_resume();
Expand Down
Loading

0 comments on commit daae585

Please sign in to comment.