linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] irqdomain: Allow ACPI device nodes to be used as irqdomain identifiers
@ 2017-07-07  8:39 Marc Zyngier
  2017-07-07  9:25 ` John Garry
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Marc Zyngier @ 2017-07-07  8:39 UTC (permalink / raw)
  To: linux-kernel
  Cc: Thomas Gleixner, Hanjun Guo, Agustin Vega-Frias, Ma Jun, John Garry

A number of irqchip implementations are (ab)using the irqdomain
allocator by passing a fwnode that is neither a FWNODE_OF or
a FWNODE_IRQCHIP.

This is pretty bad, but it also feels pretty crap to force these
drivers to allocate their own irqchip_fwid when they already have
a proper fwnode.

Instead, let's teach the irqdomain allocator about ACPI device
nodes, and add some lovely name generation code... Tested on
an arm64 D05 system.

Reported-by: John Garry <john.garry@huawei.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 kernel/irq/irqdomain.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 14fe862aa2e3..71ed8a849345 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -1,5 +1,6 @@
 #define pr_fmt(fmt)  "irq: " fmt
 
+#include <linux/acpi.h>
 #include <linux/debugfs.h>
 #include <linux/hardirq.h>
 #include <linux/interrupt.h>
@@ -155,6 +156,21 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size,
 			domain->name = fwid->name;
 			break;
 		}
+#ifdef CONFIG_ACPI
+	} else if (is_acpi_device_node(fwnode)) {
+		struct acpi_buffer buf = {
+			.length = ACPI_ALLOCATE_BUFFER,
+		};
+		acpi_handle handle;
+
+		handle = acpi_device_handle(to_acpi_device_node(fwnode));
+		if (acpi_get_name(handle, ACPI_FULL_PATHNAME, &buf) == AE_OK) {
+			domain->name = buf.pointer;
+			domain->flags |= IRQ_DOMAIN_NAME_ALLOCATED;
+		}
+
+		domain->fwnode = fwnode;
+#endif
 	} else if (of_node) {
 		char *name;
 
-- 
2.11.0

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

* Re: [PATCH] irqdomain: Allow ACPI device nodes to be used as irqdomain identifiers
  2017-07-07  8:39 [PATCH] irqdomain: Allow ACPI device nodes to be used as irqdomain identifiers Marc Zyngier
@ 2017-07-07  9:25 ` John Garry
  2017-07-07 10:16 ` [tip:irq/urgent] " tip-bot for Marc Zyngier
  2017-07-07 11:49 ` [PATCH] " Hanjun Guo
  2 siblings, 0 replies; 4+ messages in thread
From: John Garry @ 2017-07-07  9:25 UTC (permalink / raw)
  To: Marc Zyngier, linux-kernel
  Cc: Thomas Gleixner, Hanjun Guo, Agustin Vega-Frias, Ma Jun, Linuxarm

On 07/07/2017 09:39, Marc Zyngier wrote:
> A number of irqchip implementations are (ab)using the irqdomain
> allocator by passing a fwnode that is neither a FWNODE_OF or
> a FWNODE_IRQCHIP.
>
> This is pretty bad, but it also feels pretty crap to force these
> drivers to allocate their own irqchip_fwid when they already have
> a proper fwnode.
>
> Instead, let's teach the irqdomain allocator about ACPI device
> nodes, and add some lovely name generation code... Tested on
> an arm64 D05 system.
>

Thanks

FWIW, since I reported the issue:
Tested-by: John Garry <john.garry@huawei.com>

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

* [tip:irq/urgent] irqdomain: Allow ACPI device nodes to be used as irqdomain identifiers
  2017-07-07  8:39 [PATCH] irqdomain: Allow ACPI device nodes to be used as irqdomain identifiers Marc Zyngier
  2017-07-07  9:25 ` John Garry
@ 2017-07-07 10:16 ` tip-bot for Marc Zyngier
  2017-07-07 11:49 ` [PATCH] " Hanjun Guo
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Marc Zyngier @ 2017-07-07 10:16 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: majun258, john.garry, hpa, hanjun.guo, linux-kernel, tglx,
	agustinv, mingo, marc.zyngier

Commit-ID:  c5c601c4295f89368f4a304cb3ae4aebdf80db22
Gitweb:     http://git.kernel.org/tip/c5c601c4295f89368f4a304cb3ae4aebdf80db22
Author:     Marc Zyngier <marc.zyngier@arm.com>
AuthorDate: Fri, 7 Jul 2017 09:39:59 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 7 Jul 2017 12:13:29 +0200

irqdomain: Allow ACPI device nodes to be used as irqdomain identifiers

A number of irqchip implementations are (ab)using the irqdomain allocator
by passing a fwnode that is neither a FWNODE_OF or a FWNODE_IRQCHIP.

This is pretty bad, but it also feels pretty crap to force these drivers to
allocate their own irqchip_fwid when they already have a proper fwnode.

Instead, let's teach the irqdomain allocator about ACPI device nodes, and
add some lovely name generation code... Tested on an arm64 D05 system.

Reported-and-tested-by: John Garry <john.garry@huawei.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Agustin Vega-Frias <agustinv@codeaurora.org>
Cc: Ma Jun <majun258@huawei.com>
Cc: Hanjun Guo <hanjun.guo@linaro.org>
Link: http://lkml.kernel.org/r/20170707083959.10349-1-marc.zyngier@arm.com

---
 kernel/irq/irqdomain.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index ed47688..f1f2514 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -1,5 +1,6 @@
 #define pr_fmt(fmt)  "irq: " fmt
 
+#include <linux/acpi.h>
 #include <linux/debugfs.h>
 #include <linux/hardirq.h>
 #include <linux/interrupt.h>
@@ -155,6 +156,21 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size,
 			domain->name = fwid->name;
 			break;
 		}
+#ifdef CONFIG_ACPI
+	} else if (is_acpi_device_node(fwnode)) {
+		struct acpi_buffer buf = {
+			.length = ACPI_ALLOCATE_BUFFER,
+		};
+		acpi_handle handle;
+
+		handle = acpi_device_handle(to_acpi_device_node(fwnode));
+		if (acpi_get_name(handle, ACPI_FULL_PATHNAME, &buf) == AE_OK) {
+			domain->name = buf.pointer;
+			domain->flags |= IRQ_DOMAIN_NAME_ALLOCATED;
+		}
+
+		domain->fwnode = fwnode;
+#endif
 	} else if (of_node) {
 		char *name;
 

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

* Re: [PATCH] irqdomain: Allow ACPI device nodes to be used as irqdomain identifiers
  2017-07-07  8:39 [PATCH] irqdomain: Allow ACPI device nodes to be used as irqdomain identifiers Marc Zyngier
  2017-07-07  9:25 ` John Garry
  2017-07-07 10:16 ` [tip:irq/urgent] " tip-bot for Marc Zyngier
@ 2017-07-07 11:49 ` Hanjun Guo
  2 siblings, 0 replies; 4+ messages in thread
From: Hanjun Guo @ 2017-07-07 11:49 UTC (permalink / raw)
  To: Marc Zyngier, linux-kernel
  Cc: Thomas Gleixner, Hanjun Guo, Agustin Vega-Frias, Ma Jun, John Garry

On 2017/7/7 16:39, Marc Zyngier wrote:
> A number of irqchip implementations are (ab)using the irqdomain
> allocator by passing a fwnode that is neither a FWNODE_OF or
> a FWNODE_IRQCHIP.
>
> This is pretty bad, but it also feels pretty crap to force these
> drivers to allocate their own irqchip_fwid when they already have
> a proper fwnode.
>
> Instead, let's teach the irqdomain allocator about ACPI device
> nodes, and add some lovely name generation code... Tested on
> an arm64 D05 system.
>
> Reported-by: John Garry <john.garry@huawei.com>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> ---
>  kernel/irq/irqdomain.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)

Thomas already queued this patch, but I did a test on D03
and it works.

Thanks
Hanjun

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

end of thread, other threads:[~2017-07-07 11:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-07  8:39 [PATCH] irqdomain: Allow ACPI device nodes to be used as irqdomain identifiers Marc Zyngier
2017-07-07  9:25 ` John Garry
2017-07-07 10:16 ` [tip:irq/urgent] " tip-bot for Marc Zyngier
2017-07-07 11:49 ` [PATCH] " Hanjun Guo

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