Skip to contentSkip to conversation

of: allow to support irq domain register as platform_device for platform_device

RFC PATCH In review Jean-Christophe PLAGNIOL-VILLARD 5 participants 23 messages May 28, 2013 – Jun 24, 2013 10 messages not in the archive

Subsystems (9)
PowerPC MIPS GPIO Arm Samsung Exynos +5 more subsystems
lore
Share & tools
lore
#0 lore raw

cover of: allow to support irq domain register as platform_device for platform_device

Hi,

Today in the current of implementation we populate all the ressources at of_platform_populate time. But this leed to a chicken-egg dilemat some the irq present in DT are from platform_device too. And you can not resolve them as of_platform_populate. So delay the populate of irq at platform_drv_probe.

And if the irq_domain is not yet present just defer the probe (GPIO as example)

we still have one issue is that the gpio irq provide by DT need to have the gpio requested and configured which I'll fix later by handling this automatically by a gpio_irq_chip and dorp this from every drivers

The following changes since commit e4aa937ec75df0eea0bee03bffa3303ad36c986b:

Linux 3.10-rc3 (2013-05-26 16:00:47 -0700)

are available in the git repository at:

git://github.com/at91linux/linux-at91.git j/for-3.11-platform_irq_resolve

for you to fetch changes up to 898eab5ad414bfc48dd1160369965a677f135d26:

IRQ: irq domain: defer of irq ressoure resolve at platform_drv_probe (2013-05-28 05:58:31 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (3):
of: irq: rename of_irq_count to of_irq_valid_count
of: add of_irq_count: Count the number of IRQs a node present
IRQ: irq domain: defer of irq ressoure resolve at platform_drv_probe

 arch/mips/lantiq/irq.c           |    2 +-
 arch/powerpc/sysdev/ppc4xx_msi.c |    2 +-
 drivers/base/platform.c          |    5 +++++
 drivers/clocksource/exynos_mct.c |    2 +-
 drivers/gpio/gpio-mvebu.c        |    2 +-
 drivers/irqchip/irq-vt8500.c     |    4 ++--
 drivers/of/irq.c                 |   15 +++++++++++++++
 drivers/of/platform.c            |   27 ++++++++++++++++++++++++++-
 include/linux/of_irq.h           |    1 +
 include/linux/of_platform.h      |    7 +++++++
 10 files changed, 60 insertions(+), 7 deletions(-)

Best Regards,
J.

A message that is not in the archive (sent off-list or not yet received): 20130528145219.GA30411-RQcB7r2h9QmfDR2tN2SG5Ni2O/[email protected]

#2 lore raw

RFC PATCH 1/3 of: irq: rename of_irq_count to of_irq_valid_count

as we count valid mapped irq not just present irq

Cc Grant Likely <grant.likely-s3s/[email protected]>
Cc Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Ralf Baechle <ralf-6z/[email protected]>
Cc Nicolas Ferre <[email protected]>
---
 arch/mips/lantiq/irq.c           |    2 +-
 arch/powerpc/sysdev/ppc4xx_msi.c |    2 +-
 drivers/clocksource/exynos_mct.c |    2 +-
 drivers/gpio/gpio-mvebu.c        |    2 +-
 drivers/irqchip/irq-vt8500.c     |    4 ++--
 drivers/of/irq.c                 |    4 ++--
 drivers/of/platform.c            |    2 +-
 include/linux/of_irq.h           |    2 +-
 8 files changed, 10 insertions(+), 10 deletions(-)
arch/mips/lantiq/irq.c +1 -1
index 5119487..f1f54bd 100644
@@ -382,7 +382,7 @@ int __init icu_of_init(struct device_node *node, struct device_node *parent)
 	eiu_node = of_find_compatible_node(NULL, NULL, "lantiq,eiu-xway");
 	if (eiu_node && !of_address_to_resource(eiu_node, 0, &res)) {
 		/* find out how many external irq sources we have */
-		exin_avail = of_irq_count(eiu_node);
+		exin_avail = of_irq_valid_count(eiu_node);
 
 		if (exin_avail > MAX_EIU)
 			exin_avail = MAX_EIU;
arch/powerpc/sysdev/ppc4xx_msi.c +1 -1
index 43948da..b836b68 100644
@@ -243,7 +243,7 @@ static int ppc4xx_msi_probe(struct platform_device *dev)
 		goto error_out;
 	}
 
-	msi_irqs = of_irq_count(dev->dev.of_node);
+	msi_irqs = of_irq_valid_count(dev->dev.of_node);
 	if (!msi_irqs)
 		return -ENODEV;
 
drivers/clocksource/exynos_mct.c +1 -1
index 662fcc0..a0bee5b 100644
@@ -532,7 +532,7 @@ static void __init mct_init_dt(struct device_node *np, unsigned int int_type)
 	 * irqs are specified.
 	 */
 #ifdef CONFIG_OF
-	nr_irqs = of_irq_count(np);
+	nr_irqs = of_irq_valid_count(np);
 #else
 	nr_irqs = 0;
 #endif
drivers/gpio/gpio-mvebu.c +1 -1
index bf69a7e..e3e4f05 100644
@@ -668,7 +668,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
 	gpiochip_add(&mvchip->chip);
 
 	/* Some gpio controllers do not provide irq support */
-	if (!of_irq_count(np))
+	if (!of_irq_valid_count(np))
 		return 0;
 
 	/* Setup the interrupt handlers. Each chip can have up to 4
drivers/irqchip/irq-vt8500.c +2 -2
index d970595..bf1d6e7 100644
@@ -237,9 +237,9 @@ int __init vt8500_irq_init(struct device_node *node, struct device_node *parent)
 	active_cnt++;
 
 	/* check if this is a slaved controller */
-	if (of_irq_count(np) != 0) {
+	if (of_irq_valid_count(np) != 0) {
 		/* check that we have the correct number of interrupts */
-		if (of_irq_count(np) != 8) {
+		if (of_irq_valid_count(np) != 8) {
 			pr_err("%s: Incorrect IRQ map for slaved controller\n",
 					__func__);
 			return -EINVAL;
drivers/of/irq.c +2 -2
index a3c1c5a..d1c5825 100644
@@ -362,10 +362,10 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)
 EXPORT_SYMBOL_GPL(of_irq_to_resource);
 
 /**
- * of_irq_count - Count the number of IRQs a node uses
+ * of_irq_valid_count - Count the number of mapped IRQs a node uses
  * @dev: pointer to device tree node
  */
-int of_irq_count(struct device_node *dev)
+int of_irq_valid_count(struct device_node *dev)
 {
 	int nr = 0;
 
drivers/of/platform.c +1 -1
index e0a6514..00a0971 100644
@@ -152,7 +152,7 @@ struct platform_device *of_device_alloc(struct device_node *np,
 	if (of_can_translate_address(np))
 		while (of_address_to_resource(np, num_reg, &temp_res) == 0)
 			num_reg++;
-	num_irq = of_irq_count(np);
+	num_irq = of_irq_valid_count(np);
 
 	/* Populate the resource table */
 	if (num_irq || num_reg) {
include/linux/of_irq.h +1 -1
index 535cecf..88bb58c 100644
@@ -68,7 +68,7 @@ extern unsigned int irq_create_of_mapping(struct device_node *controller,
 					  unsigned int intsize);
 extern int of_irq_to_resource(struct device_node *dev, int index,
 			      struct resource *r);
-extern int of_irq_count(struct device_node *dev);
+extern int of_irq_valid_count(struct device_node *dev);
 extern int of_irq_to_resource_table(struct device_node *dev,
 		struct resource *res, int nr_irqs);
 extern struct device_node *of_irq_find_parent(struct device_node *child);
Signature · 1 line
1.7.10.4

A message that is not in the archive (sent off-list or not yet received): 1369753729-12997-1-git-send-email-plagnioj-sclMFOaUSTBWk0Htik3J/[email protected]

#4 lore raw

RFC PATCH 2/3 of: add of_irq_count: Count the number of IRQs a node present

Cc Grant Likely <grant.likely-s3s/[email protected]>
Cc Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Ralf Baechle <ralf-6z/[email protected]>
Cc Nicolas Ferre <[email protected]>
---
 drivers/of/irq.c       |   15 +++++++++++++++
 include/linux/of_irq.h |    1 +
 2 files changed, 16 insertions(+)
drivers/of/irq.c +15 -0
index d1c5825..4426223 100644
@@ -362,6 +362,21 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)
 EXPORT_SYMBOL_GPL(of_irq_to_resource);
 
 /**
+ * of_irq_count - Count the number of IRQs a node uses
+ * @dev: pointer to device tree node
+ */
+int of_irq_count(struct device_node *dev)
+{
+	struct of_irq oirq;
+	int nr = 0;
+
+	while (!of_irq_map_one(dev, nr, &oirq))
+		nr++;
+
+	return nr;
+}
+
+/**
  * of_irq_valid_count - Count the number of mapped IRQs a node uses
  * @dev: pointer to device tree node
  */
include/linux/of_irq.h +1 -0
index 88bb58c..86b78ef 100644
@@ -68,6 +68,7 @@ extern unsigned int irq_create_of_mapping(struct device_node *controller,
 					  unsigned int intsize);
 extern int of_irq_to_resource(struct device_node *dev, int index,
 			      struct resource *r);
+extern int of_irq_count(struct device_node *dev);
 extern int of_irq_valid_count(struct device_node *dev);
 extern int of_irq_to_resource_table(struct device_node *dev,
 		struct resource *res, int nr_irqs);
Signature · 1 line
1.7.10.4

A message that is not in the archive (sent off-list or not yet received): 1369753729-12997-2-git-send-email-plagnioj-sclMFOaUSTBWk0Htik3J/[email protected]

#6 lore raw

Re: [RFC] [PATCH 2/3] of: add of_irq_count: Count the number of IRQs a node present

Quoted 18 lines · Jean-Christophe PLAGNIOL-VILLARD
Cc Grant Likely <grant.likely-s3s/[email protected]>
Cc Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Ralf Baechle <ralf-6z/[email protected]>
Cc Nicolas Ferre <[email protected]>
---
 drivers/of/irq.c       |   15 +++++++++++++++
 include/linux/of_irq.h |    1 +
 2 files changed, 16 insertions(+)
drivers/of/irq.c +0 -0
index d1c5825..4426223 100644

drivers/of/irq.c int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) · line 368

Quoted 7 lines
drivers/of/irq.c +4 -0
@@ -362,6 +362,21 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)
 EXPORT_SYMBOL_GPL(of_irq_to_resource);
 
 /**
+ * of_irq_count - Count the number of IRQs a node uses
+ * @dev: pointer to device tree node
+ */
+int of_irq_count(struct device_node *dev)

Following on from my comment on patch 1/3, How about "of_irq_count_entries()"?

drivers/of/irq.c int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) · line 374

Quoted 6 lines
drivers/of/irq.c +6 -0
+{
+	struct of_irq oirq;
+	int nr = 0;
+
+	while (!of_irq_map_one(dev, nr, &oirq))
+		nr++;

The concept is good, but this ends up being very inefficient. It would be better to take the relevant parts out of of_irq_map_one() to retrieve the value of #interrupt-cells and compare it to the size of the interrupts property.

g.

#7 lore raw

Re: [RFC] [PATCH 2/3] of: add of_irq_count: Count the number of IRQs a node present

Quoted 21 lines · Grant Likely
Quoted 20 lines · Jean-Christophe PLAGNIOL-VILLARD
Cc Grant Likely <grant.likely-s3s/[email protected]>
Cc Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Ralf Baechle <ralf-6z/[email protected]>
Cc Nicolas Ferre <[email protected]>
---
 drivers/of/irq.c       |   15 +++++++++++++++
 include/linux/of_irq.h |    1 +
 2 files changed, 16 insertions(+)
drivers/of/irq.c +0 -0
index d1c5825..4426223 100644
@@ -362,6 +362,21 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)
 EXPORT_SYMBOL_GPL(of_irq_to_resource);
 
Quoted 7 lines

drivers/of/irq.c int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) · line 368

Quoted 5 lines
drivers/of/irq.c +4 -0
 /**
+ * of_irq_count - Count the number of IRQs a node uses
+ * @dev: pointer to device tree node
+ */
+int of_irq_count(struct device_node *dev)

Following on from my comment on patch 1/3, How about "of_irq_count_entries()"?

yeah look much better

so I drop the patch 1/3

Quoted 12 lines

drivers/of/irq.c int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) · line 374

Quoted 7 lines
drivers/of/irq.c +6 -0
+{
+	struct of_irq oirq;
+	int nr = 0;
+
+	while (!of_irq_map_one(dev, nr, &oirq))
+		nr++;

The concept is good, but this ends up being very inefficient. It would be better to take the relevant parts out of of_irq_map_one() to retrieve the value of #interrupt-cells and compare it to the size of the interrupts property.

ok

Best Regards,
J.

#8 lore raw

RFC PATCH 3/3 IRQ: irq domain: defer of irq ressoure resolve at platform_drv_probe

In reply to a message not in the archive

Today in the current of implementation we populate all the ressources at of_platform_populate time. But this leed to a chicken-egg dilemat some the irq present in DT are from platform_device too. And you can not resolve them as of_platform_populate. So delay the populate of irq at platform_drv_probe.

And if the irq_domain is not yet present just defer the probe (GPIO as example)

Cc Grant Likely <grant.likely-s3s/[email protected]>
Cc Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Ralf Baechle <ralf-6z/[email protected]>
Cc Nicolas Ferre <[email protected]>
---
 drivers/base/platform.c     |    5 +++++
 drivers/of/platform.c       |   29 +++++++++++++++++++++++++++--
 include/linux/of_platform.h |    7 +++++++
 3 files changed, 39 insertions(+), 2 deletions(-)
drivers/base/platform.c +5 -0
index 9eda842..c0f7906 100644
@@ -13,6 +13,7 @@
 #include <linux/string.h>
 #include <linux/platform_device.h>
 #include <linux/of_device.h>
+#include <linux/of_platform.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/dma-mapping.h>
@@ -484,6 +485,10 @@ static int platform_drv_probe(struct device *_dev)
 	struct platform_device *dev = to_platform_device(_dev);
 	int ret;
 
+	ret = of_device_init_irq(dev);
+	if (ret)
+		return ret;
+
 	if (ACPI_HANDLE(_dev))
 		acpi_dev_pm_attach(_dev, true);
 
drivers/of/platform.c +27 -2
index 00a0971..c290943 100644
@@ -131,6 +131,32 @@ void of_device_make_bus_id(struct device *dev)
 }
 
 /**
+ * of_device_alloc_irq - initialize irq of an platfrom_device
+ * @dev: plaform_device to work on
+ */
+int of_device_init_irq(struct platform_device *dev)
+{
+	struct device_node *np = dev->dev.of_node;
+	int num_irq;
+	int ret;
+	struct resource *res = dev->resource;
+
+	if (!np)
+		return 0;
+
+	num_irq = of_irq_count(np);
+	if (!num_irq)
+		return 0;
+
+	res += dev->num_resources - num_irq;
+	ret = of_irq_to_resource_table(np, res, num_irq);
+	if (ret != num_irq)
+		return -EPROBE_DEFER;
+
+	return 0;
+}
+
+/**
  * of_device_alloc - Allocate and initialize an of_device
  * @np: device node to assign to device
  * @bus_id: Name to assign to the device.  May be null to use default name.
@@ -152,7 +178,7 @@ struct platform_device *of_device_alloc(struct device_node *np,
 	if (of_can_translate_address(np))
 		while (of_address_to_resource(np, num_reg, &temp_res) == 0)
 			num_reg++;
-	num_irq = of_irq_valid_count(np);
+	num_irq = of_irq_count(np);
 
 	/* Populate the resource table */
 	if (num_irq || num_reg) {
@@ -168,7 +194,6 @@ struct platform_device *of_device_alloc(struct device_node *np,
 			rc = of_address_to_resource(np, i, res);
 			WARN_ON(rc);
 		}
-		WARN_ON(of_irq_to_resource_table(np, res, num_irq) != num_irq);
 	}
 
 	dev->dev.of_node = of_node_get(np);
include/linux/of_platform.h +7 -0
index 3863a4d..b5f9bb6 100644
@@ -79,6 +79,7 @@ extern const struct of_device_id of_default_bus_match_table[];
 extern struct platform_device *of_device_alloc(struct device_node *np,
 					 const char *bus_id,
 					 struct device *parent);
+extern int of_device_init_irq(struct platform_device *dev);
 extern struct platform_device *of_find_device_by_node(struct device_node *np);
 
 #ifdef CONFIG_OF_ADDRESS /* device reg helpers depend on OF_ADDRESS */
@@ -101,6 +102,7 @@ extern int of_platform_populate(struct device_node *root,
 #if !defined(CONFIG_OF_ADDRESS)
 struct of_dev_auxdata;
 struct device;
+struct platform_device;
 static inline int of_platform_populate(struct device_node *root,
 					const struct of_device_id *matches,
 					const struct of_dev_auxdata *lookup,
@@ -108,6 +110,11 @@ static inline int of_platform_populate(struct device_node *root,
 {
 	return -ENODEV;
 }
+
+static inline int of_device_init_irq(struct platform_device *dev)
+{
+	return 0;
+}
 #endif /* !CONFIG_OF_ADDRESS */
 
 #endif	/* _LINUX_OF_PLATFORM_H */
Signature · 1 line
1.7.10.4

A message that is not in the archive (sent off-list or not yet received): 1369753729-12997-3-git-send-email-plagnioj-sclMFOaUSTBWk0Htik3J/[email protected]

#10 lore raw

Re: [RFC] [PATCH 3/3] IRQ: irq domain: defer of irq ressoure resolve at platform_drv_probe

Quoted 1 line · Jean-Christophe PLAGNIOL-VILLARD

Today in the current of implementation we populate all the ressources

typo

Quoted 1 line

at of_platform_populate time. But this leed to a chicken-egg dilemat

2 typos

Quoted 48 lines

some the irq present in DT are from platform_device too. And you can not resolve them as of_platform_populate. So delay the populate of irq at platform_drv_probe.

And if the irq_domain is not yet present just defer the probe (GPIO as example)

Cc Grant Likely <grant.likely-s3s/[email protected]>
Cc Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Ralf Baechle <ralf-6z/[email protected]>
Cc Nicolas Ferre <[email protected]>
---
 drivers/base/platform.c     |    5 +++++
 drivers/of/platform.c       |   29 +++++++++++++++++++++++++++--
 include/linux/of_platform.h |    7 +++++++
 3 files changed, 39 insertions(+), 2 deletions(-)
drivers/base/platform.c +5 -0
index 9eda842..c0f7906 100644
@@ -13,6 +13,7 @@
 #include <linux/string.h>
 #include <linux/platform_device.h>
 #include <linux/of_device.h>
+#include <linux/of_platform.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/dma-mapping.h>
@@ -484,6 +485,10 @@ static int platform_drv_probe(struct device *_dev)
 	struct platform_device *dev = to_platform_device(_dev);
 	int ret;
 
+	ret = of_device_init_irq(dev);
+	if (ret)
+		return ret;
+
 	if (ACPI_HANDLE(_dev))
 		acpi_dev_pm_attach(_dev, true);
 
drivers/of/platform.c +0 -0
index 00a0971..c290943 100644

drivers/of/platform.c void of_device_make_bus_id(struct device *dev) · line 134

Quoted 4 lines
drivers/of/platform.c +1 -0
@@ -131,6 +131,32 @@ void of_device_make_bus_id(struct device *dev)
 }
 
 /**
+ * of_device_alloc_irq - initialize irq of an platfrom_device

typo

drivers/of/platform.c void of_device_make_bus_id(struct device *dev) · line 135

Quoted 1 line
drivers/of/platform.c +1 -0
+ * @dev: plaform_device to work on

same word, different typo.

Quoted 6 lines
drivers/of/platform.c +6 -0
+ */
+int of_device_init_irq(struct platform_device *dev)
+{
+	struct device_node *np = dev->dev.of_node;
+	int num_irq;
+	int ret;

drivers/of/platform.c void of_device_make_bus_id(struct device *dev) · line 151

Quoted 10 lines
drivers/of/platform.c +10 -0
+	struct resource *res = dev->resource;
+
+	if (!np)
+		return 0;
+
+	num_irq = of_irq_count(np);
+	if (!num_irq)
+		return 0;
+
+	res += dev->num_resources - num_irq;

This looks fragile to me as it relies on how of_device_alloc happens to be implemented.

Quoted 61 lines
drivers/of/platform.c +9 -2
+	ret = of_irq_to_resource_table(np, res, num_irq);
+	if (ret != num_irq)
+		return -EPROBE_DEFER;
+
+	return 0;
+}
+
+/**
  * of_device_alloc - Allocate and initialize an of_device
  * @np: device node to assign to device
  * @bus_id: Name to assign to the device.  May be null to use default name.
@@ -152,7 +178,7 @@ struct platform_device *of_device_alloc(struct device_node *np,
 	if (of_can_translate_address(np))
 		while (of_address_to_resource(np, num_reg, &temp_res) == 0)
 			num_reg++;
-	num_irq = of_irq_valid_count(np);
+	num_irq = of_irq_count(np);
 
 	/* Populate the resource table */
 	if (num_irq || num_reg) {
@@ -168,7 +194,6 @@ struct platform_device *of_device_alloc(struct device_node *np,
 			rc = of_address_to_resource(np, i, res);
 			WARN_ON(rc);
 		}
-		WARN_ON(of_irq_to_resource_table(np, res, num_irq) != num_irq);
 	}
 
 	dev->dev.of_node = of_node_get(np);
include/linux/of_platform.h +7 -0
index 3863a4d..b5f9bb6 100644
@@ -79,6 +79,7 @@ extern const struct of_device_id of_default_bus_match_table[];
 extern struct platform_device *of_device_alloc(struct device_node *np,
 					 const char *bus_id,
 					 struct device *parent);
+extern int of_device_init_irq(struct platform_device *dev);
 extern struct platform_device *of_find_device_by_node(struct device_node *np);
 
 #ifdef CONFIG_OF_ADDRESS /* device reg helpers depend on OF_ADDRESS */
@@ -101,6 +102,7 @@ extern int of_platform_populate(struct device_node *root,
 #if !defined(CONFIG_OF_ADDRESS)
 struct of_dev_auxdata;
 struct device;
+struct platform_device;
 static inline int of_platform_populate(struct device_node *root,
 					const struct of_device_id *matches,
 					const struct of_dev_auxdata *lookup,
@@ -108,6 +110,11 @@ static inline int of_platform_populate(struct device_node *root,
 {
 	return -ENODEV;
 }
+
+static inline int of_device_init_irq(struct platform_device *dev)
+{
+	return 0;
+}
 #endif /* !CONFIG_OF_ADDRESS */
 
 #endif	/* _LINUX_OF_PLATFORM_H */

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw

Re: [RFC] [PATCH 3/3] IRQ: irq domain: defer of irq ressoure resolve at platform_drv_probe

Quoted 20 lines
Quoted 6 lines

+ */

drivers/of/platform.c +5 -0
+int of_device_init_irq(struct platform_device *dev)
+{
+	struct device_node *np = dev->dev.of_node;
+	int num_irq;
+	int ret;

drivers/of/platform.c void of_device_make_bus_id(struct device *dev) · line 151

Quoted 10 lines
drivers/of/platform.c +10 -0
+	struct resource *res = dev->resource;
+
+	if (!np)
+		return 0;
+
+	num_irq = of_irq_count(np);
+	if (!num_irq)
+		return 0;
+
+	res += dev->num_resources - num_irq;

This looks fragile to me as it relies on how of_device_alloc happens to be implemented.

Quoted 3 lines

drivers/of/platform.c void of_device_make_bus_id(struct device *dev) · line 154

Quoted 3 lines
drivers/of/platform.c +3 -0
+	ret = of_irq_to_resource_table(np, res, num_irq);
+	if (ret != num_irq)
+		return -EPROBE_DEFER;

I could reduce the depency on the resource allocation order but I do want to preallocate the ressource

Best Regards,
J.

#13 lore raw

Re: [RFC] [PATCH 3/3] IRQ: irq domain: defer of irq ressoure resolve at platform_drv_probe

In reply to a message not in the archive
Quoted 7 lines · Jean-Christophe PLAGNIOL-VILLARD

Today in the current of implementation we populate all the ressources at of_platform_populate time. But this leed to a chicken-egg dilemat some the irq present in DT are from platform_device too. And you can not resolve them as of_platform_populate. So delay the populate of irq at platform_drv_probe.

And if the irq_domain is not yet present just defer the probe (GPIO as example)

Hi Jean-Christophe,

Thanks for looking at this.

Hmmm, this is an interesting idea. I had been thinking about taping into the platform_get_irq() call to lookup irq numbers at probe time, but that assumes that all platform drivers use that call (which they clearly do not). This approach should work for all drivers as is.

However care needs to be taken to not waste too much time processing irqs every time probe is called. Mapping irqs over and over will get expensive, especially with the current code. It would be better to rework the mapping function to iterate once over the interrupts property and map all the IRQs at once instead of calling of_irq_to_resource() over and over again. (I would however accept the argument that this is a bug fix and the refactoring should be a separate patch)

Quoted 54 lines
Cc Grant Likely <grant.likely-s3s/[email protected]>
Cc Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Ralf Baechle <ralf-6z/[email protected]>
Cc Nicolas Ferre <[email protected]>
---
 drivers/base/platform.c     |    5 +++++
 drivers/of/platform.c       |   29 +++++++++++++++++++++++++++--
 include/linux/of_platform.h |    7 +++++++
 3 files changed, 39 insertions(+), 2 deletions(-)
drivers/base/platform.c +5 -0
index 9eda842..c0f7906 100644
@@ -13,6 +13,7 @@
 #include <linux/string.h>
 #include <linux/platform_device.h>
 #include <linux/of_device.h>
+#include <linux/of_platform.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/dma-mapping.h>
@@ -484,6 +485,10 @@ static int platform_drv_probe(struct device *_dev)
 	struct platform_device *dev = to_platform_device(_dev);
 	int ret;
 
+	ret = of_device_init_irq(dev);
+	if (ret)
+		return ret;
+
 	if (ACPI_HANDLE(_dev))
 		acpi_dev_pm_attach(_dev, true);
 
drivers/of/platform.c +8 -0
index 00a0971..c290943 100644
@@ -131,6 +131,32 @@ void of_device_make_bus_id(struct device *dev)
 }
 
 /**
+ * of_device_alloc_irq - initialize irq of an platfrom_device
+ * @dev: plaform_device to work on
+ */
+int of_device_init_irq(struct platform_device *dev)
+{
+	struct device_node *np = dev->dev.of_node;
+	int num_irq;
+	int ret;

drivers/of/platform.c void of_device_make_bus_id(struct device *dev) · line 151

Quoted 10 lines
drivers/of/platform.c +10 -0
+	struct resource *res = dev->resource;
+
+	if (!np)
+		return 0;
+
+	num_irq = of_irq_count(np);
+	if (!num_irq)
+		return 0;
+
+	res += dev->num_resources - num_irq;

This is a little fragile. Instead of statically calculating the offset, scan the table and make *absolutely* sure that there is a free block of irq resources.

Also, if the table has already been populated successfully, then that should be checked for. That would prevent the same table from being parsed over and over in the case of a device that keeps getting deferred.

Finally, if it fails, make sure any entries that have been filled in get cleared out again before exiting.

Cheers,
g.

Quoted 63 lines
drivers/of/platform.c +9 -2
+	ret = of_irq_to_resource_table(np, res, num_irq);
+	if (ret != num_irq)
+		return -EPROBE_DEFER;
+
+	return 0;
+}
+
+/**
  * of_device_alloc - Allocate and initialize an of_device
  * @np: device node to assign to device
  * @bus_id: Name to assign to the device.  May be null to use default name.
@@ -152,7 +178,7 @@ struct platform_device *of_device_alloc(struct device_node *np,
 	if (of_can_translate_address(np))
 		while (of_address_to_resource(np, num_reg, &temp_res) == 0)
 			num_reg++;
-	num_irq = of_irq_valid_count(np);
+	num_irq = of_irq_count(np);
 
 	/* Populate the resource table */
 	if (num_irq || num_reg) {
@@ -168,7 +194,6 @@ struct platform_device *of_device_alloc(struct device_node *np,
 			rc = of_address_to_resource(np, i, res);
 			WARN_ON(rc);
 		}
-		WARN_ON(of_irq_to_resource_table(np, res, num_irq) != num_irq);
 	}
 
 	dev->dev.of_node = of_node_get(np);
include/linux/of_platform.h +7 -0
index 3863a4d..b5f9bb6 100644
@@ -79,6 +79,7 @@ extern const struct of_device_id of_default_bus_match_table[];
 extern struct platform_device *of_device_alloc(struct device_node *np,
 					 const char *bus_id,
 					 struct device *parent);
+extern int of_device_init_irq(struct platform_device *dev);
 extern struct platform_device *of_find_device_by_node(struct device_node *np);
 
 #ifdef CONFIG_OF_ADDRESS /* device reg helpers depend on OF_ADDRESS */
@@ -101,6 +102,7 @@ extern int of_platform_populate(struct device_node *root,
 #if !defined(CONFIG_OF_ADDRESS)
 struct of_dev_auxdata;
 struct device;
+struct platform_device;
 static inline int of_platform_populate(struct device_node *root,
 					const struct of_device_id *matches,
 					const struct of_dev_auxdata *lookup,
@@ -108,6 +110,11 @@ static inline int of_platform_populate(struct device_node *root,
 {
 	return -ENODEV;
 }
+
+static inline int of_device_init_irq(struct platform_device *dev)
+{
+	return 0;
+}
 #endif /* !CONFIG_OF_ADDRESS */
 
 #endif	/* _LINUX_OF_PLATFORM_H */
Signature · 1 line
1.7.10.4
Signature · 2 lines
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.
#14 lore raw

Re: [RFC] [PATCH 3/3] IRQ: irq domain: defer of irq ressoure resolve at platform_drv_probe

Quoted 26 lines · Grant Likely
Quoted 10 lines · Jean-Christophe PLAGNIOL-VILLARD

/**
+ * of_device_alloc_irq - initialize irq of an platfrom_device
+ * @dev: plaform_device to work on
+ */

drivers/of/platform.c +5 -0
+int of_device_init_irq(struct platform_device *dev)
+{
+	struct device_node *np = dev->dev.of_node;
+	int num_irq;
+	int ret;

drivers/of/platform.c void of_device_make_bus_id(struct device *dev) · line 151

Quoted 10 lines
drivers/of/platform.c +10 -0
+	struct resource *res = dev->resource;
+
+	if (!np)
+		return 0;
+
+	num_irq = of_irq_count(np);
+	if (!num_irq)
+		return 0;
+
+	res += dev->num_resources - num_irq;

This is a little fragile. Instead of statically calculating the offset, scan the table and make *absolutely* sure that there is a free block of irq resources.

Quoted 7 lines

Also, if the table has already been populated successfully, then that should be checked for. That would prevent the same table from being parsed over and over in the case of a device that keeps getting deferred.

Finally, if it fails, make sure any entries that have been filled in get cleared out again before exiting.

Can we actually ever get a case where mapping a subset of the interrupts fail but works at a later point? If not, we could just return a fatal error here and won't get called again.

Since a platform device only has one "interrupt-parent", as soon as one of the interrupts can get mapped, I would expect that the controller is present, and we don't need to defer the probing any more.

Arnd

A message that is not in the archive (sent off-list or not yet received): [email protected]

#16 lore raw

Re: [RFC] [PATCH 3/3] IRQ: irq domain: defer of irq ressoure resolve at platform_drv_probe

Quoted 35 lines · Arnd Bergmann
Quoted 26 lines · Grant Likely
Quoted 10 lines · Jean-Christophe PLAGNIOL-VILLARD

/**
+ * of_device_alloc_irq - initialize irq of an platfrom_device
+ * @dev: plaform_device to work on
+ */

drivers/of/platform.c +5 -0
+int of_device_init_irq(struct platform_device *dev)
+{
+   struct device_node *np = dev->dev.of_node;
+   int num_irq;
+   int ret;

drivers/of/platform.c void of_device_make_bus_id(struct device *dev) · line 151

Quoted 10 lines
drivers/of/platform.c +10 -0
+   struct resource *res = dev->resource;
+
+   if (!np)
+           return 0;
+
+   num_irq = of_irq_count(np);
+   if (!num_irq)
+           return 0;
+
+   res += dev->num_resources - num_irq;

This is a little fragile. Instead of statically calculating the offset, scan the table and make *absolutely* sure that there is a free block of irq resources.

Quoted 7 lines

Also, if the table has already been populated successfully, then that should be checked for. That would prevent the same table from being parsed over and over in the case of a device that keeps getting deferred.

Finally, if it fails, make sure any entries that have been filled in get cleared out again before exiting.

Quoted 7 lines

Can we actually ever get a case where mapping a subset of the interrupts fail but works at a later point? If not, we could just return a fatal error here and won't get called again.

Since a platform device only has one "interrupt-parent", as soon as one of the interrupts can get mapped, I would expect that the controller is present, and we don't need to defer the probing any more.

If it goes through an interrupt map node then it may only be able to resolve a subset.

g.

#17 lore raw

Re: [RFC] [PATCH 3/3] IRQ: irq domain: defer of irq ressoure resolve at platform_drv_probe

Quoted 8 lines · Grant Likely
Quoted 4 lines · Arnd Bergmann

Since a platform device only has one "interrupt-parent", as soon as one of the interrupts can get mapped, I would expect that the controller is present, and we don't need to defer the probing any more.

If it goes through an interrupt map node then it may only be able to resolve a subset.

Right, so we clearly need it. I also though of a second case, which is that the xlate() function might itself return -EPROBE_DEFER in the case that the irqchip driver is registered but e.g. not the parent of a cascaded irqchip.

Arnd

A message that is not in the archive (sent off-list or not yet received): [email protected]

#19 lore raw

Re: [RFC] [PATCH 3/3] IRQ: irq domain: defer of irq ressoure resolve at platform_drv_probe

Quoted 7 lines · Arnd Bergmann
Quoted 6 lines · Grant Likely
Quoted 4 lines · Arnd Bergmann

Since a platform device only has one "interrupt-parent", as soon as one of the interrupts can get mapped, I would expect that the controller is present, and we don't need to defer the probing any more.

Quoted 7 lines
Quoted 2 lines

If it goes through an interrupt map node then it may only be able to resolve a subset.

Right, so we clearly need it. I also though of a second case, which is that the xlate() function might itself return -EPROBE_DEFER in the case that the irqchip driver is registered but e.g. not the parent of a cascaded irqchip.

That shouldn't happen. If the parent isn't registered, then how can the child set itself up?

g.

A message that is not in the archive (sent off-list or not yet received): CACxGe6vewNv-4AtLeNDkzJnP50StrXtchi3GiKcd2HZG6YMvkA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#21 lore raw

Re: [RFC] [PATCH 3/3] IRQ: irq domain: defer of irq ressoure resolve at platform_drv_probe

Quoted 10 lines · Grant Likely
Quoted 6 lines · Arnd Bergmann

On Thursday 30 May 2013, Grant Likely wrote:

Right, so we clearly need it. I also though of a second case, which is that the xlate() function might itself return -EPROBE_DEFER in the case that the irqchip driver is registered but e.g. not the parent of a cascaded irqchip.

That shouldn't happen. If the parent isn't registered, then how can the child set itself up?

I guess it can just register the domain, but as long as no irqs are needed, it doesn't have to set up a chained handler. I don't think any irqchip driver today does it that way, but I think there is nothing stopping us from doing a driver that does.

Arnd

#22 lore raw

Re: [RFC] [PATCH 3/3] IRQ: irq domain: defer of irq ressoure resolve at platform_drv_probe

In reply to a message not in the archive
Quoted 35 lines · Arnd Bergmann
Quoted 26 lines · Grant Likely
Quoted 10 lines · Jean-Christophe PLAGNIOL-VILLARD

/**
+ * of_device_alloc_irq - initialize irq of an platfrom_device
+ * @dev: plaform_device to work on
+ */

drivers/of/platform.c +5 -0
+int of_device_init_irq(struct platform_device *dev)
+{
+	struct device_node *np = dev->dev.of_node;
+	int num_irq;
+	int ret;

drivers/of/platform.c void of_device_make_bus_id(struct device *dev) · line 151

Quoted 10 lines
drivers/of/platform.c +10 -0
+	struct resource *res = dev->resource;
+
+	if (!np)
+		return 0;
+
+	num_irq = of_irq_count(np);
+	if (!num_irq)
+		return 0;
+
+	res += dev->num_resources - num_irq;

This is a little fragile. Instead of statically calculating the offset, scan the table and make *absolutely* sure that there is a free block of irq resources.

Quoted 7 lines

Also, if the table has already been populated successfully, then that should be checked for. That would prevent the same table from being parsed over and over in the case of a device that keeps getting deferred.

Finally, if it fails, make sure any entries that have been filled in get cleared out again before exiting.

Quoted 7 lines

Can we actually ever get a case where mapping a subset of the interrupts fail but works at a later point? If not, we could just return a fatal error here and won't get called again.

Since a platform device only has one "interrupt-parent", as soon as one of the interrupts can get mapped, I would expect that the controller is present, and we don't need to defer the probing any more.

this is where I disagre we can have 2 interrupt-parent, this is why I get other issue on some devices as you get interrupts from the code controller and then use an irq on a gpio controller so you end up with 2 :(

Assume we can only have one will end-up with issue to descript such hardware

as example I comment some TI patch where we need such configuration

Best Regards,
J.

Quoted 2 lines

Arnd

#23 lore raw

Re: [RFC] [PATCH 3/3] IRQ: irq domain: defer of irq ressoure resolve at platform_drv_probe

In reply to Grant Likely
Quoted 9 lines · Grant Likely
Quoted 7 lines · Jean-Christophe PLAGNIOL-VILLARD

Today in the current of implementation we populate all the ressources at of_platform_populate time. But this leed to a chicken-egg dilemat some the irq present in DT are from platform_device too. And you can not resolve them as of_platform_populate. So delay the populate of irq at platform_drv_probe.

And if the irq_domain is not yet present just defer the probe (GPIO as example)

Quoted 8 lines

Hi Jean-Christophe,

Thanks for looking at this.

Hmmm, this is an interesting idea. I had been thinking about taping into the platform_get_irq() call to lookup irq numbers at probe time, but that assumes that all platform drivers use that call (which they clearly do not). This approach should work for all drivers as is.

Thanks, I try to do not introduce dt or c work around as done in other drivers (mmc_spi & co) as I do not want to handle gpio as irq in ANY drivers and just provide the irq number of the gpio via pdev resource or DT interrupts

while discussing with Arnd on IRC the idea come to do this and that we should do the same for reset and clock by handling it at probe time

Quoted 8 lines

However care needs to be taken to not waste too much time processing irqs every time probe is called. Mapping irqs over and over will get expensive, especially with the current code. It would be better to rework the mapping function to iterate once over the interrupts property and map all the IRQs at once instead of calling of_irq_to_resource() over and over again. (I would however accept the argument that this is a bug fix and the refactoring should be a separate patch)

I'm very concern too by booting time I'll take a look on those issues

Quoted 61 lines
Quoted 61 lines
Cc Grant Likely <grant.likely-s3s/[email protected]>
Cc Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Ralf Baechle <ralf-6z/[email protected]>
Cc Nicolas Ferre <[email protected]>
---
 drivers/base/platform.c     |    5 +++++
 drivers/of/platform.c       |   29 +++++++++++++++++++++++++++--
 include/linux/of_platform.h |    7 +++++++
 3 files changed, 39 insertions(+), 2 deletions(-)
drivers/base/platform.c +5 -0
index 9eda842..c0f7906 100644
@@ -13,6 +13,7 @@
 #include <linux/string.h>
 #include <linux/platform_device.h>
 #include <linux/of_device.h>
+#include <linux/of_platform.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/dma-mapping.h>
@@ -484,6 +485,10 @@ static int platform_drv_probe(struct device *_dev)
 	struct platform_device *dev = to_platform_device(_dev);
 	int ret;
 
+	ret = of_device_init_irq(dev);
+	if (ret)
+		return ret;
+
 	if (ACPI_HANDLE(_dev))
 		acpi_dev_pm_attach(_dev, true);
 
drivers/of/platform.c +14 -0
index 00a0971..c290943 100644
@@ -131,6 +131,32 @@ void of_device_make_bus_id(struct device *dev)
 }
 
 /**
+ * of_device_alloc_irq - initialize irq of an platfrom_device
+ * @dev: plaform_device to work on
+ */
+int of_device_init_irq(struct platform_device *dev)
+{
+	struct device_node *np = dev->dev.of_node;
+	int num_irq;
+	int ret;
+	struct resource *res = dev->resource;
+
+	if (!np)
+		return 0;
+
+	num_irq = of_irq_count(np);
Quoted 8 lines

drivers/of/platform.c void of_device_make_bus_id(struct device *dev) · line 151

Quoted 4 lines
drivers/of/platform.c +4 -0
+	if (!num_irq)
+		return 0;
+
+	res += dev->num_resources - num_irq;

This is a little fragile. Instead of statically calculating the offset, scan the table and make *absolutely* sure that there is a free block of irq resources.

yeah was thinking about it too, but did simple for RFC

Quoted 5 lines

Also, if the table has already been populated successfully, then that should be checked for. That would prevent the same table from being parsed over and over in the case of a device that keeps getting deferred.

can I add a new boolean for this in pdev of device_node?

Quoted 3 lines

Finally, if it fails, make sure any entries that have been filled in get cleared out again before exiting.

ok

Best Regards,
J.

A message that is not in the archive (sent off-list or not yet received): 20130530103639.GD19834-RQcB7r2h9QmfDR2tN2SG5Ni2O/[email protected]

#25 lore raw

Re: [RFC] [PATCH 3/3] IRQ: irq domain: defer of irq ressoure resolve at platform_drv_probe

Quoted 7 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 4 lines · Grant Likely

Also, if the table has already been populated successfully, then that should be checked for. That would prevent the same table from being parsed over and over in the case of a device that keeps getting deferred.

can I add a new boolean for this in pdev of device_node?

Try it out and see what it looks like. It would probably be better to have it as a flag in the platform device itself. Regardless, do it as a follow-on patch so that the functionality can be split from the optimization change. I think the optimization could still require a few iterations.

g.

#26 lore raw

Re: [RFC] [PATCH 3/3] IRQ: irq domain: defer of irq ressoure resolve at platform_drv_probe

In reply to a message not in the archive

Hi!

drivers/of/platform.c void of_device_make_bus_id(struct device *dev) · line 134

Quoted 7 lines · ext Jean-Christophe PLAGNIOL-VILLARD
drivers/of/platform.c +1 -0
@@ -131,6 +131,32 @@ void of_device_make_bus_id(struct device *dev)
 }
 
 /**
+ * of_device_alloc_irq - initialize irq of an platfrom_device
      ^^^^^^^^^^^^^^^^^^^

drivers/of/platform.c void of_device_make_bus_id(struct device *dev) · line 137

Quoted 3 lines
drivers/of/platform.c +3 -0
+ * @dev: plaform_device to work on
+ */
+int of_device_init_irq(struct platform_device *dev)
       ^^^^^^^^^^^^^^^^^^

I think, mismatch in function names in the comment and function itself wasn't yet reported...

Quoted 15 lines
drivers/of/platform.c +15 -0
+{
+	struct device_node *np = dev->dev.of_node;
+	int num_irq;
+	int ret;
+	struct resource *res = dev->resource;
+
+	if (!np)
+		return 0;
+
+	num_irq = of_irq_count(np);
+	if (!num_irq)
+		return 0;
+
+	res += dev->num_resources - num_irq;
+	ret = of_irq_to_resource_table(np, res, num_irq);

drivers/of/platform.c void of_device_make_bus_id(struct device *dev) · line 162

Quoted 10 lines
drivers/of/platform.c +7 -0
+	if (ret != num_irq)
+		return -EPROBE_DEFER;
+
+	return 0;
+}
+
+/**
  * of_device_alloc - Allocate and initialize an of_device
  * @np: device node to assign to device
  * @bus_id: Name to assign to the device.  May be null to use default name.

I was trying to get attention to this problem already on the list in January-February time frame, but without success... I will give your code a try... We have exactly these chained interrupt controllers dependencies and irq_create_of_mapping() was failing... I'll inform you on the test results...

Signature · 2 lines
Best regards,
Alexander Sverdlin.
#27 lore raw

Re: [RFC] [PATCH 3/3] IRQ: irq domain: defer of irq ressoure resolve at platform_drv_probe

In reply to a message not in the archive

Hi!

Quoted 9 lines · ext Jean-Christophe PLAGNIOL-VILLARD

Today in the current of implementation we populate all the ressources at of_platform_populate time. But this leed to a chicken-egg dilemat some the irq present in DT are from platform_device too. And you can not resolve them as of_platform_populate. So delay the populate of irq at platform_drv_probe.

And if the irq_domain is not yet present just defer the probe (GPIO as example)

Tested the whole series. This is definitely a necessary feature.
I've tested it on MIPS64 system with merge-able device-subtrees.
If you would come with the new patch series, please put me on CC, I'll test it again.

Quoted 12 lines
Cc Grant Likely <grant.likely-s3s/[email protected]>
Cc Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Ralf Baechle <ralf-6z/[email protected]>
Cc Nicolas Ferre <[email protected]>
---
 drivers/base/platform.c     |    5 +++++
 drivers/of/platform.c       |   29 +++++++++++++++++++++++++++--
 include/linux/of_platform.h |    7 +++++++
 3 files changed, 39 insertions(+), 2 deletions(-)

...

Signature · 2 lines
Best regards,
Alexander Sverdlin.
#28 lore raw

Re: [RFC] [PATCH 1/3] of: irq: rename of_irq_count to of_irq_valid_count

In reply to a message not in the archive
Quoted 3 lines · Jean-Christophe PLAGNIOL-VILLARD

as we count valid mapped irq not just present irq

Hmmm, even with it being in-accurately named, I think it is dangerous to rename the existing function and re-use the old name. Anyone with out-of-tree code will get the behaviour changed under their feet. I think it would be better to drop this patch from the series.

g.

#29 lore raw

Re: [RFC] [PATCH 1/3] of: irq: rename of_irq_count to of_irq_valid_count

Quoted 9 lines · Grant Likely
Quoted 3 lines · Jean-Christophe PLAGNIOL-VILLARD

as we count valid mapped irq not just present irq

Hmmm, even with it being in-accurately named, I think it is dangerous to rename the existing function and re-use the old name. Anyone with out-of-tree code will get the behaviour changed under their feet. I think it would be better to drop this patch from the series.

after think I known this can be consider as noisy change but I think we could rename it anyway to make it more clear and use a different name as you propose for the counting irq in PATCH 2/3

Best Regards,
J.

#30 lore raw
In reply to a message not in the archive
Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD

Today in the current of implementation we populate all the ressources at of_platform_populate time. But this leed to a chicken-egg dilemat some the irq present in DT are from platform_device too. And you can not resolve them as of_platform_populate. So delay the populate of irq at platform_drv_probe.

I like it a lot, thanks for doing this!

Obviously this needs to be tested well on all architectures, but I think it's the right solution for the problem. I was originally thinking we'd just allocated the resources dynamically using devm_kmalloc in platform_drv_probe, but your solution to preallocate them at boot time seems nicer.

I believe we still need the same patch for the amba bus, and possibly a couple more, but platform_bus covers most of the interesting cases.

Arnd

A message that is not in the archive (sent off-list or not yet received): [email protected]

#32 lore raw
Quoted 11 lines · Arnd Bergmann
Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD

Today in the current of implementation we populate all the ressources at of_platform_populate time. But this leed to a chicken-egg dilemat some the irq present in DT are from platform_device too. And you can not resolve them as of_platform_populate. So delay the populate of irq at platform_drv_probe.

I like it a lot, thanks for doing this!

Obviously this needs to be tested well on all architectures, but I think it's the right solution for the problem.

I've tested it today on a ARM at91sam9n12ek using a gpio as irq connected to a ks8851-ml

Quoted 4 lines

I was originally thinking we'd
just allocated the resources dynamically using devm_kmalloc in platform_drv_probe, but your solution to preallocate them at boot time seems nicer.

yes I should have put a comment in the patch 3/3
as the device tree is a fixed data, preallocate them at boot t time save the kalloc kree everytime you probe the device and the irq_domain is not yet present

Quoted 3 lines

I believe we still need the same patch for the amba bus, and possibly a couple more, but platform_bus covers most of the interesting cases.

yes exactly

Best Regards,
J.

Quoted 2 lines

Arnd