arch/irq: Untangle no_irq_type
cover arch/irq: Untangle no_irq_type
Found when reviewing Oleksii's series to enable the RISC-V build.
The way no_irq_type works is horrifying. Make it less-so.
Andrew Cooper (2):
arch/irq: Make irq_ack_none() mandatory
arch/irq: Centralise no_irq_type
xen/arch/arm/include/asm/irq.h | 3 +++ xen/arch/arm/irq.c | 14 ++------------ xen/arch/ppc/stubs.c | 11 ++++------- xen/arch/x86/irq.c | 11 +---------- xen/common/irq.c | 13 +++++++++++++ xen/include/xen/irq.h | 8 +++++++- 6 files changed, 30 insertions(+), 30 deletions(-)
base-commit: 9a905d7dc65883af082532b4dc91ce0131e54047
Signature · 1 line
2.30.2
PATCH 1/2 arch/irq: Make irq_ack_none() mandatory
Any non-stub implementation of these is going to have to do something here.
irq_end_none() is more complicated and has arch-specific interactions with irq_ack_none(), so make it optional.
For PPC, introduce a stub irq_ack_none().
For ARM and x86, export the existing {ack,end}_none() helpers, gaining an irq_ prefix for consisntency with everything else in no_irq_type.
No functional change.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Shawn Anastasio <[email protected]>
--- xen/arch/arm/include/asm/irq.h | 3 +++ xen/arch/arm/irq.c | 8 ++++---- xen/arch/ppc/stubs.c | 6 ++++++ xen/arch/x86/irq.c | 4 ++-- xen/include/xen/irq.h | 6 ++++++ 5 files changed, 21 insertions(+), 6 deletions(-)
xen/arch/arm/include/asm/irq.h +3 -0
@@ -98,6 +98,9 @@ void irq_set_affinity(struct irq_desc *desc, const cpumask_t *mask);*/ bool irq_type_set_by_domain (const struct domain *d); +void irq_end_none (struct irq_desc *irq); +#define irq_end_none irq_end_none +#endif /* _ASM_HW_IRQ_H */ /* * Local variables:
xen/arch/arm/irq.c +4 -4
@@ -31,12 +31,12 @@ struct irq_guestunsigned int virq; }; -static void ack_none (struct irq_desc *irq) +void irq_ack_none (struct irq_desc *irq) {printk ("unexpected IRQ trap at irq %02x\n" , irq->irq); } -static void end_none (struct irq_desc *irq) +void irq_end_none (struct irq_desc *irq) {/* * Still allow a CPU to end an interrupt if we receive a spurious
@@ -51,8 +51,8 @@ hw_irq_controller no_irq_type = { .shutdown = irq_shutdown_none, .enable = irq_enable_none, .disable = irq_disable_none, - .ack = ack_none, - .end = end_none + .ack = irq_ack_none, + .end = irq_end_none };static irq_desc_t irq_desc[NR_IRQS ];
xen/arch/ppc/stubs.c +6 -0
@@ -134,12 +134,18 @@ void pirq_set_affinity(struct domain *d, int pirq, const cpumask_t *mask)BUG_ON ("unimplemented" ); } +void irq_ack_none (struct irq_desc *desc) +{ +BUG_ON ("unimplemented" ); +} +hw_irq_controller no_irq_type = { .typename ="none" , .startup = irq_startup_none, .shutdown = irq_shutdown_none, .enable = irq_enable_none, .disable = irq_disable_none, + .ack = irq_ack_none, };int arch_init_one_irq_desc (struct irq_desc *desc)
xen/arch/x86/irq.c +2 -2
@@ -467,7 +467,7 @@ int __init init_irq_data(void)return 0 ; } -static void cf_check ack_none(struct irq_desc *desc) +void cf_check irq_ack_none(struct irq_desc *desc) {ack_bad_irq (desc->irq); }
@@ -478,7 +478,7 @@ hw_irq_controller no_irq_type = { irq_shutdown_none, irq_enable_none, irq_disable_none, - ack_none, + irq_ack_none, };static vmask_t *irq_get_used_vector_mask (int irq)
xen/include/xen/irq.h +6 -0
@@ -130,6 +130,12 @@ void cf_check irq_actor_none(struct irq_desc *desc);#define irq_disable_none irq_actor_none#define irq_enable_none irq_actor_none +/* +* irq_ack_none() must be provided by the architecture. +* irq_end_none() is optional, and opted into using a define. +*/ +void irq_ack_none (struct irq_desc *irq); +/* * Per-cpu interrupted context register state - the inner-most interrupt frame * on the stack.
Signature · 1 line
2.30.2
Re: [PATCH 1/2] arch/irq: Make irq_ack_none() mandatory
Quoted 9 lines · Andrew Cooper
Any non-stub implementation of these is going to have to do something here.
irq_end_none()is more complicated and has arch-specific interactions withirq_ack_none(), so make it optional.For PPC, introduce a stub
irq_ack_none().
Quoted 7 lines
For ARM and x86, export the existing {ack,end}_none() helpers, gaining an
irq_
prefix for consisntency with everything else inno_irq_type.No functional change.
Signed-off-by Andrew Cooper <[email protected]>
LGTM: Reviewed-by: Oleksii Kurochko <[email protected]>
~ Oleksii
Quoted 129 lines
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Shawn Anastasio <[email protected]>
---
xen/arch/arm/include/asm/irq.h | 3 +++ xen/arch/arm/irq.c | 8 ++++---- xen/arch/ppc/stubs.c | 6 ++++++ xen/arch/x86/irq.c | 4 ++-- xen/include/xen/irq.h | 6 ++++++5 files changed, 21 insertions(+), 6 deletions(-)xen/arch/arm/include/asm/irq.h +0
-0@@ -98,6 +98,9 @@ void irq_set_affinity(struct irq_desc *desc, constcpumask_t *mask); */ bool irq_type_set_by_domain(const struct domain *d);xen/arch/arm/include/asm/irq.h +3
-0+void irq_end_none (struct irq_desc *irq); +#define irq_end_none irq_end_none +#endif /*
_ASM_HW_IRQ_H*/
/*
* Local variables:xen/arch/arm/irq.c +0
-0@@ -31,12 +31,12 @@ struct irq_guest unsigned int virq; };xen/arch/arm/irq.c +1
-1-static void ack_none (struct irq_desc *irq) +void irq_ack_none (struct irq_desc *irq){
printk("unexpected IRQ trap at irq %02x\n", irq->irq); }xen/arch/arm/irq.c +1
-1-static void end_none (struct irq_desc *irq) +void irq_end_none (struct irq_desc *irq){
/*
* Still allow a CPU to end an interrupt if we receive a spuriousxen/arch/arm/irq.c +2
-2@@ -51,8 +51,8 @@ hw_irq_controller no_irq_type = { .shutdown = irq_shutdown_none, .enable = irq_enable_none, .disable = irq_disable_none, - .ack = ack_none, - .end = end_none + .ack = irq_ack_none, + .end = irq_end_none };
staticirq_desc_tirq_desc[NR_IRQS];xen/arch/ppc/stubs.c +0
-0@@ -134,12 +134,18 @@ void pirq_set_affinity(struct domain *d, int pirq, const cpumask_t *mask) BUG_ON("unimplemented"); }xen/arch/ppc/stubs.c +5
-0+void irq_ack_none (struct irq_desc *desc) +{ + BUG_ON("unimplemented"); +} +hw_irq_controller
no_irq_type= { .typename = "none",
.startup =irq_startup_none, .shutdown =irq_shutdown_none, .enable =irq_enable_none,
.disable =irq_disable_none,
+ .ack =irq_ack_none,
};
intarch_init_one_irq_desc(struct irq_desc *desc)xen/arch/x86/irq.c +0
-0@@ -467,7 +467,7 @@ int __init init_irq_data(void) return 0; }xen/arch/x86/irq.c +1
-1-static void cf_check ack_none(struct irq_desc *desc) +void cf_check irq_ack_none(struct irq_desc *desc){
ack_bad_irq(desc->irq);
}xen/arch/x86/irq.c +1
-1@@ -478,7 +478,7 @@ hw_irq_controller no_irq_type = { irq_shutdown_none, irq_enable_none, irq_disable_none, - ack_none, + irq_ack_none, };
staticvmask_t*irq_get_used_vector_mask(int irq)xen/include/xen/irq.h +0
-0@@ -130,6 +130,12 @@ void cf_check irq_actor_none(struct irq_desc *desc); #define irq_disable_none irq_actor_none #define irq_enable_none irq_actor_nonexen/include/xen/irq.h +6
-0+/* +* irq_ack_none() must be provided by the architecture. +* irq_end_none() is optional, and opted into using a define. +*/ +void irq_ack_none (struct irq_desc *irq); +/*
* Per-cpu interrupted context register state - the inner-most interrupt frame
* on the stack.
Re: [PATCH 1/2] arch/irq: Make irq_ack_none() mandatory
In reply to Andrew CooperQuoted 1 line · Andrew Cooper
Any non-stub implementation of these is going to have to do something here.
For whatever definition of "something", seeing ...
xen/arch/arm/irq.c struct irq_guest · line 37
Quoted 11 lines
xen/arch/arm/irq.c +1
-1@@ -31,12 +31,12 @@ struct irq_guestunsigned int virq; }; -static void ack_none (struct irq_desc *irq) +void irq_ack_none (struct irq_desc *irq) {printk ("unexpected IRQ trap at irq %02x\n" , irq->irq); }
... this, which - perhaps apart from the word "trap" - is entirely Arm- independent, and could hence quite well live in a common code fallback implementation. Nevertheless with patch 2 clearly being an improvement, both patches:
Jan
Re: [PATCH 1/2] arch/irq: Make irq_ack_none() mandatory
Quoted 10 lines · Jan Beulich
Quoted 1 line · Andrew Cooper
Any non-stub implementation of these is going to have to do something here.
For whatever definition of "something", seeing ...
Quoted 6 lines
xen/arch/arm/irq.c +0
-0@@ -31,12 +31,12 @@ struct irq_guestunsigned int virq; };
Quoted 8 lines
xen/arch/arm/irq.c struct irq_guest · line 37
Quoted 5 lines
xen/arch/arm/irq.c +1
-1-static void ack_none (struct irq_desc *irq) +void irq_ack_none (struct irq_desc *irq) {printk ("unexpected IRQ trap at irq %02x\n" , irq->irq); }... this, which - perhaps apart from the word "trap" - is entirely Arm- independent, and could hence quite well live in a common code fallback implementation.
Not really.
On ARM, ack()+end() are both mandatory and it's end() which is taking the useful action.
On x86, ack() has the effect and end() is optional (and has a different prototype even!)
Quoted 3 lines
Nevertheless with patch 2 clearly being an improvement,
both patches:Reviewed-by Jan Beulich <[email protected]>
Thanks.
~Andrew
Re: [PATCH 1/2] arch/irq: Make irq_ack_none() mandatory
In reply to Andrew CooperHi,
Quoted 5 lines · Andrew Cooper
Any non-stub implementation of these is going to have to do something here.
irq_end_none()is more complicated and has arch-specific interactions withirq_ack_none(), so make it optional.
Quoted 8 lines
For PPC, introduce a stub
irq_ack_none().For ARM and x86, export the existing {ack,end}_none() helpers, gaining an
irq_prefix for consisntency with everything else inno_irq_type.No functional change.
Signed-off-by Andrew Cooper <[email protected]>
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 1/2] arch/irq: Make irq_ack_none() mandatory
In reply to Andrew CooperHi Andrew,
Quoted 5 lines · Andrew Cooper
Any non-stub implementation of these is going to have to do something here.
irq_end_none()is more complicated and has arch-specific interactions withirq_ack_none(), so make it optional.
Quoted 8 lines
For PPC, introduce a stub
irq_ack_none().For ARM and x86, export the existing {ack,end}_none() helpers, gaining an
irq_prefix for consisntency with everything else inno_irq_type.No functional change.
Signed-off-by Andrew Cooper <[email protected]>
For the PPC parts:
Thanks,
Shawn
PATCH 2/2 arch/irq: Centralise no_irq_type
In reply to Andrew CooperHaving no_irq_type defined per arch, but using common callbacks is a mess, and particualrly hard to bootstrap a new architecture with.
Now that the ack()/end() hooks have been exported suitably, move the definition of no_irq_type into common/irq.c, and into .rodata for good measure.
No functional change, but a whole lot less tangled.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Shawn Anastasio <[email protected]>
Oleksii: For RISC-V, you should only need to provide a irq_ack_none() stub now.
--- xen/arch/arm/irq.c | 10 ---------- xen/arch/ppc/stubs.c | 9 --------- xen/arch/x86/irq.c | 9 --------- xen/common/irq.c | 13 +++++++++++++ xen/include/xen/irq.h | 2 +- 5 files changed, 14 insertions(+), 29 deletions(-)
xen/arch/arm/irq.c +0 -10
@@ -45,16 +45,6 @@ void irq_end_none(struct irq_desc *irq) gic_hw_ops->gic_host_irq_type->end (irq); } -hw_irq_controller no_irq_type = { - .typename ="none" , - .startup = irq_startup_none, - .shutdown = irq_shutdown_none, - .enable = irq_enable_none, - .disable = irq_disable_none, - .ack = irq_ack_none, - .end = irq_end_none -}; -static irq_desc_t irq_desc[NR_IRQS ]; static DEFINE_PER_CPU(irq_desc_t[NR_LOCAL_IRQS], local_irq_desc);
xen/arch/ppc/stubs.c +0 -9
@@ -139,15 +139,6 @@ void irq_ack_none(struct irq_desc *desc)BUG_ON ("unimplemented" ); } -hw_irq_controller no_irq_type = { - .typename ="none" , - .startup = irq_startup_none, - .shutdown = irq_shutdown_none, - .enable = irq_enable_none, - .disable = irq_disable_none, - .ack = irq_ack_none, -}; -int arch_init_one_irq_desc (struct irq_desc *desc) {BUG_ON ("unimplemented" );
xen/arch/x86/irq.c +0 -9
@@ -472,15 +472,6 @@ void cf_check irq_ack_none(struct irq_desc *desc)ack_bad_irq (desc->irq); } -hw_irq_controller no_irq_type = { -"none" , - irq_startup_none, - irq_shutdown_none, - irq_enable_none, - irq_disable_none, - irq_ack_none, -}; -static vmask_t *irq_get_used_vector_mask (int irq) {vmask_t *ret =NULL ;
xen/common/irq.c +13 -0
@@ -3,6 +3,19 @@ DEFINE_PER_CPU(const struct cpu_user_regs *, irq_regs); +const hw_irq_controller no_irq_type = { + .typename ="none" , + .startup = irq_startup_none, + .shutdown = irq_shutdown_none, + .enable = irq_enable_none, + .disable = irq_disable_none, + .ack = irq_ack_none, + +#ifdef irq_end_none /* Hook is optional per arch */ + .end = irq_end_none, +#endif +}; +int init_one_irq_desc (struct irq_desc *desc) {int err;
xen/include/xen/irq.h +1 -1
@@ -122,7 +122,7 @@ extern int request_irq(unsigned int irq, unsigned int irqflags,void (*handler)(int irq,void *dev_id), const char *devname, void *dev_id); -extern hw_irq_controller no_irq_type; +extern const hw_irq_controller no_irq_type; void cf_check no_action(int cpl, void *dev_id); unsigned int cf_check irq_startup_none(struct irq_desc *desc); void cf_check irq_actor_none(struct irq_desc *desc);
Signature · 1 line
2.30.2
Re: [PATCH 2/2] arch/irq: Centralise no_irq_type
Quoted 4 lines · Andrew Cooper
Having
no_irq_typedefined per arch, but using common callbacks is a mess, and
particualrly hard to bootstrap a new architecture with.
Quoted 8 lines
Now that the ack()/end() hooks have been exported suitably, move the definition of
no_irq_typeintocommon/irq.c, and into .rodata for good
measure.No functional change, but a whole lot less tangled.
Signed-off-by Andrew Cooper <[email protected]>
LGTM: Reviewed-by: Oleksii Kurochko <[email protected]>
Quoted 10 lines
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Shawn Anastasio <[email protected]>
Quoted 2 lines
Oleksii: For RISC-V, you should only need to provide a
irq_ack_none()stub now.
Sure, I will update my patch series during rebase.
~ Oleksii
Quoted 108 lines
---
xen/arch/arm/irq.c | 10 ----------
xen/arch/ppc/stubs.c | 9 ---------
xen/arch/x86/irq.c | 9 ---------
xen/common/irq.c | 13 +++++++++++++
xen/include/xen/irq.h | 2 +-5 files changed, 14 insertions(+), 29 deletions(-)xen/arch/arm/irq.c +0
-0@@ -45,16 +45,6 @@ void irq_end_none(struct irq_desc *irq) gic_hw_ops->gic_host_irq_type->end(irq); }xen/arch/arm/irq.c +0
-10-hw_irq_controller no_irq_type = { - .typename = "none", - .startup = irq_startup_none, - .shutdown = irq_shutdown_none, - .enable = irq_enable_none, - .disable = irq_disable_none, - .ack = irq_ack_none, - .end = irq_end_none -}; -static
irq_desc_tirq_desc[NR_IRQS];
staticDEFINE_PER_CPU(irq_desc_t[NR_LOCAL_IRQS], local_irq_desc);xen/arch/ppc/stubs.c +0
-0@@ -139,15 +139,6 @@ void irq_ack_none(struct irq_desc *desc) BUG_ON("unimplemented"); }xen/arch/ppc/stubs.c +0
-9-hw_irq_controller no_irq_type = { - .typename = "none", - .startup = irq_startup_none, - .shutdown = irq_shutdown_none, - .enable = irq_enable_none, - .disable = irq_disable_none, - .ack = irq_ack_none, -}; -int
arch_init_one_irq_desc(struct irq_desc *desc){
BUG_ON("unimplemented");xen/arch/x86/irq.c +0
-0@@ -472,15 +472,6 @@ void cf_check irq_ack_none(struct irq_desc *desc) ack_bad_irq(desc->irq); }xen/arch/x86/irq.c +0
-9-hw_irq_controller no_irq_type = { - "none", - irq_startup_none, - irq_shutdown_none, - irq_enable_none, - irq_disable_none, - irq_ack_none, -}; -static
vmask_t*irq_get_used_vector_mask(int irq) {
vmask_t*ret = NULL;xen/common/irq.c +0
-0@@ -3,6 +3,19 @@
DEFINE_PER_CPU(const structcpu_user_regs*,irq_regs);xen/common/irq.c +13
-0+const hw_irq_controller no_irq_type = { + .typename = "none", + .startup = irq_startup_none, + .shutdown = irq_shutdown_none, + .enable = irq_enable_none, + .disable = irq_disable_none, + .ack = irq_ack_none, + +#ifdef irq_end_none /* Hook is optional per arch */ + .end = irq_end_none, +#endif +}; +int
init_one_irq_desc(struct irq_desc *desc)
{
int err;xen/include/xen/irq.h +0
-0@@ -122,7 +122,7 @@ extern int request_irq(unsigned int irq, unsignedint irqflags, void (*handler)(int irq, void *dev_id), const char *devname, void *dev_id);xen/include/xen/irq.h +1
-1-extern hw_irq_controller no_irq_type; +extern const hw_irq_controller no_irq_type;void
cf_checkno_action(int cpl, void *dev_id); unsigned intcf_checkirq_startup_none(struct irq_desc *desc); voidcf_checkirq_actor_none(struct irq_desc *desc);
Re: [PATCH 2/2] arch/irq: Centralise no_irq_type
In reply to Andrew CooperHi Andrew,
Quoted 10 lines · Andrew Cooper
Having
no_irq_typedefined per arch, but using common callbacks is a mess, and particualrly hard to bootstrap a new architecture with.Now that the ack()/end() hooks have been exported suitably, move the definition of
no_irq_typeintocommon/irq.c, and into .rodata for good measure.No functional change, but a whole lot less tangled.
Signed-off-by Andrew Cooper <[email protected]>
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 2/2] arch/irq: Centralise no_irq_type
In reply to Andrew CooperHi Andrew,
Quoted 10 lines · Andrew Cooper
Having
no_irq_typedefined per arch, but using common callbacks is a mess, and particualrly hard to bootstrap a new architecture with.Now that the ack()/end() hooks have been exported suitably, move the definition of
no_irq_typeintocommon/irq.c, and into .rodata for good measure.No functional change, but a whole lot less tangled.
Signed-off-by Andrew Cooper <[email protected]>
Thanks,
Shawn
Quoted 14 lines · Andrew Cooper
Found when reviewing Oleksii's series to enable the RISC-V build.
The way
no_irq_typeworks is horrifying. Make it less-so.Andrew Cooper (2):
arch/irq: Makeirq_ack_none()mandatory
arch/irq: Centraliseno_irq_typexen/arch/arm/include/asm/irq.h | 3 +++ xen/arch/arm/irq.c | 14 ++------------ xen/arch/ppc/stubs.c | 11 ++++------- xen/arch/x86/irq.c | 11 +---------- xen/common/irq.c | 13 +++++++++++++ xen/include/xen/irq.h | 8 +++++++-
Quoted 4 lines
6 files changed, 30 insertions(+), 30 deletions(-)base-commit:
9a905d7dc65883af082532b4dc91ce0131e54047
I am okay to have it in release if the necessary acks will be recieved.
~ Oleksii