Skip to contentSkip to conversation

irqdomain: clean up, add irq_domain_create_legacy()

PATCH Superseded Andy Shevchenko 2 participants 10 messages Jul 8, 2020 – Sep 16, 2020

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover irqdomain: clean up, add irq_domain_create_legacy()

In order to make users OF independent provide irq_domain_create_legacy() API. Last patch is an example of such user. First three patches are little cleanups.

Since regmap patch is dependent to what is now in regmap tree, I suggest to create an immutable branch in IRQ domain tree and Mark can pull it and apply the last one.

Andy Shevchenko (5):
irqdomain: Remove unused of_device_id forward declaration
irqdomain: Add forward declaration of fwnode_handle
irqdomain: Replace open coded of_node_to_fwnode()
irqdomain: Introduce irq_domain_create_legacy() API
regmap: irq: Convert to use fwnode directly

 Documentation/core-api/irq/irq-domain.rst |  6 ++++++
 drivers/base/regmap/regmap-irq.c          | 11 +++++------
 include/linux/irqdomain.h                 |  8 +++++++-
 kernel/irq/irqdomain.c                    | 19 +++++++++++++++----
 4 files changed, 33 insertions(+), 11 deletions(-)
Signature · 1 line
2.27.0
#2 lore raw

PATCH 2/5 irqdomain: Add forward declaration of fwnode_handle

irqdomain.h is a user of struct fwnode_handle. Add forward declaration of it.

---
 include/linux/irqdomain.h | 1 +
 1 file changed, 1 insertion(+)
include/linux/irqdomain.h +1 -0
index ad6d2335e980..39bb0c13ac07 100644
@@ -37,6 +37,7 @@
 #include <linux/radix-tree.h>
 
 struct device_node;
+struct fwnode_handle;
 struct irq_domain;
 struct irq_chip;
 struct irq_data;
Signature · 1 line
2.27.0
#5 lore raw

PATCH 5/5 regmap: irq: Convert to use fwnode directly

In reply to Andy Shevchenko

Since IRQ domain provides an API to take fwnode as a parameter, switch regmap IRQ to use that directly instead of be limited to OF case only.

---
 drivers/base/regmap/regmap-irq.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/base/regmap/regmap-irq.c +5 -6
index 369a57e6f89d..2ecdfdbdfc71 100644
@@ -772,13 +772,12 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 	}
 
 	if (irq_base)
-		d->domain = irq_domain_add_legacy(to_of_node(fwnode),
-						  chip->num_irqs, irq_base,
-						  0, &regmap_domain_ops, d);
+		d->domain = irq_domain_create_legacy(fwnode, chip->num_irqs,
+						     irq_base, 0,
+						     &regmap_domain_ops, d);
 	else
-		d->domain = irq_domain_add_linear(to_of_node(fwnode),
-						  chip->num_irqs,
-						  &regmap_domain_ops, d);
+		d->domain = irq_domain_create_linear(fwnode, chip->num_irqs,
+						     &regmap_domain_ops, d);
 	if (!d->domain) {
 		dev_err(map->dev, "Failed to create IRQ domain\n");
 		ret = -ENOMEM;
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/5 irqdomain: Remove unused of_device_id forward declaration

In reply to Andy Shevchenko

There is no users of of_device_id in irqdomain.h. Drop it.

---
 include/linux/irqdomain.h | 1 -
 1 file changed, 1 deletion(-)
include/linux/irqdomain.h +0 -1
index b37350c4fe37..ad6d2335e980 100644
@@ -38,7 +38,6 @@
 
 struct device_node;
 struct irq_domain;
-struct of_device_id;
 struct irq_chip;
 struct irq_data;
 struct cpumask;
Signature · 1 line
2.27.0
#4 lore raw

PATCH 4/5 irqdomain: Introduce irq_domain_create_legacy() API

In reply to Andy Shevchenko

Introduce irq_domain_create_legacy() API which is functional equivalent to the existing irq_domain_add_legacy(), but takes a pointer to the struct fwnode_handle as a parameter.

Some users want to use it in non-OF cases.

---
 Documentation/core-api/irq/irq-domain.rst |  6 ++++++
 include/linux/irqdomain.h                 |  6 ++++++
 kernel/irq/irqdomain.c                    | 17 ++++++++++++++---
 3 files changed, 26 insertions(+), 3 deletions(-)
Documentation/core-api/irq/irq-domain.rst +6 -0
index 096db12f32d5..a77c24c27f7b 100644
@@ -147,6 +147,7 @@ Legacy
 	irq_domain_add_simple()
 	irq_domain_add_legacy()
 	irq_domain_add_legacy_isa()
+	irq_domain_create_legacy()
 
 The Legacy mapping is a special case for drivers that already have a
 range of irq_descs allocated for the hwirqs.  It is used when the
@@ -185,6 +186,11 @@ that the driver using the simple domain call irq_create_mapping()
 before any irq_find_mapping() since the latter will actually work
 for the static IRQ assignment case.
 
+irq_domain_add_legacy() and irq_domain_create_legacy() are functionally
+equivalent, except for the first argument is different - the former
+accepts an Open Firmware specific 'struct device_node', while the latter
+accepts a more general abstraction 'struct fwnode_handle'.
+
 Hierarchy IRQ domain
 --------------------
 
include/linux/irqdomain.h +6 -0
index 39bb0c13ac07..529719f4a034 100644
@@ -270,6 +270,12 @@ struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
 					 irq_hw_number_t first_hwirq,
 					 const struct irq_domain_ops *ops,
 					 void *host_data);
+struct irq_domain *irq_domain_create_legacy(struct fwnode_handle *fwnode,
+					    unsigned int size,
+					    unsigned int first_irq,
+					    irq_hw_number_t first_hwirq,
+					    const struct irq_domain_ops *ops,
+					    void *host_data);
 extern struct irq_domain *irq_find_matching_fwspec(struct irq_fwspec *fwspec,
 						   enum irq_domain_bus_token bus_token);
 extern bool irq_domain_check_msi_remap(void);
kernel/irq/irqdomain.c +14 -3
index d7a762cce8e9..04936a3eb34e 100644
@@ -349,17 +349,28 @@ struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
 					 irq_hw_number_t first_hwirq,
 					 const struct irq_domain_ops *ops,
 					 void *host_data)
+{
+	return irq_domain_create_legacy(of_node_to_fwnode(of_node), size,
+					first_irq, first_hwirq, ops, host_data);
+}
+EXPORT_SYMBOL_GPL(irq_domain_add_legacy);
+
+struct irq_domain *irq_domain_create_legacy(struct fwnode_handle *fwnode,
+					 unsigned int size,
+					 unsigned int first_irq,
+					 irq_hw_number_t first_hwirq,
+					 const struct irq_domain_ops *ops,
+					 void *host_data)
 {
 	struct irq_domain *domain;
 
-	domain = __irq_domain_add(of_node_to_fwnode(of_node), first_hwirq + size,
-				  first_hwirq + size, 0, ops, host_data);
+	domain = __irq_domain_add(fwnode, first_hwirq + size, first_hwirq + size, 0, ops, host_data);
 	if (domain)
 		irq_domain_associate_many(domain, first_irq, first_hwirq, size);
 
 	return domain;
 }
-EXPORT_SYMBOL_GPL(irq_domain_add_legacy);
+EXPORT_SYMBOL_GPL(irq_domain_create_legacy);
 
 /**
  * irq_find_matching_fwspec() - Locates a domain for a given fwspec
Signature · 1 line
2.27.0
#3 lore raw

PATCH 3/5 irqdomain: Replace open coded of_node_to_fwnode()

In reply to Andy Shevchenko

We can convert device node to fwnode with of_node_to_fwnode(). Replace open coded variant of it in of_phandle_args_to_fwspec().

---
 kernel/irq/irqdomain.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/irq/irqdomain.c +1 -1
index a4c2c915511d..d7a762cce8e9 100644
@@ -736,7 +736,7 @@ static void of_phandle_args_to_fwspec(struct device_node *np, const u32 *args,
 {
 	int i;
 
-	fwspec->fwnode = np ? &np->fwnode : NULL;
+	fwspec->fwnode = of_node_to_fwnode(np);
 	fwspec->param_count = count;
 
 	for (i = 0; i < count; i++)
Signature · 1 line
2.27.0
#7 lore raw
In reply to Andy Shevchenko
Quoted 6 lines · Andy Shevchenko

In order to make users OF independent provide irq_domain_create_legacy() API. Last patch is an example of such user. First three patches are little cleanups.

Since regmap patch is dependent to what is now in regmap tree, I suggest to create an immutable branch in IRQ domain tree and Mark can pull it and apply the last one.

Marc, are you okay with the IRQ domain patches?

Quoted 16 lines

Andy Shevchenko (5):
irqdomain: Remove unused of_device_id forward declaration
irqdomain: Add forward declaration of fwnode_handle
irqdomain: Replace open coded of_node_to_fwnode()
irqdomain: Introduce irq_domain_create_legacy() API
regmap: irq: Convert to use fwnode directly

 Documentation/core-api/irq/irq-domain.rst |  6 ++++++
 drivers/base/regmap/regmap-irq.c          | 11 +++++------
 include/linux/irqdomain.h                 |  8 +++++++-
 kernel/irq/irqdomain.c                    | 19 +++++++++++++++----
 4 files changed, 33 insertions(+), 11 deletions(-)
Signature · 1 line
2.27.0
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#8 lore raw
Quoted 9 lines · Andy Shevchenko
Quoted 6 lines · Andy Shevchenko

In order to make users OF independent provide irq_domain_create_legacy() API. Last patch is an example of such user. First three patches are little cleanups.

Since regmap patch is dependent to what is now in regmap tree, I suggest to create an immutable branch in IRQ domain tree and Mark can pull it and apply the last one.

Marc, are you okay with the IRQ domain patches?

Marc, should I resend this? All dependencies are now resolved.

Quoted 12 lines
Quoted 12 lines

Andy Shevchenko (5):
irqdomain: Remove unused of_device_id forward declaration
irqdomain: Add forward declaration of fwnode_handle
irqdomain: Replace open coded of_node_to_fwnode()
irqdomain: Introduce irq_domain_create_legacy() API
regmap: irq: Convert to use fwnode directly

 Documentation/core-api/irq/irq-domain.rst |  6 ++++++
 drivers/base/regmap/regmap-irq.c          | 11 +++++------
 include/linux/irqdomain.h                 |  8 +++++++-
 kernel/irq/irqdomain.c                    | 19 +++++++++++++++----
 4 files changed, 33 insertions(+), 11 deletions(-)
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#9 lore raw
In reply to Andy Shevchenko
Quoted 6 lines · Andy Shevchenko

In order to make users OF independent provide irq_domain_create_legacy() API. Last patch is an example of such user. First three patches are little cleanups.

Since regmap patch is dependent to what is now in regmap tree, I suggest to create an immutable branch in IRQ domain tree and Mark can pull it and apply the last one.

Rafael, can you review this? It seems stuck supposedly b/c of no review tag given.

Quoted 16 lines

Andy Shevchenko (5):
irqdomain: Remove unused of_device_id forward declaration
irqdomain: Add forward declaration of fwnode_handle
irqdomain: Replace open coded of_node_to_fwnode()
irqdomain: Introduce irq_domain_create_legacy() API
regmap: irq: Convert to use fwnode directly

 Documentation/core-api/irq/irq-domain.rst |  6 ++++++
 drivers/base/regmap/regmap-irq.c          | 11 +++++------
 include/linux/irqdomain.h                 |  8 +++++++-
 kernel/irq/irqdomain.c                    | 19 +++++++++++++++----
 4 files changed, 33 insertions(+), 11 deletions(-)
Signature · 1 line
2.27.0
Signature · 2 lines
With Best Regards,
Andy Shevchenko