Skip to contentSkip to conversation

ARM: Interrupt cleanups and API change preparation

PATCH New Thomas Gleixner 2 participants 13 messages Jul 13, 2015 – Aug 5, 2015

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover ARM: Interrupt cleanups and API change preparation

The following patch series contains the following changes:

- Consolidation of chained interrupt handler setup/removal

- Switch to functions which avoid a redundant interrupt descriptor lookup

- Preparation of interrupt flow handlers for the 'irq' argument removal

The series has no dependencies and is also available as a git branch for your convenience:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/arm

If you want me to carry the patches in the irq/core branch of tip, please let me know.

Thanks,

tglx

#1 lore raw

PATCH 1/11 ARM/orion: Consolidate chained IRQ handler install/remove

Chained irq handlers usually set up handler data as well. We now have a function to set both under irq_desc->lock. Replace the two calls with one.

Search and conversion was done with coccinelle.

Cc Julia Lawall <[email protected]>
Cc Russell King <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
---
 arch/arm/plat-orion/gpio.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/plat-orion/gpio.c +3 -2
Index: tip/arch/arm/plat-orion/gpio.c
===================================================================
@@ -582,8 +582,9 @@ void __init orion_gpio_init(struct devic
 
 	for (i = 0; i < 4; i++) {
 		if (irqs[i]) {
-			irq_set_handler_data(irqs[i], ochip);
-			irq_set_chained_handler(irqs[i], gpio_irq_handler);
+			irq_set_chained_handler_and_data(irqs[i],
+							 gpio_irq_handler,
+							 ochip);
 		}
 	}
 
#2 lore raw

PATCH 2/11 ARM/locomo: Consolidate chained IRQ handler install/remove

In reply to Thomas Gleixner

Chained irq handlers usually set up handler data as well. We now have a function to set both under irq_desc->lock. Replace the two calls with one.

Search and conversion was done with coccinelle.

Cc Julia Lawall <[email protected]>
Cc Russell King <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
---
 arch/arm/common/locomo.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/common/locomo.c +1 -2
Index: tip/arch/arm/common/locomo.c
===================================================================
@@ -475,8 +475,7 @@ static void __locomo_remove(struct locom
 	device_for_each_child(lchip->dev, NULL, locomo_remove_child);
 
 	if (lchip->irq != NO_IRQ) {
-		irq_set_chained_handler(lchip->irq, NULL);
-		irq_set_handler_data(lchip->irq, NULL);
+		irq_set_chained_handler_and_data(lchip->irq, NULL, NULL);
 	}
 
 	iounmap(lchip->base);
#3 lore raw

PATCH 3/11 ARM/irq: Use access helper irq_data_get_affinity_mask()

In reply to Thomas Gleixner

From: Jiang Liu <[email protected]>

This is a preparatory patch for moving irq_data struct members.

Cc Russell King <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
---
 arch/arm/kernel/irq.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/kernel/irq.c +2 -2
Index: tip/arch/arm/kernel/irq.c
===================================================================
@@ -140,7 +140,7 @@ int __init arch_probe_nr_irqs(void)
 static bool migrate_one_irq(struct irq_desc *desc)
 {
 	struct irq_data *d = irq_desc_get_irq_data(desc);
-	const struct cpumask *affinity = d->affinity;
+	const struct cpumask *affinity = irq_data_get_affinity_mask(d);
 	struct irq_chip *c;
 	bool ret = false;
 
@@ -160,7 +160,7 @@ static bool migrate_one_irq(struct irq_d
 	if (!c->irq_set_affinity)
 		pr_debug("IRQ%u: unable to set affinity\n", d->irq);
 	else if (c->irq_set_affinity(d, affinity, false) == IRQ_SET_MASK_OK && ret)
-		cpumask_copy(d->affinity, affinity);
+		cpumask_copy(irq_data_get_affinity_mask(d), affinity);
 
 	return ret;
 }
#4 lore raw

PATCH 4/11 ARM/LPC32xx: Use irq_set_handler_locked()

In reply to Thomas Gleixner

Use irq_set_handler_locked() as it avoids a redundant lookup of the irq descriptor.

Search and replacement was done with coccinelle.

Cc Jiang Liu <[email protected]>
Cc Julia Lawall <[email protected]>
Cc Russell King <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
---
 arch/arm/mach-lpc32xx/irq.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/mach-lpc32xx/irq.c +4 -4
Index: tip/arch/arm/mach-lpc32xx/irq.c
===================================================================
@@ -283,25 +283,25 @@ static int lpc32xx_set_irq_type(struct i
 	case IRQ_TYPE_EDGE_RISING:
 		/* Rising edge sensitive */
 		__lpc32xx_set_irq_type(d->hwirq, 1, 1);
-		__irq_set_handler_locked(d->irq, handle_edge_irq);
+		irq_set_handler_locked(d, handle_edge_irq);
 		break;
 
 	case IRQ_TYPE_EDGE_FALLING:
 		/* Falling edge sensitive */
 		__lpc32xx_set_irq_type(d->hwirq, 0, 1);
-		__irq_set_handler_locked(d->irq, handle_edge_irq);
+		irq_set_handler_locked(d, handle_edge_irq);
 		break;
 
 	case IRQ_TYPE_LEVEL_LOW:
 		/* Low level sensitive */
 		__lpc32xx_set_irq_type(d->hwirq, 0, 0);
-		__irq_set_handler_locked(d->irq, handle_level_irq);
+		irq_set_handler_locked(d, handle_level_irq);
 		break;
 
 	case IRQ_TYPE_LEVEL_HIGH:
 		/* High level sensitive */
 		__lpc32xx_set_irq_type(d->hwirq, 1, 0);
-		__irq_set_handler_locked(d->irq, handle_level_irq);
+		irq_set_handler_locked(d, handle_level_irq);
 		break;
 
 	/* Other modes are not supported */
#5 lore raw

PATCH 5/11 ARM, irq: Use irq_desc_get_xxx() to avoid redundant lookup of irq_desc

In reply to Thomas Gleixner

From: Jiang Liu <[email protected]>

Use irq_desc_get_xxx() to avoid redundant lookup of irq_desc while we already have a pointer to corresponding irq_desc.

Cc Russell King <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
---
 arch/arm/common/locomo.c   |    2 +-
 arch/arm/common/sa1111.c   |    2 +-
 arch/arm/plat-orion/gpio.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/common/locomo.c +1 -1
Index: tip/arch/arm/common/locomo.c
===================================================================
@@ -140,7 +140,7 @@ static struct locomo_dev_info locomo_dev
 
 static void locomo_handler(unsigned int irq, struct irq_desc *desc)
 {
-	struct locomo *lchip = irq_get_chip_data(irq);
+	struct locomo *lchip = irq_desc_get_chip_data(desc);
 	int req, i;
 
 	/* Acknowledge the parent IRQ */
arch/arm/common/sa1111.c +1 -1
Index: tip/arch/arm/common/sa1111.c
===================================================================
@@ -200,7 +200,7 @@ static void
 sa1111_irq_handler(unsigned int irq, struct irq_desc *desc)
 {
 	unsigned int stat0, stat1, i;
-	struct sa1111 *sachip = irq_get_handler_data(irq);
+	struct sa1111 *sachip = irq_desc_get_handler_data(desc);
 	void __iomem *mapbase = sachip->base + SA1111_INTC;
 
 	stat0 = sa1111_readl(mapbase + SA1111_INTSTATCLR0);
arch/arm/plat-orion/gpio.c +1 -1
Index: tip/arch/arm/plat-orion/gpio.c
===================================================================
@@ -409,7 +409,7 @@ static int gpio_irq_set_type(struct irq_
 
 static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
 {
-	struct orion_gpio_chip *ochip = irq_get_handler_data(irq);
+	struct orion_gpio_chip *ochip = irq_desc_get_handler_data(desc);
 	u32 cause, type;
 	int i;
 
#6 lore raw

PATCH 6/11 ARM/locomo: Prepare locomo_handler for irq argument removal

In reply to Thomas Gleixner

The irq argument of most interrupt flow handlers is unused or merily used instead of a local variable. The handlers which need the irq argument can retrieve the irq number from the irq descriptor.

Search and update was done with coccinelle and the invaluable help of Julia Lawall.

Cc Julia Lawall <[email protected]>
Cc Jiang Liu <[email protected]>
Cc Russell King <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
---
 arch/arm/common/locomo.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm/common/locomo.c +3 -1
Index: tip/arch/arm/common/locomo.c
===================================================================
@@ -138,7 +138,7 @@ static struct locomo_dev_info locomo_dev
 	},
 };
 
-static void locomo_handler(unsigned int irq, struct irq_desc *desc)
+static void locomo_handler(unsigned int __irq, struct irq_desc *desc)
 {
 	struct locomo *lchip = irq_desc_get_chip_data(desc);
 	int req, i;
@@ -150,6 +150,8 @@ static void locomo_handler(unsigned int
 	req = locomo_readl(lchip->base + LOCOMO_ICR) & 0x0f00;
 
 	if (req) {
+		unsigned int irq;
+
 		/* generate the next interrupt(s) */
 		irq = lchip->irq_base;
 		for (i = 0; i <= 3; i++, irq++) {
#7 lore raw

PATCH 7/11 ARM/sa1111: Prepare sa1111_irq_handler for irq argument removal

In reply to Thomas Gleixner

The irq argument of most interrupt flow handlers is unused or merily used instead of a local variable. The handlers which need the irq argument can retrieve the irq number from the irq descriptor.

Search and update was done with coccinelle and the invaluable help of Julia Lawall.

Cc Julia Lawall <[email protected]>
Cc Jiang Liu <[email protected]>
Cc Russell King <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
---
 arch/arm/common/sa1111.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/common/sa1111.c +2 -1
Index: tip/arch/arm/common/sa1111.c
===================================================================
@@ -197,8 +197,9 @@ static struct sa1111_dev_info sa1111_dev
  * will call us again if there are more interrupts to process.
  */
 static void
-sa1111_irq_handler(unsigned int irq, struct irq_desc *desc)
+sa1111_irq_handler(unsigned int __irq, struct irq_desc *desc)
 {
+	unsigned int irq = irq_desc_get_irq(desc);
 	unsigned int stat0, stat1, i;
 	struct sa1111 *sachip = irq_desc_get_handler_data(desc);
 	void __iomem *mapbase = sachip->base + SA1111_INTC;
#8 lore raw

PATCH 8/11 ARM/dove: Prepare pmu_irq_handler for irq argument removal

In reply to Thomas Gleixner

The irq argument of most interrupt flow handlers is unused or merily used instead of a local variable. The handlers which need the irq argument can retrieve the irq number from the irq descriptor.

Search and update was done with coccinelle and the invaluable help of Julia Lawall.

Cc Julia Lawall <[email protected]>
Cc Jiang Liu <[email protected]>
Cc Russell King <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
---
 arch/arm/mach-dove/irq.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/mach-dove/irq.c +2 -1
Index: tip/arch/arm/mach-dove/irq.c
===================================================================
@@ -69,8 +69,9 @@ static struct irq_chip pmu_irq_chip = {
 	.irq_ack	= pmu_irq_ack,
 };
 
-static void pmu_irq_handler(unsigned int irq, struct irq_desc *desc)
+static void pmu_irq_handler(unsigned int __irq, struct irq_desc *desc)
 {
+	unsigned int irq = irq_desc_get_irq(desc);
 	unsigned long cause = readl(PMU_INTERRUPT_CAUSE);
 
 	cause &= readl(PMU_INTERRUPT_MASK);
#9 lore raw

PATCH 9/11 ARM/pxa: Prepare *_irq_handler for irq argument removal

In reply to Thomas Gleixner

The irq argument of most interrupt flow handlers is unused or merily used instead of a local variable. The handlers which need the irq argument can retrieve the irq number from the irq descriptor.

Search and update was done with coccinelle and the invaluable help of Julia Lawall.

Cc Julia Lawall <[email protected]>
Cc Jiang Liu <[email protected]>
Cc Russell King <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
---
 arch/arm/mach-pxa/cm-x2xx-pci.c      |    3 ++-
 arch/arm/mach-pxa/lpd270.c           |    3 ++-
 arch/arm/mach-pxa/pcm990-baseboard.c |    3 ++-
 arch/arm/mach-pxa/viper.c            |    3 ++-
 arch/arm/mach-pxa/zeus.c             |    3 ++-
 5 files changed, 10 insertions(+), 5 deletions(-)
arch/arm/mach-pxa/cm-x2xx-pci.c +2 -1
Index: tip/arch/arm/mach-pxa/cm-x2xx-pci.c
===================================================================
@@ -29,8 +29,9 @@
 void __iomem *it8152_base_address;
 static int cmx2xx_it8152_irq_gpio;
 
-static void cmx2xx_it8152_irq_demux(unsigned int irq, struct irq_desc *desc)
+static void cmx2xx_it8152_irq_demux(unsigned int __irq, struct irq_desc *desc)
 {
+	unsigned int irq = irq_desc_get_irq(desc);
 	/* clear our parent irq */
 	desc->irq_data.chip->irq_ack(&desc->irq_data);
 
arch/arm/mach-pxa/lpd270.c +2 -1
Index: tip/arch/arm/mach-pxa/lpd270.c
===================================================================
@@ -120,8 +120,9 @@ static struct irq_chip lpd270_irq_chip =
 	.irq_unmask	= lpd270_unmask_irq,
 };
 
-static void lpd270_irq_handler(unsigned int irq, struct irq_desc *desc)
+static void lpd270_irq_handler(unsigned int __irq, struct irq_desc *desc)
 {
+	unsigned int irq;
 	unsigned long pending;
 
 	pending = __raw_readw(LPD270_INT_STATUS) & lpd270_irq_enabled;
arch/arm/mach-pxa/pcm990-baseboard.c +2 -1
Index: tip/arch/arm/mach-pxa/pcm990-baseboard.c
===================================================================
@@ -284,8 +284,9 @@ static struct irq_chip pcm990_irq_chip =
 	.irq_unmask	= pcm990_unmask_irq,
 };
 
-static void pcm990_irq_handler(unsigned int irq, struct irq_desc *desc)
+static void pcm990_irq_handler(unsigned int __irq, struct irq_desc *desc)
 {
+	unsigned int irq;
 	unsigned long pending;
 
 	pending = ~pcm990_cpld_readb(PCM990_CTRL_INTSETCLR);
arch/arm/mach-pxa/viper.c +2 -1
Index: tip/arch/arm/mach-pxa/viper.c
===================================================================
@@ -276,8 +276,9 @@ static inline unsigned long viper_irq_pe
 			viper_irq_enabled_mask;
 }
 
-static void viper_irq_handler(unsigned int irq, struct irq_desc *desc)
+static void viper_irq_handler(unsigned int __irq, struct irq_desc *desc)
 {
+	unsigned int irq;
 	unsigned long pending;
 
 	pending = viper_irq_pending();
arch/arm/mach-pxa/zeus.c +2 -1
Index: tip/arch/arm/mach-pxa/zeus.c
===================================================================
@@ -105,8 +105,9 @@ static inline unsigned long zeus_irq_pen
 	return __raw_readw(ZEUS_CPLD_ISA_IRQ) & zeus_irq_enabled_mask;
 }
 
-static void zeus_irq_handler(unsigned int irq, struct irq_desc *desc)
+static void zeus_irq_handler(unsigned int __irq, struct irq_desc *desc)
 {
+	unsigned int irq;
 	unsigned long pending;
 
 	pending = zeus_irq_pending();
#10 lore raw

PATCH 10/11 ARM/pxa: Prepare balloon3_irq_handler for irq argument removal

In reply to Thomas Gleixner

The irq argument of most interrupt flow handlers is unused or merily used instead of a local variable. The handlers which need the irq argument can retrieve the irq number from the irq descriptor.

While at it fix the pointless lookup of irq_data with the proper methods to retrieve the same information from the irq descriptor.

Cc Jiang Liu <[email protected]>
Cc Russell King <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
---
 arch/arm/mach-pxa/balloon3.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
arch/arm/mach-pxa/balloon3.c +7 -7
Index: tip/arch/arm/mach-pxa/balloon3.c
===================================================================
@@ -496,18 +496,18 @@ static struct irq_chip balloon3_irq_chip
 	.irq_unmask	= balloon3_unmask_irq,
 };
 
-static void balloon3_irq_handler(unsigned int irq, struct irq_desc *desc)
+static void balloon3_irq_handler(unsigned int __irq, struct irq_desc *desc)
 {
 	unsigned long pending = __raw_readl(BALLOON3_INT_CONTROL_REG) &
 					balloon3_irq_enabled;
 	do {
-		/* clear useless edge notification */
-		if (desc->irq_data.chip->irq_ack) {
-			struct irq_data *d;
+		struct irq_data *d = irq_desc_get_irq_data(desc);
+		struct irq_chip *chip = irq_data_get_chip(d);
+		unsigned int irq;
 
-			d = irq_get_irq_data(BALLOON3_AUX_NIRQ);
-			desc->irq_data.chip->irq_ack(d);
-		}
+		/* clear useless edge notification */
+		if (chip->irq_ack)
+			chip->irq_ack(d);
 
 		while (pending) {
 			irq = BALLOON3_IRQ(0) + __ffs(pending);
#11 lore raw

PATCH 11/11 ARM/orion/gpio: Prepare gpio_irq_handler for irq argument removal

In reply to Thomas Gleixner

The irq argument of most interrupt flow handlers is unused or merily used instead of a local variable. The handlers which need the irq argument can retrieve the irq number from the irq descriptor.

In this case the irq argument is shadowed by a local variable already, so just rename it.

Search and update was done with coccinelle and the invaluable help of Julia Lawall.

Cc Julia Lawall <[email protected]>
Cc Jiang Liu <[email protected]>
Cc Russell King <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
---
 arch/arm/plat-orion/gpio.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/plat-orion/gpio.c +1 -1
Index: tip/arch/arm/plat-orion/gpio.c
===================================================================
@@ -407,7 +407,7 @@ static int gpio_irq_set_type(struct irq_
 	return 0;
 }
 
-static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
+static void gpio_irq_handler(unsigned __irq, struct irq_desc *desc)
 {
 	struct orion_gpio_chip *ochip = irq_desc_get_handler_data(desc);
 	u32 cause, type;
#12 lore raw

cover ARM: Interrupt cleanups and API change preparation

In reply to Thomas Gleixner
Quoted 10 lines · Thomas Gleixner

The following patch series contains the following changes:

- Consolidation of chained interrupt handler setup/removal

- Switch to functions which avoid a redundant interrupt descriptor lookup

- Preparation of interrupt flow handlers for the 'irq' argument removal

Quoted 7 lines

The series has no dependencies and is also available as a git branch for your convenience:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/arm

If you want me to carry the patches in the irq/core branch of tip, please let me know.

I've now merged this into next/cleanup in arm-soc (for 4.3).

Thanks!

-Olof