All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 00/14] Modular Broadcom irqchip drivers
@ 2021-10-09  2:20 ` Florian Fainelli
  0 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

Hi Thomas, Marc,

This patch series aims at allowing the 3 interrupt controller drivers
used on Broadcom STB platforms to be built as modules in order for those
to be shipped in a GKI enabled system (Android).

The irq-bcm7038-l1 requires us to export a number of symbols, which is
not great, but there are not obvious solutions other than adding
accessor functions to get the same information.

Assuming you are happy with the changes though, please do take the last
two changes as well through your tree.

Thanks!

Changes in v4:

- added Thomas' Acked-by for patch #1
- added Rob's Reviewed-by for patch 9 and updated qcom-pdc.c as
  suggested
- s/argument/parameter/ in patch #14 as suggested by Sergey

Changes in v3:

- avoid the use of the cpu_logical_map array for platforms other than
  MIPS
- removed the bogus irq_set_affinity callback for platforms other than
  MIPS
- bring-back the export of irq_gc_noop() lost in the v2

Changes in v2:

- avoid using irq_to_desc() and use irq_get_irq_data() instead
- re-order patches to avoid linking failure for irq-brcmstb-l2
- removed the use of .irq_cpu_offline() and converted BMIPS to use
  irq_migrate_all_off_this_cpu()
- avoid exporting of_irq_count() and use a platform device passed
  down from the irqchip platform driver registration code instead
- added kernel-doc fix

Florian Fainelli (14):
  MIPS: BMIPS: Remove use of irq_cpu_offline
  irqchip/irq-bcm7038-l1: Remove .irq_cpu_offline()
  irqchip/irq-bcm7038-l1: Use irq_get_irq_data()
  irqchip/irq-bcm7038-l1: Gate use of CPU logical map to MIPS
  irqchip/irq-bcm7038-l1: Restrict affinity setting to MIPS
  irqchip/irq-bcm7038-l1: Switch to IRQCHIP_PLATFORM_DRIVER
  genirq: Export irq_gc_{unmask_enable,mask_disable}_reg
  irqchip/irq-brcmstb-l2: Switch to IRQCHIP_PLATFORM_DRIVER
  irqchip: Provide platform_device to of_irq_init_cb_t
  genirq: Export irq_gc_noop()
  irqchip/irq-bcm7120-l2: Switch to IRQCHIP_PLATFORM_DRIVER
  arm64: broadcom: Removed forced select of interrupt controllers
  ARM: bcm: Removed forced select of interrupt controllers
  irqchip: Fix kernel-doc parameter typo for IRQCHIP_DECLARE

 arch/arm/mach-bcm/Kconfig        |  4 ---
 arch/arm64/Kconfig.platforms     |  3 --
 arch/mips/Kconfig                |  1 +
 arch/mips/kernel/smp-bmips.c     |  3 +-
 drivers/irqchip/Kconfig          | 12 ++++++--
 drivers/irqchip/irq-bcm7038-l1.c | 47 ++++++++------------------------
 drivers/irqchip/irq-bcm7120-l2.c | 28 +++++++++++--------
 drivers/irqchip/irq-brcmstb-l2.c | 16 ++++++-----
 drivers/irqchip/irqchip.c        |  2 +-
 drivers/irqchip/qcom-pdc.c       |  3 +-
 drivers/of/irq.c                 |  2 +-
 include/linux/irqchip.h          |  2 +-
 include/linux/of_irq.h           |  5 +++-
 kernel/irq/generic-chip.c        |  3 ++
 14 files changed, 60 insertions(+), 71 deletions(-)

-- 
2.25.1


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

* [PATCH v4 00/14] Modular Broadcom irqchip drivers
@ 2021-10-09  2:20 ` Florian Fainelli
  0 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

Hi Thomas, Marc,

This patch series aims at allowing the 3 interrupt controller drivers
used on Broadcom STB platforms to be built as modules in order for those
to be shipped in a GKI enabled system (Android).

The irq-bcm7038-l1 requires us to export a number of symbols, which is
not great, but there are not obvious solutions other than adding
accessor functions to get the same information.

Assuming you are happy with the changes though, please do take the last
two changes as well through your tree.

Thanks!

Changes in v4:

- added Thomas' Acked-by for patch #1
- added Rob's Reviewed-by for patch 9 and updated qcom-pdc.c as
  suggested
- s/argument/parameter/ in patch #14 as suggested by Sergey

Changes in v3:

- avoid the use of the cpu_logical_map array for platforms other than
  MIPS
- removed the bogus irq_set_affinity callback for platforms other than
  MIPS
- bring-back the export of irq_gc_noop() lost in the v2

Changes in v2:

- avoid using irq_to_desc() and use irq_get_irq_data() instead
- re-order patches to avoid linking failure for irq-brcmstb-l2
- removed the use of .irq_cpu_offline() and converted BMIPS to use
  irq_migrate_all_off_this_cpu()
- avoid exporting of_irq_count() and use a platform device passed
  down from the irqchip platform driver registration code instead
- added kernel-doc fix

Florian Fainelli (14):
  MIPS: BMIPS: Remove use of irq_cpu_offline
  irqchip/irq-bcm7038-l1: Remove .irq_cpu_offline()
  irqchip/irq-bcm7038-l1: Use irq_get_irq_data()
  irqchip/irq-bcm7038-l1: Gate use of CPU logical map to MIPS
  irqchip/irq-bcm7038-l1: Restrict affinity setting to MIPS
  irqchip/irq-bcm7038-l1: Switch to IRQCHIP_PLATFORM_DRIVER
  genirq: Export irq_gc_{unmask_enable,mask_disable}_reg
  irqchip/irq-brcmstb-l2: Switch to IRQCHIP_PLATFORM_DRIVER
  irqchip: Provide platform_device to of_irq_init_cb_t
  genirq: Export irq_gc_noop()
  irqchip/irq-bcm7120-l2: Switch to IRQCHIP_PLATFORM_DRIVER
  arm64: broadcom: Removed forced select of interrupt controllers
  ARM: bcm: Removed forced select of interrupt controllers
  irqchip: Fix kernel-doc parameter typo for IRQCHIP_DECLARE

 arch/arm/mach-bcm/Kconfig        |  4 ---
 arch/arm64/Kconfig.platforms     |  3 --
 arch/mips/Kconfig                |  1 +
 arch/mips/kernel/smp-bmips.c     |  3 +-
 drivers/irqchip/Kconfig          | 12 ++++++--
 drivers/irqchip/irq-bcm7038-l1.c | 47 ++++++++------------------------
 drivers/irqchip/irq-bcm7120-l2.c | 28 +++++++++++--------
 drivers/irqchip/irq-brcmstb-l2.c | 16 ++++++-----
 drivers/irqchip/irqchip.c        |  2 +-
 drivers/irqchip/qcom-pdc.c       |  3 +-
 drivers/of/irq.c                 |  2 +-
 include/linux/irqchip.h          |  2 +-
 include/linux/of_irq.h           |  5 +++-
 kernel/irq/generic-chip.c        |  3 ++
 14 files changed, 60 insertions(+), 71 deletions(-)

-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 01/14] MIPS: BMIPS: Remove use of irq_cpu_offline
  2021-10-09  2:20 ` Florian Fainelli
@ 2021-10-09  2:20   ` Florian Fainelli
  -1 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Thomas Gleixner, Thomas Bogendoerfer, Ray Jui,
	Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Marc Zyngier,
	Rob Herring, Frank Rowand, moderated list:ARM SUB-ARCHITECTURES,
	open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

irq_cpu_offline() is only used by MIPS and we should instead use
irq_migrate_all_off_this_cpu(). This will be helpful in order to remove
drivers/irqchip/irq-bcm7038-l1.c irq_cpu_offline callback which would
have got in the way of making this driver modular.

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 arch/mips/Kconfig            | 1 +
 arch/mips/kernel/smp-bmips.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 771ca53af06d..2c03b27cec02 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1782,6 +1782,7 @@ config CPU_BMIPS
 	select CPU_HAS_PREFETCH
 	select CPU_SUPPORTS_CPUFREQ
 	select MIPS_EXTERNAL_TIMER
+	select GENERIC_IRQ_MIGRATION if HOTPLUG_CPU
 	help
 	  Support for BMIPS32/3300/4350/4380 and BMIPS5000 processors.
 
diff --git a/arch/mips/kernel/smp-bmips.c b/arch/mips/kernel/smp-bmips.c
index b6ef5f7312cf..f5d7bfa3472a 100644
--- a/arch/mips/kernel/smp-bmips.c
+++ b/arch/mips/kernel/smp-bmips.c
@@ -26,6 +26,7 @@
 #include <linux/bug.h>
 #include <linux/kernel.h>
 #include <linux/kexec.h>
+#include <linux/irq.h>
 
 #include <asm/time.h>
 #include <asm/processor.h>
@@ -373,7 +374,7 @@ static int bmips_cpu_disable(void)
 
 	set_cpu_online(cpu, false);
 	calculate_cpu_foreign_map();
-	irq_cpu_offline();
+	irq_migrate_all_off_this_cpu();
 	clear_c0_status(IE_IRQ5);
 
 	local_flush_tlb_all();
-- 
2.25.1


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

* [PATCH v4 01/14] MIPS: BMIPS: Remove use of irq_cpu_offline
@ 2021-10-09  2:20   ` Florian Fainelli
  0 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Thomas Gleixner, Thomas Bogendoerfer, Ray Jui,
	Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Marc Zyngier,
	Rob Herring, Frank Rowand, moderated list:ARM SUB-ARCHITECTURES,
	open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

irq_cpu_offline() is only used by MIPS and we should instead use
irq_migrate_all_off_this_cpu(). This will be helpful in order to remove
drivers/irqchip/irq-bcm7038-l1.c irq_cpu_offline callback which would
have got in the way of making this driver modular.

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 arch/mips/Kconfig            | 1 +
 arch/mips/kernel/smp-bmips.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 771ca53af06d..2c03b27cec02 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1782,6 +1782,7 @@ config CPU_BMIPS
 	select CPU_HAS_PREFETCH
 	select CPU_SUPPORTS_CPUFREQ
 	select MIPS_EXTERNAL_TIMER
+	select GENERIC_IRQ_MIGRATION if HOTPLUG_CPU
 	help
 	  Support for BMIPS32/3300/4350/4380 and BMIPS5000 processors.
 
diff --git a/arch/mips/kernel/smp-bmips.c b/arch/mips/kernel/smp-bmips.c
index b6ef5f7312cf..f5d7bfa3472a 100644
--- a/arch/mips/kernel/smp-bmips.c
+++ b/arch/mips/kernel/smp-bmips.c
@@ -26,6 +26,7 @@
 #include <linux/bug.h>
 #include <linux/kernel.h>
 #include <linux/kexec.h>
+#include <linux/irq.h>
 
 #include <asm/time.h>
 #include <asm/processor.h>
@@ -373,7 +374,7 @@ static int bmips_cpu_disable(void)
 
 	set_cpu_online(cpu, false);
 	calculate_cpu_foreign_map();
-	irq_cpu_offline();
+	irq_migrate_all_off_this_cpu();
 	clear_c0_status(IE_IRQ5);
 
 	local_flush_tlb_all();
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 02/14] irqchip/irq-bcm7038-l1: Remove .irq_cpu_offline()
  2021-10-09  2:20 ` Florian Fainelli
@ 2021-10-09  2:20   ` Florian Fainelli
  -1 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

With arch/mips/kernel/smp-bmips.c having been migrated away from
irq_cpu_offline() and use irq_migrate_all_off_this_cpu() instead, we no
longer need to implement an .irq_cpu_offline() callback. This is a
necessary change to facilitate the building of this driver as a module.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/irqchip/irq-bcm7038-l1.c | 30 ------------------------------
 1 file changed, 30 deletions(-)

diff --git a/drivers/irqchip/irq-bcm7038-l1.c b/drivers/irqchip/irq-bcm7038-l1.c
index a035c385ca7a..750156217c82 100644
--- a/drivers/irqchip/irq-bcm7038-l1.c
+++ b/drivers/irqchip/irq-bcm7038-l1.c
@@ -221,33 +221,6 @@ static int bcm7038_l1_set_affinity(struct irq_data *d,
 	return 0;
 }
 
-#ifdef CONFIG_SMP
-static void bcm7038_l1_cpu_offline(struct irq_data *d)
-{
-	struct cpumask *mask = irq_data_get_affinity_mask(d);
-	int cpu = smp_processor_id();
-	cpumask_t new_affinity;
-
-	/* This CPU was not on the affinity mask */
-	if (!cpumask_test_cpu(cpu, mask))
-		return;
-
-	if (cpumask_weight(mask) > 1) {
-		/*
-		 * Multiple CPU affinity, remove this CPU from the affinity
-		 * mask
-		 */
-		cpumask_copy(&new_affinity, mask);
-		cpumask_clear_cpu(cpu, &new_affinity);
-	} else {
-		/* Only CPU, put on the lowest online CPU */
-		cpumask_clear(&new_affinity);
-		cpumask_set_cpu(cpumask_first(cpu_online_mask), &new_affinity);
-	}
-	irq_set_affinity_locked(d, &new_affinity, false);
-}
-#endif
-
 static int __init bcm7038_l1_init_one(struct device_node *dn,
 				      unsigned int idx,
 				      struct bcm7038_l1_chip *intc)
@@ -396,9 +369,6 @@ static struct irq_chip bcm7038_l1_irq_chip = {
 	.irq_mask		= bcm7038_l1_mask,
 	.irq_unmask		= bcm7038_l1_unmask,
 	.irq_set_affinity	= bcm7038_l1_set_affinity,
-#ifdef CONFIG_SMP
-	.irq_cpu_offline	= bcm7038_l1_cpu_offline,
-#endif
 #ifdef CONFIG_PM_SLEEP
 	.irq_set_wake		= bcm7038_l1_set_wake,
 #endif
-- 
2.25.1


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

* [PATCH v4 02/14] irqchip/irq-bcm7038-l1: Remove .irq_cpu_offline()
@ 2021-10-09  2:20   ` Florian Fainelli
  0 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

With arch/mips/kernel/smp-bmips.c having been migrated away from
irq_cpu_offline() and use irq_migrate_all_off_this_cpu() instead, we no
longer need to implement an .irq_cpu_offline() callback. This is a
necessary change to facilitate the building of this driver as a module.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/irqchip/irq-bcm7038-l1.c | 30 ------------------------------
 1 file changed, 30 deletions(-)

diff --git a/drivers/irqchip/irq-bcm7038-l1.c b/drivers/irqchip/irq-bcm7038-l1.c
index a035c385ca7a..750156217c82 100644
--- a/drivers/irqchip/irq-bcm7038-l1.c
+++ b/drivers/irqchip/irq-bcm7038-l1.c
@@ -221,33 +221,6 @@ static int bcm7038_l1_set_affinity(struct irq_data *d,
 	return 0;
 }
 
-#ifdef CONFIG_SMP
-static void bcm7038_l1_cpu_offline(struct irq_data *d)
-{
-	struct cpumask *mask = irq_data_get_affinity_mask(d);
-	int cpu = smp_processor_id();
-	cpumask_t new_affinity;
-
-	/* This CPU was not on the affinity mask */
-	if (!cpumask_test_cpu(cpu, mask))
-		return;
-
-	if (cpumask_weight(mask) > 1) {
-		/*
-		 * Multiple CPU affinity, remove this CPU from the affinity
-		 * mask
-		 */
-		cpumask_copy(&new_affinity, mask);
-		cpumask_clear_cpu(cpu, &new_affinity);
-	} else {
-		/* Only CPU, put on the lowest online CPU */
-		cpumask_clear(&new_affinity);
-		cpumask_set_cpu(cpumask_first(cpu_online_mask), &new_affinity);
-	}
-	irq_set_affinity_locked(d, &new_affinity, false);
-}
-#endif
-
 static int __init bcm7038_l1_init_one(struct device_node *dn,
 				      unsigned int idx,
 				      struct bcm7038_l1_chip *intc)
@@ -396,9 +369,6 @@ static struct irq_chip bcm7038_l1_irq_chip = {
 	.irq_mask		= bcm7038_l1_mask,
 	.irq_unmask		= bcm7038_l1_unmask,
 	.irq_set_affinity	= bcm7038_l1_set_affinity,
-#ifdef CONFIG_SMP
-	.irq_cpu_offline	= bcm7038_l1_cpu_offline,
-#endif
 #ifdef CONFIG_PM_SLEEP
 	.irq_set_wake		= bcm7038_l1_set_wake,
 #endif
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 03/14] irqchip/irq-bcm7038-l1: Use irq_get_irq_data()
  2021-10-09  2:20 ` Florian Fainelli
@ 2021-10-09  2:20   ` Florian Fainelli
  -1 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

Using irq_desc_get_irq_data(irq_to_desc()) to retrieve the irq_data
structure from a virtual interrupt number is going to be problematic to
make irq-bcm7038-l1 a module because irq_to_desc() is not exported, and
there is no intent to export it to modules, see 64a1b95bb9fe ("genirq:
Restrict export of irq_to_desc()").

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/irqchip/irq-bcm7038-l1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-bcm7038-l1.c b/drivers/irqchip/irq-bcm7038-l1.c
index 750156217c82..14caf32dc23e 100644
--- a/drivers/irqchip/irq-bcm7038-l1.c
+++ b/drivers/irqchip/irq-bcm7038-l1.c
@@ -386,7 +386,7 @@ static int bcm7038_l1_map(struct irq_domain *d, unsigned int virq,
 
 	irq_set_chip_and_handler(virq, &bcm7038_l1_irq_chip, handle_level_irq);
 	irq_set_chip_data(virq, d->host_data);
-	irqd_set_single_target(irq_desc_get_irq_data(irq_to_desc(virq)));
+	irqd_set_single_target(irq_get_irq_data(virq));
 	return 0;
 }
 
-- 
2.25.1


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

* [PATCH v4 03/14] irqchip/irq-bcm7038-l1: Use irq_get_irq_data()
@ 2021-10-09  2:20   ` Florian Fainelli
  0 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

Using irq_desc_get_irq_data(irq_to_desc()) to retrieve the irq_data
structure from a virtual interrupt number is going to be problematic to
make irq-bcm7038-l1 a module because irq_to_desc() is not exported, and
there is no intent to export it to modules, see 64a1b95bb9fe ("genirq:
Restrict export of irq_to_desc()").

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/irqchip/irq-bcm7038-l1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-bcm7038-l1.c b/drivers/irqchip/irq-bcm7038-l1.c
index 750156217c82..14caf32dc23e 100644
--- a/drivers/irqchip/irq-bcm7038-l1.c
+++ b/drivers/irqchip/irq-bcm7038-l1.c
@@ -386,7 +386,7 @@ static int bcm7038_l1_map(struct irq_domain *d, unsigned int virq,
 
 	irq_set_chip_and_handler(virq, &bcm7038_l1_irq_chip, handle_level_irq);
 	irq_set_chip_data(virq, d->host_data);
-	irqd_set_single_target(irq_desc_get_irq_data(irq_to_desc(virq)));
+	irqd_set_single_target(irq_get_irq_data(virq));
 	return 0;
 }
 
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 04/14] irqchip/irq-bcm7038-l1: Gate use of CPU logical map to MIPS
  2021-10-09  2:20 ` Florian Fainelli
@ 2021-10-09  2:20   ` Florian Fainelli
  -1 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

The use of the cpu_logical_map[] array is only relevant for MIPS based
platform where this driver is used as a first level interrupt controller
and contains multiple register groups to map with an associated CPU.

On ARM/ARM64 based systems this interrupt controller is present and used
as a second level interrupt controller hanging off the ARM GIC. That
copy of the interrupt controller contains a single group, resulting in
the intc->cpus[] array to be of size 1.

Things happened to work in that case because we install that interrupt
controller as a chained handler which does not allow it to be affine to
any CPU but the boot CPU which happens to be 0, therefore we never
de-reference past intc->cpus[] but with the current code in place, we do
leave a chance of de-referencing the array past its bounds.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/irqchip/irq-bcm7038-l1.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/irqchip/irq-bcm7038-l1.c b/drivers/irqchip/irq-bcm7038-l1.c
index 14caf32dc23e..3c4e348c661e 100644
--- a/drivers/irqchip/irq-bcm7038-l1.c
+++ b/drivers/irqchip/irq-bcm7038-l1.c
@@ -28,9 +28,6 @@
 #include <linux/irqchip.h>
 #include <linux/irqchip/chained_irq.h>
 #include <linux/syscore_ops.h>
-#ifdef CONFIG_ARM
-#include <asm/smp_plat.h>
-#endif
 
 #define IRQS_PER_WORD		32
 #define REG_BYTES_PER_IRQ_WORD	(sizeof(u32) * 4)
@@ -127,7 +124,7 @@ static void bcm7038_l1_irq_handle(struct irq_desc *desc)
 	struct irq_chip *chip = irq_desc_get_chip(desc);
 	unsigned int idx;
 
-#ifdef CONFIG_SMP
+#if defined(CONFIG_SMP) && defined(CONFIG_MIPS)
 	cpu = intc->cpus[cpu_logical_map(smp_processor_id())];
 #else
 	cpu = intc->cpus[0];
@@ -301,7 +298,7 @@ static int bcm7038_l1_suspend(void)
 	u32 val;
 
 	/* Wakeup interrupt should only come from the boot cpu */
-#ifdef CONFIG_SMP
+#if defined(CONFIG_SMP) && defined(CONFIG_MIPS)
 	boot_cpu = cpu_logical_map(0);
 #else
 	boot_cpu = 0;
@@ -325,7 +322,7 @@ static void bcm7038_l1_resume(void)
 	struct bcm7038_l1_chip *intc;
 	int boot_cpu, word;
 
-#ifdef CONFIG_SMP
+#if defined(CONFIG_SMP) && defined(CONFIG_MIPS)
 	boot_cpu = cpu_logical_map(0);
 #else
 	boot_cpu = 0;
-- 
2.25.1


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

* [PATCH v4 04/14] irqchip/irq-bcm7038-l1: Gate use of CPU logical map to MIPS
@ 2021-10-09  2:20   ` Florian Fainelli
  0 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

The use of the cpu_logical_map[] array is only relevant for MIPS based
platform where this driver is used as a first level interrupt controller
and contains multiple register groups to map with an associated CPU.

On ARM/ARM64 based systems this interrupt controller is present and used
as a second level interrupt controller hanging off the ARM GIC. That
copy of the interrupt controller contains a single group, resulting in
the intc->cpus[] array to be of size 1.

Things happened to work in that case because we install that interrupt
controller as a chained handler which does not allow it to be affine to
any CPU but the boot CPU which happens to be 0, therefore we never
de-reference past intc->cpus[] but with the current code in place, we do
leave a chance of de-referencing the array past its bounds.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/irqchip/irq-bcm7038-l1.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/irqchip/irq-bcm7038-l1.c b/drivers/irqchip/irq-bcm7038-l1.c
index 14caf32dc23e..3c4e348c661e 100644
--- a/drivers/irqchip/irq-bcm7038-l1.c
+++ b/drivers/irqchip/irq-bcm7038-l1.c
@@ -28,9 +28,6 @@
 #include <linux/irqchip.h>
 #include <linux/irqchip/chained_irq.h>
 #include <linux/syscore_ops.h>
-#ifdef CONFIG_ARM
-#include <asm/smp_plat.h>
-#endif
 
 #define IRQS_PER_WORD		32
 #define REG_BYTES_PER_IRQ_WORD	(sizeof(u32) * 4)
@@ -127,7 +124,7 @@ static void bcm7038_l1_irq_handle(struct irq_desc *desc)
 	struct irq_chip *chip = irq_desc_get_chip(desc);
 	unsigned int idx;
 
-#ifdef CONFIG_SMP
+#if defined(CONFIG_SMP) && defined(CONFIG_MIPS)
 	cpu = intc->cpus[cpu_logical_map(smp_processor_id())];
 #else
 	cpu = intc->cpus[0];
@@ -301,7 +298,7 @@ static int bcm7038_l1_suspend(void)
 	u32 val;
 
 	/* Wakeup interrupt should only come from the boot cpu */
-#ifdef CONFIG_SMP
+#if defined(CONFIG_SMP) && defined(CONFIG_MIPS)
 	boot_cpu = cpu_logical_map(0);
 #else
 	boot_cpu = 0;
@@ -325,7 +322,7 @@ static void bcm7038_l1_resume(void)
 	struct bcm7038_l1_chip *intc;
 	int boot_cpu, word;
 
-#ifdef CONFIG_SMP
+#if defined(CONFIG_SMP) && defined(CONFIG_MIPS)
 	boot_cpu = cpu_logical_map(0);
 #else
 	boot_cpu = 0;
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 05/14] irqchip/irq-bcm7038-l1: Restrict affinity setting to MIPS
  2021-10-09  2:20 ` Florian Fainelli
@ 2021-10-09  2:20   ` Florian Fainelli
  -1 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

Only MIPS based platforms using this interrupt controller as first level
interrupt controller can actually change the affinity of interrupts by
re-programming the affinity mask of the interrupt controller and use
another word group to have another CPU process the interrupt.

When this interrupt is used as a second level interrupt controller on
ARM/ARM64 there is no way to change the interrupt affinity. This fixes a
NULL pointer de-reference while trying to change the affinity since
there is only a single word group in that case, and we would have been
overruning the intc->cpus[] array.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/irqchip/irq-bcm7038-l1.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/irqchip/irq-bcm7038-l1.c b/drivers/irqchip/irq-bcm7038-l1.c
index 3c4e348c661e..357570dd8780 100644
--- a/drivers/irqchip/irq-bcm7038-l1.c
+++ b/drivers/irqchip/irq-bcm7038-l1.c
@@ -191,6 +191,7 @@ static void bcm7038_l1_mask(struct irq_data *d)
 	raw_spin_unlock_irqrestore(&intc->lock, flags);
 }
 
+#if defined(CONFIG_MIPS) && defined(CONFIG_SMP)
 static int bcm7038_l1_set_affinity(struct irq_data *d,
 				   const struct cpumask *dest,
 				   bool force)
@@ -217,6 +218,7 @@ static int bcm7038_l1_set_affinity(struct irq_data *d,
 
 	return 0;
 }
+#endif
 
 static int __init bcm7038_l1_init_one(struct device_node *dn,
 				      unsigned int idx,
@@ -365,7 +367,9 @@ static struct irq_chip bcm7038_l1_irq_chip = {
 	.name			= "bcm7038-l1",
 	.irq_mask		= bcm7038_l1_mask,
 	.irq_unmask		= bcm7038_l1_unmask,
+#if defined(CONFIG_SMP) && defined(CONFIG_MIPS)
 	.irq_set_affinity	= bcm7038_l1_set_affinity,
+#endif
 #ifdef CONFIG_PM_SLEEP
 	.irq_set_wake		= bcm7038_l1_set_wake,
 #endif
-- 
2.25.1


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

* [PATCH v4 05/14] irqchip/irq-bcm7038-l1: Restrict affinity setting to MIPS
@ 2021-10-09  2:20   ` Florian Fainelli
  0 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

Only MIPS based platforms using this interrupt controller as first level
interrupt controller can actually change the affinity of interrupts by
re-programming the affinity mask of the interrupt controller and use
another word group to have another CPU process the interrupt.

When this interrupt is used as a second level interrupt controller on
ARM/ARM64 there is no way to change the interrupt affinity. This fixes a
NULL pointer de-reference while trying to change the affinity since
there is only a single word group in that case, and we would have been
overruning the intc->cpus[] array.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/irqchip/irq-bcm7038-l1.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/irqchip/irq-bcm7038-l1.c b/drivers/irqchip/irq-bcm7038-l1.c
index 3c4e348c661e..357570dd8780 100644
--- a/drivers/irqchip/irq-bcm7038-l1.c
+++ b/drivers/irqchip/irq-bcm7038-l1.c
@@ -191,6 +191,7 @@ static void bcm7038_l1_mask(struct irq_data *d)
 	raw_spin_unlock_irqrestore(&intc->lock, flags);
 }
 
+#if defined(CONFIG_MIPS) && defined(CONFIG_SMP)
 static int bcm7038_l1_set_affinity(struct irq_data *d,
 				   const struct cpumask *dest,
 				   bool force)
@@ -217,6 +218,7 @@ static int bcm7038_l1_set_affinity(struct irq_data *d,
 
 	return 0;
 }
+#endif
 
 static int __init bcm7038_l1_init_one(struct device_node *dn,
 				      unsigned int idx,
@@ -365,7 +367,9 @@ static struct irq_chip bcm7038_l1_irq_chip = {
 	.name			= "bcm7038-l1",
 	.irq_mask		= bcm7038_l1_mask,
 	.irq_unmask		= bcm7038_l1_unmask,
+#if defined(CONFIG_SMP) && defined(CONFIG_MIPS)
 	.irq_set_affinity	= bcm7038_l1_set_affinity,
+#endif
 #ifdef CONFIG_PM_SLEEP
 	.irq_set_wake		= bcm7038_l1_set_wake,
 #endif
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 06/14] irqchip/irq-bcm7038-l1: Switch to IRQCHIP_PLATFORM_DRIVER
  2021-10-09  2:20 ` Florian Fainelli
@ 2021-10-09  2:20   ` Florian Fainelli
  -1 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

Allow the user selection and building of this interrupt controller
driver as a module since it is used on ARM/ARM64 based systems as a
second level interrupt controller hanging off the ARM GIC and is
therefore loadable during boot.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/irqchip/Kconfig          | 4 +++-
 drivers/irqchip/irq-bcm7038-l1.c | 6 +++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 4d5924e9f766..3022f6137096 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -115,7 +115,9 @@ config BCM6345_L1_IRQ
 	select GENERIC_IRQ_EFFECTIVE_AFF_MASK
 
 config BCM7038_L1_IRQ
-	bool
+	tristate "Broadcom STB 7038-style L1/L2 interrupt controller driver"
+	depends on ARCH_BRCMSTB || BMIPS_GENERIC
+	default ARCH_BRCMSTB || BMIPS_GENERIC
 	select GENERIC_IRQ_CHIP
 	select IRQ_DOMAIN
 	select GENERIC_IRQ_EFFECTIVE_AFF_MASK
diff --git a/drivers/irqchip/irq-bcm7038-l1.c b/drivers/irqchip/irq-bcm7038-l1.c
index 357570dd8780..a62b96237b82 100644
--- a/drivers/irqchip/irq-bcm7038-l1.c
+++ b/drivers/irqchip/irq-bcm7038-l1.c
@@ -455,4 +455,8 @@ static int __init bcm7038_l1_of_init(struct device_node *dn,
 	return ret;
 }
 
-IRQCHIP_DECLARE(bcm7038_l1, "brcm,bcm7038-l1-intc", bcm7038_l1_of_init);
+IRQCHIP_PLATFORM_DRIVER_BEGIN(bcm7038_l1)
+IRQCHIP_MATCH("brcm,bcm7038-l1-intc", bcm7038_l1_of_init)
+IRQCHIP_PLATFORM_DRIVER_END(bcm7038_l1)
+MODULE_DESCRIPTION("Broadcom STB 7038-style L1/L2 interrupt controller");
+MODULE_LICENSE("GPL v2");
-- 
2.25.1


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

* [PATCH v4 06/14] irqchip/irq-bcm7038-l1: Switch to IRQCHIP_PLATFORM_DRIVER
@ 2021-10-09  2:20   ` Florian Fainelli
  0 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

Allow the user selection and building of this interrupt controller
driver as a module since it is used on ARM/ARM64 based systems as a
second level interrupt controller hanging off the ARM GIC and is
therefore loadable during boot.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/irqchip/Kconfig          | 4 +++-
 drivers/irqchip/irq-bcm7038-l1.c | 6 +++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 4d5924e9f766..3022f6137096 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -115,7 +115,9 @@ config BCM6345_L1_IRQ
 	select GENERIC_IRQ_EFFECTIVE_AFF_MASK
 
 config BCM7038_L1_IRQ
-	bool
+	tristate "Broadcom STB 7038-style L1/L2 interrupt controller driver"
+	depends on ARCH_BRCMSTB || BMIPS_GENERIC
+	default ARCH_BRCMSTB || BMIPS_GENERIC
 	select GENERIC_IRQ_CHIP
 	select IRQ_DOMAIN
 	select GENERIC_IRQ_EFFECTIVE_AFF_MASK
diff --git a/drivers/irqchip/irq-bcm7038-l1.c b/drivers/irqchip/irq-bcm7038-l1.c
index 357570dd8780..a62b96237b82 100644
--- a/drivers/irqchip/irq-bcm7038-l1.c
+++ b/drivers/irqchip/irq-bcm7038-l1.c
@@ -455,4 +455,8 @@ static int __init bcm7038_l1_of_init(struct device_node *dn,
 	return ret;
 }
 
-IRQCHIP_DECLARE(bcm7038_l1, "brcm,bcm7038-l1-intc", bcm7038_l1_of_init);
+IRQCHIP_PLATFORM_DRIVER_BEGIN(bcm7038_l1)
+IRQCHIP_MATCH("brcm,bcm7038-l1-intc", bcm7038_l1_of_init)
+IRQCHIP_PLATFORM_DRIVER_END(bcm7038_l1)
+MODULE_DESCRIPTION("Broadcom STB 7038-style L1/L2 interrupt controller");
+MODULE_LICENSE("GPL v2");
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 07/14] genirq: Export irq_gc_{unmask_enable,mask_disable}_reg
  2021-10-09  2:20 ` Florian Fainelli
@ 2021-10-09  2:20   ` Florian Fainelli
  -1 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

In order to allow drivers/irqchip/irq-brcmstb-l2.c to be built as a
module we need to export: irq_gc_unmask_enable_reg() and
irq_gc_mask_disable_reg().

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 kernel/irq/generic-chip.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c
index cc7cdd26e23e..4c011c21bb1a 100644
--- a/kernel/irq/generic-chip.c
+++ b/kernel/irq/generic-chip.c
@@ -44,6 +44,7 @@ void irq_gc_mask_disable_reg(struct irq_data *d)
 	*ct->mask_cache &= ~mask;
 	irq_gc_unlock(gc);
 }
+EXPORT_SYMBOL_GPL(irq_gc_mask_disable_reg);
 
 /**
  * irq_gc_mask_set_bit - Mask chip via setting bit in mask register
@@ -103,6 +104,7 @@ void irq_gc_unmask_enable_reg(struct irq_data *d)
 	*ct->mask_cache |= mask;
 	irq_gc_unlock(gc);
 }
+EXPORT_SYMBOL_GPL(irq_gc_unmask_enable_reg);
 
 /**
  * irq_gc_ack_set_bit - Ack pending interrupt via setting bit
-- 
2.25.1


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

* [PATCH v4 07/14] genirq: Export irq_gc_{unmask_enable, mask_disable}_reg
@ 2021-10-09  2:20   ` Florian Fainelli
  0 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

In order to allow drivers/irqchip/irq-brcmstb-l2.c to be built as a
module we need to export: irq_gc_unmask_enable_reg() and
irq_gc_mask_disable_reg().

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 kernel/irq/generic-chip.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c
index cc7cdd26e23e..4c011c21bb1a 100644
--- a/kernel/irq/generic-chip.c
+++ b/kernel/irq/generic-chip.c
@@ -44,6 +44,7 @@ void irq_gc_mask_disable_reg(struct irq_data *d)
 	*ct->mask_cache &= ~mask;
 	irq_gc_unlock(gc);
 }
+EXPORT_SYMBOL_GPL(irq_gc_mask_disable_reg);
 
 /**
  * irq_gc_mask_set_bit - Mask chip via setting bit in mask register
@@ -103,6 +104,7 @@ void irq_gc_unmask_enable_reg(struct irq_data *d)
 	*ct->mask_cache |= mask;
 	irq_gc_unlock(gc);
 }
+EXPORT_SYMBOL_GPL(irq_gc_unmask_enable_reg);
 
 /**
  * irq_gc_ack_set_bit - Ack pending interrupt via setting bit
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 08/14] irqchip/irq-brcmstb-l2: Switch to IRQCHIP_PLATFORM_DRIVER
  2021-10-09  2:20 ` Florian Fainelli
@ 2021-10-09  2:20   ` Florian Fainelli
  -1 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

Allow the user selection and building of this interrupt controller
driver as a module since it is used on ARM/ARM64 based systems as a
second level interrupt controller hanging off the ARM GIC and is
therefore loadable during boot.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/irqchip/Kconfig          |  4 +++-
 drivers/irqchip/irq-brcmstb-l2.c | 16 +++++++++-------
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 3022f6137096..dfe54bf9b35f 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -128,7 +128,9 @@ config BCM7120_L2_IRQ
 	select IRQ_DOMAIN
 
 config BRCMSTB_L2_IRQ
-	bool
+	tristate "Broadcom STB generic L2 interrupt controller driver"
+	depends on ARCH_BCM2835 || ARCH_BRCMSTB || BMIPS_GENERIC
+	default ARCH_BCM2835 || ARCH_BRCMSTB || BMIPS_GENERIC
 	select GENERIC_IRQ_CHIP
 	select IRQ_DOMAIN
 
diff --git a/drivers/irqchip/irq-brcmstb-l2.c b/drivers/irqchip/irq-brcmstb-l2.c
index 8e0911561f2d..e4efc08ac594 100644
--- a/drivers/irqchip/irq-brcmstb-l2.c
+++ b/drivers/irqchip/irq-brcmstb-l2.c
@@ -275,16 +275,18 @@ static int __init brcmstb_l2_edge_intc_of_init(struct device_node *np,
 {
 	return brcmstb_l2_intc_of_init(np, parent, &l2_edge_intc_init);
 }
-IRQCHIP_DECLARE(brcmstb_l2_intc, "brcm,l2-intc", brcmstb_l2_edge_intc_of_init);
-IRQCHIP_DECLARE(brcmstb_hif_spi_l2_intc, "brcm,hif-spi-l2-intc",
-		brcmstb_l2_edge_intc_of_init);
-IRQCHIP_DECLARE(brcmstb_upg_aux_aon_l2_intc, "brcm,upg-aux-aon-l2-intc",
-		brcmstb_l2_edge_intc_of_init);
 
 static int __init brcmstb_l2_lvl_intc_of_init(struct device_node *np,
 	struct device_node *parent)
 {
 	return brcmstb_l2_intc_of_init(np, parent, &l2_lvl_intc_init);
 }
-IRQCHIP_DECLARE(bcm7271_l2_intc, "brcm,bcm7271-l2-intc",
-	brcmstb_l2_lvl_intc_of_init);
+
+IRQCHIP_PLATFORM_DRIVER_BEGIN(brcmstb_l2)
+IRQCHIP_MATCH("brcm,l2-intc", brcmstb_l2_edge_intc_of_init)
+IRQCHIP_MATCH("brcm,hif-spi-l2-intc", brcmstb_l2_edge_intc_of_init)
+IRQCHIP_MATCH("brcm,upg-aux-aon-l2-intc", brcmstb_l2_edge_intc_of_init)
+IRQCHIP_MATCH("brcm,bcm7271-l2-intc", brcmstb_l2_lvl_intc_of_init)
+IRQCHIP_PLATFORM_DRIVER_END(brcmstb_l2)
+MODULE_DESCRIPTION("Broadcom STB generic L2 interrupt controller");
+MODULE_LICENSE("GPL v2");
-- 
2.25.1


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

* [PATCH v4 08/14] irqchip/irq-brcmstb-l2: Switch to IRQCHIP_PLATFORM_DRIVER
@ 2021-10-09  2:20   ` Florian Fainelli
  0 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

Allow the user selection and building of this interrupt controller
driver as a module since it is used on ARM/ARM64 based systems as a
second level interrupt controller hanging off the ARM GIC and is
therefore loadable during boot.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/irqchip/Kconfig          |  4 +++-
 drivers/irqchip/irq-brcmstb-l2.c | 16 +++++++++-------
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 3022f6137096..dfe54bf9b35f 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -128,7 +128,9 @@ config BCM7120_L2_IRQ
 	select IRQ_DOMAIN
 
 config BRCMSTB_L2_IRQ
-	bool
+	tristate "Broadcom STB generic L2 interrupt controller driver"
+	depends on ARCH_BCM2835 || ARCH_BRCMSTB || BMIPS_GENERIC
+	default ARCH_BCM2835 || ARCH_BRCMSTB || BMIPS_GENERIC
 	select GENERIC_IRQ_CHIP
 	select IRQ_DOMAIN
 
diff --git a/drivers/irqchip/irq-brcmstb-l2.c b/drivers/irqchip/irq-brcmstb-l2.c
index 8e0911561f2d..e4efc08ac594 100644
--- a/drivers/irqchip/irq-brcmstb-l2.c
+++ b/drivers/irqchip/irq-brcmstb-l2.c
@@ -275,16 +275,18 @@ static int __init brcmstb_l2_edge_intc_of_init(struct device_node *np,
 {
 	return brcmstb_l2_intc_of_init(np, parent, &l2_edge_intc_init);
 }
-IRQCHIP_DECLARE(brcmstb_l2_intc, "brcm,l2-intc", brcmstb_l2_edge_intc_of_init);
-IRQCHIP_DECLARE(brcmstb_hif_spi_l2_intc, "brcm,hif-spi-l2-intc",
-		brcmstb_l2_edge_intc_of_init);
-IRQCHIP_DECLARE(brcmstb_upg_aux_aon_l2_intc, "brcm,upg-aux-aon-l2-intc",
-		brcmstb_l2_edge_intc_of_init);
 
 static int __init brcmstb_l2_lvl_intc_of_init(struct device_node *np,
 	struct device_node *parent)
 {
 	return brcmstb_l2_intc_of_init(np, parent, &l2_lvl_intc_init);
 }
-IRQCHIP_DECLARE(bcm7271_l2_intc, "brcm,bcm7271-l2-intc",
-	brcmstb_l2_lvl_intc_of_init);
+
+IRQCHIP_PLATFORM_DRIVER_BEGIN(brcmstb_l2)
+IRQCHIP_MATCH("brcm,l2-intc", brcmstb_l2_edge_intc_of_init)
+IRQCHIP_MATCH("brcm,hif-spi-l2-intc", brcmstb_l2_edge_intc_of_init)
+IRQCHIP_MATCH("brcm,upg-aux-aon-l2-intc", brcmstb_l2_edge_intc_of_init)
+IRQCHIP_MATCH("brcm,bcm7271-l2-intc", brcmstb_l2_lvl_intc_of_init)
+IRQCHIP_PLATFORM_DRIVER_END(brcmstb_l2)
+MODULE_DESCRIPTION("Broadcom STB generic L2 interrupt controller");
+MODULE_LICENSE("GPL v2");
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 09/14] irqchip: Provide platform_device to of_irq_init_cb_t
  2021-10-09  2:20 ` Florian Fainelli
@ 2021-10-09  2:20   ` Florian Fainelli
  -1 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Rob Herring, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

Provide the platform device mapping to the interrupt controller node to
the of_irq_init_cb_t callback such that drivers can make use of it.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/irqchip/irqchip.c  | 2 +-
 drivers/irqchip/qcom-pdc.c | 3 ++-
 drivers/of/irq.c           | 2 +-
 include/linux/of_irq.h     | 5 ++++-
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
index 3570f0a588c4..289784eefd00 100644
--- a/drivers/irqchip/irqchip.c
+++ b/drivers/irqchip/irqchip.c
@@ -55,6 +55,6 @@ int platform_irqchip_probe(struct platform_device *pdev)
 	if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY))
 		return -EPROBE_DEFER;
 
-	return irq_init_cb(np, par_np);
+	return irq_init_cb(np, par_np, pdev);
 }
 EXPORT_SYMBOL_GPL(platform_irqchip_probe);
diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c
index 173e6520e06e..819a93360b96 100644
--- a/drivers/irqchip/qcom-pdc.c
+++ b/drivers/irqchip/qcom-pdc.c
@@ -359,7 +359,8 @@ static int pdc_setup_pin_mapping(struct device_node *np)
 	return 0;
 }
 
-static int qcom_pdc_init(struct device_node *node, struct device_node *parent)
+static int qcom_pdc_init(struct device_node *node, struct device_node *parent,
+			 struct platform_device *pdev)
 {
 	struct irq_domain *parent_domain, *pdc_domain, *pdc_gpio_domain;
 	int ret;
diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 352e14b007e7..18f3f5c00c87 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -538,7 +538,7 @@ void __init of_irq_init(const struct of_device_id *matches)
 				 desc->dev,
 				 desc->dev, desc->interrupt_parent);
 			ret = desc->irq_init_cb(desc->dev,
-						desc->interrupt_parent);
+						desc->interrupt_parent, NULL);
 			if (ret) {
 				of_node_clear_flag(desc->dev, OF_POPULATED);
 				kfree(desc);
diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
index aaf219bd0354..89acc8b089f0 100644
--- a/include/linux/of_irq.h
+++ b/include/linux/of_irq.h
@@ -9,7 +9,10 @@
 #include <linux/ioport.h>
 #include <linux/of.h>
 
-typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *);
+struct platform_device;
+
+typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *,
+				struct platform_device *);
 
 /*
  * Workarounds only applied to 32bit powermac machines
-- 
2.25.1


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

* [PATCH v4 09/14] irqchip: Provide platform_device to of_irq_init_cb_t
@ 2021-10-09  2:20   ` Florian Fainelli
  0 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Rob Herring, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

Provide the platform device mapping to the interrupt controller node to
the of_irq_init_cb_t callback such that drivers can make use of it.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/irqchip/irqchip.c  | 2 +-
 drivers/irqchip/qcom-pdc.c | 3 ++-
 drivers/of/irq.c           | 2 +-
 include/linux/of_irq.h     | 5 ++++-
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
index 3570f0a588c4..289784eefd00 100644
--- a/drivers/irqchip/irqchip.c
+++ b/drivers/irqchip/irqchip.c
@@ -55,6 +55,6 @@ int platform_irqchip_probe(struct platform_device *pdev)
 	if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY))
 		return -EPROBE_DEFER;
 
-	return irq_init_cb(np, par_np);
+	return irq_init_cb(np, par_np, pdev);
 }
 EXPORT_SYMBOL_GPL(platform_irqchip_probe);
diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c
index 173e6520e06e..819a93360b96 100644
--- a/drivers/irqchip/qcom-pdc.c
+++ b/drivers/irqchip/qcom-pdc.c
@@ -359,7 +359,8 @@ static int pdc_setup_pin_mapping(struct device_node *np)
 	return 0;
 }
 
-static int qcom_pdc_init(struct device_node *node, struct device_node *parent)
+static int qcom_pdc_init(struct device_node *node, struct device_node *parent,
+			 struct platform_device *pdev)
 {
 	struct irq_domain *parent_domain, *pdc_domain, *pdc_gpio_domain;
 	int ret;
diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 352e14b007e7..18f3f5c00c87 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -538,7 +538,7 @@ void __init of_irq_init(const struct of_device_id *matches)
 				 desc->dev,
 				 desc->dev, desc->interrupt_parent);
 			ret = desc->irq_init_cb(desc->dev,
-						desc->interrupt_parent);
+						desc->interrupt_parent, NULL);
 			if (ret) {
 				of_node_clear_flag(desc->dev, OF_POPULATED);
 				kfree(desc);
diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
index aaf219bd0354..89acc8b089f0 100644
--- a/include/linux/of_irq.h
+++ b/include/linux/of_irq.h
@@ -9,7 +9,10 @@
 #include <linux/ioport.h>
 #include <linux/of.h>
 
-typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *);
+struct platform_device;
+
+typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *,
+				struct platform_device *);
 
 /*
  * Workarounds only applied to 32bit powermac machines
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 10/14] genirq: Export irq_gc_noop()
  2021-10-09  2:20 ` Florian Fainelli
@ 2021-10-09  2:20   ` Florian Fainelli
  -1 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

In order to build drivers/irqchip/irq-bcm7120-l2.c as a module which
references irq_gc_noop(), we need to export it towards modules.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 kernel/irq/generic-chip.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c
index 4c011c21bb1a..6f29bf4c8515 100644
--- a/kernel/irq/generic-chip.c
+++ b/kernel/irq/generic-chip.c
@@ -25,6 +25,7 @@ static DEFINE_RAW_SPINLOCK(gc_lock);
 void irq_gc_noop(struct irq_data *d)
 {
 }
+EXPORT_SYMBOL_GPL(irq_gc_noop);
 
 /**
  * irq_gc_mask_disable_reg - Mask chip via disable register
-- 
2.25.1


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

* [PATCH v4 10/14] genirq: Export irq_gc_noop()
@ 2021-10-09  2:20   ` Florian Fainelli
  0 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

In order to build drivers/irqchip/irq-bcm7120-l2.c as a module which
references irq_gc_noop(), we need to export it towards modules.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 kernel/irq/generic-chip.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c
index 4c011c21bb1a..6f29bf4c8515 100644
--- a/kernel/irq/generic-chip.c
+++ b/kernel/irq/generic-chip.c
@@ -25,6 +25,7 @@ static DEFINE_RAW_SPINLOCK(gc_lock);
 void irq_gc_noop(struct irq_data *d)
 {
 }
+EXPORT_SYMBOL_GPL(irq_gc_noop);
 
 /**
  * irq_gc_mask_disable_reg - Mask chip via disable register
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 11/14] irqchip/irq-bcm7120-l2: Switch to IRQCHIP_PLATFORM_DRIVER
  2021-10-09  2:20 ` Florian Fainelli
@ 2021-10-09  2:20   ` Florian Fainelli
  -1 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

Allow the user selection and building of this interrupt controller
driver as a module since it is used on ARM/ARM64 based systems as a
second level interrupt controller hanging off the ARM GIC and is
therefore loadable during boot.

To avoid using of_irq_count() which is not exported towards module,
switch the driver to use the platform_device provided by the irqchip
platform driver code and resolve the number of interrupts using
platform_irq_count().

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/irqchip/Kconfig          |  4 +++-
 drivers/irqchip/irq-bcm7120-l2.c | 28 ++++++++++++++++------------
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index dfe54bf9b35f..c7320bed5668 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -123,7 +123,9 @@ config BCM7038_L1_IRQ
 	select GENERIC_IRQ_EFFECTIVE_AFF_MASK
 
 config BCM7120_L2_IRQ
-	bool
+	tristate "Broadcom STB 7120-style L2 interrupt controller driver"
+	depends on ARCH_BRCMSTB || BMIPS_GENERIC
+	default ARCH_BRCMSTB || BMIPS_GENERIC
 	select GENERIC_IRQ_CHIP
 	select IRQ_DOMAIN
 
diff --git a/drivers/irqchip/irq-bcm7120-l2.c b/drivers/irqchip/irq-bcm7120-l2.c
index f23d7651ea84..9b1edf7747fd 100644
--- a/drivers/irqchip/irq-bcm7120-l2.c
+++ b/drivers/irqchip/irq-bcm7120-l2.c
@@ -214,6 +214,7 @@ static int __init bcm7120_l2_intc_iomap_3380(struct device_node *dn,
 
 static int __init bcm7120_l2_intc_probe(struct device_node *dn,
 				 struct device_node *parent,
+				 struct platform_device *pdev,
 				 int (*iomap_regs_fn)(struct device_node *,
 					struct bcm7120_l2_intc_data *),
 				 const char *intc_name)
@@ -230,7 +231,7 @@ static int __init bcm7120_l2_intc_probe(struct device_node *dn,
 	if (!data)
 		return -ENOMEM;
 
-	data->num_parent_irqs = of_irq_count(dn);
+	data->num_parent_irqs = platform_irq_count(pdev);
 	if (data->num_parent_irqs <= 0) {
 		pr_err("invalid number of parent interrupts\n");
 		ret = -ENOMEM;
@@ -334,21 +335,24 @@ static int __init bcm7120_l2_intc_probe(struct device_node *dn,
 }
 
 static int __init bcm7120_l2_intc_probe_7120(struct device_node *dn,
-					     struct device_node *parent)
+					     struct device_node *parent,
+					     struct platform_device *pdev)
 {
-	return bcm7120_l2_intc_probe(dn, parent, bcm7120_l2_intc_iomap_7120,
-				     "BCM7120 L2");
+	return bcm7120_l2_intc_probe(dn, parent, pdev,
+				     bcm7120_l2_intc_iomap_7120, "BCM7120 L2");
 }
 
 static int __init bcm7120_l2_intc_probe_3380(struct device_node *dn,
-					     struct device_node *parent)
+					     struct device_node *parent,
+					     struct platform_device *pdev)
 {
-	return bcm7120_l2_intc_probe(dn, parent, bcm7120_l2_intc_iomap_3380,
-				     "BCM3380 L2");
+	return bcm7120_l2_intc_probe(dn, parent, pdev,
+				     bcm7120_l2_intc_iomap_3380, "BCM3380 L2");
 }
 
-IRQCHIP_DECLARE(bcm7120_l2_intc, "brcm,bcm7120-l2-intc",
-		bcm7120_l2_intc_probe_7120);
-
-IRQCHIP_DECLARE(bcm3380_l2_intc, "brcm,bcm3380-l2-intc",
-		bcm7120_l2_intc_probe_3380);
+IRQCHIP_PLATFORM_DRIVER_BEGIN(bcm7120_l2)
+IRQCHIP_MATCH("brcm,bcm7120-l2-intc", bcm7120_l2_intc_probe_7120)
+IRQCHIP_MATCH("brcm,bcm3380-l2-intc", bcm7120_l2_intc_probe_3380)
+IRQCHIP_PLATFORM_DRIVER_END(bcm7120_l2)
+MODULE_DESCRIPTION("Broadcom STB 7120-style L2 interrupt controller driver");
+MODULE_LICENSE("GPL v2");
-- 
2.25.1


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

* [PATCH v4 11/14] irqchip/irq-bcm7120-l2: Switch to IRQCHIP_PLATFORM_DRIVER
@ 2021-10-09  2:20   ` Florian Fainelli
  0 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

Allow the user selection and building of this interrupt controller
driver as a module since it is used on ARM/ARM64 based systems as a
second level interrupt controller hanging off the ARM GIC and is
therefore loadable during boot.

To avoid using of_irq_count() which is not exported towards module,
switch the driver to use the platform_device provided by the irqchip
platform driver code and resolve the number of interrupts using
platform_irq_count().

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/irqchip/Kconfig          |  4 +++-
 drivers/irqchip/irq-bcm7120-l2.c | 28 ++++++++++++++++------------
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index dfe54bf9b35f..c7320bed5668 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -123,7 +123,9 @@ config BCM7038_L1_IRQ
 	select GENERIC_IRQ_EFFECTIVE_AFF_MASK
 
 config BCM7120_L2_IRQ
-	bool
+	tristate "Broadcom STB 7120-style L2 interrupt controller driver"
+	depends on ARCH_BRCMSTB || BMIPS_GENERIC
+	default ARCH_BRCMSTB || BMIPS_GENERIC
 	select GENERIC_IRQ_CHIP
 	select IRQ_DOMAIN
 
diff --git a/drivers/irqchip/irq-bcm7120-l2.c b/drivers/irqchip/irq-bcm7120-l2.c
index f23d7651ea84..9b1edf7747fd 100644
--- a/drivers/irqchip/irq-bcm7120-l2.c
+++ b/drivers/irqchip/irq-bcm7120-l2.c
@@ -214,6 +214,7 @@ static int __init bcm7120_l2_intc_iomap_3380(struct device_node *dn,
 
 static int __init bcm7120_l2_intc_probe(struct device_node *dn,
 				 struct device_node *parent,
+				 struct platform_device *pdev,
 				 int (*iomap_regs_fn)(struct device_node *,
 					struct bcm7120_l2_intc_data *),
 				 const char *intc_name)
@@ -230,7 +231,7 @@ static int __init bcm7120_l2_intc_probe(struct device_node *dn,
 	if (!data)
 		return -ENOMEM;
 
-	data->num_parent_irqs = of_irq_count(dn);
+	data->num_parent_irqs = platform_irq_count(pdev);
 	if (data->num_parent_irqs <= 0) {
 		pr_err("invalid number of parent interrupts\n");
 		ret = -ENOMEM;
@@ -334,21 +335,24 @@ static int __init bcm7120_l2_intc_probe(struct device_node *dn,
 }
 
 static int __init bcm7120_l2_intc_probe_7120(struct device_node *dn,
-					     struct device_node *parent)
+					     struct device_node *parent,
+					     struct platform_device *pdev)
 {
-	return bcm7120_l2_intc_probe(dn, parent, bcm7120_l2_intc_iomap_7120,
-				     "BCM7120 L2");
+	return bcm7120_l2_intc_probe(dn, parent, pdev,
+				     bcm7120_l2_intc_iomap_7120, "BCM7120 L2");
 }
 
 static int __init bcm7120_l2_intc_probe_3380(struct device_node *dn,
-					     struct device_node *parent)
+					     struct device_node *parent,
+					     struct platform_device *pdev)
 {
-	return bcm7120_l2_intc_probe(dn, parent, bcm7120_l2_intc_iomap_3380,
-				     "BCM3380 L2");
+	return bcm7120_l2_intc_probe(dn, parent, pdev,
+				     bcm7120_l2_intc_iomap_3380, "BCM3380 L2");
 }
 
-IRQCHIP_DECLARE(bcm7120_l2_intc, "brcm,bcm7120-l2-intc",
-		bcm7120_l2_intc_probe_7120);
-
-IRQCHIP_DECLARE(bcm3380_l2_intc, "brcm,bcm3380-l2-intc",
-		bcm7120_l2_intc_probe_3380);
+IRQCHIP_PLATFORM_DRIVER_BEGIN(bcm7120_l2)
+IRQCHIP_MATCH("brcm,bcm7120-l2-intc", bcm7120_l2_intc_probe_7120)
+IRQCHIP_MATCH("brcm,bcm3380-l2-intc", bcm7120_l2_intc_probe_3380)
+IRQCHIP_PLATFORM_DRIVER_END(bcm7120_l2)
+MODULE_DESCRIPTION("Broadcom STB 7120-style L2 interrupt controller driver");
+MODULE_LICENSE("GPL v2");
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 12/14] arm64: broadcom: Removed forced select of interrupt controllers
  2021-10-09  2:20 ` Florian Fainelli
@ 2021-10-09  2:20   ` Florian Fainelli
  -1 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

Now that the various second level interrupt controllers have been moved
to IRQCHIP_PLATFORM_DRIVER and they do default to ARCH_BRCMSTB and
ARCH_BCM2835 where relevant, remove their forced selection from the
machine entry to allow an user to build them as modules.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 arch/arm64/Kconfig.platforms | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
index b0ce18d4cc98..2e9440f2da22 100644
--- a/arch/arm64/Kconfig.platforms
+++ b/arch/arm64/Kconfig.platforms
@@ -44,7 +44,6 @@ config ARCH_BCM2835
 	select ARM_AMBA
 	select ARM_GIC
 	select ARM_TIMER_SP804
-	select BRCMSTB_L2_IRQ
 	help
 	  This enables support for the Broadcom BCM2837 and BCM2711 SoC.
 	  These SoCs are used in the Raspberry Pi 3 and 4 devices.
@@ -82,8 +81,6 @@ config ARCH_BITMAIN
 config ARCH_BRCMSTB
 	bool "Broadcom Set-Top-Box SoCs"
 	select ARCH_HAS_RESET_CONTROLLER
-	select BCM7038_L1_IRQ
-	select BRCMSTB_L2_IRQ
 	select GENERIC_IRQ_CHIP
 	select PINCTRL
 	help
-- 
2.25.1


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

* [PATCH v4 12/14] arm64: broadcom: Removed forced select of interrupt controllers
@ 2021-10-09  2:20   ` Florian Fainelli
  0 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

Now that the various second level interrupt controllers have been moved
to IRQCHIP_PLATFORM_DRIVER and they do default to ARCH_BRCMSTB and
ARCH_BCM2835 where relevant, remove their forced selection from the
machine entry to allow an user to build them as modules.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 arch/arm64/Kconfig.platforms | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
index b0ce18d4cc98..2e9440f2da22 100644
--- a/arch/arm64/Kconfig.platforms
+++ b/arch/arm64/Kconfig.platforms
@@ -44,7 +44,6 @@ config ARCH_BCM2835
 	select ARM_AMBA
 	select ARM_GIC
 	select ARM_TIMER_SP804
-	select BRCMSTB_L2_IRQ
 	help
 	  This enables support for the Broadcom BCM2837 and BCM2711 SoC.
 	  These SoCs are used in the Raspberry Pi 3 and 4 devices.
@@ -82,8 +81,6 @@ config ARCH_BITMAIN
 config ARCH_BRCMSTB
 	bool "Broadcom Set-Top-Box SoCs"
 	select ARCH_HAS_RESET_CONTROLLER
-	select BCM7038_L1_IRQ
-	select BRCMSTB_L2_IRQ
 	select GENERIC_IRQ_CHIP
 	select PINCTRL
 	help
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 13/14] ARM: bcm: Removed forced select of interrupt controllers
  2021-10-09  2:20 ` Florian Fainelli
@ 2021-10-09  2:20   ` Florian Fainelli
  -1 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

Now that the various second level interrupt controllers have been moved
to IRQCHIP_PLATFORM_DRIVER and they do default to ARCH_BRCMSTB and
ARCH_BCM2835 where relevant, remove their forced selection from the
machine entry to allow an user to build them as modules.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 arch/arm/mach-bcm/Kconfig | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/arch/arm/mach-bcm/Kconfig b/arch/arm/mach-bcm/Kconfig
index 2890e61b2b46..bd3f82788ebc 100644
--- a/arch/arm/mach-bcm/Kconfig
+++ b/arch/arm/mach-bcm/Kconfig
@@ -161,7 +161,6 @@ config ARCH_BCM2835
 	select ARM_TIMER_SP804
 	select HAVE_ARM_ARCH_TIMER if ARCH_MULTI_V7
 	select BCM2835_TIMER
-	select BRCMSTB_L2_IRQ
 	select PINCTRL
 	select PINCTRL_BCM2835
 	select MFD_CORE
@@ -209,9 +208,6 @@ config ARCH_BRCMSTB
 	select ARM_GIC
 	select ARM_ERRATA_798181 if SMP
 	select HAVE_ARM_ARCH_TIMER
-	select BCM7038_L1_IRQ
-	select BRCMSTB_L2_IRQ
-	select BCM7120_L2_IRQ
 	select ZONE_DMA if ARM_LPAE
 	select SOC_BRCMSTB
 	select SOC_BUS
-- 
2.25.1


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

* [PATCH v4 13/14] ARM: bcm: Removed forced select of interrupt controllers
@ 2021-10-09  2:20   ` Florian Fainelli
  0 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

Now that the various second level interrupt controllers have been moved
to IRQCHIP_PLATFORM_DRIVER and they do default to ARCH_BRCMSTB and
ARCH_BCM2835 where relevant, remove their forced selection from the
machine entry to allow an user to build them as modules.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 arch/arm/mach-bcm/Kconfig | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/arch/arm/mach-bcm/Kconfig b/arch/arm/mach-bcm/Kconfig
index 2890e61b2b46..bd3f82788ebc 100644
--- a/arch/arm/mach-bcm/Kconfig
+++ b/arch/arm/mach-bcm/Kconfig
@@ -161,7 +161,6 @@ config ARCH_BCM2835
 	select ARM_TIMER_SP804
 	select HAVE_ARM_ARCH_TIMER if ARCH_MULTI_V7
 	select BCM2835_TIMER
-	select BRCMSTB_L2_IRQ
 	select PINCTRL
 	select PINCTRL_BCM2835
 	select MFD_CORE
@@ -209,9 +208,6 @@ config ARCH_BRCMSTB
 	select ARM_GIC
 	select ARM_ERRATA_798181 if SMP
 	select HAVE_ARM_ARCH_TIMER
-	select BCM7038_L1_IRQ
-	select BRCMSTB_L2_IRQ
-	select BCM7120_L2_IRQ
 	select ZONE_DMA if ARM_LPAE
 	select SOC_BRCMSTB
 	select SOC_BUS
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v4 14/14] irqchip: Fix kernel-doc parameter typo for IRQCHIP_DECLARE
  2021-10-09  2:20 ` Florian Fainelli
@ 2021-10-09  2:20   ` Florian Fainelli
  -1 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

The documentation refers to "compstr" when we have the parameter named
"compat", fix the typo.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 include/linux/irqchip.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h
index 67351aac65ef..ccf32758ea85 100644
--- a/include/linux/irqchip.h
+++ b/include/linux/irqchip.h
@@ -23,7 +23,7 @@
  *
  * @name: name that must be unique across all IRQCHIP_DECLARE of the
  * same file.
- * @compstr: compatible string of the irqchip driver
+ * @compat: compatible string of the irqchip driver
  * @fn: initialization function
  */
 #define IRQCHIP_DECLARE(name, compat, fn) OF_DECLARE_2(irqchip, name, compat, fn)
-- 
2.25.1


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

* [PATCH v4 14/14] irqchip: Fix kernel-doc parameter typo for IRQCHIP_DECLARE
@ 2021-10-09  2:20   ` Florian Fainelli
  0 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-09  2:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Florian Fainelli, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

The documentation refers to "compstr" when we have the parameter named
"compat", fix the typo.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 include/linux/irqchip.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h
index 67351aac65ef..ccf32758ea85 100644
--- a/include/linux/irqchip.h
+++ b/include/linux/irqchip.h
@@ -23,7 +23,7 @@
  *
  * @name: name that must be unique across all IRQCHIP_DECLARE of the
  * same file.
- * @compstr: compatible string of the irqchip driver
+ * @compat: compatible string of the irqchip driver
  * @fn: initialization function
  */
 #define IRQCHIP_DECLARE(name, compat, fn) OF_DECLARE_2(irqchip, name, compat, fn)
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v4 00/14] Modular Broadcom irqchip drivers
  2021-10-09  2:20 ` Florian Fainelli
@ 2021-10-19 19:13   ` Florian Fainelli
  -1 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-19 19:13 UTC (permalink / raw)
  To: Florian Fainelli, linux-kernel
  Cc: Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

On 10/8/21 7:20 PM, Florian Fainelli wrote:
> Hi Thomas, Marc,
> 
> This patch series aims at allowing the 3 interrupt controller drivers
> used on Broadcom STB platforms to be built as modules in order for those
> to be shipped in a GKI enabled system (Android).
> 
> The irq-bcm7038-l1 requires us to export a number of symbols, which is
> not great, but there are not obvious solutions other than adding
> accessor functions to get the same information.
> 
> Assuming you are happy with the changes though, please do take the last
> two changes as well through your tree.
> 
> Thanks!

Does this look reasonable to you? If so, can you apply all of those
patches through the irqchip tree? Thanks!
-- 
Florian

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

* Re: [PATCH v4 00/14] Modular Broadcom irqchip drivers
@ 2021-10-19 19:13   ` Florian Fainelli
  0 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-19 19:13 UTC (permalink / raw)
  To: Florian Fainelli, linux-kernel
  Cc: Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Marc Zyngier, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

On 10/8/21 7:20 PM, Florian Fainelli wrote:
> Hi Thomas, Marc,
> 
> This patch series aims at allowing the 3 interrupt controller drivers
> used on Broadcom STB platforms to be built as modules in order for those
> to be shipped in a GKI enabled system (Android).
> 
> The irq-bcm7038-l1 requires us to export a number of symbols, which is
> not great, but there are not obvious solutions other than adding
> accessor functions to get the same information.
> 
> Assuming you are happy with the changes though, please do take the last
> two changes as well through your tree.
> 
> Thanks!

Does this look reasonable to you? If so, can you apply all of those
patches through the irqchip tree? Thanks!
-- 
Florian

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v4 09/14] irqchip: Provide platform_device to of_irq_init_cb_t
  2021-10-09  2:20   ` Florian Fainelli
@ 2021-10-19 21:43     ` Marc Zyngier
  -1 siblings, 0 replies; 46+ messages in thread
From: Marc Zyngier @ 2021-10-19 21:43 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: linux-kernel, Rob Herring, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

On Sat, 09 Oct 2021 03:20:18 +0100,
Florian Fainelli <f.fainelli@gmail.com> wrote:
> 
> Provide the platform device mapping to the interrupt controller node to
> the of_irq_init_cb_t callback such that drivers can make use of it.
> 
> Reviewed-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  drivers/irqchip/irqchip.c  | 2 +-
>  drivers/irqchip/qcom-pdc.c | 3 ++-
>  drivers/of/irq.c           | 2 +-
>  include/linux/of_irq.h     | 5 ++++-
>  4 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
> index 3570f0a588c4..289784eefd00 100644
> --- a/drivers/irqchip/irqchip.c
> +++ b/drivers/irqchip/irqchip.c
> @@ -55,6 +55,6 @@ int platform_irqchip_probe(struct platform_device *pdev)
>  	if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY))
>  		return -EPROBE_DEFER;
>  
> -	return irq_init_cb(np, par_np);
> +	return irq_init_cb(np, par_np, pdev);
>  }
>  EXPORT_SYMBOL_GPL(platform_irqchip_probe);
> diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c
> index 173e6520e06e..819a93360b96 100644
> --- a/drivers/irqchip/qcom-pdc.c
> +++ b/drivers/irqchip/qcom-pdc.c
> @@ -359,7 +359,8 @@ static int pdc_setup_pin_mapping(struct device_node *np)
>  	return 0;
>  }
>  
> -static int qcom_pdc_init(struct device_node *node, struct device_node *parent)
> +static int qcom_pdc_init(struct device_node *node, struct device_node *parent,
> +			 struct platform_device *pdev)
>  {
>  	struct irq_domain *parent_domain, *pdc_domain, *pdc_gpio_domain;
>  	int ret;
> diff --git a/drivers/of/irq.c b/drivers/of/irq.c
> index 352e14b007e7..18f3f5c00c87 100644
> --- a/drivers/of/irq.c
> +++ b/drivers/of/irq.c
> @@ -538,7 +538,7 @@ void __init of_irq_init(const struct of_device_id *matches)
>  				 desc->dev,
>  				 desc->dev, desc->interrupt_parent);
>  			ret = desc->irq_init_cb(desc->dev,
> -						desc->interrupt_parent);
> +						desc->interrupt_parent, NULL);
>  			if (ret) {
>  				of_node_clear_flag(desc->dev, OF_POPULATED);
>  				kfree(desc);
> diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
> index aaf219bd0354..89acc8b089f0 100644
> --- a/include/linux/of_irq.h
> +++ b/include/linux/of_irq.h
> @@ -9,7 +9,10 @@
>  #include <linux/ioport.h>
>  #include <linux/of.h>
>  
> -typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *);
> +struct platform_device;
> +
> +typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *,
> +				struct platform_device *);

Having added some type-checking to the IRQCHIP_MATCH() #definery, I
end-up with warnings such as:

In file included from ./include/linux/kernel.h:16,
                 from drivers/irqchip/irq-bcm7038-l1.c:12:
./include/linux/minmax.h:20:28: warning: comparison of distinct pointer types lacks a cast
   20 |  (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
      |                            ^~
./include/linux/irqchip.h:41:2: note: in expansion of macro ‘__typecheck’
   41 |  __typecheck(typecheck_irq_init_cb, fn) ? fn : fn
      |  ^~~~~~~~~~~
./include/linux/irqchip.h:44:12: note: in expansion of macro ‘typecheck_irq_init_cb’
   44 |    .data = typecheck_irq_init_cb(fn), },
      |            ^~~~~~~~~~~~~~~~~~~~~
drivers/irqchip/irq-bcm7038-l1.c:459:1: note: in expansion of macro ‘IRQCHIP_MATCH’
  459 | IRQCHIP_MATCH("brcm,bcm7038-l1-intc", bcm7038_l1_of_init)
      | ^~~~~~~~~~~~~

Clearly, you didn't update the drivers you just converted to
IRQCHIP_MATCH(), and only fixed the QC driver.

FWIW, I'm planning to take something like the hack below into the tree
to detect this sort of stuff early.

	M.

diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h
index ccf32758ea85..146a9d80a6a2 100644
--- a/include/linux/irqchip.h
+++ b/include/linux/irqchip.h
@@ -33,7 +33,15 @@ extern int platform_irqchip_probe(struct platform_device *pdev);
 #define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \
 static const struct of_device_id drv_name##_irqchip_match_table[] = {
 
-#define IRQCHIP_MATCH(compat, fn) { .compatible = compat, .data = fn },
+/* Undefined on purpose */
+int typecheck_irq_init_cb(struct device_node *, struct device_node *,
+			  struct platform_device *);
+
+#define typecheck_irq_init_cb(fn)					\
+	__typecheck(typecheck_irq_init_cb, fn) ? fn : fn
+
+#define IRQCHIP_MATCH(compat, fn) { .compatible = compat,	\
+			.data = typecheck_irq_init_cb(fn), },
 
 #define IRQCHIP_PLATFORM_DRIVER_END(drv_name)				\
 	{},								\

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

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

* Re: [PATCH v4 09/14] irqchip: Provide platform_device to of_irq_init_cb_t
@ 2021-10-19 21:43     ` Marc Zyngier
  0 siblings, 0 replies; 46+ messages in thread
From: Marc Zyngier @ 2021-10-19 21:43 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: linux-kernel, Rob Herring, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

On Sat, 09 Oct 2021 03:20:18 +0100,
Florian Fainelli <f.fainelli@gmail.com> wrote:
> 
> Provide the platform device mapping to the interrupt controller node to
> the of_irq_init_cb_t callback such that drivers can make use of it.
> 
> Reviewed-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  drivers/irqchip/irqchip.c  | 2 +-
>  drivers/irqchip/qcom-pdc.c | 3 ++-
>  drivers/of/irq.c           | 2 +-
>  include/linux/of_irq.h     | 5 ++++-
>  4 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
> index 3570f0a588c4..289784eefd00 100644
> --- a/drivers/irqchip/irqchip.c
> +++ b/drivers/irqchip/irqchip.c
> @@ -55,6 +55,6 @@ int platform_irqchip_probe(struct platform_device *pdev)
>  	if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY))
>  		return -EPROBE_DEFER;
>  
> -	return irq_init_cb(np, par_np);
> +	return irq_init_cb(np, par_np, pdev);
>  }
>  EXPORT_SYMBOL_GPL(platform_irqchip_probe);
> diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c
> index 173e6520e06e..819a93360b96 100644
> --- a/drivers/irqchip/qcom-pdc.c
> +++ b/drivers/irqchip/qcom-pdc.c
> @@ -359,7 +359,8 @@ static int pdc_setup_pin_mapping(struct device_node *np)
>  	return 0;
>  }
>  
> -static int qcom_pdc_init(struct device_node *node, struct device_node *parent)
> +static int qcom_pdc_init(struct device_node *node, struct device_node *parent,
> +			 struct platform_device *pdev)
>  {
>  	struct irq_domain *parent_domain, *pdc_domain, *pdc_gpio_domain;
>  	int ret;
> diff --git a/drivers/of/irq.c b/drivers/of/irq.c
> index 352e14b007e7..18f3f5c00c87 100644
> --- a/drivers/of/irq.c
> +++ b/drivers/of/irq.c
> @@ -538,7 +538,7 @@ void __init of_irq_init(const struct of_device_id *matches)
>  				 desc->dev,
>  				 desc->dev, desc->interrupt_parent);
>  			ret = desc->irq_init_cb(desc->dev,
> -						desc->interrupt_parent);
> +						desc->interrupt_parent, NULL);
>  			if (ret) {
>  				of_node_clear_flag(desc->dev, OF_POPULATED);
>  				kfree(desc);
> diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
> index aaf219bd0354..89acc8b089f0 100644
> --- a/include/linux/of_irq.h
> +++ b/include/linux/of_irq.h
> @@ -9,7 +9,10 @@
>  #include <linux/ioport.h>
>  #include <linux/of.h>
>  
> -typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *);
> +struct platform_device;
> +
> +typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *,
> +				struct platform_device *);

Having added some type-checking to the IRQCHIP_MATCH() #definery, I
end-up with warnings such as:

In file included from ./include/linux/kernel.h:16,
                 from drivers/irqchip/irq-bcm7038-l1.c:12:
./include/linux/minmax.h:20:28: warning: comparison of distinct pointer types lacks a cast
   20 |  (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
      |                            ^~
./include/linux/irqchip.h:41:2: note: in expansion of macro ‘__typecheck’
   41 |  __typecheck(typecheck_irq_init_cb, fn) ? fn : fn
      |  ^~~~~~~~~~~
./include/linux/irqchip.h:44:12: note: in expansion of macro ‘typecheck_irq_init_cb’
   44 |    .data = typecheck_irq_init_cb(fn), },
      |            ^~~~~~~~~~~~~~~~~~~~~
drivers/irqchip/irq-bcm7038-l1.c:459:1: note: in expansion of macro ‘IRQCHIP_MATCH’
  459 | IRQCHIP_MATCH("brcm,bcm7038-l1-intc", bcm7038_l1_of_init)
      | ^~~~~~~~~~~~~

Clearly, you didn't update the drivers you just converted to
IRQCHIP_MATCH(), and only fixed the QC driver.

FWIW, I'm planning to take something like the hack below into the tree
to detect this sort of stuff early.

	M.

diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h
index ccf32758ea85..146a9d80a6a2 100644
--- a/include/linux/irqchip.h
+++ b/include/linux/irqchip.h
@@ -33,7 +33,15 @@ extern int platform_irqchip_probe(struct platform_device *pdev);
 #define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \
 static const struct of_device_id drv_name##_irqchip_match_table[] = {
 
-#define IRQCHIP_MATCH(compat, fn) { .compatible = compat, .data = fn },
+/* Undefined on purpose */
+int typecheck_irq_init_cb(struct device_node *, struct device_node *,
+			  struct platform_device *);
+
+#define typecheck_irq_init_cb(fn)					\
+	__typecheck(typecheck_irq_init_cb, fn) ? fn : fn
+
+#define IRQCHIP_MATCH(compat, fn) { .compatible = compat,	\
+			.data = typecheck_irq_init_cb(fn), },
 
 #define IRQCHIP_PLATFORM_DRIVER_END(drv_name)				\
 	{},								\

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v4 00/14] Modular Broadcom irqchip drivers
  2021-10-19 19:13   ` Florian Fainelli
@ 2021-10-19 21:46     ` Marc Zyngier
  -1 siblings, 0 replies; 46+ messages in thread
From: Marc Zyngier @ 2021-10-19 21:46 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: linux-kernel, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

On Tue, 19 Oct 2021 20:13:08 +0100,
Florian Fainelli <f.fainelli@gmail.com> wrote:
> 
> On 10/8/21 7:20 PM, Florian Fainelli wrote:
> > Hi Thomas, Marc,
> > 
> > This patch series aims at allowing the 3 interrupt controller drivers
> > used on Broadcom STB platforms to be built as modules in order for those
> > to be shipped in a GKI enabled system (Android).
> > 
> > The irq-bcm7038-l1 requires us to export a number of symbols, which is
> > not great, but there are not obvious solutions other than adding
> > accessor functions to get the same information.
> > 
> > Assuming you are happy with the changes though, please do take the last
> > two changes as well through your tree.
> > 
> > Thanks!
> 
> Does this look reasonable to you? If so, can you apply all of those
> patches through the irqchip tree? Thanks!

Great timing! See my reply to patch #9. Please respin this to fix the
glaring issue I mentioned there.

	M.

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

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

* Re: [PATCH v4 00/14] Modular Broadcom irqchip drivers
@ 2021-10-19 21:46     ` Marc Zyngier
  0 siblings, 0 replies; 46+ messages in thread
From: Marc Zyngier @ 2021-10-19 21:46 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: linux-kernel, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

On Tue, 19 Oct 2021 20:13:08 +0100,
Florian Fainelli <f.fainelli@gmail.com> wrote:
> 
> On 10/8/21 7:20 PM, Florian Fainelli wrote:
> > Hi Thomas, Marc,
> > 
> > This patch series aims at allowing the 3 interrupt controller drivers
> > used on Broadcom STB platforms to be built as modules in order for those
> > to be shipped in a GKI enabled system (Android).
> > 
> > The irq-bcm7038-l1 requires us to export a number of symbols, which is
> > not great, but there are not obvious solutions other than adding
> > accessor functions to get the same information.
> > 
> > Assuming you are happy with the changes though, please do take the last
> > two changes as well through your tree.
> > 
> > Thanks!
> 
> Does this look reasonable to you? If so, can you apply all of those
> patches through the irqchip tree? Thanks!

Great timing! See my reply to patch #9. Please respin this to fix the
glaring issue I mentioned there.

	M.

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v4 09/14] irqchip: Provide platform_device to of_irq_init_cb_t
  2021-10-19 21:43     ` Marc Zyngier
@ 2021-10-19 21:52       ` Florian Fainelli
  -1 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-19 21:52 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: linux-kernel, Rob Herring, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

On 10/19/21 2:43 PM, Marc Zyngier wrote:
> On Sat, 09 Oct 2021 03:20:18 +0100,
> Florian Fainelli <f.fainelli@gmail.com> wrote:
>>
>> Provide the platform device mapping to the interrupt controller node to
>> the of_irq_init_cb_t callback such that drivers can make use of it.
>>
>> Reviewed-by: Rob Herring <robh@kernel.org>
>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>> ---
>>  drivers/irqchip/irqchip.c  | 2 +-
>>  drivers/irqchip/qcom-pdc.c | 3 ++-
>>  drivers/of/irq.c           | 2 +-
>>  include/linux/of_irq.h     | 5 ++++-
>>  4 files changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
>> index 3570f0a588c4..289784eefd00 100644
>> --- a/drivers/irqchip/irqchip.c
>> +++ b/drivers/irqchip/irqchip.c
>> @@ -55,6 +55,6 @@ int platform_irqchip_probe(struct platform_device *pdev)
>>  	if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY))
>>  		return -EPROBE_DEFER;
>>  
>> -	return irq_init_cb(np, par_np);
>> +	return irq_init_cb(np, par_np, pdev);
>>  }
>>  EXPORT_SYMBOL_GPL(platform_irqchip_probe);
>> diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c
>> index 173e6520e06e..819a93360b96 100644
>> --- a/drivers/irqchip/qcom-pdc.c
>> +++ b/drivers/irqchip/qcom-pdc.c
>> @@ -359,7 +359,8 @@ static int pdc_setup_pin_mapping(struct device_node *np)
>>  	return 0;
>>  }
>>  
>> -static int qcom_pdc_init(struct device_node *node, struct device_node *parent)
>> +static int qcom_pdc_init(struct device_node *node, struct device_node *parent,
>> +			 struct platform_device *pdev)
>>  {
>>  	struct irq_domain *parent_domain, *pdc_domain, *pdc_gpio_domain;
>>  	int ret;
>> diff --git a/drivers/of/irq.c b/drivers/of/irq.c
>> index 352e14b007e7..18f3f5c00c87 100644
>> --- a/drivers/of/irq.c
>> +++ b/drivers/of/irq.c
>> @@ -538,7 +538,7 @@ void __init of_irq_init(const struct of_device_id *matches)
>>  				 desc->dev,
>>  				 desc->dev, desc->interrupt_parent);
>>  			ret = desc->irq_init_cb(desc->dev,
>> -						desc->interrupt_parent);
>> +						desc->interrupt_parent, NULL);
>>  			if (ret) {
>>  				of_node_clear_flag(desc->dev, OF_POPULATED);
>>  				kfree(desc);
>> diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
>> index aaf219bd0354..89acc8b089f0 100644
>> --- a/include/linux/of_irq.h
>> +++ b/include/linux/of_irq.h
>> @@ -9,7 +9,10 @@
>>  #include <linux/ioport.h>
>>  #include <linux/of.h>
>>  
>> -typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *);
>> +struct platform_device;
>> +
>> +typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *,
>> +				struct platform_device *);
> 
> Having added some type-checking to the IRQCHIP_MATCH() #definery, I
> end-up with warnings such as:
> 
> In file included from ./include/linux/kernel.h:16,
>                  from drivers/irqchip/irq-bcm7038-l1.c:12:
> ./include/linux/minmax.h:20:28: warning: comparison of distinct pointer types lacks a cast
>    20 |  (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
>       |                            ^~
> ./include/linux/irqchip.h:41:2: note: in expansion of macro ‘__typecheck’
>    41 |  __typecheck(typecheck_irq_init_cb, fn) ? fn : fn
>       |  ^~~~~~~~~~~
> ./include/linux/irqchip.h:44:12: note: in expansion of macro ‘typecheck_irq_init_cb’
>    44 |    .data = typecheck_irq_init_cb(fn), },
>       |            ^~~~~~~~~~~~~~~~~~~~~
> drivers/irqchip/irq-bcm7038-l1.c:459:1: note: in expansion of macro ‘IRQCHIP_MATCH’
>   459 | IRQCHIP_MATCH("brcm,bcm7038-l1-intc", bcm7038_l1_of_init)
>       | ^~~~~~~~~~~~~
> 
> Clearly, you didn't update the drivers you just converted to
> IRQCHIP_MATCH(), and only fixed the QC driver.

Yes, I will re-order the patches a little bit and update the drivers as
they are converted.

> 
> FWIW, I'm planning to take something like the hack below into the tree
> to detect this sort of stuff early.

Sounds good, thanks!
-- 
Florian

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

* Re: [PATCH v4 09/14] irqchip: Provide platform_device to of_irq_init_cb_t
@ 2021-10-19 21:52       ` Florian Fainelli
  0 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-19 21:52 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: linux-kernel, Rob Herring, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Rob Herring, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

On 10/19/21 2:43 PM, Marc Zyngier wrote:
> On Sat, 09 Oct 2021 03:20:18 +0100,
> Florian Fainelli <f.fainelli@gmail.com> wrote:
>>
>> Provide the platform device mapping to the interrupt controller node to
>> the of_irq_init_cb_t callback such that drivers can make use of it.
>>
>> Reviewed-by: Rob Herring <robh@kernel.org>
>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>> ---
>>  drivers/irqchip/irqchip.c  | 2 +-
>>  drivers/irqchip/qcom-pdc.c | 3 ++-
>>  drivers/of/irq.c           | 2 +-
>>  include/linux/of_irq.h     | 5 ++++-
>>  4 files changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
>> index 3570f0a588c4..289784eefd00 100644
>> --- a/drivers/irqchip/irqchip.c
>> +++ b/drivers/irqchip/irqchip.c
>> @@ -55,6 +55,6 @@ int platform_irqchip_probe(struct platform_device *pdev)
>>  	if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY))
>>  		return -EPROBE_DEFER;
>>  
>> -	return irq_init_cb(np, par_np);
>> +	return irq_init_cb(np, par_np, pdev);
>>  }
>>  EXPORT_SYMBOL_GPL(platform_irqchip_probe);
>> diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c
>> index 173e6520e06e..819a93360b96 100644
>> --- a/drivers/irqchip/qcom-pdc.c
>> +++ b/drivers/irqchip/qcom-pdc.c
>> @@ -359,7 +359,8 @@ static int pdc_setup_pin_mapping(struct device_node *np)
>>  	return 0;
>>  }
>>  
>> -static int qcom_pdc_init(struct device_node *node, struct device_node *parent)
>> +static int qcom_pdc_init(struct device_node *node, struct device_node *parent,
>> +			 struct platform_device *pdev)
>>  {
>>  	struct irq_domain *parent_domain, *pdc_domain, *pdc_gpio_domain;
>>  	int ret;
>> diff --git a/drivers/of/irq.c b/drivers/of/irq.c
>> index 352e14b007e7..18f3f5c00c87 100644
>> --- a/drivers/of/irq.c
>> +++ b/drivers/of/irq.c
>> @@ -538,7 +538,7 @@ void __init of_irq_init(const struct of_device_id *matches)
>>  				 desc->dev,
>>  				 desc->dev, desc->interrupt_parent);
>>  			ret = desc->irq_init_cb(desc->dev,
>> -						desc->interrupt_parent);
>> +						desc->interrupt_parent, NULL);
>>  			if (ret) {
>>  				of_node_clear_flag(desc->dev, OF_POPULATED);
>>  				kfree(desc);
>> diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
>> index aaf219bd0354..89acc8b089f0 100644
>> --- a/include/linux/of_irq.h
>> +++ b/include/linux/of_irq.h
>> @@ -9,7 +9,10 @@
>>  #include <linux/ioport.h>
>>  #include <linux/of.h>
>>  
>> -typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *);
>> +struct platform_device;
>> +
>> +typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *,
>> +				struct platform_device *);
> 
> Having added some type-checking to the IRQCHIP_MATCH() #definery, I
> end-up with warnings such as:
> 
> In file included from ./include/linux/kernel.h:16,
>                  from drivers/irqchip/irq-bcm7038-l1.c:12:
> ./include/linux/minmax.h:20:28: warning: comparison of distinct pointer types lacks a cast
>    20 |  (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
>       |                            ^~
> ./include/linux/irqchip.h:41:2: note: in expansion of macro ‘__typecheck’
>    41 |  __typecheck(typecheck_irq_init_cb, fn) ? fn : fn
>       |  ^~~~~~~~~~~
> ./include/linux/irqchip.h:44:12: note: in expansion of macro ‘typecheck_irq_init_cb’
>    44 |    .data = typecheck_irq_init_cb(fn), },
>       |            ^~~~~~~~~~~~~~~~~~~~~
> drivers/irqchip/irq-bcm7038-l1.c:459:1: note: in expansion of macro ‘IRQCHIP_MATCH’
>   459 | IRQCHIP_MATCH("brcm,bcm7038-l1-intc", bcm7038_l1_of_init)
>       | ^~~~~~~~~~~~~
> 
> Clearly, you didn't update the drivers you just converted to
> IRQCHIP_MATCH(), and only fixed the QC driver.

Yes, I will re-order the patches a little bit and update the drivers as
they are converted.

> 
> FWIW, I'm planning to take something like the hack below into the tree
> to detect this sort of stuff early.

Sounds good, thanks!
-- 
Florian

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v4 09/14] irqchip: Provide platform_device to of_irq_init_cb_t
  2021-10-19 21:43     ` Marc Zyngier
@ 2021-10-19 22:23       ` Rob Herring
  -1 siblings, 0 replies; 46+ messages in thread
From: Rob Herring @ 2021-10-19 22:23 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Florian Fainelli, linux-kernel, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

 On Tue, Oct 19, 2021 at 4:43 PM Marc Zyngier <maz@kernel.org> wrote:
>
> On Sat, 09 Oct 2021 03:20:18 +0100,
> Florian Fainelli <f.fainelli@gmail.com> wrote:
> >
> > Provide the platform device mapping to the interrupt controller node to
> > the of_irq_init_cb_t callback such that drivers can make use of it.
> >
> > Reviewed-by: Rob Herring <robh@kernel.org>
> > Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> > ---
> >  drivers/irqchip/irqchip.c  | 2 +-
> >  drivers/irqchip/qcom-pdc.c | 3 ++-
> >  drivers/of/irq.c           | 2 +-
> >  include/linux/of_irq.h     | 5 ++++-
> >  4 files changed, 8 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
> > index 3570f0a588c4..289784eefd00 100644
> > --- a/drivers/irqchip/irqchip.c
> > +++ b/drivers/irqchip/irqchip.c
> > @@ -55,6 +55,6 @@ int platform_irqchip_probe(struct platform_device *pdev)
> >       if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY))
> >               return -EPROBE_DEFER;
> >
> > -     return irq_init_cb(np, par_np);
> > +     return irq_init_cb(np, par_np, pdev);
> >  }
> >  EXPORT_SYMBOL_GPL(platform_irqchip_probe);
> > diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c
> > index 173e6520e06e..819a93360b96 100644
> > --- a/drivers/irqchip/qcom-pdc.c
> > +++ b/drivers/irqchip/qcom-pdc.c
> > @@ -359,7 +359,8 @@ static int pdc_setup_pin_mapping(struct device_node *np)
> >       return 0;
> >  }
> >
> > -static int qcom_pdc_init(struct device_node *node, struct device_node *parent)
> > +static int qcom_pdc_init(struct device_node *node, struct device_node *parent,
> > +                      struct platform_device *pdev)
> >  {
> >       struct irq_domain *parent_domain, *pdc_domain, *pdc_gpio_domain;
> >       int ret;
> > diff --git a/drivers/of/irq.c b/drivers/of/irq.c
> > index 352e14b007e7..18f3f5c00c87 100644
> > --- a/drivers/of/irq.c
> > +++ b/drivers/of/irq.c
> > @@ -538,7 +538,7 @@ void __init of_irq_init(const struct of_device_id *matches)
> >                                desc->dev,
> >                                desc->dev, desc->interrupt_parent);
> >                       ret = desc->irq_init_cb(desc->dev,
> > -                                             desc->interrupt_parent);
> > +                                             desc->interrupt_parent, NULL);
> >                       if (ret) {
> >                               of_node_clear_flag(desc->dev, OF_POPULATED);
> >                               kfree(desc);
> > diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
> > index aaf219bd0354..89acc8b089f0 100644
> > --- a/include/linux/of_irq.h
> > +++ b/include/linux/of_irq.h
> > @@ -9,7 +9,10 @@
> >  #include <linux/ioport.h>
> >  #include <linux/of.h>
> >
> > -typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *);
> > +struct platform_device;
> > +
> > +typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *,
> > +                             struct platform_device *);
>
> Having added some type-checking to the IRQCHIP_MATCH() #definery, I
> end-up with warnings such as:
>
> In file included from ./include/linux/kernel.h:16,
>                  from drivers/irqchip/irq-bcm7038-l1.c:12:
> ./include/linux/minmax.h:20:28: warning: comparison of distinct pointer types lacks a cast
>    20 |  (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
>       |                            ^~
> ./include/linux/irqchip.h:41:2: note: in expansion of macro ‘__typecheck’
>    41 |  __typecheck(typecheck_irq_init_cb, fn) ? fn : fn
>       |  ^~~~~~~~~~~
> ./include/linux/irqchip.h:44:12: note: in expansion of macro ‘typecheck_irq_init_cb’
>    44 |    .data = typecheck_irq_init_cb(fn), },
>       |            ^~~~~~~~~~~~~~~~~~~~~
> drivers/irqchip/irq-bcm7038-l1.c:459:1: note: in expansion of macro ‘IRQCHIP_MATCH’
>   459 | IRQCHIP_MATCH("brcm,bcm7038-l1-intc", bcm7038_l1_of_init)
>       | ^~~~~~~~~~~~~
>
> Clearly, you didn't update the drivers you just converted to
> IRQCHIP_MATCH(), and only fixed the QC driver.
>
> FWIW, I'm planning to take something like the hack below into the tree
> to detect this sort of stuff early.
>
>         M.
>
> diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h
> index ccf32758ea85..146a9d80a6a2 100644
> --- a/include/linux/irqchip.h
> +++ b/include/linux/irqchip.h
> @@ -33,7 +33,15 @@ extern int platform_irqchip_probe(struct platform_device *pdev);
>  #define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \
>  static const struct of_device_id drv_name##_irqchip_match_table[] = {
>
> -#define IRQCHIP_MATCH(compat, fn) { .compatible = compat, .data = fn },
> +/* Undefined on purpose */
> +int typecheck_irq_init_cb(struct device_node *, struct device_node *,
> +                         struct platform_device *);
> +
> +#define typecheck_irq_init_cb(fn)                                      \
> +       __typecheck(typecheck_irq_init_cb, fn) ? fn : fn

That's nice! Shouldn't it also be used for IRQCHIP_DECLARE?

> +#define IRQCHIP_MATCH(compat, fn) { .compatible = compat,      \
> +                       .data = typecheck_irq_init_cb(fn), },

I was going to say I wasn't really a fan of IRQCHIP_MATCH given it had
nothing irqchip specific about it, but you fixed that now...

>
>  #define IRQCHIP_PLATFORM_DRIVER_END(drv_name)                          \
>         {},                                                             \
>
> --
> Without deviation from the norm, progress is not possible.

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

* Re: [PATCH v4 09/14] irqchip: Provide platform_device to of_irq_init_cb_t
@ 2021-10-19 22:23       ` Rob Herring
  0 siblings, 0 replies; 46+ messages in thread
From: Rob Herring @ 2021-10-19 22:23 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Florian Fainelli, linux-kernel, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

 On Tue, Oct 19, 2021 at 4:43 PM Marc Zyngier <maz@kernel.org> wrote:
>
> On Sat, 09 Oct 2021 03:20:18 +0100,
> Florian Fainelli <f.fainelli@gmail.com> wrote:
> >
> > Provide the platform device mapping to the interrupt controller node to
> > the of_irq_init_cb_t callback such that drivers can make use of it.
> >
> > Reviewed-by: Rob Herring <robh@kernel.org>
> > Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> > ---
> >  drivers/irqchip/irqchip.c  | 2 +-
> >  drivers/irqchip/qcom-pdc.c | 3 ++-
> >  drivers/of/irq.c           | 2 +-
> >  include/linux/of_irq.h     | 5 ++++-
> >  4 files changed, 8 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
> > index 3570f0a588c4..289784eefd00 100644
> > --- a/drivers/irqchip/irqchip.c
> > +++ b/drivers/irqchip/irqchip.c
> > @@ -55,6 +55,6 @@ int platform_irqchip_probe(struct platform_device *pdev)
> >       if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY))
> >               return -EPROBE_DEFER;
> >
> > -     return irq_init_cb(np, par_np);
> > +     return irq_init_cb(np, par_np, pdev);
> >  }
> >  EXPORT_SYMBOL_GPL(platform_irqchip_probe);
> > diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c
> > index 173e6520e06e..819a93360b96 100644
> > --- a/drivers/irqchip/qcom-pdc.c
> > +++ b/drivers/irqchip/qcom-pdc.c
> > @@ -359,7 +359,8 @@ static int pdc_setup_pin_mapping(struct device_node *np)
> >       return 0;
> >  }
> >
> > -static int qcom_pdc_init(struct device_node *node, struct device_node *parent)
> > +static int qcom_pdc_init(struct device_node *node, struct device_node *parent,
> > +                      struct platform_device *pdev)
> >  {
> >       struct irq_domain *parent_domain, *pdc_domain, *pdc_gpio_domain;
> >       int ret;
> > diff --git a/drivers/of/irq.c b/drivers/of/irq.c
> > index 352e14b007e7..18f3f5c00c87 100644
> > --- a/drivers/of/irq.c
> > +++ b/drivers/of/irq.c
> > @@ -538,7 +538,7 @@ void __init of_irq_init(const struct of_device_id *matches)
> >                                desc->dev,
> >                                desc->dev, desc->interrupt_parent);
> >                       ret = desc->irq_init_cb(desc->dev,
> > -                                             desc->interrupt_parent);
> > +                                             desc->interrupt_parent, NULL);
> >                       if (ret) {
> >                               of_node_clear_flag(desc->dev, OF_POPULATED);
> >                               kfree(desc);
> > diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
> > index aaf219bd0354..89acc8b089f0 100644
> > --- a/include/linux/of_irq.h
> > +++ b/include/linux/of_irq.h
> > @@ -9,7 +9,10 @@
> >  #include <linux/ioport.h>
> >  #include <linux/of.h>
> >
> > -typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *);
> > +struct platform_device;
> > +
> > +typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *,
> > +                             struct platform_device *);
>
> Having added some type-checking to the IRQCHIP_MATCH() #definery, I
> end-up with warnings such as:
>
> In file included from ./include/linux/kernel.h:16,
>                  from drivers/irqchip/irq-bcm7038-l1.c:12:
> ./include/linux/minmax.h:20:28: warning: comparison of distinct pointer types lacks a cast
>    20 |  (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
>       |                            ^~
> ./include/linux/irqchip.h:41:2: note: in expansion of macro ‘__typecheck’
>    41 |  __typecheck(typecheck_irq_init_cb, fn) ? fn : fn
>       |  ^~~~~~~~~~~
> ./include/linux/irqchip.h:44:12: note: in expansion of macro ‘typecheck_irq_init_cb’
>    44 |    .data = typecheck_irq_init_cb(fn), },
>       |            ^~~~~~~~~~~~~~~~~~~~~
> drivers/irqchip/irq-bcm7038-l1.c:459:1: note: in expansion of macro ‘IRQCHIP_MATCH’
>   459 | IRQCHIP_MATCH("brcm,bcm7038-l1-intc", bcm7038_l1_of_init)
>       | ^~~~~~~~~~~~~
>
> Clearly, you didn't update the drivers you just converted to
> IRQCHIP_MATCH(), and only fixed the QC driver.
>
> FWIW, I'm planning to take something like the hack below into the tree
> to detect this sort of stuff early.
>
>         M.
>
> diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h
> index ccf32758ea85..146a9d80a6a2 100644
> --- a/include/linux/irqchip.h
> +++ b/include/linux/irqchip.h
> @@ -33,7 +33,15 @@ extern int platform_irqchip_probe(struct platform_device *pdev);
>  #define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \
>  static const struct of_device_id drv_name##_irqchip_match_table[] = {
>
> -#define IRQCHIP_MATCH(compat, fn) { .compatible = compat, .data = fn },
> +/* Undefined on purpose */
> +int typecheck_irq_init_cb(struct device_node *, struct device_node *,
> +                         struct platform_device *);
> +
> +#define typecheck_irq_init_cb(fn)                                      \
> +       __typecheck(typecheck_irq_init_cb, fn) ? fn : fn

That's nice! Shouldn't it also be used for IRQCHIP_DECLARE?

> +#define IRQCHIP_MATCH(compat, fn) { .compatible = compat,      \
> +                       .data = typecheck_irq_init_cb(fn), },

I was going to say I wasn't really a fan of IRQCHIP_MATCH given it had
nothing irqchip specific about it, but you fixed that now...

>
>  #define IRQCHIP_PLATFORM_DRIVER_END(drv_name)                          \
>         {},                                                             \
>
> --
> Without deviation from the norm, progress is not possible.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v4 09/14] irqchip: Provide platform_device to of_irq_init_cb_t
  2021-10-19 22:23       ` Rob Herring
@ 2021-10-20  8:24         ` Marc Zyngier
  -1 siblings, 0 replies; 46+ messages in thread
From: Marc Zyngier @ 2021-10-20  8:24 UTC (permalink / raw)
  To: Rob Herring
  Cc: Florian Fainelli, linux-kernel, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

On Tue, 19 Oct 2021 23:23:52 +0100,
Rob Herring <robh@kernel.org> wrote:
> 
>  On Tue, Oct 19, 2021 at 4:43 PM Marc Zyngier <maz@kernel.org> wrote:
> >
> > diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h
> > index ccf32758ea85..146a9d80a6a2 100644
> > --- a/include/linux/irqchip.h
> > +++ b/include/linux/irqchip.h
> > @@ -33,7 +33,15 @@ extern int platform_irqchip_probe(struct platform_device *pdev);
> >  #define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \
> >  static const struct of_device_id drv_name##_irqchip_match_table[] = {
> >
> > -#define IRQCHIP_MATCH(compat, fn) { .compatible = compat, .data = fn },
> > +/* Undefined on purpose */
> > +int typecheck_irq_init_cb(struct device_node *, struct device_node *,
> > +                         struct platform_device *);
> > +
> > +#define typecheck_irq_init_cb(fn)                                      \
> > +       __typecheck(typecheck_irq_init_cb, fn) ? fn : fn
> 
> That's nice! Shouldn't it also be used for IRQCHIP_DECLARE?

Absolutely. And enabling this shows that changing of_irq_init_cb_t
breaks *all users* of IRQCHIP_DECLARE(). Not an acceptable outcome
when we're at -rc5.

Why can't the relevant drivers use of_find_device_by_node() instead?
That would allow us to keep the status-quo on of_irq_init_cb_t.

Thanks,

	M.

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

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

* Re: [PATCH v4 09/14] irqchip: Provide platform_device to of_irq_init_cb_t
@ 2021-10-20  8:24         ` Marc Zyngier
  0 siblings, 0 replies; 46+ messages in thread
From: Marc Zyngier @ 2021-10-20  8:24 UTC (permalink / raw)
  To: Rob Herring
  Cc: Florian Fainelli, linux-kernel, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

On Tue, 19 Oct 2021 23:23:52 +0100,
Rob Herring <robh@kernel.org> wrote:
> 
>  On Tue, Oct 19, 2021 at 4:43 PM Marc Zyngier <maz@kernel.org> wrote:
> >
> > diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h
> > index ccf32758ea85..146a9d80a6a2 100644
> > --- a/include/linux/irqchip.h
> > +++ b/include/linux/irqchip.h
> > @@ -33,7 +33,15 @@ extern int platform_irqchip_probe(struct platform_device *pdev);
> >  #define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \
> >  static const struct of_device_id drv_name##_irqchip_match_table[] = {
> >
> > -#define IRQCHIP_MATCH(compat, fn) { .compatible = compat, .data = fn },
> > +/* Undefined on purpose */
> > +int typecheck_irq_init_cb(struct device_node *, struct device_node *,
> > +                         struct platform_device *);
> > +
> > +#define typecheck_irq_init_cb(fn)                                      \
> > +       __typecheck(typecheck_irq_init_cb, fn) ? fn : fn
> 
> That's nice! Shouldn't it also be used for IRQCHIP_DECLARE?

Absolutely. And enabling this shows that changing of_irq_init_cb_t
breaks *all users* of IRQCHIP_DECLARE(). Not an acceptable outcome
when we're at -rc5.

Why can't the relevant drivers use of_find_device_by_node() instead?
That would allow us to keep the status-quo on of_irq_init_cb_t.

Thanks,

	M.

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v4 09/14] irqchip: Provide platform_device to of_irq_init_cb_t
  2021-10-20  8:24         ` Marc Zyngier
@ 2021-10-20 15:14           ` Florian Fainelli
  -1 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-20 15:14 UTC (permalink / raw)
  To: Marc Zyngier, Rob Herring
  Cc: Florian Fainelli, linux-kernel, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE



On 10/20/2021 1:24 AM, Marc Zyngier wrote:
> On Tue, 19 Oct 2021 23:23:52 +0100,
> Rob Herring <robh@kernel.org> wrote:
>>
>>   On Tue, Oct 19, 2021 at 4:43 PM Marc Zyngier <maz@kernel.org> wrote:
>>>
>>> diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h
>>> index ccf32758ea85..146a9d80a6a2 100644
>>> --- a/include/linux/irqchip.h
>>> +++ b/include/linux/irqchip.h
>>> @@ -33,7 +33,15 @@ extern int platform_irqchip_probe(struct platform_device *pdev);
>>>   #define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \
>>>   static const struct of_device_id drv_name##_irqchip_match_table[] = {
>>>
>>> -#define IRQCHIP_MATCH(compat, fn) { .compatible = compat, .data = fn },
>>> +/* Undefined on purpose */
>>> +int typecheck_irq_init_cb(struct device_node *, struct device_node *,
>>> +                         struct platform_device *);
>>> +
>>> +#define typecheck_irq_init_cb(fn)                                      \
>>> +       __typecheck(typecheck_irq_init_cb, fn) ? fn : fn
>>
>> That's nice! Shouldn't it also be used for IRQCHIP_DECLARE?
> 
> Absolutely. And enabling this shows that changing of_irq_init_cb_t
> breaks *all users* of IRQCHIP_DECLARE(). Not an acceptable outcome
> when we're at -rc5. >
> Why can't the relevant drivers use of_find_device_by_node() instead?
> That would allow us to keep the status-quo on of_irq_init_cb_t.

Rob had suggested several solutions, including using 
of_find_device_by_node(), however updating of_irq_init_cb_t was 
indicated to be the better way. I had intentionally not updated 
IRQCHIP_DECLARE() because it would ignore the 3rd argument we passed to 
it (platform_device *) so I thought.

If I am spinning a v6 using of_find_device_by_node() would that be 
acceptable to you?
-- 
Florian

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

* Re: [PATCH v4 09/14] irqchip: Provide platform_device to of_irq_init_cb_t
@ 2021-10-20 15:14           ` Florian Fainelli
  0 siblings, 0 replies; 46+ messages in thread
From: Florian Fainelli @ 2021-10-20 15:14 UTC (permalink / raw)
  To: Marc Zyngier, Rob Herring
  Cc: Florian Fainelli, linux-kernel, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE



On 10/20/2021 1:24 AM, Marc Zyngier wrote:
> On Tue, 19 Oct 2021 23:23:52 +0100,
> Rob Herring <robh@kernel.org> wrote:
>>
>>   On Tue, Oct 19, 2021 at 4:43 PM Marc Zyngier <maz@kernel.org> wrote:
>>>
>>> diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h
>>> index ccf32758ea85..146a9d80a6a2 100644
>>> --- a/include/linux/irqchip.h
>>> +++ b/include/linux/irqchip.h
>>> @@ -33,7 +33,15 @@ extern int platform_irqchip_probe(struct platform_device *pdev);
>>>   #define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \
>>>   static const struct of_device_id drv_name##_irqchip_match_table[] = {
>>>
>>> -#define IRQCHIP_MATCH(compat, fn) { .compatible = compat, .data = fn },
>>> +/* Undefined on purpose */
>>> +int typecheck_irq_init_cb(struct device_node *, struct device_node *,
>>> +                         struct platform_device *);
>>> +
>>> +#define typecheck_irq_init_cb(fn)                                      \
>>> +       __typecheck(typecheck_irq_init_cb, fn) ? fn : fn
>>
>> That's nice! Shouldn't it also be used for IRQCHIP_DECLARE?
> 
> Absolutely. And enabling this shows that changing of_irq_init_cb_t
> breaks *all users* of IRQCHIP_DECLARE(). Not an acceptable outcome
> when we're at -rc5. >
> Why can't the relevant drivers use of_find_device_by_node() instead?
> That would allow us to keep the status-quo on of_irq_init_cb_t.

Rob had suggested several solutions, including using 
of_find_device_by_node(), however updating of_irq_init_cb_t was 
indicated to be the better way. I had intentionally not updated 
IRQCHIP_DECLARE() because it would ignore the 3rd argument we passed to 
it (platform_device *) so I thought.

If I am spinning a v6 using of_find_device_by_node() would that be 
acceptable to you?
-- 
Florian

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v4 09/14] irqchip: Provide platform_device to of_irq_init_cb_t
  2021-10-20 15:14           ` Florian Fainelli
@ 2021-10-20 15:28             ` Marc Zyngier
  -1 siblings, 0 replies; 46+ messages in thread
From: Marc Zyngier @ 2021-10-20 15:28 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Rob Herring, linux-kernel, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

On Wed, 20 Oct 2021 16:14:07 +0100,
Florian Fainelli <f.fainelli@gmail.com> wrote:
> 
> 
> 
> On 10/20/2021 1:24 AM, Marc Zyngier wrote:
> > On Tue, 19 Oct 2021 23:23:52 +0100,
> > Rob Herring <robh@kernel.org> wrote:
> >> 
> >>   On Tue, Oct 19, 2021 at 4:43 PM Marc Zyngier <maz@kernel.org> wrote:
> >>> 
> >>> diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h
> >>> index ccf32758ea85..146a9d80a6a2 100644
> >>> --- a/include/linux/irqchip.h
> >>> +++ b/include/linux/irqchip.h
> >>> @@ -33,7 +33,15 @@ extern int platform_irqchip_probe(struct platform_device *pdev);
> >>>   #define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \
> >>>   static const struct of_device_id drv_name##_irqchip_match_table[] = {
> >>> 
> >>> -#define IRQCHIP_MATCH(compat, fn) { .compatible = compat, .data = fn },
> >>> +/* Undefined on purpose */
> >>> +int typecheck_irq_init_cb(struct device_node *, struct device_node *,
> >>> +                         struct platform_device *);
> >>> +
> >>> +#define typecheck_irq_init_cb(fn)                                      \
> >>> +       __typecheck(typecheck_irq_init_cb, fn) ? fn : fn
> >> 
> >> That's nice! Shouldn't it also be used for IRQCHIP_DECLARE?
> > 
> > Absolutely. And enabling this shows that changing of_irq_init_cb_t
> > breaks *all users* of IRQCHIP_DECLARE(). Not an acceptable outcome
> > when we're at -rc5. >
> > Why can't the relevant drivers use of_find_device_by_node() instead?
> > That would allow us to keep the status-quo on of_irq_init_cb_t.
> 
> Rob had suggested several solutions, including using
> of_find_device_by_node(), however updating of_irq_init_cb_t was
> indicated to be the better way. I had intentionally not updated
> IRQCHIP_DECLARE() because it would ignore the 3rd argument we passed
> to it (platform_device *) so I thought.

In general, conflicting prototype always lead to the compiler
legitimately screwing something up, and you are left with a pile of
steaming crap to debug.

So *no* to that sort of trick.

> If I am spinning a v6 using of_find_device_by_node() would that be
> acceptable to you?

That'd be much better.

Thanks,

	M.

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

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

* Re: [PATCH v4 09/14] irqchip: Provide platform_device to of_irq_init_cb_t
@ 2021-10-20 15:28             ` Marc Zyngier
  0 siblings, 0 replies; 46+ messages in thread
From: Marc Zyngier @ 2021-10-20 15:28 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Rob Herring, linux-kernel, Ray Jui, Scott Branden,
	maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...,
	Russell King, Catalin Marinas, Will Deacon, Thomas Bogendoerfer,
	Thomas Gleixner, Frank Rowand,
	moderated list:ARM SUB-ARCHITECTURES, open list:MIPS,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE

On Wed, 20 Oct 2021 16:14:07 +0100,
Florian Fainelli <f.fainelli@gmail.com> wrote:
> 
> 
> 
> On 10/20/2021 1:24 AM, Marc Zyngier wrote:
> > On Tue, 19 Oct 2021 23:23:52 +0100,
> > Rob Herring <robh@kernel.org> wrote:
> >> 
> >>   On Tue, Oct 19, 2021 at 4:43 PM Marc Zyngier <maz@kernel.org> wrote:
> >>> 
> >>> diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h
> >>> index ccf32758ea85..146a9d80a6a2 100644
> >>> --- a/include/linux/irqchip.h
> >>> +++ b/include/linux/irqchip.h
> >>> @@ -33,7 +33,15 @@ extern int platform_irqchip_probe(struct platform_device *pdev);
> >>>   #define IRQCHIP_PLATFORM_DRIVER_BEGIN(drv_name) \
> >>>   static const struct of_device_id drv_name##_irqchip_match_table[] = {
> >>> 
> >>> -#define IRQCHIP_MATCH(compat, fn) { .compatible = compat, .data = fn },
> >>> +/* Undefined on purpose */
> >>> +int typecheck_irq_init_cb(struct device_node *, struct device_node *,
> >>> +                         struct platform_device *);
> >>> +
> >>> +#define typecheck_irq_init_cb(fn)                                      \
> >>> +       __typecheck(typecheck_irq_init_cb, fn) ? fn : fn
> >> 
> >> That's nice! Shouldn't it also be used for IRQCHIP_DECLARE?
> > 
> > Absolutely. And enabling this shows that changing of_irq_init_cb_t
> > breaks *all users* of IRQCHIP_DECLARE(). Not an acceptable outcome
> > when we're at -rc5. >
> > Why can't the relevant drivers use of_find_device_by_node() instead?
> > That would allow us to keep the status-quo on of_irq_init_cb_t.
> 
> Rob had suggested several solutions, including using
> of_find_device_by_node(), however updating of_irq_init_cb_t was
> indicated to be the better way. I had intentionally not updated
> IRQCHIP_DECLARE() because it would ignore the 3rd argument we passed
> to it (platform_device *) so I thought.

In general, conflicting prototype always lead to the compiler
legitimately screwing something up, and you are left with a pile of
steaming crap to debug.

So *no* to that sort of trick.

> If I am spinning a v6 using of_find_device_by_node() would that be
> acceptable to you?

That'd be much better.

Thanks,

	M.

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2021-10-20 15:35 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-09  2:20 [PATCH v4 00/14] Modular Broadcom irqchip drivers Florian Fainelli
2021-10-09  2:20 ` Florian Fainelli
2021-10-09  2:20 ` [PATCH v4 01/14] MIPS: BMIPS: Remove use of irq_cpu_offline Florian Fainelli
2021-10-09  2:20   ` Florian Fainelli
2021-10-09  2:20 ` [PATCH v4 02/14] irqchip/irq-bcm7038-l1: Remove .irq_cpu_offline() Florian Fainelli
2021-10-09  2:20   ` Florian Fainelli
2021-10-09  2:20 ` [PATCH v4 03/14] irqchip/irq-bcm7038-l1: Use irq_get_irq_data() Florian Fainelli
2021-10-09  2:20   ` Florian Fainelli
2021-10-09  2:20 ` [PATCH v4 04/14] irqchip/irq-bcm7038-l1: Gate use of CPU logical map to MIPS Florian Fainelli
2021-10-09  2:20   ` Florian Fainelli
2021-10-09  2:20 ` [PATCH v4 05/14] irqchip/irq-bcm7038-l1: Restrict affinity setting " Florian Fainelli
2021-10-09  2:20   ` Florian Fainelli
2021-10-09  2:20 ` [PATCH v4 06/14] irqchip/irq-bcm7038-l1: Switch to IRQCHIP_PLATFORM_DRIVER Florian Fainelli
2021-10-09  2:20   ` Florian Fainelli
2021-10-09  2:20 ` [PATCH v4 07/14] genirq: Export irq_gc_{unmask_enable,mask_disable}_reg Florian Fainelli
2021-10-09  2:20   ` [PATCH v4 07/14] genirq: Export irq_gc_{unmask_enable, mask_disable}_reg Florian Fainelli
2021-10-09  2:20 ` [PATCH v4 08/14] irqchip/irq-brcmstb-l2: Switch to IRQCHIP_PLATFORM_DRIVER Florian Fainelli
2021-10-09  2:20   ` Florian Fainelli
2021-10-09  2:20 ` [PATCH v4 09/14] irqchip: Provide platform_device to of_irq_init_cb_t Florian Fainelli
2021-10-09  2:20   ` Florian Fainelli
2021-10-19 21:43   ` Marc Zyngier
2021-10-19 21:43     ` Marc Zyngier
2021-10-19 21:52     ` Florian Fainelli
2021-10-19 21:52       ` Florian Fainelli
2021-10-19 22:23     ` Rob Herring
2021-10-19 22:23       ` Rob Herring
2021-10-20  8:24       ` Marc Zyngier
2021-10-20  8:24         ` Marc Zyngier
2021-10-20 15:14         ` Florian Fainelli
2021-10-20 15:14           ` Florian Fainelli
2021-10-20 15:28           ` Marc Zyngier
2021-10-20 15:28             ` Marc Zyngier
2021-10-09  2:20 ` [PATCH v4 10/14] genirq: Export irq_gc_noop() Florian Fainelli
2021-10-09  2:20   ` Florian Fainelli
2021-10-09  2:20 ` [PATCH v4 11/14] irqchip/irq-bcm7120-l2: Switch to IRQCHIP_PLATFORM_DRIVER Florian Fainelli
2021-10-09  2:20   ` Florian Fainelli
2021-10-09  2:20 ` [PATCH v4 12/14] arm64: broadcom: Removed forced select of interrupt controllers Florian Fainelli
2021-10-09  2:20   ` Florian Fainelli
2021-10-09  2:20 ` [PATCH v4 13/14] ARM: bcm: " Florian Fainelli
2021-10-09  2:20   ` Florian Fainelli
2021-10-09  2:20 ` [PATCH v4 14/14] irqchip: Fix kernel-doc parameter typo for IRQCHIP_DECLARE Florian Fainelli
2021-10-09  2:20   ` Florian Fainelli
2021-10-19 19:13 ` [PATCH v4 00/14] Modular Broadcom irqchip drivers Florian Fainelli
2021-10-19 19:13   ` Florian Fainelli
2021-10-19 21:46   ` Marc Zyngier
2021-10-19 21:46     ` Marc Zyngier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.