All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 0/6] gicv2m: acpi: Add ACPI support for GICv2m MSI
@ 2015-10-14 23:25 ` Suravee Suthikulpanit
  0 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: marc.zyngier, tglx, jason, rjw
  Cc: Lorenzo Pieralisi, Will Deacon, Catalin Marinas, hanjun.guo,
	tomasz.nowicki, graeme.gregory, dhdang, linux-arm-kernel,
	linux-kernel, linux-acpi, Suravee Suthikulpanit

This patch series has been forked from the following patch series since
it no longer depends on the rest of the patches.

  [PATCH v4 00/10] ACPI GIC Self-probing, GICv2m and GICv3 support
  https://lkml.org/lkml/2015/7/29/234

It has been ported to use the newly introduced device fwnode_handle 
for ACPI irqdmain introduced by Marc in the following patch series:

  [PATCH v2 00/17] Divorcing irqdomain and device_node
  http://git.kernel.org/cgit/linux/kernel/git/maz/arm-platforms.git irq/irq-domain-fwnode-v2

The following git branch contains the submitted patches along with
the pre-requsite patches (mainly for ARM64 PCI support for ACPI).

  https://github.com/ssuthiku/linux.git	irq-domain-fwnode-v2-v2m-multiframe

This has been tested on AMD Seattle (Overdrive) RevB system. 

NOTE: I have not tested ACPI GICv2m multiframe support since
I don't have access to such system. Any helps are appreciated.

Thanks,
Suravee

Changes from V1: (https://lkml.org/lkml/2015/10/13/859)
  - Rebase on top of Marc's patch to addng support for multiple MSI frames
    (https://lkml.org/lkml/2015/10/14/271)
  - Adding fwnode convenient functions (patch 3 and 4)

Suravee Suthikulpanit (6):
  pci: msi: Add support to query MSI domain for pci device
  acpi: pci: Setup MSI domain for ACPI based pci devices
  irqdomain: introduce is_fwnode_irqchip helper
  irqdomain: Introduce irq_domain_get_irqchip_fwnode_name helper
    function
  gicv2m: Refactor to prepare for ACPI support
  gicv2m: acpi: Introducing GICv2m ACPI support

 drivers/irqchip/irq-gic-v2m.c   | 151 ++++++++++++++++++++++++++++++++++------
 drivers/irqchip/irq-gic.c       |   5 +-
 drivers/pci/msi.c               |  30 ++++++++
 drivers/pci/pci-acpi.c          |  13 ++++
 drivers/pci/probe.c             |   2 +
 include/linux/irqchip/arm-gic.h |   6 ++
 include/linux/irqdomain.h       |   6 ++
 include/linux/msi.h             |   7 ++
 include/linux/pci.h             |   7 ++
 kernel/irq/irqdomain.c          |  20 +++++-
 10 files changed, 224 insertions(+), 23 deletions(-)

-- 
2.1.0


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

* [PATCH V2 0/6] gicv2m: acpi: Add ACPI support for GICv2m MSI
@ 2015-10-14 23:25 ` Suravee Suthikulpanit
  0 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: marc.zyngier, tglx, jason, rjw
  Cc: Lorenzo Pieralisi, Will Deacon, Catalin Marinas, hanjun.guo,
	tomasz.nowicki, graeme.gregory, dhdang, linux-arm-kernel,
	linux-kernel, linux-acpi, Suravee Suthikulpanit

This patch series has been forked from the following patch series since
it no longer depends on the rest of the patches.

  [PATCH v4 00/10] ACPI GIC Self-probing, GICv2m and GICv3 support
  https://lkml.org/lkml/2015/7/29/234

It has been ported to use the newly introduced device fwnode_handle 
for ACPI irqdmain introduced by Marc in the following patch series:

  [PATCH v2 00/17] Divorcing irqdomain and device_node
  http://git.kernel.org/cgit/linux/kernel/git/maz/arm-platforms.git irq/irq-domain-fwnode-v2

The following git branch contains the submitted patches along with
the pre-requsite patches (mainly for ARM64 PCI support for ACPI).

  https://github.com/ssuthiku/linux.git	irq-domain-fwnode-v2-v2m-multiframe

This has been tested on AMD Seattle (Overdrive) RevB system. 

NOTE: I have not tested ACPI GICv2m multiframe support since
I don't have access to such system. Any helps are appreciated.

Thanks,
Suravee

Changes from V1: (https://lkml.org/lkml/2015/10/13/859)
  - Rebase on top of Marc's patch to addng support for multiple MSI frames
    (https://lkml.org/lkml/2015/10/14/271)
  - Adding fwnode convenient functions (patch 3 and 4)

Suravee Suthikulpanit (6):
  pci: msi: Add support to query MSI domain for pci device
  acpi: pci: Setup MSI domain for ACPI based pci devices
  irqdomain: introduce is_fwnode_irqchip helper
  irqdomain: Introduce irq_domain_get_irqchip_fwnode_name helper
    function
  gicv2m: Refactor to prepare for ACPI support
  gicv2m: acpi: Introducing GICv2m ACPI support

 drivers/irqchip/irq-gic-v2m.c   | 151 ++++++++++++++++++++++++++++++++++------
 drivers/irqchip/irq-gic.c       |   5 +-
 drivers/pci/msi.c               |  30 ++++++++
 drivers/pci/pci-acpi.c          |  13 ++++
 drivers/pci/probe.c             |   2 +
 include/linux/irqchip/arm-gic.h |   6 ++
 include/linux/irqdomain.h       |   6 ++
 include/linux/msi.h             |   7 ++
 include/linux/pci.h             |   7 ++
 kernel/irq/irqdomain.c          |  20 +++++-
 10 files changed, 224 insertions(+), 23 deletions(-)

-- 
2.1.0


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

* [PATCH V2 0/6] gicv2m: acpi: Add ACPI support for GICv2m MSI
@ 2015-10-14 23:25 ` Suravee Suthikulpanit
  0 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: linux-arm-kernel

This patch series has been forked from the following patch series since
it no longer depends on the rest of the patches.

  [PATCH v4 00/10] ACPI GIC Self-probing, GICv2m and GICv3 support
  https://lkml.org/lkml/2015/7/29/234

It has been ported to use the newly introduced device fwnode_handle 
for ACPI irqdmain introduced by Marc in the following patch series:

  [PATCH v2 00/17] Divorcing irqdomain and device_node
  http://git.kernel.org/cgit/linux/kernel/git/maz/arm-platforms.git irq/irq-domain-fwnode-v2

The following git branch contains the submitted patches along with
the pre-requsite patches (mainly for ARM64 PCI support for ACPI).

  https://github.com/ssuthiku/linux.git	irq-domain-fwnode-v2-v2m-multiframe

This has been tested on AMD Seattle (Overdrive) RevB system. 

NOTE: I have not tested ACPI GICv2m multiframe support since
I don't have access to such system. Any helps are appreciated.

Thanks,
Suravee

Changes from V1: (https://lkml.org/lkml/2015/10/13/859)
  - Rebase on top of Marc's patch to addng support for multiple MSI frames
    (https://lkml.org/lkml/2015/10/14/271)
  - Adding fwnode convenient functions (patch 3 and 4)

Suravee Suthikulpanit (6):
  pci: msi: Add support to query MSI domain for pci device
  acpi: pci: Setup MSI domain for ACPI based pci devices
  irqdomain: introduce is_fwnode_irqchip helper
  irqdomain: Introduce irq_domain_get_irqchip_fwnode_name helper
    function
  gicv2m: Refactor to prepare for ACPI support
  gicv2m: acpi: Introducing GICv2m ACPI support

 drivers/irqchip/irq-gic-v2m.c   | 151 ++++++++++++++++++++++++++++++++++------
 drivers/irqchip/irq-gic.c       |   5 +-
 drivers/pci/msi.c               |  30 ++++++++
 drivers/pci/pci-acpi.c          |  13 ++++
 drivers/pci/probe.c             |   2 +
 include/linux/irqchip/arm-gic.h |   6 ++
 include/linux/irqdomain.h       |   6 ++
 include/linux/msi.h             |   7 ++
 include/linux/pci.h             |   7 ++
 kernel/irq/irqdomain.c          |  20 +++++-
 10 files changed, 224 insertions(+), 23 deletions(-)

-- 
2.1.0

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

* [PATCH V2 1/6] pci: msi: Add support to query MSI domain for pci device
  2015-10-14 23:25 ` Suravee Suthikulpanit
  (?)
@ 2015-10-14 23:25   ` Suravee Suthikulpanit
  -1 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: marc.zyngier, tglx, jason, rjw
  Cc: Lorenzo Pieralisi, graeme.gregory, Catalin Marinas, dhdang,
	Will Deacon, linux-kernel, tomasz.nowicki, linux-acpi,
	hanjun.guo, Suravee Suthikulpanit, linux-arm-kernel

This patch introduces an interface for irqchip to register a callback,
to provide a way to determine appropriate MSI domain for a pci device.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
---
 drivers/pci/msi.c   | 30 ++++++++++++++++++++++++++++++
 include/linux/msi.h |  7 +++++++
 2 files changed, 37 insertions(+)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index ddd59fe..2c87843 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -1327,4 +1327,34 @@ struct irq_domain *pci_msi_create_default_irq_domain(struct fwnode_handle *fwnod
 
 	return domain;
 }
+
+static struct fwnode_handle *(*pci_msi_get_fwnode_cb)(struct device *dev);
+
+/**
+ * pci_msi_register_fwnode_provider - Register callback to retrieve fwnode
+ * @fn:		The interrupt domain to retrieve
+ *
+ * This should be called by irqchip driver, which is the parent of
+ * the MSI domain to provide callback interface to query fwnode.
+ */
+void
+pci_msi_register_fwnode_provider(struct fwnode_handle *(*fn)(struct device *))
+{
+	pci_msi_get_fwnode_cb = fn;
+}
+
+/**
+ * pci_msi_get_fwnode - Query fwnode for MSI controller of the @dev
+ * @dev:	The device that we try to query MSI domain token for
+ *
+ * This is used to query MSI domain token when setting up MSI domain
+ * for a device. Returns fwnode_handle * if token found / NULL if not found
+ */
+struct fwnode_handle *pci_msi_get_fwnode(struct device *dev)
+{
+	if (pci_msi_get_fwnode_cb)
+		return pci_msi_get_fwnode_cb(dev);
+
+	return NULL;
+}
 #endif /* CONFIG_PCI_MSI_IRQ_DOMAIN */
diff --git a/include/linux/msi.h b/include/linux/msi.h
index 32a24b9..ceaebf6 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -3,6 +3,7 @@
 
 #include <linux/kobject.h>
 #include <linux/list.h>
+#include <linux/fwnode.h>
 
 struct msi_msg {
 	u32	address_lo;	/* low 32 bits of msi message address */
@@ -294,6 +295,12 @@ irq_hw_number_t pci_msi_domain_calc_hwirq(struct pci_dev *dev,
 					  struct msi_desc *desc);
 int pci_msi_domain_check_cap(struct irq_domain *domain,
 			     struct msi_domain_info *info, struct device *dev);
+
+void
+pci_msi_register_fwnode_provider(struct fwnode_handle *(*fn)(struct device *));
+
+struct fwnode_handle *pci_msi_get_fwnode(struct device *dev);
+
 #endif /* CONFIG_PCI_MSI_IRQ_DOMAIN */
 
 #endif /* LINUX_MSI_H */
-- 
2.1.0

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

* [PATCH V2 1/6] pci: msi: Add support to query MSI domain for pci device
@ 2015-10-14 23:25   ` Suravee Suthikulpanit
  0 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: marc.zyngier, tglx, jason, rjw
  Cc: Lorenzo Pieralisi, Will Deacon, Catalin Marinas, hanjun.guo,
	tomasz.nowicki, graeme.gregory, dhdang, linux-arm-kernel,
	linux-kernel, linux-acpi, Suravee Suthikulpanit

This patch introduces an interface for irqchip to register a callback,
to provide a way to determine appropriate MSI domain for a pci device.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
---
 drivers/pci/msi.c   | 30 ++++++++++++++++++++++++++++++
 include/linux/msi.h |  7 +++++++
 2 files changed, 37 insertions(+)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index ddd59fe..2c87843 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -1327,4 +1327,34 @@ struct irq_domain *pci_msi_create_default_irq_domain(struct fwnode_handle *fwnod
 
 	return domain;
 }
+
+static struct fwnode_handle *(*pci_msi_get_fwnode_cb)(struct device *dev);
+
+/**
+ * pci_msi_register_fwnode_provider - Register callback to retrieve fwnode
+ * @fn:		The interrupt domain to retrieve
+ *
+ * This should be called by irqchip driver, which is the parent of
+ * the MSI domain to provide callback interface to query fwnode.
+ */
+void
+pci_msi_register_fwnode_provider(struct fwnode_handle *(*fn)(struct device *))
+{
+	pci_msi_get_fwnode_cb = fn;
+}
+
+/**
+ * pci_msi_get_fwnode - Query fwnode for MSI controller of the @dev
+ * @dev:	The device that we try to query MSI domain token for
+ *
+ * This is used to query MSI domain token when setting up MSI domain
+ * for a device. Returns fwnode_handle * if token found / NULL if not found
+ */
+struct fwnode_handle *pci_msi_get_fwnode(struct device *dev)
+{
+	if (pci_msi_get_fwnode_cb)
+		return pci_msi_get_fwnode_cb(dev);
+
+	return NULL;
+}
 #endif /* CONFIG_PCI_MSI_IRQ_DOMAIN */
diff --git a/include/linux/msi.h b/include/linux/msi.h
index 32a24b9..ceaebf6 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -3,6 +3,7 @@
 
 #include <linux/kobject.h>
 #include <linux/list.h>
+#include <linux/fwnode.h>
 
 struct msi_msg {
 	u32	address_lo;	/* low 32 bits of msi message address */
@@ -294,6 +295,12 @@ irq_hw_number_t pci_msi_domain_calc_hwirq(struct pci_dev *dev,
 					  struct msi_desc *desc);
 int pci_msi_domain_check_cap(struct irq_domain *domain,
 			     struct msi_domain_info *info, struct device *dev);
+
+void
+pci_msi_register_fwnode_provider(struct fwnode_handle *(*fn)(struct device *));
+
+struct fwnode_handle *pci_msi_get_fwnode(struct device *dev);
+
 #endif /* CONFIG_PCI_MSI_IRQ_DOMAIN */
 
 #endif /* LINUX_MSI_H */
-- 
2.1.0


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

* [PATCH V2 1/6] pci: msi: Add support to query MSI domain for pci device
@ 2015-10-14 23:25   ` Suravee Suthikulpanit
  0 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: linux-arm-kernel

This patch introduces an interface for irqchip to register a callback,
to provide a way to determine appropriate MSI domain for a pci device.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
---
 drivers/pci/msi.c   | 30 ++++++++++++++++++++++++++++++
 include/linux/msi.h |  7 +++++++
 2 files changed, 37 insertions(+)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index ddd59fe..2c87843 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -1327,4 +1327,34 @@ struct irq_domain *pci_msi_create_default_irq_domain(struct fwnode_handle *fwnod
 
 	return domain;
 }
+
+static struct fwnode_handle *(*pci_msi_get_fwnode_cb)(struct device *dev);
+
+/**
+ * pci_msi_register_fwnode_provider - Register callback to retrieve fwnode
+ * @fn:		The interrupt domain to retrieve
+ *
+ * This should be called by irqchip driver, which is the parent of
+ * the MSI domain to provide callback interface to query fwnode.
+ */
+void
+pci_msi_register_fwnode_provider(struct fwnode_handle *(*fn)(struct device *))
+{
+	pci_msi_get_fwnode_cb = fn;
+}
+
+/**
+ * pci_msi_get_fwnode - Query fwnode for MSI controller of the @dev
+ * @dev:	The device that we try to query MSI domain token for
+ *
+ * This is used to query MSI domain token when setting up MSI domain
+ * for a device. Returns fwnode_handle * if token found / NULL if not found
+ */
+struct fwnode_handle *pci_msi_get_fwnode(struct device *dev)
+{
+	if (pci_msi_get_fwnode_cb)
+		return pci_msi_get_fwnode_cb(dev);
+
+	return NULL;
+}
 #endif /* CONFIG_PCI_MSI_IRQ_DOMAIN */
diff --git a/include/linux/msi.h b/include/linux/msi.h
index 32a24b9..ceaebf6 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -3,6 +3,7 @@
 
 #include <linux/kobject.h>
 #include <linux/list.h>
+#include <linux/fwnode.h>
 
 struct msi_msg {
 	u32	address_lo;	/* low 32 bits of msi message address */
@@ -294,6 +295,12 @@ irq_hw_number_t pci_msi_domain_calc_hwirq(struct pci_dev *dev,
 					  struct msi_desc *desc);
 int pci_msi_domain_check_cap(struct irq_domain *domain,
 			     struct msi_domain_info *info, struct device *dev);
+
+void
+pci_msi_register_fwnode_provider(struct fwnode_handle *(*fn)(struct device *));
+
+struct fwnode_handle *pci_msi_get_fwnode(struct device *dev);
+
 #endif /* CONFIG_PCI_MSI_IRQ_DOMAIN */
 
 #endif /* LINUX_MSI_H */
-- 
2.1.0

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

* [PATCH V2 2/6] acpi: pci: Setup MSI domain for ACPI based pci devices
  2015-10-14 23:25 ` Suravee Suthikulpanit
  (?)
@ 2015-10-14 23:25   ` Suravee Suthikulpanit
  -1 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: marc.zyngier, tglx, jason, rjw
  Cc: Lorenzo Pieralisi, Will Deacon, Catalin Marinas, hanjun.guo,
	tomasz.nowicki, graeme.gregory, dhdang, linux-arm-kernel,
	linux-kernel, linux-acpi, Suravee Suthikulpanit

This patch introduces pci_host_bridge_acpi_msi_domain(), which returns
the MSI domain of the specified PCI host bridge with DOMAIN_BUS_PCI_MSI
bus token. Then, it is assigned to pci device.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
---
 drivers/pci/pci-acpi.c | 13 +++++++++++++
 drivers/pci/probe.c    |  2 ++
 include/linux/pci.h    |  7 +++++++
 3 files changed, 22 insertions(+)

diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index a32ba75..0e21ef4 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -9,7 +9,9 @@
 
 #include <linux/delay.h>
 #include <linux/init.h>
+#include <linux/irqdomain.h>
 #include <linux/pci.h>
+#include <linux/msi.h>
 #include <linux/pci_hotplug.h>
 #include <linux/module.h>
 #include <linux/pci-aspm.h>
@@ -689,6 +691,17 @@ static struct acpi_bus_type acpi_pci_bus = {
 	.cleanup = pci_acpi_cleanup,
 };
 
+struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus)
+{
+	struct irq_domain *dom = NULL;
+	struct fwnode_handle *fwnode = pci_msi_get_fwnode(&bus->dev);
+
+	if (fwnode)
+		dom = irq_find_matching_fwnode(fwnode,
+					       DOMAIN_BUS_PCI_MSI);
+	return dom;
+}
+
 static int __init acpi_pci_init(void)
 {
 	int ret;
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 0dbc7fb..bea1840 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -671,6 +671,8 @@ static struct irq_domain *pci_host_bridge_msi_domain(struct pci_bus *bus)
 	 * should be called from here.
 	 */
 	d = pci_host_bridge_of_msi_domain(bus);
+	if (!d)
+		d = pci_host_bridge_acpi_msi_domain(bus);
 
 	return d;
 }
diff --git a/include/linux/pci.h b/include/linux/pci.h
index e90eb22..4a7f6a9 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1925,6 +1925,13 @@ static inline struct irq_domain *
 pci_host_bridge_of_msi_domain(struct pci_bus *bus) { return NULL; }
 #endif  /* CONFIG_OF */
 
+#ifdef CONFIG_ACPI
+struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus);
+#else
+static inline struct irq_domain *
+pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) { return NULL; }
+#endif
+
 #ifdef CONFIG_EEH
 static inline struct eeh_dev *pci_dev_to_eeh_dev(struct pci_dev *pdev)
 {
-- 
2.1.0

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

* [PATCH V2 2/6] acpi: pci: Setup MSI domain for ACPI based pci devices
@ 2015-10-14 23:25   ` Suravee Suthikulpanit
  0 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: marc.zyngier, tglx, jason, rjw
  Cc: Lorenzo Pieralisi, Will Deacon, Catalin Marinas, hanjun.guo,
	tomasz.nowicki, graeme.gregory, dhdang, linux-arm-kernel,
	linux-kernel, linux-acpi, Suravee Suthikulpanit

This patch introduces pci_host_bridge_acpi_msi_domain(), which returns
the MSI domain of the specified PCI host bridge with DOMAIN_BUS_PCI_MSI
bus token. Then, it is assigned to pci device.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
---
 drivers/pci/pci-acpi.c | 13 +++++++++++++
 drivers/pci/probe.c    |  2 ++
 include/linux/pci.h    |  7 +++++++
 3 files changed, 22 insertions(+)

diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index a32ba75..0e21ef4 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -9,7 +9,9 @@
 
 #include <linux/delay.h>
 #include <linux/init.h>
+#include <linux/irqdomain.h>
 #include <linux/pci.h>
+#include <linux/msi.h>
 #include <linux/pci_hotplug.h>
 #include <linux/module.h>
 #include <linux/pci-aspm.h>
@@ -689,6 +691,17 @@ static struct acpi_bus_type acpi_pci_bus = {
 	.cleanup = pci_acpi_cleanup,
 };
 
+struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus)
+{
+	struct irq_domain *dom = NULL;
+	struct fwnode_handle *fwnode = pci_msi_get_fwnode(&bus->dev);
+
+	if (fwnode)
+		dom = irq_find_matching_fwnode(fwnode,
+					       DOMAIN_BUS_PCI_MSI);
+	return dom;
+}
+
 static int __init acpi_pci_init(void)
 {
 	int ret;
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 0dbc7fb..bea1840 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -671,6 +671,8 @@ static struct irq_domain *pci_host_bridge_msi_domain(struct pci_bus *bus)
 	 * should be called from here.
 	 */
 	d = pci_host_bridge_of_msi_domain(bus);
+	if (!d)
+		d = pci_host_bridge_acpi_msi_domain(bus);
 
 	return d;
 }
diff --git a/include/linux/pci.h b/include/linux/pci.h
index e90eb22..4a7f6a9 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1925,6 +1925,13 @@ static inline struct irq_domain *
 pci_host_bridge_of_msi_domain(struct pci_bus *bus) { return NULL; }
 #endif  /* CONFIG_OF */
 
+#ifdef CONFIG_ACPI
+struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus);
+#else
+static inline struct irq_domain *
+pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) { return NULL; }
+#endif
+
 #ifdef CONFIG_EEH
 static inline struct eeh_dev *pci_dev_to_eeh_dev(struct pci_dev *pdev)
 {
-- 
2.1.0


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

* [PATCH V2 2/6] acpi: pci: Setup MSI domain for ACPI based pci devices
@ 2015-10-14 23:25   ` Suravee Suthikulpanit
  0 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: linux-arm-kernel

This patch introduces pci_host_bridge_acpi_msi_domain(), which returns
the MSI domain of the specified PCI host bridge with DOMAIN_BUS_PCI_MSI
bus token. Then, it is assigned to pci device.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
---
 drivers/pci/pci-acpi.c | 13 +++++++++++++
 drivers/pci/probe.c    |  2 ++
 include/linux/pci.h    |  7 +++++++
 3 files changed, 22 insertions(+)

diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index a32ba75..0e21ef4 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -9,7 +9,9 @@
 
 #include <linux/delay.h>
 #include <linux/init.h>
+#include <linux/irqdomain.h>
 #include <linux/pci.h>
+#include <linux/msi.h>
 #include <linux/pci_hotplug.h>
 #include <linux/module.h>
 #include <linux/pci-aspm.h>
@@ -689,6 +691,17 @@ static struct acpi_bus_type acpi_pci_bus = {
 	.cleanup = pci_acpi_cleanup,
 };
 
+struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus)
+{
+	struct irq_domain *dom = NULL;
+	struct fwnode_handle *fwnode = pci_msi_get_fwnode(&bus->dev);
+
+	if (fwnode)
+		dom = irq_find_matching_fwnode(fwnode,
+					       DOMAIN_BUS_PCI_MSI);
+	return dom;
+}
+
 static int __init acpi_pci_init(void)
 {
 	int ret;
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 0dbc7fb..bea1840 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -671,6 +671,8 @@ static struct irq_domain *pci_host_bridge_msi_domain(struct pci_bus *bus)
 	 * should be called from here.
 	 */
 	d = pci_host_bridge_of_msi_domain(bus);
+	if (!d)
+		d = pci_host_bridge_acpi_msi_domain(bus);
 
 	return d;
 }
diff --git a/include/linux/pci.h b/include/linux/pci.h
index e90eb22..4a7f6a9 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1925,6 +1925,13 @@ static inline struct irq_domain *
 pci_host_bridge_of_msi_domain(struct pci_bus *bus) { return NULL; }
 #endif  /* CONFIG_OF */
 
+#ifdef CONFIG_ACPI
+struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus);
+#else
+static inline struct irq_domain *
+pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) { return NULL; }
+#endif
+
 #ifdef CONFIG_EEH
 static inline struct eeh_dev *pci_dev_to_eeh_dev(struct pci_dev *pdev)
 {
-- 
2.1.0

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

* [PATCH V2 3/6] irqdomain: introduce is_fwnode_irqchip helper
  2015-10-14 23:25 ` Suravee Suthikulpanit
  (?)
@ 2015-10-14 23:25   ` Suravee Suthikulpanit
  -1 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: marc.zyngier, tglx, jason, rjw
  Cc: Lorenzo Pieralisi, Will Deacon, Catalin Marinas, hanjun.guo,
	tomasz.nowicki, graeme.gregory, dhdang, linux-arm-kernel,
	linux-kernel, linux-acpi, Suravee Suthikulpanit

Since there will be several places checking if fwnode.type
is equal FWNODE_IRQCHIP, this patch adds a convenient function
for this purpose.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
---
 drivers/irqchip/irq-gic.c | 2 +-
 include/linux/irqdomain.h | 5 +++++
 kernel/irq/irqdomain.c    | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index 1d0e768..6685b33 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -939,7 +939,7 @@ static int gic_irq_domain_translate(struct irq_domain *d,
 		return 0;
 	}
 
-	if (fwspec->fwnode->type == FWNODE_IRQCHIP) {
+	if (is_fwnode_irqchip(fwspec->fwnode)) {
 		if(fwspec->param_count != 2)
 			return -EINVAL;
 
diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index d5e5c5b..4950a71 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -211,6 +211,11 @@ static inline struct fwnode_handle *of_node_to_fwnode(struct device_node *node)
 	return node ? &node->fwnode : NULL;
 }
 
+static inline bool is_fwnode_irqchip(struct fwnode_handle *fwnode)
+{
+	return fwnode && fwnode->type == FWNODE_IRQCHIP;
+}
+
 static inline struct irq_domain *irq_find_matching_host(struct device_node *node,
 							enum irq_domain_bus_token bus_token)
 {
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 22aa961..7f34d98 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -70,7 +70,7 @@ void irq_domain_free_fwnode(struct fwnode_handle *fwnode)
 {
 	struct irqchip_fwid *fwid;
 
-	if (WARN_ON(fwnode->type != FWNODE_IRQCHIP))
+	if (WARN_ON(!is_fwnode_irqchip(fwnode)))
 		return;
 
 	fwid = container_of(fwnode, struct irqchip_fwid, fwnode);
-- 
2.1.0

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

* [PATCH V2 3/6] irqdomain: introduce is_fwnode_irqchip helper
@ 2015-10-14 23:25   ` Suravee Suthikulpanit
  0 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: marc.zyngier, tglx, jason, rjw
  Cc: Lorenzo Pieralisi, Will Deacon, Catalin Marinas, hanjun.guo,
	tomasz.nowicki, graeme.gregory, dhdang, linux-arm-kernel,
	linux-kernel, linux-acpi, Suravee Suthikulpanit

Since there will be several places checking if fwnode.type
is equal FWNODE_IRQCHIP, this patch adds a convenient function
for this purpose.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
---
 drivers/irqchip/irq-gic.c | 2 +-
 include/linux/irqdomain.h | 5 +++++
 kernel/irq/irqdomain.c    | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index 1d0e768..6685b33 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -939,7 +939,7 @@ static int gic_irq_domain_translate(struct irq_domain *d,
 		return 0;
 	}
 
-	if (fwspec->fwnode->type == FWNODE_IRQCHIP) {
+	if (is_fwnode_irqchip(fwspec->fwnode)) {
 		if(fwspec->param_count != 2)
 			return -EINVAL;
 
diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index d5e5c5b..4950a71 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -211,6 +211,11 @@ static inline struct fwnode_handle *of_node_to_fwnode(struct device_node *node)
 	return node ? &node->fwnode : NULL;
 }
 
+static inline bool is_fwnode_irqchip(struct fwnode_handle *fwnode)
+{
+	return fwnode && fwnode->type == FWNODE_IRQCHIP;
+}
+
 static inline struct irq_domain *irq_find_matching_host(struct device_node *node,
 							enum irq_domain_bus_token bus_token)
 {
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 22aa961..7f34d98 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -70,7 +70,7 @@ void irq_domain_free_fwnode(struct fwnode_handle *fwnode)
 {
 	struct irqchip_fwid *fwid;
 
-	if (WARN_ON(fwnode->type != FWNODE_IRQCHIP))
+	if (WARN_ON(!is_fwnode_irqchip(fwnode)))
 		return;
 
 	fwid = container_of(fwnode, struct irqchip_fwid, fwnode);
-- 
2.1.0


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

* [PATCH V2 3/6] irqdomain: introduce is_fwnode_irqchip helper
@ 2015-10-14 23:25   ` Suravee Suthikulpanit
  0 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: linux-arm-kernel

Since there will be several places checking if fwnode.type
is equal FWNODE_IRQCHIP, this patch adds a convenient function
for this purpose.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
---
 drivers/irqchip/irq-gic.c | 2 +-
 include/linux/irqdomain.h | 5 +++++
 kernel/irq/irqdomain.c    | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index 1d0e768..6685b33 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -939,7 +939,7 @@ static int gic_irq_domain_translate(struct irq_domain *d,
 		return 0;
 	}
 
-	if (fwspec->fwnode->type == FWNODE_IRQCHIP) {
+	if (is_fwnode_irqchip(fwspec->fwnode)) {
 		if(fwspec->param_count != 2)
 			return -EINVAL;
 
diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index d5e5c5b..4950a71 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -211,6 +211,11 @@ static inline struct fwnode_handle *of_node_to_fwnode(struct device_node *node)
 	return node ? &node->fwnode : NULL;
 }
 
+static inline bool is_fwnode_irqchip(struct fwnode_handle *fwnode)
+{
+	return fwnode && fwnode->type == FWNODE_IRQCHIP;
+}
+
 static inline struct irq_domain *irq_find_matching_host(struct device_node *node,
 							enum irq_domain_bus_token bus_token)
 {
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 22aa961..7f34d98 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -70,7 +70,7 @@ void irq_domain_free_fwnode(struct fwnode_handle *fwnode)
 {
 	struct irqchip_fwid *fwid;
 
-	if (WARN_ON(fwnode->type != FWNODE_IRQCHIP))
+	if (WARN_ON(!is_fwnode_irqchip(fwnode)))
 		return;
 
 	fwid = container_of(fwnode, struct irqchip_fwid, fwnode);
-- 
2.1.0

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

* [PATCH V2 4/6] irqdomain: Introduce irq_domain_get_irqchip_fwnode_name helper function
  2015-10-14 23:25 ` Suravee Suthikulpanit
  (?)
@ 2015-10-14 23:25   ` Suravee Suthikulpanit
  -1 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: marc.zyngier, tglx, jason, rjw
  Cc: Lorenzo Pieralisi, Will Deacon, Catalin Marinas, hanjun.guo,
	tomasz.nowicki, graeme.gregory, dhdang, linux-arm-kernel,
	linux-kernel, linux-acpi, Suravee Suthikulpanit

This patch adds an accessor function to retrieve struct irqchip_fwid.name.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
---
 include/linux/irqdomain.h |  1 +
 kernel/irq/irqdomain.c    | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index 4950a71..006633d 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -187,6 +187,7 @@ static inline struct device_node *irq_domain_get_of_node(struct irq_domain *d)
 #ifdef CONFIG_IRQ_DOMAIN
 struct fwnode_handle *irq_domain_alloc_fwnode(void *data);
 void irq_domain_free_fwnode(struct fwnode_handle *fwnode);
+const char *irq_domain_get_irqchip_fwnode_name(struct fwnode_handle *fwnode);
 struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size,
 				    irq_hw_number_t hwirq_max, int direct_max,
 				    const struct irq_domain_ops *ops,
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 7f34d98..a8c1cf6 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -79,6 +79,24 @@ void irq_domain_free_fwnode(struct fwnode_handle *fwnode)
 }
 
 /**
+ * irq_domain_get_irqchip_fwnode_name - Retrieve associated name of
+ *                                      specified irqchip fwnode
+ * @fwnode: Specified fwnode_handle
+ *
+ * Returns associated name of the specified fwnode, or NULL on failure.
+ */
+const char *irq_domain_get_irqchip_fwnode_name(struct fwnode_handle *fwnode)
+{
+	struct irqchip_fwid *fwid;
+
+	if (!is_fwnode_irqchip(fwnode))
+		return NULL;
+
+	fwid = container_of(fwnode, struct irqchip_fwid, fwnode);
+	return fwid->name;
+}
+
+/**
  * __irq_domain_add() - Allocate a new irq_domain data structure
  * @of_node: optional device-tree node of the interrupt controller
  * @size: Size of linear map; 0 for radix mapping only
-- 
2.1.0

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

* [PATCH V2 4/6] irqdomain: Introduce irq_domain_get_irqchip_fwnode_name helper function
@ 2015-10-14 23:25   ` Suravee Suthikulpanit
  0 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: marc.zyngier, tglx, jason, rjw
  Cc: Lorenzo Pieralisi, Will Deacon, Catalin Marinas, hanjun.guo,
	tomasz.nowicki, graeme.gregory, dhdang, linux-arm-kernel,
	linux-kernel, linux-acpi, Suravee Suthikulpanit

This patch adds an accessor function to retrieve struct irqchip_fwid.name.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
---
 include/linux/irqdomain.h |  1 +
 kernel/irq/irqdomain.c    | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index 4950a71..006633d 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -187,6 +187,7 @@ static inline struct device_node *irq_domain_get_of_node(struct irq_domain *d)
 #ifdef CONFIG_IRQ_DOMAIN
 struct fwnode_handle *irq_domain_alloc_fwnode(void *data);
 void irq_domain_free_fwnode(struct fwnode_handle *fwnode);
+const char *irq_domain_get_irqchip_fwnode_name(struct fwnode_handle *fwnode);
 struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size,
 				    irq_hw_number_t hwirq_max, int direct_max,
 				    const struct irq_domain_ops *ops,
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 7f34d98..a8c1cf6 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -79,6 +79,24 @@ void irq_domain_free_fwnode(struct fwnode_handle *fwnode)
 }
 
 /**
+ * irq_domain_get_irqchip_fwnode_name - Retrieve associated name of
+ *                                      specified irqchip fwnode
+ * @fwnode: Specified fwnode_handle
+ *
+ * Returns associated name of the specified fwnode, or NULL on failure.
+ */
+const char *irq_domain_get_irqchip_fwnode_name(struct fwnode_handle *fwnode)
+{
+	struct irqchip_fwid *fwid;
+
+	if (!is_fwnode_irqchip(fwnode))
+		return NULL;
+
+	fwid = container_of(fwnode, struct irqchip_fwid, fwnode);
+	return fwid->name;
+}
+
+/**
  * __irq_domain_add() - Allocate a new irq_domain data structure
  * @of_node: optional device-tree node of the interrupt controller
  * @size: Size of linear map; 0 for radix mapping only
-- 
2.1.0


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

* [PATCH V2 4/6] irqdomain: Introduce irq_domain_get_irqchip_fwnode_name helper function
@ 2015-10-14 23:25   ` Suravee Suthikulpanit
  0 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds an accessor function to retrieve struct irqchip_fwid.name.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
---
 include/linux/irqdomain.h |  1 +
 kernel/irq/irqdomain.c    | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index 4950a71..006633d 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -187,6 +187,7 @@ static inline struct device_node *irq_domain_get_of_node(struct irq_domain *d)
 #ifdef CONFIG_IRQ_DOMAIN
 struct fwnode_handle *irq_domain_alloc_fwnode(void *data);
 void irq_domain_free_fwnode(struct fwnode_handle *fwnode);
+const char *irq_domain_get_irqchip_fwnode_name(struct fwnode_handle *fwnode);
 struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size,
 				    irq_hw_number_t hwirq_max, int direct_max,
 				    const struct irq_domain_ops *ops,
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 7f34d98..a8c1cf6 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -79,6 +79,24 @@ void irq_domain_free_fwnode(struct fwnode_handle *fwnode)
 }
 
 /**
+ * irq_domain_get_irqchip_fwnode_name - Retrieve associated name of
+ *                                      specified irqchip fwnode
+ * @fwnode: Specified fwnode_handle
+ *
+ * Returns associated name of the specified fwnode, or NULL on failure.
+ */
+const char *irq_domain_get_irqchip_fwnode_name(struct fwnode_handle *fwnode)
+{
+	struct irqchip_fwid *fwid;
+
+	if (!is_fwnode_irqchip(fwnode))
+		return NULL;
+
+	fwid = container_of(fwnode, struct irqchip_fwid, fwnode);
+	return fwid->name;
+}
+
+/**
  * __irq_domain_add() - Allocate a new irq_domain data structure
  * @of_node: optional device-tree node of the interrupt controller
  * @size: Size of linear map; 0 for radix mapping only
-- 
2.1.0

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

* [PATCH V2 5/6] gicv2m: Refactor to prepare for ACPI support
  2015-10-14 23:25 ` Suravee Suthikulpanit
  (?)
@ 2015-10-14 23:25   ` Suravee Suthikulpanit
  -1 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: marc.zyngier, tglx, jason, rjw
  Cc: Lorenzo Pieralisi, Will Deacon, Catalin Marinas, hanjun.guo,
	tomasz.nowicki, graeme.gregory, dhdang, linux-arm-kernel,
	linux-kernel, linux-acpi, Suravee Suthikulpanit

This patch replaces the struct device_node in v2m_data with
struct fwnode_handle since this structure is common between DT and ACPI.

It also refactors gicv2m_init_one() to prepare for ACPI support.
There should be no functional changes.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
---
 drivers/irqchip/irq-gic-v2m.c | 57 +++++++++++++++++++++++++++----------------
 1 file changed, 36 insertions(+), 21 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
index 87f8d10..7e60f7e 100644
--- a/drivers/irqchip/irq-gic-v2m.c
+++ b/drivers/irqchip/irq-gic-v2m.c
@@ -55,7 +55,7 @@ static DEFINE_SPINLOCK(v2m_lock);
 
 struct v2m_data {
 	struct list_head entry;
-	struct device_node *node;
+	struct fwnode_handle *fwnode;
 	struct resource res;	/* GICv2m resource */
 	void __iomem *base;	/* GICv2m virt address */
 	u32 spi_start;		/* The SPI number that MSIs start */
@@ -254,7 +254,7 @@ static void gicv2m_teardown(void)
 		list_del(&v2m->entry);
 		kfree(v2m->bm);
 		iounmap(v2m->base);
-		of_node_put(v2m->node);
+		of_node_put(to_of_node(v2m->fwnode));
 		kfree(v2m);
 	}
 }
@@ -268,7 +268,7 @@ static int gicv2m_allocate_domains(struct irq_domain *parent)
 	if (!v2m)
 		return 0;
 
-	inner_domain = irq_domain_create_tree(of_node_to_fwnode(v2m->node),
+	inner_domain = irq_domain_create_tree(v2m->fwnode,
 					      &gicv2m_domain_ops, v2m);
 	if (!inner_domain) {
 		pr_err("Failed to create GICv2m domain\n");
@@ -277,10 +277,10 @@ static int gicv2m_allocate_domains(struct irq_domain *parent)
 
 	inner_domain->bus_token = DOMAIN_BUS_NEXUS;
 	inner_domain->parent = parent;
-	pci_domain = pci_msi_create_irq_domain(of_node_to_fwnode(v2m->node),
+	pci_domain = pci_msi_create_irq_domain(v2m->fwnode,
 					       &gicv2m_msi_domain_info,
 					       inner_domain);
-	plat_domain = platform_msi_create_irq_domain(of_node_to_fwnode(v2m->node),
+	plat_domain = platform_msi_create_irq_domain(v2m->fwnode,
 						     &gicv2m_pmsi_domain_info,
 						     inner_domain);
 	if (!pci_domain || !plat_domain) {
@@ -296,11 +296,13 @@ static int gicv2m_allocate_domains(struct irq_domain *parent)
 	return 0;
 }
 
-static int __init gicv2m_init_one(struct device_node *node,
-				  struct irq_domain *parent)
+static int __init gicv2m_init_one(struct fwnode_handle *fwnode,
+				  u32 spi_start, u32 nr_spis,
+				  struct resource *res)
 {
 	int ret;
 	struct v2m_data *v2m;
+	const char *name = NULL;
 
 	v2m = kzalloc(sizeof(struct v2m_data), GFP_KERNEL);
 	if (!v2m) {
@@ -309,13 +311,9 @@ static int __init gicv2m_init_one(struct device_node *node,
 	}
 
 	INIT_LIST_HEAD(&v2m->entry);
-	v2m->node = node;
+	v2m->fwnode = fwnode;
 
-	ret = of_address_to_resource(node, 0, &v2m->res);
-	if (ret) {
-		pr_err("Failed to allocate v2m resource.\n");
-		goto err_free_v2m;
-	}
+	memcpy(&v2m->res, res, sizeof(struct resource));
 
 	v2m->base = ioremap(v2m->res.start, resource_size(&v2m->res));
 	if (!v2m->base) {
@@ -324,10 +322,9 @@ static int __init gicv2m_init_one(struct device_node *node,
 		goto err_free_v2m;
 	}
 
-	if (!of_property_read_u32(node, "arm,msi-base-spi", &v2m->spi_start) &&
-	    !of_property_read_u32(node, "arm,msi-num-spis", &v2m->nr_spis)) {
-		pr_info("Overriding V2M MSI_TYPER (base:%u, num:%u)\n",
-			v2m->spi_start, v2m->nr_spis);
+	if (spi_start && nr_spis) {
+		v2m->spi_start = spi_start;
+		v2m->nr_spis = nr_spis;
 	} else {
 		u32 typer = readl_relaxed(v2m->base + V2M_MSI_TYPER);
 
@@ -359,10 +356,13 @@ static int __init gicv2m_init_one(struct device_node *node,
 	}
 
 	list_add_tail(&v2m->entry, &v2m_nodes);
-	pr_info("Node %s: range[%#lx:%#lx], SPI[%d:%d]\n", node->name,
-		(unsigned long)v2m->res.start, (unsigned long)v2m->res.end,
-		v2m->spi_start, (v2m->spi_start + v2m->nr_spis));
 
+	if (to_of_node(fwnode))
+		name = to_of_node(fwnode)->name;
+
+	pr_info("Frame %s: range[%#lx:%#lx], SPI[%d:%d]\n", name,
+		(unsigned long)res->start, (unsigned long)res->end,
+		v2m->spi_start, (v2m->spi_start + v2m->nr_spis));
 	return 0;
 
 err_iounmap:
@@ -384,10 +384,25 @@ int __init gicv2m_of_init(struct device_node *node, struct irq_domain *parent)
 
 	for (child = of_find_matching_node(node, gicv2m_device_id); child;
 	     child = of_find_matching_node(child, gicv2m_device_id)) {
+		u32 spi_start = 0, nr_spis = 0;
+		struct resource res;
+
 		if (!of_find_property(child, "msi-controller", NULL))
 			continue;
 
-		ret = gicv2m_init_one(child, parent);
+		ret = of_address_to_resource(child, 0, &res);
+		if (ret) {
+			pr_err("Failed to allocate v2m resource.\n");
+			break;
+		}
+
+		if (!of_property_read_u32(child, "arm,msi-base-spi",
+					  &spi_start) &&
+		    !of_property_read_u32(child, "arm,msi-num-spis", &nr_spis))
+			pr_info("DT overriding V2M MSI_TYPER (base:%u, num:%u)\n",
+				spi_start, nr_spis);
+
+		ret = gicv2m_init_one(&child->fwnode, spi_start, nr_spis, &res);
 		if (ret) {
 			of_node_put(node);
 			break;
-- 
2.1.0

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

* [PATCH V2 5/6] gicv2m: Refactor to prepare for ACPI support
@ 2015-10-14 23:25   ` Suravee Suthikulpanit
  0 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: marc.zyngier, tglx, jason, rjw
  Cc: Lorenzo Pieralisi, Will Deacon, Catalin Marinas, hanjun.guo,
	tomasz.nowicki, graeme.gregory, dhdang, linux-arm-kernel,
	linux-kernel, linux-acpi, Suravee Suthikulpanit

This patch replaces the struct device_node in v2m_data with
struct fwnode_handle since this structure is common between DT and ACPI.

It also refactors gicv2m_init_one() to prepare for ACPI support.
There should be no functional changes.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
---
 drivers/irqchip/irq-gic-v2m.c | 57 +++++++++++++++++++++++++++----------------
 1 file changed, 36 insertions(+), 21 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
index 87f8d10..7e60f7e 100644
--- a/drivers/irqchip/irq-gic-v2m.c
+++ b/drivers/irqchip/irq-gic-v2m.c
@@ -55,7 +55,7 @@ static DEFINE_SPINLOCK(v2m_lock);
 
 struct v2m_data {
 	struct list_head entry;
-	struct device_node *node;
+	struct fwnode_handle *fwnode;
 	struct resource res;	/* GICv2m resource */
 	void __iomem *base;	/* GICv2m virt address */
 	u32 spi_start;		/* The SPI number that MSIs start */
@@ -254,7 +254,7 @@ static void gicv2m_teardown(void)
 		list_del(&v2m->entry);
 		kfree(v2m->bm);
 		iounmap(v2m->base);
-		of_node_put(v2m->node);
+		of_node_put(to_of_node(v2m->fwnode));
 		kfree(v2m);
 	}
 }
@@ -268,7 +268,7 @@ static int gicv2m_allocate_domains(struct irq_domain *parent)
 	if (!v2m)
 		return 0;
 
-	inner_domain = irq_domain_create_tree(of_node_to_fwnode(v2m->node),
+	inner_domain = irq_domain_create_tree(v2m->fwnode,
 					      &gicv2m_domain_ops, v2m);
 	if (!inner_domain) {
 		pr_err("Failed to create GICv2m domain\n");
@@ -277,10 +277,10 @@ static int gicv2m_allocate_domains(struct irq_domain *parent)
 
 	inner_domain->bus_token = DOMAIN_BUS_NEXUS;
 	inner_domain->parent = parent;
-	pci_domain = pci_msi_create_irq_domain(of_node_to_fwnode(v2m->node),
+	pci_domain = pci_msi_create_irq_domain(v2m->fwnode,
 					       &gicv2m_msi_domain_info,
 					       inner_domain);
-	plat_domain = platform_msi_create_irq_domain(of_node_to_fwnode(v2m->node),
+	plat_domain = platform_msi_create_irq_domain(v2m->fwnode,
 						     &gicv2m_pmsi_domain_info,
 						     inner_domain);
 	if (!pci_domain || !plat_domain) {
@@ -296,11 +296,13 @@ static int gicv2m_allocate_domains(struct irq_domain *parent)
 	return 0;
 }
 
-static int __init gicv2m_init_one(struct device_node *node,
-				  struct irq_domain *parent)
+static int __init gicv2m_init_one(struct fwnode_handle *fwnode,
+				  u32 spi_start, u32 nr_spis,
+				  struct resource *res)
 {
 	int ret;
 	struct v2m_data *v2m;
+	const char *name = NULL;
 
 	v2m = kzalloc(sizeof(struct v2m_data), GFP_KERNEL);
 	if (!v2m) {
@@ -309,13 +311,9 @@ static int __init gicv2m_init_one(struct device_node *node,
 	}
 
 	INIT_LIST_HEAD(&v2m->entry);
-	v2m->node = node;
+	v2m->fwnode = fwnode;
 
-	ret = of_address_to_resource(node, 0, &v2m->res);
-	if (ret) {
-		pr_err("Failed to allocate v2m resource.\n");
-		goto err_free_v2m;
-	}
+	memcpy(&v2m->res, res, sizeof(struct resource));
 
 	v2m->base = ioremap(v2m->res.start, resource_size(&v2m->res));
 	if (!v2m->base) {
@@ -324,10 +322,9 @@ static int __init gicv2m_init_one(struct device_node *node,
 		goto err_free_v2m;
 	}
 
-	if (!of_property_read_u32(node, "arm,msi-base-spi", &v2m->spi_start) &&
-	    !of_property_read_u32(node, "arm,msi-num-spis", &v2m->nr_spis)) {
-		pr_info("Overriding V2M MSI_TYPER (base:%u, num:%u)\n",
-			v2m->spi_start, v2m->nr_spis);
+	if (spi_start && nr_spis) {
+		v2m->spi_start = spi_start;
+		v2m->nr_spis = nr_spis;
 	} else {
 		u32 typer = readl_relaxed(v2m->base + V2M_MSI_TYPER);
 
@@ -359,10 +356,13 @@ static int __init gicv2m_init_one(struct device_node *node,
 	}
 
 	list_add_tail(&v2m->entry, &v2m_nodes);
-	pr_info("Node %s: range[%#lx:%#lx], SPI[%d:%d]\n", node->name,
-		(unsigned long)v2m->res.start, (unsigned long)v2m->res.end,
-		v2m->spi_start, (v2m->spi_start + v2m->nr_spis));
 
+	if (to_of_node(fwnode))
+		name = to_of_node(fwnode)->name;
+
+	pr_info("Frame %s: range[%#lx:%#lx], SPI[%d:%d]\n", name,
+		(unsigned long)res->start, (unsigned long)res->end,
+		v2m->spi_start, (v2m->spi_start + v2m->nr_spis));
 	return 0;
 
 err_iounmap:
@@ -384,10 +384,25 @@ int __init gicv2m_of_init(struct device_node *node, struct irq_domain *parent)
 
 	for (child = of_find_matching_node(node, gicv2m_device_id); child;
 	     child = of_find_matching_node(child, gicv2m_device_id)) {
+		u32 spi_start = 0, nr_spis = 0;
+		struct resource res;
+
 		if (!of_find_property(child, "msi-controller", NULL))
 			continue;
 
-		ret = gicv2m_init_one(child, parent);
+		ret = of_address_to_resource(child, 0, &res);
+		if (ret) {
+			pr_err("Failed to allocate v2m resource.\n");
+			break;
+		}
+
+		if (!of_property_read_u32(child, "arm,msi-base-spi",
+					  &spi_start) &&
+		    !of_property_read_u32(child, "arm,msi-num-spis", &nr_spis))
+			pr_info("DT overriding V2M MSI_TYPER (base:%u, num:%u)\n",
+				spi_start, nr_spis);
+
+		ret = gicv2m_init_one(&child->fwnode, spi_start, nr_spis, &res);
 		if (ret) {
 			of_node_put(node);
 			break;
-- 
2.1.0


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

* [PATCH V2 5/6] gicv2m: Refactor to prepare for ACPI support
@ 2015-10-14 23:25   ` Suravee Suthikulpanit
  0 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: linux-arm-kernel

This patch replaces the struct device_node in v2m_data with
struct fwnode_handle since this structure is common between DT and ACPI.

It also refactors gicv2m_init_one() to prepare for ACPI support.
There should be no functional changes.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
---
 drivers/irqchip/irq-gic-v2m.c | 57 +++++++++++++++++++++++++++----------------
 1 file changed, 36 insertions(+), 21 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
index 87f8d10..7e60f7e 100644
--- a/drivers/irqchip/irq-gic-v2m.c
+++ b/drivers/irqchip/irq-gic-v2m.c
@@ -55,7 +55,7 @@ static DEFINE_SPINLOCK(v2m_lock);
 
 struct v2m_data {
 	struct list_head entry;
-	struct device_node *node;
+	struct fwnode_handle *fwnode;
 	struct resource res;	/* GICv2m resource */
 	void __iomem *base;	/* GICv2m virt address */
 	u32 spi_start;		/* The SPI number that MSIs start */
@@ -254,7 +254,7 @@ static void gicv2m_teardown(void)
 		list_del(&v2m->entry);
 		kfree(v2m->bm);
 		iounmap(v2m->base);
-		of_node_put(v2m->node);
+		of_node_put(to_of_node(v2m->fwnode));
 		kfree(v2m);
 	}
 }
@@ -268,7 +268,7 @@ static int gicv2m_allocate_domains(struct irq_domain *parent)
 	if (!v2m)
 		return 0;
 
-	inner_domain = irq_domain_create_tree(of_node_to_fwnode(v2m->node),
+	inner_domain = irq_domain_create_tree(v2m->fwnode,
 					      &gicv2m_domain_ops, v2m);
 	if (!inner_domain) {
 		pr_err("Failed to create GICv2m domain\n");
@@ -277,10 +277,10 @@ static int gicv2m_allocate_domains(struct irq_domain *parent)
 
 	inner_domain->bus_token = DOMAIN_BUS_NEXUS;
 	inner_domain->parent = parent;
-	pci_domain = pci_msi_create_irq_domain(of_node_to_fwnode(v2m->node),
+	pci_domain = pci_msi_create_irq_domain(v2m->fwnode,
 					       &gicv2m_msi_domain_info,
 					       inner_domain);
-	plat_domain = platform_msi_create_irq_domain(of_node_to_fwnode(v2m->node),
+	plat_domain = platform_msi_create_irq_domain(v2m->fwnode,
 						     &gicv2m_pmsi_domain_info,
 						     inner_domain);
 	if (!pci_domain || !plat_domain) {
@@ -296,11 +296,13 @@ static int gicv2m_allocate_domains(struct irq_domain *parent)
 	return 0;
 }
 
-static int __init gicv2m_init_one(struct device_node *node,
-				  struct irq_domain *parent)
+static int __init gicv2m_init_one(struct fwnode_handle *fwnode,
+				  u32 spi_start, u32 nr_spis,
+				  struct resource *res)
 {
 	int ret;
 	struct v2m_data *v2m;
+	const char *name = NULL;
 
 	v2m = kzalloc(sizeof(struct v2m_data), GFP_KERNEL);
 	if (!v2m) {
@@ -309,13 +311,9 @@ static int __init gicv2m_init_one(struct device_node *node,
 	}
 
 	INIT_LIST_HEAD(&v2m->entry);
-	v2m->node = node;
+	v2m->fwnode = fwnode;
 
-	ret = of_address_to_resource(node, 0, &v2m->res);
-	if (ret) {
-		pr_err("Failed to allocate v2m resource.\n");
-		goto err_free_v2m;
-	}
+	memcpy(&v2m->res, res, sizeof(struct resource));
 
 	v2m->base = ioremap(v2m->res.start, resource_size(&v2m->res));
 	if (!v2m->base) {
@@ -324,10 +322,9 @@ static int __init gicv2m_init_one(struct device_node *node,
 		goto err_free_v2m;
 	}
 
-	if (!of_property_read_u32(node, "arm,msi-base-spi", &v2m->spi_start) &&
-	    !of_property_read_u32(node, "arm,msi-num-spis", &v2m->nr_spis)) {
-		pr_info("Overriding V2M MSI_TYPER (base:%u, num:%u)\n",
-			v2m->spi_start, v2m->nr_spis);
+	if (spi_start && nr_spis) {
+		v2m->spi_start = spi_start;
+		v2m->nr_spis = nr_spis;
 	} else {
 		u32 typer = readl_relaxed(v2m->base + V2M_MSI_TYPER);
 
@@ -359,10 +356,13 @@ static int __init gicv2m_init_one(struct device_node *node,
 	}
 
 	list_add_tail(&v2m->entry, &v2m_nodes);
-	pr_info("Node %s: range[%#lx:%#lx], SPI[%d:%d]\n", node->name,
-		(unsigned long)v2m->res.start, (unsigned long)v2m->res.end,
-		v2m->spi_start, (v2m->spi_start + v2m->nr_spis));
 
+	if (to_of_node(fwnode))
+		name = to_of_node(fwnode)->name;
+
+	pr_info("Frame %s: range[%#lx:%#lx], SPI[%d:%d]\n", name,
+		(unsigned long)res->start, (unsigned long)res->end,
+		v2m->spi_start, (v2m->spi_start + v2m->nr_spis));
 	return 0;
 
 err_iounmap:
@@ -384,10 +384,25 @@ int __init gicv2m_of_init(struct device_node *node, struct irq_domain *parent)
 
 	for (child = of_find_matching_node(node, gicv2m_device_id); child;
 	     child = of_find_matching_node(child, gicv2m_device_id)) {
+		u32 spi_start = 0, nr_spis = 0;
+		struct resource res;
+
 		if (!of_find_property(child, "msi-controller", NULL))
 			continue;
 
-		ret = gicv2m_init_one(child, parent);
+		ret = of_address_to_resource(child, 0, &res);
+		if (ret) {
+			pr_err("Failed to allocate v2m resource.\n");
+			break;
+		}
+
+		if (!of_property_read_u32(child, "arm,msi-base-spi",
+					  &spi_start) &&
+		    !of_property_read_u32(child, "arm,msi-num-spis", &nr_spis))
+			pr_info("DT overriding V2M MSI_TYPER (base:%u, num:%u)\n",
+				spi_start, nr_spis);
+
+		ret = gicv2m_init_one(&child->fwnode, spi_start, nr_spis, &res);
 		if (ret) {
 			of_node_put(node);
 			break;
-- 
2.1.0

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

* [PATCH V2 6/6] gicv2m: acpi: Introducing GICv2m ACPI support
  2015-10-14 23:25 ` Suravee Suthikulpanit
  (?)
@ 2015-10-14 23:25   ` Suravee Suthikulpanit
  -1 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: marc.zyngier, tglx, jason, rjw
  Cc: Lorenzo Pieralisi, Will Deacon, Catalin Marinas, hanjun.guo,
	tomasz.nowicki, graeme.gregory, dhdang, linux-arm-kernel,
	linux-kernel, linux-acpi, Suravee Suthikulpanit

This patch introduces gicv2m_acpi_init(), which uses information
in MADT GIC MSI frames structure to initialize GICv2m driver.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 drivers/irqchip/irq-gic-v2m.c   | 94 +++++++++++++++++++++++++++++++++++++++++
 drivers/irqchip/irq-gic.c       |  3 ++
 include/linux/irqchip/arm-gic.h |  6 +++
 3 files changed, 103 insertions(+)

diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
index 7e60f7e..290f5b3 100644
--- a/drivers/irqchip/irq-gic-v2m.c
+++ b/drivers/irqchip/irq-gic-v2m.c
@@ -15,9 +15,11 @@
 
 #define pr_fmt(fmt) "GICv2m: " fmt
 
+#include <linux/acpi.h>
 #include <linux/irq.h>
 #include <linux/irqdomain.h>
 #include <linux/kernel.h>
+#include <linux/msi.h>
 #include <linux/of_address.h>
 #include <linux/of_pci.h>
 #include <linux/slab.h>
@@ -138,6 +140,11 @@ static int gicv2m_irq_gic_domain_alloc(struct irq_domain *domain,
 		fwspec.param[0] = 0;
 		fwspec.param[1] = hwirq - 32;
 		fwspec.param[2] = IRQ_TYPE_EDGE_RISING;
+	} else if (is_fwnode_irqchip(domain->parent->fwnode)) {
+		fwspec.fwnode = domain->parent->fwnode;
+		fwspec.param_count = 2;
+		fwspec.param[0] = hwirq;
+		fwspec.param[1] = IRQ_TYPE_EDGE_RISING & IRQ_TYPE_SENSE_MASK;
 	} else {
 		return -EINVAL;
 	}
@@ -255,6 +262,8 @@ static void gicv2m_teardown(void)
 		kfree(v2m->bm);
 		iounmap(v2m->base);
 		of_node_put(to_of_node(v2m->fwnode));
+		if (is_fwnode_irqchip(v2m->fwnode))
+			irq_domain_free_fwnode(v2m->fwnode);
 		kfree(v2m);
 	}
 }
@@ -359,6 +368,8 @@ static int __init gicv2m_init_one(struct fwnode_handle *fwnode,
 
 	if (to_of_node(fwnode))
 		name = to_of_node(fwnode)->name;
+	else
+		name = irq_domain_get_irqchip_fwnode_name(fwnode);
 
 	pr_info("Frame %s: range[%#lx:%#lx], SPI[%d:%d]\n", name,
 		(unsigned long)res->start, (unsigned long)res->end,
@@ -415,3 +426,86 @@ int __init gicv2m_of_init(struct device_node *node, struct irq_domain *parent)
 		gicv2m_teardown();
 	return ret;
 }
+
+#ifdef CONFIG_ACPI
+static int acpi_num_msi;
+
+static struct fwnode_handle *gicv2m_get_fwnode(struct device *dev)
+{
+	struct v2m_data *data;
+
+	if (WARN_ON(acpi_num_msi <= 0))
+		return NULL;
+
+	/* We only return the fwnode of the first MSI frame. */
+	data = list_first_entry_or_null(&v2m_nodes,
+					struct v2m_data, entry);
+	if (!data)
+		return NULL;
+
+	return data->fwnode;
+}
+
+static int __init
+acpi_parse_madt_msi(struct acpi_subtable_header *header,
+		    const unsigned long end)
+{
+	int ret;
+	struct resource res;
+	u32 spi_start = 0, nr_spis = 0;
+	struct acpi_madt_generic_msi_frame *m;
+	struct fwnode_handle *fwnode = NULL;
+
+	m = (struct acpi_madt_generic_msi_frame *)header;
+	if (BAD_MADT_ENTRY(m, end))
+		return -EINVAL;
+
+	res.start = m->base_address;
+	res.end = m->base_address + 0x1000;
+
+	if (m->flags & ACPI_MADT_OVERRIDE_SPI_VALUES) {
+		spi_start = m->spi_base;
+		nr_spis = m->spi_count;
+
+		pr_info("ACPI overriding V2M MSI_TYPER (base:%u, num:%u)\n",
+			spi_start, nr_spis);
+	}
+
+	fwnode = irq_domain_alloc_fwnode((void *)m->base_address);
+	if (!fwnode) {
+		pr_err("Unable to allocate GICv2m domain token\n");
+		return -EINVAL;
+	}
+
+	ret = gicv2m_init_one(fwnode, spi_start, nr_spis, &res);
+
+	return ret;
+}
+
+int __init gicv2m_acpi_init(struct irq_domain *parent)
+{
+	int ret;
+
+	if (acpi_num_msi > 0)
+		return 0;
+
+	acpi_num_msi = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_MSI_FRAME,
+				      acpi_parse_madt_msi, 0);
+
+	if (acpi_num_msi <= 0)
+		goto err_out;
+
+	ret = gicv2m_allocate_domains(parent);
+	if (ret)
+		goto err_out;
+
+	pci_msi_register_fwnode_provider(&gicv2m_get_fwnode);
+
+	return 0;
+
+err_out:
+	gicv2m_teardown();
+	return -EINVAL;
+}
+
+#endif /* CONFIG_ACPI */
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index 6685b33..bb3e1f2 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -1329,6 +1329,9 @@ gic_v2_acpi_init(struct acpi_table_header *table)
 
 	__gic_init_bases(0, -1, dist_base, cpu_base, 0, domain_handle);
 
+	if (IS_ENABLED(CONFIG_ARM_GIC_V2M))
+		gicv2m_acpi_init(gic_data[0].domain);
+
 	acpi_set_irq_model(ACPI_IRQ_MODEL_GIC, domain_handle);
 	return 0;
 }
diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
index bae69e5..7398538 100644
--- a/include/linux/irqchip/arm-gic.h
+++ b/include/linux/irqchip/arm-gic.h
@@ -108,6 +108,12 @@ void gic_init(unsigned int nr, int start,
 
 int gicv2m_of_init(struct device_node *node, struct irq_domain *parent);
 
+#ifdef CONFIG_ACPI
+#include <linux/acpi.h>
+
+int gicv2m_acpi_init(struct irq_domain *parent);
+#endif
+
 void gic_send_sgi(unsigned int cpu_id, unsigned int irq);
 int gic_get_cpu_id(unsigned int cpu);
 void gic_migrate_target(unsigned int new_cpu_id);
-- 
2.1.0

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

* [PATCH V2 6/6] gicv2m: acpi: Introducing GICv2m ACPI support
@ 2015-10-14 23:25   ` Suravee Suthikulpanit
  0 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: marc.zyngier, tglx, jason, rjw
  Cc: Lorenzo Pieralisi, Will Deacon, Catalin Marinas, hanjun.guo,
	tomasz.nowicki, graeme.gregory, dhdang, linux-arm-kernel,
	linux-kernel, linux-acpi, Suravee Suthikulpanit

This patch introduces gicv2m_acpi_init(), which uses information
in MADT GIC MSI frames structure to initialize GICv2m driver.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 drivers/irqchip/irq-gic-v2m.c   | 94 +++++++++++++++++++++++++++++++++++++++++
 drivers/irqchip/irq-gic.c       |  3 ++
 include/linux/irqchip/arm-gic.h |  6 +++
 3 files changed, 103 insertions(+)

diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
index 7e60f7e..290f5b3 100644
--- a/drivers/irqchip/irq-gic-v2m.c
+++ b/drivers/irqchip/irq-gic-v2m.c
@@ -15,9 +15,11 @@
 
 #define pr_fmt(fmt) "GICv2m: " fmt
 
+#include <linux/acpi.h>
 #include <linux/irq.h>
 #include <linux/irqdomain.h>
 #include <linux/kernel.h>
+#include <linux/msi.h>
 #include <linux/of_address.h>
 #include <linux/of_pci.h>
 #include <linux/slab.h>
@@ -138,6 +140,11 @@ static int gicv2m_irq_gic_domain_alloc(struct irq_domain *domain,
 		fwspec.param[0] = 0;
 		fwspec.param[1] = hwirq - 32;
 		fwspec.param[2] = IRQ_TYPE_EDGE_RISING;
+	} else if (is_fwnode_irqchip(domain->parent->fwnode)) {
+		fwspec.fwnode = domain->parent->fwnode;
+		fwspec.param_count = 2;
+		fwspec.param[0] = hwirq;
+		fwspec.param[1] = IRQ_TYPE_EDGE_RISING & IRQ_TYPE_SENSE_MASK;
 	} else {
 		return -EINVAL;
 	}
@@ -255,6 +262,8 @@ static void gicv2m_teardown(void)
 		kfree(v2m->bm);
 		iounmap(v2m->base);
 		of_node_put(to_of_node(v2m->fwnode));
+		if (is_fwnode_irqchip(v2m->fwnode))
+			irq_domain_free_fwnode(v2m->fwnode);
 		kfree(v2m);
 	}
 }
@@ -359,6 +368,8 @@ static int __init gicv2m_init_one(struct fwnode_handle *fwnode,
 
 	if (to_of_node(fwnode))
 		name = to_of_node(fwnode)->name;
+	else
+		name = irq_domain_get_irqchip_fwnode_name(fwnode);
 
 	pr_info("Frame %s: range[%#lx:%#lx], SPI[%d:%d]\n", name,
 		(unsigned long)res->start, (unsigned long)res->end,
@@ -415,3 +426,86 @@ int __init gicv2m_of_init(struct device_node *node, struct irq_domain *parent)
 		gicv2m_teardown();
 	return ret;
 }
+
+#ifdef CONFIG_ACPI
+static int acpi_num_msi;
+
+static struct fwnode_handle *gicv2m_get_fwnode(struct device *dev)
+{
+	struct v2m_data *data;
+
+	if (WARN_ON(acpi_num_msi <= 0))
+		return NULL;
+
+	/* We only return the fwnode of the first MSI frame. */
+	data = list_first_entry_or_null(&v2m_nodes,
+					struct v2m_data, entry);
+	if (!data)
+		return NULL;
+
+	return data->fwnode;
+}
+
+static int __init
+acpi_parse_madt_msi(struct acpi_subtable_header *header,
+		    const unsigned long end)
+{
+	int ret;
+	struct resource res;
+	u32 spi_start = 0, nr_spis = 0;
+	struct acpi_madt_generic_msi_frame *m;
+	struct fwnode_handle *fwnode = NULL;
+
+	m = (struct acpi_madt_generic_msi_frame *)header;
+	if (BAD_MADT_ENTRY(m, end))
+		return -EINVAL;
+
+	res.start = m->base_address;
+	res.end = m->base_address + 0x1000;
+
+	if (m->flags & ACPI_MADT_OVERRIDE_SPI_VALUES) {
+		spi_start = m->spi_base;
+		nr_spis = m->spi_count;
+
+		pr_info("ACPI overriding V2M MSI_TYPER (base:%u, num:%u)\n",
+			spi_start, nr_spis);
+	}
+
+	fwnode = irq_domain_alloc_fwnode((void *)m->base_address);
+	if (!fwnode) {
+		pr_err("Unable to allocate GICv2m domain token\n");
+		return -EINVAL;
+	}
+
+	ret = gicv2m_init_one(fwnode, spi_start, nr_spis, &res);
+
+	return ret;
+}
+
+int __init gicv2m_acpi_init(struct irq_domain *parent)
+{
+	int ret;
+
+	if (acpi_num_msi > 0)
+		return 0;
+
+	acpi_num_msi = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_MSI_FRAME,
+				      acpi_parse_madt_msi, 0);
+
+	if (acpi_num_msi <= 0)
+		goto err_out;
+
+	ret = gicv2m_allocate_domains(parent);
+	if (ret)
+		goto err_out;
+
+	pci_msi_register_fwnode_provider(&gicv2m_get_fwnode);
+
+	return 0;
+
+err_out:
+	gicv2m_teardown();
+	return -EINVAL;
+}
+
+#endif /* CONFIG_ACPI */
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index 6685b33..bb3e1f2 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -1329,6 +1329,9 @@ gic_v2_acpi_init(struct acpi_table_header *table)
 
 	__gic_init_bases(0, -1, dist_base, cpu_base, 0, domain_handle);
 
+	if (IS_ENABLED(CONFIG_ARM_GIC_V2M))
+		gicv2m_acpi_init(gic_data[0].domain);
+
 	acpi_set_irq_model(ACPI_IRQ_MODEL_GIC, domain_handle);
 	return 0;
 }
diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
index bae69e5..7398538 100644
--- a/include/linux/irqchip/arm-gic.h
+++ b/include/linux/irqchip/arm-gic.h
@@ -108,6 +108,12 @@ void gic_init(unsigned int nr, int start,
 
 int gicv2m_of_init(struct device_node *node, struct irq_domain *parent);
 
+#ifdef CONFIG_ACPI
+#include <linux/acpi.h>
+
+int gicv2m_acpi_init(struct irq_domain *parent);
+#endif
+
 void gic_send_sgi(unsigned int cpu_id, unsigned int irq);
 int gic_get_cpu_id(unsigned int cpu);
 void gic_migrate_target(unsigned int new_cpu_id);
-- 
2.1.0


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

* [PATCH V2 6/6] gicv2m: acpi: Introducing GICv2m ACPI support
@ 2015-10-14 23:25   ` Suravee Suthikulpanit
  0 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-14 23:25 UTC (permalink / raw)
  To: linux-arm-kernel

This patch introduces gicv2m_acpi_init(), which uses information
in MADT GIC MSI frames structure to initialize GICv2m driver.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
 drivers/irqchip/irq-gic-v2m.c   | 94 +++++++++++++++++++++++++++++++++++++++++
 drivers/irqchip/irq-gic.c       |  3 ++
 include/linux/irqchip/arm-gic.h |  6 +++
 3 files changed, 103 insertions(+)

diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
index 7e60f7e..290f5b3 100644
--- a/drivers/irqchip/irq-gic-v2m.c
+++ b/drivers/irqchip/irq-gic-v2m.c
@@ -15,9 +15,11 @@
 
 #define pr_fmt(fmt) "GICv2m: " fmt
 
+#include <linux/acpi.h>
 #include <linux/irq.h>
 #include <linux/irqdomain.h>
 #include <linux/kernel.h>
+#include <linux/msi.h>
 #include <linux/of_address.h>
 #include <linux/of_pci.h>
 #include <linux/slab.h>
@@ -138,6 +140,11 @@ static int gicv2m_irq_gic_domain_alloc(struct irq_domain *domain,
 		fwspec.param[0] = 0;
 		fwspec.param[1] = hwirq - 32;
 		fwspec.param[2] = IRQ_TYPE_EDGE_RISING;
+	} else if (is_fwnode_irqchip(domain->parent->fwnode)) {
+		fwspec.fwnode = domain->parent->fwnode;
+		fwspec.param_count = 2;
+		fwspec.param[0] = hwirq;
+		fwspec.param[1] = IRQ_TYPE_EDGE_RISING & IRQ_TYPE_SENSE_MASK;
 	} else {
 		return -EINVAL;
 	}
@@ -255,6 +262,8 @@ static void gicv2m_teardown(void)
 		kfree(v2m->bm);
 		iounmap(v2m->base);
 		of_node_put(to_of_node(v2m->fwnode));
+		if (is_fwnode_irqchip(v2m->fwnode))
+			irq_domain_free_fwnode(v2m->fwnode);
 		kfree(v2m);
 	}
 }
@@ -359,6 +368,8 @@ static int __init gicv2m_init_one(struct fwnode_handle *fwnode,
 
 	if (to_of_node(fwnode))
 		name = to_of_node(fwnode)->name;
+	else
+		name = irq_domain_get_irqchip_fwnode_name(fwnode);
 
 	pr_info("Frame %s: range[%#lx:%#lx], SPI[%d:%d]\n", name,
 		(unsigned long)res->start, (unsigned long)res->end,
@@ -415,3 +426,86 @@ int __init gicv2m_of_init(struct device_node *node, struct irq_domain *parent)
 		gicv2m_teardown();
 	return ret;
 }
+
+#ifdef CONFIG_ACPI
+static int acpi_num_msi;
+
+static struct fwnode_handle *gicv2m_get_fwnode(struct device *dev)
+{
+	struct v2m_data *data;
+
+	if (WARN_ON(acpi_num_msi <= 0))
+		return NULL;
+
+	/* We only return the fwnode of the first MSI frame. */
+	data = list_first_entry_or_null(&v2m_nodes,
+					struct v2m_data, entry);
+	if (!data)
+		return NULL;
+
+	return data->fwnode;
+}
+
+static int __init
+acpi_parse_madt_msi(struct acpi_subtable_header *header,
+		    const unsigned long end)
+{
+	int ret;
+	struct resource res;
+	u32 spi_start = 0, nr_spis = 0;
+	struct acpi_madt_generic_msi_frame *m;
+	struct fwnode_handle *fwnode = NULL;
+
+	m = (struct acpi_madt_generic_msi_frame *)header;
+	if (BAD_MADT_ENTRY(m, end))
+		return -EINVAL;
+
+	res.start = m->base_address;
+	res.end = m->base_address + 0x1000;
+
+	if (m->flags & ACPI_MADT_OVERRIDE_SPI_VALUES) {
+		spi_start = m->spi_base;
+		nr_spis = m->spi_count;
+
+		pr_info("ACPI overriding V2M MSI_TYPER (base:%u, num:%u)\n",
+			spi_start, nr_spis);
+	}
+
+	fwnode = irq_domain_alloc_fwnode((void *)m->base_address);
+	if (!fwnode) {
+		pr_err("Unable to allocate GICv2m domain token\n");
+		return -EINVAL;
+	}
+
+	ret = gicv2m_init_one(fwnode, spi_start, nr_spis, &res);
+
+	return ret;
+}
+
+int __init gicv2m_acpi_init(struct irq_domain *parent)
+{
+	int ret;
+
+	if (acpi_num_msi > 0)
+		return 0;
+
+	acpi_num_msi = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_MSI_FRAME,
+				      acpi_parse_madt_msi, 0);
+
+	if (acpi_num_msi <= 0)
+		goto err_out;
+
+	ret = gicv2m_allocate_domains(parent);
+	if (ret)
+		goto err_out;
+
+	pci_msi_register_fwnode_provider(&gicv2m_get_fwnode);
+
+	return 0;
+
+err_out:
+	gicv2m_teardown();
+	return -EINVAL;
+}
+
+#endif /* CONFIG_ACPI */
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index 6685b33..bb3e1f2 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -1329,6 +1329,9 @@ gic_v2_acpi_init(struct acpi_table_header *table)
 
 	__gic_init_bases(0, -1, dist_base, cpu_base, 0, domain_handle);
 
+	if (IS_ENABLED(CONFIG_ARM_GIC_V2M))
+		gicv2m_acpi_init(gic_data[0].domain);
+
 	acpi_set_irq_model(ACPI_IRQ_MODEL_GIC, domain_handle);
 	return 0;
 }
diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
index bae69e5..7398538 100644
--- a/include/linux/irqchip/arm-gic.h
+++ b/include/linux/irqchip/arm-gic.h
@@ -108,6 +108,12 @@ void gic_init(unsigned int nr, int start,
 
 int gicv2m_of_init(struct device_node *node, struct irq_domain *parent);
 
+#ifdef CONFIG_ACPI
+#include <linux/acpi.h>
+
+int gicv2m_acpi_init(struct irq_domain *parent);
+#endif
+
 void gic_send_sgi(unsigned int cpu_id, unsigned int irq);
 int gic_get_cpu_id(unsigned int cpu);
 void gic_migrate_target(unsigned int new_cpu_id);
-- 
2.1.0

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

* Re: [PATCH V2 6/6] gicv2m: acpi: Introducing GICv2m ACPI support
  2015-10-14 23:25   ` Suravee Suthikulpanit
@ 2015-10-15  6:15     ` Tomasz Nowicki
  -1 siblings, 0 replies; 31+ messages in thread
From: Tomasz Nowicki @ 2015-10-15  6:15 UTC (permalink / raw)
  To: Suravee Suthikulpanit, marc.zyngier, tglx, jason, rjw
  Cc: Lorenzo Pieralisi, Will Deacon, Catalin Marinas, hanjun.guo,
	graeme.gregory, dhdang, linux-arm-kernel, linux-kernel,
	linux-acpi

Hi Suravee,

On 15.10.2015 01:25, Suravee Suthikulpanit wrote:
> This patch introduces gicv2m_acpi_init(), which uses information
> in MADT GIC MSI frames structure to initialize GICv2m driver.
>
> Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>   drivers/irqchip/irq-gic-v2m.c   | 94 +++++++++++++++++++++++++++++++++++++++++
>   drivers/irqchip/irq-gic.c       |  3 ++
>   include/linux/irqchip/arm-gic.h |  6 +++
>   3 files changed, 103 insertions(+)
>
> diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
> index 7e60f7e..290f5b3 100644
> --- a/drivers/irqchip/irq-gic-v2m.c
> +++ b/drivers/irqchip/irq-gic-v2m.c
> @@ -15,9 +15,11 @@
>
>   #define pr_fmt(fmt) "GICv2m: " fmt
>
> +#include <linux/acpi.h>
>   #include <linux/irq.h>
>   #include <linux/irqdomain.h>
>   #include <linux/kernel.h>
> +#include <linux/msi.h>
>   #include <linux/of_address.h>
>   #include <linux/of_pci.h>
>   #include <linux/slab.h>
> @@ -138,6 +140,11 @@ static int gicv2m_irq_gic_domain_alloc(struct irq_domain *domain,
>   		fwspec.param[0] = 0;
>   		fwspec.param[1] = hwirq - 32;
>   		fwspec.param[2] = IRQ_TYPE_EDGE_RISING;
> +	} else if (is_fwnode_irqchip(domain->parent->fwnode)) {
> +		fwspec.fwnode = domain->parent->fwnode;
> +		fwspec.param_count = 2;
> +		fwspec.param[0] = hwirq;
> +		fwspec.param[1] = IRQ_TYPE_EDGE_RISING & IRQ_TYPE_SENSE_MASK;
How about just:
fwspec.param[1] = IRQ_TYPE_EDGE_RISING;

>   	} else {
>   		return -EINVAL;
>   	}
> @@ -255,6 +262,8 @@ static void gicv2m_teardown(void)
>   		kfree(v2m->bm);
>   		iounmap(v2m->base);
>   		of_node_put(to_of_node(v2m->fwnode));
> +		if (is_fwnode_irqchip(v2m->fwnode))
> +			irq_domain_free_fwnode(v2m->fwnode);
>   		kfree(v2m);
>   	}
>   }
> @@ -359,6 +368,8 @@ static int __init gicv2m_init_one(struct fwnode_handle *fwnode,
>
>   	if (to_of_node(fwnode))
>   		name = to_of_node(fwnode)->name;
> +	else
> +		name = irq_domain_get_irqchip_fwnode_name(fwnode);
>
>   	pr_info("Frame %s: range[%#lx:%#lx], SPI[%d:%d]\n", name,
>   		(unsigned long)res->start, (unsigned long)res->end,
> @@ -415,3 +426,86 @@ int __init gicv2m_of_init(struct device_node *node, struct irq_domain *parent)
>   		gicv2m_teardown();
>   	return ret;
>   }
> +
> +#ifdef CONFIG_ACPI
> +static int acpi_num_msi;
> +
> +static struct fwnode_handle *gicv2m_get_fwnode(struct device *dev)
> +{
> +	struct v2m_data *data;
> +
> +	if (WARN_ON(acpi_num_msi <= 0))
> +		return NULL;
> +
> +	/* We only return the fwnode of the first MSI frame. */
> +	data = list_first_entry_or_null(&v2m_nodes,
> +					struct v2m_data, entry);
This can be one line and still fits within 80 characters.
> +	if (!data)
> +		return NULL;
> +
> +	return data->fwnode;
> +}
> +
> +static int __init
> +acpi_parse_madt_msi(struct acpi_subtable_header *header,
> +		    const unsigned long end)
> +{
> +	int ret;
> +	struct resource res;
> +	u32 spi_start = 0, nr_spis = 0;
> +	struct acpi_madt_generic_msi_frame *m;
> +	struct fwnode_handle *fwnode = NULL;
> +
> +	m = (struct acpi_madt_generic_msi_frame *)header;
> +	if (BAD_MADT_ENTRY(m, end))
> +		return -EINVAL;
> +
> +	res.start = m->base_address;
> +	res.end = m->base_address + 0x1000;
> +
> +	if (m->flags & ACPI_MADT_OVERRIDE_SPI_VALUES) {
> +		spi_start = m->spi_base;
> +		nr_spis = m->spi_count;
> +
> +		pr_info("ACPI overriding V2M MSI_TYPER (base:%u, num:%u)\n",
> +			spi_start, nr_spis);
> +	}
> +
> +	fwnode = irq_domain_alloc_fwnode((void *)m->base_address);
> +	if (!fwnode) {
> +		pr_err("Unable to allocate GICv2m domain token\n");
> +		return -EINVAL;
> +	}
> +
> +	ret = gicv2m_init_one(fwnode, spi_start, nr_spis, &res);
I case of error, we should call here:
irq_domain_free_fwnode(fwnode);

> +
> +	return ret;
> +}
> +
> +int __init gicv2m_acpi_init(struct irq_domain *parent)
> +{
> +	int ret;
> +
> +	if (acpi_num_msi > 0)
> +		return 0;
> +
> +	acpi_num_msi = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_MSI_FRAME,
> +				      acpi_parse_madt_msi, 0);
> +
> +	if (acpi_num_msi <= 0)
> +		goto err_out;
If acpi_table_parse_madt return 0, then we don't need to call 
gicv2m_teardown(). Instead we can simply return, optionally add some 
pr_info. Well, gicv2m_teardown would do nothing, so this is just 
cosmetic and up to you.

> +
> +	ret = gicv2m_allocate_domains(parent);
> +	if (ret)
> +		goto err_out;
> +
> +	pci_msi_register_fwnode_provider(&gicv2m_get_fwnode);
> +
> +	return 0;
> +
> +err_out:
> +	gicv2m_teardown();
> +	return -EINVAL;
> +}
> +
> +#endif /* CONFIG_ACPI */
> diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
> index 6685b33..bb3e1f2 100644
> --- a/drivers/irqchip/irq-gic.c
> +++ b/drivers/irqchip/irq-gic.c
> @@ -1329,6 +1329,9 @@ gic_v2_acpi_init(struct acpi_table_header *table)
>
>   	__gic_init_bases(0, -1, dist_base, cpu_base, 0, domain_handle);
>
> +	if (IS_ENABLED(CONFIG_ARM_GIC_V2M))
> +		gicv2m_acpi_init(gic_data[0].domain);
> +
>   	acpi_set_irq_model(ACPI_IRQ_MODEL_GIC, domain_handle);
>   	return 0;
>   }
> diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
> index bae69e5..7398538 100644
> --- a/include/linux/irqchip/arm-gic.h
> +++ b/include/linux/irqchip/arm-gic.h
> @@ -108,6 +108,12 @@ void gic_init(unsigned int nr, int start,
>
>   int gicv2m_of_init(struct device_node *node, struct irq_domain *parent);
>
> +#ifdef CONFIG_ACPI
> +#include <linux/acpi.h>
I think, we don't need this include here. You already added it to itq-gic.c

Moreover, seems we need to add irq_domain_free_fwnode to gicv2m_teardown():
  static void gicv2m_teardown(void)
  {
  	struct v2m_data *v2m, *tmp;

  	list_for_each_entry_safe(v2m, tmp, &v2m_nodes, entry) {
+		struct fwnode_handle *handle = v2m->fwnode;
+
  		list_del(&v2m->entry);
  		kfree(v2m->bm);
  		iounmap(v2m->base);
-		of_node_put(to_of_node(v2m->fwnode));
+		if (is_of_node(handle))
+			of_node_put(to_of_node(handle));
+		else if (is_irqchip_node(handle))
+			irq_domain_free_fwnode(handle);
  		kfree(v2m);
  	}
  }

Thanks,
Tomasz

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

* [PATCH V2 6/6] gicv2m: acpi: Introducing GICv2m ACPI support
@ 2015-10-15  6:15     ` Tomasz Nowicki
  0 siblings, 0 replies; 31+ messages in thread
From: Tomasz Nowicki @ 2015-10-15  6:15 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Suravee,

On 15.10.2015 01:25, Suravee Suthikulpanit wrote:
> This patch introduces gicv2m_acpi_init(), which uses information
> in MADT GIC MSI frames structure to initialize GICv2m driver.
>
> Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>   drivers/irqchip/irq-gic-v2m.c   | 94 +++++++++++++++++++++++++++++++++++++++++
>   drivers/irqchip/irq-gic.c       |  3 ++
>   include/linux/irqchip/arm-gic.h |  6 +++
>   3 files changed, 103 insertions(+)
>
> diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
> index 7e60f7e..290f5b3 100644
> --- a/drivers/irqchip/irq-gic-v2m.c
> +++ b/drivers/irqchip/irq-gic-v2m.c
> @@ -15,9 +15,11 @@
>
>   #define pr_fmt(fmt) "GICv2m: " fmt
>
> +#include <linux/acpi.h>
>   #include <linux/irq.h>
>   #include <linux/irqdomain.h>
>   #include <linux/kernel.h>
> +#include <linux/msi.h>
>   #include <linux/of_address.h>
>   #include <linux/of_pci.h>
>   #include <linux/slab.h>
> @@ -138,6 +140,11 @@ static int gicv2m_irq_gic_domain_alloc(struct irq_domain *domain,
>   		fwspec.param[0] = 0;
>   		fwspec.param[1] = hwirq - 32;
>   		fwspec.param[2] = IRQ_TYPE_EDGE_RISING;
> +	} else if (is_fwnode_irqchip(domain->parent->fwnode)) {
> +		fwspec.fwnode = domain->parent->fwnode;
> +		fwspec.param_count = 2;
> +		fwspec.param[0] = hwirq;
> +		fwspec.param[1] = IRQ_TYPE_EDGE_RISING & IRQ_TYPE_SENSE_MASK;
How about just:
fwspec.param[1] = IRQ_TYPE_EDGE_RISING;

>   	} else {
>   		return -EINVAL;
>   	}
> @@ -255,6 +262,8 @@ static void gicv2m_teardown(void)
>   		kfree(v2m->bm);
>   		iounmap(v2m->base);
>   		of_node_put(to_of_node(v2m->fwnode));
> +		if (is_fwnode_irqchip(v2m->fwnode))
> +			irq_domain_free_fwnode(v2m->fwnode);
>   		kfree(v2m);
>   	}
>   }
> @@ -359,6 +368,8 @@ static int __init gicv2m_init_one(struct fwnode_handle *fwnode,
>
>   	if (to_of_node(fwnode))
>   		name = to_of_node(fwnode)->name;
> +	else
> +		name = irq_domain_get_irqchip_fwnode_name(fwnode);
>
>   	pr_info("Frame %s: range[%#lx:%#lx], SPI[%d:%d]\n", name,
>   		(unsigned long)res->start, (unsigned long)res->end,
> @@ -415,3 +426,86 @@ int __init gicv2m_of_init(struct device_node *node, struct irq_domain *parent)
>   		gicv2m_teardown();
>   	return ret;
>   }
> +
> +#ifdef CONFIG_ACPI
> +static int acpi_num_msi;
> +
> +static struct fwnode_handle *gicv2m_get_fwnode(struct device *dev)
> +{
> +	struct v2m_data *data;
> +
> +	if (WARN_ON(acpi_num_msi <= 0))
> +		return NULL;
> +
> +	/* We only return the fwnode of the first MSI frame. */
> +	data = list_first_entry_or_null(&v2m_nodes,
> +					struct v2m_data, entry);
This can be one line and still fits within 80 characters.
> +	if (!data)
> +		return NULL;
> +
> +	return data->fwnode;
> +}
> +
> +static int __init
> +acpi_parse_madt_msi(struct acpi_subtable_header *header,
> +		    const unsigned long end)
> +{
> +	int ret;
> +	struct resource res;
> +	u32 spi_start = 0, nr_spis = 0;
> +	struct acpi_madt_generic_msi_frame *m;
> +	struct fwnode_handle *fwnode = NULL;
> +
> +	m = (struct acpi_madt_generic_msi_frame *)header;
> +	if (BAD_MADT_ENTRY(m, end))
> +		return -EINVAL;
> +
> +	res.start = m->base_address;
> +	res.end = m->base_address + 0x1000;
> +
> +	if (m->flags & ACPI_MADT_OVERRIDE_SPI_VALUES) {
> +		spi_start = m->spi_base;
> +		nr_spis = m->spi_count;
> +
> +		pr_info("ACPI overriding V2M MSI_TYPER (base:%u, num:%u)\n",
> +			spi_start, nr_spis);
> +	}
> +
> +	fwnode = irq_domain_alloc_fwnode((void *)m->base_address);
> +	if (!fwnode) {
> +		pr_err("Unable to allocate GICv2m domain token\n");
> +		return -EINVAL;
> +	}
> +
> +	ret = gicv2m_init_one(fwnode, spi_start, nr_spis, &res);
I case of error, we should call here:
irq_domain_free_fwnode(fwnode);

> +
> +	return ret;
> +}
> +
> +int __init gicv2m_acpi_init(struct irq_domain *parent)
> +{
> +	int ret;
> +
> +	if (acpi_num_msi > 0)
> +		return 0;
> +
> +	acpi_num_msi = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_MSI_FRAME,
> +				      acpi_parse_madt_msi, 0);
> +
> +	if (acpi_num_msi <= 0)
> +		goto err_out;
If acpi_table_parse_madt return 0, then we don't need to call 
gicv2m_teardown(). Instead we can simply return, optionally add some 
pr_info. Well, gicv2m_teardown would do nothing, so this is just 
cosmetic and up to you.

> +
> +	ret = gicv2m_allocate_domains(parent);
> +	if (ret)
> +		goto err_out;
> +
> +	pci_msi_register_fwnode_provider(&gicv2m_get_fwnode);
> +
> +	return 0;
> +
> +err_out:
> +	gicv2m_teardown();
> +	return -EINVAL;
> +}
> +
> +#endif /* CONFIG_ACPI */
> diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
> index 6685b33..bb3e1f2 100644
> --- a/drivers/irqchip/irq-gic.c
> +++ b/drivers/irqchip/irq-gic.c
> @@ -1329,6 +1329,9 @@ gic_v2_acpi_init(struct acpi_table_header *table)
>
>   	__gic_init_bases(0, -1, dist_base, cpu_base, 0, domain_handle);
>
> +	if (IS_ENABLED(CONFIG_ARM_GIC_V2M))
> +		gicv2m_acpi_init(gic_data[0].domain);
> +
>   	acpi_set_irq_model(ACPI_IRQ_MODEL_GIC, domain_handle);
>   	return 0;
>   }
> diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
> index bae69e5..7398538 100644
> --- a/include/linux/irqchip/arm-gic.h
> +++ b/include/linux/irqchip/arm-gic.h
> @@ -108,6 +108,12 @@ void gic_init(unsigned int nr, int start,
>
>   int gicv2m_of_init(struct device_node *node, struct irq_domain *parent);
>
> +#ifdef CONFIG_ACPI
> +#include <linux/acpi.h>
I think, we don't need this include here. You already added it to itq-gic.c

Moreover, seems we need to add irq_domain_free_fwnode to gicv2m_teardown():
  static void gicv2m_teardown(void)
  {
  	struct v2m_data *v2m, *tmp;

  	list_for_each_entry_safe(v2m, tmp, &v2m_nodes, entry) {
+		struct fwnode_handle *handle = v2m->fwnode;
+
  		list_del(&v2m->entry);
  		kfree(v2m->bm);
  		iounmap(v2m->base);
-		of_node_put(to_of_node(v2m->fwnode));
+		if (is_of_node(handle))
+			of_node_put(to_of_node(handle));
+		else if (is_irqchip_node(handle))
+			irq_domain_free_fwnode(handle);
  		kfree(v2m);
  	}
  }

Thanks,
Tomasz

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

* Re: [PATCH V2 6/6] gicv2m: acpi: Introducing GICv2m ACPI support
  2015-10-15  6:15     ` Tomasz Nowicki
@ 2015-10-15  6:29       ` Tomasz Nowicki
  -1 siblings, 0 replies; 31+ messages in thread
From: Tomasz Nowicki @ 2015-10-15  6:29 UTC (permalink / raw)
  To: Tomasz Nowicki, Suravee Suthikulpanit, marc.zyngier, tglx, jason, rjw
  Cc: Lorenzo Pieralisi, Will Deacon, Catalin Marinas, hanjun.guo,
	graeme.gregory, dhdang, linux-arm-kernel, linux-kernel,
	linux-acpi

On 15.10.2015 08:15, Tomasz Nowicki wrote:
> Hi Suravee,
>

[...]

> Moreover, seems we need to add irq_domain_free_fwnode to gicv2m_teardown():
>   static void gicv2m_teardown(void)
>   {
>       struct v2m_data *v2m, *tmp;
>
>       list_for_each_entry_safe(v2m, tmp, &v2m_nodes, entry) {
> +        struct fwnode_handle *handle = v2m->fwnode;
> +
>           list_del(&v2m->entry);
>           kfree(v2m->bm);
>           iounmap(v2m->base);
> -        of_node_put(to_of_node(v2m->fwnode));
> +        if (is_of_node(handle))
> +            of_node_put(to_of_node(handle));
> +        else if (is_irqchip_node(handle))
> +            irq_domain_free_fwnode(handle);
>           kfree(v2m);
>       }
>   }
>
Sorry, I missed you already did something similar in your patch.

Tomasz

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

* [PATCH V2 6/6] gicv2m: acpi: Introducing GICv2m ACPI support
@ 2015-10-15  6:29       ` Tomasz Nowicki
  0 siblings, 0 replies; 31+ messages in thread
From: Tomasz Nowicki @ 2015-10-15  6:29 UTC (permalink / raw)
  To: linux-arm-kernel

On 15.10.2015 08:15, Tomasz Nowicki wrote:
> Hi Suravee,
>

[...]

> Moreover, seems we need to add irq_domain_free_fwnode to gicv2m_teardown():
>   static void gicv2m_teardown(void)
>   {
>       struct v2m_data *v2m, *tmp;
>
>       list_for_each_entry_safe(v2m, tmp, &v2m_nodes, entry) {
> +        struct fwnode_handle *handle = v2m->fwnode;
> +
>           list_del(&v2m->entry);
>           kfree(v2m->bm);
>           iounmap(v2m->base);
> -        of_node_put(to_of_node(v2m->fwnode));
> +        if (is_of_node(handle))
> +            of_node_put(to_of_node(handle));
> +        else if (is_irqchip_node(handle))
> +            irq_domain_free_fwnode(handle);
>           kfree(v2m);
>       }
>   }
>
Sorry, I missed you already did something similar in your patch.

Tomasz

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

* Re: [PATCH V2 6/6] gicv2m: acpi: Introducing GICv2m ACPI support
  2015-10-15  6:15     ` Tomasz Nowicki
  (?)
@ 2015-10-15 14:03       ` Suravee Suthikulanit
  -1 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulanit @ 2015-10-15 14:03 UTC (permalink / raw)
  To: Tomasz Nowicki, marc.zyngier, tglx, jason, rjw
  Cc: Lorenzo Pieralisi, Will Deacon, Catalin Marinas, hanjun.guo,
	graeme.gregory, dhdang, linux-arm-kernel, linux-kernel,
	linux-acpi

Hi Tomasz,

Thanks for the feedback.

On 10/15/2015 1:15 AM, Tomasz Nowicki wrote:
>> [..]
>> @@ -138,6 +140,11 @@ static int gicv2m_irq_gic_domain_alloc(struct
>> irq_domain *domain,
>>           fwspec.param[0] = 0;
>>           fwspec.param[1] = hwirq - 32;
>>           fwspec.param[2] = IRQ_TYPE_EDGE_RISING;
>> +    } else if (is_fwnode_irqchip(domain->parent->fwnode)) {
>> +        fwspec.fwnode = domain->parent->fwnode;
>> +        fwspec.param_count = 2;
>> +        fwspec.param[0] = hwirq;
>> +        fwspec.param[1] = IRQ_TYPE_EDGE_RISING & IRQ_TYPE_SENSE_MASK;
> How about just:
> fwspec.param[1] = IRQ_TYPE_EDGE_RISING;

Right.

>
>>       } else {
>>           return -EINVAL;
>>       }
>> @@ -255,6 +262,8 @@ static void gicv2m_teardown(void)
>>           kfree(v2m->bm);
>>           iounmap(v2m->base);
>>           of_node_put(to_of_node(v2m->fwnode));
>> +        if (is_fwnode_irqchip(v2m->fwnode))
>> +            irq_domain_free_fwnode(v2m->fwnode);
>>           kfree(v2m);
>>       }
>>   }
>> @@ -359,6 +368,8 @@ static int __init gicv2m_init_one(struct
>> fwnode_handle *fwnode,
>>
>>       if (to_of_node(fwnode))
>>           name = to_of_node(fwnode)->name;
>> +    else
>> +        name = irq_domain_get_irqchip_fwnode_name(fwnode);
>>
>>       pr_info("Frame %s: range[%#lx:%#lx], SPI[%d:%d]\n", name,
>>           (unsigned long)res->start, (unsigned long)res->end,
>> @@ -415,3 +426,86 @@ int __init gicv2m_of_init(struct device_node
>> *node, struct irq_domain *parent)
>>           gicv2m_teardown();
>>       return ret;
>>   }
>> +
>> +#ifdef CONFIG_ACPI
>> +static int acpi_num_msi;
>> +
>> +static struct fwnode_handle *gicv2m_get_fwnode(struct device *dev)
>> +{
>> +    struct v2m_data *data;
>> +
>> +    if (WARN_ON(acpi_num_msi <= 0))
>> +        return NULL;
>> +
>> +    /* We only return the fwnode of the first MSI frame. */
>> +    data = list_first_entry_or_null(&v2m_nodes,
>> +                    struct v2m_data, entry);
> This can be one line and still fits within 80 characters.

Ok.

>> +    if (!data)
>> +        return NULL;
>> +
>> +    return data->fwnode;
>> +}
>> +
>> +static int __init
>> +acpi_parse_madt_msi(struct acpi_subtable_header *header,
>> +            const unsigned long end)
>> +{
>> +    int ret;
>> +    struct resource res;
>> +    u32 spi_start = 0, nr_spis = 0;
>> +    struct acpi_madt_generic_msi_frame *m;
>> +    struct fwnode_handle *fwnode = NULL;
>> +
>> +    m = (struct acpi_madt_generic_msi_frame *)header;
>> +    if (BAD_MADT_ENTRY(m, end))
>> +        return -EINVAL;
>> +
>> +    res.start = m->base_address;
>> +    res.end = m->base_address + 0x1000;
>> +
>> +    if (m->flags & ACPI_MADT_OVERRIDE_SPI_VALUES) {
>> +        spi_start = m->spi_base;
>> +        nr_spis = m->spi_count;
>> +
>> +        pr_info("ACPI overriding V2M MSI_TYPER (base:%u, num:%u)\n",
>> +            spi_start, nr_spis);
>> +    }
>> +
>> +    fwnode = irq_domain_alloc_fwnode((void *)m->base_address);
>> +    if (!fwnode) {
>> +        pr_err("Unable to allocate GICv2m domain token\n");
>> +        return -EINVAL;
>> +    }
>> +
>> +    ret = gicv2m_init_one(fwnode, spi_start, nr_spis, &res);
> I case of error, we should call here:
> irq_domain_free_fwnode(fwnode);

This should have already been handled when returning from the 
acpi_parse_madt_msi() in gicv2m_teardown() since we would need to 
iterate through all existing MSI frame to clean up.

>> +
>> +    return ret;
>> +}
>> +
>> +int __init gicv2m_acpi_init(struct irq_domain *parent)
>> +{
>> +    int ret;
>> +
>> +    if (acpi_num_msi > 0)
>> +        return 0;
>> +
>> +    acpi_num_msi =
>> acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_MSI_FRAME,
>> +                      acpi_parse_madt_msi, 0);
>> +
>> +    if (acpi_num_msi <= 0)
>> +        goto err_out;
> If acpi_table_parse_madt return 0, then we don't need to call
> gicv2m_teardown(). Instead we can simply return, optionally add some
> pr_info. Well, gicv2m_teardown would do nothing, so this is just
> cosmetic and up to you.

I'd be hesitate to add pr_info here since V2m is optional, we already 
print information for each frame found. I think I would just leave this 
one the way it is.

>> [..]
>> diff --git a/include/linux/irqchip/arm-gic.h
>> b/include/linux/irqchip/arm-gic.h
>> index bae69e5..7398538 100644
>> --- a/include/linux/irqchip/arm-gic.h
>> +++ b/include/linux/irqchip/arm-gic.h
>> @@ -108,6 +108,12 @@ void gic_init(unsigned int nr, int start,
>>
>>   int gicv2m_of_init(struct device_node *node, struct irq_domain
>> *parent);
>>
>> +#ifdef CONFIG_ACPI
>> +#include <linux/acpi.h>
> I think, we don't need this include here. You already added it to itq-gic.c

Right.

Thanks,
Suravee



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

* Re: [PATCH V2 6/6] gicv2m: acpi: Introducing GICv2m ACPI support
@ 2015-10-15 14:03       ` Suravee Suthikulanit
  0 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulanit @ 2015-10-15 14:03 UTC (permalink / raw)
  To: Tomasz Nowicki, marc.zyngier, tglx, jason, rjw
  Cc: Lorenzo Pieralisi, Will Deacon, Catalin Marinas, hanjun.guo,
	graeme.gregory, dhdang, linux-arm-kernel, linux-kernel,
	linux-acpi

Hi Tomasz,

Thanks for the feedback.

On 10/15/2015 1:15 AM, Tomasz Nowicki wrote:
>> [..]
>> @@ -138,6 +140,11 @@ static int gicv2m_irq_gic_domain_alloc(struct
>> irq_domain *domain,
>>           fwspec.param[0] = 0;
>>           fwspec.param[1] = hwirq - 32;
>>           fwspec.param[2] = IRQ_TYPE_EDGE_RISING;
>> +    } else if (is_fwnode_irqchip(domain->parent->fwnode)) {
>> +        fwspec.fwnode = domain->parent->fwnode;
>> +        fwspec.param_count = 2;
>> +        fwspec.param[0] = hwirq;
>> +        fwspec.param[1] = IRQ_TYPE_EDGE_RISING & IRQ_TYPE_SENSE_MASK;
> How about just:
> fwspec.param[1] = IRQ_TYPE_EDGE_RISING;

Right.

>
>>       } else {
>>           return -EINVAL;
>>       }
>> @@ -255,6 +262,8 @@ static void gicv2m_teardown(void)
>>           kfree(v2m->bm);
>>           iounmap(v2m->base);
>>           of_node_put(to_of_node(v2m->fwnode));
>> +        if (is_fwnode_irqchip(v2m->fwnode))
>> +            irq_domain_free_fwnode(v2m->fwnode);
>>           kfree(v2m);
>>       }
>>   }
>> @@ -359,6 +368,8 @@ static int __init gicv2m_init_one(struct
>> fwnode_handle *fwnode,
>>
>>       if (to_of_node(fwnode))
>>           name = to_of_node(fwnode)->name;
>> +    else
>> +        name = irq_domain_get_irqchip_fwnode_name(fwnode);
>>
>>       pr_info("Frame %s: range[%#lx:%#lx], SPI[%d:%d]\n", name,
>>           (unsigned long)res->start, (unsigned long)res->end,
>> @@ -415,3 +426,86 @@ int __init gicv2m_of_init(struct device_node
>> *node, struct irq_domain *parent)
>>           gicv2m_teardown();
>>       return ret;
>>   }
>> +
>> +#ifdef CONFIG_ACPI
>> +static int acpi_num_msi;
>> +
>> +static struct fwnode_handle *gicv2m_get_fwnode(struct device *dev)
>> +{
>> +    struct v2m_data *data;
>> +
>> +    if (WARN_ON(acpi_num_msi <= 0))
>> +        return NULL;
>> +
>> +    /* We only return the fwnode of the first MSI frame. */
>> +    data = list_first_entry_or_null(&v2m_nodes,
>> +                    struct v2m_data, entry);
> This can be one line and still fits within 80 characters.

Ok.

>> +    if (!data)
>> +        return NULL;
>> +
>> +    return data->fwnode;
>> +}
>> +
>> +static int __init
>> +acpi_parse_madt_msi(struct acpi_subtable_header *header,
>> +            const unsigned long end)
>> +{
>> +    int ret;
>> +    struct resource res;
>> +    u32 spi_start = 0, nr_spis = 0;
>> +    struct acpi_madt_generic_msi_frame *m;
>> +    struct fwnode_handle *fwnode = NULL;
>> +
>> +    m = (struct acpi_madt_generic_msi_frame *)header;
>> +    if (BAD_MADT_ENTRY(m, end))
>> +        return -EINVAL;
>> +
>> +    res.start = m->base_address;
>> +    res.end = m->base_address + 0x1000;
>> +
>> +    if (m->flags & ACPI_MADT_OVERRIDE_SPI_VALUES) {
>> +        spi_start = m->spi_base;
>> +        nr_spis = m->spi_count;
>> +
>> +        pr_info("ACPI overriding V2M MSI_TYPER (base:%u, num:%u)\n",
>> +            spi_start, nr_spis);
>> +    }
>> +
>> +    fwnode = irq_domain_alloc_fwnode((void *)m->base_address);
>> +    if (!fwnode) {
>> +        pr_err("Unable to allocate GICv2m domain token\n");
>> +        return -EINVAL;
>> +    }
>> +
>> +    ret = gicv2m_init_one(fwnode, spi_start, nr_spis, &res);
> I case of error, we should call here:
> irq_domain_free_fwnode(fwnode);

This should have already been handled when returning from the 
acpi_parse_madt_msi() in gicv2m_teardown() since we would need to 
iterate through all existing MSI frame to clean up.

>> +
>> +    return ret;
>> +}
>> +
>> +int __init gicv2m_acpi_init(struct irq_domain *parent)
>> +{
>> +    int ret;
>> +
>> +    if (acpi_num_msi > 0)
>> +        return 0;
>> +
>> +    acpi_num_msi =
>> acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_MSI_FRAME,
>> +                      acpi_parse_madt_msi, 0);
>> +
>> +    if (acpi_num_msi <= 0)
>> +        goto err_out;
> If acpi_table_parse_madt return 0, then we don't need to call
> gicv2m_teardown(). Instead we can simply return, optionally add some
> pr_info. Well, gicv2m_teardown would do nothing, so this is just
> cosmetic and up to you.

I'd be hesitate to add pr_info here since V2m is optional, we already 
print information for each frame found. I think I would just leave this 
one the way it is.

>> [..]
>> diff --git a/include/linux/irqchip/arm-gic.h
>> b/include/linux/irqchip/arm-gic.h
>> index bae69e5..7398538 100644
>> --- a/include/linux/irqchip/arm-gic.h
>> +++ b/include/linux/irqchip/arm-gic.h
>> @@ -108,6 +108,12 @@ void gic_init(unsigned int nr, int start,
>>
>>   int gicv2m_of_init(struct device_node *node, struct irq_domain
>> *parent);
>>
>> +#ifdef CONFIG_ACPI
>> +#include <linux/acpi.h>
> I think, we don't need this include here. You already added it to itq-gic.c

Right.

Thanks,
Suravee



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

* [PATCH V2 6/6] gicv2m: acpi: Introducing GICv2m ACPI support
@ 2015-10-15 14:03       ` Suravee Suthikulanit
  0 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulanit @ 2015-10-15 14:03 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Tomasz,

Thanks for the feedback.

On 10/15/2015 1:15 AM, Tomasz Nowicki wrote:
>> [..]
>> @@ -138,6 +140,11 @@ static int gicv2m_irq_gic_domain_alloc(struct
>> irq_domain *domain,
>>           fwspec.param[0] = 0;
>>           fwspec.param[1] = hwirq - 32;
>>           fwspec.param[2] = IRQ_TYPE_EDGE_RISING;
>> +    } else if (is_fwnode_irqchip(domain->parent->fwnode)) {
>> +        fwspec.fwnode = domain->parent->fwnode;
>> +        fwspec.param_count = 2;
>> +        fwspec.param[0] = hwirq;
>> +        fwspec.param[1] = IRQ_TYPE_EDGE_RISING & IRQ_TYPE_SENSE_MASK;
> How about just:
> fwspec.param[1] = IRQ_TYPE_EDGE_RISING;

Right.

>
>>       } else {
>>           return -EINVAL;
>>       }
>> @@ -255,6 +262,8 @@ static void gicv2m_teardown(void)
>>           kfree(v2m->bm);
>>           iounmap(v2m->base);
>>           of_node_put(to_of_node(v2m->fwnode));
>> +        if (is_fwnode_irqchip(v2m->fwnode))
>> +            irq_domain_free_fwnode(v2m->fwnode);
>>           kfree(v2m);
>>       }
>>   }
>> @@ -359,6 +368,8 @@ static int __init gicv2m_init_one(struct
>> fwnode_handle *fwnode,
>>
>>       if (to_of_node(fwnode))
>>           name = to_of_node(fwnode)->name;
>> +    else
>> +        name = irq_domain_get_irqchip_fwnode_name(fwnode);
>>
>>       pr_info("Frame %s: range[%#lx:%#lx], SPI[%d:%d]\n", name,
>>           (unsigned long)res->start, (unsigned long)res->end,
>> @@ -415,3 +426,86 @@ int __init gicv2m_of_init(struct device_node
>> *node, struct irq_domain *parent)
>>           gicv2m_teardown();
>>       return ret;
>>   }
>> +
>> +#ifdef CONFIG_ACPI
>> +static int acpi_num_msi;
>> +
>> +static struct fwnode_handle *gicv2m_get_fwnode(struct device *dev)
>> +{
>> +    struct v2m_data *data;
>> +
>> +    if (WARN_ON(acpi_num_msi <= 0))
>> +        return NULL;
>> +
>> +    /* We only return the fwnode of the first MSI frame. */
>> +    data = list_first_entry_or_null(&v2m_nodes,
>> +                    struct v2m_data, entry);
> This can be one line and still fits within 80 characters.

Ok.

>> +    if (!data)
>> +        return NULL;
>> +
>> +    return data->fwnode;
>> +}
>> +
>> +static int __init
>> +acpi_parse_madt_msi(struct acpi_subtable_header *header,
>> +            const unsigned long end)
>> +{
>> +    int ret;
>> +    struct resource res;
>> +    u32 spi_start = 0, nr_spis = 0;
>> +    struct acpi_madt_generic_msi_frame *m;
>> +    struct fwnode_handle *fwnode = NULL;
>> +
>> +    m = (struct acpi_madt_generic_msi_frame *)header;
>> +    if (BAD_MADT_ENTRY(m, end))
>> +        return -EINVAL;
>> +
>> +    res.start = m->base_address;
>> +    res.end = m->base_address + 0x1000;
>> +
>> +    if (m->flags & ACPI_MADT_OVERRIDE_SPI_VALUES) {
>> +        spi_start = m->spi_base;
>> +        nr_spis = m->spi_count;
>> +
>> +        pr_info("ACPI overriding V2M MSI_TYPER (base:%u, num:%u)\n",
>> +            spi_start, nr_spis);
>> +    }
>> +
>> +    fwnode = irq_domain_alloc_fwnode((void *)m->base_address);
>> +    if (!fwnode) {
>> +        pr_err("Unable to allocate GICv2m domain token\n");
>> +        return -EINVAL;
>> +    }
>> +
>> +    ret = gicv2m_init_one(fwnode, spi_start, nr_spis, &res);
> I case of error, we should call here:
> irq_domain_free_fwnode(fwnode);

This should have already been handled when returning from the 
acpi_parse_madt_msi() in gicv2m_teardown() since we would need to 
iterate through all existing MSI frame to clean up.

>> +
>> +    return ret;
>> +}
>> +
>> +int __init gicv2m_acpi_init(struct irq_domain *parent)
>> +{
>> +    int ret;
>> +
>> +    if (acpi_num_msi > 0)
>> +        return 0;
>> +
>> +    acpi_num_msi =
>> acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_MSI_FRAME,
>> +                      acpi_parse_madt_msi, 0);
>> +
>> +    if (acpi_num_msi <= 0)
>> +        goto err_out;
> If acpi_table_parse_madt return 0, then we don't need to call
> gicv2m_teardown(). Instead we can simply return, optionally add some
> pr_info. Well, gicv2m_teardown would do nothing, so this is just
> cosmetic and up to you.

I'd be hesitate to add pr_info here since V2m is optional, we already 
print information for each frame found. I think I would just leave this 
one the way it is.

>> [..]
>> diff --git a/include/linux/irqchip/arm-gic.h
>> b/include/linux/irqchip/arm-gic.h
>> index bae69e5..7398538 100644
>> --- a/include/linux/irqchip/arm-gic.h
>> +++ b/include/linux/irqchip/arm-gic.h
>> @@ -108,6 +108,12 @@ void gic_init(unsigned int nr, int start,
>>
>>   int gicv2m_of_init(struct device_node *node, struct irq_domain
>> *parent);
>>
>> +#ifdef CONFIG_ACPI
>> +#include <linux/acpi.h>
> I think, we don't need this include here. You already added it to itq-gic.c

Right.

Thanks,
Suravee

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

* Re: [PATCH V2 6/6] gicv2m: acpi: Introducing GICv2m ACPI support
  2015-10-15 14:03       ` Suravee Suthikulanit
  (?)
@ 2015-10-15 14:30         ` Suravee Suthikulanit
  -1 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulanit @ 2015-10-15 14:30 UTC (permalink / raw)
  To: Tomasz Nowicki, marc.zyngier, tglx, jason, rjw
  Cc: Lorenzo Pieralisi, Will Deacon, Catalin Marinas, hanjun.guo,
	graeme.gregory, dhdang, linux-arm-kernel, linux-kernel,
	linux-acpi

Hi Tomasz,

On 10/15/2015 9:03 AM, Suravee Suthikulanit wrote:
>>> +    if (!data)
>>> +        return NULL;
>>> +
>>> +    return data->fwnode;
>>> +}
>>> +
>>> +static int __init
>>> +acpi_parse_madt_msi(struct acpi_subtable_header *header,
>>> +            const unsigned long end)
>>> +{
>>> +    int ret;
>>> +    struct resource res;
>>> +    u32 spi_start = 0, nr_spis = 0;
>>> +    struct acpi_madt_generic_msi_frame *m;
>>> +    struct fwnode_handle *fwnode = NULL;
>>> +
>>> +    m = (struct acpi_madt_generic_msi_frame *)header;
>>> +    if (BAD_MADT_ENTRY(m, end))
>>> +        return -EINVAL;
>>> +
>>> +    res.start = m->base_address;
>>> +    res.end = m->base_address + 0x1000;
>>> +
>>> +    if (m->flags & ACPI_MADT_OVERRIDE_SPI_VALUES) {
>>> +        spi_start = m->spi_base;
>>> +        nr_spis = m->spi_count;
>>> +
>>> +        pr_info("ACPI overriding V2M MSI_TYPER (base:%u, num:%u)\n",
>>> +            spi_start, nr_spis);
>>> +    }
>>> +
>>> +    fwnode = irq_domain_alloc_fwnode((void *)m->base_address);
>>> +    if (!fwnode) {
>>> +        pr_err("Unable to allocate GICv2m domain token\n");
>>> +        return -EINVAL;
>>> +    }
>>> +
>>> +    ret = gicv2m_init_one(fwnode, spi_start, nr_spis, &res);
>> I case of error, we should call here:
>> irq_domain_free_fwnode(fwnode);
>
> This should have already been handled when returning from the
> acpi_parse_madt_msi() in gicv2m_teardown() since we would need to
> iterate through all existing MSI frame to clean up.

Actually, you are correct since the fwnode allocated here might not get 
assigned to the v2m_data.fwnode and added to the v2m_nodes list yet. So, 
we would need to call irq_domain_alloc_fwnode() here in case of error.

Thanks,
Suravee


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

* Re: [PATCH V2 6/6] gicv2m: acpi: Introducing GICv2m ACPI support
@ 2015-10-15 14:30         ` Suravee Suthikulanit
  0 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulanit @ 2015-10-15 14:30 UTC (permalink / raw)
  To: Tomasz Nowicki, marc.zyngier, tglx, jason, rjw
  Cc: Lorenzo Pieralisi, Will Deacon, Catalin Marinas, hanjun.guo,
	graeme.gregory, dhdang, linux-arm-kernel, linux-kernel,
	linux-acpi

Hi Tomasz,

On 10/15/2015 9:03 AM, Suravee Suthikulanit wrote:
>>> +    if (!data)
>>> +        return NULL;
>>> +
>>> +    return data->fwnode;
>>> +}
>>> +
>>> +static int __init
>>> +acpi_parse_madt_msi(struct acpi_subtable_header *header,
>>> +            const unsigned long end)
>>> +{
>>> +    int ret;
>>> +    struct resource res;
>>> +    u32 spi_start = 0, nr_spis = 0;
>>> +    struct acpi_madt_generic_msi_frame *m;
>>> +    struct fwnode_handle *fwnode = NULL;
>>> +
>>> +    m = (struct acpi_madt_generic_msi_frame *)header;
>>> +    if (BAD_MADT_ENTRY(m, end))
>>> +        return -EINVAL;
>>> +
>>> +    res.start = m->base_address;
>>> +    res.end = m->base_address + 0x1000;
>>> +
>>> +    if (m->flags & ACPI_MADT_OVERRIDE_SPI_VALUES) {
>>> +        spi_start = m->spi_base;
>>> +        nr_spis = m->spi_count;
>>> +
>>> +        pr_info("ACPI overriding V2M MSI_TYPER (base:%u, num:%u)\n",
>>> +            spi_start, nr_spis);
>>> +    }
>>> +
>>> +    fwnode = irq_domain_alloc_fwnode((void *)m->base_address);
>>> +    if (!fwnode) {
>>> +        pr_err("Unable to allocate GICv2m domain token\n");
>>> +        return -EINVAL;
>>> +    }
>>> +
>>> +    ret = gicv2m_init_one(fwnode, spi_start, nr_spis, &res);
>> I case of error, we should call here:
>> irq_domain_free_fwnode(fwnode);
>
> This should have already been handled when returning from the
> acpi_parse_madt_msi() in gicv2m_teardown() since we would need to
> iterate through all existing MSI frame to clean up.

Actually, you are correct since the fwnode allocated here might not get 
assigned to the v2m_data.fwnode and added to the v2m_nodes list yet. So, 
we would need to call irq_domain_alloc_fwnode() here in case of error.

Thanks,
Suravee


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

* [PATCH V2 6/6] gicv2m: acpi: Introducing GICv2m ACPI support
@ 2015-10-15 14:30         ` Suravee Suthikulanit
  0 siblings, 0 replies; 31+ messages in thread
From: Suravee Suthikulanit @ 2015-10-15 14:30 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Tomasz,

On 10/15/2015 9:03 AM, Suravee Suthikulanit wrote:
>>> +    if (!data)
>>> +        return NULL;
>>> +
>>> +    return data->fwnode;
>>> +}
>>> +
>>> +static int __init
>>> +acpi_parse_madt_msi(struct acpi_subtable_header *header,
>>> +            const unsigned long end)
>>> +{
>>> +    int ret;
>>> +    struct resource res;
>>> +    u32 spi_start = 0, nr_spis = 0;
>>> +    struct acpi_madt_generic_msi_frame *m;
>>> +    struct fwnode_handle *fwnode = NULL;
>>> +
>>> +    m = (struct acpi_madt_generic_msi_frame *)header;
>>> +    if (BAD_MADT_ENTRY(m, end))
>>> +        return -EINVAL;
>>> +
>>> +    res.start = m->base_address;
>>> +    res.end = m->base_address + 0x1000;
>>> +
>>> +    if (m->flags & ACPI_MADT_OVERRIDE_SPI_VALUES) {
>>> +        spi_start = m->spi_base;
>>> +        nr_spis = m->spi_count;
>>> +
>>> +        pr_info("ACPI overriding V2M MSI_TYPER (base:%u, num:%u)\n",
>>> +            spi_start, nr_spis);
>>> +    }
>>> +
>>> +    fwnode = irq_domain_alloc_fwnode((void *)m->base_address);
>>> +    if (!fwnode) {
>>> +        pr_err("Unable to allocate GICv2m domain token\n");
>>> +        return -EINVAL;
>>> +    }
>>> +
>>> +    ret = gicv2m_init_one(fwnode, spi_start, nr_spis, &res);
>> I case of error, we should call here:
>> irq_domain_free_fwnode(fwnode);
>
> This should have already been handled when returning from the
> acpi_parse_madt_msi() in gicv2m_teardown() since we would need to
> iterate through all existing MSI frame to clean up.

Actually, you are correct since the fwnode allocated here might not get 
assigned to the v2m_data.fwnode and added to the v2m_nodes list yet. So, 
we would need to call irq_domain_alloc_fwnode() here in case of error.

Thanks,
Suravee

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

end of thread, other threads:[~2015-10-15 14:30 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-14 23:25 [PATCH V2 0/6] gicv2m: acpi: Add ACPI support for GICv2m MSI Suravee Suthikulpanit
2015-10-14 23:25 ` Suravee Suthikulpanit
2015-10-14 23:25 ` Suravee Suthikulpanit
2015-10-14 23:25 ` [PATCH V2 1/6] pci: msi: Add support to query MSI domain for pci device Suravee Suthikulpanit
2015-10-14 23:25   ` Suravee Suthikulpanit
2015-10-14 23:25   ` Suravee Suthikulpanit
2015-10-14 23:25 ` [PATCH V2 2/6] acpi: pci: Setup MSI domain for ACPI based pci devices Suravee Suthikulpanit
2015-10-14 23:25   ` Suravee Suthikulpanit
2015-10-14 23:25   ` Suravee Suthikulpanit
2015-10-14 23:25 ` [PATCH V2 3/6] irqdomain: introduce is_fwnode_irqchip helper Suravee Suthikulpanit
2015-10-14 23:25   ` Suravee Suthikulpanit
2015-10-14 23:25   ` Suravee Suthikulpanit
2015-10-14 23:25 ` [PATCH V2 4/6] irqdomain: Introduce irq_domain_get_irqchip_fwnode_name helper function Suravee Suthikulpanit
2015-10-14 23:25   ` Suravee Suthikulpanit
2015-10-14 23:25   ` Suravee Suthikulpanit
2015-10-14 23:25 ` [PATCH V2 5/6] gicv2m: Refactor to prepare for ACPI support Suravee Suthikulpanit
2015-10-14 23:25   ` Suravee Suthikulpanit
2015-10-14 23:25   ` Suravee Suthikulpanit
2015-10-14 23:25 ` [PATCH V2 6/6] gicv2m: acpi: Introducing GICv2m " Suravee Suthikulpanit
2015-10-14 23:25   ` Suravee Suthikulpanit
2015-10-14 23:25   ` Suravee Suthikulpanit
2015-10-15  6:15   ` Tomasz Nowicki
2015-10-15  6:15     ` Tomasz Nowicki
2015-10-15  6:29     ` Tomasz Nowicki
2015-10-15  6:29       ` Tomasz Nowicki
2015-10-15 14:03     ` Suravee Suthikulanit
2015-10-15 14:03       ` Suravee Suthikulanit
2015-10-15 14:03       ` Suravee Suthikulanit
2015-10-15 14:30       ` Suravee Suthikulanit
2015-10-15 14:30         ` Suravee Suthikulanit
2015-10-15 14:30         ` Suravee Suthikulanit

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.