* [PATCH 0/9] Add new helper to allocate irq domain for hosts
@ 2018-04-27 8:22 Shawn Lin
2018-04-27 8:22 ` [PATCH 1/9] PCI: Add new helper for allocating irq domain for INTx Shawn Lin
` (9 more replies)
0 siblings, 10 replies; 17+ messages in thread
From: Shawn Lin @ 2018-04-27 8:22 UTC (permalink / raw)
To: Lorenzo Pieralisi, Bjorn Helgaas; +Cc: linux-pci, Shawn Lin
Hi Bjorn and Lorenzo,
PCI drivers use highly similar code block to allocate irq domain which
leads to code duplication than expected. This patchset adds a new helper,
pci_alloc_intx_irqd(), to avoid that as much as possible. Just leave
pcie-rockchip out now as it's under re-construct and will add incremental
patch for it if this series looks ok and the pcie-rockchip ongoing patches
got merge.
Shawn Lin (9):
PCI: Add new helper for allocating irq domain for INTx
PCI: dra7xx: Use pci_alloc_intx_irqd() helper to simplify the code
PCI: keystone-dw: Use pci_alloc_intx_irqd() helper to get irq domain
for INTx
PCI: aardvark: Use pci_alloc_intx_irqd() helper to get irq domain for
INTx
PCI: faraday: Use pci_alloc_intx_irqd() helper to get irq domain for
INTx
PCI: altera: Use pci_alloc_intx_irqd() helper to get irq domain for
INTx
PCI: mediatek: Use pci_alloc_intx_irqd() helper to get irq domain for
INTx
PCI: xilinx-nwl: Use pci_alloc_intx_irqd() helper to get irq domain
for INTx
PCI: xilinx: Use pci_alloc_intx_irqd() helper to get irq domain for
INTx
drivers/pci/dwc/pci-dra7xx.c | 41 ++-------------------
drivers/pci/dwc/pci-keystone-dw.c | 12 +++----
drivers/pci/host/pci-aardvark.c | 24 +++----------
drivers/pci/host/pci-ftpci100.c | 15 +++-----
drivers/pci/host/pcie-altera.c | 38 +++-----------------
drivers/pci/host/pcie-mediatek.c | 29 ++-------------
drivers/pci/host/pcie-xilinx-nwl.c | 21 +++--------
drivers/pci/host/pcie-xilinx.c | 43 ++--------------------
include/linux/pci.h | 74 ++++++++++++++++++++++++++++++++++++++
9 files changed, 104 insertions(+), 193 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 1/9] PCI: Add new helper for allocating irq domain for INTx
2018-04-27 8:22 [PATCH 0/9] Add new helper to allocate irq domain for hosts Shawn Lin
@ 2018-04-27 8:22 ` Shawn Lin
2018-04-27 17:18 ` Bjorn Helgaas
` (2 more replies)
2018-04-27 8:22 ` [PATCH 2/9] PCI: dra7xx: Use pci_alloc_intx_irqd() helper to simplify the code Shawn Lin
` (8 subsequent siblings)
9 siblings, 3 replies; 17+ messages in thread
From: Shawn Lin @ 2018-04-27 8:22 UTC (permalink / raw)
To: Lorenzo Pieralisi, Bjorn Helgaas; +Cc: linux-pci, Shawn Lin
It seems host drivers which allocate irq domain for INTx
and the related code block looks highly similar to each other.
Add a new helper, pci_alloc_intx_irqd(), to avoid code duplication
as much as possible.
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
include/linux/pci.h | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 73178a2..68a1994 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -31,6 +31,8 @@
#include <linux/device.h>
#include <linux/interrupt.h>
#include <linux/io.h>
+#include <linux/irq.h>
+#include <linux/of_irq.h>
#include <linux/resource_ext.h>
#include <uapi/linux/pci.h>
@@ -1449,6 +1451,74 @@ static inline int pci_irqd_intx_xlate(struct irq_domain *d,
return 0;
}
+static int pcie_intx_map(struct irq_domain *domain, unsigned int irq,
+ irq_hw_number_t hwirq)
+{
+ irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq);
+ irq_set_chip_data(irq, domain->host_data);
+
+ return 0;
+}
+
+static struct irq_domain_ops pci_intx_domain_ops = {
+ .map = pcie_intx_map,
+};
+
+/**
+ * pci_alloc_intx_irqd() - PCI helper for allocating INTx irq domain
+ * @dev: device associated with the PCI controller.
+ * @host: pointer to host specific data struct
+ * @general_xlate: flag for whether use pci_irqd_intx_xlate() helper
+ * @intx_domain_ops: pointer to driver specific struct irq_domain_ops
+ * @local_intc: pointer to driver specific interrupt controller node
+ *
+ * A simple helper for drivers to allocate irq domain for INTx. If
+ * intx_domain_ops is NULL, use pci_intx_domain_ops by defalut. And if
+ * local_intc is present, then use it firstly, otherwise, fallback to get
+ * interrupt controller node from @dev.
+ *
+ * Returns valid pointer of struct irq_domain on success, or PTR_ERR(-EINVAL)
+ * if failure occurred.
+ */
+static __maybe_unused struct irq_domain *pci_alloc_intx_irqd(struct device *dev,
+ void *host, bool general_xlate,
+ const struct irq_domain_ops *intx_domain_ops,
+ struct device_node *local_intc)
+{
+ struct device_node *intc = local_intc;
+ struct irq_domain *domain;
+ const struct irq_domain_ops *irqd_ops;
+ bool need_put = false;
+
+ if (!intc) {
+ intc = of_get_next_child(dev->of_node, NULL);
+ if (!intc) {
+ dev_err(dev, "missing child interrupt-controller node\n");
+ return ERR_PTR(-EINVAL);
+ }
+ need_put = true;
+ }
+
+ if (intx_domain_ops) {
+ irqd_ops = intx_domain_ops;
+ } else {
+ if (general_xlate)
+ pci_intx_domain_ops.xlate = &pci_irqd_intx_xlate;
+ irqd_ops = &pci_intx_domain_ops;
+ }
+
+ domain = irq_domain_add_linear(intc, PCI_NUM_INTX,
+ irqd_ops, host);
+ if (!domain) {
+ dev_err(dev, "failed to get a INTx IRQ domain\n");
+ if (need_put)
+ of_node_put(intc);
+ return ERR_PTR(-EINVAL);
+ }
+
+ return domain;
+}
+
#ifdef CONFIG_PCIEPORTBUS
extern bool pcie_ports_disabled;
#else
@@ -1683,6 +1753,10 @@ static inline int pci_irqd_intx_xlate(struct irq_domain *d,
unsigned long *out_hwirq,
unsigned int *out_type)
{ return -EINVAL; }
+
+static __maybe_unused struct irq_domain *pci_alloc_intx_irqd(struct device *dev,
+ void *host, bool general_xlate, const struct irq_domain_ops *ops)
+{ return ERR_PTR(-EINVAL); }
#endif /* CONFIG_PCI */
/* Include architecture-dependent settings and functions */
--
1.9.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 2/9] PCI: dra7xx: Use pci_alloc_intx_irqd() helper to simplify the code
2018-04-27 8:22 [PATCH 0/9] Add new helper to allocate irq domain for hosts Shawn Lin
2018-04-27 8:22 ` [PATCH 1/9] PCI: Add new helper for allocating irq domain for INTx Shawn Lin
@ 2018-04-27 8:22 ` Shawn Lin
2018-04-27 8:23 ` [PATCH 3/9] PCI: keystone-dw: Use pci_alloc_intx_irqd() helper to get irq domain for INTx Shawn Lin
` (7 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Shawn Lin @ 2018-04-27 8:22 UTC (permalink / raw)
To: Lorenzo Pieralisi, Bjorn Helgaas
Cc: linux-pci, Shawn Lin, Kishon Vijay Abraham I
Just avoid code duplication, but no functional change intended.
Cc: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
drivers/pci/dwc/pci-dra7xx.c | 41 ++---------------------------------------
1 file changed, 2 insertions(+), 39 deletions(-)
diff --git a/drivers/pci/dwc/pci-dra7xx.c b/drivers/pci/dwc/pci-dra7xx.c
index ed8558d..45f6456 100644
--- a/drivers/pci/dwc/pci-dra7xx.c
+++ b/drivers/pci/dwc/pci-dra7xx.c
@@ -212,43 +212,6 @@ static int dra7xx_pcie_host_init(struct pcie_port *pp)
.host_init = dra7xx_pcie_host_init,
};
-static int dra7xx_pcie_intx_map(struct irq_domain *domain, unsigned int irq,
- irq_hw_number_t hwirq)
-{
- irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq);
- irq_set_chip_data(irq, domain->host_data);
-
- return 0;
-}
-
-static const struct irq_domain_ops intx_domain_ops = {
- .map = dra7xx_pcie_intx_map,
- .xlate = pci_irqd_intx_xlate,
-};
-
-static int dra7xx_pcie_init_irq_domain(struct pcie_port *pp)
-{
- struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
- struct device *dev = pci->dev;
- struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci);
- struct device_node *node = dev->of_node;
- struct device_node *pcie_intc_node = of_get_next_child(node, NULL);
-
- if (!pcie_intc_node) {
- dev_err(dev, "No PCIe Intc node found\n");
- return -ENODEV;
- }
-
- dra7xx->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX,
- &intx_domain_ops, pp);
- if (!dra7xx->irq_domain) {
- dev_err(dev, "Failed to get a INTx IRQ domain\n");
- return -ENODEV;
- }
-
- return 0;
-}
-
static irqreturn_t dra7xx_pcie_msi_irq_handler(int irq, void *arg)
{
struct dra7xx_pcie *dra7xx = arg;
@@ -454,8 +417,8 @@ static int __init dra7xx_add_pcie_port(struct dra7xx_pcie *dra7xx,
return ret;
}
- ret = dra7xx_pcie_init_irq_domain(pp);
- if (ret < 0)
+ dra7xx->irq_domain = pci_alloc_intx_irqd(dev, dra7xx, true, NULL, NULL);
+ if (IS_ERR(dra7xx->irq_domain))
return ret;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rc_dbics");
--
1.9.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 3/9] PCI: keystone-dw: Use pci_alloc_intx_irqd() helper to get irq domain for INTx
2018-04-27 8:22 [PATCH 0/9] Add new helper to allocate irq domain for hosts Shawn Lin
2018-04-27 8:22 ` [PATCH 1/9] PCI: Add new helper for allocating irq domain for INTx Shawn Lin
2018-04-27 8:22 ` [PATCH 2/9] PCI: dra7xx: Use pci_alloc_intx_irqd() helper to simplify the code Shawn Lin
@ 2018-04-27 8:23 ` Shawn Lin
2018-04-27 8:23 ` [PATCH 4/9] PCI: aardvark: " Shawn Lin
` (6 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Shawn Lin @ 2018-04-27 8:23 UTC (permalink / raw)
To: Lorenzo Pieralisi, Bjorn Helgaas
Cc: linux-pci, Shawn Lin, Kishon Vijay Abraham I
Just avoid code duplication, but no functional change intended.
Cc: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
drivers/pci/dwc/pci-keystone-dw.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/pci/dwc/pci-keystone-dw.c b/drivers/pci/dwc/pci-keystone-dw.c
index 0682213..171198a 100644
--- a/drivers/pci/dwc/pci-keystone-dw.c
+++ b/drivers/pci/dwc/pci-keystone-dw.c
@@ -470,15 +470,11 @@ int __init ks_dw_pcie_host_init(struct keystone_pcie *ks_pcie,
ks_pcie->app = *res;
/* Create legacy IRQ domain */
- ks_pcie->legacy_irq_domain =
- irq_domain_add_linear(ks_pcie->legacy_intc_np,
- PCI_NUM_INTX,
+ ks_pcie->legacy_irq_domain = pci_alloc_intx_irqd(dev, ks_pcie, false,
&ks_dw_pcie_legacy_irq_domain_ops,
- NULL);
- if (!ks_pcie->legacy_irq_domain) {
- dev_err(dev, "Failed to add irq domain for legacy irqs\n");
- return -EINVAL;
- }
+ ks_pcie->legacy_intc_np);
+ if (IS_ERR(ks_pcie->legacy_irq_domain))
+ return PTR_ERR(ks_pcie->legacy_irq_domain);
return dw_pcie_host_init(pp);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 4/9] PCI: aardvark: Use pci_alloc_intx_irqd() helper to get irq domain for INTx
2018-04-27 8:22 [PATCH 0/9] Add new helper to allocate irq domain for hosts Shawn Lin
` (2 preceding siblings ...)
2018-04-27 8:23 ` [PATCH 3/9] PCI: keystone-dw: Use pci_alloc_intx_irqd() helper to get irq domain for INTx Shawn Lin
@ 2018-04-27 8:23 ` Shawn Lin
2018-04-27 8:23 ` [PATCH 5/9] PCI: faraday: " Shawn Lin
` (5 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Shawn Lin @ 2018-04-27 8:23 UTC (permalink / raw)
To: Lorenzo Pieralisi, Bjorn Helgaas; +Cc: linux-pci, Shawn Lin, Thomas Petazzoni
Just avoid code duplication, but no functional change intended.
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
drivers/pci/host/pci-aardvark.c | 24 +++++-------------------
1 file changed, 5 insertions(+), 19 deletions(-)
diff --git a/drivers/pci/host/pci-aardvark.c b/drivers/pci/host/pci-aardvark.c
index 9abf549..df02b9a 100644
--- a/drivers/pci/host/pci-aardvark.c
+++ b/drivers/pci/host/pci-aardvark.c
@@ -702,37 +702,23 @@ static void advk_pcie_remove_msi_irq_domain(struct advk_pcie *pcie)
static int advk_pcie_init_irq_domain(struct advk_pcie *pcie)
{
struct device *dev = &pcie->pdev->dev;
- struct device_node *node = dev->of_node;
- struct device_node *pcie_intc_node;
struct irq_chip *irq_chip;
- pcie_intc_node = of_get_next_child(node, NULL);
- if (!pcie_intc_node) {
- dev_err(dev, "No PCIe Intc node found\n");
- return -ENODEV;
- }
-
irq_chip = &pcie->irq_chip;
irq_chip->name = devm_kasprintf(dev, GFP_KERNEL, "%s-irq",
dev_name(dev));
- if (!irq_chip->name) {
- of_node_put(pcie_intc_node);
+ if (!irq_chip->name)
return -ENOMEM;
- }
irq_chip->irq_mask = advk_pcie_irq_mask;
irq_chip->irq_mask_ack = advk_pcie_irq_mask;
irq_chip->irq_unmask = advk_pcie_irq_unmask;
- pcie->irq_domain =
- irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX,
- &advk_pcie_irq_domain_ops, pcie);
- if (!pcie->irq_domain) {
- dev_err(dev, "Failed to get a INTx IRQ domain\n");
- of_node_put(pcie_intc_node);
- return -ENOMEM;
- }
+ pcie->irq_domain = pci_alloc_intx_irqd(dev, pcie, false,
+ &advk_pcie_irq_domain_ops, NULL);
+ if (IS_ERR(pcie->irq_domain))
+ return PTR_ERR(pcie->irq_domain);
return 0;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 5/9] PCI: faraday: Use pci_alloc_intx_irqd() helper to get irq domain for INTx
2018-04-27 8:22 [PATCH 0/9] Add new helper to allocate irq domain for hosts Shawn Lin
` (3 preceding siblings ...)
2018-04-27 8:23 ` [PATCH 4/9] PCI: aardvark: " Shawn Lin
@ 2018-04-27 8:23 ` Shawn Lin
2018-04-28 23:32 ` kbuild test robot
2018-04-27 8:24 ` [PATCH 6/9] PCI: altera: " Shawn Lin
` (4 subsequent siblings)
9 siblings, 1 reply; 17+ messages in thread
From: Shawn Lin @ 2018-04-27 8:23 UTC (permalink / raw)
To: Lorenzo Pieralisi, Bjorn Helgaas; +Cc: linux-pci, Shawn Lin
Just avoid code duplication, but no functional change intended.
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
drivers/pci/host/pci-ftpci100.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/pci/host/pci-ftpci100.c b/drivers/pci/host/pci-ftpci100.c
index 5008fd8..018e4f4 100644
--- a/drivers/pci/host/pci-ftpci100.c
+++ b/drivers/pci/host/pci-ftpci100.c
@@ -344,24 +344,19 @@ static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p)
int irq;
int i;
- if (!intc) {
- dev_err(p->dev, "missing child interrupt-controller node\n");
- return -EINVAL;
- }
+ p->irqdomain = pci_alloc_intx_irqd(p->dev, p, false,
+ &faraday_pci_irqdomain_ops, intc)
+ if (IS_ERR(p->irqdomain))
+ return PTR_ERR(p->irqdomain);
/* All PCI IRQs cascade off this one */
irq = of_irq_get(intc, 0);
if (irq <= 0) {
dev_err(p->dev, "failed to get parent IRQ\n");
+ irq_domain_remove(p->irqdomain);
return irq ?: -EINVAL;
}
- p->irqdomain = irq_domain_add_linear(intc, PCI_NUM_INTX,
- &faraday_pci_irqdomain_ops, p);
- if (!p->irqdomain) {
- dev_err(p->dev, "failed to create Gemini PCI IRQ domain\n");
- return -EINVAL;
- }
irq_set_chained_handler_and_data(irq, faraday_pci_irq_handler, p);
--
1.9.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 6/9] PCI: altera: Use pci_alloc_intx_irqd() helper to get irq domain for INTx
2018-04-27 8:22 [PATCH 0/9] Add new helper to allocate irq domain for hosts Shawn Lin
` (4 preceding siblings ...)
2018-04-27 8:23 ` [PATCH 5/9] PCI: faraday: " Shawn Lin
@ 2018-04-27 8:24 ` Shawn Lin
2018-04-27 8:24 ` [PATCH 7/9] PCI: mediatek: " Shawn Lin
` (3 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Shawn Lin @ 2018-04-27 8:24 UTC (permalink / raw)
To: Lorenzo Pieralisi, Bjorn Helgaas; +Cc: linux-pci, Shawn Lin, Ley Foon Tan
Just avoid code duplication, but no functional change intended.
Cc: Ley Foon Tan <ley.foon.tan@intel.com>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
drivers/pci/host/pcie-altera.c | 38 ++++----------------------------------
1 file changed, 4 insertions(+), 34 deletions(-)
diff --git a/drivers/pci/host/pcie-altera.c b/drivers/pci/host/pcie-altera.c
index a6af62e..a0fcf0f 100644
--- a/drivers/pci/host/pcie-altera.c
+++ b/drivers/pci/host/pcie-altera.c
@@ -441,19 +441,6 @@ static void altera_pcie_retrain(struct altera_pcie *pcie)
}
}
-static int altera_pcie_intx_map(struct irq_domain *domain, unsigned int irq,
- irq_hw_number_t hwirq)
-{
- irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq);
- irq_set_chip_data(irq, domain->host_data);
- return 0;
-}
-
-static const struct irq_domain_ops intx_domain_ops = {
- .map = altera_pcie_intx_map,
- .xlate = pci_irqd_intx_xlate,
-};
-
static void altera_pcie_isr(struct irq_desc *desc)
{
struct irq_chip *chip = irq_desc_get_chip(desc);
@@ -518,22 +505,6 @@ static int altera_pcie_parse_request_of_pci_ranges(struct altera_pcie *pcie)
return err;
}
-static int altera_pcie_init_irq_domain(struct altera_pcie *pcie)
-{
- struct device *dev = &pcie->pdev->dev;
- struct device_node *node = dev->of_node;
-
- /* Setup INTx */
- pcie->irq_domain = irq_domain_add_linear(node, PCI_NUM_INTX,
- &intx_domain_ops, pcie);
- if (!pcie->irq_domain) {
- dev_err(dev, "Failed to get a INTx IRQ domain\n");
- return -ENOMEM;
- }
-
- return 0;
-}
-
static int altera_pcie_parse_dt(struct altera_pcie *pcie)
{
struct device *dev = &pcie->pdev->dev;
@@ -591,11 +562,10 @@ static int altera_pcie_probe(struct platform_device *pdev)
return ret;
}
- ret = altera_pcie_init_irq_domain(pcie);
- if (ret) {
- dev_err(dev, "Failed creating IRQ Domain\n");
- return ret;
- }
+ pcie->irq_domain = pci_alloc_intx_irqd(dev, pcie, true, NULL,
+ dev->of_node);
+ if (IS_ERR(pcie->irq_domain))
+ return PTR_ERR(pcie->irq_domain);
/* clear all interrupts */
cra_writel(pcie, P2A_INT_STS_ALL, P2A_INT_STATUS);
--
1.9.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 7/9] PCI: mediatek: Use pci_alloc_intx_irqd() helper to get irq domain for INTx
2018-04-27 8:22 [PATCH 0/9] Add new helper to allocate irq domain for hosts Shawn Lin
` (5 preceding siblings ...)
2018-04-27 8:24 ` [PATCH 6/9] PCI: altera: " Shawn Lin
@ 2018-04-27 8:24 ` Shawn Lin
2018-04-27 8:24 ` [PATCH 8/9] PCI: xilinx-nwl: " Shawn Lin
` (2 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Shawn Lin @ 2018-04-27 8:24 UTC (permalink / raw)
To: Lorenzo Pieralisi, Bjorn Helgaas; +Cc: linux-pci, Shawn Lin, Ryder Lee
Just avoid code duplication, but no functional change intended.
Cc: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
drivers/pci/host/pcie-mediatek.c | 29 +++--------------------------
1 file changed, 3 insertions(+), 26 deletions(-)
diff --git a/drivers/pci/host/pcie-mediatek.c b/drivers/pci/host/pcie-mediatek.c
index a8b20c5..e977a43 100644
--- a/drivers/pci/host/pcie-mediatek.c
+++ b/drivers/pci/host/pcie-mediatek.c
@@ -541,38 +541,15 @@ static void mtk_pcie_enable_msi(struct mtk_pcie_port *port)
writel(val, port->base + PCIE_INT_MASK);
}
-static int mtk_pcie_intx_map(struct irq_domain *domain, unsigned int irq,
- irq_hw_number_t hwirq)
-{
- irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq);
- irq_set_chip_data(irq, domain->host_data);
-
- return 0;
-}
-
-static const struct irq_domain_ops intx_domain_ops = {
- .map = mtk_pcie_intx_map,
-};
-
static int mtk_pcie_init_irq_domain(struct mtk_pcie_port *port,
struct device_node *node)
{
struct device *dev = port->pcie->dev;
- struct device_node *pcie_intc_node;
- /* Setup INTx */
- pcie_intc_node = of_get_next_child(node, NULL);
- if (!pcie_intc_node) {
- dev_err(dev, "no PCIe Intc node found\n");
- return -ENODEV;
- }
+ port->irq_domain = pci_alloc_intx_irqd(dev, port, false, NULL, NULL);
+ if (IS_ERR(port->irq_domain))
+ return PTR_ERR(port->irq_domain);
- port->irq_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX,
- &intx_domain_ops, port);
- if (!port->irq_domain) {
- dev_err(dev, "failed to get INTx IRQ domain\n");
- return -ENODEV;
- }
if (IS_ENABLED(CONFIG_PCI_MSI)) {
port->msi_domain = irq_domain_add_linear(node, MTK_MSI_IRQS_NUM,
--
1.9.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 8/9] PCI: xilinx-nwl: Use pci_alloc_intx_irqd() helper to get irq domain for INTx
2018-04-27 8:22 [PATCH 0/9] Add new helper to allocate irq domain for hosts Shawn Lin
` (6 preceding siblings ...)
2018-04-27 8:24 ` [PATCH 7/9] PCI: mediatek: " Shawn Lin
@ 2018-04-27 8:24 ` Shawn Lin
2018-04-27 8:25 ` [PATCH 9/9] PCI: xilinx: " Shawn Lin
2018-04-30 10:19 ` [PATCH 0/9] Add new helper to allocate irq domain for hosts Lorenzo Pieralisi
9 siblings, 0 replies; 17+ messages in thread
From: Shawn Lin @ 2018-04-27 8:24 UTC (permalink / raw)
To: Lorenzo Pieralisi, Bjorn Helgaas; +Cc: linux-pci, Shawn Lin
Just avoid code duplication, but no functional change intended.
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
drivers/pci/host/pcie-xilinx-nwl.c | 21 ++++-----------------
1 file changed, 4 insertions(+), 17 deletions(-)
diff --git a/drivers/pci/host/pcie-xilinx-nwl.c b/drivers/pci/host/pcie-xilinx-nwl.c
index 4839ae5..1bb77c0 100644
--- a/drivers/pci/host/pcie-xilinx-nwl.c
+++ b/drivers/pci/host/pcie-xilinx-nwl.c
@@ -544,24 +544,11 @@ static int nwl_pcie_init_msi_irq_domain(struct nwl_pcie *pcie)
static int nwl_pcie_init_irq_domain(struct nwl_pcie *pcie)
{
struct device *dev = pcie->dev;
- struct device_node *node = dev->of_node;
- struct device_node *legacy_intc_node;
-
- legacy_intc_node = of_get_next_child(node, NULL);
- if (!legacy_intc_node) {
- dev_err(dev, "No legacy intc node found\n");
- return -EINVAL;
- }
- pcie->legacy_irq_domain = irq_domain_add_linear(legacy_intc_node,
- PCI_NUM_INTX,
- &legacy_domain_ops,
- pcie);
-
- if (!pcie->legacy_irq_domain) {
- dev_err(dev, "failed to create IRQ domain\n");
- return -ENOMEM;
- }
+ pcie->legacy_irq_domain = pci_alloc_intx_irqd(dev, pcie, false,
+ &legacy_domain_ops, NULL);
+ if (IS_ERR(pcie->legacy_irq_domain))
+ return PTR_ERR(pcie->legacy_irq_domain);
raw_spin_lock_init(&pcie->leg_mask_lock);
nwl_pcie_init_msi_irq_domain(pcie);
--
1.9.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 9/9] PCI: xilinx: Use pci_alloc_intx_irqd() helper to get irq domain for INTx
2018-04-27 8:22 [PATCH 0/9] Add new helper to allocate irq domain for hosts Shawn Lin
` (7 preceding siblings ...)
2018-04-27 8:24 ` [PATCH 8/9] PCI: xilinx-nwl: " Shawn Lin
@ 2018-04-27 8:25 ` Shawn Lin
2018-04-30 10:19 ` [PATCH 0/9] Add new helper to allocate irq domain for hosts Lorenzo Pieralisi
9 siblings, 0 replies; 17+ messages in thread
From: Shawn Lin @ 2018-04-27 8:25 UTC (permalink / raw)
To: Lorenzo Pieralisi, Bjorn Helgaas; +Cc: linux-pci, Shawn Lin
Just avoid code duplication, but no functional change intended.
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
drivers/pci/host/pcie-xilinx.c | 43 +++---------------------------------------
1 file changed, 3 insertions(+), 40 deletions(-)
diff --git a/drivers/pci/host/pcie-xilinx.c b/drivers/pci/host/pcie-xilinx.c
index 0ad188e..905668a 100644
--- a/drivers/pci/host/pcie-xilinx.c
+++ b/drivers/pci/host/pcie-xilinx.c
@@ -344,31 +344,6 @@ static void xilinx_pcie_enable_msi(struct xilinx_pcie_port *port)
pcie_write(port, msg_addr, XILINX_PCIE_REG_MSIBASE2);
}
-/* INTx Functions */
-
-/**
- * xilinx_pcie_intx_map - Set the handler for the INTx and mark IRQ as valid
- * @domain: IRQ domain
- * @irq: Virtual IRQ number
- * @hwirq: HW interrupt number
- *
- * Return: Always returns 0.
- */
-static int xilinx_pcie_intx_map(struct irq_domain *domain, unsigned int irq,
- irq_hw_number_t hwirq)
-{
- irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq);
- irq_set_chip_data(irq, domain->host_data);
-
- return 0;
-}
-
-/* INTx IRQ Domain operations */
-static const struct irq_domain_ops intx_domain_ops = {
- .map = xilinx_pcie_intx_map,
- .xlate = pci_irqd_intx_xlate,
-};
-
/* PCIe HW Functions */
/**
@@ -495,22 +470,10 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie_port *port)
{
struct device *dev = port->dev;
struct device_node *node = dev->of_node;
- struct device_node *pcie_intc_node;
- /* Setup INTx */
- pcie_intc_node = of_get_next_child(node, NULL);
- if (!pcie_intc_node) {
- dev_err(dev, "No PCIe Intc node found\n");
- return -ENODEV;
- }
-
- port->leg_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX,
- &intx_domain_ops,
- port);
- if (!port->leg_domain) {
- dev_err(dev, "Failed to get a INTx IRQ domain\n");
- return -ENODEV;
- }
+ port->leg_domain = pci_alloc_intx_irqd(dev, port, true, NULL, NULL);
+ if (IS_ERR(port->leg_domain))
+ return PTR_ERR(port->leg_domain);
/* Setup MSI */
if (IS_ENABLED(CONFIG_PCI_MSI)) {
--
1.9.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 1/9] PCI: Add new helper for allocating irq domain for INTx
2018-04-27 8:22 ` [PATCH 1/9] PCI: Add new helper for allocating irq domain for INTx Shawn Lin
@ 2018-04-27 17:18 ` Bjorn Helgaas
2018-04-28 0:44 ` Shawn Lin
2018-04-28 22:52 ` kbuild test robot
2018-04-28 23:08 ` kbuild test robot
2 siblings, 1 reply; 17+ messages in thread
From: Bjorn Helgaas @ 2018-04-27 17:18 UTC (permalink / raw)
To: Shawn Lin; +Cc: Lorenzo Pieralisi, Bjorn Helgaas, linux-pci
s/PCI: Add new helper for allocating irq domain for INTx/
PCI: Add pci_alloc_intx_irqd() for allocating IRQ domain
On Fri, Apr 27, 2018 at 04:22:47PM +0800, Shawn Lin wrote:
> It seems host drivers which allocate irq domain for INTx
s/irq/IRQ/
> and the related code block looks highly similar to each other.
> Add a new helper, pci_alloc_intx_irqd(), to avoid code duplication
> as much as possible.
>
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---
>
> include/linux/pci.h | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 74 insertions(+)
>
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 73178a2..68a1994 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -31,6 +31,8 @@
> #include <linux/device.h>
> #include <linux/interrupt.h>
> #include <linux/io.h>
> +#include <linux/irq.h>
> +#include <linux/of_irq.h>
> #include <linux/resource_ext.h>
> #include <uapi/linux/pci.h>
>
> @@ -1449,6 +1451,74 @@ static inline int pci_irqd_intx_xlate(struct irq_domain *d,
> return 0;
> }
>
> +static int pcie_intx_map(struct irq_domain *domain, unsigned int irq,
> + irq_hw_number_t hwirq)
> +{
> + irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq);
> + irq_set_chip_data(irq, domain->host_data);
> +
> + return 0;
> +}
> +
> +static struct irq_domain_ops pci_intx_domain_ops = {
> + .map = pcie_intx_map,
> +};
> +
> +/**
> + * pci_alloc_intx_irqd() - PCI helper for allocating INTx irq domain
s/PCI helper for allocating INTx irq domain/
Allocate INTx IRQ domain
> + * @dev: device associated with the PCI controller.
> + * @host: pointer to host specific data struct
> + * @general_xlate: flag for whether use pci_irqd_intx_xlate() helper
> + * @intx_domain_ops: pointer to driver specific struct irq_domain_ops
> + * @local_intc: pointer to driver specific interrupt controller node
> + *
> + * A simple helper for drivers to allocate irq domain for INTx. If
> + * intx_domain_ops is NULL, use pci_intx_domain_ops by defalut. And if
> + * local_intc is present, then use it firstly, otherwise, fallback to get
> + * interrupt controller node from @dev.
s/irq/IRQ/
s/defalut/default/
> + * Returns valid pointer of struct irq_domain on success, or PTR_ERR(-EINVAL)
> + * if failure occurred.
> + */
> +static __maybe_unused struct irq_domain *pci_alloc_intx_irqd(struct device *dev,
> + void *host, bool general_xlate,
> + const struct irq_domain_ops *intx_domain_ops,
> + struct device_node *local_intc)
Why is this in the header file? This is not a performance path and I
don't want to deal with this __maybe_unused stuff.
> +{
> + struct device_node *intc = local_intc;
> + struct irq_domain *domain;
> + const struct irq_domain_ops *irqd_ops;
> + bool need_put = false;
> +
> + if (!intc) {
> + intc = of_get_next_child(dev->of_node, NULL);
> + if (!intc) {
> + dev_err(dev, "missing child interrupt-controller node\n");
> + return ERR_PTR(-EINVAL);
> + }
> + need_put = true;
> + }
> +
> + if (intx_domain_ops) {
> + irqd_ops = intx_domain_ops;
> + } else {
> + if (general_xlate)
> + pci_intx_domain_ops.xlate = &pci_irqd_intx_xlate;
> + irqd_ops = &pci_intx_domain_ops;
> + }
> +
> + domain = irq_domain_add_linear(intc, PCI_NUM_INTX,
> + irqd_ops, host);
> + if (!domain) {
> + dev_err(dev, "failed to get a INTx IRQ domain\n");
> + if (need_put)
> + of_node_put(intc);
> + return ERR_PTR(-EINVAL);
> + }
> +
> + return domain;
> +}
> +
> #ifdef CONFIG_PCIEPORTBUS
> extern bool pcie_ports_disabled;
> #else
> @@ -1683,6 +1753,10 @@ static inline int pci_irqd_intx_xlate(struct irq_domain *d,
> unsigned long *out_hwirq,
> unsigned int *out_type)
> { return -EINVAL; }
> +
> +static __maybe_unused struct irq_domain *pci_alloc_intx_irqd(struct device *dev,
> + void *host, bool general_xlate, const struct irq_domain_ops *ops)
> +{ return ERR_PTR(-EINVAL); }
> #endif /* CONFIG_PCI */
>
> /* Include architecture-dependent settings and functions */
> --
> 1.9.1
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/9] PCI: Add new helper for allocating irq domain for INTx
2018-04-27 17:18 ` Bjorn Helgaas
@ 2018-04-28 0:44 ` Shawn Lin
0 siblings, 0 replies; 17+ messages in thread
From: Shawn Lin @ 2018-04-28 0:44 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: shawn.lin, Lorenzo Pieralisi, Bjorn Helgaas, linux-pci
Hi Bjorn,
On 2018/4/28 1:18, Bjorn Helgaas wrote:
> s/PCI: Add new helper for allocating irq domain for INTx/
> PCI: Add pci_alloc_intx_irqd() for allocating IRQ domain
>
> On Fri, Apr 27, 2018 at 04:22:47PM +0800, Shawn Lin wrote:
>> It seems host drivers which allocate irq domain for INTx
>
> s/irq/IRQ/
>
>> and the related code block looks highly similar to each other.
>> Add a new helper, pci_alloc_intx_irqd(), to avoid code duplication
>> as much as possible.
>>
>> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
>> ---
>>
>> include/linux/pci.h | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 74 insertions(+)
>>
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index 73178a2..68a1994 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -31,6 +31,8 @@
>> #include <linux/device.h>
>> #include <linux/interrupt.h>
>> #include <linux/io.h>
>> +#include <linux/irq.h>
>> +#include <linux/of_irq.h>
>> #include <linux/resource_ext.h>
>> #include <uapi/linux/pci.h>
>>
>> @@ -1449,6 +1451,74 @@ static inline int pci_irqd_intx_xlate(struct irq_domain *d,
>> return 0;
>> }
>>
>> +static int pcie_intx_map(struct irq_domain *domain, unsigned int irq,
>> + irq_hw_number_t hwirq)
>> +{
>> + irq_set_chip_and_handler(irq, &dummy_irq_chip, handle_simple_irq);
>> + irq_set_chip_data(irq, domain->host_data);
>> +
>> + return 0;
>> +}
>> +
>> +static struct irq_domain_ops pci_intx_domain_ops = {
>> + .map = pcie_intx_map,
>> +};
>> +
>> +/**
>> + * pci_alloc_intx_irqd() - PCI helper for allocating INTx irq domain
>
> s/PCI helper for allocating INTx irq domain/
> Allocate INTx IRQ domain
>
>> + * @dev: device associated with the PCI controller.
>> + * @host: pointer to host specific data struct
>> + * @general_xlate: flag for whether use pci_irqd_intx_xlate() helper
>> + * @intx_domain_ops: pointer to driver specific struct irq_domain_ops
>> + * @local_intc: pointer to driver specific interrupt controller node
>> + *
>> + * A simple helper for drivers to allocate irq domain for INTx. If
>> + * intx_domain_ops is NULL, use pci_intx_domain_ops by defalut. And if
>> + * local_intc is present, then use it firstly, otherwise, fallback to get
>> + * interrupt controller node from @dev.
>
> s/irq/IRQ/
> s/defalut/default/
>
>> + * Returns valid pointer of struct irq_domain on success, or PTR_ERR(-EINVAL)
>> + * if failure occurred.
>> + */
>> +static __maybe_unused struct irq_domain *pci_alloc_intx_irqd(struct device *dev,
>> + void *host, bool general_xlate,
>> + const struct irq_domain_ops *intx_domain_ops,
>> + struct device_node *local_intc)
>
> Why is this in the header file? This is not a performance path and I
> don't want to deal with this __maybe_unused stuff.
Ah, I saw pci_irqd_intx_xlate() was here, and instinctively keep the
code close to it. Will move it to C file in v2.
>
>> +{
>> + struct device_node *intc = local_intc;
>> + struct irq_domain *domain;
>> + const struct irq_domain_ops *irqd_ops;
>> + bool need_put = false;
>> +
>> + if (!intc) {
>> + intc = of_get_next_child(dev->of_node, NULL);
>> + if (!intc) {
>> + dev_err(dev, "missing child interrupt-controller node\n");
>> + return ERR_PTR(-EINVAL);
>> + }
>> + need_put = true;
>> + }
>> +
>> + if (intx_domain_ops) {
>> + irqd_ops = intx_domain_ops;
>> + } else {
>> + if (general_xlate)
>> + pci_intx_domain_ops.xlate = &pci_irqd_intx_xlate;
>> + irqd_ops = &pci_intx_domain_ops;
>> + }
>> +
>> + domain = irq_domain_add_linear(intc, PCI_NUM_INTX,
>> + irqd_ops, host);
>> + if (!domain) {
>> + dev_err(dev, "failed to get a INTx IRQ domain\n");
>> + if (need_put)
>> + of_node_put(intc);
>> + return ERR_PTR(-EINVAL);
>> + }
>> +
>> + return domain;
>> +}
>> +
>> #ifdef CONFIG_PCIEPORTBUS
>> extern bool pcie_ports_disabled;
>> #else
>> @@ -1683,6 +1753,10 @@ static inline int pci_irqd_intx_xlate(struct irq_domain *d,
>> unsigned long *out_hwirq,
>> unsigned int *out_type)
>> { return -EINVAL; }
>> +
>> +static __maybe_unused struct irq_domain *pci_alloc_intx_irqd(struct device *dev,
>> + void *host, bool general_xlate, const struct irq_domain_ops *ops)
>> +{ return ERR_PTR(-EINVAL); }
>> #endif /* CONFIG_PCI */
>>
>> /* Include architecture-dependent settings and functions */
>> --
>> 1.9.1
>>
>>
>
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/9] PCI: Add new helper for allocating irq domain for INTx
2018-04-27 8:22 ` [PATCH 1/9] PCI: Add new helper for allocating irq domain for INTx Shawn Lin
2018-04-27 17:18 ` Bjorn Helgaas
@ 2018-04-28 22:52 ` kbuild test robot
2018-04-28 23:08 ` kbuild test robot
2 siblings, 0 replies; 17+ messages in thread
From: kbuild test robot @ 2018-04-28 22:52 UTC (permalink / raw)
To: Shawn Lin
Cc: kbuild-all, Lorenzo Pieralisi, Bjorn Helgaas, linux-pci, Shawn Lin
[-- Attachment #1: Type: text/plain, Size: 3603 bytes --]
Hi Shawn,
I love your patch! Yet something to improve:
[auto build test ERROR on pci/next]
[also build test ERROR on v4.17-rc2 next-20180426]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Shawn-Lin/Add-new-helper-to-allocate-irq-domain-for-hosts/20180429-053656
base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next
config: i386-alldefconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All error/warnings (new ones prefixed by >>):
In file included from arch/x86//kernel/cpu/mtrr/main.c:46:0:
include/linux/pci.h: In function 'pci_alloc_intx_irqd':
>> include/linux/pci.h:1510:11: error: implicit declaration of function 'irq_domain_add_linear'; did you mean 'irq_domain_get_of_node'? [-Werror=implicit-function-declaration]
domain = irq_domain_add_linear(intc, PCI_NUM_INTX,
^~~~~~~~~~~~~~~~~~~~~
irq_domain_get_of_node
>> include/linux/pci.h:1510:9: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
domain = irq_domain_add_linear(intc, PCI_NUM_INTX,
^
cc1: some warnings being treated as errors
vim +1510 include/linux/pci.h
1466
1467 /**
1468 * pci_alloc_intx_irqd() - PCI helper for allocating INTx irq domain
1469 * @dev: device associated with the PCI controller.
1470 * @host: pointer to host specific data struct
1471 * @general_xlate: flag for whether use pci_irqd_intx_xlate() helper
1472 * @intx_domain_ops: pointer to driver specific struct irq_domain_ops
1473 * @local_intc: pointer to driver specific interrupt controller node
1474 *
1475 * A simple helper for drivers to allocate irq domain for INTx. If
1476 * intx_domain_ops is NULL, use pci_intx_domain_ops by defalut. And if
1477 * local_intc is present, then use it firstly, otherwise, fallback to get
1478 * interrupt controller node from @dev.
1479 *
1480 * Returns valid pointer of struct irq_domain on success, or PTR_ERR(-EINVAL)
1481 * if failure occurred.
1482 */
1483 static __maybe_unused struct irq_domain *pci_alloc_intx_irqd(struct device *dev,
1484 void *host, bool general_xlate,
1485 const struct irq_domain_ops *intx_domain_ops,
1486 struct device_node *local_intc)
1487 {
1488 struct device_node *intc = local_intc;
1489 struct irq_domain *domain;
1490 const struct irq_domain_ops *irqd_ops;
1491 bool need_put = false;
1492
1493 if (!intc) {
1494 intc = of_get_next_child(dev->of_node, NULL);
1495 if (!intc) {
1496 dev_err(dev, "missing child interrupt-controller node\n");
1497 return ERR_PTR(-EINVAL);
1498 }
1499 need_put = true;
1500 }
1501
1502 if (intx_domain_ops) {
1503 irqd_ops = intx_domain_ops;
1504 } else {
1505 if (general_xlate)
1506 pci_intx_domain_ops.xlate = &pci_irqd_intx_xlate;
1507 irqd_ops = &pci_intx_domain_ops;
1508 }
1509
> 1510 domain = irq_domain_add_linear(intc, PCI_NUM_INTX,
1511 irqd_ops, host);
1512 if (!domain) {
1513 dev_err(dev, "failed to get a INTx IRQ domain\n");
1514 if (need_put)
1515 of_node_put(intc);
1516 return ERR_PTR(-EINVAL);
1517 }
1518
1519 return domain;
1520 }
1521
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 10166 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/9] PCI: Add new helper for allocating irq domain for INTx
2018-04-27 8:22 ` [PATCH 1/9] PCI: Add new helper for allocating irq domain for INTx Shawn Lin
2018-04-27 17:18 ` Bjorn Helgaas
2018-04-28 22:52 ` kbuild test robot
@ 2018-04-28 23:08 ` kbuild test robot
2 siblings, 0 replies; 17+ messages in thread
From: kbuild test robot @ 2018-04-28 23:08 UTC (permalink / raw)
To: Shawn Lin
Cc: kbuild-all, Lorenzo Pieralisi, Bjorn Helgaas, linux-pci, Shawn Lin
[-- Attachment #1: Type: text/plain, Size: 3735 bytes --]
Hi Shawn,
I love your patch! Yet something to improve:
[auto build test ERROR on pci/next]
[also build test ERROR on v4.17-rc2 next-20180426]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Shawn-Lin/Add-new-helper-to-allocate-irq-domain-for-hosts/20180429-053656
base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next
config: sparc-defconfig (attached as .config)
compiler: sparc-linux-gcc (GCC) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sparc
All errors (new ones prefixed by >>):
In file included from arch/sparc/kernel/ioport.c:37:0:
include/linux/pci.h: In function 'pci_alloc_intx_irqd':
include/linux/pci.h:1510:11: error: implicit declaration of function 'irq_domain_add_linear'; did you mean 'irq_domain_get_of_node'? [-Werror=implicit-function-declaration]
domain = irq_domain_add_linear(intc, PCI_NUM_INTX,
^~~~~~~~~~~~~~~~~~~~~
irq_domain_get_of_node
>> include/linux/pci.h:1510:9: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
domain = irq_domain_add_linear(intc, PCI_NUM_INTX,
^
cc1: all warnings being treated as errors
vim +1510 include/linux/pci.h
1466
1467 /**
1468 * pci_alloc_intx_irqd() - PCI helper for allocating INTx irq domain
1469 * @dev: device associated with the PCI controller.
1470 * @host: pointer to host specific data struct
1471 * @general_xlate: flag for whether use pci_irqd_intx_xlate() helper
1472 * @intx_domain_ops: pointer to driver specific struct irq_domain_ops
1473 * @local_intc: pointer to driver specific interrupt controller node
1474 *
1475 * A simple helper for drivers to allocate irq domain for INTx. If
1476 * intx_domain_ops is NULL, use pci_intx_domain_ops by defalut. And if
1477 * local_intc is present, then use it firstly, otherwise, fallback to get
1478 * interrupt controller node from @dev.
1479 *
1480 * Returns valid pointer of struct irq_domain on success, or PTR_ERR(-EINVAL)
1481 * if failure occurred.
1482 */
1483 static __maybe_unused struct irq_domain *pci_alloc_intx_irqd(struct device *dev,
1484 void *host, bool general_xlate,
1485 const struct irq_domain_ops *intx_domain_ops,
1486 struct device_node *local_intc)
1487 {
1488 struct device_node *intc = local_intc;
1489 struct irq_domain *domain;
1490 const struct irq_domain_ops *irqd_ops;
1491 bool need_put = false;
1492
1493 if (!intc) {
1494 intc = of_get_next_child(dev->of_node, NULL);
1495 if (!intc) {
1496 dev_err(dev, "missing child interrupt-controller node\n");
1497 return ERR_PTR(-EINVAL);
1498 }
1499 need_put = true;
1500 }
1501
1502 if (intx_domain_ops) {
1503 irqd_ops = intx_domain_ops;
1504 } else {
1505 if (general_xlate)
1506 pci_intx_domain_ops.xlate = &pci_irqd_intx_xlate;
1507 irqd_ops = &pci_intx_domain_ops;
1508 }
1509
> 1510 domain = irq_domain_add_linear(intc, PCI_NUM_INTX,
1511 irqd_ops, host);
1512 if (!domain) {
1513 dev_err(dev, "failed to get a INTx IRQ domain\n");
1514 if (need_put)
1515 of_node_put(intc);
1516 return ERR_PTR(-EINVAL);
1517 }
1518
1519 return domain;
1520 }
1521
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 11531 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 5/9] PCI: faraday: Use pci_alloc_intx_irqd() helper to get irq domain for INTx
2018-04-27 8:23 ` [PATCH 5/9] PCI: faraday: " Shawn Lin
@ 2018-04-28 23:32 ` kbuild test robot
0 siblings, 0 replies; 17+ messages in thread
From: kbuild test robot @ 2018-04-28 23:32 UTC (permalink / raw)
To: Shawn Lin
Cc: kbuild-all, Lorenzo Pieralisi, Bjorn Helgaas, linux-pci, Shawn Lin
[-- Attachment #1: Type: text/plain, Size: 2086 bytes --]
Hi Shawn,
I love your patch! Yet something to improve:
[auto build test ERROR on pci/next]
[also build test ERROR on v4.17-rc2 next-20180426]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Shawn-Lin/Add-new-helper-to-allocate-irq-domain-for-hosts/20180429-053656
base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm
All errors (new ones prefixed by >>):
drivers/pci/host/pci-ftpci100.c: In function 'faraday_pci_setup_cascaded_irq':
>> drivers/pci/host/pci-ftpci100.c:349:2: error: expected ';' before 'if'
if (IS_ERR(p->irqdomain))
^~
vim +349 drivers/pci/host/pci-ftpci100.c
340
341 static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p)
342 {
343 struct device_node *intc = of_get_next_child(p->dev->of_node, NULL);
344 int irq;
345 int i;
346
347 p->irqdomain = pci_alloc_intx_irqd(p->dev, p, false,
348 &faraday_pci_irqdomain_ops, intc)
> 349 if (IS_ERR(p->irqdomain))
350 return PTR_ERR(p->irqdomain);
351
352 /* All PCI IRQs cascade off this one */
353 irq = of_irq_get(intc, 0);
354 if (irq <= 0) {
355 dev_err(p->dev, "failed to get parent IRQ\n");
356 irq_domain_remove(p->irqdomain);
357 return irq ?: -EINVAL;
358 }
359
360
361 irq_set_chained_handler_and_data(irq, faraday_pci_irq_handler, p);
362
363 for (i = 0; i < 4; i++)
364 irq_create_mapping(p->irqdomain, i);
365
366 return 0;
367 }
368
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 65221 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 0/9] Add new helper to allocate irq domain for hosts
2018-04-27 8:22 [PATCH 0/9] Add new helper to allocate irq domain for hosts Shawn Lin
` (8 preceding siblings ...)
2018-04-27 8:25 ` [PATCH 9/9] PCI: xilinx: " Shawn Lin
@ 2018-04-30 10:19 ` Lorenzo Pieralisi
2018-05-02 0:59 ` Shawn Lin
9 siblings, 1 reply; 17+ messages in thread
From: Lorenzo Pieralisi @ 2018-04-30 10:19 UTC (permalink / raw)
To: Shawn Lin; +Cc: Bjorn Helgaas, linux-pci
On Fri, Apr 27, 2018 at 04:22:02PM +0800, Shawn Lin wrote:
>
> Hi Bjorn and Lorenzo,
>
> PCI drivers use highly similar code block to allocate irq domain which
> leads to code duplication than expected. This patchset adds a new helper,
> pci_alloc_intx_irqd(), to avoid that as much as possible. Just leave
> pcie-rockchip out now as it's under re-construct and will add incremental
> patch for it if this series looks ok and the pcie-rockchip ongoing patches
> got merge.
Is this patch series v1 of:
https://patchwork.ozlabs.org/patch/906006/
?
Thanks,
Lorenzo
>
>
>
>
> Shawn Lin (9):
> PCI: Add new helper for allocating irq domain for INTx
> PCI: dra7xx: Use pci_alloc_intx_irqd() helper to simplify the code
> PCI: keystone-dw: Use pci_alloc_intx_irqd() helper to get irq domain
> for INTx
> PCI: aardvark: Use pci_alloc_intx_irqd() helper to get irq domain for
> INTx
> PCI: faraday: Use pci_alloc_intx_irqd() helper to get irq domain for
> INTx
> PCI: altera: Use pci_alloc_intx_irqd() helper to get irq domain for
> INTx
> PCI: mediatek: Use pci_alloc_intx_irqd() helper to get irq domain for
> INTx
> PCI: xilinx-nwl: Use pci_alloc_intx_irqd() helper to get irq domain
> for INTx
> PCI: xilinx: Use pci_alloc_intx_irqd() helper to get irq domain for
> INTx
>
> drivers/pci/dwc/pci-dra7xx.c | 41 ++-------------------
> drivers/pci/dwc/pci-keystone-dw.c | 12 +++----
> drivers/pci/host/pci-aardvark.c | 24 +++----------
> drivers/pci/host/pci-ftpci100.c | 15 +++-----
> drivers/pci/host/pcie-altera.c | 38 +++-----------------
> drivers/pci/host/pcie-mediatek.c | 29 ++-------------
> drivers/pci/host/pcie-xilinx-nwl.c | 21 +++--------
> drivers/pci/host/pcie-xilinx.c | 43 ++--------------------
> include/linux/pci.h | 74 ++++++++++++++++++++++++++++++++++++++
> 9 files changed, 104 insertions(+), 193 deletions(-)
>
> --
> 1.9.1
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 0/9] Add new helper to allocate irq domain for hosts
2018-04-30 10:19 ` [PATCH 0/9] Add new helper to allocate irq domain for hosts Lorenzo Pieralisi
@ 2018-05-02 0:59 ` Shawn Lin
0 siblings, 0 replies; 17+ messages in thread
From: Shawn Lin @ 2018-05-02 0:59 UTC (permalink / raw)
To: Lorenzo Pieralisi; +Cc: shawn.lin, Bjorn Helgaas, linux-pci
Hi Lorenzo,
On 2018/4/30 18:19, Lorenzo Pieralisi wrote:
> On Fri, Apr 27, 2018 at 04:22:02PM +0800, Shawn Lin wrote:
>>
>> Hi Bjorn and Lorenzo,
>>
>> PCI drivers use highly similar code block to allocate irq domain which
>> leads to code duplication than expected. This patchset adds a new helper,
>> pci_alloc_intx_irqd(), to avoid that as much as possible. Just leave
>> pcie-rockchip out now as it's under re-construct and will add incremental
>> patch for it if this series looks ok and the pcie-rockchip ongoing patches
>> got merge.
>
> Is this patch series v1 of:
>
> https://patchwork.ozlabs.org/patch/906006/
>
> ?
Yes.
>
> Thanks,
> Lorenzo
>
>>
>>
>>
>>
>> Shawn Lin (9):
>> PCI: Add new helper for allocating irq domain for INTx
>> PCI: dra7xx: Use pci_alloc_intx_irqd() helper to simplify the code
>> PCI: keystone-dw: Use pci_alloc_intx_irqd() helper to get irq domain
>> for INTx
>> PCI: aardvark: Use pci_alloc_intx_irqd() helper to get irq domain for
>> INTx
>> PCI: faraday: Use pci_alloc_intx_irqd() helper to get irq domain for
>> INTx
>> PCI: altera: Use pci_alloc_intx_irqd() helper to get irq domain for
>> INTx
>> PCI: mediatek: Use pci_alloc_intx_irqd() helper to get irq domain for
>> INTx
>> PCI: xilinx-nwl: Use pci_alloc_intx_irqd() helper to get irq domain
>> for INTx
>> PCI: xilinx: Use pci_alloc_intx_irqd() helper to get irq domain for
>> INTx
>>
>> drivers/pci/dwc/pci-dra7xx.c | 41 ++-------------------
>> drivers/pci/dwc/pci-keystone-dw.c | 12 +++----
>> drivers/pci/host/pci-aardvark.c | 24 +++----------
>> drivers/pci/host/pci-ftpci100.c | 15 +++-----
>> drivers/pci/host/pcie-altera.c | 38 +++-----------------
>> drivers/pci/host/pcie-mediatek.c | 29 ++-------------
>> drivers/pci/host/pcie-xilinx-nwl.c | 21 +++--------
>> drivers/pci/host/pcie-xilinx.c | 43 ++--------------------
>> include/linux/pci.h | 74 ++++++++++++++++++++++++++++++++++++++
>> 9 files changed, 104 insertions(+), 193 deletions(-)
>>
>> --
>> 1.9.1
>>
>>
>
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2018-05-02 0:59 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-27 8:22 [PATCH 0/9] Add new helper to allocate irq domain for hosts Shawn Lin
2018-04-27 8:22 ` [PATCH 1/9] PCI: Add new helper for allocating irq domain for INTx Shawn Lin
2018-04-27 17:18 ` Bjorn Helgaas
2018-04-28 0:44 ` Shawn Lin
2018-04-28 22:52 ` kbuild test robot
2018-04-28 23:08 ` kbuild test robot
2018-04-27 8:22 ` [PATCH 2/9] PCI: dra7xx: Use pci_alloc_intx_irqd() helper to simplify the code Shawn Lin
2018-04-27 8:23 ` [PATCH 3/9] PCI: keystone-dw: Use pci_alloc_intx_irqd() helper to get irq domain for INTx Shawn Lin
2018-04-27 8:23 ` [PATCH 4/9] PCI: aardvark: " Shawn Lin
2018-04-27 8:23 ` [PATCH 5/9] PCI: faraday: " Shawn Lin
2018-04-28 23:32 ` kbuild test robot
2018-04-27 8:24 ` [PATCH 6/9] PCI: altera: " Shawn Lin
2018-04-27 8:24 ` [PATCH 7/9] PCI: mediatek: " Shawn Lin
2018-04-27 8:24 ` [PATCH 8/9] PCI: xilinx-nwl: " Shawn Lin
2018-04-27 8:25 ` [PATCH 9/9] PCI: xilinx: " Shawn Lin
2018-04-30 10:19 ` [PATCH 0/9] Add new helper to allocate irq domain for hosts Lorenzo Pieralisi
2018-05-02 0:59 ` Shawn Lin
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.