Message ID | 20211021180236.37428-5-mark.rutland@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | irq: remove handle_domain_{irq,nmi}() | expand |
On Thu, 21 Oct 2021 19:02:25 +0100, Mark Rutland <mark.rutland@arm.com> wrote: > > There's no need for handle_domain_{irq,nmi}() to open-code the NULL > check performed by handle_irq_desc(), nor the resolution of the desc > performed by generic_handle_domain_irq(). > > Use generic_handle_domain_irq() directly, as this is functioanlly > equivalent and clearer. At the same time, delete the stale comments, > which are no longer helpful. > > There should be no functional change as a result of this patch. > > Signed-off-by: Mark Rutland <mark.rutland@arm.com> > Cc: Marc Zyngier <maz@kernel.org> > Cc: Thomas Gleixner <tglx@linutronix.de> > --- > kernel/irq/irqdesc.c | 24 ++++-------------------- > 1 file changed, 4 insertions(+), 20 deletions(-) > > diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c > index 4e3c29bb603c..b07d0e1552bc 100644 > --- a/kernel/irq/irqdesc.c > +++ b/kernel/irq/irqdesc.c > @@ -690,17 +690,11 @@ int handle_domain_irq(struct irq_domain *domain, > unsigned int hwirq, struct pt_regs *regs) > { > struct pt_regs *old_regs = set_irq_regs(regs); > - struct irq_desc *desc; > - int ret = 0; > + int ret; > > irq_enter(); > > - /* The irqdomain code provides boundary checks */ > - desc = irq_resolve_mapping(domain, hwirq); > - if (likely(desc)) > - handle_irq_desc(desc); > - else > - ret = -EINVAL; > + ret = generic_handle_domain_irq(domain, hwirq); > > irq_exit(); > set_irq_regs(old_regs); > @@ -721,24 +715,14 @@ int handle_domain_nmi(struct irq_domain *domain, unsigned int hwirq, > struct pt_regs *regs) > { > struct pt_regs *old_regs = set_irq_regs(regs); > - struct irq_desc *desc; > - int ret = 0; > + int ret; > > /* > * NMI context needs to be setup earlier in order to deal with tracing. > */ > WARN_ON(!in_nmi()); > > - desc = irq_resolve_mapping(domain, hwirq); > - > - /* > - * ack_bad_irq is not NMI-safe, just report > - * an invalid interrupt. > - */ > - if (likely(desc)) > - handle_irq_desc(desc); > - else > - ret = -EINVAL; > + ret = generic_handle_domain_irq(domain, hwirq); > > set_irq_regs(old_regs); > return ret; Yup, that's really neat. I somehow missed that when I moved some of the legacy stuff to be ARM specific. On a vaguely related note, I think you can drop the EXPORT_SYMBOL_GPL on handle_irq_desc() now. M.
On Fri, Oct 22, 2021 at 11:52:28AM +0100, Marc Zyngier wrote: > On Thu, 21 Oct 2021 19:02:25 +0100, > Mark Rutland <mark.rutland@arm.com> wrote: > > > > There's no need for handle_domain_{irq,nmi}() to open-code the NULL > > check performed by handle_irq_desc(), nor the resolution of the desc > > performed by generic_handle_domain_irq(). > > > > Use generic_handle_domain_irq() directly, as this is functioanlly > > equivalent and clearer. At the same time, delete the stale comments, > > which are no longer helpful. > > > > There should be no functional change as a result of this patch. > > > > Signed-off-by: Mark Rutland <mark.rutland@arm.com> > > Cc: Marc Zyngier <maz@kernel.org> > > Cc: Thomas Gleixner <tglx@linutronix.de> > > --- > > kernel/irq/irqdesc.c | 24 ++++-------------------- > > 1 file changed, 4 insertions(+), 20 deletions(-) > Yup, that's really neat. I somehow missed that when I moved some of > the legacy stuff to be ARM specific. > > On a vaguely related note, I think you can drop the EXPORT_SYMBOL_GPL > on handle_irq_desc() now. Seems so: [mark@lakrids:~/src/linux]% git grep -w handle_irq_desc arch/arm/kernel/irq.c: handle_irq_desc(desc); include/linux/irqdesc.h:int handle_irq_desc(struct irq_desc *desc); kernel/irq/irqdesc.c:int handle_irq_desc(struct irq_desc *desc) kernel/irq/irqdesc.c: return handle_irq_desc(irq_to_desc(irq)); kernel/irq/irqdesc.c: return handle_irq_desc(irq_resolve_mapping(domain, hwirq)); I'll add a patch to clean that up. Thanks, Mark
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index 4e3c29bb603c..b07d0e1552bc 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c @@ -690,17 +690,11 @@ int handle_domain_irq(struct irq_domain *domain, unsigned int hwirq, struct pt_regs *regs) { struct pt_regs *old_regs = set_irq_regs(regs); - struct irq_desc *desc; - int ret = 0; + int ret; irq_enter(); - /* The irqdomain code provides boundary checks */ - desc = irq_resolve_mapping(domain, hwirq); - if (likely(desc)) - handle_irq_desc(desc); - else - ret = -EINVAL; + ret = generic_handle_domain_irq(domain, hwirq); irq_exit(); set_irq_regs(old_regs); @@ -721,24 +715,14 @@ int handle_domain_nmi(struct irq_domain *domain, unsigned int hwirq, struct pt_regs *regs) { struct pt_regs *old_regs = set_irq_regs(regs); - struct irq_desc *desc; - int ret = 0; + int ret; /* * NMI context needs to be setup earlier in order to deal with tracing. */ WARN_ON(!in_nmi()); - desc = irq_resolve_mapping(domain, hwirq); - - /* - * ack_bad_irq is not NMI-safe, just report - * an invalid interrupt. - */ - if (likely(desc)) - handle_irq_desc(desc); - else - ret = -EINVAL; + ret = generic_handle_domain_irq(domain, hwirq); set_irq_regs(old_regs); return ret;
There's no need for handle_domain_{irq,nmi}() to open-code the NULL check performed by handle_irq_desc(), nor the resolution of the desc performed by generic_handle_domain_irq(). Use generic_handle_domain_irq() directly, as this is functioanlly equivalent and clearer. At the same time, delete the stale comments, which are no longer helpful. There should be no functional change as a result of this patch. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Cc: Marc Zyngier <maz@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> --- kernel/irq/irqdesc.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-)