Skip to contentSkip to conversation

pci: octeon: Remove udelay() causing huge IRQ latency

PATCH In review Alexander Sverdlin 4 participants 7 messages Mar 18, 2015 – Mar 19, 2015 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pci: octeon: Remove udelay() causing huge IRQ latency

udelay() in PCI/PCIe read/write callbacks cause 30ms IRQ latency on Octeon platforms because these operations are called from PCI_OP_READ() and PCI_OP_WRITE() under raw_spin_lock_irqsave().

---
 arch/mips/include/asm/octeon/pci-octeon.h |    3 ---
 arch/mips/pci/pci-octeon.c                |    6 ------
 arch/mips/pci/pcie-octeon.c               |    8 --------
 3 files changed, 0 insertions(+), 17 deletions(-)
arch/mips/include/asm/octeon/pci-octeon.h +0 -3
index 64ba56a..1884609 100644
@@ -11,9 +11,6 @@
 
 #include <linux/pci.h>
 
-/* Some PCI cards require delays when accessing config space. */
-#define PCI_CONFIG_SPACE_DELAY 10000
-
 /*
  * The physical memory base mapped by BAR1.  256MB at the end of the
  * first 4GB.
arch/mips/pci/pci-octeon.c +0 -6
index a04af55..01c604a 100644
@@ -271,9 +271,6 @@ static int octeon_read_config(struct pci_bus *bus, unsigned int devfn,
 	pci_addr.s.func = devfn & 0x7;
 	pci_addr.s.reg = reg;
 
-#if PCI_CONFIG_SPACE_DELAY
-	udelay(PCI_CONFIG_SPACE_DELAY);
-#endif
 	switch (size) {
 	case 4:
 		*val = le32_to_cpu(cvmx_read64_uint32(pci_addr.u64));
@@ -308,9 +305,6 @@ static int octeon_write_config(struct pci_bus *bus, unsigned int devfn,
 	pci_addr.s.func = devfn & 0x7;
 	pci_addr.s.reg = reg;
 
-#if PCI_CONFIG_SPACE_DELAY
-	udelay(PCI_CONFIG_SPACE_DELAY);
-#endif
 	switch (size) {
 	case 4:
 		cvmx_write64_uint32(pci_addr.u64, cpu_to_le32(val));
arch/mips/pci/pcie-octeon.c +0 -8
index 1bb0b2b..99f3db4 100644
@@ -1762,14 +1762,6 @@ static int octeon_pcie_write_config(unsigned int pcie_port, struct pci_bus *bus,
 	default:
 		return PCIBIOS_FUNC_NOT_SUPPORTED;
 	}
-#if PCI_CONFIG_SPACE_DELAY
-	/*
-	 * Delay on writes so that devices have time to come up. Some
-	 * bridges need this to allow time for the secondary busses to
-	 * work
-	 */
-	udelay(PCI_CONFIG_SPACE_DELAY);
-#endif
 	return PCIBIOS_SUCCESSFUL;
 }
 
#1 lore raw
Quoted 5 lines · Alexander Sverdlin

udelay() in PCI/PCIe read/write callbacks cause 30ms IRQ latency on Octeon platforms because these operations are called from PCI_OP_READ() and PCI_OP_WRITE() under raw_spin_lock_irqsave().

I have no idea about the octeon platform, but how do you deal with the fact that is stated by the comment you are removing? I.e.

	/* Some PCI cards require delays when accessing config space. */

Is that not the case any more for some reason? If not, it really needs to be explained in the changelog.

Signature · 2 lines
Jiri Kosina
SUSE Labs
#2 lore raw

Hi!

Quoted 4 lines · ext Jiri Kosina
Quoted 4 lines

udelay() in PCI/PCIe read/write callbacks cause 30ms IRQ latency on Octeon

Quoted 3 lines

platforms because these operations are called from PCI_OP_READ() and PCI_OP_WRITE() under raw_spin_lock_irqsave().

Quoted 8 lines
Quoted 1 line
Quoted 1 line

I have no idea about the octeon platform, but how do you deal with the fact that is stated by the comment you are removing? I.e.

	/* Some PCI cards require delays when accessing config space. */

Is that not the case any more for some reason? If not, it really needs to be explained in the changelog.

This udelay() should not have made its way upstream, someone overseen it during code review. This is simply not allowed to have delayed read/write in the current Linux PCI subsystem. And maybe there is no place for it at all.

Signature · 2 lines
Best regards,
Alexander Sverdlin.
#3 lore raw
In reply to Alexander Sverdlin
Quoted 5 lines · Alexander Sverdlin

udelay() in PCI/PCIe read/write callbacks cause 30ms IRQ latency on Octeon platforms because these operations are called from PCI_OP_READ() and PCI_OP_WRITE() under raw_spin_lock_irqsave().

Can you say how it was tested. In principle I have no objections, but it would be nice to know how it was validated.

Thanks,
David Daney

Quoted 64 lines
---
  arch/mips/include/asm/octeon/pci-octeon.h |    3 ---
  arch/mips/pci/pci-octeon.c                |    6 ------
  arch/mips/pci/pcie-octeon.c               |    8 --------
  3 files changed, 0 insertions(+), 17 deletions(-)
arch/mips/include/asm/octeon/pci-octeon.h +0 -3
index 64ba56a..1884609 100644
@@ -11,9 +11,6 @@
 
  #include <linux/pci.h>
 
-/* Some PCI cards require delays when accessing config space. */
-#define PCI_CONFIG_SPACE_DELAY 10000
-
  /*
   * The physical memory base mapped by BAR1.  256MB at the end of the
   * first 4GB.
arch/mips/pci/pci-octeon.c +0 -6
index a04af55..01c604a 100644
@@ -271,9 +271,6 @@ static int octeon_read_config(struct pci_bus *bus, unsigned int devfn,
  	pci_addr.s.func = devfn & 0x7;
  	pci_addr.s.reg = reg;
 
-#if PCI_CONFIG_SPACE_DELAY
-	udelay(PCI_CONFIG_SPACE_DELAY);
-#endif
  	switch (size) {
  	case 4:
  		*val = le32_to_cpu(cvmx_read64_uint32(pci_addr.u64));
@@ -308,9 +305,6 @@ static int octeon_write_config(struct pci_bus *bus, unsigned int devfn,
  	pci_addr.s.func = devfn & 0x7;
  	pci_addr.s.reg = reg;
 
-#if PCI_CONFIG_SPACE_DELAY
-	udelay(PCI_CONFIG_SPACE_DELAY);
-#endif
  	switch (size) {
  	case 4:
  		cvmx_write64_uint32(pci_addr.u64, cpu_to_le32(val));
arch/mips/pci/pcie-octeon.c +0 -8
index 1bb0b2b..99f3db4 100644
@@ -1762,14 +1762,6 @@ static int octeon_pcie_write_config(unsigned int pcie_port, struct pci_bus *bus,
  	default:
  		return PCIBIOS_FUNC_NOT_SUPPORTED;
  	}
-#if PCI_CONFIG_SPACE_DELAY
-	/*
-	 * Delay on writes so that devices have time to come up. Some
-	 * bridges need this to allow time for the secondary busses to
-	 * work
-	 */
-	udelay(PCI_CONFIG_SPACE_DELAY);
-#endif
  	return PCIBIOS_SUCCESSFUL;
  }
 
#4 lore raw

Hello David,

Quoted 7 lines · ext David Daney
Quoted 5 lines

udelay() in PCI/PCIe read/write callbacks cause 30ms IRQ latency on Octeon platforms because these operations are called from PCI_OP_READ() and PCI_OP_WRITE() under raw_spin_lock_irqsave().

Can you say how it was tested. In principle I have no objections, but it would be nice to know how it was validated.

What do you want to know, how we've debugged IRQ latency and found the root cause or how we figured out that delay is not necessary? I'm pretty sure that there is HW which requires it. Maybe it's even Octeon itself... But putting udelay() in this callbacks is wrong wrong wrong.

Signature · 2 lines
Best regards,
Alexander Sverdlin.
#5 lore raw

Hi,

Quoted 5 lines · Alexander Sverdlin
Quoted 4 lines · ext David Daney
Quoted 4 lines

udelay() in PCI/PCIe read/write callbacks cause 30ms IRQ latency on Octeon platforms because these operations are called from PCI_OP_READ() and PCI_OP_WRITE() under raw_spin_lock_irqsave().

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Can you say how it was tested. In principle I have no objections, but it would be nice to know how it was validated.

What do you want to know, how we've debugged IRQ latency and found the root cause or how we figured out that delay is not necessary?

You could at least say on which OCTEON platforms (e.g. OCTEON II or older) you tested the patch on, and tell about tested PCI bus topology and devices.

Quoted 3 lines

I'm pretty sure that there is HW which requires it. Maybe it's even Octeon itself... But putting udelay() in this callbacks is wrong wrong wrong.

Still, you should not break HW that works with current kernel.

A.

#6 lore raw

Hi!

Quoted 3 lines · ext Aaro Koskinen

You could at least say on which OCTEON platforms (e.g. OCTEON II or older) you tested the patch on, and tell about tested PCI bus topology and devices.

Octeon II CN68xx with Marvell XGE switch connected to PCIe.

Signature · 2 lines
Best regards,
Alexander Sverdlin.