Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: xilinx-nwl: Translate INTx range to hwirqs 0-3

The devicetree binding documentation for the Xilinx NWL PCIe root port
bridge 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 4, which therefore covers the hwirq range 0-3.

This means that if we attempt to make use of the INTD interrupt then we're
likely to hit a WARN() in irq_domain_associate() because INTD, or hwirw=4,
is outside of the range covered by the IRQ domain. irq_domain_associate()
will then return -EINVAL and we'll be unable to make use of INTD.

Fix this by making use of the pci_irqd_intx_xlate() helper function to
translate the 1-4 range used in the DT to a 0-3 range used within the
driver, and stop adding 1 to decoded hwirq numbers.

Whilst cleaning up INTx handling we make use of the new PCI_NUM_INTX macro
& drop the custom INTX definitions.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: "Sören Brinkmann" <soren.brinkmann@xilinx.com>

authored by

Paul Burton and committed by
Bjorn Helgaas
b8550f11 5c125683

+4 -5
+4 -5
drivers/pci/host/pcie-xilinx-nwl.c
··· 133 133 #define CFG_DMA_REG_BAR GENMASK(2, 0) 134 134 135 135 #define INT_PCI_MSI_NR (2 * 32) 136 - #define INTX_NUM 4 137 136 138 137 /* Readin the PS_LINKUP */ 139 138 #define PS_LINKUP_OFFSET 0x00000238 ··· 333 334 334 335 while ((status = nwl_bridge_readl(pcie, MSGF_LEG_STATUS) & 335 336 MSGF_LEG_SR_MASKALL) != 0) { 336 - for_each_set_bit(bit, &status, INTX_NUM) { 337 - virq = irq_find_mapping(pcie->legacy_irq_domain, 338 - bit + 1); 337 + for_each_set_bit(bit, &status, PCI_NUM_INTX) { 338 + virq = irq_find_mapping(pcie->legacy_irq_domain, bit); 339 339 if (virq) 340 340 generic_handle_irq(virq); 341 341 } ··· 434 436 435 437 static const struct irq_domain_ops legacy_domain_ops = { 436 438 .map = nwl_legacy_map, 439 + .xlate = pci_irqd_intx_xlate, 437 440 }; 438 441 439 442 #ifdef CONFIG_PCI_MSI ··· 558 559 } 559 560 560 561 pcie->legacy_irq_domain = irq_domain_add_linear(legacy_intc_node, 561 - INTX_NUM, 562 + PCI_NUM_INTX, 562 563 &legacy_domain_ops, 563 564 pcie); 564 565