[PATCH v2] irqchip/irq-brcmstb-l2: Replace brcmstb_l2_mask_and_ack() by generic function

linux@treblig.org posted 1 patch 2 weeks, 6 days ago
drivers/irqchip/irq-brcmstb-l2.c | 28 +---------------------------
kernel/irq/generic-chip.c        |  1 +
2 files changed, 2 insertions(+), 27 deletions(-)
[PATCH v2] irqchip/irq-brcmstb-l2: Replace brcmstb_l2_mask_and_ack() by generic function
Posted by linux@treblig.org 2 weeks, 6 days ago
From: "Dr. David Alan Gilbert" <linux@treblig.org>

Replace brcmstb_l2_mask_and_ack() by the generic
irq_gc_mask_disable_and_ack_set().

brcmstb_l2_mask_and_ack() was added in commit 49aa6ef0b439
("irqchip/brcmstb-l2: Remove some processing from the handler") in
September 2017 with a comment saying it was actually generic and someone
should add it to the generic code.

commit 20608924cc2e ("genirq: generic chip: Add
irq_gc_mask_disable_and_ack_set()") did that a few weeks later, however no
one went back and took the brcmstb variant out.

Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://lore.kernel.org/all/20241224001727.149337-1-linux@treblig.org
---
v2
  Add EXPORT_SYMBOL_GPL as spotted by kernel test robot and
  fix suggested by Florian

 drivers/irqchip/irq-brcmstb-l2.c | 28 +---------------------------
 kernel/irq/generic-chip.c        |  1 +
 2 files changed, 2 insertions(+), 27 deletions(-)

diff --git a/drivers/irqchip/irq-brcmstb-l2.c b/drivers/irqchip/irq-brcmstb-l2.c
index c988886917f7..db4c9721fcf2 100644
--- a/drivers/irqchip/irq-brcmstb-l2.c
+++ b/drivers/irqchip/irq-brcmstb-l2.c
@@ -61,32 +61,6 @@ struct brcmstb_l2_intc_data {
 	u32 saved_mask; /* for suspend/resume */
 };
 
-/**
- * brcmstb_l2_mask_and_ack - Mask and ack pending interrupt
- * @d: irq_data
- *
- * Chip has separate enable/disable registers instead of a single mask
- * register and pending interrupt is acknowledged by setting a bit.
- *
- * Note: This function is generic and could easily be added to the
- * generic irqchip implementation if there ever becomes a will to do so.
- * Perhaps with a name like irq_gc_mask_disable_and_ack_set().
- *
- * e.g.: https://patchwork.kernel.org/patch/9831047/
- */
-static void brcmstb_l2_mask_and_ack(struct irq_data *d)
-{
-	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
-	struct irq_chip_type *ct = irq_data_get_chip_type(d);
-	u32 mask = d->mask;
-
-	irq_gc_lock(gc);
-	irq_reg_writel(gc, mask, ct->regs.disable);
-	*ct->mask_cache &= ~mask;
-	irq_reg_writel(gc, mask, ct->regs.ack);
-	irq_gc_unlock(gc);
-}
-
 static void brcmstb_l2_intc_irq_handle(struct irq_desc *desc)
 {
 	struct brcmstb_l2_intc_data *b = irq_desc_get_handler_data(desc);
@@ -248,7 +222,7 @@ static int __init brcmstb_l2_intc_of_init(struct device_node *np,
 	if (init_params->cpu_clear >= 0) {
 		ct->regs.ack = init_params->cpu_clear;
 		ct->chip.irq_ack = irq_gc_ack_set_bit;
-		ct->chip.irq_mask_ack = brcmstb_l2_mask_and_ack;
+		ct->chip.irq_mask_ack = irq_gc_mask_disable_and_ack_set;
 	} else {
 		/* No Ack - but still slightly more efficient to define this */
 		ct->chip.irq_mask_ack = irq_gc_mask_disable_reg;
diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c
index 32ffcbb87fa1..c4a8bca5f2b0 100644
--- a/kernel/irq/generic-chip.c
+++ b/kernel/irq/generic-chip.c
@@ -162,6 +162,7 @@ void irq_gc_mask_disable_and_ack_set(struct irq_data *d)
 	irq_reg_writel(gc, mask, ct->regs.ack);
 	irq_gc_unlock(gc);
 }
+EXPORT_SYMBOL_GPL(irq_gc_mask_disable_and_ack_set);
 
 /**
  * irq_gc_eoi - EOI interrupt
-- 
2.48.0
Re: [PATCH v2] irqchip/irq-brcmstb-l2: Replace brcmstb_l2_mask_and_ack() by generic function
Posted by Thomas Gleixner 2 weeks, 6 days ago
David!

On Thu, Jan 16 2025 at 00:59, linux@treblig.org wrote:
> Replace brcmstb_l2_mask_and_ack() by the generic
> irq_gc_mask_disable_and_ack_set().
>
> brcmstb_l2_mask_and_ack() was added in commit 49aa6ef0b439
> ("irqchip/brcmstb-l2: Remove some processing from the handler") in
> September 2017 with a comment saying it was actually generic and someone
> should add it to the generic code.
>
> commit 20608924cc2e ("genirq: generic chip: Add
> irq_gc_mask_disable_and_ack_set()") did that a few weeks later, however no
> one went back and took the brcmstb variant out.

That's too late. The original patch is already applied and I'm not going
to redo the whole branch for this minor hickup. I've converted it to a
delta fix.

> Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

You cannot add my Signed-off-by to a new submission.

Thanks,

        tglx
Re: [PATCH v2] irqchip/irq-brcmstb-l2: Replace brcmstb_l2_mask_and_ack() by generic function
Posted by Dr. David Alan Gilbert 2 weeks, 5 days ago
* Thomas Gleixner (tglx@linutronix.de) wrote:
> David!
> 
> On Thu, Jan 16 2025 at 00:59, linux@treblig.org wrote:
> > Replace brcmstb_l2_mask_and_ack() by the generic
> > irq_gc_mask_disable_and_ack_set().
> >
> > brcmstb_l2_mask_and_ack() was added in commit 49aa6ef0b439
> > ("irqchip/brcmstb-l2: Remove some processing from the handler") in
> > September 2017 with a comment saying it was actually generic and someone
> > should add it to the generic code.
> >
> > commit 20608924cc2e ("genirq: generic chip: Add
> > irq_gc_mask_disable_and_ack_set()") did that a few weeks later, however no
> > one went back and took the brcmstb variant out.
> 
> That's too late. The original patch is already applied and I'm not going
> to redo the whole branch for this minor hickup. I've converted it to a
> delta fix.

Thanks.

> > Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
> > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> 
> You cannot add my Signed-off-by to a new submission.

Apologies.

Dave

> Thanks,
> 
>         tglx
-- 
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
[tip: irq/core] genirq/generic_chip: Export irq_gc_mask_disable_and_ack_set()
Posted by tip-bot2 for Dr. David Alan Gilbert 2 weeks, 6 days ago
The following commit has been merged into the irq/core branch of tip:

Commit-ID:     a4b3990e01df169334ff2695d2fe494eda63a297
Gitweb:        https://git.kernel.org/tip/a4b3990e01df169334ff2695d2fe494eda63a297
Author:        Dr. David Alan Gilbert <linux@treblig.org>
AuthorDate:    Thu, 16 Jan 2025 00:59:20 
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Thu, 16 Jan 2025 09:10:17 +01:00

genirq/generic_chip: Export irq_gc_mask_disable_and_ack_set()

The recent conversion of brcmstb_l2_mask_and_ack() to
irq_gc_mask_disable_and_ack_set() missed that the driver can be built as a
module, but the generic function is not exported.

Add the missing export.

[ tglx: Converted it to a fix ]

Fixes: dd1f17a9faf5 ("irqchip/irq-brcmstb-l2: Replace brcmstb_l2_mask_and_ack() by generic function")
Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250116005920.626822-1-linux@treblig.org
---
 kernel/irq/generic-chip.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c
index 32ffcbb..c4a8bca 100644
--- a/kernel/irq/generic-chip.c
+++ b/kernel/irq/generic-chip.c
@@ -162,6 +162,7 @@ void irq_gc_mask_disable_and_ack_set(struct irq_data *d)
 	irq_reg_writel(gc, mask, ct->regs.ack);
 	irq_gc_unlock(gc);
 }
+EXPORT_SYMBOL_GPL(irq_gc_mask_disable_and_ack_set);
 
 /**
  * irq_gc_eoi - EOI interrupt