linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name
@ 2022-02-09 16:25 Marc Zyngier
  2022-02-09 16:25 ` [PATCH 01/10] irqdomain: Let irq_domain_set_{info,hwirq_and_chip} take a const irq_chip Marc Zyngier
                   ` (10 more replies)
  0 siblings, 11 replies; 39+ messages in thread
From: Marc Zyngier @ 2022-02-09 16:25 UTC (permalink / raw)
  To: linux-kernel, linux-gpio
  Cc: Linus Walleij, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Emil Renner Berthing,
	kernel-team

Another common abuse in irqchip drivers (and derivatives) is to place
a string representing the underlying device in the irq_chip::name
field that gets displayed in /proc/interrupts while this should only
be an indication of the "type" of interrupt controller.

Not only this is pretty pointless (with hierarchical domains, you only
see the top chip), but it also gets in the way of making the irq_chip
structure const. For debug, we have a whole infrastructure that does
everything you can imagine (and stuff you don't want to).

We can't remove this name as it is visible from userspace and there is
a whole collection of CI scripts that parse /proc/interrupts for good
(and mostly bad) reasons. The solution is to use the irq_print_chip()
callback and to let it output whatever string is necessary.

Having done that, we can cleanup a few irqchip drivers and make their
irq_chip structure const (which requires touching a handful of core
functions). Whilst we're at it, we do the same for a couple of gpio
drivers.

This series relies on the one posted at [1].

Thanks,

	M.

[1] https://lore.kernel.org/r/20220201120310.878267-1-maz@kernel.org

Marc Zyngier (10):
  irqdomain: Let irq_domain_set_{info,hwirq_and_chip} take a const
    irq_chip
  genirq: Allow irq_chip registration functions to take a const irq_chip
  irqchip/gic: Switch to dynamic chip name output
  irqchip/lpc32xx: Switch to dynamic chip name output
  irqchip/mvebu-pic: Switch to dynamic chip name output
  irqchip/ts4800: Switch to dynamic chip name output
  irqchip/versatile-fpga: Switch to dynamic chip name output
  gpio: mt7621: Switch to dynamic chip name output
  gpio: omap: Switch to dynamic chip name output
  pinctrl: starfive: Switch to dynamic chip name output

 drivers/gpio/gpio-mt7621.c             |  12 ++-
 drivers/gpio/gpio-omap.c               |  28 ++++---
 drivers/irqchip/irq-ftintc010.c        |   1 -
 drivers/irqchip/irq-gic.c              | 102 +++++++++++++------------
 drivers/irqchip/irq-lpc32xx.c          |  34 ++++++---
 drivers/irqchip/irq-mvebu-pic.c        |  28 ++++---
 drivers/irqchip/irq-ts4800.c           |  25 ++++--
 drivers/irqchip/irq-versatile-fpga.c   |  46 ++++++-----
 drivers/pinctrl/pinctrl-starfive.c     |  11 ++-
 include/linux/irq.h                    |   7 +-
 include/linux/irqchip/versatile-fpga.h |  14 ----
 include/linux/irqdomain.h              |   5 +-
 kernel/irq/chip.c                      |   9 +--
 kernel/irq/irqdomain.c                 |   7 +-
 14 files changed, 189 insertions(+), 140 deletions(-)
 delete mode 100644 include/linux/irqchip/versatile-fpga.h

-- 
2.30.2


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 01/10] irqdomain: Let irq_domain_set_{info,hwirq_and_chip} take a const irq_chip
  2022-02-09 16:25 [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name Marc Zyngier
@ 2022-02-09 16:25 ` Marc Zyngier
  2022-02-15 12:20   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
  2022-02-09 16:25 ` [PATCH 02/10] genirq: Allow irq_chip registration functions to " Marc Zyngier
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 39+ messages in thread
From: Marc Zyngier @ 2022-02-09 16:25 UTC (permalink / raw)
  To: linux-kernel, linux-gpio
  Cc: Linus Walleij, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Emil Renner Berthing,
	kernel-team

In order to let a const irqchip be fed to the irqchip layer, adjust
the various prototypes. An extra cast in irq_domain_set_hwirq_and_chip()
is required to avoid a warning.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 include/linux/irqdomain.h | 5 +++--
 kernel/irq/irqdomain.c    | 7 ++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index be25a33293e5..00d577f90883 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -479,7 +479,8 @@ int irq_destroy_ipi(unsigned int irq, const struct cpumask *dest);
 extern struct irq_data *irq_domain_get_irq_data(struct irq_domain *domain,
 						unsigned int virq);
 extern void irq_domain_set_info(struct irq_domain *domain, unsigned int virq,
-				irq_hw_number_t hwirq, struct irq_chip *chip,
+				irq_hw_number_t hwirq,
+				const struct irq_chip *chip,
 				void *chip_data, irq_flow_handler_t handler,
 				void *handler_data, const char *handler_name);
 extern void irq_domain_reset_irq_data(struct irq_data *irq_data);
@@ -522,7 +523,7 @@ extern int irq_domain_alloc_irqs_hierarchy(struct irq_domain *domain,
 extern int irq_domain_set_hwirq_and_chip(struct irq_domain *domain,
 					 unsigned int virq,
 					 irq_hw_number_t hwirq,
-					 struct irq_chip *chip,
+					 const struct irq_chip *chip,
 					 void *chip_data);
 extern void irq_domain_free_irqs_common(struct irq_domain *domain,
 					unsigned int virq,
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index bf38c546aa25..14cf52708890 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -1319,7 +1319,8 @@ EXPORT_SYMBOL_GPL(irq_domain_get_irq_data);
  * @chip_data:	The associated chip data
  */
 int irq_domain_set_hwirq_and_chip(struct irq_domain *domain, unsigned int virq,
-				  irq_hw_number_t hwirq, struct irq_chip *chip,
+				  irq_hw_number_t hwirq,
+				  const struct irq_chip *chip,
 				  void *chip_data)
 {
 	struct irq_data *irq_data = irq_domain_get_irq_data(domain, virq);
@@ -1328,7 +1329,7 @@ int irq_domain_set_hwirq_and_chip(struct irq_domain *domain, unsigned int virq,
 		return -ENOENT;
 
 	irq_data->hwirq = hwirq;
-	irq_data->chip = chip ? chip : &no_irq_chip;
+	irq_data->chip = (struct irq_chip *)(chip ? chip : &no_irq_chip);
 	irq_data->chip_data = chip_data;
 
 	return 0;
@@ -1347,7 +1348,7 @@ EXPORT_SYMBOL_GPL(irq_domain_set_hwirq_and_chip);
  * @handler_name:	The interrupt handler name
  */
 void irq_domain_set_info(struct irq_domain *domain, unsigned int virq,
-			 irq_hw_number_t hwirq, struct irq_chip *chip,
+			 irq_hw_number_t hwirq, const struct irq_chip *chip,
 			 void *chip_data, irq_flow_handler_t handler,
 			 void *handler_data, const char *handler_name)
 {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 02/10] genirq: Allow irq_chip registration functions to take a const irq_chip
  2022-02-09 16:25 [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name Marc Zyngier
  2022-02-09 16:25 ` [PATCH 01/10] irqdomain: Let irq_domain_set_{info,hwirq_and_chip} take a const irq_chip Marc Zyngier
@ 2022-02-09 16:25 ` Marc Zyngier
  2022-02-15 12:20   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
  2022-02-09 16:26 ` [PATCH 03/10] irqchip/gic: Switch to dynamic chip name output Marc Zyngier
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 39+ messages in thread
From: Marc Zyngier @ 2022-02-09 16:25 UTC (permalink / raw)
  To: linux-kernel, linux-gpio
  Cc: Linus Walleij, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Emil Renner Berthing,
	kernel-team

In order to let a const irqchip be fed to the irqchip layer, adjust
the various prototypes. An extra cast in irq_set_chip()() is required
to avoid a warning.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 include/linux/irq.h | 7 ++++---
 kernel/irq/chip.c   | 9 +++------
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/include/linux/irq.h b/include/linux/irq.h
index 2cb2e2ac2703..f92788ccdba2 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -710,10 +710,11 @@ extern struct irq_chip no_irq_chip;
 extern struct irq_chip dummy_irq_chip;
 
 extern void
-irq_set_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
+irq_set_chip_and_handler_name(unsigned int irq, const struct irq_chip *chip,
 			      irq_flow_handler_t handle, const char *name);
 
-static inline void irq_set_chip_and_handler(unsigned int irq, struct irq_chip *chip,
+static inline void irq_set_chip_and_handler(unsigned int irq,
+					    const struct irq_chip *chip,
 					    irq_flow_handler_t handle)
 {
 	irq_set_chip_and_handler_name(irq, chip, handle, NULL);
@@ -803,7 +804,7 @@ static inline void irq_set_percpu_devid_flags(unsigned int irq)
 }
 
 /* Set/get chip/data for an IRQ: */
-extern int irq_set_chip(unsigned int irq, struct irq_chip *chip);
+extern int irq_set_chip(unsigned int irq, const struct irq_chip *chip);
 extern int irq_set_handler_data(unsigned int irq, void *data);
 extern int irq_set_chip_data(unsigned int irq, void *data);
 extern int irq_set_irq_type(unsigned int irq, unsigned int type);
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 24b6f2b40e5e..54af0deb239b 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -38,7 +38,7 @@ struct irqaction chained_action = {
  *	@irq:	irq number
  *	@chip:	pointer to irq chip description structure
  */
-int irq_set_chip(unsigned int irq, struct irq_chip *chip)
+int irq_set_chip(unsigned int irq, const struct irq_chip *chip)
 {
 	unsigned long flags;
 	struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
@@ -46,10 +46,7 @@ int irq_set_chip(unsigned int irq, struct irq_chip *chip)
 	if (!desc)
 		return -EINVAL;
 
-	if (!chip)
-		chip = &no_irq_chip;
-
-	desc->irq_data.chip = chip;
+	desc->irq_data.chip = (struct irq_chip *)(chip ?: &no_irq_chip);
 	irq_put_desc_unlock(desc, flags);
 	/*
 	 * For !CONFIG_SPARSE_IRQ make the irq show up in
@@ -1073,7 +1070,7 @@ irq_set_chained_handler_and_data(unsigned int irq, irq_flow_handler_t handle,
 EXPORT_SYMBOL_GPL(irq_set_chained_handler_and_data);
 
 void
-irq_set_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
+irq_set_chip_and_handler_name(unsigned int irq, const struct irq_chip *chip,
 			      irq_flow_handler_t handle, const char *name)
 {
 	irq_set_chip(irq, chip);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 03/10] irqchip/gic: Switch to dynamic chip name output
  2022-02-09 16:25 [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name Marc Zyngier
  2022-02-09 16:25 ` [PATCH 01/10] irqdomain: Let irq_domain_set_{info,hwirq_and_chip} take a const irq_chip Marc Zyngier
  2022-02-09 16:25 ` [PATCH 02/10] genirq: Allow irq_chip registration functions to " Marc Zyngier
@ 2022-02-09 16:26 ` Marc Zyngier
  2022-02-10 23:38   ` Linus Walleij
  2022-02-15 12:19   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
  2022-02-09 16:26 ` [PATCH 04/10] irqchip/lpc32xx: " Marc Zyngier
                   ` (7 subsequent siblings)
  10 siblings, 2 replies; 39+ messages in thread
From: Marc Zyngier @ 2022-02-09 16:26 UTC (permalink / raw)
  To: linux-kernel, linux-gpio
  Cc: Linus Walleij, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Emil Renner Berthing,
	kernel-team

The last dynamic aspect of the GIC's irq_chip structure is the
name that is associated to it.

Move the output of that name to the relevant callback, which
allows us to do a bit of cleanup and mark the structures const.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/irqchip/irq-gic.c | 102 ++++++++++++++++++++------------------
 1 file changed, 54 insertions(+), 48 deletions(-)

diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index fb741b42ca2d..58ba835bee1f 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -34,6 +34,7 @@
 #include <linux/irqdomain.h>
 #include <linux/interrupt.h>
 #include <linux/percpu.h>
+#include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/irqchip.h>
 #include <linux/irqchip/chained_irq.h>
@@ -66,7 +67,6 @@ union gic_base {
 };
 
 struct gic_chip_data {
-	struct irq_chip chip;
 	union gic_base dist_base;
 	union gic_base cpu_base;
 	void __iomem *raw_dist_base;
@@ -397,18 +397,15 @@ static void gic_handle_cascade_irq(struct irq_desc *desc)
 	chained_irq_exit(chip, desc);
 }
 
-static const struct irq_chip gic_chip = {
-	.irq_mask		= gic_mask_irq,
-	.irq_unmask		= gic_unmask_irq,
-	.irq_eoi		= gic_eoi_irq,
-	.irq_set_type		= gic_set_type,
-	.irq_retrigger          = gic_retrigger,
-	.irq_get_irqchip_state	= gic_irq_get_irqchip_state,
-	.irq_set_irqchip_state	= gic_irq_set_irqchip_state,
-	.flags			= IRQCHIP_SET_TYPE_MASKED |
-				  IRQCHIP_SKIP_SET_WAKE |
-				  IRQCHIP_MASK_ON_SUSPEND,
-};
+static void gic_irq_print_chip(struct irq_data *d, struct seq_file *p)
+{
+	struct gic_chip_data *gic = irq_data_get_irq_chip_data(d);
+
+	if (gic->domain->dev)
+		seq_printf(p, gic->domain->dev->of_node->name);
+	else
+		seq_printf(p, "GIC-%d", (int)(gic - &gic_data[0]));
+}
 
 void __init gic_cascade_irq(unsigned int gic_nr, unsigned int irq)
 {
@@ -799,8 +796,12 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
 			    bool force)
 {
 	void __iomem *reg = gic_dist_base(d) + GIC_DIST_TARGET + gic_irq(d);
+	struct gic_chip_data *gic = irq_data_get_irq_chip_data(d);
 	unsigned int cpu;
 
+	if (unlikely(gic != &gic_data[0]))
+		return -EINVAL;
+
 	if (!force)
 		cpu = cpumask_any_and(mask_val, cpu_online_mask);
 	else
@@ -880,6 +881,39 @@ static __init void gic_smp_init(void)
 #define gic_ipi_send_mask	NULL
 #endif
 
+static const struct irq_chip gic_chip = {
+	.irq_mask		= gic_mask_irq,
+	.irq_unmask		= gic_unmask_irq,
+	.irq_eoi		= gic_eoi_irq,
+	.irq_set_type		= gic_set_type,
+	.irq_retrigger          = gic_retrigger,
+	.irq_set_affinity	= gic_set_affinity,
+	.ipi_send_mask		= gic_ipi_send_mask,
+	.irq_get_irqchip_state	= gic_irq_get_irqchip_state,
+	.irq_set_irqchip_state	= gic_irq_set_irqchip_state,
+	.irq_print_chip		= gic_irq_print_chip,
+	.flags			= IRQCHIP_SET_TYPE_MASKED |
+				  IRQCHIP_SKIP_SET_WAKE |
+				  IRQCHIP_MASK_ON_SUSPEND,
+};
+
+static const struct irq_chip gic_chip_mode1 = {
+	.name			= "GICv2",
+	.irq_mask		= gic_eoimode1_mask_irq,
+	.irq_unmask		= gic_unmask_irq,
+	.irq_eoi		= gic_eoimode1_eoi_irq,
+	.irq_set_type		= gic_set_type,
+	.irq_retrigger          = gic_retrigger,
+	.irq_set_affinity	= gic_set_affinity,
+	.ipi_send_mask		= gic_ipi_send_mask,
+	.irq_get_irqchip_state	= gic_irq_get_irqchip_state,
+	.irq_set_irqchip_state	= gic_irq_set_irqchip_state,
+	.irq_set_vcpu_affinity	= gic_irq_set_vcpu_affinity,
+	.flags			= IRQCHIP_SET_TYPE_MASKED |
+				  IRQCHIP_SKIP_SET_WAKE |
+				  IRQCHIP_MASK_ON_SUSPEND,
+};
+
 #ifdef CONFIG_BL_SWITCHER
 /*
  * gic_send_sgi - send a SGI directly to given CPU interface number
@@ -1024,15 +1058,19 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int irq,
 {
 	struct gic_chip_data *gic = d->host_data;
 	struct irq_data *irqd = irq_desc_get_irq_data(irq_to_desc(irq));
+	const struct irq_chip *chip;
+
+	chip = (static_branch_likely(&supports_deactivate_key) &&
+		gic == &gic_data[0]) ? &gic_chip_mode1 : &gic_chip;
 
 	switch (hw) {
 	case 0 ... 31:
 		irq_set_percpu_devid(irq);
-		irq_domain_set_info(d, irq, hw, &gic->chip, d->host_data,
+		irq_domain_set_info(d, irq, hw, chip, d->host_data,
 				    handle_percpu_devid_irq, NULL, NULL);
 		break;
 	default:
-		irq_domain_set_info(d, irq, hw, &gic->chip, d->host_data,
+		irq_domain_set_info(d, irq, hw, chip, d->host_data,
 				    handle_fasteoi_irq, NULL, NULL);
 		irq_set_probe(irq);
 		irqd_set_single_target(irqd);
@@ -1127,25 +1165,6 @@ static const struct irq_domain_ops gic_irq_domain_ops = {
 	.unmap = gic_irq_domain_unmap,
 };
 
-static void gic_init_chip(struct gic_chip_data *gic, const char *name,
-			  bool use_eoimode1)
-{
-	/* Initialize irq_chip */
-	gic->chip = gic_chip;
-	gic->chip.name = name;
-
-	if (use_eoimode1) {
-		gic->chip.irq_mask = gic_eoimode1_mask_irq;
-		gic->chip.irq_eoi = gic_eoimode1_eoi_irq;
-		gic->chip.irq_set_vcpu_affinity = gic_irq_set_vcpu_affinity;
-	}
-
-	if (gic == &gic_data[0]) {
-		gic->chip.irq_set_affinity = gic_set_affinity;
-		gic->chip.ipi_send_mask = gic_ipi_send_mask;
-	}
-}
-
 static int gic_init_bases(struct gic_chip_data *gic,
 			  struct fwnode_handle *handle)
 {
@@ -1245,7 +1264,6 @@ static int gic_init_bases(struct gic_chip_data *gic,
 static int __init __gic_init_bases(struct gic_chip_data *gic,
 				   struct fwnode_handle *handle)
 {
-	char *name;
 	int i, ret;
 
 	if (WARN_ON(!gic || gic->domain))
@@ -1265,18 +1283,8 @@ static int __init __gic_init_bases(struct gic_chip_data *gic,
 			pr_info("GIC: Using split EOI/Deactivate mode\n");
 	}
 
-	if (static_branch_likely(&supports_deactivate_key) && gic == &gic_data[0]) {
-		name = kasprintf(GFP_KERNEL, "GICv2");
-		gic_init_chip(gic, name, true);
-	} else {
-		name = kasprintf(GFP_KERNEL, "GIC-%d", (int)(gic-&gic_data[0]));
-		gic_init_chip(gic, name, false);
-	}
-
 	ret = gic_init_bases(gic, handle);
-	if (ret)
-		kfree(name);
-	else if (gic == &gic_data[0])
+	if (gic == &gic_data[0])
 		gic_smp_init();
 
 	return ret;
@@ -1459,8 +1467,6 @@ int gic_of_init_child(struct device *dev, struct gic_chip_data **gic, int irq)
 	if (!*gic)
 		return -ENOMEM;
 
-	gic_init_chip(*gic, dev->of_node->name, false);
-
 	ret = gic_of_setup(*gic, dev->of_node);
 	if (ret)
 		return ret;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 04/10] irqchip/lpc32xx: Switch to dynamic chip name output
  2022-02-09 16:25 [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name Marc Zyngier
                   ` (2 preceding siblings ...)
  2022-02-09 16:26 ` [PATCH 03/10] irqchip/gic: Switch to dynamic chip name output Marc Zyngier
@ 2022-02-09 16:26 ` Marc Zyngier
  2022-02-15 12:19   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
  2022-02-09 16:26 ` [PATCH 05/10] irqchip/mvebu-pic: " Marc Zyngier
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 39+ messages in thread
From: Marc Zyngier @ 2022-02-09 16:26 UTC (permalink / raw)
  To: linux-kernel, linux-gpio
  Cc: Linus Walleij, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Emil Renner Berthing,
	kernel-team

Instead of overriding the name field with the device name, use
the relevant callback. This allows us to make the irq_chip structure
const.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/irqchip/irq-lpc32xx.c | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/drivers/irqchip/irq-lpc32xx.c b/drivers/irqchip/irq-lpc32xx.c
index a29357f39450..4d70a857133f 100644
--- a/drivers/irqchip/irq-lpc32xx.c
+++ b/drivers/irqchip/irq-lpc32xx.c
@@ -11,6 +11,7 @@
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
+#include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <asm/exception.h>
 
@@ -25,8 +26,8 @@
 
 struct lpc32xx_irq_chip {
 	void __iomem *base;
+	phys_addr_t addr;
 	struct irq_domain *domain;
-	struct irq_chip chip;
 };
 
 static struct lpc32xx_irq_chip *lpc32xx_mic_irqc;
@@ -118,6 +119,24 @@ static int lpc32xx_irq_set_type(struct irq_data *d, unsigned int type)
 	return 0;
 }
 
+static void lpc32xx_irq_print_chip(struct irq_data *d, struct seq_file *p)
+{
+	struct lpc32xx_irq_chip *ic = irq_data_get_irq_chip_data(d);
+
+	if (ic == lpc32xx_mic_irqc)
+		seq_printf(p, "%08x.mic", ic->addr);
+	else
+		seq_printf(p, "%08x.sic", ic->addr);
+}
+
+static const struct irq_chip lpc32xx_chip = {
+	.irq_ack	= lpc32xx_irq_ack,
+	.irq_mask	= lpc32xx_irq_mask,
+	.irq_unmask	= lpc32xx_irq_unmask,
+	.irq_set_type	= lpc32xx_irq_set_type,
+	.irq_print_chip	= lpc32xx_irq_print_chip,
+};
+
 static void __exception_irq_entry lpc32xx_handle_irq(struct pt_regs *regs)
 {
 	struct lpc32xx_irq_chip *ic = lpc32xx_mic_irqc;
@@ -153,7 +172,7 @@ static int lpc32xx_irq_domain_map(struct irq_domain *id, unsigned int virq,
 	struct lpc32xx_irq_chip *ic = id->host_data;
 
 	irq_set_chip_data(virq, ic);
-	irq_set_chip_and_handler(virq, &ic->chip, handle_level_irq);
+	irq_set_chip_and_handler(virq, &lpc32xx_chip, handle_level_irq);
 	irq_set_status_flags(virq, IRQ_LEVEL);
 	irq_set_noprobe(virq);
 
@@ -183,6 +202,7 @@ static int __init lpc32xx_of_ic_init(struct device_node *node,
 	if (!irqc)
 		return -ENOMEM;
 
+	irqc->addr = addr;
 	irqc->base = of_iomap(node, 0);
 	if (!irqc->base) {
 		pr_err("%pOF: unable to map registers\n", node);
@@ -190,21 +210,11 @@ static int __init lpc32xx_of_ic_init(struct device_node *node,
 		return -EINVAL;
 	}
 
-	irqc->chip.irq_ack = lpc32xx_irq_ack;
-	irqc->chip.irq_mask = lpc32xx_irq_mask;
-	irqc->chip.irq_unmask = lpc32xx_irq_unmask;
-	irqc->chip.irq_set_type = lpc32xx_irq_set_type;
-	if (is_mic)
-		irqc->chip.name = kasprintf(GFP_KERNEL, "%08x.mic", addr);
-	else
-		irqc->chip.name = kasprintf(GFP_KERNEL, "%08x.sic", addr);
-
 	irqc->domain = irq_domain_add_linear(node, NR_LPC32XX_IC_IRQS,
 					     &lpc32xx_irq_domain_ops, irqc);
 	if (!irqc->domain) {
 		pr_err("unable to add irq domain\n");
 		iounmap(irqc->base);
-		kfree(irqc->chip.name);
 		kfree(irqc);
 		return -ENODEV;
 	}
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 05/10] irqchip/mvebu-pic: Switch to dynamic chip name output
  2022-02-09 16:25 [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name Marc Zyngier
                   ` (3 preceding siblings ...)
  2022-02-09 16:26 ` [PATCH 04/10] irqchip/lpc32xx: " Marc Zyngier
@ 2022-02-09 16:26 ` Marc Zyngier
  2022-02-14 14:48   ` Gregory CLEMENT
  2022-02-15 12:19   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
  2022-02-09 16:26 ` [PATCH 06/10] irqchip/ts4800: " Marc Zyngier
                   ` (5 subsequent siblings)
  10 siblings, 2 replies; 39+ messages in thread
From: Marc Zyngier @ 2022-02-09 16:26 UTC (permalink / raw)
  To: linux-kernel, linux-gpio
  Cc: Linus Walleij, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Emil Renner Berthing,
	kernel-team

Instead of overriding the name field, track the corresponding device
and use the relevant callback to output its name.

This allows us to make the irq_chip structure const.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/irqchip/irq-mvebu-pic.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/drivers/irqchip/irq-mvebu-pic.c b/drivers/irqchip/irq-mvebu-pic.c
index 870f9866b8da..ef3d3646ccc2 100644
--- a/drivers/irqchip/irq-mvebu-pic.c
+++ b/drivers/irqchip/irq-mvebu-pic.c
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/of_irq.h>
 #include <linux/platform_device.h>
+#include <linux/seq_file.h>
 
 #define PIC_CAUSE	       0x0
 #define PIC_MASK	       0x4
@@ -29,7 +30,7 @@ struct mvebu_pic {
 	void __iomem *base;
 	u32 parent_irq;
 	struct irq_domain *domain;
-	struct irq_chip irq_chip;
+	struct platform_device *pdev;
 };
 
 static void mvebu_pic_reset(struct mvebu_pic *pic)
@@ -66,6 +67,20 @@ static void mvebu_pic_unmask_irq(struct irq_data *d)
 	writel(reg, pic->base + PIC_MASK);
 }
 
+static void mvebu_pic_print_chip(struct irq_data *d, struct seq_file *p)
+{
+	struct mvebu_pic *pic = irq_data_get_irq_chip_data(d);
+
+	seq_printf(p, dev_name(&pic->pdev->dev));
+}
+
+static const struct irq_chip mvebu_pic_chip = {
+	.irq_mask	= mvebu_pic_mask_irq,
+	.irq_unmask	= mvebu_pic_unmask_irq,
+	.irq_eoi	= mvebu_pic_eoi_irq,
+	.irq_print_chip	= mvebu_pic_print_chip,
+};
+
 static int mvebu_pic_irq_map(struct irq_domain *domain, unsigned int virq,
 			     irq_hw_number_t hwirq)
 {
@@ -73,8 +88,7 @@ static int mvebu_pic_irq_map(struct irq_domain *domain, unsigned int virq,
 
 	irq_set_percpu_devid(virq);
 	irq_set_chip_data(virq, pic);
-	irq_set_chip_and_handler(virq, &pic->irq_chip,
-				 handle_percpu_devid_irq);
+	irq_set_chip_and_handler(virq, &mvebu_pic_chip, handle_percpu_devid_irq);
 	irq_set_status_flags(virq, IRQ_LEVEL);
 	irq_set_probe(virq);
 
@@ -120,22 +134,16 @@ static int mvebu_pic_probe(struct platform_device *pdev)
 {
 	struct device_node *node = pdev->dev.of_node;
 	struct mvebu_pic *pic;
-	struct irq_chip *irq_chip;
 
 	pic = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_pic), GFP_KERNEL);
 	if (!pic)
 		return -ENOMEM;
 
+	pic->pdev = pdev;
 	pic->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(pic->base))
 		return PTR_ERR(pic->base);
 
-	irq_chip = &pic->irq_chip;
-	irq_chip->name = dev_name(&pdev->dev);
-	irq_chip->irq_mask = mvebu_pic_mask_irq;
-	irq_chip->irq_unmask = mvebu_pic_unmask_irq;
-	irq_chip->irq_eoi = mvebu_pic_eoi_irq;
-
 	pic->parent_irq = irq_of_parse_and_map(node, 0);
 	if (pic->parent_irq <= 0) {
 		dev_err(&pdev->dev, "Failed to parse parent interrupt\n");
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 06/10] irqchip/ts4800: Switch to dynamic chip name output
  2022-02-09 16:25 [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name Marc Zyngier
                   ` (4 preceding siblings ...)
  2022-02-09 16:26 ` [PATCH 05/10] irqchip/mvebu-pic: " Marc Zyngier
@ 2022-02-09 16:26 ` Marc Zyngier
  2022-02-15 12:19   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
  2022-02-09 16:26 ` [PATCH 07/10] irqchip/versatile-fpga: " Marc Zyngier
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 39+ messages in thread
From: Marc Zyngier @ 2022-02-09 16:26 UTC (permalink / raw)
  To: linux-kernel, linux-gpio
  Cc: Linus Walleij, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Emil Renner Berthing,
	kernel-team

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/irqchip/irq-ts4800.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/irqchip/irq-ts4800.c b/drivers/irqchip/irq-ts4800.c
index f032db23b30f..b2d61d4f6fe6 100644
--- a/drivers/irqchip/irq-ts4800.c
+++ b/drivers/irqchip/irq-ts4800.c
@@ -19,14 +19,15 @@
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/platform_device.h>
+#include <linux/seq_file.h>
 
 #define IRQ_MASK        0x4
 #define IRQ_STATUS      0x8
 
 struct ts4800_irq_data {
 	void __iomem            *base;
+	struct platform_device	*pdev;
 	struct irq_domain       *domain;
-	struct irq_chip         irq_chip;
 };
 
 static void ts4800_irq_mask(struct irq_data *d)
@@ -47,12 +48,25 @@ static void ts4800_irq_unmask(struct irq_data *d)
 	writew(reg & ~mask, data->base + IRQ_MASK);
 }
 
+static void ts4800_irq_print_chip(struct irq_data *d, struct seq_file *p)
+{
+	struct ts4800_irq_data *data = irq_data_get_irq_chip_data(d);
+
+	seq_printf(p, "%s", dev_name(&data->pdev->dev));
+}
+
+static const struct irq_chip ts4800_chip = {
+	.irq_mask	= ts4800_irq_mask,
+	.irq_unmask	= ts4800_irq_unmask,
+	.irq_print_chip	= ts4800_irq_print_chip,
+};
+
 static int ts4800_irqdomain_map(struct irq_domain *d, unsigned int irq,
 				irq_hw_number_t hwirq)
 {
 	struct ts4800_irq_data *data = d->host_data;
 
-	irq_set_chip_and_handler(irq, &data->irq_chip, handle_simple_irq);
+	irq_set_chip_and_handler(irq, &ts4800_chip, handle_simple_irq);
 	irq_set_chip_data(irq, data);
 	irq_set_noprobe(irq);
 
@@ -92,13 +106,13 @@ static int ts4800_ic_probe(struct platform_device *pdev)
 {
 	struct device_node *node = pdev->dev.of_node;
 	struct ts4800_irq_data *data;
-	struct irq_chip *irq_chip;
 	int parent_irq;
 
 	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
+	data->pdev = pdev;
 	data->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(data->base))
 		return PTR_ERR(data->base);
@@ -111,11 +125,6 @@ static int ts4800_ic_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	irq_chip = &data->irq_chip;
-	irq_chip->name = dev_name(&pdev->dev);
-	irq_chip->irq_mask = ts4800_irq_mask;
-	irq_chip->irq_unmask = ts4800_irq_unmask;
-
 	data->domain = irq_domain_add_linear(node, 8, &ts4800_ic_ops, data);
 	if (!data->domain) {
 		dev_err(&pdev->dev, "cannot add IRQ domain\n");
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 07/10] irqchip/versatile-fpga: Switch to dynamic chip name output
  2022-02-09 16:25 [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name Marc Zyngier
                   ` (5 preceding siblings ...)
  2022-02-09 16:26 ` [PATCH 06/10] irqchip/ts4800: " Marc Zyngier
@ 2022-02-09 16:26 ` Marc Zyngier
  2022-02-10 23:29   ` Linus Walleij
  2022-02-15 12:19   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
  2022-02-09 16:26 ` [PATCH 08/10] gpio: mt7621: " Marc Zyngier
                   ` (3 subsequent siblings)
  10 siblings, 2 replies; 39+ messages in thread
From: Marc Zyngier @ 2022-02-09 16:26 UTC (permalink / raw)
  To: linux-kernel, linux-gpio
  Cc: Linus Walleij, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Emil Renner Berthing,
	kernel-team

Move the name output to the relevant callback, which allows us
some nice cleanups (mostly owing to the fact that the driver is
now DT only.

We also drop a random include directive from the ftintc010 driver.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/irqchip/irq-ftintc010.c        |  1 -
 drivers/irqchip/irq-versatile-fpga.c   | 46 +++++++++++++++-----------
 include/linux/irqchip/versatile-fpga.h | 14 --------
 3 files changed, 26 insertions(+), 35 deletions(-)
 delete mode 100644 include/linux/irqchip/versatile-fpga.h

diff --git a/drivers/irqchip/irq-ftintc010.c b/drivers/irqchip/irq-ftintc010.c
index 5cc268880f8e..46a3aa60e50e 100644
--- a/drivers/irqchip/irq-ftintc010.c
+++ b/drivers/irqchip/irq-ftintc010.c
@@ -11,7 +11,6 @@
 #include <linux/irq.h>
 #include <linux/io.h>
 #include <linux/irqchip.h>
-#include <linux/irqchip/versatile-fpga.h>
 #include <linux/irqdomain.h>
 #include <linux/module.h>
 #include <linux/of.h>
diff --git a/drivers/irqchip/irq-versatile-fpga.c b/drivers/irqchip/irq-versatile-fpga.c
index f2757b6aecc8..ba543ed9c154 100644
--- a/drivers/irqchip/irq-versatile-fpga.c
+++ b/drivers/irqchip/irq-versatile-fpga.c
@@ -7,12 +7,12 @@
 #include <linux/io.h>
 #include <linux/irqchip.h>
 #include <linux/irqchip/chained_irq.h>
-#include <linux/irqchip/versatile-fpga.h>
 #include <linux/irqdomain.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
+#include <linux/seq_file.h>
 
 #include <asm/exception.h>
 #include <asm/mach/irq.h>
@@ -34,14 +34,12 @@
 /**
  * struct fpga_irq_data - irq data container for the FPGA IRQ controller
  * @base: memory offset in virtual memory
- * @chip: chip container for this instance
  * @domain: IRQ domain for this instance
  * @valid: mask for valid IRQs on this controller
  * @used_irqs: number of active IRQs on this controller
  */
 struct fpga_irq_data {
 	void __iomem *base;
-	struct irq_chip chip;
 	u32 valid;
 	struct irq_domain *domain;
 	u8 used_irqs;
@@ -67,6 +65,20 @@ static void fpga_irq_unmask(struct irq_data *d)
 	writel(mask, f->base + IRQ_ENABLE_SET);
 }
 
+static void fpga_irq_print_chip(struct irq_data *d, struct seq_file *p)
+{
+	struct fpga_irq_data *f = irq_data_get_irq_chip_data(d);
+
+	seq_printf(p, irq_domain_get_of_node(f->domain)->name);
+}
+
+static const struct irq_chip fpga_chip = {
+	.irq_ack	= fpga_irq_mask,
+	.irq_mask	= fpga_irq_mask,
+	.irq_unmask	= fpga_irq_unmask,
+	.irq_print_chip	= fpga_irq_print_chip,
+};
+
 static void fpga_irq_handle(struct irq_desc *desc)
 {
 	struct irq_chip *chip = irq_desc_get_chip(desc);
@@ -116,7 +128,7 @@ static int handle_one_fpga(struct fpga_irq_data *f, struct pt_regs *regs)
  * Keep iterating over all registered FPGA IRQ controllers until there are
  * no pending interrupts.
  */
-asmlinkage void __exception_irq_entry fpga_handle_irq(struct pt_regs *regs)
+static asmlinkage void __exception_irq_entry fpga_handle_irq(struct pt_regs *regs)
 {
 	int i, handled;
 
@@ -135,8 +147,7 @@ static int fpga_irqdomain_map(struct irq_domain *d, unsigned int irq,
 	if (!(f->valid & BIT(hwirq)))
 		return -EPERM;
 	irq_set_chip_data(irq, f);
-	irq_set_chip_and_handler(irq, &f->chip,
-				handle_level_irq);
+	irq_set_chip_and_handler(irq, &fpga_chip, handle_level_irq);
 	irq_set_probe(irq);
 	return 0;
 }
@@ -146,8 +157,8 @@ static const struct irq_domain_ops fpga_irqdomain_ops = {
 	.xlate = irq_domain_xlate_onetwocell,
 };
 
-void __init fpga_irq_init(void __iomem *base, const char *name, int irq_start,
-			  int parent_irq, u32 valid, struct device_node *node)
+static void __init fpga_irq_init(void __iomem *base, int parent_irq,
+				 u32 valid, struct device_node *node)
 {
 	struct fpga_irq_data *f;
 	int i;
@@ -158,10 +169,6 @@ void __init fpga_irq_init(void __iomem *base, const char *name, int irq_start,
 	}
 	f = &fpga_irq_devices[fpga_irq_id];
 	f->base = base;
-	f->chip.name = name;
-	f->chip.irq_ack = fpga_irq_mask;
-	f->chip.irq_mask = fpga_irq_mask;
-	f->chip.irq_unmask = fpga_irq_unmask;
 	f->valid = valid;
 
 	if (parent_irq != -1) {
@@ -169,20 +176,19 @@ void __init fpga_irq_init(void __iomem *base, const char *name, int irq_start,
 						 f);
 	}
 
-	/* This will also allocate irq descriptors */
-	f->domain = irq_domain_add_simple(node, fls(valid), irq_start,
+	f->domain = irq_domain_add_linear(node, fls(valid),
 					  &fpga_irqdomain_ops, f);
 
 	/* This will allocate all valid descriptors in the linear case */
 	for (i = 0; i < fls(valid); i++)
 		if (valid & BIT(i)) {
-			if (!irq_start)
-				irq_create_mapping(f->domain, i);
+			/* Is this still required? */
+			irq_create_mapping(f->domain, i);
 			f->used_irqs++;
 		}
 
 	pr_info("FPGA IRQ chip %d \"%s\" @ %p, %u irqs",
-		fpga_irq_id, name, base, f->used_irqs);
+		fpga_irq_id, node->name, base, f->used_irqs);
 	if (parent_irq != -1)
 		pr_cont(", parent IRQ: %d\n", parent_irq);
 	else
@@ -192,8 +198,8 @@ void __init fpga_irq_init(void __iomem *base, const char *name, int irq_start,
 }
 
 #ifdef CONFIG_OF
-int __init fpga_irq_of_init(struct device_node *node,
-			    struct device_node *parent)
+static int __init fpga_irq_of_init(struct device_node *node,
+				   struct device_node *parent)
 {
 	void __iomem *base;
 	u32 clear_mask;
@@ -222,7 +228,7 @@ int __init fpga_irq_of_init(struct device_node *node,
 		parent_irq = -1;
 	}
 
-	fpga_irq_init(base, node->name, 0, parent_irq, valid_mask, node);
+	fpga_irq_init(base, parent_irq, valid_mask, node);
 
 	/*
 	 * On Versatile AB/PB, some secondary interrupts have a direct
diff --git a/include/linux/irqchip/versatile-fpga.h b/include/linux/irqchip/versatile-fpga.h
deleted file mode 100644
index a978fc8c7996..000000000000
--- a/include/linux/irqchip/versatile-fpga.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef PLAT_FPGA_IRQ_H
-#define PLAT_FPGA_IRQ_H
-
-struct device_node;
-struct pt_regs;
-
-void fpga_handle_irq(struct pt_regs *regs);
-void fpga_irq_init(void __iomem *, const char *, int, int, u32,
-		struct device_node *node);
-int fpga_irq_of_init(struct device_node *node,
-		     struct device_node *parent);
-
-#endif
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 08/10] gpio: mt7621: Switch to dynamic chip name output
  2022-02-09 16:25 [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name Marc Zyngier
                   ` (6 preceding siblings ...)
  2022-02-09 16:26 ` [PATCH 07/10] irqchip/versatile-fpga: " Marc Zyngier
@ 2022-02-09 16:26 ` Marc Zyngier
  2022-02-09 16:26 ` [PATCH 09/10] gpio: omap: " Marc Zyngier
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 39+ messages in thread
From: Marc Zyngier @ 2022-02-09 16:26 UTC (permalink / raw)
  To: linux-kernel, linux-gpio
  Cc: Linus Walleij, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Emil Renner Berthing,
	kernel-team

Instead of overloading the name field, use the relevant callback to
output the device name.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/gpio/gpio-mt7621.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-mt7621.c b/drivers/gpio/gpio-mt7621.c
index d8a26e503ca5..14ba4bc141c9 100644
--- a/drivers/gpio/gpio-mt7621.c
+++ b/drivers/gpio/gpio-mt7621.c
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/of_irq.h>
 #include <linux/platform_device.h>
+#include <linux/seq_file.h>
 #include <linux/spinlock.h>
 
 #define MTK_BANK_CNT	3
@@ -188,6 +189,15 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int type)
 	return 0;
 }
 
+static void mediatek_irq_print_chip(struct irq_data *d, struct seq_file *p)
+{
+	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+	struct mtk_gc *rg = to_mediatek_gpio(gc);
+	struct mtk *mtk = container_of(rg - rg->bank, struct mtk, gc_map[0]);
+
+	seq_printf(p, dev_name(mtk->dev));
+}
+
 static int
 mediatek_gpio_xlate(struct gpio_chip *chip,
 		    const struct of_phandle_args *spec, u32 *flags)
@@ -238,11 +248,11 @@ mediatek_gpio_bank_probe(struct device *dev, int bank)
 		return -ENOMEM;
 
 	rg->chip.offset = bank * MTK_BANK_WIDTH;
-	rg->irq_chip.name = dev_name(dev);
 	rg->irq_chip.irq_unmask = mediatek_gpio_irq_unmask;
 	rg->irq_chip.irq_mask = mediatek_gpio_irq_mask;
 	rg->irq_chip.irq_mask_ack = mediatek_gpio_irq_mask;
 	rg->irq_chip.irq_set_type = mediatek_gpio_irq_type;
+	rg->irq_chip.irq_print_chip = mediatek_gpio_irq_print_chip;
 
 	if (mtk->gpio_irq) {
 		struct gpio_irq_chip *girq;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 09/10] gpio: omap: Switch to dynamic chip name output
  2022-02-09 16:25 [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name Marc Zyngier
                   ` (7 preceding siblings ...)
  2022-02-09 16:26 ` [PATCH 08/10] gpio: mt7621: " Marc Zyngier
@ 2022-02-09 16:26 ` Marc Zyngier
  2022-02-09 16:26 ` [PATCH 10/10] pinctrl: starfive: " Marc Zyngier
  2022-02-10 23:41 ` [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name Linus Walleij
  10 siblings, 0 replies; 39+ messages in thread
From: Marc Zyngier @ 2022-02-09 16:26 UTC (permalink / raw)
  To: linux-kernel, linux-gpio
  Cc: Linus Walleij, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Emil Renner Berthing,
	kernel-team

Instead of overloading the name field, use the relevant callback to
output the device name. Take this opportunity to fix the trailing
commas that really should be semi-colons.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/gpio/gpio-omap.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 80ddc43fd875..f2f874f0bf95 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -22,6 +22,7 @@
 #include <linux/pm.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/seq_file.h>
 #include <linux/gpio/driver.h>
 #include <linux/bitops.h>
 #include <linux/platform_data/gpio-omap.h>
@@ -708,6 +709,13 @@ static void omap_gpio_unmask_irq(struct irq_data *d)
 	raw_spin_unlock_irqrestore(&bank->lock, flags);
 }
 
+static void omap_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p)
+{
+	struct gpio_bank *bank = omap_irq_data_get_bank(d);
+
+	seq_printf(p, dev_name(bank->chip.parent));
+}
+
 /*---------------------------------------------------------------------*/
 
 static int omap_mpuio_suspend_noirq(struct device *dev)
@@ -1393,16 +1401,16 @@ static int omap_gpio_probe(struct platform_device *pdev)
 	if (!irqc)
 		return -ENOMEM;
 
-	irqc->irq_startup = omap_gpio_irq_startup,
-	irqc->irq_shutdown = omap_gpio_irq_shutdown,
-	irqc->irq_ack = dummy_irq_chip.irq_ack,
-	irqc->irq_mask = omap_gpio_mask_irq,
-	irqc->irq_unmask = omap_gpio_unmask_irq,
-	irqc->irq_set_type = omap_gpio_irq_type,
-	irqc->irq_set_wake = omap_gpio_wake_enable,
-	irqc->irq_bus_lock = omap_gpio_irq_bus_lock,
-	irqc->irq_bus_sync_unlock = gpio_irq_bus_sync_unlock,
-	irqc->name = dev_name(&pdev->dev);
+	irqc->irq_startup = omap_gpio_irq_startup;
+	irqc->irq_shutdown = omap_gpio_irq_shutdown;
+	irqc->irq_ack = dummy_irq_chip.irq_ack;
+	irqc->irq_mask = omap_gpio_mask_irq;
+	irqc->irq_unmask = omap_gpio_unmask_irq;
+	irqc->irq_set_type = omap_gpio_irq_type;
+	irqc->irq_set_wake = omap_gpio_wake_enable;
+	irqc->irq_bus_lock = omap_gpio_irq_bus_lock;
+	irqc->irq_bus_sync_unlock = gpio_irq_bus_sync_unlock;
+	irqc->irq_print_chip = omap_gpio_irq_print_chip;
 	irqc->flags = IRQCHIP_MASK_ON_SUSPEND;
 
 	bank->irq = platform_get_irq(pdev, 0);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 10/10] pinctrl: starfive: Switch to dynamic chip name output
  2022-02-09 16:25 [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name Marc Zyngier
                   ` (8 preceding siblings ...)
  2022-02-09 16:26 ` [PATCH 09/10] gpio: omap: " Marc Zyngier
@ 2022-02-09 16:26 ` Marc Zyngier
  2022-02-09 23:30   ` Emil Renner Berthing
  2022-02-10 23:41 ` [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name Linus Walleij
  10 siblings, 1 reply; 39+ messages in thread
From: Marc Zyngier @ 2022-02-09 16:26 UTC (permalink / raw)
  To: linux-kernel, linux-gpio
  Cc: Linus Walleij, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Emil Renner Berthing,
	kernel-team

Instead of overloading the name field, use the relevant callback to
output the device name.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/pinctrl/pinctrl-starfive.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-starfive.c b/drivers/pinctrl/pinctrl-starfive.c
index 5be9866c2b3c..f29d9ccf858b 100644
--- a/drivers/pinctrl/pinctrl-starfive.c
+++ b/drivers/pinctrl/pinctrl-starfive.c
@@ -15,6 +15,7 @@
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/reset.h>
+#include <linux/seq_file.h>
 #include <linux/spinlock.h>
 
 #include <linux/pinctrl/pinctrl.h>
@@ -1163,12 +1164,20 @@ static int starfive_irq_set_type(struct irq_data *d, unsigned int trigger)
 	return 0;
 }
 
+static void starfive_irq_print_chip(struct irq_data *d, struct seq_file *p)
+{
+	struct starfive_pinctrl *sfp = starfive_from_irq_data(d);
+
+	seq_printf(p, sfp->gc.label);
+}
+
 static struct irq_chip starfive_irq_chip = {
 	.irq_ack = starfive_irq_ack,
 	.irq_mask = starfive_irq_mask,
 	.irq_mask_ack = starfive_irq_mask_ack,
 	.irq_unmask = starfive_irq_unmask,
 	.irq_set_type = starfive_irq_set_type,
+	.irq_print_chip = starfive_irq_print_chip,
 	.flags = IRQCHIP_SET_TYPE_MASKED,
 };
 
@@ -1307,8 +1316,6 @@ static int starfive_probe(struct platform_device *pdev)
 	sfp->gc.base = -1;
 	sfp->gc.ngpio = NR_GPIOS;
 
-	starfive_irq_chip.name = sfp->gc.label;
-
 	sfp->gc.irq.chip = &starfive_irq_chip;
 	sfp->gc.irq.parent_handler = starfive_gpio_irq_handler;
 	sfp->gc.irq.num_parents = 1;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* Re: [PATCH 10/10] pinctrl: starfive: Switch to dynamic chip name output
  2022-02-09 16:26 ` [PATCH 10/10] pinctrl: starfive: " Marc Zyngier
@ 2022-02-09 23:30   ` Emil Renner Berthing
  2022-02-10  9:06     ` Marc Zyngier
  0 siblings, 1 reply; 39+ messages in thread
From: Emil Renner Berthing @ 2022-02-09 23:30 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Linux Kernel Mailing List, open list:GPIO SUBSYSTEM,
	Linus Walleij, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, kernel-team

On Wed, 9 Feb 2022 at 17:49, Marc Zyngier <maz@kernel.org> wrote:
>
> Instead of overloading the name field, use the relevant callback to
> output the device name.
>
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
>  drivers/pinctrl/pinctrl-starfive.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-starfive.c b/drivers/pinctrl/pinctrl-starfive.c
> index 5be9866c2b3c..f29d9ccf858b 100644
> --- a/drivers/pinctrl/pinctrl-starfive.c
> +++ b/drivers/pinctrl/pinctrl-starfive.c
> @@ -15,6 +15,7 @@
>  #include <linux/of.h>
>  #include <linux/platform_device.h>
>  #include <linux/reset.h>
> +#include <linux/seq_file.h>
>  #include <linux/spinlock.h>
>
>  #include <linux/pinctrl/pinctrl.h>
> @@ -1163,12 +1164,20 @@ static int starfive_irq_set_type(struct irq_data *d, unsigned int trigger)
>         return 0;
>  }
>
> +static void starfive_irq_print_chip(struct irq_data *d, struct seq_file *p)
> +{
> +       struct starfive_pinctrl *sfp = starfive_from_irq_data(d);
> +
> +       seq_printf(p, sfp->gc.label);
> +}
> +
>  static struct irq_chip starfive_irq_chip = {
>         .irq_ack = starfive_irq_ack,
>         .irq_mask = starfive_irq_mask,
>         .irq_mask_ack = starfive_irq_mask_ack,
>         .irq_unmask = starfive_irq_unmask,
>         .irq_set_type = starfive_irq_set_type,
> +       .irq_print_chip = starfive_irq_print_chip,
>         .flags = IRQCHIP_SET_TYPE_MASKED,
>  };

The parent interrupt doesn't show up in /proc/interrupts anyway, so if
setting the name is considered abuse we can just drop the addition
above and just delete the two lines below.

The gpio framework seems to fill in default handlers in the struct
above, so unfortunately it can't yet be made const. Is this something
you intend to fix in the future?

> @@ -1307,8 +1316,6 @@ static int starfive_probe(struct platform_device *pdev)
>         sfp->gc.base = -1;
>         sfp->gc.ngpio = NR_GPIOS;
>
> -       starfive_irq_chip.name = sfp->gc.label;
> -
>         sfp->gc.irq.chip = &starfive_irq_chip;
>         sfp->gc.irq.parent_handler = starfive_gpio_irq_handler;
>         sfp->gc.irq.num_parents = 1;
> --
> 2.30.2
>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 10/10] pinctrl: starfive: Switch to dynamic chip name output
  2022-02-09 23:30   ` Emil Renner Berthing
@ 2022-02-10  9:06     ` Marc Zyngier
  2022-02-10 12:59       ` Emil Renner Berthing
  2022-02-11  0:15       ` Linus Walleij
  0 siblings, 2 replies; 39+ messages in thread
From: Marc Zyngier @ 2022-02-10  9:06 UTC (permalink / raw)
  To: Emil Renner Berthing
  Cc: Linux Kernel Mailing List, open list:GPIO SUBSYSTEM,
	Linus Walleij, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, kernel-team

On Wed, 09 Feb 2022 23:30:55 +0000,
Emil Renner Berthing <kernel@esmil.dk> wrote:
> 
> On Wed, 9 Feb 2022 at 17:49, Marc Zyngier <maz@kernel.org> wrote:
> >
> > Instead of overloading the name field, use the relevant callback to
> > output the device name.
> >
> > Signed-off-by: Marc Zyngier <maz@kernel.org>
> > ---
> >  drivers/pinctrl/pinctrl-starfive.c | 11 +++++++++--
> >  1 file changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/pinctrl/pinctrl-starfive.c b/drivers/pinctrl/pinctrl-starfive.c
> > index 5be9866c2b3c..f29d9ccf858b 100644
> > --- a/drivers/pinctrl/pinctrl-starfive.c
> > +++ b/drivers/pinctrl/pinctrl-starfive.c
> > @@ -15,6 +15,7 @@
> >  #include <linux/of.h>
> >  #include <linux/platform_device.h>
> >  #include <linux/reset.h>
> > +#include <linux/seq_file.h>
> >  #include <linux/spinlock.h>
> >
> >  #include <linux/pinctrl/pinctrl.h>
> > @@ -1163,12 +1164,20 @@ static int starfive_irq_set_type(struct irq_data *d, unsigned int trigger)
> >         return 0;
> >  }
> >
> > +static void starfive_irq_print_chip(struct irq_data *d, struct seq_file *p)
> > +{
> > +       struct starfive_pinctrl *sfp = starfive_from_irq_data(d);
> > +
> > +       seq_printf(p, sfp->gc.label);
> > +}
> > +
> >  static struct irq_chip starfive_irq_chip = {
> >         .irq_ack = starfive_irq_ack,
> >         .irq_mask = starfive_irq_mask,
> >         .irq_mask_ack = starfive_irq_mask_ack,
> >         .irq_unmask = starfive_irq_unmask,
> >         .irq_set_type = starfive_irq_set_type,
> > +       .irq_print_chip = starfive_irq_print_chip,
> >         .flags = IRQCHIP_SET_TYPE_MASKED,
> >  };
> 
> The parent interrupt doesn't show up in /proc/interrupts anyway, so if
> setting the name is considered abuse we can just drop the addition
> above and just delete the two lines below.

Are you sure this never appears? Is there a another irqchip stacked on
top of this one? Could you please dump /sys/kernel/debug/irq/irqs/XX,
where XX is an interrupt number using one of these GPIO pins? Please
run it without this patch, as I just noticed that debugfs blindly
uses the name.

> The gpio framework seems to fill in default handlers in the struct
> above, so unfortunately it can't yet be made const. Is this something
> you intend to fix in the future?

This is next on my list of things to address. The whole 'let's copy a
whole irqchip structure and hijack random pointers' should not have
happened, and it certainly is going to be an interesting ride.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 10/10] pinctrl: starfive: Switch to dynamic chip name output
  2022-02-10  9:06     ` Marc Zyngier
@ 2022-02-10 12:59       ` Emil Renner Berthing
  2022-02-10 13:32         ` Marc Zyngier
  2022-02-11  0:15       ` Linus Walleij
  1 sibling, 1 reply; 39+ messages in thread
From: Emil Renner Berthing @ 2022-02-10 12:59 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Linux Kernel Mailing List, open list:GPIO SUBSYSTEM,
	Linus Walleij, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, kernel-team

On Thu, 10 Feb 2022 at 10:06, Marc Zyngier <maz@kernel.org> wrote:
> On Wed, 09 Feb 2022 23:30:55 +0000,
> Emil Renner Berthing <kernel@esmil.dk> wrote:
> >
> > On Wed, 9 Feb 2022 at 17:49, Marc Zyngier <maz@kernel.org> wrote:
> > >
> > > Instead of overloading the name field, use the relevant callback to
> > > output the device name.
> > >
> > > Signed-off-by: Marc Zyngier <maz@kernel.org>
> > > ---
> > >  drivers/pinctrl/pinctrl-starfive.c | 11 +++++++++--
> > >  1 file changed, 9 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/pinctrl/pinctrl-starfive.c b/drivers/pinctrl/pinctrl-starfive.c
> > > index 5be9866c2b3c..f29d9ccf858b 100644
> > > --- a/drivers/pinctrl/pinctrl-starfive.c
> > > +++ b/drivers/pinctrl/pinctrl-starfive.c
> > > @@ -15,6 +15,7 @@
> > >  #include <linux/of.h>
> > >  #include <linux/platform_device.h>
> > >  #include <linux/reset.h>
> > > +#include <linux/seq_file.h>
> > >  #include <linux/spinlock.h>
> > >
> > >  #include <linux/pinctrl/pinctrl.h>
> > > @@ -1163,12 +1164,20 @@ static int starfive_irq_set_type(struct irq_data *d, unsigned int trigger)
> > >         return 0;
> > >  }
> > >
> > > +static void starfive_irq_print_chip(struct irq_data *d, struct seq_file *p)
> > > +{
> > > +       struct starfive_pinctrl *sfp = starfive_from_irq_data(d);
> > > +
> > > +       seq_printf(p, sfp->gc.label);
> > > +}
> > > +
> > >  static struct irq_chip starfive_irq_chip = {
> > >         .irq_ack = starfive_irq_ack,
> > >         .irq_mask = starfive_irq_mask,
> > >         .irq_mask_ack = starfive_irq_mask_ack,
> > >         .irq_unmask = starfive_irq_unmask,
> > >         .irq_set_type = starfive_irq_set_type,
> > > +       .irq_print_chip = starfive_irq_print_chip,
> > >         .flags = IRQCHIP_SET_TYPE_MASKED,
> > >  };
> >
> > The parent interrupt doesn't show up in /proc/interrupts anyway, so if
> > setting the name is considered abuse we can just drop the addition
> > above and just delete the two lines below.
>
> Are you sure this never appears? Is there a another irqchip stacked on
> top of this one? Could you please dump /sys/kernel/debug/irq/irqs/XX,
> where XX is an interrupt number using one of these GPIO pins? Please
> run it without this patch, as I just noticed that debugfs blindly
> uses the name.

Yes, the old gpio driver this derives from used to set
    sfp->gc.irq.parent_handler = NULL
and then register its own irq handler, then the parent would show up
in /proc/interrupts. But after switching to letting the gpio framework
register the handler it stopped showing up.

root@visionfive~# cat /proc/interrupts
           CPU0       CPU1
  5:       5035       4907  RISC-V INTC   5 Edge      riscv-timer
  6:        960          0  SiFive PLIC   4 Edge      dw-mci
  7:       4384          0  SiFive PLIC   5 Edge      dw-mci
  8:        562          0  SiFive PLIC   6 Edge      eth0
 10:          1          0  SiFive PLIC   7 Edge      eth0
 11:          0          0  SiFive PLIC   2 Edge      dw_axi_dmac_platform
 15:       2690          0  SiFive PLIC  44 Edge      xhci-hcd:usb1
 17:          0          0  SiFive PLIC  43 Edge      104c0000.usb
 18:          0          0  SiFive PLIC   1 Edge      dw_axi_dmac_platform
 20:        234          0  SiFive PLIC  96 Edge      118b0000.i2c
 21:          0          0  SiFive PLIC  97 Edge      118c0000.i2c
 22:          7          0  SiFive PLIC  98 Edge      118d0000.trng
 28:          0          0  SiFive PLIC 101 Edge      sf_lcdc
 29:          0          0  SiFive PLIC 103 Edge      sf_vpp1
 30:          0          0  SiFive PLIC  70 Edge      12410000.spi
 31:        205          0  SiFive PLIC  73 Edge      ttyS0
 32:          0          0  SiFive PLIC  74 Edge      12450000.i2c
 33:          0          0  SiFive PLIC  80 Edge      12480000.watchdog
 34:         28          0  SiFive PLIC 122 Edge      124a0000.tmon
 37:          0          0  11910000.pinctrl  35 Edge      gpiomon
IPI0:        52        133  Rescheduling interrupts
IPI1:      2591       6924  Function call interrupts
IPI2:         0          0  CPU stop interrupts
IPI3:         0          0  IRQ work interrupts
IPI4:         0          0  Timer broadcast interrupts
root@visionfive~# cat /sys/kernel/debug/irq/irqs/26
handler:  starfive_gpio_irq_handler
device:   (null)
status:   0x00010c00
            _IRQ_NOPROBE
            _IRQ_NOREQUEST
            _IRQ_NOTHREAD
istate:   0x00000000
ddepth:   0
wdepth:   0
dstate:   0x02401200
            IRQD_ACTIVATED
            IRQD_IRQ_STARTED
            IRQD_AFFINITY_SET
            IRQD_DEFAULT_TRIGGER_SET
node:     0
affinity: 0-1
domain:  :soc:interrupt-controller@c000000
 hwirq:   0x20
 chip:    SiFive PLIC
  flags:   0x0
root@visionfive~# cat /sys/kernel/debug/irq/irqs/37
handler:  handle_edge_irq
device:   (null)
status:   0x00000403
            _IRQ_NOPROBE
istate:   0x00000020
            IRQS_ONESHOT
ddepth:   0
wdepth:   0
dstate:   0x00400203
            IRQ_TYPE_EDGE_RISING
            IRQ_TYPE_EDGE_FALLING
            IRQD_ACTIVATED
            IRQD_IRQ_STARTED
node:     0
affinity: 0-1
domain:  :soc:pinctrl@11910000
 hwirq:   0x23
 chip:    11910000.pinctrl
  flags:   0x1
             IRQCHIP_SET_TYPE_MASKED

> > The gpio framework seems to fill in default handlers in the struct
> > above, so unfortunately it can't yet be made const. Is this something
> > you intend to fix in the future?
>
> This is next on my list of things to address. The whole 'let's copy a
> whole irqchip structure and hijack random pointers' should not have
> happened, and it certainly is going to be an interesting ride.

Sounds great, thanks.

/Emil

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 10/10] pinctrl: starfive: Switch to dynamic chip name output
  2022-02-10 12:59       ` Emil Renner Berthing
@ 2022-02-10 13:32         ` Marc Zyngier
  2022-02-10 13:44           ` Emil Renner Berthing
  0 siblings, 1 reply; 39+ messages in thread
From: Marc Zyngier @ 2022-02-10 13:32 UTC (permalink / raw)
  To: Emil Renner Berthing
  Cc: Linux Kernel Mailing List, open list:GPIO SUBSYSTEM,
	Linus Walleij, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, kernel-team

On Thu, 10 Feb 2022 12:59:59 +0000,
Emil Renner Berthing <kernel@esmil.dk> wrote:
> 
> On Thu, 10 Feb 2022 at 10:06, Marc Zyngier <maz@kernel.org> wrote:
> > On Wed, 09 Feb 2022 23:30:55 +0000,
> > Emil Renner Berthing <kernel@esmil.dk> wrote:
> > >
> > > On Wed, 9 Feb 2022 at 17:49, Marc Zyngier <maz@kernel.org> wrote:
> > > >
> > > > Instead of overloading the name field, use the relevant callback to
> > > > output the device name.
> > > >
> > > > Signed-off-by: Marc Zyngier <maz@kernel.org>
> > > > ---
> > > >  drivers/pinctrl/pinctrl-starfive.c | 11 +++++++++--
> > > >  1 file changed, 9 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/pinctrl/pinctrl-starfive.c b/drivers/pinctrl/pinctrl-starfive.c
> > > > index 5be9866c2b3c..f29d9ccf858b 100644
> > > > --- a/drivers/pinctrl/pinctrl-starfive.c
> > > > +++ b/drivers/pinctrl/pinctrl-starfive.c
> > > > @@ -15,6 +15,7 @@
> > > >  #include <linux/of.h>
> > > >  #include <linux/platform_device.h>
> > > >  #include <linux/reset.h>
> > > > +#include <linux/seq_file.h>
> > > >  #include <linux/spinlock.h>
> > > >
> > > >  #include <linux/pinctrl/pinctrl.h>
> > > > @@ -1163,12 +1164,20 @@ static int starfive_irq_set_type(struct irq_data *d, unsigned int trigger)
> > > >         return 0;
> > > >  }
> > > >
> > > > +static void starfive_irq_print_chip(struct irq_data *d, struct seq_file *p)
> > > > +{
> > > > +       struct starfive_pinctrl *sfp = starfive_from_irq_data(d);
> > > > +
> > > > +       seq_printf(p, sfp->gc.label);
> > > > +}
> > > > +
> > > >  static struct irq_chip starfive_irq_chip = {
> > > >         .irq_ack = starfive_irq_ack,
> > > >         .irq_mask = starfive_irq_mask,
> > > >         .irq_mask_ack = starfive_irq_mask_ack,
> > > >         .irq_unmask = starfive_irq_unmask,
> > > >         .irq_set_type = starfive_irq_set_type,
> > > > +       .irq_print_chip = starfive_irq_print_chip,
> > > >         .flags = IRQCHIP_SET_TYPE_MASKED,
> > > >  };
> > >
> > > The parent interrupt doesn't show up in /proc/interrupts anyway, so if
> > > setting the name is considered abuse we can just drop the addition
> > > above and just delete the two lines below.
> >
> > Are you sure this never appears? Is there a another irqchip stacked on
> > top of this one? Could you please dump /sys/kernel/debug/irq/irqs/XX,
> > where XX is an interrupt number using one of these GPIO pins? Please
> > run it without this patch, as I just noticed that debugfs blindly
> > uses the name.
> 
> Yes, the old gpio driver this derives from used to set
>     sfp->gc.irq.parent_handler = NULL
> and then register its own irq handler, then the parent would show up
> in /proc/interrupts. But after switching to letting the gpio framework
> register the handler it stopped showing up.

But this patch does not deal with the parent interrupt. It deals with
the irqchip that is used for the 'children interrupt'. Output
interrupts for a chained handler are never shown, as they don't really
make much sense on their own (you'd only see the sum of the input
interrupts).

> 
> root@visionfive~# cat /proc/interrupts
>            CPU0       CPU1
>   5:       5035       4907  RISC-V INTC   5 Edge      riscv-timer
>   6:        960          0  SiFive PLIC   4 Edge      dw-mci
>   7:       4384          0  SiFive PLIC   5 Edge      dw-mci
>   8:        562          0  SiFive PLIC   6 Edge      eth0
>  10:          1          0  SiFive PLIC   7 Edge      eth0
>  11:          0          0  SiFive PLIC   2 Edge      dw_axi_dmac_platform
>  15:       2690          0  SiFive PLIC  44 Edge      xhci-hcd:usb1
>  17:          0          0  SiFive PLIC  43 Edge      104c0000.usb
>  18:          0          0  SiFive PLIC   1 Edge      dw_axi_dmac_platform
>  20:        234          0  SiFive PLIC  96 Edge      118b0000.i2c
>  21:          0          0  SiFive PLIC  97 Edge      118c0000.i2c
>  22:          7          0  SiFive PLIC  98 Edge      118d0000.trng
>  28:          0          0  SiFive PLIC 101 Edge      sf_lcdc
>  29:          0          0  SiFive PLIC 103 Edge      sf_vpp1
>  30:          0          0  SiFive PLIC  70 Edge      12410000.spi
>  31:        205          0  SiFive PLIC  73 Edge      ttyS0
>  32:          0          0  SiFive PLIC  74 Edge      12450000.i2c
>  33:          0          0  SiFive PLIC  80 Edge      12480000.watchdog
>  34:         28          0  SiFive PLIC 122 Edge      124a0000.tmon
>  37:          0          0  11910000.pinctrl  35 Edge      gpiomon
                              ^^^^^^^^^^^^^^^^
This is what this patch deals with. Going with your suggestion of
dropping this output (or to hardcode it to something else) would be a
userspace visible change, and we can't do that.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 10/10] pinctrl: starfive: Switch to dynamic chip name output
  2022-02-10 13:32         ` Marc Zyngier
@ 2022-02-10 13:44           ` Emil Renner Berthing
  2022-02-10 13:50             ` Marc Zyngier
  0 siblings, 1 reply; 39+ messages in thread
From: Emil Renner Berthing @ 2022-02-10 13:44 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Linux Kernel Mailing List, open list:GPIO SUBSYSTEM,
	Linus Walleij, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, kernel-team

On Thu, 10 Feb 2022 at 14:32, Marc Zyngier <maz@kernel.org> wrote:
> On Thu, 10 Feb 2022 12:59:59 +0000,
> Emil Renner Berthing <kernel@esmil.dk> wrote:
> >
> > On Thu, 10 Feb 2022 at 10:06, Marc Zyngier <maz@kernel.org> wrote:
> > > On Wed, 09 Feb 2022 23:30:55 +0000,
> > > Emil Renner Berthing <kernel@esmil.dk> wrote:
> > > >
> > > > On Wed, 9 Feb 2022 at 17:49, Marc Zyngier <maz@kernel.org> wrote:
> > > > >
> > > > > Instead of overloading the name field, use the relevant callback to
> > > > > output the device name.
> > > > >
> > > > > Signed-off-by: Marc Zyngier <maz@kernel.org>
> > > > > ---
> > > > >  drivers/pinctrl/pinctrl-starfive.c | 11 +++++++++--
> > > > >  1 file changed, 9 insertions(+), 2 deletions(-)
> > > > >
> > > > > diff --git a/drivers/pinctrl/pinctrl-starfive.c b/drivers/pinctrl/pinctrl-starfive.c
> > > > > index 5be9866c2b3c..f29d9ccf858b 100644
> > > > > --- a/drivers/pinctrl/pinctrl-starfive.c
> > > > > +++ b/drivers/pinctrl/pinctrl-starfive.c
> > > > > @@ -15,6 +15,7 @@
> > > > >  #include <linux/of.h>
> > > > >  #include <linux/platform_device.h>
> > > > >  #include <linux/reset.h>
> > > > > +#include <linux/seq_file.h>
> > > > >  #include <linux/spinlock.h>
> > > > >
> > > > >  #include <linux/pinctrl/pinctrl.h>
> > > > > @@ -1163,12 +1164,20 @@ static int starfive_irq_set_type(struct irq_data *d, unsigned int trigger)
> > > > >         return 0;
> > > > >  }
> > > > >
> > > > > +static void starfive_irq_print_chip(struct irq_data *d, struct seq_file *p)
> > > > > +{
> > > > > +       struct starfive_pinctrl *sfp = starfive_from_irq_data(d);
> > > > > +
> > > > > +       seq_printf(p, sfp->gc.label);
> > > > > +}
> > > > > +
> > > > >  static struct irq_chip starfive_irq_chip = {
> > > > >         .irq_ack = starfive_irq_ack,
> > > > >         .irq_mask = starfive_irq_mask,
> > > > >         .irq_mask_ack = starfive_irq_mask_ack,
> > > > >         .irq_unmask = starfive_irq_unmask,
> > > > >         .irq_set_type = starfive_irq_set_type,
> > > > > +       .irq_print_chip = starfive_irq_print_chip,
> > > > >         .flags = IRQCHIP_SET_TYPE_MASKED,
> > > > >  };
> > > >
> > > > The parent interrupt doesn't show up in /proc/interrupts anyway, so if
> > > > setting the name is considered abuse we can just drop the addition
> > > > above and just delete the two lines below.
> > >
> > > Are you sure this never appears? Is there a another irqchip stacked on
> > > top of this one? Could you please dump /sys/kernel/debug/irq/irqs/XX,
> > > where XX is an interrupt number using one of these GPIO pins? Please
> > > run it without this patch, as I just noticed that debugfs blindly
> > > uses the name.
> >
> > Yes, the old gpio driver this derives from used to set
> >     sfp->gc.irq.parent_handler = NULL
> > and then register its own irq handler, then the parent would show up
> > in /proc/interrupts. But after switching to letting the gpio framework
> > register the handler it stopped showing up.
>
> But this patch does not deal with the parent interrupt. It deals with
> the irqchip that is used for the 'children interrupt'. Output
> interrupts for a chained handler are never shown, as they don't really
> make much sense on their own (you'd only see the sum of the input
> interrupts).

I see. Sorry for the confusion.

> >
> > root@visionfive~# cat /proc/interrupts
> >            CPU0       CPU1
> >   5:       5035       4907  RISC-V INTC   5 Edge      riscv-timer
> >   6:        960          0  SiFive PLIC   4 Edge      dw-mci
> >   7:       4384          0  SiFive PLIC   5 Edge      dw-mci
> >   8:        562          0  SiFive PLIC   6 Edge      eth0
> >  10:          1          0  SiFive PLIC   7 Edge      eth0
> >  11:          0          0  SiFive PLIC   2 Edge      dw_axi_dmac_platform
> >  15:       2690          0  SiFive PLIC  44 Edge      xhci-hcd:usb1
> >  17:          0          0  SiFive PLIC  43 Edge      104c0000.usb
> >  18:          0          0  SiFive PLIC   1 Edge      dw_axi_dmac_platform
> >  20:        234          0  SiFive PLIC  96 Edge      118b0000.i2c
> >  21:          0          0  SiFive PLIC  97 Edge      118c0000.i2c
> >  22:          7          0  SiFive PLIC  98 Edge      118d0000.trng
> >  28:          0          0  SiFive PLIC 101 Edge      sf_lcdc
> >  29:          0          0  SiFive PLIC 103 Edge      sf_vpp1
> >  30:          0          0  SiFive PLIC  70 Edge      12410000.spi
> >  31:        205          0  SiFive PLIC  73 Edge      ttyS0
> >  32:          0          0  SiFive PLIC  74 Edge      12450000.i2c
> >  33:          0          0  SiFive PLIC  80 Edge      12480000.watchdog
> >  34:         28          0  SiFive PLIC 122 Edge      124a0000.tmon
> >  37:          0          0  11910000.pinctrl  35 Edge      gpiomon
>                               ^^^^^^^^^^^^^^^^
> This is what this patch deals with. Going with your suggestion of
> dropping this output (or to hardcode it to something else) would be a
> userspace visible change, and we can't do that.

Gotcha. The SoC has been out in very few numbers for less than a year
and the driver only entered mainline in 5.17-rc1, so I doubt anyone
has had time to write scripts that check for this, but I'll let it be
up to you.

Reviewed-by: Emil Renner Berthing <kernel@esmil.dk>
Tested-by: Emil Renner Berthing <kernel@esmil.dk>

Thanks.
/Emil

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 10/10] pinctrl: starfive: Switch to dynamic chip name output
  2022-02-10 13:44           ` Emil Renner Berthing
@ 2022-02-10 13:50             ` Marc Zyngier
  2022-02-10 14:14               ` Emil Renner Berthing
  0 siblings, 1 reply; 39+ messages in thread
From: Marc Zyngier @ 2022-02-10 13:50 UTC (permalink / raw)
  To: Emil Renner Berthing
  Cc: Linux Kernel Mailing List, open list:GPIO SUBSYSTEM,
	Linus Walleij, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, kernel-team

On Thu, 10 Feb 2022 13:44:12 +0000,
Emil Renner Berthing <kernel@esmil.dk> wrote:
> 
> On Thu, 10 Feb 2022 at 14:32, Marc Zyngier <maz@kernel.org> wrote:
> > On Thu, 10 Feb 2022 12:59:59 +0000,
> > Emil Renner Berthing <kernel@esmil.dk> wrote:
> > >
> > > On Thu, 10 Feb 2022 at 10:06, Marc Zyngier <maz@kernel.org> wrote:
> > > > On Wed, 09 Feb 2022 23:30:55 +0000,
> > > > Emil Renner Berthing <kernel@esmil.dk> wrote:
> > > > >
> > > > > On Wed, 9 Feb 2022 at 17:49, Marc Zyngier <maz@kernel.org> wrote:
> > > > > >
> > > > > > Instead of overloading the name field, use the relevant callback to
> > > > > > output the device name.
> > > > > >
> > > > > > Signed-off-by: Marc Zyngier <maz@kernel.org>
> > > > > > ---
> > > > > >  drivers/pinctrl/pinctrl-starfive.c | 11 +++++++++--
> > > > > >  1 file changed, 9 insertions(+), 2 deletions(-)
> > > > > >
> > > > > > diff --git a/drivers/pinctrl/pinctrl-starfive.c b/drivers/pinctrl/pinctrl-starfive.c
> > > > > > index 5be9866c2b3c..f29d9ccf858b 100644
> > > > > > --- a/drivers/pinctrl/pinctrl-starfive.c
> > > > > > +++ b/drivers/pinctrl/pinctrl-starfive.c
> > > > > > @@ -15,6 +15,7 @@
> > > > > >  #include <linux/of.h>
> > > > > >  #include <linux/platform_device.h>
> > > > > >  #include <linux/reset.h>
> > > > > > +#include <linux/seq_file.h>
> > > > > >  #include <linux/spinlock.h>
> > > > > >
> > > > > >  #include <linux/pinctrl/pinctrl.h>
> > > > > > @@ -1163,12 +1164,20 @@ static int starfive_irq_set_type(struct irq_data *d, unsigned int trigger)
> > > > > >         return 0;
> > > > > >  }
> > > > > >
> > > > > > +static void starfive_irq_print_chip(struct irq_data *d, struct seq_file *p)
> > > > > > +{
> > > > > > +       struct starfive_pinctrl *sfp = starfive_from_irq_data(d);
> > > > > > +
> > > > > > +       seq_printf(p, sfp->gc.label);
> > > > > > +}
> > > > > > +
> > > > > >  static struct irq_chip starfive_irq_chip = {
> > > > > >         .irq_ack = starfive_irq_ack,
> > > > > >         .irq_mask = starfive_irq_mask,
> > > > > >         .irq_mask_ack = starfive_irq_mask_ack,
> > > > > >         .irq_unmask = starfive_irq_unmask,
> > > > > >         .irq_set_type = starfive_irq_set_type,
> > > > > > +       .irq_print_chip = starfive_irq_print_chip,
> > > > > >         .flags = IRQCHIP_SET_TYPE_MASKED,
> > > > > >  };
> > > > >
> > > > > The parent interrupt doesn't show up in /proc/interrupts anyway, so if
> > > > > setting the name is considered abuse we can just drop the addition
> > > > > above and just delete the two lines below.
> > > >
> > > > Are you sure this never appears? Is there a another irqchip stacked on
> > > > top of this one? Could you please dump /sys/kernel/debug/irq/irqs/XX,
> > > > where XX is an interrupt number using one of these GPIO pins? Please
> > > > run it without this patch, as I just noticed that debugfs blindly
> > > > uses the name.
> > >
> > > Yes, the old gpio driver this derives from used to set
> > >     sfp->gc.irq.parent_handler = NULL
> > > and then register its own irq handler, then the parent would show up
> > > in /proc/interrupts. But after switching to letting the gpio framework
> > > register the handler it stopped showing up.
> >
> > But this patch does not deal with the parent interrupt. It deals with
> > the irqchip that is used for the 'children interrupt'. Output
> > interrupts for a chained handler are never shown, as they don't really
> > make much sense on their own (you'd only see the sum of the input
> > interrupts).
> 
> I see. Sorry for the confusion.
> 
> > >
> > > root@visionfive~# cat /proc/interrupts
> > >            CPU0       CPU1
> > >   5:       5035       4907  RISC-V INTC   5 Edge      riscv-timer
> > >   6:        960          0  SiFive PLIC   4 Edge      dw-mci
> > >   7:       4384          0  SiFive PLIC   5 Edge      dw-mci
> > >   8:        562          0  SiFive PLIC   6 Edge      eth0
> > >  10:          1          0  SiFive PLIC   7 Edge      eth0
> > >  11:          0          0  SiFive PLIC   2 Edge      dw_axi_dmac_platform
> > >  15:       2690          0  SiFive PLIC  44 Edge      xhci-hcd:usb1
> > >  17:          0          0  SiFive PLIC  43 Edge      104c0000.usb
> > >  18:          0          0  SiFive PLIC   1 Edge      dw_axi_dmac_platform
> > >  20:        234          0  SiFive PLIC  96 Edge      118b0000.i2c
> > >  21:          0          0  SiFive PLIC  97 Edge      118c0000.i2c
> > >  22:          7          0  SiFive PLIC  98 Edge      118d0000.trng
> > >  28:          0          0  SiFive PLIC 101 Edge      sf_lcdc
> > >  29:          0          0  SiFive PLIC 103 Edge      sf_vpp1
> > >  30:          0          0  SiFive PLIC  70 Edge      12410000.spi
> > >  31:        205          0  SiFive PLIC  73 Edge      ttyS0
> > >  32:          0          0  SiFive PLIC  74 Edge      12450000.i2c
> > >  33:          0          0  SiFive PLIC  80 Edge      12480000.watchdog
> > >  34:         28          0  SiFive PLIC 122 Edge      124a0000.tmon
> > >  37:          0          0  11910000.pinctrl  35 Edge      gpiomon
> >                               ^^^^^^^^^^^^^^^^
> > This is what this patch deals with. Going with your suggestion of
> > dropping this output (or to hardcode it to something else) would be a
> > userspace visible change, and we can't do that.
> 
> Gotcha. The SoC has been out in very few numbers for less than a year
> and the driver only entered mainline in 5.17-rc1, so I doubt anyone
> has had time to write scripts that check for this, but I'll let it be
> up to you.

Ah, I should have checked that. In which case, would you be OK if I
simply pushed the removal of this label as a fix for 5.17, and just
have it to say "Star5 GPIO", for example, without any indication of
the device (which appears in debugfs anyway as part of the irqdomain)?

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 10/10] pinctrl: starfive: Switch to dynamic chip name output
  2022-02-10 13:50             ` Marc Zyngier
@ 2022-02-10 14:14               ` Emil Renner Berthing
  2022-02-10 14:22                 ` Marc Zyngier, Linus Walleij
  2022-02-10 14:34                 ` Marc Zyngier
  0 siblings, 2 replies; 39+ messages in thread
From: Emil Renner Berthing @ 2022-02-10 14:14 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Linux Kernel Mailing List, open list:GPIO SUBSYSTEM,
	Linus Walleij, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, kernel-team

On Thu, 10 Feb 2022 at 14:50, Marc Zyngier <maz@kernel.org> wrote:
> On Thu, 10 Feb 2022 13:44:12 +0000,
> Emil Renner Berthing <kernel@esmil.dk> wrote:
> >
> > On Thu, 10 Feb 2022 at 14:32, Marc Zyngier <maz@kernel.org> wrote:
> > > On Thu, 10 Feb 2022 12:59:59 +0000,
> > > Emil Renner Berthing <kernel@esmil.dk> wrote:
> > > >
> > > > On Thu, 10 Feb 2022 at 10:06, Marc Zyngier <maz@kernel.org> wrote:
> > > > > On Wed, 09 Feb 2022 23:30:55 +0000,
> > > > > Emil Renner Berthing <kernel@esmil.dk> wrote:
> > > > > >
> > > > > > On Wed, 9 Feb 2022 at 17:49, Marc Zyngier <maz@kernel.org> wrote:
> > > > > > >
> > > > > > > Instead of overloading the name field, use the relevant callback to
> > > > > > > output the device name.
> > > > > > >
> > > > > > > Signed-off-by: Marc Zyngier <maz@kernel.org>
> > > > > > > ---
> > > > > > >  drivers/pinctrl/pinctrl-starfive.c | 11 +++++++++--
> > > > > > >  1 file changed, 9 insertions(+), 2 deletions(-)
> > > > > > >
> > > > > > > diff --git a/drivers/pinctrl/pinctrl-starfive.c b/drivers/pinctrl/pinctrl-starfive.c
> > > > > > > index 5be9866c2b3c..f29d9ccf858b 100644
> > > > > > > --- a/drivers/pinctrl/pinctrl-starfive.c
> > > > > > > +++ b/drivers/pinctrl/pinctrl-starfive.c
> > > > > > > @@ -15,6 +15,7 @@
> > > > > > >  #include <linux/of.h>
> > > > > > >  #include <linux/platform_device.h>
> > > > > > >  #include <linux/reset.h>
> > > > > > > +#include <linux/seq_file.h>
> > > > > > >  #include <linux/spinlock.h>
> > > > > > >
> > > > > > >  #include <linux/pinctrl/pinctrl.h>
> > > > > > > @@ -1163,12 +1164,20 @@ static int starfive_irq_set_type(struct irq_data *d, unsigned int trigger)
> > > > > > >         return 0;
> > > > > > >  }
> > > > > > >
> > > > > > > +static void starfive_irq_print_chip(struct irq_data *d, struct seq_file *p)
> > > > > > > +{
> > > > > > > +       struct starfive_pinctrl *sfp = starfive_from_irq_data(d);
> > > > > > > +
> > > > > > > +       seq_printf(p, sfp->gc.label);
> > > > > > > +}
> > > > > > > +
> > > > > > >  static struct irq_chip starfive_irq_chip = {
> > > > > > >         .irq_ack = starfive_irq_ack,
> > > > > > >         .irq_mask = starfive_irq_mask,
> > > > > > >         .irq_mask_ack = starfive_irq_mask_ack,
> > > > > > >         .irq_unmask = starfive_irq_unmask,
> > > > > > >         .irq_set_type = starfive_irq_set_type,
> > > > > > > +       .irq_print_chip = starfive_irq_print_chip,
> > > > > > >         .flags = IRQCHIP_SET_TYPE_MASKED,
> > > > > > >  };
> > > > > >
> > > > > > The parent interrupt doesn't show up in /proc/interrupts anyway, so if
> > > > > > setting the name is considered abuse we can just drop the addition
> > > > > > above and just delete the two lines below.
> > > > >
> > > > > Are you sure this never appears? Is there a another irqchip stacked on
> > > > > top of this one? Could you please dump /sys/kernel/debug/irq/irqs/XX,
> > > > > where XX is an interrupt number using one of these GPIO pins? Please
> > > > > run it without this patch, as I just noticed that debugfs blindly
> > > > > uses the name.
> > > >
> > > > Yes, the old gpio driver this derives from used to set
> > > >     sfp->gc.irq.parent_handler = NULL
> > > > and then register its own irq handler, then the parent would show up
> > > > in /proc/interrupts. But after switching to letting the gpio framework
> > > > register the handler it stopped showing up.
> > >
> > > But this patch does not deal with the parent interrupt. It deals with
> > > the irqchip that is used for the 'children interrupt'. Output
> > > interrupts for a chained handler are never shown, as they don't really
> > > make much sense on their own (you'd only see the sum of the input
> > > interrupts).
> >
> > I see. Sorry for the confusion.
> >
> > > >
> > > > root@visionfive~# cat /proc/interrupts
> > > >            CPU0       CPU1
> > > >   5:       5035       4907  RISC-V INTC   5 Edge      riscv-timer
> > > >   6:        960          0  SiFive PLIC   4 Edge      dw-mci
> > > >   7:       4384          0  SiFive PLIC   5 Edge      dw-mci
> > > >   8:        562          0  SiFive PLIC   6 Edge      eth0
> > > >  10:          1          0  SiFive PLIC   7 Edge      eth0
> > > >  11:          0          0  SiFive PLIC   2 Edge      dw_axi_dmac_platform
> > > >  15:       2690          0  SiFive PLIC  44 Edge      xhci-hcd:usb1
> > > >  17:          0          0  SiFive PLIC  43 Edge      104c0000.usb
> > > >  18:          0          0  SiFive PLIC   1 Edge      dw_axi_dmac_platform
> > > >  20:        234          0  SiFive PLIC  96 Edge      118b0000.i2c
> > > >  21:          0          0  SiFive PLIC  97 Edge      118c0000.i2c
> > > >  22:          7          0  SiFive PLIC  98 Edge      118d0000.trng
> > > >  28:          0          0  SiFive PLIC 101 Edge      sf_lcdc
> > > >  29:          0          0  SiFive PLIC 103 Edge      sf_vpp1
> > > >  30:          0          0  SiFive PLIC  70 Edge      12410000.spi
> > > >  31:        205          0  SiFive PLIC  73 Edge      ttyS0
> > > >  32:          0          0  SiFive PLIC  74 Edge      12450000.i2c
> > > >  33:          0          0  SiFive PLIC  80 Edge      12480000.watchdog
> > > >  34:         28          0  SiFive PLIC 122 Edge      124a0000.tmon
> > > >  37:          0          0  11910000.pinctrl  35 Edge      gpiomon
> > >                               ^^^^^^^^^^^^^^^^
> > > This is what this patch deals with. Going with your suggestion of
> > > dropping this output (or to hardcode it to something else) would be a
> > > userspace visible change, and we can't do that.
> >
> > Gotcha. The SoC has been out in very few numbers for less than a year
> > and the driver only entered mainline in 5.17-rc1, so I doubt anyone
> > has had time to write scripts that check for this, but I'll let it be
> > up to you.
>
> Ah, I should have checked that. In which case, would you be OK if I
> simply pushed the removal of this label as a fix for 5.17, and just
> have it to say "Star5 GPIO", for example, without any indication of
> the device (which appears in debugfs anyway as part of the irqdomain)?

I'm fine with it although I'd prefer "StarFive GPIO". I haven't seen
star5 used anywhere.
But shouldn't changes like this normally go through Linus Walleij's tree?

/Emil

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 10/10] pinctrl: starfive: Switch to dynamic chip name output
  2022-02-10 14:14               ` Emil Renner Berthing
@ 2022-02-10 14:22                 ` Marc Zyngier, Linus Walleij
  2022-02-10 14:34                 ` Marc Zyngier
  1 sibling, 0 replies; 39+ messages in thread
From: Marc Zyngier, Linus Walleij @ 2022-02-10 14:22 UTC (permalink / raw)
  To: Emil Renner Berthing
  Cc: Linux Kernel Mailing List, open list:GPIO SUBSYSTEM,
	Bartosz Golaszewski, Matthias Brugger, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Tony Lindgren, Thomas Gleixner,
	Vladimir Zapolskiy, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, kernel-team

On Thu, 10 Feb 2022 14:14:19 +0000,
Emil Renner Berthing <kernel@esmil.dk> wrote:
> 
> On Thu, 10 Feb 2022 at 14:50, Marc Zyngier <maz@kernel.org> wrote:
> > On Thu, 10 Feb 2022 13:44:12 +0000,
> > Emil Renner Berthing <kernel@esmil.dk> wrote:
> > >
> > > Gotcha. The SoC has been out in very few numbers for less than a year
> > > and the driver only entered mainline in 5.17-rc1, so I doubt anyone
> > > has had time to write scripts that check for this, but I'll let it be
> > > up to you.
> >
> > Ah, I should have checked that. In which case, would you be OK if I
> > simply pushed the removal of this label as a fix for 5.17, and just
> > have it to say "Star5 GPIO", for example, without any indication of
> > the device (which appears in debugfs anyway as part of the irqdomain)?
> 
> I'm fine with it although I'd prefer "StarFive GPIO". I haven't seen
> star5 used anywhere.

Fair enough.

> But shouldn't changes like this normally go through Linus Walleij's
> tree?

Either way, I don't mind. For the record, see below what I'm
suggesting we take in before 5.17-final.

Linus?

Thanks,

	M.

From a84b83c32048de2ba72e5d05645eabc95ffabe49 Mon Sep 17 00:00:00 2001
From: Marc Zyngier <maz@kernel.org>
Date: Thu, 10 Feb 2022 14:13:36 +0000
Subject: [PATCH] pinctrl: starfive: Use a static name for the GPIO irq_chip

Drop the device name used for the GPIO irq_chip and replace it
with something static. The information is still available from
debugfs and carried as part of the irqdomain.

Suggested-by: Emil Renner Berthing <kernel@esmil.dk>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/pinctrl/pinctrl-starfive.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-starfive.c b/drivers/pinctrl/pinctrl-starfive.c
index 0b912152a405..266da41a6162 100644
--- a/drivers/pinctrl/pinctrl-starfive.c
+++ b/drivers/pinctrl/pinctrl-starfive.c
@@ -1164,6 +1164,7 @@ static int starfive_irq_set_type(struct irq_data *d, unsigned int trigger)
 }
 
 static struct irq_chip starfive_irq_chip = {
+	.name = "StarFive GPIO",
 	.irq_ack = starfive_irq_ack,
 	.irq_mask = starfive_irq_mask,
 	.irq_mask_ack = starfive_irq_mask_ack,
@@ -1308,7 +1309,6 @@ static int starfive_probe(struct platform_device *pdev)
 	sfp->gc.ngpio = NR_GPIOS;
 
 	starfive_irq_chip.parent_device = dev;
-	starfive_irq_chip.name = sfp->gc.label;
 
 	sfp->gc.irq.chip = &starfive_irq_chip;
 	sfp->gc.irq.parent_handler = starfive_gpio_irq_handler;
-- 
2.34.1


-- 
Without deviation from the norm, progress is not possible.

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* Re: [PATCH 10/10] pinctrl: starfive: Switch to dynamic chip name output
  2022-02-10 14:14               ` Emil Renner Berthing
  2022-02-10 14:22                 ` Marc Zyngier, Linus Walleij
@ 2022-02-10 14:34                 ` Marc Zyngier
  2022-02-10 14:46                   ` Emil Renner Berthing
  2022-02-11  0:18                   ` Linus Walleij
  1 sibling, 2 replies; 39+ messages in thread
From: Marc Zyngier @ 2022-02-10 14:34 UTC (permalink / raw)
  To: Emil Renner Berthing, Linus Walleij
  Cc: Linux Kernel Mailing List, open list:GPIO SUBSYSTEM,
	Bartosz Golaszewski, Matthias Brugger, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Tony Lindgren, Thomas Gleixner,
	Vladimir Zapolskiy, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, kernel-team

[resending, as I managed to royally screw up my initial email]

On Thu, 10 Feb 2022 14:14:19 +0000,
Emil Renner Berthing <kernel@esmil.dk> wrote:
> 
> On Thu, 10 Feb 2022 at 14:50, Marc Zyngier <maz@kernel.org> wrote:
> > On Thu, 10 Feb 2022 13:44:12 +0000,
> > Emil Renner Berthing <kernel@esmil.dk> wrote:
> > >
> > > Gotcha. The SoC has been out in very few numbers for less than a year
> > > and the driver only entered mainline in 5.17-rc1, so I doubt anyone
> > > has had time to write scripts that check for this, but I'll let it be
> > > up to you.
> >
> > Ah, I should have checked that. In which case, would you be OK if I
> > simply pushed the removal of this label as a fix for 5.17, and just
> > have it to say "Star5 GPIO", for example, without any indication of
> > the device (which appears in debugfs anyway as part of the irqdomain)?
> 
> I'm fine with it although I'd prefer "StarFive GPIO". I haven't seen
> star5 used anywhere.

Fair enough.

> But shouldn't changes like this normally go through Linus Walleij's
> tree?

Either way, I don't mind. For the record, see below what I'm
suggesting we take in before 5.17-final.

Linus?

Thanks,

	M.

From a84b83c32048de2ba72e5d05645eabc95ffabe49 Mon Sep 17 00:00:00 2001
From: Marc Zyngier <maz@kernel.org>
Date: Thu, 10 Feb 2022 14:13:36 +0000
Subject: [PATCH] pinctrl: starfive: Use a static name for the GPIO irq_chip

Drop the device name used for the GPIO irq_chip and replace it
with something static. The information is still available from
debugfs and carried as part of the irqdomain.

Suggested-by: Emil Renner Berthing <kernel@esmil.dk>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/pinctrl/pinctrl-starfive.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-starfive.c b/drivers/pinctrl/pinctrl-starfive.c
index 0b912152a405..266da41a6162 100644
--- a/drivers/pinctrl/pinctrl-starfive.c
+++ b/drivers/pinctrl/pinctrl-starfive.c
@@ -1164,6 +1164,7 @@ static int starfive_irq_set_type(struct irq_data *d, unsigned int trigger)
 }
 
 static struct irq_chip starfive_irq_chip = {
+	.name = "StarFive GPIO",
 	.irq_ack = starfive_irq_ack,
 	.irq_mask = starfive_irq_mask,
 	.irq_mask_ack = starfive_irq_mask_ack,
@@ -1308,7 +1309,6 @@ static int starfive_probe(struct platform_device *pdev)
 	sfp->gc.ngpio = NR_GPIOS;
 
 	starfive_irq_chip.parent_device = dev;
-	starfive_irq_chip.name = sfp->gc.label;
 
 	sfp->gc.irq.chip = &starfive_irq_chip;
 	sfp->gc.irq.parent_handler = starfive_gpio_irq_handler;
-- 
2.34.1


-- 
Without deviation from the norm, progress is not possible.

-- 
Without deviation from the norm, progress is not possible.

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* Re: [PATCH 10/10] pinctrl: starfive: Switch to dynamic chip name output
  2022-02-10 14:34                 ` Marc Zyngier
@ 2022-02-10 14:46                   ` Emil Renner Berthing
  2022-02-11  0:18                   ` Linus Walleij
  1 sibling, 0 replies; 39+ messages in thread
From: Emil Renner Berthing @ 2022-02-10 14:46 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Linus Walleij, Linux Kernel Mailing List,
	open list:GPIO SUBSYSTEM, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, kernel-team

On Thu, 10 Feb 2022 at 15:34, Marc Zyngier <maz@kernel.org> wrote:
>
> [resending, as I managed to royally screw up my initial email]
>
> On Thu, 10 Feb 2022 14:14:19 +0000,
> Emil Renner Berthing <kernel@esmil.dk> wrote:
> >
> > On Thu, 10 Feb 2022 at 14:50, Marc Zyngier <maz@kernel.org> wrote:
> > > On Thu, 10 Feb 2022 13:44:12 +0000,
> > > Emil Renner Berthing <kernel@esmil.dk> wrote:
> > > >
> > > > Gotcha. The SoC has been out in very few numbers for less than a year
> > > > and the driver only entered mainline in 5.17-rc1, so I doubt anyone
> > > > has had time to write scripts that check for this, but I'll let it be
> > > > up to you.
> > >
> > > Ah, I should have checked that. In which case, would you be OK if I
> > > simply pushed the removal of this label as a fix for 5.17, and just
> > > have it to say "Star5 GPIO", for example, without any indication of
> > > the device (which appears in debugfs anyway as part of the irqdomain)?
> >
> > I'm fine with it although I'd prefer "StarFive GPIO". I haven't seen
> > star5 used anywhere.
>
> Fair enough.
>
> > But shouldn't changes like this normally go through Linus Walleij's
> > tree?
>
> Either way, I don't mind. For the record, see below what I'm
> suggesting we take in before 5.17-final.

Looks good to me. I don't mind which tree it goes through, just wanted
to make sure everyone's happy.

> Linus?
>
> Thanks,
>
>         M.
>
> From a84b83c32048de2ba72e5d05645eabc95ffabe49 Mon Sep 17 00:00:00 2001
> From: Marc Zyngier <maz@kernel.org>
> Date: Thu, 10 Feb 2022 14:13:36 +0000
> Subject: [PATCH] pinctrl: starfive: Use a static name for the GPIO irq_chip
>
> Drop the device name used for the GPIO irq_chip and replace it
> with something static. The information is still available from
> debugfs and carried as part of the irqdomain.
>
> Suggested-by: Emil Renner Berthing <kernel@esmil.dk>
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
>  drivers/pinctrl/pinctrl-starfive.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pinctrl/pinctrl-starfive.c b/drivers/pinctrl/pinctrl-starfive.c
> index 0b912152a405..266da41a6162 100644
> --- a/drivers/pinctrl/pinctrl-starfive.c
> +++ b/drivers/pinctrl/pinctrl-starfive.c
> @@ -1164,6 +1164,7 @@ static int starfive_irq_set_type(struct irq_data *d, unsigned int trigger)
>  }
>
>  static struct irq_chip starfive_irq_chip = {
> +       .name = "StarFive GPIO",
>         .irq_ack = starfive_irq_ack,
>         .irq_mask = starfive_irq_mask,
>         .irq_mask_ack = starfive_irq_mask_ack,
> @@ -1308,7 +1309,6 @@ static int starfive_probe(struct platform_device *pdev)
>         sfp->gc.ngpio = NR_GPIOS;
>
>         starfive_irq_chip.parent_device = dev;
> -       starfive_irq_chip.name = sfp->gc.label;
>
>         sfp->gc.irq.chip = &starfive_irq_chip;
>         sfp->gc.irq.parent_handler = starfive_gpio_irq_handler;
> --
> 2.34.1
>
>
> --
> Without deviation from the norm, progress is not possible.
>
> --
> Without deviation from the norm, progress is not possible.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 07/10] irqchip/versatile-fpga: Switch to dynamic chip name output
  2022-02-09 16:26 ` [PATCH 07/10] irqchip/versatile-fpga: " Marc Zyngier
@ 2022-02-10 23:29   ` Linus Walleij
  2022-02-15 12:19   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
  1 sibling, 0 replies; 39+ messages in thread
From: Linus Walleij @ 2022-02-10 23:29 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: linux-kernel, linux-gpio, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Emil Renner Berthing,
	kernel-team

On Wed, Feb 9, 2022 at 5:26 PM Marc Zyngier <maz@kernel.org> wrote:

> Move the name output to the relevant callback, which allows us
> some nice cleanups (mostly owing to the fact that the driver is
> now DT only.
>
> We also drop a random include directive from the ftintc010 driver.
>
> Signed-off-by: Marc Zyngier <maz@kernel.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

BTW nice cleanup.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 03/10] irqchip/gic: Switch to dynamic chip name output
  2022-02-09 16:26 ` [PATCH 03/10] irqchip/gic: Switch to dynamic chip name output Marc Zyngier
@ 2022-02-10 23:38   ` Linus Walleij
  2022-02-11  9:08     ` Marc Zyngier
  2022-02-15 12:19   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
  1 sibling, 1 reply; 39+ messages in thread
From: Linus Walleij @ 2022-02-10 23:38 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: linux-kernel, linux-gpio, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Emil Renner Berthing,
	kernel-team

On Wed, Feb 9, 2022 at 5:26 PM Marc Zyngier <maz@kernel.org> wrote:

> The last dynamic aspect of the GIC's irq_chip structure is the
> name that is associated to it.
>
> Move the output of that name to the relevant callback, which
> allows us to do a bit of cleanup and mark the structures const.
>
> Signed-off-by: Marc Zyngier <maz@kernel.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

This naming was once introduced for the ARM PB11MPCore
that had two cascaded GICs (commit 58b8964990dc6)
so it became a pain to see which one
was being used in /proc/interrupts
arch/arm/boot/dts/arm-realview-pb11mp.dts

I see it is not appreciated to use /proc/interrupts for this
type of diagnostics. Ugh. I suppose people do it for the
same reason they keep using the GPIO sysfs, they like
it and they know it.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name
  2022-02-09 16:25 [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name Marc Zyngier
                   ` (9 preceding siblings ...)
  2022-02-09 16:26 ` [PATCH 10/10] pinctrl: starfive: " Marc Zyngier
@ 2022-02-10 23:41 ` Linus Walleij
  2022-02-15 12:13   ` Marc Zyngier
  2022-02-15 15:37   ` Andy Shevchenko
  10 siblings, 2 replies; 39+ messages in thread
From: Linus Walleij @ 2022-02-10 23:41 UTC (permalink / raw)
  To: Marc Zyngier, Bartosz Golaszewski
  Cc: linux-kernel, linux-gpio, Matthias Brugger, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Tony Lindgren, Thomas Gleixner,
	Vladimir Zapolskiy, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Emil Renner Berthing, kernel-team

On Wed, Feb 9, 2022 at 5:26 PM Marc Zyngier <maz@kernel.org> wrote:

> Having done that, we can cleanup a few irqchip drivers and make their
> irq_chip structure const (which requires touching a handful of core
> functions). Whilst we're at it, we do the same for a couple of gpio
> drivers.

The series:
Acked-by: Linus Walleij <linus.walleij@linaro.org>

Since Bartosz is queueing GPIO patches and I am mostly
playing with a baby during the daytime it's good if you also
get an ACK from Bartosz on this one before applying the
series.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 10/10] pinctrl: starfive: Switch to dynamic chip name output
  2022-02-10  9:06     ` Marc Zyngier
  2022-02-10 12:59       ` Emil Renner Berthing
@ 2022-02-11  0:15       ` Linus Walleij
  2022-02-11  9:20         ` Marc Zyngier
  1 sibling, 1 reply; 39+ messages in thread
From: Linus Walleij @ 2022-02-11  0:15 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Emil Renner Berthing, Linux Kernel Mailing List,
	open list:GPIO SUBSYSTEM, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, kernel-team

On Thu, Feb 10, 2022 at 10:06 AM Marc Zyngier <maz@kernel.org> wrote:
> On Wed, 09 Feb 2022 23:30:55 +0000,
> Emil Renner Berthing <kernel@esmil.dk> wrote:

> > The gpio framework seems to fill in default handlers in the struct
> > above, so unfortunately it can't yet be made const. Is this something
> > you intend to fix in the future?
>
> This is next on my list of things to address. The whole 'let's copy a
> whole irqchip structure and hijack random pointers' should not have
> happened, and it certainly is going to be an interesting ride.

Sorry about that... Probably my bad idea. The only upside is that the
things that are ugly are centralized to one spot.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 10/10] pinctrl: starfive: Switch to dynamic chip name output
  2022-02-10 14:34                 ` Marc Zyngier
  2022-02-10 14:46                   ` Emil Renner Berthing
@ 2022-02-11  0:18                   ` Linus Walleij
  1 sibling, 0 replies; 39+ messages in thread
From: Linus Walleij @ 2022-02-11  0:18 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Emil Renner Berthing, Linux Kernel Mailing List,
	open list:GPIO SUBSYSTEM, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, kernel-team

On Thu, Feb 10, 2022 at 3:34 PM Marc Zyngier <maz@kernel.org> wrote:

> Either way, I don't mind. For the record, see below what I'm
> suggesting we take in before 5.17-final.
>
> Linus?

I'm game! :)

Can you send a separate patch because b4 doesn't let me pick a patch
in the conversation
of a patch...

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 03/10] irqchip/gic: Switch to dynamic chip name output
  2022-02-10 23:38   ` Linus Walleij
@ 2022-02-11  9:08     ` Marc Zyngier
  0 siblings, 0 replies; 39+ messages in thread
From: Marc Zyngier @ 2022-02-11  9:08 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-kernel, linux-gpio, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Emil Renner Berthing,
	kernel-team

On Thu, 10 Feb 2022 23:38:49 +0000,
Linus Walleij <linus.walleij@linaro.org> wrote:
> 
> On Wed, Feb 9, 2022 at 5:26 PM Marc Zyngier <maz@kernel.org> wrote:
> 
> > The last dynamic aspect of the GIC's irq_chip structure is the
> > name that is associated to it.
> >
> > Move the output of that name to the relevant callback, which
> > allows us to do a bit of cleanup and mark the structures const.
> >
> > Signed-off-by: Marc Zyngier <maz@kernel.org>
> 
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> 
> This naming was once introduced for the ARM PB11MPCore
> that had two cascaded GICs (commit 58b8964990dc6)
> so it became a pain to see which one
> was being used in /proc/interrupts
> arch/arm/boot/dts/arm-realview-pb11mp.dts
> 
> I see it is not appreciated to use /proc/interrupts for this
> type of diagnostics. Ugh. I suppose people do it for the
> same reason they keep using the GPIO sysfs, they like
> it and they know it.

It was sort of fair game to use /proc/interrupts to track these things
when we only had that. These days, we have a whole interrupt debugging
infrastructure that is able to track hierarchies, domains and other
state. And it isn't like we're taking away the /proc/interrupts
facility at all, we only indirecting the name output it when possible.

There are also a number of advantages in keeping these data structures
read-only when possible, in addition to the memory saving associated
with only having a reference to the irq_chip structure.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 10/10] pinctrl: starfive: Switch to dynamic chip name output
  2022-02-11  0:15       ` Linus Walleij
@ 2022-02-11  9:20         ` Marc Zyngier
  0 siblings, 0 replies; 39+ messages in thread
From: Marc Zyngier @ 2022-02-11  9:20 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Emil Renner Berthing, Linux Kernel Mailing List,
	open list:GPIO SUBSYSTEM, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, kernel-team

On Fri, 11 Feb 2022 00:15:25 +0000,
Linus Walleij <linus.walleij@linaro.org> wrote:
> 
> On Thu, Feb 10, 2022 at 10:06 AM Marc Zyngier <maz@kernel.org> wrote:
> > On Wed, 09 Feb 2022 23:30:55 +0000,
> > Emil Renner Berthing <kernel@esmil.dk> wrote:
> 
> > > The gpio framework seems to fill in default handlers in the struct
> > > above, so unfortunately it can't yet be made const. Is this something
> > > you intend to fix in the future?
> >
> > This is next on my list of things to address. The whole 'let's copy a
> > whole irqchip structure and hijack random pointers' should not have
> > happened, and it certainly is going to be an interesting ride.
> 
> Sorry about that... Probably my bad idea. The only upside is that the
> things that are ugly are centralized to one spot.

No worries. I should have kept an eye on that too and spotted it
earlier. It is only when helping with the M1 GPIO driver that this was
brought to my attention.

My current approach is to move each and every driver to using the
existing helpers, and advertise to the core GPIO code that they don't
need to be fiddled with a new irqchip flag. It is a rather simple
change, but there are a lot of drivers (I have so far converted the
Apple, Qualcomm and Tegra186 drivers, as this is the HW I have
around), allowing their irq_chip structures to be made const and only
used by reference.

Once all drivers are converted (one day), we can drop the flag and the
pointer swapping code.

The alternative approach was to use a hierarchical irqchip provided by
the GPIO code, but this proved difficult as it would need to know
which methods to implement depending on the flow used. There are also
only a handful of drivers using the hierarchical mode anyway, and we'd
be stuck for all the other drivers.

Anyway, I'll post something shortly with the stuff I have changed, and
we can happily repaint that bike shed.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 05/10] irqchip/mvebu-pic: Switch to dynamic chip name output
  2022-02-09 16:26 ` [PATCH 05/10] irqchip/mvebu-pic: " Marc Zyngier
@ 2022-02-14 14:48   ` Gregory CLEMENT
  2022-02-15 12:19   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
  1 sibling, 0 replies; 39+ messages in thread
From: Gregory CLEMENT @ 2022-02-14 14:48 UTC (permalink / raw)
  To: Marc Zyngier, linux-kernel, linux-gpio
  Cc: Linus Walleij, Bartosz Golaszewski, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Sebastian Hesselbarth, Emil Renner Berthing, kernel-team

Hello Marc;

> Instead of overriding the name field, track the corresponding device
> and use the relevant callback to output its name.
>
> This allows us to make the irq_chip structure const.
>
> Signed-off-by: Marc Zyngier <maz@kernel.org>

Reviewed-by: Gregory CLEMENT <gregory.clement@bootlin.com>

Thanks,

Gregory

> ---
>  drivers/irqchip/irq-mvebu-pic.c | 28 ++++++++++++++++++----------
>  1 file changed, 18 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/irqchip/irq-mvebu-pic.c b/drivers/irqchip/irq-mvebu-pic.c
> index 870f9866b8da..ef3d3646ccc2 100644
> --- a/drivers/irqchip/irq-mvebu-pic.c
> +++ b/drivers/irqchip/irq-mvebu-pic.c
> @@ -18,6 +18,7 @@
>  #include <linux/module.h>
>  #include <linux/of_irq.h>
>  #include <linux/platform_device.h>
> +#include <linux/seq_file.h>
>  
>  #define PIC_CAUSE	       0x0
>  #define PIC_MASK	       0x4
> @@ -29,7 +30,7 @@ struct mvebu_pic {
>  	void __iomem *base;
>  	u32 parent_irq;
>  	struct irq_domain *domain;
> -	struct irq_chip irq_chip;
> +	struct platform_device *pdev;
>  };
>  
>  static void mvebu_pic_reset(struct mvebu_pic *pic)
> @@ -66,6 +67,20 @@ static void mvebu_pic_unmask_irq(struct irq_data *d)
>  	writel(reg, pic->base + PIC_MASK);
>  }
>  
> +static void mvebu_pic_print_chip(struct irq_data *d, struct seq_file *p)
> +{
> +	struct mvebu_pic *pic = irq_data_get_irq_chip_data(d);
> +
> +	seq_printf(p, dev_name(&pic->pdev->dev));
> +}
> +
> +static const struct irq_chip mvebu_pic_chip = {
> +	.irq_mask	= mvebu_pic_mask_irq,
> +	.irq_unmask	= mvebu_pic_unmask_irq,
> +	.irq_eoi	= mvebu_pic_eoi_irq,
> +	.irq_print_chip	= mvebu_pic_print_chip,
> +};
> +
>  static int mvebu_pic_irq_map(struct irq_domain *domain, unsigned int virq,
>  			     irq_hw_number_t hwirq)
>  {
> @@ -73,8 +88,7 @@ static int mvebu_pic_irq_map(struct irq_domain *domain, unsigned int virq,
>  
>  	irq_set_percpu_devid(virq);
>  	irq_set_chip_data(virq, pic);
> -	irq_set_chip_and_handler(virq, &pic->irq_chip,
> -				 handle_percpu_devid_irq);
> +	irq_set_chip_and_handler(virq, &mvebu_pic_chip, handle_percpu_devid_irq);
>  	irq_set_status_flags(virq, IRQ_LEVEL);
>  	irq_set_probe(virq);
>  
> @@ -120,22 +134,16 @@ static int mvebu_pic_probe(struct platform_device *pdev)
>  {
>  	struct device_node *node = pdev->dev.of_node;
>  	struct mvebu_pic *pic;
> -	struct irq_chip *irq_chip;
>  
>  	pic = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_pic), GFP_KERNEL);
>  	if (!pic)
>  		return -ENOMEM;
>  
> +	pic->pdev = pdev;
>  	pic->base = devm_platform_ioremap_resource(pdev, 0);
>  	if (IS_ERR(pic->base))
>  		return PTR_ERR(pic->base);
>  
> -	irq_chip = &pic->irq_chip;
> -	irq_chip->name = dev_name(&pdev->dev);
> -	irq_chip->irq_mask = mvebu_pic_mask_irq;
> -	irq_chip->irq_unmask = mvebu_pic_unmask_irq;
> -	irq_chip->irq_eoi = mvebu_pic_eoi_irq;
> -
>  	pic->parent_irq = irq_of_parse_and_map(node, 0);
>  	if (pic->parent_irq <= 0) {
>  		dev_err(&pdev->dev, "Failed to parse parent interrupt\n");
> -- 
> 2.30.2
>

-- 
Gregory Clement, Bootlin
Embedded Linux and Kernel engineering
http://bootlin.com

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name
  2022-02-10 23:41 ` [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name Linus Walleij
@ 2022-02-15 12:13   ` Marc Zyngier
  2022-02-15 15:37   ` Andy Shevchenko
  1 sibling, 0 replies; 39+ messages in thread
From: Marc Zyngier @ 2022-02-15 12:13 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Bartosz Golaszewski, linux-kernel, linux-gpio, Matthias Brugger,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman,
	Tony Lindgren, Thomas Gleixner, Vladimir Zapolskiy, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Emil Renner Berthing,
	kernel-team

On Thu, 10 Feb 2022 23:41:25 +0000,
Linus Walleij <linus.walleij@linaro.org> wrote:
> 
> On Wed, Feb 9, 2022 at 5:26 PM Marc Zyngier <maz@kernel.org> wrote:
> 
> > Having done that, we can cleanup a few irqchip drivers and make their
> > irq_chip structure const (which requires touching a handful of core
> > functions). Whilst we're at it, we do the same for a couple of gpio
> > drivers.
> 
> The series:
> Acked-by: Linus Walleij <linus.walleij@linaro.org>

Thanks.

> Since Bartosz is queueing GPIO patches and I am mostly
> playing with a baby during the daytime it's good if you also
> get an ACK from Bartosz on this one before applying the
> series.

To be on the safe side and until I hear from Bartosz, I have dropped
the GPIO patches from the branch which I'm about to push into -next.
If Bartosz is happy with them, I'll add them to the mix. Otherwise,
they can be taken at a later time, as there is no shortage of drivers
that will need reworking once we agree on the way to resolve the
irqchip fiddling in gpiolib.

Have fun playing! :)

	M.

-- 
Without deviation from the norm, progress is not possible.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [irqchip: irq/irqchip-next] irqchip/versatile-fpga: Switch to dynamic chip name output
  2022-02-09 16:26 ` [PATCH 07/10] irqchip/versatile-fpga: " Marc Zyngier
  2022-02-10 23:29   ` Linus Walleij
@ 2022-02-15 12:19   ` irqchip-bot for Marc Zyngier
  1 sibling, 0 replies; 39+ messages in thread
From: irqchip-bot for Marc Zyngier @ 2022-02-15 12:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Marc Zyngier, Linus Walleij, tglx

The following commit has been merged into the irq/irqchip-next branch of irqchip:

Commit-ID:     3fb212a042fbd8eccbb2af1852e03ed7757b9600
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/3fb212a042fbd8eccbb2af1852e03ed7757b9600
Author:        Marc Zyngier <maz@kernel.org>
AuthorDate:    Wed, 09 Feb 2022 16:26:04 
Committer:     Marc Zyngier <maz@kernel.org>
CommitterDate: Tue, 15 Feb 2022 11:25:46 

irqchip/versatile-fpga: Switch to dynamic chip name output

Move the name output to the relevant callback, which allows us
some nice cleanups (mostly owing to the fact that the driver is
now DT only.

We also drop a random include directive from the ftintc010 driver.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220209162607.1118325-8-maz@kernel.org
---
 drivers/irqchip/irq-ftintc010.c        |  1 +-
 drivers/irqchip/irq-versatile-fpga.c   | 46 ++++++++++++++-----------
 include/linux/irqchip/versatile-fpga.h | 14 +--------
 3 files changed, 26 insertions(+), 35 deletions(-)
 delete mode 100644 include/linux/irqchip/versatile-fpga.h

diff --git a/drivers/irqchip/irq-ftintc010.c b/drivers/irqchip/irq-ftintc010.c
index 5cc2688..46a3aa6 100644
--- a/drivers/irqchip/irq-ftintc010.c
+++ b/drivers/irqchip/irq-ftintc010.c
@@ -11,7 +11,6 @@
 #include <linux/irq.h>
 #include <linux/io.h>
 #include <linux/irqchip.h>
-#include <linux/irqchip/versatile-fpga.h>
 #include <linux/irqdomain.h>
 #include <linux/module.h>
 #include <linux/of.h>
diff --git a/drivers/irqchip/irq-versatile-fpga.c b/drivers/irqchip/irq-versatile-fpga.c
index f2757b6..ba543ed 100644
--- a/drivers/irqchip/irq-versatile-fpga.c
+++ b/drivers/irqchip/irq-versatile-fpga.c
@@ -7,12 +7,12 @@
 #include <linux/io.h>
 #include <linux/irqchip.h>
 #include <linux/irqchip/chained_irq.h>
-#include <linux/irqchip/versatile-fpga.h>
 #include <linux/irqdomain.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
+#include <linux/seq_file.h>
 
 #include <asm/exception.h>
 #include <asm/mach/irq.h>
@@ -34,14 +34,12 @@
 /**
  * struct fpga_irq_data - irq data container for the FPGA IRQ controller
  * @base: memory offset in virtual memory
- * @chip: chip container for this instance
  * @domain: IRQ domain for this instance
  * @valid: mask for valid IRQs on this controller
  * @used_irqs: number of active IRQs on this controller
  */
 struct fpga_irq_data {
 	void __iomem *base;
-	struct irq_chip chip;
 	u32 valid;
 	struct irq_domain *domain;
 	u8 used_irqs;
@@ -67,6 +65,20 @@ static void fpga_irq_unmask(struct irq_data *d)
 	writel(mask, f->base + IRQ_ENABLE_SET);
 }
 
+static void fpga_irq_print_chip(struct irq_data *d, struct seq_file *p)
+{
+	struct fpga_irq_data *f = irq_data_get_irq_chip_data(d);
+
+	seq_printf(p, irq_domain_get_of_node(f->domain)->name);
+}
+
+static const struct irq_chip fpga_chip = {
+	.irq_ack	= fpga_irq_mask,
+	.irq_mask	= fpga_irq_mask,
+	.irq_unmask	= fpga_irq_unmask,
+	.irq_print_chip	= fpga_irq_print_chip,
+};
+
 static void fpga_irq_handle(struct irq_desc *desc)
 {
 	struct irq_chip *chip = irq_desc_get_chip(desc);
@@ -116,7 +128,7 @@ static int handle_one_fpga(struct fpga_irq_data *f, struct pt_regs *regs)
  * Keep iterating over all registered FPGA IRQ controllers until there are
  * no pending interrupts.
  */
-asmlinkage void __exception_irq_entry fpga_handle_irq(struct pt_regs *regs)
+static asmlinkage void __exception_irq_entry fpga_handle_irq(struct pt_regs *regs)
 {
 	int i, handled;
 
@@ -135,8 +147,7 @@ static int fpga_irqdomain_map(struct irq_domain *d, unsigned int irq,
 	if (!(f->valid & BIT(hwirq)))
 		return -EPERM;
 	irq_set_chip_data(irq, f);
-	irq_set_chip_and_handler(irq, &f->chip,
-				handle_level_irq);
+	irq_set_chip_and_handler(irq, &fpga_chip, handle_level_irq);
 	irq_set_probe(irq);
 	return 0;
 }
@@ -146,8 +157,8 @@ static const struct irq_domain_ops fpga_irqdomain_ops = {
 	.xlate = irq_domain_xlate_onetwocell,
 };
 
-void __init fpga_irq_init(void __iomem *base, const char *name, int irq_start,
-			  int parent_irq, u32 valid, struct device_node *node)
+static void __init fpga_irq_init(void __iomem *base, int parent_irq,
+				 u32 valid, struct device_node *node)
 {
 	struct fpga_irq_data *f;
 	int i;
@@ -158,10 +169,6 @@ void __init fpga_irq_init(void __iomem *base, const char *name, int irq_start,
 	}
 	f = &fpga_irq_devices[fpga_irq_id];
 	f->base = base;
-	f->chip.name = name;
-	f->chip.irq_ack = fpga_irq_mask;
-	f->chip.irq_mask = fpga_irq_mask;
-	f->chip.irq_unmask = fpga_irq_unmask;
 	f->valid = valid;
 
 	if (parent_irq != -1) {
@@ -169,20 +176,19 @@ void __init fpga_irq_init(void __iomem *base, const char *name, int irq_start,
 						 f);
 	}
 
-	/* This will also allocate irq descriptors */
-	f->domain = irq_domain_add_simple(node, fls(valid), irq_start,
+	f->domain = irq_domain_add_linear(node, fls(valid),
 					  &fpga_irqdomain_ops, f);
 
 	/* This will allocate all valid descriptors in the linear case */
 	for (i = 0; i < fls(valid); i++)
 		if (valid & BIT(i)) {
-			if (!irq_start)
-				irq_create_mapping(f->domain, i);
+			/* Is this still required? */
+			irq_create_mapping(f->domain, i);
 			f->used_irqs++;
 		}
 
 	pr_info("FPGA IRQ chip %d \"%s\" @ %p, %u irqs",
-		fpga_irq_id, name, base, f->used_irqs);
+		fpga_irq_id, node->name, base, f->used_irqs);
 	if (parent_irq != -1)
 		pr_cont(", parent IRQ: %d\n", parent_irq);
 	else
@@ -192,8 +198,8 @@ void __init fpga_irq_init(void __iomem *base, const char *name, int irq_start,
 }
 
 #ifdef CONFIG_OF
-int __init fpga_irq_of_init(struct device_node *node,
-			    struct device_node *parent)
+static int __init fpga_irq_of_init(struct device_node *node,
+				   struct device_node *parent)
 {
 	void __iomem *base;
 	u32 clear_mask;
@@ -222,7 +228,7 @@ int __init fpga_irq_of_init(struct device_node *node,
 		parent_irq = -1;
 	}
 
-	fpga_irq_init(base, node->name, 0, parent_irq, valid_mask, node);
+	fpga_irq_init(base, parent_irq, valid_mask, node);
 
 	/*
 	 * On Versatile AB/PB, some secondary interrupts have a direct
diff --git a/include/linux/irqchip/versatile-fpga.h b/include/linux/irqchip/versatile-fpga.h
deleted file mode 100644
index a978fc8..0000000
--- a/include/linux/irqchip/versatile-fpga.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef PLAT_FPGA_IRQ_H
-#define PLAT_FPGA_IRQ_H
-
-struct device_node;
-struct pt_regs;
-
-void fpga_handle_irq(struct pt_regs *regs);
-void fpga_irq_init(void __iomem *, const char *, int, int, u32,
-		struct device_node *node);
-int fpga_irq_of_init(struct device_node *node,
-		     struct device_node *parent);
-
-#endif

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [irqchip: irq/irqchip-next] irqchip/ts4800: Switch to dynamic chip name output
  2022-02-09 16:26 ` [PATCH 06/10] irqchip/ts4800: " Marc Zyngier
@ 2022-02-15 12:19   ` irqchip-bot for Marc Zyngier
  0 siblings, 0 replies; 39+ messages in thread
From: irqchip-bot for Marc Zyngier @ 2022-02-15 12:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Marc Zyngier, Linus Walleij, tglx

The following commit has been merged into the irq/irqchip-next branch of irqchip:

Commit-ID:     3344265a2692414831c15964dd27a5b4adc4ed83
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/3344265a2692414831c15964dd27a5b4adc4ed83
Author:        Marc Zyngier <maz@kernel.org>
AuthorDate:    Wed, 09 Feb 2022 16:26:03 
Committer:     Marc Zyngier <maz@kernel.org>
CommitterDate: Tue, 15 Feb 2022 11:25:46 

irqchip/ts4800: Switch to dynamic chip name output

Signed-off-by: Marc Zyngier <maz@kernel.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220209162607.1118325-7-maz@kernel.org
---
 drivers/irqchip/irq-ts4800.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/irqchip/irq-ts4800.c b/drivers/irqchip/irq-ts4800.c
index f032db2..b2d61d4 100644
--- a/drivers/irqchip/irq-ts4800.c
+++ b/drivers/irqchip/irq-ts4800.c
@@ -19,14 +19,15 @@
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/platform_device.h>
+#include <linux/seq_file.h>
 
 #define IRQ_MASK        0x4
 #define IRQ_STATUS      0x8
 
 struct ts4800_irq_data {
 	void __iomem            *base;
+	struct platform_device	*pdev;
 	struct irq_domain       *domain;
-	struct irq_chip         irq_chip;
 };
 
 static void ts4800_irq_mask(struct irq_data *d)
@@ -47,12 +48,25 @@ static void ts4800_irq_unmask(struct irq_data *d)
 	writew(reg & ~mask, data->base + IRQ_MASK);
 }
 
+static void ts4800_irq_print_chip(struct irq_data *d, struct seq_file *p)
+{
+	struct ts4800_irq_data *data = irq_data_get_irq_chip_data(d);
+
+	seq_printf(p, "%s", dev_name(&data->pdev->dev));
+}
+
+static const struct irq_chip ts4800_chip = {
+	.irq_mask	= ts4800_irq_mask,
+	.irq_unmask	= ts4800_irq_unmask,
+	.irq_print_chip	= ts4800_irq_print_chip,
+};
+
 static int ts4800_irqdomain_map(struct irq_domain *d, unsigned int irq,
 				irq_hw_number_t hwirq)
 {
 	struct ts4800_irq_data *data = d->host_data;
 
-	irq_set_chip_and_handler(irq, &data->irq_chip, handle_simple_irq);
+	irq_set_chip_and_handler(irq, &ts4800_chip, handle_simple_irq);
 	irq_set_chip_data(irq, data);
 	irq_set_noprobe(irq);
 
@@ -92,13 +106,13 @@ static int ts4800_ic_probe(struct platform_device *pdev)
 {
 	struct device_node *node = pdev->dev.of_node;
 	struct ts4800_irq_data *data;
-	struct irq_chip *irq_chip;
 	int parent_irq;
 
 	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
+	data->pdev = pdev;
 	data->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(data->base))
 		return PTR_ERR(data->base);
@@ -111,11 +125,6 @@ static int ts4800_ic_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	irq_chip = &data->irq_chip;
-	irq_chip->name = dev_name(&pdev->dev);
-	irq_chip->irq_mask = ts4800_irq_mask;
-	irq_chip->irq_unmask = ts4800_irq_unmask;
-
 	data->domain = irq_domain_add_linear(node, 8, &ts4800_ic_ops, data);
 	if (!data->domain) {
 		dev_err(&pdev->dev, "cannot add IRQ domain\n");

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [irqchip: irq/irqchip-next] irqchip/mvebu-pic: Switch to dynamic chip name output
  2022-02-09 16:26 ` [PATCH 05/10] irqchip/mvebu-pic: " Marc Zyngier
  2022-02-14 14:48   ` Gregory CLEMENT
@ 2022-02-15 12:19   ` irqchip-bot for Marc Zyngier
  1 sibling, 0 replies; 39+ messages in thread
From: irqchip-bot for Marc Zyngier @ 2022-02-15 12:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Marc Zyngier, Gregory CLEMENT, Linus Walleij, tglx

The following commit has been merged into the irq/irqchip-next branch of irqchip:

Commit-ID:     421f16238a9da88ce1f2e3a103866de095cc15f6
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/421f16238a9da88ce1f2e3a103866de095cc15f6
Author:        Marc Zyngier <maz@kernel.org>
AuthorDate:    Wed, 09 Feb 2022 16:26:02 
Committer:     Marc Zyngier <maz@kernel.org>
CommitterDate: Tue, 15 Feb 2022 11:25:46 

irqchip/mvebu-pic: Switch to dynamic chip name output

Instead of overriding the name field, track the corresponding device
and use the relevant callback to output its name.

This allows us to make the irq_chip structure const.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Gregory CLEMENT <gregory.clement@bootlin.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220209162607.1118325-6-maz@kernel.org
---
 drivers/irqchip/irq-mvebu-pic.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/drivers/irqchip/irq-mvebu-pic.c b/drivers/irqchip/irq-mvebu-pic.c
index 870f986..ef3d364 100644
--- a/drivers/irqchip/irq-mvebu-pic.c
+++ b/drivers/irqchip/irq-mvebu-pic.c
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/of_irq.h>
 #include <linux/platform_device.h>
+#include <linux/seq_file.h>
 
 #define PIC_CAUSE	       0x0
 #define PIC_MASK	       0x4
@@ -29,7 +30,7 @@ struct mvebu_pic {
 	void __iomem *base;
 	u32 parent_irq;
 	struct irq_domain *domain;
-	struct irq_chip irq_chip;
+	struct platform_device *pdev;
 };
 
 static void mvebu_pic_reset(struct mvebu_pic *pic)
@@ -66,6 +67,20 @@ static void mvebu_pic_unmask_irq(struct irq_data *d)
 	writel(reg, pic->base + PIC_MASK);
 }
 
+static void mvebu_pic_print_chip(struct irq_data *d, struct seq_file *p)
+{
+	struct mvebu_pic *pic = irq_data_get_irq_chip_data(d);
+
+	seq_printf(p, dev_name(&pic->pdev->dev));
+}
+
+static const struct irq_chip mvebu_pic_chip = {
+	.irq_mask	= mvebu_pic_mask_irq,
+	.irq_unmask	= mvebu_pic_unmask_irq,
+	.irq_eoi	= mvebu_pic_eoi_irq,
+	.irq_print_chip	= mvebu_pic_print_chip,
+};
+
 static int mvebu_pic_irq_map(struct irq_domain *domain, unsigned int virq,
 			     irq_hw_number_t hwirq)
 {
@@ -73,8 +88,7 @@ static int mvebu_pic_irq_map(struct irq_domain *domain, unsigned int virq,
 
 	irq_set_percpu_devid(virq);
 	irq_set_chip_data(virq, pic);
-	irq_set_chip_and_handler(virq, &pic->irq_chip,
-				 handle_percpu_devid_irq);
+	irq_set_chip_and_handler(virq, &mvebu_pic_chip, handle_percpu_devid_irq);
 	irq_set_status_flags(virq, IRQ_LEVEL);
 	irq_set_probe(virq);
 
@@ -120,22 +134,16 @@ static int mvebu_pic_probe(struct platform_device *pdev)
 {
 	struct device_node *node = pdev->dev.of_node;
 	struct mvebu_pic *pic;
-	struct irq_chip *irq_chip;
 
 	pic = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_pic), GFP_KERNEL);
 	if (!pic)
 		return -ENOMEM;
 
+	pic->pdev = pdev;
 	pic->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(pic->base))
 		return PTR_ERR(pic->base);
 
-	irq_chip = &pic->irq_chip;
-	irq_chip->name = dev_name(&pdev->dev);
-	irq_chip->irq_mask = mvebu_pic_mask_irq;
-	irq_chip->irq_unmask = mvebu_pic_unmask_irq;
-	irq_chip->irq_eoi = mvebu_pic_eoi_irq;
-
 	pic->parent_irq = irq_of_parse_and_map(node, 0);
 	if (pic->parent_irq <= 0) {
 		dev_err(&pdev->dev, "Failed to parse parent interrupt\n");

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [irqchip: irq/irqchip-next] irqchip/lpc32xx: Switch to dynamic chip name output
  2022-02-09 16:26 ` [PATCH 04/10] irqchip/lpc32xx: " Marc Zyngier
@ 2022-02-15 12:19   ` irqchip-bot for Marc Zyngier
  0 siblings, 0 replies; 39+ messages in thread
From: irqchip-bot for Marc Zyngier @ 2022-02-15 12:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Marc Zyngier, Linus Walleij, tglx

The following commit has been merged into the irq/irqchip-next branch of irqchip:

Commit-ID:     365550239f87342e3d29802fce0f5e9a044e8070
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/365550239f87342e3d29802fce0f5e9a044e8070
Author:        Marc Zyngier <maz@kernel.org>
AuthorDate:    Wed, 09 Feb 2022 16:26:01 
Committer:     Marc Zyngier <maz@kernel.org>
CommitterDate: Tue, 15 Feb 2022 11:25:46 

irqchip/lpc32xx: Switch to dynamic chip name output

Instead of overriding the name field with the device name, use
the relevant callback. This allows us to make the irq_chip structure
const.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220209162607.1118325-5-maz@kernel.org
---
 drivers/irqchip/irq-lpc32xx.c | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/drivers/irqchip/irq-lpc32xx.c b/drivers/irqchip/irq-lpc32xx.c
index a29357f..4d70a85 100644
--- a/drivers/irqchip/irq-lpc32xx.c
+++ b/drivers/irqchip/irq-lpc32xx.c
@@ -11,6 +11,7 @@
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
+#include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <asm/exception.h>
 
@@ -25,8 +26,8 @@
 
 struct lpc32xx_irq_chip {
 	void __iomem *base;
+	phys_addr_t addr;
 	struct irq_domain *domain;
-	struct irq_chip chip;
 };
 
 static struct lpc32xx_irq_chip *lpc32xx_mic_irqc;
@@ -118,6 +119,24 @@ static int lpc32xx_irq_set_type(struct irq_data *d, unsigned int type)
 	return 0;
 }
 
+static void lpc32xx_irq_print_chip(struct irq_data *d, struct seq_file *p)
+{
+	struct lpc32xx_irq_chip *ic = irq_data_get_irq_chip_data(d);
+
+	if (ic == lpc32xx_mic_irqc)
+		seq_printf(p, "%08x.mic", ic->addr);
+	else
+		seq_printf(p, "%08x.sic", ic->addr);
+}
+
+static const struct irq_chip lpc32xx_chip = {
+	.irq_ack	= lpc32xx_irq_ack,
+	.irq_mask	= lpc32xx_irq_mask,
+	.irq_unmask	= lpc32xx_irq_unmask,
+	.irq_set_type	= lpc32xx_irq_set_type,
+	.irq_print_chip	= lpc32xx_irq_print_chip,
+};
+
 static void __exception_irq_entry lpc32xx_handle_irq(struct pt_regs *regs)
 {
 	struct lpc32xx_irq_chip *ic = lpc32xx_mic_irqc;
@@ -153,7 +172,7 @@ static int lpc32xx_irq_domain_map(struct irq_domain *id, unsigned int virq,
 	struct lpc32xx_irq_chip *ic = id->host_data;
 
 	irq_set_chip_data(virq, ic);
-	irq_set_chip_and_handler(virq, &ic->chip, handle_level_irq);
+	irq_set_chip_and_handler(virq, &lpc32xx_chip, handle_level_irq);
 	irq_set_status_flags(virq, IRQ_LEVEL);
 	irq_set_noprobe(virq);
 
@@ -183,6 +202,7 @@ static int __init lpc32xx_of_ic_init(struct device_node *node,
 	if (!irqc)
 		return -ENOMEM;
 
+	irqc->addr = addr;
 	irqc->base = of_iomap(node, 0);
 	if (!irqc->base) {
 		pr_err("%pOF: unable to map registers\n", node);
@@ -190,21 +210,11 @@ static int __init lpc32xx_of_ic_init(struct device_node *node,
 		return -EINVAL;
 	}
 
-	irqc->chip.irq_ack = lpc32xx_irq_ack;
-	irqc->chip.irq_mask = lpc32xx_irq_mask;
-	irqc->chip.irq_unmask = lpc32xx_irq_unmask;
-	irqc->chip.irq_set_type = lpc32xx_irq_set_type;
-	if (is_mic)
-		irqc->chip.name = kasprintf(GFP_KERNEL, "%08x.mic", addr);
-	else
-		irqc->chip.name = kasprintf(GFP_KERNEL, "%08x.sic", addr);
-
 	irqc->domain = irq_domain_add_linear(node, NR_LPC32XX_IC_IRQS,
 					     &lpc32xx_irq_domain_ops, irqc);
 	if (!irqc->domain) {
 		pr_err("unable to add irq domain\n");
 		iounmap(irqc->base);
-		kfree(irqc->chip.name);
 		kfree(irqc);
 		return -ENODEV;
 	}

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [irqchip: irq/irqchip-next] irqchip/gic: Switch to dynamic chip name output
  2022-02-09 16:26 ` [PATCH 03/10] irqchip/gic: Switch to dynamic chip name output Marc Zyngier
  2022-02-10 23:38   ` Linus Walleij
@ 2022-02-15 12:19   ` irqchip-bot for Marc Zyngier
  1 sibling, 0 replies; 39+ messages in thread
From: irqchip-bot for Marc Zyngier @ 2022-02-15 12:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Marc Zyngier, Linus Walleij, tglx

The following commit has been merged into the irq/irqchip-next branch of irqchip:

Commit-ID:     745f1fb91fe51b4a36bc1c3dbccdbbbb978f93d2
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/745f1fb91fe51b4a36bc1c3dbccdbbbb978f93d2
Author:        Marc Zyngier <maz@kernel.org>
AuthorDate:    Wed, 09 Feb 2022 16:26:00 
Committer:     Marc Zyngier <maz@kernel.org>
CommitterDate: Tue, 15 Feb 2022 11:25:46 

irqchip/gic: Switch to dynamic chip name output

The last dynamic aspect of the GIC's irq_chip structure is the
name that is associated to it.

Move the output of that name to the relevant callback, which
allows us to do a bit of cleanup and mark the structures const.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220209162607.1118325-4-maz@kernel.org
---
 drivers/irqchip/irq-gic.c | 102 +++++++++++++++++++------------------
 1 file changed, 54 insertions(+), 48 deletions(-)

diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index fb741b4..58ba835 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -34,6 +34,7 @@
 #include <linux/irqdomain.h>
 #include <linux/interrupt.h>
 #include <linux/percpu.h>
+#include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/irqchip.h>
 #include <linux/irqchip/chained_irq.h>
@@ -66,7 +67,6 @@ union gic_base {
 };
 
 struct gic_chip_data {
-	struct irq_chip chip;
 	union gic_base dist_base;
 	union gic_base cpu_base;
 	void __iomem *raw_dist_base;
@@ -397,18 +397,15 @@ static void gic_handle_cascade_irq(struct irq_desc *desc)
 	chained_irq_exit(chip, desc);
 }
 
-static const struct irq_chip gic_chip = {
-	.irq_mask		= gic_mask_irq,
-	.irq_unmask		= gic_unmask_irq,
-	.irq_eoi		= gic_eoi_irq,
-	.irq_set_type		= gic_set_type,
-	.irq_retrigger          = gic_retrigger,
-	.irq_get_irqchip_state	= gic_irq_get_irqchip_state,
-	.irq_set_irqchip_state	= gic_irq_set_irqchip_state,
-	.flags			= IRQCHIP_SET_TYPE_MASKED |
-				  IRQCHIP_SKIP_SET_WAKE |
-				  IRQCHIP_MASK_ON_SUSPEND,
-};
+static void gic_irq_print_chip(struct irq_data *d, struct seq_file *p)
+{
+	struct gic_chip_data *gic = irq_data_get_irq_chip_data(d);
+
+	if (gic->domain->dev)
+		seq_printf(p, gic->domain->dev->of_node->name);
+	else
+		seq_printf(p, "GIC-%d", (int)(gic - &gic_data[0]));
+}
 
 void __init gic_cascade_irq(unsigned int gic_nr, unsigned int irq)
 {
@@ -799,8 +796,12 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
 			    bool force)
 {
 	void __iomem *reg = gic_dist_base(d) + GIC_DIST_TARGET + gic_irq(d);
+	struct gic_chip_data *gic = irq_data_get_irq_chip_data(d);
 	unsigned int cpu;
 
+	if (unlikely(gic != &gic_data[0]))
+		return -EINVAL;
+
 	if (!force)
 		cpu = cpumask_any_and(mask_val, cpu_online_mask);
 	else
@@ -880,6 +881,39 @@ static __init void gic_smp_init(void)
 #define gic_ipi_send_mask	NULL
 #endif
 
+static const struct irq_chip gic_chip = {
+	.irq_mask		= gic_mask_irq,
+	.irq_unmask		= gic_unmask_irq,
+	.irq_eoi		= gic_eoi_irq,
+	.irq_set_type		= gic_set_type,
+	.irq_retrigger          = gic_retrigger,
+	.irq_set_affinity	= gic_set_affinity,
+	.ipi_send_mask		= gic_ipi_send_mask,
+	.irq_get_irqchip_state	= gic_irq_get_irqchip_state,
+	.irq_set_irqchip_state	= gic_irq_set_irqchip_state,
+	.irq_print_chip		= gic_irq_print_chip,
+	.flags			= IRQCHIP_SET_TYPE_MASKED |
+				  IRQCHIP_SKIP_SET_WAKE |
+				  IRQCHIP_MASK_ON_SUSPEND,
+};
+
+static const struct irq_chip gic_chip_mode1 = {
+	.name			= "GICv2",
+	.irq_mask		= gic_eoimode1_mask_irq,
+	.irq_unmask		= gic_unmask_irq,
+	.irq_eoi		= gic_eoimode1_eoi_irq,
+	.irq_set_type		= gic_set_type,
+	.irq_retrigger          = gic_retrigger,
+	.irq_set_affinity	= gic_set_affinity,
+	.ipi_send_mask		= gic_ipi_send_mask,
+	.irq_get_irqchip_state	= gic_irq_get_irqchip_state,
+	.irq_set_irqchip_state	= gic_irq_set_irqchip_state,
+	.irq_set_vcpu_affinity	= gic_irq_set_vcpu_affinity,
+	.flags			= IRQCHIP_SET_TYPE_MASKED |
+				  IRQCHIP_SKIP_SET_WAKE |
+				  IRQCHIP_MASK_ON_SUSPEND,
+};
+
 #ifdef CONFIG_BL_SWITCHER
 /*
  * gic_send_sgi - send a SGI directly to given CPU interface number
@@ -1024,15 +1058,19 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int irq,
 {
 	struct gic_chip_data *gic = d->host_data;
 	struct irq_data *irqd = irq_desc_get_irq_data(irq_to_desc(irq));
+	const struct irq_chip *chip;
+
+	chip = (static_branch_likely(&supports_deactivate_key) &&
+		gic == &gic_data[0]) ? &gic_chip_mode1 : &gic_chip;
 
 	switch (hw) {
 	case 0 ... 31:
 		irq_set_percpu_devid(irq);
-		irq_domain_set_info(d, irq, hw, &gic->chip, d->host_data,
+		irq_domain_set_info(d, irq, hw, chip, d->host_data,
 				    handle_percpu_devid_irq, NULL, NULL);
 		break;
 	default:
-		irq_domain_set_info(d, irq, hw, &gic->chip, d->host_data,
+		irq_domain_set_info(d, irq, hw, chip, d->host_data,
 				    handle_fasteoi_irq, NULL, NULL);
 		irq_set_probe(irq);
 		irqd_set_single_target(irqd);
@@ -1127,25 +1165,6 @@ static const struct irq_domain_ops gic_irq_domain_ops = {
 	.unmap = gic_irq_domain_unmap,
 };
 
-static void gic_init_chip(struct gic_chip_data *gic, const char *name,
-			  bool use_eoimode1)
-{
-	/* Initialize irq_chip */
-	gic->chip = gic_chip;
-	gic->chip.name = name;
-
-	if (use_eoimode1) {
-		gic->chip.irq_mask = gic_eoimode1_mask_irq;
-		gic->chip.irq_eoi = gic_eoimode1_eoi_irq;
-		gic->chip.irq_set_vcpu_affinity = gic_irq_set_vcpu_affinity;
-	}
-
-	if (gic == &gic_data[0]) {
-		gic->chip.irq_set_affinity = gic_set_affinity;
-		gic->chip.ipi_send_mask = gic_ipi_send_mask;
-	}
-}
-
 static int gic_init_bases(struct gic_chip_data *gic,
 			  struct fwnode_handle *handle)
 {
@@ -1245,7 +1264,6 @@ error:
 static int __init __gic_init_bases(struct gic_chip_data *gic,
 				   struct fwnode_handle *handle)
 {
-	char *name;
 	int i, ret;
 
 	if (WARN_ON(!gic || gic->domain))
@@ -1265,18 +1283,8 @@ static int __init __gic_init_bases(struct gic_chip_data *gic,
 			pr_info("GIC: Using split EOI/Deactivate mode\n");
 	}
 
-	if (static_branch_likely(&supports_deactivate_key) && gic == &gic_data[0]) {
-		name = kasprintf(GFP_KERNEL, "GICv2");
-		gic_init_chip(gic, name, true);
-	} else {
-		name = kasprintf(GFP_KERNEL, "GIC-%d", (int)(gic-&gic_data[0]));
-		gic_init_chip(gic, name, false);
-	}
-
 	ret = gic_init_bases(gic, handle);
-	if (ret)
-		kfree(name);
-	else if (gic == &gic_data[0])
+	if (gic == &gic_data[0])
 		gic_smp_init();
 
 	return ret;
@@ -1459,8 +1467,6 @@ int gic_of_init_child(struct device *dev, struct gic_chip_data **gic, int irq)
 	if (!*gic)
 		return -ENOMEM;
 
-	gic_init_chip(*gic, dev->of_node->name, false);
-
 	ret = gic_of_setup(*gic, dev->of_node);
 	if (ret)
 		return ret;

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [irqchip: irq/irqchip-next] genirq: Allow irq_chip registration functions to take a const irq_chip
  2022-02-09 16:25 ` [PATCH 02/10] genirq: Allow irq_chip registration functions to " Marc Zyngier
@ 2022-02-15 12:20   ` irqchip-bot for Marc Zyngier
  0 siblings, 0 replies; 39+ messages in thread
From: irqchip-bot for Marc Zyngier @ 2022-02-15 12:20 UTC (permalink / raw)
  To: linux-kernel; +Cc: Marc Zyngier, Linus Walleij, tglx

The following commit has been merged into the irq/irqchip-next branch of irqchip:

Commit-ID:     393e1280f765661cf39785e967676a4e57324126
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/393e1280f765661cf39785e967676a4e57324126
Author:        Marc Zyngier <maz@kernel.org>
AuthorDate:    Wed, 09 Feb 2022 16:25:59 
Committer:     Marc Zyngier <maz@kernel.org>
CommitterDate: Tue, 15 Feb 2022 11:10:21 

genirq: Allow irq_chip registration functions to take a const irq_chip

In order to let a const irqchip be fed to the irqchip layer, adjust
the various prototypes. An extra cast in irq_set_chip()() is required
to avoid a warning.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220209162607.1118325-3-maz@kernel.org
---
 include/linux/irq.h |  7 ++++---
 kernel/irq/chip.c   |  9 +++------
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/include/linux/irq.h b/include/linux/irq.h
index 2cb2e2a..f92788c 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -710,10 +710,11 @@ extern struct irq_chip no_irq_chip;
 extern struct irq_chip dummy_irq_chip;
 
 extern void
-irq_set_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
+irq_set_chip_and_handler_name(unsigned int irq, const struct irq_chip *chip,
 			      irq_flow_handler_t handle, const char *name);
 
-static inline void irq_set_chip_and_handler(unsigned int irq, struct irq_chip *chip,
+static inline void irq_set_chip_and_handler(unsigned int irq,
+					    const struct irq_chip *chip,
 					    irq_flow_handler_t handle)
 {
 	irq_set_chip_and_handler_name(irq, chip, handle, NULL);
@@ -803,7 +804,7 @@ static inline void irq_set_percpu_devid_flags(unsigned int irq)
 }
 
 /* Set/get chip/data for an IRQ: */
-extern int irq_set_chip(unsigned int irq, struct irq_chip *chip);
+extern int irq_set_chip(unsigned int irq, const struct irq_chip *chip);
 extern int irq_set_handler_data(unsigned int irq, void *data);
 extern int irq_set_chip_data(unsigned int irq, void *data);
 extern int irq_set_irq_type(unsigned int irq, unsigned int type);
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 24b6f2b..54af0de 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -38,7 +38,7 @@ struct irqaction chained_action = {
  *	@irq:	irq number
  *	@chip:	pointer to irq chip description structure
  */
-int irq_set_chip(unsigned int irq, struct irq_chip *chip)
+int irq_set_chip(unsigned int irq, const struct irq_chip *chip)
 {
 	unsigned long flags;
 	struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
@@ -46,10 +46,7 @@ int irq_set_chip(unsigned int irq, struct irq_chip *chip)
 	if (!desc)
 		return -EINVAL;
 
-	if (!chip)
-		chip = &no_irq_chip;
-
-	desc->irq_data.chip = chip;
+	desc->irq_data.chip = (struct irq_chip *)(chip ?: &no_irq_chip);
 	irq_put_desc_unlock(desc, flags);
 	/*
 	 * For !CONFIG_SPARSE_IRQ make the irq show up in
@@ -1073,7 +1070,7 @@ irq_set_chained_handler_and_data(unsigned int irq, irq_flow_handler_t handle,
 EXPORT_SYMBOL_GPL(irq_set_chained_handler_and_data);
 
 void
-irq_set_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
+irq_set_chip_and_handler_name(unsigned int irq, const struct irq_chip *chip,
 			      irq_flow_handler_t handle, const char *name)
 {
 	irq_set_chip(irq, chip);

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [irqchip: irq/irqchip-next] irqdomain: Let irq_domain_set_{info,hwirq_and_chip} take a const irq_chip
  2022-02-09 16:25 ` [PATCH 01/10] irqdomain: Let irq_domain_set_{info,hwirq_and_chip} take a const irq_chip Marc Zyngier
@ 2022-02-15 12:20   ` irqchip-bot for Marc Zyngier
  0 siblings, 0 replies; 39+ messages in thread
From: irqchip-bot for Marc Zyngier @ 2022-02-15 12:20 UTC (permalink / raw)
  To: linux-kernel; +Cc: Marc Zyngier, Linus Walleij, tglx

The following commit has been merged into the irq/irqchip-next branch of irqchip:

Commit-ID:     45ec846c1cd11835a29c85645065115dd791aa45
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/45ec846c1cd11835a29c85645065115dd791aa45
Author:        Marc Zyngier <maz@kernel.org>
AuthorDate:    Wed, 09 Feb 2022 16:25:58 
Committer:     Marc Zyngier <maz@kernel.org>
CommitterDate: Tue, 15 Feb 2022 11:10:21 

irqdomain: Let irq_domain_set_{info,hwirq_and_chip} take a const irq_chip

In order to let a const irqchip be fed to the irqchip layer, adjust
the various prototypes. An extra cast in irq_domain_set_hwirq_and_chip()
is required to avoid a warning.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220209162607.1118325-2-maz@kernel.org
---
 include/linux/irqdomain.h |  5 +++--
 kernel/irq/irqdomain.c    |  9 +++++----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index be25a33..00d577f 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -479,7 +479,8 @@ int irq_destroy_ipi(unsigned int irq, const struct cpumask *dest);
 extern struct irq_data *irq_domain_get_irq_data(struct irq_domain *domain,
 						unsigned int virq);
 extern void irq_domain_set_info(struct irq_domain *domain, unsigned int virq,
-				irq_hw_number_t hwirq, struct irq_chip *chip,
+				irq_hw_number_t hwirq,
+				const struct irq_chip *chip,
 				void *chip_data, irq_flow_handler_t handler,
 				void *handler_data, const char *handler_name);
 extern void irq_domain_reset_irq_data(struct irq_data *irq_data);
@@ -522,7 +523,7 @@ extern int irq_domain_alloc_irqs_hierarchy(struct irq_domain *domain,
 extern int irq_domain_set_hwirq_and_chip(struct irq_domain *domain,
 					 unsigned int virq,
 					 irq_hw_number_t hwirq,
-					 struct irq_chip *chip,
+					 const struct irq_chip *chip,
 					 void *chip_data);
 extern void irq_domain_free_irqs_common(struct irq_domain *domain,
 					unsigned int virq,
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index bf38c54..d5ce965 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -1319,7 +1319,8 @@ EXPORT_SYMBOL_GPL(irq_domain_get_irq_data);
  * @chip_data:	The associated chip data
  */
 int irq_domain_set_hwirq_and_chip(struct irq_domain *domain, unsigned int virq,
-				  irq_hw_number_t hwirq, struct irq_chip *chip,
+				  irq_hw_number_t hwirq,
+				  const struct irq_chip *chip,
 				  void *chip_data)
 {
 	struct irq_data *irq_data = irq_domain_get_irq_data(domain, virq);
@@ -1328,7 +1329,7 @@ int irq_domain_set_hwirq_and_chip(struct irq_domain *domain, unsigned int virq,
 		return -ENOENT;
 
 	irq_data->hwirq = hwirq;
-	irq_data->chip = chip ? chip : &no_irq_chip;
+	irq_data->chip = (struct irq_chip *)(chip ? chip : &no_irq_chip);
 	irq_data->chip_data = chip_data;
 
 	return 0;
@@ -1347,7 +1348,7 @@ EXPORT_SYMBOL_GPL(irq_domain_set_hwirq_and_chip);
  * @handler_name:	The interrupt handler name
  */
 void irq_domain_set_info(struct irq_domain *domain, unsigned int virq,
-			 irq_hw_number_t hwirq, struct irq_chip *chip,
+			 irq_hw_number_t hwirq, const struct irq_chip *chip,
 			 void *chip_data, irq_flow_handler_t handler,
 			 void *handler_data, const char *handler_name)
 {
@@ -1853,7 +1854,7 @@ EXPORT_SYMBOL_GPL(irq_domain_get_irq_data);
  * @handler_name:	The interrupt handler name
  */
 void irq_domain_set_info(struct irq_domain *domain, unsigned int virq,
-			 irq_hw_number_t hwirq, struct irq_chip *chip,
+			 irq_hw_number_t hwirq, const struct irq_chip *chip,
 			 void *chip_data, irq_flow_handler_t handler,
 			 void *handler_data, const char *handler_name)
 {

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* Re: [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name
  2022-02-10 23:41 ` [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name Linus Walleij
  2022-02-15 12:13   ` Marc Zyngier
@ 2022-02-15 15:37   ` Andy Shevchenko
  2022-02-19  1:03     ` Linus Walleij
  1 sibling, 1 reply; 39+ messages in thread
From: Andy Shevchenko @ 2022-02-15 15:37 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Marc Zyngier, Bartosz Golaszewski, Linux Kernel Mailing List,
	open list:GPIO SUBSYSTEM, Matthias Brugger, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Tony Lindgren, Thomas Gleixner,
	Vladimir Zapolskiy, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Emil Renner Berthing, Android Kernel Team

On Fri, Feb 11, 2022 at 8:31 AM Linus Walleij <linus.walleij@linaro.org> wrote:
> On Wed, Feb 9, 2022 at 5:26 PM Marc Zyngier <maz@kernel.org> wrote:

...

> Since ... I am mostly
> playing with a baby during the daytime

A bit of a side topic, since I need to send a PR for fixes before my
vacation starts tomorrow, should I Cc my PR to that Linus as well, so
he can accept it?
It will contain two one-liner ID patches to pin control Intel drivers
and won't conflict with anything (as far as I am aware and know).

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name
  2022-02-15 15:37   ` Andy Shevchenko
@ 2022-02-19  1:03     ` Linus Walleij
  0 siblings, 0 replies; 39+ messages in thread
From: Linus Walleij @ 2022-02-19  1:03 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Marc Zyngier, Bartosz Golaszewski, Linux Kernel Mailing List,
	open list:GPIO SUBSYSTEM, Matthias Brugger, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Tony Lindgren, Thomas Gleixner,
	Vladimir Zapolskiy, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Emil Renner Berthing, Android Kernel Team

On Tue, Feb 15, 2022 at 4:38 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Fri, Feb 11, 2022 at 8:31 AM Linus Walleij <linus.walleij@linaro.org> wrote:
> > On Wed, Feb 9, 2022 at 5:26 PM Marc Zyngier <maz@kernel.org> wrote:
>
> ...
>
> > Since ... I am mostly
> > playing with a baby during the daytime
>
> A bit of a side topic, since I need to send a PR for fixes before my
> vacation starts tomorrow, should I Cc my PR to that Linus as well, so
> he can accept it?
> It will contain two one-liner ID patches to pin control Intel drivers
> and won't conflict with anything (as far as I am aware and know).

I manage the pin control stuff but at a bit slow pace, so I'll pick
it up!

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2022-02-19  1:03 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-09 16:25 [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name Marc Zyngier
2022-02-09 16:25 ` [PATCH 01/10] irqdomain: Let irq_domain_set_{info,hwirq_and_chip} take a const irq_chip Marc Zyngier
2022-02-15 12:20   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-02-09 16:25 ` [PATCH 02/10] genirq: Allow irq_chip registration functions to " Marc Zyngier
2022-02-15 12:20   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-02-09 16:26 ` [PATCH 03/10] irqchip/gic: Switch to dynamic chip name output Marc Zyngier
2022-02-10 23:38   ` Linus Walleij
2022-02-11  9:08     ` Marc Zyngier
2022-02-15 12:19   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-02-09 16:26 ` [PATCH 04/10] irqchip/lpc32xx: " Marc Zyngier
2022-02-15 12:19   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-02-09 16:26 ` [PATCH 05/10] irqchip/mvebu-pic: " Marc Zyngier
2022-02-14 14:48   ` Gregory CLEMENT
2022-02-15 12:19   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-02-09 16:26 ` [PATCH 06/10] irqchip/ts4800: " Marc Zyngier
2022-02-15 12:19   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-02-09 16:26 ` [PATCH 07/10] irqchip/versatile-fpga: " Marc Zyngier
2022-02-10 23:29   ` Linus Walleij
2022-02-15 12:19   ` [irqchip: irq/irqchip-next] " irqchip-bot for Marc Zyngier
2022-02-09 16:26 ` [PATCH 08/10] gpio: mt7621: " Marc Zyngier
2022-02-09 16:26 ` [PATCH 09/10] gpio: omap: " Marc Zyngier
2022-02-09 16:26 ` [PATCH 10/10] pinctrl: starfive: " Marc Zyngier
2022-02-09 23:30   ` Emil Renner Berthing
2022-02-10  9:06     ` Marc Zyngier
2022-02-10 12:59       ` Emil Renner Berthing
2022-02-10 13:32         ` Marc Zyngier
2022-02-10 13:44           ` Emil Renner Berthing
2022-02-10 13:50             ` Marc Zyngier
2022-02-10 14:14               ` Emil Renner Berthing
2022-02-10 14:22                 ` Marc Zyngier, Linus Walleij
2022-02-10 14:34                 ` Marc Zyngier
2022-02-10 14:46                   ` Emil Renner Berthing
2022-02-11  0:18                   ` Linus Walleij
2022-02-11  0:15       ` Linus Walleij
2022-02-11  9:20         ` Marc Zyngier
2022-02-10 23:41 ` [PATCH 00/10] irqchip: Prevent drivers abusing irq_chip::name Linus Walleij
2022-02-15 12:13   ` Marc Zyngier
2022-02-15 15:37   ` Andy Shevchenko
2022-02-19  1:03     ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).