* [PATCH v7 1/8] PCI: Move enum pci_interrupt_pin to linux/pci.h
2017-08-15 19:02 [PATCH v7 0/8] PCI: INTx interrupt fixes & cleanup Paul Burton
@ 2017-08-15 19:02 ` Paul Burton
2017-08-15 19:02 ` [PATCH v7 2/8] PCI: Introduce pci_irqd_intx_xlate() Paul Burton
` (8 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Paul Burton @ 2017-08-15 19:02 UTC (permalink / raw)
To: Bjorn Helgaas, linux-pci; +Cc: Paul Burton
We currently have a definition of enum pci_interrupt_pin in a header
specific to PCI endpoints - linux/pci-epf.h. In order to allow for use
of this enum from PCI host code in a future commit, move its definition
to linux/pci.h & include that from linux/pci-epf.h.
Additionally we add a PCI_NUM_INTX macro which indicates the number of
PCI INTx interrupts, and will be used alongside enum pci_interrupt_pin
in further patches.
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org
---
Changes in v7:
- Move it to linux/pci.h rather than a new header.
- Add PCI_NUM_INTX.
Changes in v6:
- New patch.
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
include/linux/pci-epf.h | 9 +--------
include/linux/pci.h | 22 ++++++++++++++++++++++
2 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h
index 0d529cb90143..bc8750688348 100644
--- a/include/linux/pci-epf.h
+++ b/include/linux/pci-epf.h
@@ -14,17 +14,10 @@
#include <linux/device.h>
#include <linux/mod_devicetable.h>
+#include <linux/pci.h>
struct pci_epf;
-enum pci_interrupt_pin {
- PCI_INTERRUPT_UNKNOWN,
- PCI_INTERRUPT_INTA,
- PCI_INTERRUPT_INTB,
- PCI_INTERRUPT_INTC,
- PCI_INTERRUPT_INTD,
-};
-
enum pci_barno {
BAR_0,
BAR_1,
diff --git a/include/linux/pci.h b/include/linux/pci.h
index a75c13673852..8098c438d88a 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1395,6 +1395,28 @@ pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
NULL);
}
+/**
+ * enum pci_interrupt_pin - PCI INTx interrupt values
+ * @PCI_INTERRUPT_UNKNOWN: Unknown or unassigned interrupt
+ * @PCI_INTERRUPT_INTA: PCI INTA pin
+ * @PCI_INTERRUPT_INTB: PCI INTB pin
+ * @PCI_INTERRUPT_INTC: PCI INTC pin
+ * @PCI_INTERRUPT_INTD: PCI INTD pin
+ *
+ * Corresponds to values for legacy PCI INTx interrupts, as can be found in the
+ * PCI_INTERRUPT_PIN register.
+ */
+enum pci_interrupt_pin {
+ PCI_INTERRUPT_UNKNOWN,
+ PCI_INTERRUPT_INTA,
+ PCI_INTERRUPT_INTB,
+ PCI_INTERRUPT_INTC,
+ PCI_INTERRUPT_INTD,
+};
+
+/* The number of legacy PCI INTx interrupts */
+#define PCI_NUM_INTX 4
+
#ifdef CONFIG_PCIEPORTBUS
extern bool pcie_ports_disabled;
extern bool pcie_ports_auto;
--
2.14.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v7 2/8] PCI: Introduce pci_irqd_intx_xlate()
2017-08-15 19:02 [PATCH v7 0/8] PCI: INTx interrupt fixes & cleanup Paul Burton
2017-08-15 19:02 ` [PATCH v7 1/8] PCI: Move enum pci_interrupt_pin to linux/pci.h Paul Burton
@ 2017-08-15 19:02 ` Paul Burton
2017-08-15 19:02 ` [PATCH v7 3/8] PCI: altera: Use size=4 IRQ domain for legacy INTx Paul Burton
` (7 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Paul Burton @ 2017-08-15 19:02 UTC (permalink / raw)
To: Bjorn Helgaas, linux-pci; +Cc: Paul Burton
Legacy PCI INTx interrupts are represented in the PCI_INTERRUPT_PIN
register using the range 1-4, which matches our enum pci_interrupt_pin.
This is however not ideal for an IRQ domain, where with 4 interrupts we
would ideally have a domain of size 4 & hwirq numbers in the range 0-3.
Different PCI host controller drivers have handled this in different
ways. Of those under drivers/pci/ which register an INTx IRQ domain, we
have:
- pcie-altera uses the range 1-4 in device trees and an IRQ domain of
size 5 to cover that range, with entry 0 wasted.
- pcie-xilinx & pcie-xilinx-nwl use the range 1-4 in device trees but
register an IRQ domain of size 4, which doesn't cover the hwirq=4/INTD
case leading to that interrupt being broken.
- pci-ftpci100 & pci-aardvark use the range 0-3 in both device trees &
as hwirq numbering in the driver & IRQ domain.
In order to introduce some level of consistency in at least the hwirq
numbering used by the drivers & IRQ domains, this patch introduces a new
pci_irqd_intx_xlate() helper function which drivers using the 1-4 range
in device trees can assign as the xlate callback for their INTx IRQ
domain. This translates the 1-4 range into a 0-3 range, allowing us to
use an IRQ domain of size 4 & avoid a wasted entry. Further patches will
make use of this in drivers to allow them to use an IRQ domain of size 4
for legacy INTx interrupts without breaking INTD.
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org
---
Changes in v7:
- Rewrite the commit message.
Changes in v6:
- New patch.
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
include/linux/pci.h | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 8098c438d88a..e97ce5d1bbb6 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1417,6 +1417,38 @@ enum pci_interrupt_pin {
/* The number of legacy PCI INTx interrupts */
#define PCI_NUM_INTX 4
+/**
+ * pci_irqd_intx_xlate() - Translate PCI INTx value to an IRQ domain hwirq
+ * @d: the INTx IRQ domain
+ * @node: the DT node for the device whose interrupt we're translating
+ * @intspec: the interrupt specifier data from the DT
+ * @intsize: the number of entries in @intspec
+ * @out_hwirq: pointer at which to write the hwirq number
+ * @out_type: pointer at which to write the interrupt type
+ *
+ * Translate a PCI INTx interrupt number from device tree in the range 1-4, as
+ * stored in the standard PCI_INTERRUPT_PIN register, to a value in the range
+ * 0-3 suitable for use in a 4 entry IRQ domain. That is, subtract one from the
+ * INTx value to obtain the hwirq number.
+ *
+ * Returns 0 on success, or -EINVAL if the interrupt specifier is out of range.
+ */
+static inline int pci_irqd_intx_xlate(struct irq_domain *d,
+ struct device_node *node,
+ const u32 *intspec,
+ unsigned int intsize,
+ unsigned long *out_hwirq,
+ unsigned int *out_type)
+{
+ const u32 intx = intspec[0];
+
+ if (intx < PCI_INTERRUPT_INTA || intx > PCI_INTERRUPT_INTD)
+ return -EINVAL;
+
+ *out_hwirq = intx - PCI_INTERRUPT_INTA;
+ return 0;
+}
+
#ifdef CONFIG_PCIEPORTBUS
extern bool pcie_ports_disabled;
extern bool pcie_ports_auto;
--
2.14.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v7 3/8] PCI: altera: Use size=4 IRQ domain for legacy INTx
2017-08-15 19:02 [PATCH v7 0/8] PCI: INTx interrupt fixes & cleanup Paul Burton
2017-08-15 19:02 ` [PATCH v7 1/8] PCI: Move enum pci_interrupt_pin to linux/pci.h Paul Burton
2017-08-15 19:02 ` [PATCH v7 2/8] PCI: Introduce pci_irqd_intx_xlate() Paul Burton
@ 2017-08-15 19:02 ` Paul Burton
2017-08-15 19:02 ` [PATCH v7 4/8] PCI: xilinx: Translate INTx range to hwirqs 0-3 Paul Burton
` (6 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Paul Burton @ 2017-08-15 19:02 UTC (permalink / raw)
To: Bjorn Helgaas, linux-pci; +Cc: Paul Burton, Ley Foon Tan, rfi
The devicetree binding documentation for the Altera PCIe controller
shows an example which uses an interrupt-map property to map PCI INTx
interrupts to hardware IRQ numbers 1-4. The driver creates an IRQ domain
with size 5 in order to cover this range, with hwirq=0 left unused.
This patch cleans up this wasted IRQ domain entry, modifying the driver
to use an IRQ domain of size 4 which matches the actual number of PCI
INTx interrupts. Since the hwirq numbers 1-4 are part of the devicetree
binding, and this is considered ABI, we cannot simply change the
interrupt-map property to use the range 0-3. Instead we make use of the
pci_irqd_intx_xlate() helper function to translate the range 1-4 used at
the DT level into the range 0-3 which is now used within the driver, and
stop adding 1 to decoded hwirq numbers in altera_pcie_isr().
Whilst cleaning up INTx handling we make use of the new PCI_NUM_INTX
macro & drop the custom INTX_NUM definition.
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Ley Foon Tan <lftan@altera.com>
Cc: linux-pci@vger.kernel.org
Cc: rfi@lists.rocketboards.org
---
I have only build tested this.
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/pci/host/pcie-altera.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/pci/host/pcie-altera.c b/drivers/pci/host/pcie-altera.c
index 4ea4f8f5dc77..6fced590eb87 100644
--- a/drivers/pci/host/pcie-altera.c
+++ b/drivers/pci/host/pcie-altera.c
@@ -76,8 +76,6 @@
#define LINK_UP_TIMEOUT HZ
#define LINK_RETRAIN_TIMEOUT HZ
-#define INTX_NUM 4
-
#define DWORD_MASK 3
struct altera_pcie {
@@ -464,6 +462,7 @@ static int altera_pcie_intx_map(struct irq_domain *domain, unsigned int irq,
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)
@@ -481,11 +480,11 @@ static void altera_pcie_isr(struct irq_desc *desc)
while ((status = cra_readl(pcie, P2A_INT_STATUS)
& P2A_INT_STS_ALL) != 0) {
- for_each_set_bit(bit, &status, INTX_NUM) {
+ for_each_set_bit(bit, &status, PCI_NUM_INTX) {
/* clear interrupts */
cra_writel(pcie, 1 << bit, P2A_INT_STATUS);
- virq = irq_find_mapping(pcie->irq_domain, bit + 1);
+ virq = irq_find_mapping(pcie->irq_domain, bit);
if (virq)
generic_handle_irq(virq);
else
@@ -536,7 +535,7 @@ static int altera_pcie_init_irq_domain(struct altera_pcie *pcie)
struct device_node *node = dev->of_node;
/* Setup INTx */
- pcie->irq_domain = irq_domain_add_linear(node, INTX_NUM + 1,
+ 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");
--
2.14.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v7 4/8] PCI: xilinx: Translate INTx range to hwirqs 0-3
2017-08-15 19:02 [PATCH v7 0/8] PCI: INTx interrupt fixes & cleanup Paul Burton
` (2 preceding siblings ...)
2017-08-15 19:02 ` [PATCH v7 3/8] PCI: altera: Use size=4 IRQ domain for legacy INTx Paul Burton
@ 2017-08-15 19:02 ` Paul Burton
2017-08-15 19:02 ` [PATCH v7 5/8] PCI: xilinx-nwl: " Paul Burton
` (5 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Paul Burton @ 2017-08-15 19:02 UTC (permalink / raw)
To: Bjorn Helgaas, linux-pci
Cc: Paul Burton, Bharat Kumar Gogada, Michal Simek,
Ravikiran Gummaluri
The pcie-xilinx driver creates an IRQ domain of size 4 for legacy PCI
INTx interrupts, which at first glance seems reasonable since there are
4 possible such interrupts. Unfortunately the driver then proceeds to
use the range 1-4 as the hwirq numbers for INTA-INTD, causing warnings &
broken interrupts when attempting to use INTD/hwirq=4 due to it being
beyond the range of the IRQ domain:
WARNING: CPU: 0 PID: 1 at kernel/irq/irqdomain.c:365
irq_domain_associate+0x170/0x220
error: hwirq 0x4 is too large for dummy
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W
4.12.0-rc5-00126-g19e1b3a10aad-dirty #427
Stack : 0000000000000000 0000000000000004 0000000000000006 ffffffff8092c78a
0000000000000061 ffffffff8018bf60 0000000000000000 0000000000000000
ffffffff8088c287 ffffffff80811d18 a8000000ffc60000 ffffffff80926678
0000000000000001 0000000000000000 ffffffff80887880 ffffffff80960000
ffffffff80920000 ffffffff801e6744 ffffffff80887880 a8000000ffc4f8f8
000000000000089c ffffffff8018d260 0000000000010000 ffffffff80811d18
0000000000000000 0000000000000001 0000000000000000 0000000000000000
0000000000000000 a8000000ffc4f840 0000000000000000 ffffffff8042cf34
0000000000000000 0000000000000000 0000000000000000 0000000000040c00
0000000000000000 ffffffff8010d1c8 0000000000000000 ffffffff8042cf34
...
Call Trace:
[<ffffffff8010d1c8>] show_stack+0x80/0xa0
[<ffffffff8042cf34>] dump_stack+0xd4/0x110
[<ffffffff8013ea98>] __warn+0xf0/0x108
[<ffffffff8013eb14>] warn_slowpath_fmt+0x3c/0x48
[<ffffffff80196528>] irq_domain_associate+0x170/0x220
[<ffffffff80196bf0>] irq_create_mapping+0x88/0x118
[<ffffffff801976a8>] irq_create_fwspec_mapping+0xb8/0x320
[<ffffffff80197970>] irq_create_of_mapping+0x60/0x70
[<ffffffff805d1318>] of_irq_parse_and_map_pci+0x20/0x38
[<ffffffff8049c210>] pci_fixup_irqs+0x60/0xe0
[<ffffffff8049cd64>] xilinx_pcie_probe+0x28c/0x478
[<ffffffff804e8ca8>] platform_drv_probe+0x50/0xd0
[<ffffffff804e73a4>] driver_probe_device+0x2c4/0x3a0
[<ffffffff804e7544>] __driver_attach+0xc4/0xd0
[<ffffffff804e5254>] bus_for_each_dev+0x64/0xa8
[<ffffffff804e5e40>] bus_add_driver+0x1f0/0x268
[<ffffffff804e8000>] driver_register+0x68/0x118
[<ffffffff801001a4>] do_one_initcall+0x4c/0x178
[<ffffffff808d3ca8>] kernel_init_freeable+0x204/0x2b0
[<ffffffff80730b68>] kernel_init+0x10/0xf8
[<ffffffff80106218>] ret_from_kernel_thread+0x14/0x1c
Fix this by making use of the new pci_irqd_intx_xlate() helper to
translate the INTx 1-4 range into the 0-3 range suitable for the IRQ
domain of size 4, and stop adding 1 to the hwirq number decoded from the
interrupt FIFO which is already in the range 0-3.
Whilst we're here we switch to using PCI_NUM_INTX rather than the magic
number 4, making it clearer what the 4 means.
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: Bharat Kumar Gogada <bharatku@xilinx.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: Ravikiran Gummaluri <rgummal@xilinx.com>
Cc: linux-pci@vger.kernel.org
---
Changes in v7: None
Changes in v6:
- New patch, replacing "PCI: xilinx: Create legacy IRQ domain with size 5".
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/pci/host/pcie-xilinx.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/host/pcie-xilinx.c b/drivers/pci/host/pcie-xilinx.c
index f63fa5e0278c..9a8d5ad1dd70 100644
--- a/drivers/pci/host/pcie-xilinx.c
+++ b/drivers/pci/host/pcie-xilinx.c
@@ -369,6 +369,7 @@ static int xilinx_pcie_intx_map(struct irq_domain *domain, unsigned int irq,
/* 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 */
@@ -440,8 +441,8 @@ static irqreturn_t xilinx_pcie_intr_handler(int irq, void *data)
XILINX_PCIE_REG_RPIFR1);
/* Handle INTx Interrupt */
- val = ((val & XILINX_PCIE_RPIFR1_INTR_MASK) >>
- XILINX_PCIE_RPIFR1_INTR_SHIFT) + 1;
+ val = (val & XILINX_PCIE_RPIFR1_INTR_MASK) >>
+ XILINX_PCIE_RPIFR1_INTR_SHIFT;
generic_handle_irq(irq_find_mapping(port->leg_domain,
val));
}
@@ -524,7 +525,7 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie_port *port)
return -ENODEV;
}
- port->leg_domain = irq_domain_add_linear(pcie_intc_node, 4,
+ port->leg_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX,
&intx_domain_ops,
port);
if (!port->leg_domain) {
--
2.14.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v7 5/8] PCI: xilinx-nwl: Translate INTx range to hwirqs 0-3
2017-08-15 19:02 [PATCH v7 0/8] PCI: INTx interrupt fixes & cleanup Paul Burton
` (3 preceding siblings ...)
2017-08-15 19:02 ` [PATCH v7 4/8] PCI: xilinx: Translate INTx range to hwirqs 0-3 Paul Burton
@ 2017-08-15 19:02 ` Paul Burton
2017-08-15 19:02 ` [PATCH v7 6/8] PCI: aardvark: Use PCI_NUM_INTX Paul Burton
` (4 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Paul Burton @ 2017-08-15 19:02 UTC (permalink / raw)
To: Bjorn Helgaas, linux-pci
Cc: Sören Brinkmann, Michal Simek, Paul Burton, linux-arm-kernel
VGhlIGRldmljZXRyZWUgYmluZGluZyBkb2N1bWVudGF0aW9uIGZvciB0aGUgWGlsaW54IE5XTCBQ
Q0llIHJvb3QgcG9ydApicmlkZ2Ugc2hvd3MgYW4gZXhhbXBsZSB3aGljaCB1c2VzIGFuIGludGVy
cnVwdC1tYXAgcHJvcGVydHkgdG8gbWFwIFBDSQpJTlR4IGludGVycnVwdHMgdG8gaGFyZHdhcmUg
SVJRIG51bWJlcnMgMS00LiBUaGUgZHJpdmVyIGNyZWF0ZXMgYW4gSVJRCmRvbWFpbiB3aXRoIHNp
emUgNCwgd2hpY2ggdGhlcmVmb3JlIGNvdmVycyB0aGUgaHdpcnEgcmFuZ2UgMC0zLgoKVGhpcyBt
ZWFucyB0aGF0IGlmIHdlIGF0dGVtcHQgdG8gbWFrZSB1c2Ugb2YgdGhlIElOVEQgaW50ZXJydXB0
IHRoZW4Kd2UncmUgbGlrZWx5IHRvIGhpdCBhIFdBUk4oKSBpbiBpcnFfZG9tYWluX2Fzc29jaWF0
ZSgpIGJlY2F1c2UgSU5URCwgb3IKaHdpcnc9NCwgaXMgb3V0c2lkZSBvZiB0aGUgcmFuZ2UgY292
ZXJlZCBieSB0aGUgSVJRIGRvbWFpbi4KaXJxX2RvbWFpbl9hc3NvY2lhdGUoKSB3aWxsIHRoZW4g
cmV0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bCBtYWlsaW5nIGxpc3QK
bGludXgtYXJtLWtlcm5lbEBsaXN0cy5pbmZyYWRlYWQub3JnCmh0dHA6Ly9saXN0cy5pbmZyYWRl
YWQub3JnL21haWxtYW4vbGlzdGluZm8vbGludXgtYXJtLWtlcm5lbAo=
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH v7 6/8] PCI: aardvark: Use PCI_NUM_INTX
2017-08-15 19:02 [PATCH v7 0/8] PCI: INTx interrupt fixes & cleanup Paul Burton
` (4 preceding siblings ...)
2017-08-15 19:02 ` [PATCH v7 5/8] PCI: xilinx-nwl: " Paul Burton
@ 2017-08-15 19:02 ` Paul Burton
2017-08-15 19:46 ` Thomas Petazzoni
2017-08-15 19:02 ` [PATCH v7 7/8] PCI: ftpci100: " Paul Burton
` (3 subsequent siblings)
9 siblings, 1 reply; 13+ messages in thread
From: Paul Burton @ 2017-08-15 19:02 UTC (permalink / raw)
To: Bjorn Helgaas, linux-pci; +Cc: Thomas Petazzoni, linux-arm-kernel, Paul Burton
Switch from using a custom LEGACY_IRQ_NUM macro to the generic
PCI_NUM_INTX definition for the number of INTx interrupts.
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-pci@vger.kernel.org
---
I have only build tested this.
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/pci/host/pci-aardvark.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/host/pci-aardvark.c b/drivers/pci/host/pci-aardvark.c
index 5fb9b620ac78..89f4e3d072d7 100644
--- a/drivers/pci/host/pci-aardvark.c
+++ b/drivers/pci/host/pci-aardvark.c
@@ -191,7 +191,6 @@
#define LINK_WAIT_USLEEP_MIN 90000
#define LINK_WAIT_USLEEP_MAX 100000
-#define LEGACY_IRQ_NUM 4
#define MSI_IRQ_NUM 32
struct advk_pcie {
@@ -729,7 +728,7 @@ static int advk_pcie_init_irq_domain(struct advk_pcie *pcie)
irq_chip->irq_unmask = advk_pcie_irq_unmask;
pcie->irq_domain =
- irq_domain_add_linear(pcie_intc_node, LEGACY_IRQ_NUM,
+ 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");
@@ -786,7 +785,7 @@ static void advk_pcie_handle_int(struct advk_pcie *pcie)
advk_pcie_handle_msi(pcie);
/* Process legacy interrupts */
- for (i = 0; i < LEGACY_IRQ_NUM; i++) {
+ for (i = 0; i < PCI_NUM_INTX; i++) {
if (!(status & PCIE_ISR0_INTX_ASSERT(i)))
continue;
--
2.14.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v7 7/8] PCI: ftpci100: Use PCI_NUM_INTX
2017-08-15 19:02 [PATCH v7 0/8] PCI: INTx interrupt fixes & cleanup Paul Burton
` (5 preceding siblings ...)
2017-08-15 19:02 ` [PATCH v7 6/8] PCI: aardvark: Use PCI_NUM_INTX Paul Burton
@ 2017-08-15 19:02 ` Paul Burton
2017-08-15 19:02 ` [PATCH v7 8/8] PCI: rockchip: " Paul Burton
` (2 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Paul Burton @ 2017-08-15 19:02 UTC (permalink / raw)
To: Bjorn Helgaas, linux-pci; +Cc: Paul Burton
Use the PCI_NUM_INTX macro to indicate the number of PCI INTx interrupts
rather than the magic number 4. This makes it clearer where the number
comes from & what it relates to.
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org
---
I have only build tested this.
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/pci/host/pci-ftpci100.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/host/pci-ftpci100.c b/drivers/pci/host/pci-ftpci100.c
index 5162dffc102b..1f1f780182de 100644
--- a/drivers/pci/host/pci-ftpci100.c
+++ b/drivers/pci/host/pci-ftpci100.c
@@ -355,7 +355,7 @@ static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p)
return -EINVAL;
}
- p->irqdomain = irq_domain_add_linear(intc, 4,
+ 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");
--
2.14.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v7 8/8] PCI: rockchip: Use PCI_NUM_INTX
2017-08-15 19:02 [PATCH v7 0/8] PCI: INTx interrupt fixes & cleanup Paul Burton
` (6 preceding siblings ...)
2017-08-15 19:02 ` [PATCH v7 7/8] PCI: ftpci100: " Paul Burton
@ 2017-08-15 19:02 ` Paul Burton
2017-08-15 21:33 ` [PATCH v7 0/8] PCI: INTx interrupt fixes & cleanup Bjorn Helgaas
2017-08-18 1:34 ` Shawn Lin
9 siblings, 0 replies; 13+ messages in thread
From: Paul Burton @ 2017-08-15 19:02 UTC (permalink / raw)
To: Bjorn Helgaas, linux-pci
Cc: linux-arm-kernel, linux-rockchip, Shawn Lin, Heiko Stuebner,
Paul Burton
Use the PCI_NUM_INTX macro to indicate the number of PCI INTx interrupts
rather than the magic number 4. This makes it clearer where the number
comes from & what it relates to.
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Shawn Lin <shawn.lin@rock-chips.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-pci@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
---
I have only build tested this.
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/pci/host/pcie-rockchip.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/host/pcie-rockchip.c b/drivers/pci/host/pcie-rockchip.c
index 7bb9870f6d8c..eae195ca06ab 100644
--- a/drivers/pci/host/pcie-rockchip.c
+++ b/drivers/pci/host/pcie-rockchip.c
@@ -1116,7 +1116,7 @@ static int rockchip_pcie_init_irq_domain(struct rockchip_pcie *rockchip)
return -EINVAL;
}
- rockchip->irq_domain = irq_domain_add_linear(intc, 4,
+ rockchip->irq_domain = irq_domain_add_linear(intc, PCI_NUM_INTX,
&intx_domain_ops, rockchip);
if (!rockchip->irq_domain) {
dev_err(dev, "failed to get a INTx IRQ domain\n");
--
2.14.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH v7 0/8] PCI: INTx interrupt fixes & cleanup
2017-08-15 19:02 [PATCH v7 0/8] PCI: INTx interrupt fixes & cleanup Paul Burton
` (7 preceding siblings ...)
2017-08-15 19:02 ` [PATCH v7 8/8] PCI: rockchip: " Paul Burton
@ 2017-08-15 21:33 ` Bjorn Helgaas
2017-08-17 22:38 ` Paul Burton
2017-08-18 1:34 ` Shawn Lin
9 siblings, 1 reply; 13+ messages in thread
From: Bjorn Helgaas @ 2017-08-15 21:33 UTC (permalink / raw)
To: Paul Burton; +Cc: Bjorn Helgaas, linux-pci
On Tue, Aug 15, 2017 at 12:02:15PM -0700, Paul Burton wrote:
> This series fixes our handling of the PCI INTD interrupts in both Xilinx
> PCIe controller drivers, and cleans up a wasted IRQ domain entry in the
> Altera PCIe controller driver. It also adds a common PCI_INTX_NUM
> definition which all relevant drivers under drivers/pci/host/ are
> adjusted to make use of.
>
> - Patch 1 moves enum pci_interrupt_pin to somewhere we can use it from
> PCI host code.
>
> - Patch 2 introduces a helper function to translate 1-4 INTx ranges into
> the 0-3 range, by using it as a struct irq_domain's xlate callback.
>
> - Patches 3 adjusts the Altera driver to avoid wasting an IRQ domain
> entry.
>
> - Patches 4 & 5 fix the INTD interrupt for Xilinx PCIe drivers.
>
> - Patches 6-8 make use of PCI_NUM_INTX to replace custom definitions or
> magic numbers in drivers.
>
> The series versioning is continuing on from that of my "PCI: xilinx:
> Fixes, optimisation & MIPS support" series which some of the earlier
> patches were originally a part of, in order to prevent individual
> patches from jumping backwards in versioning.
>
> Applies atop v4.13-rc5.
>
> Paul Burton (8):
> PCI: Move enum pci_interrupt_pin to linux/pci.h
> PCI: Introduce pci_irqd_intx_xlate()
> PCI: altera: Use size=4 IRQ domain for legacy INTx
> PCI: xilinx: Translate INTx range to hwirqs 0-3
> PCI: xilinx-nwl: Translate INTx range to hwirqs 0-3
> PCI: aardvark: Use PCI_NUM_INTX
> PCI: ftpci100: Use PCI_NUM_INTX
> PCI: rockchip: Use PCI_NUM_INTX
>
> drivers/pci/host/pci-aardvark.c | 5 ++--
> drivers/pci/host/pci-ftpci100.c | 2 +-
> drivers/pci/host/pcie-altera.c | 9 +++----
> drivers/pci/host/pcie-rockchip.c | 2 +-
> drivers/pci/host/pcie-xilinx-nwl.c | 9 +++----
> drivers/pci/host/pcie-xilinx.c | 7 ++---
> include/linux/pci-epf.h | 9 +------
> include/linux/pci.h | 54 ++++++++++++++++++++++++++++++++++++++
> 8 files changed, 71 insertions(+), 26 deletions(-)
Thanks for updating these, Paul. I applied them on pci/irq-intx and the
individual driver branches. I added Thomas' reviewed-by for Aardvark, and
I expect we'll get more for the others.
I found two more places we can use PCI_NUM_INTX; I'll post those in a
minute.
Thanks for all your work on this!
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v7 0/8] PCI: INTx interrupt fixes & cleanup
2017-08-15 21:33 ` [PATCH v7 0/8] PCI: INTx interrupt fixes & cleanup Bjorn Helgaas
@ 2017-08-17 22:38 ` Paul Burton
0 siblings, 0 replies; 13+ messages in thread
From: Paul Burton @ 2017-08-17 22:38 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: Bjorn Helgaas, linux-pci
[-- Attachment #1: Type: text/plain, Size: 2711 bytes --]
Hi Bjorn,
On Tuesday, 15 August 2017 14:33:15 PDT Bjorn Helgaas wrote:
> On Tue, Aug 15, 2017 at 12:02:15PM -0700, Paul Burton wrote:
> > This series fixes our handling of the PCI INTD interrupts in both Xilinx
> > PCIe controller drivers, and cleans up a wasted IRQ domain entry in the
> > Altera PCIe controller driver. It also adds a common PCI_INTX_NUM
> > definition which all relevant drivers under drivers/pci/host/ are
> > adjusted to make use of.
> >
> > - Patch 1 moves enum pci_interrupt_pin to somewhere we can use it from
> >
> > PCI host code.
> >
> > - Patch 2 introduces a helper function to translate 1-4 INTx ranges into
> >
> > the 0-3 range, by using it as a struct irq_domain's xlate callback.
> >
> > - Patches 3 adjusts the Altera driver to avoid wasting an IRQ domain
> >
> > entry.
> >
> > - Patches 4 & 5 fix the INTD interrupt for Xilinx PCIe drivers.
> >
> > - Patches 6-8 make use of PCI_NUM_INTX to replace custom definitions or
> >
> > magic numbers in drivers.
> >
> > The series versioning is continuing on from that of my "PCI: xilinx:
> > Fixes, optimisation & MIPS support" series which some of the earlier
> > patches were originally a part of, in order to prevent individual
> > patches from jumping backwards in versioning.
> >
> > Applies atop v4.13-rc5.
> >
> > Paul Burton (8):
> > PCI: Move enum pci_interrupt_pin to linux/pci.h
> > PCI: Introduce pci_irqd_intx_xlate()
> > PCI: altera: Use size=4 IRQ domain for legacy INTx
> > PCI: xilinx: Translate INTx range to hwirqs 0-3
> > PCI: xilinx-nwl: Translate INTx range to hwirqs 0-3
> > PCI: aardvark: Use PCI_NUM_INTX
> > PCI: ftpci100: Use PCI_NUM_INTX
> > PCI: rockchip: Use PCI_NUM_INTX
> >
> > drivers/pci/host/pci-aardvark.c | 5 ++--
> > drivers/pci/host/pci-ftpci100.c | 2 +-
> > drivers/pci/host/pcie-altera.c | 9 +++----
> > drivers/pci/host/pcie-rockchip.c | 2 +-
> > drivers/pci/host/pcie-xilinx-nwl.c | 9 +++----
> > drivers/pci/host/pcie-xilinx.c | 7 ++---
> > include/linux/pci-epf.h | 9 +------
> > include/linux/pci.h | 54
> > ++++++++++++++++++++++++++++++++++++++ 8 files changed, 71
> > insertions(+), 26 deletions(-)
>
> Thanks for updating these, Paul. I applied them on pci/irq-intx and the
> individual driver branches. I added Thomas' reviewed-by for Aardvark, and
> I expect we'll get more for the others.
Great, thanks :)
> I found two more places we can use PCI_NUM_INTX; I'll post those in a
> minute.
Both look good to me - I'd only looked under drivers/pci/host/ so drivers/pci/
dwc/ had escaped my gaze.
> Thanks for all your work on this!
You're welcome, thanks for merging.
Paul
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v7 0/8] PCI: INTx interrupt fixes & cleanup
2017-08-15 19:02 [PATCH v7 0/8] PCI: INTx interrupt fixes & cleanup Paul Burton
` (8 preceding siblings ...)
2017-08-15 21:33 ` [PATCH v7 0/8] PCI: INTx interrupt fixes & cleanup Bjorn Helgaas
@ 2017-08-18 1:34 ` Shawn Lin
9 siblings, 0 replies; 13+ messages in thread
From: Shawn Lin @ 2017-08-18 1:34 UTC (permalink / raw)
To: Paul Burton, Bjorn Helgaas, linux-pci; +Cc: shawn.lin
Hi Paul,
On 2017/8/16 3:02, Paul Burton wrote:
> This series fixes our handling of the PCI INTD interrupts in both Xilinx
> PCIe controller drivers, and cleans up a wasted IRQ domain entry in the
> Altera PCIe controller driver. It also adds a common PCI_INTX_NUM
> definition which all relevant drivers under drivers/pci/host/ are
> adjusted to make use of.
>
> - Patch 1 moves enum pci_interrupt_pin to somewhere we can use it from
> PCI host code.
>
> - Patch 2 introduces a helper function to translate 1-4 INTx ranges into
> the 0-3 range, by using it as a struct irq_domain's xlate callback.
>
> - Patches 3 adjusts the Altera driver to avoid wasting an IRQ domain
> entry.
>
> - Patches 4 & 5 fix the INTD interrupt for Xilinx PCIe drivers.
>
> - Patches 6-8 make use of PCI_NUM_INTX to replace custom definitions or
> magic numbers in drivers.
>
> The series versioning is continuing on from that of my "PCI: xilinx:
> Fixes, optimisation & MIPS support" series which some of the earlier
> patches were originally a part of, in order to prevent individual
> patches from jumping backwards in versioning.
>
> Applies atop v4.13-rc5.
>
> Paul Burton (8):
> PCI: Move enum pci_interrupt_pin to linux/pci.h
> PCI: Introduce pci_irqd_intx_xlate()
> PCI: altera: Use size=4 IRQ domain for legacy INTx
> PCI: xilinx: Translate INTx range to hwirqs 0-3
> PCI: xilinx-nwl: Translate INTx range to hwirqs 0-3
> PCI: aardvark: Use PCI_NUM_INTX
> PCI: ftpci100: Use PCI_NUM_INTX
> PCI: rockchip: Use PCI_NUM_INTX
>
Nice work!
For pcie-rockchip,
Tested-by: Shawn Lin <shawn.lin@rock-chips.com>
Acked-by: Shawn Lin <shawn.lin@rock-chips.com>
and for the whole series,
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
> drivers/pci/host/pci-aardvark.c | 5 ++--
> drivers/pci/host/pci-ftpci100.c | 2 +-
> drivers/pci/host/pcie-altera.c | 9 +++----
> drivers/pci/host/pcie-rockchip.c | 2 +-
> drivers/pci/host/pcie-xilinx-nwl.c | 9 +++----
> drivers/pci/host/pcie-xilinx.c | 7 ++---
> include/linux/pci-epf.h | 9 +------
> include/linux/pci.h | 54 ++++++++++++++++++++++++++++++++++++++
> 8 files changed, 71 insertions(+), 26 deletions(-)
>
^ permalink raw reply [flat|nested] 13+ messages in thread