Skip to contentSkip to conversation

irqdomain: clean up, add irq_domain_create_legacy()

PATCH Applied Andy Shevchenko 3 participants 12 messages Oct 30, 2020 – Nov 7, 2020

Subsystems (6)
Documentation ACPI Driver core IRQ +2 more subsystems
lore
Share & tools
lore
#0 lore raw

v2 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.

Rafael, can you have a look at this series?

Changelog v2:
- rebased on top of v5.10-rc1
- dependency-free (they are in v5.10-rc1)
- added Ack (Mark)

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.28.0
#1 lore raw

PATCH v2 1/5 irqdomain: Remove unused of_device_id forward declaration

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 71535e87109f..56642188ec21 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.28.0
#2 lore raw

[tip: irq/core] irqdomain: Remove unused of_device_id forward declaration

The following commit has been merged into the irq/core branch of tip:

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     eda2845ae5e0ae466c1aca715d642b4977311747
Gitweb:        https://git.kernel.org/tip/eda2845ae5e0ae466c1aca715d642b4977311747
Author:        Andy Shevchenko <[email protected]>
AuthorDate:    Fri, 30 Oct 2020 18:59:15 +02:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Sat, 07 Nov 2020 11:33:45 +01:00

irqdomain: Remove unused of_device_id forward declaration

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 71535e8..5664218 100644
@@ -38,7 +38,6 @@
 
 struct device_node;
 struct irq_domain;
-struct of_device_id;
 struct irq_chip;
 struct irq_data;
 struct cpumask;
#3 lore raw

PATCH v2 2/5 irqdomain: Add forward declaration of fwnode_handle

In reply to Andy Shevchenko

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 56642188ec21..d21f75d294d7 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.28.0
#4 lore raw

[tip: irq/core] irqdomain: Add forward declaration of fwnode_handle

The following commit has been merged into the irq/core branch of tip:

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     08219fb1efae451c83281cb6ba4bb6c35ac88fab
Gitweb:        https://git.kernel.org/tip/08219fb1efae451c83281cb6ba4bb6c35ac88fab
Author:        Andy Shevchenko <[email protected]>
AuthorDate:    Fri, 30 Oct 2020 18:59:16 +02:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Sat, 07 Nov 2020 11:33:45 +01:00

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 5664218..d21f75d 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;
#5 lore raw

PATCH v2 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 cf8b374b892d..831526f2e728 100644
@@ -737,7 +737,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.28.0
#6 lore raw

[tip: irq/core] irqdomain: Replace open coded of_node_to_fwnode()

The following commit has been merged into the irq/core branch of tip:

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     c3a877fea962d9d0fb1e3747334699978f566930
Gitweb:        https://git.kernel.org/tip/c3a877fea962d9d0fb1e3747334699978f566930
Author:        Andy Shevchenko <[email protected]>
AuthorDate:    Fri, 30 Oct 2020 18:59:17 +02:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Sat, 07 Nov 2020 11:33:45 +01:00

irqdomain: Replace open coded of_node_to_fwnode()

of_node_to_fwnode() should be used for conversion. Replace the 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 cf8b374..831526f 100644
@@ -737,7 +737,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++)
#7 lore raw

PATCH v2 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 d21f75d294d7..77bf7d84c673 100644
@@ -271,6 +271,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 831526f2e728..9c9cb8829f7a 100644
@@ -350,17 +350,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.28.0
#8 lore raw

[tip: irq/core] irqdomain: Introduce irq_domain_create_legacy() API

The following commit has been merged into the irq/core branch of tip:

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     b6e95788fde8c9bc9da729102085dd36a5a0cda6
Gitweb:        https://git.kernel.org/tip/b6e95788fde8c9bc9da729102085dd36a5a0cda6
Author:        Andy Shevchenko <[email protected]>
AuthorDate:    Fri, 30 Oct 2020 18:59:18 +02:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Sat, 07 Nov 2020 11:33:46 +01:00

irqdomain: Introduce irq_domain_create_legacy() API

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.

This is useful for non OF systems.

---
 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 096db12..a77c24c 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 d21f75d..77bf7d8 100644
@@ -271,6 +271,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 831526f..9c9cb88 100644
@@ -351,16 +351,27 @@ struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
 					 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
#9 lore raw

PATCH v2 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 ad5c2de395d1..19db764ffa4a 100644
@@ -803,13 +803,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.28.0
#10 lore raw

[tip: irq/core] regmap: irq: Convert to use irq_domain_create_legacy()

The following commit has been merged into the irq/core branch of tip:

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     d315c627a18249930750fe4eb2b21f3fe9b32ea4
Gitweb:        https://git.kernel.org/tip/d315c627a18249930750fe4eb2b21f3fe9b32ea4
Author:        Andy Shevchenko <[email protected]>
AuthorDate:    Fri, 30 Oct 2020 18:59:19 +02:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Sat, 07 Nov 2020 11:33:46 +01:00

regmap: irq: Convert to use irq_domain_create_legacy()

irq_domain_create_legacy() takes a fwnode as parameter contrary to irq_domain_add_legacy() which requires a OF node.

Switch the regmap irq domain creation to use that new function so it is not longer limited to OF based usage.

---
 drivers/base/regmap/regmap-irq.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/base/regmap/regmap-irq.c +5 -6
index ad5c2de..19db764 100644
@@ -803,13 +803,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;
maintainer Reviewed-by on the v2 series
#11 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.

Rafael, can you have a look at this series?

Done.

Feel free to add

to all of the patches in it.

Thanks!

Quoted 21 lines

Changelog v2:
- rebased on top of v5.10-rc1
- dependency-free (they are in v5.10-rc1)
- added Ack (Mark)

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(-)

--
2.28.0