arm64/irq: report bug if NR_IPI greater than max SGI during compile time
Subsystems (3)
PATCH 1/1 arm64/irq: report bug if NR_IPI greater than max SGI during compile time
Although there is a runtime WARN_ON() when NR_IPR > max SGI, it had better do the check during built time, and associate these related code together.
To: [email protected]
Cc: [email protected]
--- arch/arm64/kernel/smp.c | 2 ++ drivers/irqchip/irq-gic-v3.c | 2 +- drivers/irqchip/irq-gic.c | 2 +- include/linux/irqchip/arm-gic-common.h | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-)
arch/arm64/kernel/smp.c +2 -0
@@ -33,6 +33,7 @@#include <linux/kernel_stat.h> #include <linux/kexec.h> #include <linux/kvm_host.h> +#include <linux/irqchip/arm-gic-common.h> #include <asm/alternative.h> #include <asm/atomic.h>
@@ -76,6 +77,7 @@ enum ipi_msg_type {IPI_WAKEUP , NR_IPI }; +static_assert (NR_IPI <=MAX_SGI_NUM );static int ipi_irq_base__read_mostly ;static int nr_ipi__read_mostly =NR_IPI ;
drivers/irqchip/irq-gic-v3.c +1 -1
@@ -1162,7 +1162,7 @@ static void __init gic_smp_init(void) gic_starting_cpu, NULL);/* Register all 8 non-secure SGIs */ - base_sgi =__irq_domain_alloc_irqs (gic_data.domain,-1 ,8 , + base_sgi =__irq_domain_alloc_irqs (gic_data.domain,-1 ,MAX_SGI_NUM ,NUMA_NO_NODE , &sgi_fwspec, false,NULL );if (WARN_ON (base_sgi <=0 ))
drivers/irqchip/irq-gic.c +1 -1
@@ -845,7 +845,7 @@ static __init void gic_smp_init(void)"irqchip/arm/gic:starting" , gic_starting_cpu, NULL); - base_sgi =__irq_domain_alloc_irqs (gic_data[0 ].domain,-1 ,8 , + base_sgi =__irq_domain_alloc_irqs (gic_data[0 ].domain,-1 ,MAX_SGI_NUM ,NUMA_NO_NODE , &sgi_fwspec, false,NULL );if (WARN_ON (base_sgi <=0 ))
include/linux/irqchip/arm-gic-common.h +2 -0
@@ -16,6 +16,8 @@ (GICD_INT_DEF_PRI << 8) |\ GICD_INT_DEF_PRI) +#define MAX_SGI_NUM 8 +enum gic_type {GIC_V2 ,GIC_V3 ,
Signature · 1 line
2.7.5
Marc Zyngier
maintainerQuoted 32 lines · Pingfan Liu
Although there is a runtime
WARN_ON()whenNR_IPR> max SGI, it had better do the check during built time, and associate these related code together.Signed-off-by Pingfan Liu <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Jason Cooper <[email protected]>Cc Marc Zyngier <[email protected]>Cc Mark Rutland <[email protected]>To: [email protected]
Cc: [email protected]--- arch/arm64/kernel/smp.c | 2 ++ drivers/irqchip/irq-gic-v3.c | 2 +- drivers/irqchip/irq-gic.c | 2 +- include/linux/irqchip/arm-gic-common.h | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-)arch/arm64/kernel/smp.c +1
-0@@ -33,6 +33,7 @@#include <linux/kernel_stat.h> #include <linux/kexec.h> #include <linux/kvm_host.h> +#include <linux/irqchip/arm-gic-common.h> #include <asm/alternative.h> #include <asm/atomic.h>
arch/arm64/kernel/smp.c enum ipi_msg_type { · line 80
Quoted 4 lines
arch/arm64/kernel/smp.c +1
-0@@ -76,6 +77,7 @@ enum ipi_msg_type {IPI_WAKEUP , NR_IPI }; +static_assert (NR_IPI <=MAX_SGI_NUM );
I am trying *very hard* to remove dependencies between the architecture code and random drivers, so this kind of check really is counter-productive.
Driver code should not have to know the number of IPIs, because there is no requirement that all IPIs should map 1:1 to SGIs. Conflating the two is already wrong, and I really don't want to add more of that.
Thanks,
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
Quoted 45 lines · Marc Zyngier
Quoted 34 lines · Pingfan Liu
Although there is a runtime
WARN_ON()whenNR_IPR> max SGI, it had better
do the check during built time, and associate these related code together.Signed-off-by Pingfan Liu <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Jason Cooper <[email protected]>Cc Marc Zyngier <[email protected]>Cc Mark Rutland <[email protected]>To: [email protected]
Cc: [email protected]--- arch/arm64/kernel/smp.c | 2 ++ drivers/irqchip/irq-gic-v3.c | 2 +- drivers/irqchip/irq-gic.c | 2 +- include/linux/irqchip/arm-gic-common.h | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-)arch/arm64/kernel/smp.c +1
-0@@ -33,6 +33,7 @@#include <linux/kernel_stat.h> #include <linux/kexec.h> #include <linux/kvm_host.h> +#include <linux/irqchip/arm-gic-common.h> #include <asm/alternative.h> #include <asm/atomic.h> arch/arm64/kernel/smp.c enum ipi_msg_type { · line 80
Quoted 4 lines
arch/arm64/kernel/smp.c +1
-0@@ -76,6 +77,7 @@ enum ipi_msg_type {IPI_WAKEUP , NR_IPI }; +static_assert (NR_IPI <=MAX_SGI_NUM );I am trying *very hard* to remove dependencies between the architecture code and random drivers, so this kind of check really is counter-productive.
Quoted 2 lines
Driver code should not have to know the number of IPIs, because there is no requirement that all IPIs should map 1:1 to SGIs. Conflating the two
Just curious about this. Is there an IPI which is not implemented by SGI? Or mapping several IPIs to a single SGI, and scatter out due to a global variable value?
Thanks,
Pingfan
Quoted 7 lines
is already wrong, and I really don't want to add more of that.
Thanks,
M.--
Jazz is not dead. It just smells funny...
Marc Zyngier
maintainerQuoted 46 lines · Pingfan Liu
Quoted 45 lines · Marc Zyngier
Quoted 34 lines · Pingfan Liu
Although there is a runtime
WARN_ON()whenNR_IPR> max SGI, it had better
do the check during built time, and associate these related code together.Signed-off-by Pingfan Liu <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Jason Cooper <[email protected]>Cc Marc Zyngier <[email protected]>Cc Mark Rutland <[email protected]>To: [email protected]
Cc: [email protected]--- arch/arm64/kernel/smp.c | 2 ++ drivers/irqchip/irq-gic-v3.c | 2 +- drivers/irqchip/irq-gic.c | 2 +- include/linux/irqchip/arm-gic-common.h | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-)arch/arm64/kernel/smp.c +1
-0@@ -33,6 +33,7 @@#include <linux/kernel_stat.h> #include <linux/kexec.h> #include <linux/kvm_host.h> +#include <linux/irqchip/arm-gic-common.h> #include <asm/alternative.h> #include <asm/atomic.h> arch/arm64/kernel/smp.c enum ipi_msg_type { · line 80
Quoted 4 lines
arch/arm64/kernel/smp.c +1
-0@@ -76,6 +77,7 @@ enum ipi_msg_type {IPI_WAKEUP , NR_IPI }; +static_assert (NR_IPI <=MAX_SGI_NUM );I am trying *very hard* to remove dependencies between the architecture code and random drivers, so this kind of check really is counter-productive.
Quoted 6 lines
Quoted 2 lines
Driver code should not have to know the number of IPIs, because there is no requirement that all IPIs should map 1:1 to SGIs. Conflating the two
Just curious about this. Is there an IPI which is not implemented by SGI? Or mapping several IPIs to a single SGI, and scatter out due to a global variable value?
We currently have a single NS SGI left, and I'd like to move some of the non-critical IPIs over to dispatching mechanism (the two "CPU stop" IPIs definitely are candidate for merging). That's not implemented yet, but I don't see a need to add checks that would otherwise violate this IPI/SGI distinction.
Thanks,
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
Quoted 58 lines · Marc Zyngier
Quoted 47 lines · Pingfan Liu
Quoted 46 lines · Marc Zyngier
Quoted 34 lines · Pingfan Liu
Although there is a runtime
WARN_ON()whenNR_IPR> max SGI, it had better
do the check during built time, and associate these related code together.Signed-off-by Pingfan Liu <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Jason Cooper <[email protected]>Cc Marc Zyngier <[email protected]>Cc Mark Rutland <[email protected]>To: [email protected]
Cc: [email protected]--- arch/arm64/kernel/smp.c | 2 ++ drivers/irqchip/irq-gic-v3.c | 2 +- drivers/irqchip/irq-gic.c | 2 +- include/linux/irqchip/arm-gic-common.h | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-)arch/arm64/kernel/smp.c +1
-0@@ -33,6 +33,7 @@#include <linux/kernel_stat.h> #include <linux/kexec.h> #include <linux/kvm_host.h> +#include <linux/irqchip/arm-gic-common.h> #include <asm/alternative.h> #include <asm/atomic.h> arch/arm64/kernel/smp.c enum ipi_msg_type { · line 80
Quoted 4 lines
arch/arm64/kernel/smp.c +1
-0@@ -76,6 +77,7 @@ enum ipi_msg_type {IPI_WAKEUP , NR_IPI }; +static_assert (NR_IPI <=MAX_SGI_NUM );I am trying *very hard* to remove dependencies between the architecture
code and random drivers, so this kind of check really is counter-productive.Quoted 8 lines
Quoted 4 lines
Driver code should not have to know the number of IPIs, because there is
no requirement that all IPIs should map 1:1 to SGIs. Conflating the twoJust curious about this. Is there an IPI which is not implemented by SGI? Or mapping several IPIs to a single SGI, and scatter out due to a global variable value?
Quoted 5 lines
We currently have a single NS SGI left, and I'd like to move some of the non-critical IPIs over to dispatching mechanism (the two "CPU stop" IPIs definitely are candidate for merging). That's not implemented yet, but I don't see a need to add checks that would otherwise violate this IPI/SGI distinction.
Got it. Thanks for your detailed explanation.
Regards,
Pingfan