linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Stacked domains and MSI improvements
@ 2014-11-15 10:49 Marc Zyngier
  2014-11-15 10:49 ` [PATCH 1/2] PCI/MSI: Allow an msi_chip to be associated to an irq domain Marc Zyngier
  2014-11-15 10:49 ` [PATCH 2/2] genirq: Work around __irq_set_handler vs stacked domains ordering issues Marc Zyngier
  0 siblings, 2 replies; 5+ messages in thread
From: Marc Zyngier @ 2014-11-15 10:49 UTC (permalink / raw)
  To: Thomas Gleixner, Jiang Liu
  Cc: Yingjoe Chen, Bjorn Helgaas, linux-kernel, linux-arm-kernel

This short series builds upon Jiang Liu's MSI stacked domain and tries
to clean up a couple of points:

- Patch 1 allows an msi_chip to carry a pointer to its irq domain.
  When populated by the MSI driver, this allow the PCI bus to be
  associated with an irq domain, removing most of the need for arch
  specific code in the case of multiple PCI busses.

- Patch 2 tries to work around a limitation of __irq_set_handler when
  called with an interrupt belongging to a stacked domain.

This has been tested on arm64, together with the GICv3 ITS.

Marc Zyngier (2):
  PCI/MSI: Allow an msi_chip to be associated to an irq domain
  genirq: Work around __irq_set_handler vs stacked domains ordering
    issues

 drivers/pci/msi.c   | 16 +++++++++++++++-
 include/linux/msi.h |  3 +++
 kernel/irq/chip.c   | 11 ++++++++++-
 3 files changed, 28 insertions(+), 2 deletions(-)

-- 
2.1.0


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

* [PATCH 1/2] PCI/MSI: Allow an msi_chip to be associated to an irq domain
  2014-11-15 10:49 [PATCH 0/2] Stacked domains and MSI improvements Marc Zyngier
@ 2014-11-15 10:49 ` Marc Zyngier
  2014-11-23 18:14   ` [tip:irq/irqdomain] PCI/MSI: Allow an msi_controller " tip-bot for Marc Zyngier
  2014-11-15 10:49 ` [PATCH 2/2] genirq: Work around __irq_set_handler vs stacked domains ordering issues Marc Zyngier
  1 sibling, 1 reply; 5+ messages in thread
From: Marc Zyngier @ 2014-11-15 10:49 UTC (permalink / raw)
  To: Thomas Gleixner, Jiang Liu
  Cc: Yingjoe Chen, Bjorn Helgaas, linux-kernel, linux-arm-kernel

With the new stacked irq domains, it becomes pretty tempting
to allocate an MSI domain per PCI bus, which would remove
the requirement of either relying on arch-specific code, or
a default PCI MSI domain.

By allowing the msi_chip structure to carry a pointer to
an irq_domain, we can easily use this in pci_msi_setup_msi_irqs.
The existing code can still be used as a fallback if the MSI driver
does not populate the domain field.

Tested on arm64 with the GICv3 ITS driver.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 drivers/pci/msi.c   | 16 +++++++++++++++-
 include/linux/msi.h |  3 +++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index af66b95..aa3b720 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -84,11 +84,25 @@ int __weak arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
 	return 0;
 }
 
+static struct irq_domain *pci_msi_get_domain(struct pci_dev *dev)
+{
+	struct irq_domain *domain = NULL;
+
+#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
+	if (dev->bus->msi)
+		domain = dev->bus->msi->domain;
+#endif
+	if (!domain)
+		domain = arch_get_pci_msi_domain(dev);
+
+	return domain;
+}
+
 static int pci_msi_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
 {
 	struct irq_domain *domain;
 
-	domain = arch_get_pci_msi_domain(dev);
+	domain = pci_msi_get_domain(dev);
 	if (domain)
 		return pci_msi_domain_alloc_irqs(domain, type, dev);
 
diff --git a/include/linux/msi.h b/include/linux/msi.h
index 8b4a69b..a8d309a 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -89,6 +89,9 @@ struct msi_chip {
 	struct device *dev;
 	struct device_node *of_node;
 	struct list_head list;
+#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
+	struct irq_domain *domain;
+#endif
 
 	int (*setup_irq)(struct msi_chip *chip, struct pci_dev *dev,
 			 struct msi_desc *desc);
-- 
2.1.0


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

* [PATCH 2/2] genirq: Work around __irq_set_handler vs stacked domains ordering issues
  2014-11-15 10:49 [PATCH 0/2] Stacked domains and MSI improvements Marc Zyngier
  2014-11-15 10:49 ` [PATCH 1/2] PCI/MSI: Allow an msi_chip to be associated to an irq domain Marc Zyngier
@ 2014-11-15 10:49 ` Marc Zyngier
  2014-11-23 18:11   ` [tip:irq/irqdomain] " tip-bot for Marc Zyngier
  1 sibling, 1 reply; 5+ messages in thread
From: Marc Zyngier @ 2014-11-15 10:49 UTC (permalink / raw)
  To: Thomas Gleixner, Jiang Liu
  Cc: Yingjoe Chen, Bjorn Helgaas, linux-kernel, linux-arm-kernel

With the introduction of stacked domains, we have the issue that,
depending on where in the stack this is called, __irq_set_handler
will succeed or fail: If this is called from the inner irqchip,
__irq_set_handler() will fail, as it will look at the outer domain
as the (desc->irq_data.chip == &no_irq_chip) test fails (we haven't
set the top level yet).

This patch implements the following: "If there is at least one
valid irqchip in the domain, it will probably sort itself out".
This is clearly not ideal, but it is far less confusing then
crashing because the top-level domain is not up yet.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 kernel/irq/chip.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index d028b34..cad4f62 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -731,7 +731,16 @@ __irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
 	if (!handle) {
 		handle = handle_bad_irq;
 	} else {
-		if (WARN_ON(desc->irq_data.chip == &no_irq_chip))
+		struct irq_data *irq_data = &desc->irq_data;
+#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
+		while (irq_data) {
+			if (irq_data->chip != &no_irq_chip)
+				break;
+			irq_data = irq_data->parent_data;
+		}
+#endif
+
+		if (WARN_ON(!irq_data || irq_data->chip == &no_irq_chip))
 			goto out;
 	}
 
-- 
2.1.0


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

* [tip:irq/irqdomain] genirq: Work around __irq_set_handler vs stacked domains ordering issues
  2014-11-15 10:49 ` [PATCH 2/2] genirq: Work around __irq_set_handler vs stacked domains ordering issues Marc Zyngier
@ 2014-11-23 18:11   ` tip-bot for Marc Zyngier
  0 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Marc Zyngier @ 2014-11-23 18:11 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, mingo, bhelgaas, jiang.liu, tglx, marc.zyngier,
	linux-kernel, yingjoe.chen

Commit-ID:  f86eff222fabe30da5c536ef2b51bd98d14cfe3b
Gitweb:     http://git.kernel.org/tip/f86eff222fabe30da5c536ef2b51bd98d14cfe3b
Author:     Marc Zyngier <marc.zyngier@arm.com>
AuthorDate: Sat, 15 Nov 2014 10:49:13 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 23 Nov 2014 13:01:47 +0100

genirq: Work around __irq_set_handler vs stacked domains ordering issues

With the introduction of stacked domains, we have the issue that,
depending on where in the stack this is called, __irq_set_handler
will succeed or fail: If this is called from the inner irqchip,
__irq_set_handler() will fail, as it will look at the outer domain
as the (desc->irq_data.chip == &no_irq_chip) test fails (we haven't
set the top level yet).

This patch implements the following: "If there is at least one
valid irqchip in the domain, it will probably sort itself out".
This is clearly not ideal, but it is far less confusing then
crashing because the top-level domain is not up yet.

[ tglx: Added comment and a protection against chained interrupts in
  	that context ]

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Yingjoe Chen <yingjoe.chen@mediatek.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Link: http://lkml.kernel.org/r/1416048553-29289-3-git-send-email-marc.zyngier@arm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/irq/chip.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 63c16d1..6f1c7a5 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -731,7 +731,30 @@ __irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
 	if (!handle) {
 		handle = handle_bad_irq;
 	} else {
-		if (WARN_ON(desc->irq_data.chip == &no_irq_chip))
+		struct irq_data *irq_data = &desc->irq_data;
+#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
+		/*
+		 * With hierarchical domains we might run into a
+		 * situation where the outermost chip is not yet set
+		 * up, but the inner chips are there.  Instead of
+		 * bailing we install the handler, but obviously we
+		 * cannot enable/startup the interrupt at this point.
+		 */
+		while (irq_data) {
+			if (irq_data->chip != &no_irq_chip)
+				break;
+			/*
+			 * Bail out if the outer chip is not set up
+			 * and the interrrupt supposed to be started
+			 * right away.
+			 */
+			if (WARN_ON(is_chained))
+				goto out;
+			/* Try the parent */
+			irq_data = irq_data->parent_data;
+		}
+#endif
+		if (WARN_ON(!irq_data || irq_data->chip == &no_irq_chip))
 			goto out;
 	}
 

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

* [tip:irq/irqdomain] PCI/MSI: Allow an msi_controller to be associated to an irq domain
  2014-11-15 10:49 ` [PATCH 1/2] PCI/MSI: Allow an msi_chip to be associated to an irq domain Marc Zyngier
@ 2014-11-23 18:14   ` tip-bot for Marc Zyngier
  0 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Marc Zyngier @ 2014-11-23 18:14 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, linux-kernel, mingo, tglx, marc.zyngier, bhelgaas,
	yingjoe.chen, jiang.liu

Commit-ID:  020c312658d61297ffe43b412441c69b1c36fb1b
Gitweb:     http://git.kernel.org/tip/020c312658d61297ffe43b412441c69b1c36fb1b
Author:     Marc Zyngier <marc.zyngier@arm.com>
AuthorDate: Sat, 15 Nov 2014 10:49:12 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 23 Nov 2014 17:14:43 +0100

PCI/MSI: Allow an msi_controller to be associated to an irq domain

With the new stacked irq domains, it becomes pretty tempting to
allocate an MSI domain per PCI bus, which would remove the requirement
of either relying on arch-specific code, or a default PCI MSI domain.

By allowing the msi_controller structure to carry a pointer to an
irq_domain, we can easily use this in pci_msi_setup_msi_irqs.  The
existing code can still be used as a fallback if the MSI driver does
not populate the domain field.

Tested on arm64 with the GICv3 ITS driver.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Yingjoe Chen <yingjoe.chen@mediatek.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Link: http://lkml.kernel.org/r/1416048553-29289-2-git-send-email-marc.zyngier@arm.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/pci/msi.c   | 16 ++++++++++++++--
 include/linux/msi.h |  3 +++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 4befe09..476f4b1 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -37,11 +37,23 @@ struct irq_domain * __weak arch_get_pci_msi_domain(struct pci_dev *dev)
 	return pci_msi_default_domain;
 }
 
+static struct irq_domain *pci_msi_get_domain(struct pci_dev *dev)
+{
+	struct irq_domain *domain = NULL;
+
+	if (dev->bus->msi)
+		domain = dev->bus->msi->domain;
+	if (!domain)
+		domain = arch_get_pci_msi_domain(dev);
+
+	return domain;
+}
+
 static int pci_msi_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
 {
 	struct irq_domain *domain;
 
-	domain = arch_get_pci_msi_domain(dev);
+	domain = pci_msi_get_domain(dev);
 	if (domain)
 		return pci_msi_domain_alloc_irqs(domain, dev, nvec, type);
 
@@ -52,7 +64,7 @@ static void pci_msi_teardown_msi_irqs(struct pci_dev *dev)
 {
 	struct irq_domain *domain;
 
-	domain = arch_get_pci_msi_domain(dev);
+	domain = pci_msi_get_domain(dev);
 	if (domain)
 		pci_msi_domain_free_irqs(domain, dev);
 	else
diff --git a/include/linux/msi.h b/include/linux/msi.h
index 692f217..8ac4a68 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -108,6 +108,9 @@ struct msi_controller {
 	struct device *dev;
 	struct device_node *of_node;
 	struct list_head list;
+#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
+	struct irq_domain *domain;
+#endif
 
 	int (*setup_irq)(struct msi_controller *chip, struct pci_dev *dev,
 			 struct msi_desc *desc);

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

end of thread, other threads:[~2014-11-24 20:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-15 10:49 [PATCH 0/2] Stacked domains and MSI improvements Marc Zyngier
2014-11-15 10:49 ` [PATCH 1/2] PCI/MSI: Allow an msi_chip to be associated to an irq domain Marc Zyngier
2014-11-23 18:14   ` [tip:irq/irqdomain] PCI/MSI: Allow an msi_controller " tip-bot for Marc Zyngier
2014-11-15 10:49 ` [PATCH 2/2] genirq: Work around __irq_set_handler vs stacked domains ordering issues Marc Zyngier
2014-11-23 18:11   ` [tip:irq/irqdomain] " tip-bot for Marc Zyngier

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