*** Simplify RISC-V IPI code ***
Subsystems (2)
cover *** Simplify RISC-V IPI code ***
RISC-V is different from aarch64. AArch64 has SGI0-15 and use SGI0-7 to send IPIs, so we introduced a feature that we handle inband ipis multiplexed over SGI0. But RISC-V only has one register to inform IPI and the ipi_types are recorded in the PER_CPU variables, which can store sizeof(atomic_t) bits. So we don't need to use the same way to send IPIs. We can simplify the code by unifying the IPI handling code and sending code for oob and inband ipis.
shannmu (1):
riscv: irq_pipeline: simplify the send and handle operation for ipis
arch/riscv/include/asm/irq_pipeline.h | 18 +++-- arch/riscv/kernel/sbi-ipi.c | 10 ++- arch/riscv/kernel/smp.c | 102 ++++++++------------------ drivers/clocksource/timer-clint.c | 8 ++ 4 files changed, 59 insertions(+), 79 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/1 riscv: irq_pipeline: simplify the send and handle operation for ipis
riscv is different from aarch64 and we don't need to encode and decode inband ipis multiplexed over ipi_desc[0], because we can alloc for up to BITS_PER_TYPE(int) ipis. So we could introudce more OOB_XXX ipi_message_types and treat them as inband ipi.
--- arch/riscv/include/asm/irq_pipeline.h | 18 +++-- arch/riscv/kernel/sbi-ipi.c | 10 ++- arch/riscv/kernel/smp.c | 102 ++++++++------------------ drivers/clocksource/timer-clint.c | 8 ++ 4 files changed, 59 insertions(+), 79 deletions(-)
arch/riscv/include/asm/irq_pipeline.h +10 -8
@@ -9,17 +9,19 @@#ifndef _ASM_RISCV_IRQ_PIPELINE_H#define _ASM_RISCV_IRQ_PIPELINE_H -/* -* Multiplex In-band IPI messages over software interrupt 0 -* as we do in the arm implementation. -*/ #define OOB_NR_IPI 3 -#define OOB_IPI_OFFSET 1/* Software interrupt 1 */ -#define TIMER_OOB_IPI (ipi_virq_base + OOB_IPI_OFFSET) -#define RESCHEDULE_OOB_IPI (TIMER_OOB_IPI + 1) -#define CALL_FUNCTION_OOB_IPI (RESCHEDULE_OOB_IPI + 1) +extern int ipi_virq_base; +extern int NR_CALL_FUNCTION_OOB_IPI ; +extern int NR_RESCHEDULE_OOB_IPI ; +extern int NR_TIMER_OOB_IPI ; +extern int ipi_max; + +#define CALL_FUNCTION_OOB_IPI (ipi_virq_base + NR_CALL_FUNCTION_OOB_IPI) +#define RESCHEDULE_OOB_IPI (ipi_virq_base + NR_RESCHEDULE_OOB_IPI) +#define TIMER_OOB_IPI (ipi_virq_base + NR_TIMER_OOB_IPI) +#define PIPELINED_IPI_MAX ipi_max#ifdef CONFIG_IRQ_PIPELINE
arch/riscv/kernel/sbi-ipi.c +9 -1
@@ -12,6 +12,7 @@#include <linux/irqchip/chained_irq.h> #include <linux/irqdomain.h> #include <asm/sbi.h> +#include <asm/irq_pipeline.h> DEFINE_STATIC_KEY_FALSE (riscv_sbi_for_rfence);EXPORT_SYMBOL_GPL (riscv_sbi_for_rfence);
@@ -57,7 +58,11 @@ void __init sbi_ipi_init(void)return ; } +#ifdef CONFIG_IRQ_PIPELINE + virq =ipi_mux_create (PIPELINED_IPI_MAX , sbi_send_ipi); +#else virq =ipi_mux_create (BITS_PER_BYTE , sbi_send_ipi); +#endif if (virq <=0 ) {pr_err ("unable to create muxed IPIs\n" );irq_dispose_mapping (sbi_ipi_virq);
@@ -74,8 +79,11 @@ void __init sbi_ipi_init(void)cpuhp_setup_state (CPUHP_AP_IRQ_RISCV_SBI_IPI_STARTING ,"irqchip/sbi-ipi:starting" , sbi_ipi_starting_cpu,NULL ); - +#ifdef CONFIG_IRQ_PIPELINE +riscv_ipi_set_virq_range (virq,PIPELINED_IPI_MAX ); +#else riscv_ipi_set_virq_range (virq,BITS_PER_BYTE ); +#endif pr_info ("providing IPIs using SBI IPI extension\n" );/*
arch/riscv/kernel/smp.c +32 -70
166 lines not on this page · raw message
drivers/clocksource/timer-clint.c +8 -0
@@ -243,7 +243,11 @@ static int __init clint_timer_init_dt(struct device_node *np) }#ifdef CONFIG_SMP +#ifdef CONFIG_IRQ_PIPELINE + rc =ipi_mux_create (PIPELINED_IPI_MAX , clint_send_ipi); +#else rc =ipi_mux_create (BITS_PER_BYTE , clint_send_ipi); +#endif if (rc <=0 ) {pr_err ("unable to create muxed IPIs\n" ); rc = (rc <0 ) ? rc : -ENODEV ;
@@ -251,7 +255,11 @@ static int __init clint_timer_init_dt(struct device_node *np) }irq_set_chained_handler (clint_ipi_irq, clint_ipi_interrupt); +#ifdef CONFIG_IRQ_PIPELINE +riscv_ipi_set_virq_range (rc,PIPELINED_IPI_MAX ); +#else riscv_ipi_set_virq_range (rc,BITS_PER_BYTE ); +#endif clint_clear_ipi ();#endif
Signature · 1 line
2.34.1
Re: [PATCH] riscv: irq_pipeline: simplify the send and handle operation for ipis
Quoted 59 lines · shannmu
riscv is different from aarch64 and we don't need to encode and decode inband ipis multiplexed over
ipi_desc[0], because we can alloc for up toBITS_PER_TYPE(int)ipis. So we could introudce moreOOB_XXXipi_message_typesand treat them as inband ipi.Signed-off-by shannmu <[email protected]>--- arch/riscv/include/asm/irq_pipeline.h | 18 +++-- arch/riscv/kernel/sbi-ipi.c | 10 ++- arch/riscv/kernel/smp.c | 102 ++++++++------------------ drivers/clocksource/timer-clint.c | 8 ++ 4 files changed, 59 insertions(+), 79 deletions(-)arch/riscv/include/asm/irq_pipeline.h +10
-8@@ -9,17 +9,19 @@#ifndef _ASM_RISCV_IRQ_PIPELINE_H#define _ASM_RISCV_IRQ_PIPELINE_H -/* -* Multiplex In-band IPI messages over software interrupt 0 -* as we do in the arm implementation. -*/ #define OOB_NR_IPI 3 -#define OOB_IPI_OFFSET 1/* Software interrupt 1 */ -#define TIMER_OOB_IPI (ipi_virq_base + OOB_IPI_OFFSET) -#define RESCHEDULE_OOB_IPI (TIMER_OOB_IPI + 1) -#define CALL_FUNCTION_OOB_IPI (RESCHEDULE_OOB_IPI + 1) +extern int ipi_virq_base; +extern int NR_CALL_FUNCTION_OOB_IPI ; +extern int NR_RESCHEDULE_OOB_IPI ; +extern int NR_TIMER_OOB_IPI ; +extern int ipi_max; + +#define CALL_FUNCTION_OOB_IPI (ipi_virq_base + NR_CALL_FUNCTION_OOB_IPI) +#define RESCHEDULE_OOB_IPI (ipi_virq_base + NR_RESCHEDULE_OOB_IPI) +#define TIMER_OOB_IPI (ipi_virq_base + NR_TIMER_OOB_IPI) +#define PIPELINED_IPI_MAX ipi_max#ifdef CONFIG_IRQ_PIPELINE arch/riscv/kernel/sbi-ipi.c +1
-0@@ -12,6 +12,7 @@#include <linux/irqchip/chained_irq.h> #include <linux/irqdomain.h> #include <asm/sbi.h> +#include <asm/irq_pipeline.h> DEFINE_STATIC_KEY_FALSE (riscv_sbi_for_rfence);EXPORT_SYMBOL_GPL (riscv_sbi_for_rfence);
arch/riscv/kernel/sbi-ipi.c void __init sbi_ipi_init(void) · line 65
Quoted 8 lines
arch/riscv/kernel/sbi-ipi.c +4
-0@@ -57,7 +58,11 @@ void __init sbi_ipi_init(void)return ; } +#ifdef CONFIG_IRQ_PIPELINE + virq =ipi_mux_create (PIPELINED_IPI_MAX , sbi_send_ipi); +#else virq =ipi_mux_create (BITS_PER_BYTE , sbi_send_ipi); +#endif
Maybe we rather want
#ifndef CONFIG_IRQ_PIPELINE
#define PIPELINED_IPI_MAX BITS_PER_BYTE
#endif
somewhere.
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
Quoted 8 lines · shannmu
RISC-V is different from aarch64. AArch64 has SGI0-15 and use SGI0-7 to send IPIs, so we introduced a feature that we handle inband ipis multiplexed over SGI0. But RISC-V only has one register to inform IPI and the
ipi_typesare recorded in thePER_CPUvariables,
which can storesizeof(atomic_t)bits. So we don't need to use the same way to send IPIs. We can simplify the code by unifying the IPI handling code and sending code for oob and inband ipis.
Looks good to me. Thanks for this improvement.
Best,
Tobias
Quoted 12 lines
shannmu (1):
riscv:irq_pipeline: simplify the send and handle operation for ipisarch/riscv/include/asm/irq_pipeline.h | 18 +++-- arch/riscv/kernel/sbi-ipi.c | 10 ++- arch/riscv/kernel/smp.c | 102 ++++++++---------------- --
drivers/clocksource/timer-clint.c | 8 ++4 files changed, 59 insertions(+), 79 deletions(-)
Philippe Gerum
AppliedQuoted 10 lines · Tobias
Quoted 8 lines · shannmu
RISC-V is different from aarch64. AArch64 has SGI0-15 and use SGI0-7 to send IPIs, so we introduced a feature that we handle inband ipis multiplexed over SGI0. But RISC-V only has one register to inform IPI and the
ipi_typesare recorded in thePER_CPUvariables,
which can storesizeof(atomic_t)bits. So we don't need to use the same way to send IPIs. We can simplify the code by unifying the IPI handling code and sending code for oob and inband ipis.
Quoted 4 lines
Tested-by Tobias Schaffner <[email protected]>Looks good to me. Thanks for this improvement.
Merged into [1], thanks.
[1] https://source.denx.de/Xenomai/linux-dovetail/-/commits/wip/dovetail-riscv?ref_type=heads
Signature · 1 line
Philippe.