Skip to contentSkip to conversation

Add host controller drivers for Cavium ThunderX PCI

PATCH Superseded David Daney 5 participants 17 messages Feb 5, 2016 – Feb 9, 2016

Subsystems (3)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v5 cover Add host controller drivers for Cavium ThunderX PCI

From: David Daney <[email protected]>

Some Cavium ThunderX processors require quirky access methods for the config space of the PCIe bridge.

There are now three patches:

1) Refactor code in pci-host-generic so that it can more easily be used by other drivers. This splits the driver for CAM and ECAM access methods to a separate file from the common host driver code.

2) Add the ThunderX PCIe driver to external PCIe buses, which leverages the code in pci-host-generic

3) Add ThunderX PCI driver for internel SoC buses used on early ThunderX chip revisions.

Changes from v4: Added patch 3/3. Stylistic changes to 2/3 suggested by Bjorn Helgaas. When expanding config write width to 32-bits, mask out unintened writes to W1C bits, also suggested by Bjorn Helgaas.

Changes from v3: Add some Acked-by, rebased to v4.5.0-rc1

Changes from v2: Improve device tree binding example as noted by Rob Herring. Rename pcie-thunder-pem.* to pci-thunder-pem.* for better consistency. Update MAINTAINERS to reflect the changes.

Changes from v1: Split CAM and ECAM code from common driver code as suggested by Arnd Bergmann. Fix spelling errors in pcie-thunder-pem.txt

David Daney (3):
PCI: generic: Refactor code to enable reuse by other drivers. pci, pci-thunder-pem: Add PCIe host driver for ThunderX processors. pci, pci-thunder-ecam: Add driver for ThunderX-pass1 on-chip devices

 .../devicetree/bindings/pci/pci-thunder-ecam.txt   |  30 ++
 .../devicetree/bindings/pci/pci-thunder-pem.txt    |  43 +++
 MAINTAINERS                                        |   9 +
 drivers/pci/host/Kconfig                           |  18 ++
 drivers/pci/host/Makefile                          |   3 +
 drivers/pci/host/pci-host-common.c                 | 194 +++++++++++
 drivers/pci/host/pci-host-common.h                 |  47 +++
 drivers/pci/host/pci-host-generic.c                | 181 +----------
 drivers/pci/host/pci-thunder-ecam.c                | 358 +++++++++++++++++++++
 drivers/pci/host/pci-thunder-pem.c                 | 332 +++++++++++++++++++
 10 files changed, 1038 insertions(+), 177 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt
 create mode 100644 Documentation/devicetree/bindings/pci/pci-thunder-pem.txt
 create mode 100644 drivers/pci/host/pci-host-common.c
 create mode 100644 drivers/pci/host/pci-host-common.h
 create mode 100644 drivers/pci/host/pci-thunder-ecam.c
 create mode 100644 drivers/pci/host/pci-thunder-pem.c
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v5 1/3 PCI: generic: Refactor code to enable reuse by other drivers.

From: David Daney <[email protected]>

No change in functionality.

Move structure definitions into a separate header file. Move common code to new file with Kconfig machinery to build it. Split probe function in to two parts:

- a small driver specific probe function (gen_pci_probe)

- a common probe that can be used by other drivers (pci_host_common_probe)

---
 MAINTAINERS                         |   1 +
 drivers/pci/host/Kconfig            |   4 +
 drivers/pci/host/Makefile           |   1 +
 drivers/pci/host/pci-host-common.c  | 194 ++++++++++++++++++++++++++++++++++++
 drivers/pci/host/pci-host-common.h  |  47 +++++++++
 drivers/pci/host/pci-host-generic.c | 181 +--------------------------------
 6 files changed, 251 insertions(+), 177 deletions(-)
 create mode 100644 drivers/pci/host/pci-host-common.c
 create mode 100644 drivers/pci/host/pci-host-common.h
MAINTAINERS +1 -0
index a9010d9..9287929 100644
@@ -8367,6 +8367,7 @@ L:	linux-pci at vger.kernel.org
 L:	linux-arm-kernel at lists.infradead.org (moderated for non-subscribers)
 S:	Maintained
 F:	Documentation/devicetree/bindings/pci/host-generic-pci.txt
+F:	drivers/pci/host/pci-host-common.c
 F:	drivers/pci/host/pci-host-generic.c
 
 PCI DRIVER FOR INTEL VOLUME MANAGEMENT DEVICE (VMD)
drivers/pci/host/Kconfig +4 -0
index 75a6054..65709b4 100644
@@ -53,9 +53,13 @@ config PCI_RCAR_GEN2_PCIE
 	help
 	  Say Y here if you want PCIe controller support on R-Car Gen2 SoCs.
 
+config PCI_HOST_COMMON
+	bool
+
 config PCI_HOST_GENERIC
 	bool "Generic PCI host controller"
 	depends on (ARM || ARM64) && OF
+	select PCI_HOST_COMMON
 	help
 	  Say Y here if you want to support a simple generic PCI host
 	  controller, such as the one emulated by kvmtool.
drivers/pci/host/Makefile +1 -0
index 7b2f20c..3b24af8 100644
@@ -6,6 +6,7 @@ obj-$(CONFIG_PCI_MVEBU) += pci-mvebu.o
 obj-$(CONFIG_PCI_TEGRA) += pci-tegra.o
 obj-$(CONFIG_PCI_RCAR_GEN2) += pci-rcar-gen2.o
 obj-$(CONFIG_PCI_RCAR_GEN2_PCIE) += pcie-rcar.o
+obj-$(CONFIG_PCI_HOST_COMMON) += pci-host-common.o
 obj-$(CONFIG_PCI_HOST_GENERIC) += pci-host-generic.o
 obj-$(CONFIG_PCIE_SPEAR13XX) += pcie-spear13xx.o
 obj-$(CONFIG_PCI_KEYSTONE) += pci-keystone-dw.o pci-keystone.o
drivers/pci/host/pci-host-common.c new file +194 -0

194 lines not on this page · raw message

drivers/pci/host/pci-host-common.h new file +47 -0

47 lines not on this page · raw message

drivers/pci/host/pci-host-generic.c +4 -177

203 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#2 lore raw

PATCH v5 2/3 pci, pci-thunder-pem: Add PCIe host driver for ThunderX processors.

In reply to David Daney

From: David Daney <[email protected]>

The root complexes used to access off-chip PCIe devices (called PEM units in the hardware manuals) on some Cavium ThunderX processors require quirky access methods for the config space of the PCIe bridge. Add a driver to provide these config space accessor functions. The pci-host-common code is used to configure the PCI machinery.

---
 .../devicetree/bindings/pci/pci-thunder-pem.txt    |  43 +++
 MAINTAINERS                                        |   8 +
 drivers/pci/host/Kconfig                           |   7 +
 drivers/pci/host/Makefile                          |   1 +
 drivers/pci/host/pci-thunder-pem.c                 | 332 +++++++++++++++++++++
 5 files changed, 391 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/pci-thunder-pem.txt
 create mode 100644 drivers/pci/host/pci-thunder-pem.c
Documentation/devicetree/bindings/pci/pci-thunder-pem.txt new file +43 -0
new file mode 100644
index 0000000..f131fae
@@ -0,0 +1,43 @@
+* ThunderX PEM PCIe host controller
+
+Firmware-initialized PCI host controller found on some Cavium
+ThunderX processors.
+
+The properties and their meanings are identical to those described in
+host-generic-pci.txt except as listed below.
+
+Properties of the host controller node that differ from
+host-generic-pci.txt:
+
+- compatible     : Must be "cavium,pci-host-thunder-pem"
+
+- reg            : Two entries: First the configuration space for down
+                   stream devices base address and size, as accessed
+                   from the parent bus. Second, the register bank of
+                   the PEM device PCIe bridge.
+
+Example:
+
+    pci at 87e0,c2000000 {
+	compatible = "cavium,pci-host-thunder-pem";
+	device_type = "pci";
+	msi-parent = <&its>;
+	msi-map = <0 &its 0x10000 0x10000>;
+	bus-range = <0x8f 0xc7>;
+	#size-cells = <2>;
+	#address-cells = <3>;
+
+	reg = <0x8880 0x8f000000 0x0 0x39000000>,  /* Configuration space */
+	      <0x87e0 0xc2000000 0x0 0x00010000>; /* PEM space */
+	ranges = <0x01000000 0x00 0x00020000 0x88b0 0x00020000 0x00 0x00010000>, /* I/O */
+		 <0x03000000 0x00 0x10000000 0x8890 0x10000000 0x0f 0xf0000000>, /* mem64 */
+		 <0x43000000 0x10 0x00000000 0x88a0 0x00000000 0x10 0x00000000>, /* mem64-pref */
+		 <0x03000000 0x87e0 0xc2f00000 0x87e0 0xc2000000 0x00 0x00100000>; /* mem64 PEM BAR4 */
+
+	#interrupt-cells = <1>;
+	interrupt-map-mask = <0 0 0 7>;
+	interrupt-map = <0 0 0 1 &gic0 0 0 0 24 4>, /* INTA */
+			<0 0 0 2 &gic0 0 0 0 25 4>, /* INTB */
+			<0 0 0 3 &gic0 0 0 0 26 4>, /* INTC */
+			<0 0 0 4 &gic0 0 0 0 27 4>; /* INTD */
+    };
MAINTAINERS +8 -0
index 9287929..ff5c367 100644
@@ -8413,6 +8413,14 @@ L:     linux-arm-msm at vger.kernel.org
 S:     Maintained
 F:     drivers/pci/host/*qcom*
 
+PCIE DRIVER FOR CAVIUM THUNDERX
+M:	David Daney <[email protected]>
+L:	linux-pci at vger.kernel.org
+L:	linux-arm-kernel at lists.infradead.org (moderated for non-subscribers)
+S:	Supported
+F:	Documentation/devicetree/bindings/pci/pci-thunder-*
+F:	drivers/pci/host/pci-thunder-*
+
 PCMCIA SUBSYSTEM
 P:	Linux PCMCIA Team
 L:	linux-pcmcia at lists.infradead.org
drivers/pci/host/Kconfig +7 -0
index 65709b4..184df22 100644
@@ -195,4 +195,11 @@ config PCIE_QCOM
 	  PCIe controller uses the Designware core plus Qualcomm-specific
 	  hardware wrappers.
 
+config PCI_HOST_THUNDER_PEM
+	bool "Cavium Thunder PCIe controller to off-chip devices"
+	depends on OF && ARM64
+	select PCI_HOST_COMMON
+	help
+	  Say Y here if you want PCIe support for CN88XX Cavium Thunder SoCs.
+
 endmenu
drivers/pci/host/Makefile +1 -0
index 3b24af8..8903172 100644
@@ -23,3 +23,4 @@ obj-$(CONFIG_PCIE_ALTERA) += pcie-altera.o
 obj-$(CONFIG_PCIE_ALTERA_MSI) += pcie-altera-msi.o
 obj-$(CONFIG_PCI_HISI) += pcie-hisi.o
 obj-$(CONFIG_PCIE_QCOM) += pcie-qcom.o
+obj-$(CONFIG_PCI_HOST_THUNDER_PEM) += pci-thunder-pem.o
drivers/pci/host/pci-thunder-pem.c new file +332 -0

332 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#4 lore raw

PATCH v5 3/3 pci, pci-thunder-ecam: Add driver for ThunderX-pass1 on-chip devices

In reply to David Daney

From: David Daney <[email protected]>

The cavium,pci-thunder-ecam devices are exactly ECAM based PCI root complexes. These root complexes (loosely referred to as ECAM units in the hardware manuals) are used to access the Thunder on-chips devices. They are special in that all the BARs on devices behind these root complexes are at fixed addresses. To handle this in a manner compatible with the core PCI code, we have the config access functions synthesize Enhanced Allocation (EA) capability entries for each BAR.

Since this EA synthesis is needed for exactly one chip model, we can hard code some assumptions about the device topology and the properties of specific DEVFNs in the driver.

---
 .../devicetree/bindings/pci/pci-thunder-ecam.txt   |  30 ++
 drivers/pci/host/Kconfig                           |   7 +
 drivers/pci/host/Makefile                          |   1 +
 drivers/pci/host/pci-thunder-ecam.c                | 358 +++++++++++++++++++++
 4 files changed, 396 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt
 create mode 100644 drivers/pci/host/pci-thunder-ecam.c
Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt new file +30 -0
new file mode 100644
index 0000000..34658f2
@@ -0,0 +1,30 @@
+* ThunderX PCI host controller for pass-1.x silicon
+
+Firmware-initialized PCI host controller to on-chip devices found on
+some Cavium ThunderX processors.  These devices have ECAM based config
+access, but the BARs are all at fixed addresses.  We handle the fixed
+addresses by synthesizing Enhanced Allocation (EA) capabilities for
+these devices.
+
+The properties and their meanings are identical to those described in
+host-generic-pci.txt except as listed below.
+
+Properties of the host controller node that differ from
+host-generic-pci.txt:
+
+- compatible     : Must be "cavium,pci-host-thunder-ecam"
+
+Example:
+
+	pci at 84b0,00000000 {
+		compatible = "cavium,pci-host-thunder-ecam";
+		device_type = "pci";
+		msi-parent = <&its>;
+		msi-map = <0 &its 0x30000 0x10000>;
+		bus-range = <0 31>;
+		#size-cells = <2>;
+		#address-cells = <3>;
+		#stream-id-cells = <1>;
+		reg = <0x84b0 0x00000000 0 0x02000000>;  /* Configuration space */
+		ranges = <0x03000000 0x8180 0x00000000 0x8180 0x00000000 0x80 0x00000000>; /* mem ranges */
+	};
drivers/pci/host/Kconfig +7 -0
index 184df22..f8912c6 100644
@@ -202,4 +202,11 @@ config PCI_HOST_THUNDER_PEM
 	help
 	  Say Y here if you want PCIe support for CN88XX Cavium Thunder SoCs.
 
+config PCI_HOST_THUNDER_ECAM
+	bool "Cavium Thunder ECAMe controller to on-chip devices on pass-1.x silicon"
+	depends on OF && ARM64
+	select PCI_HOST_COMMON
+	help
+	  Say Y here if you want ECAM support for CN88XX-Pass-1.x Cavium Thunder SoCs.
+
 endmenu
drivers/pci/host/Makefile +1 -0
index 8903172..d6af3ba 100644
@@ -23,4 +23,5 @@ obj-$(CONFIG_PCIE_ALTERA) += pcie-altera.o
 obj-$(CONFIG_PCIE_ALTERA_MSI) += pcie-altera-msi.o
 obj-$(CONFIG_PCI_HISI) += pcie-hisi.o
 obj-$(CONFIG_PCIE_QCOM) += pcie-qcom.o
+obj-$(CONFIG_PCI_HOST_THUNDER_ECAM) += pci-thunder-ecam.o
 obj-$(CONFIG_PCI_HOST_THUNDER_PEM) += pci-thunder-pem.o
drivers/pci/host/pci-thunder-ecam.c new file +358 -0

358 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#3 lore raw

Re: [PATCH v5 2/3] pci, pci-thunder-pem: Add PCIe host driver for ThunderX processors.

In reply to David Daney

Hi David,

I don't have time today to look at this thoroughly, but I think I did see one actual bug and a possible way to make this more readable. I think reading difficulty increases as at least the square of the maximum indent level :)

Bjorn

Quoted 41 lines · David Daney

...

drivers/pci/host/pci-thunder-pem.c new file +40 -0
+static int thunder_pem_config_write(struct pci_bus *bus, unsigned int devfn,
+				    int where, int size, u32 val)
+{
+	struct gen_pci *pci = bus->sysdata;
+	struct thunder_pem_pci *pem_pci;
+
+	pem_pci = container_of(pci, struct thunder_pem_pci, gen_pci);
+
+	/*
+	 * The first device on the bus in the PEM PCIe bridge.
+	 * Special case its config access.
+	 */
+	if (bus->number == pci->cfg.bus_range->start) {
+		u64 write_val, read_val;
+		u32 mask = 0;
+
+		if (devfn != 0 || where >= 2048)
+			return PCIBIOS_DEVICE_NOT_FOUND;
+
+		/*
+		 * 32-bit accesses only.  If the write is for a size
+		 * smaller than 32-bits, we must first read the 32-bit
+		 * value and merge in the desired bits and then write
+		 * the whole 32-bits back out.
+		 */
+		switch (size) {
+		case 1:
+			read_val = where & ~3ull;
+			writeq(read_val, pem_pci->pem_reg_base + PEM_CFG_RD);
+			read_val = readq(pem_pci->pem_reg_base + PEM_CFG_RD);
+			read_val >>= 32;
+			mask = ~(0xff << (8 * (where & 3)));
+			read_val &= mask;
+			val = (val & 0xff) << (8 * (where & 3));
+			val |= (u32)read_val;
+			break;
+		case 2:
+			read_val = where & ~3ull;
+			writeq(read_val, pem_pci->pem_reg_base + PEM_CFG_RD);
+			read_val = readq(pem_pci->pem_reg_base + PEM_CFG_RD);

drivers/pci/host/pci-thunder-pem.c line 198

Quoted 10 lines
drivers/pci/host/pci-thunder-pem.c new file +10 -0
+			read_val >>= 32;
+			mask = ~(0xffff << (8 * (where & 3)));
+			read_val &= mask;
+			val = (val & 0xffff) << (8 * (where & 3));
+			val |= (u32)read_val;
+			break;
+		default:
+			break;
+
+		}

I think it would make this easier to read if the root bus case were split to a different function, e.g.,

  static u32 thunder_pem_root_w1c_bits(...)
  {
    ...
  }

  static int thunder_pem_root_config_write(...)
  {
    u32 mask[2] = {0xff, 0xffff};
    if (devfn != 0 || where >= 2048)
      return PCIBIOS_DEVICE_NOT_FOUND;

    if (size != 1 && size != 2 && size != 4)
      return PCIBIOS_BAD_REGISTER_NUMBER;

    /* 32-bit accesses supported natively */
    if (size == 4) {
      write_val = where & ~3ull;
      write_val |= (((u64)val) << 32);
      writeq(write_val, pem_pci->pem_reg_base + PEM_CFG_WR);
      return PCIBIOS_SUCCESSFUL;
    }

    /* smaller accesses require read/modify/write */
    read_val = where & ~3ull;
    writeq(read_val, pem_pci->pem_reg_base + PEM_CFG_RD);
    read_val = readq(pem_pci->pem_reg_base + PEM_CFG_RD);
    read_val >>= 32;

    /* mask W1C bits so we don't clear them inadvertently */
    write_val = read_val & ~thunder_pem_root_w1c_bits(...);

    /* deposit new write data (which may intentionally write W1C bits) */
    val &= mask[size];
    shift = 8 * (where & 3);

    write_val &= ~(mask[size] << shift);
    write_val |= val << shift;

    write_val = where & ~3ull;
    write_val |= (((u64)val) << 32);
    writeq(write_val, pem_pci->pem_reg_base + PEM_CFG_WR);
    return PCIBIOS_SUCCESSFUL;

}

static int thunder_pem_config_write(struct pci_bus *bus, unsigned int devfn,
int where, int size, u32 val)

  {
    ...
    if (bus->number < pci->cfg.bus_range->start ||
        bus->number > pci->cfg.bus_range->end)
      return PCIBIOS_DEVICE_NOT_FOUND;

    if (bus->number == pci->cfg.bus_range->start)
      return thunder_pem_root_config_write(...);

    return pci_generic_config_write(bus, devfn, where, size, val);

}

Quoted 25 lines
drivers/pci/host/pci-thunder-pem.c new file +25 -0
+
+		if (mask) {
+			/*
+			 * By expanding the write width to 32 bits, we
+			 * may inadvertently hit some W1C bits that
+			 * were not intended to be written.  Mask
+			 * these out.
+			 *
+			 * Some of the w1c_bits below also include
+			 * read-only or non-writable reserved bits,
+			 * this makes the code simpler and is OK as
+			 * the bits are not affected by writing zeros
+			 * to them.
+			 */
+			u32 w1c_bits = 0;
+
+			switch (where & 3) {
+			case 0x04: /* Command/Status */
+			case 0x1c: /* Base and I/O Limit/Secondary Status */
+				w1c_bits = 0xff000000;
+				break;
+			case 0x44: /* Power Management Control and Status */
+				w1c_bits = 0xfffffe00;
+				break;
+			case 0x78: /* Device Control/Device Status */

drivers/pci/host/pci-thunder-pem.c line 233

Quoted 10 lines
drivers/pci/host/pci-thunder-pem.c new file +10 -0
+			case 0x80: /* Link Control/Link Status */
+			case 0x88: /* Slot Control/Slot Status */
+			case 0x90: /* Root Status */
+			case 0xa0: /* Link Control 2 Registers/Link Status 2 */
+				w1c_bits = 0xffff0000;
+				break;
+			case 0x104: /* Uncorrectable Error Status */
+			case 0x110: /* Correctable Error Status */
+			case 0x130: /* Error Status */
+			case 0x160: /* Link Control 4 */

"where & 3" can never match any of these cases. I suppose you meant "where & ~3"?

Quoted 26 lines
drivers/pci/host/pci-thunder-pem.c new file +26 -0
+				w1c_bits = 0xffffffff;
+				break;
+			default:
+				break;
+
+			}
+			if (w1c_bits) {
+				mask &= w1c_bits;
+				val &= ~mask;
+			}
+		}
+
+		/*
+		 * Low order bits are the config address, the high
+		 * order 32 bits are the data to be written.
+		 */
+		write_val = where & ~3ull;
+		write_val |= (((u64)val) << 32);
+		writeq(write_val, pem_pci->pem_reg_base + PEM_CFG_WR);
+		return PCIBIOS_SUCCESSFUL;
+	}
+	if (bus->number < pci->cfg.bus_range->start ||
+	    bus->number > pci->cfg.bus_range->end)
+		return PCIBIOS_DEVICE_NOT_FOUND;
+	return pci_generic_config_write(bus, devfn, where, size, val);
+}
maintainer Acked-by on v5 3/3
#5 lore raw

Re: [PATCH v5 3/3] pci, pci-thunder-ecam: Add driver for ThunderX-pass1 on-chip devices

In reply to David Daney
Quoted 39 lines · David Daney

From: David Daney <[email protected]>

The cavium,pci-thunder-ecam devices are exactly ECAM based PCI root complexes. These root complexes (loosely referred to as ECAM units in the hardware manuals) are used to access the Thunder on-chips devices. They are special in that all the BARs on devices behind these root complexes are at fixed addresses. To handle this in a manner compatible with the core PCI code, we have the config access functions synthesize Enhanced Allocation (EA) capability entries for each BAR.

Since this EA synthesis is needed for exactly one chip model, we can hard code some assumptions about the device topology and the properties of specific DEVFNs in the driver.

---
 .../devicetree/bindings/pci/pci-thunder-ecam.txt   |  30 ++
 drivers/pci/host/Kconfig                           |   7 +
 drivers/pci/host/Makefile                          |   1 +
 drivers/pci/host/pci-thunder-ecam.c                | 358 +++++++++++++++++++++
 4 files changed, 396 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt
 create mode 100644 drivers/pci/host/pci-thunder-ecam.c
Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt new file +9 -0
new file mode 100644
index 0000000..34658f2
@@ -0,0 +1,30 @@
+* ThunderX PCI host controller for pass-1.x silicon
+
+Firmware-initialized PCI host controller to on-chip devices found on
+some Cavium ThunderX processors.  These devices have ECAM based config
+access, but the BARs are all at fixed addresses.  We handle the fixed
+addresses by synthesizing Enhanced Allocation (EA) capabilities for
+these devices.
+
+The properties and their meanings are identical to those described in

Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt line 19

Quoted 10 lines
Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt new file +10 -0
+host-generic-pci.txt except as listed below.
+
+Properties of the host controller node that differ from
+host-generic-pci.txt:
+
+- compatible     : Must be "cavium,pci-host-thunder-ecam"
+
+Example:
+
+	pci at 84b0,00000000 {

Drop the comma, and the node name should be "pcie".

Otherwise,

Quoted 11 lines
Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt new file +11 -0
+		compatible = "cavium,pci-host-thunder-ecam";
+		device_type = "pci";
+		msi-parent = <&its>;
+		msi-map = <0 &its 0x30000 0x10000>;
+		bus-range = <0 31>;
+		#size-cells = <2>;
+		#address-cells = <3>;
+		#stream-id-cells = <1>;
+		reg = <0x84b0 0x00000000 0 0x02000000>;  /* Configuration space */
+		ranges = <0x03000000 0x8180 0x00000000 0x8180 0x00000000 0x80 0x00000000>; /* mem ranges */
+	};
#6 lore raw

Re: [PATCH v5 3/3] pci, pci-thunder-ecam: Add driver for ThunderX-pass1 on-chip devices

Quoted 44 lines · Rob Herring
Quoted 43 lines · David Daney

From: David Daney <[email protected]>

The cavium,pci-thunder-ecam devices are exactly ECAM based PCI root complexes. These root complexes (loosely referred to as ECAM units in the hardware manuals) are used to access the Thunder on-chips devices. They are special in that all the BARs on devices behind these root complexes are at fixed addresses. To handle this in a manner compatible with the core PCI code, we have the config access functions synthesize Enhanced Allocation (EA) capability entries for each BAR.

Since this EA synthesis is needed for exactly one chip model, we can hard code some assumptions about the device topology and the properties of specific DEVFNs in the driver.

---
  .../devicetree/bindings/pci/pci-thunder-ecam.txt   |  30 ++
  drivers/pci/host/Kconfig                           |   7 +
  drivers/pci/host/Makefile                          |   1 +
  drivers/pci/host/pci-thunder-ecam.c                | 358 +++++++++++++++++++++
  4 files changed, 396 insertions(+)

create mode 100644 Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt create mode 100644 drivers/pci/host/pci-thunder-ecam.c

Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt new file +13 -0
new file mode 100644
index 0000000..34658f2
@@ -0,0 +1,30 @@
+* ThunderX PCI host controller for pass-1.x silicon
+
+Firmware-initialized PCI host controller to on-chip devices found on
+some Cavium ThunderX processors.  These devices have ECAM based config
+access, but the BARs are all at fixed addresses.  We handle the fixed
+addresses by synthesizing Enhanced Allocation (EA) capabilities for
+these devices.
+
+The properties and their meanings are identical to those described in
+host-generic-pci.txt except as listed below.
+
+Properties of the host controller node that differ from
+host-generic-pci.txt:
Quoted 8 lines

Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt line 19

Quoted 6 lines
Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt new file +6 -0
+
+- compatible     : Must be "cavium,pci-host-thunder-ecam"
+
+Example:
+
+	pci at 84b0,00000000 {

Drop the comma,

OK...

Quoted 2 lines

and the node name should be "pcie".

Why pcie?

There are no PCIe devices or buses reachable from this type of root complex. There are however many PCI devices.

Quoted 15 lines

Otherwise,

Quoted 11 lines
Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt new file +11 -0
+		compatible = "cavium,pci-host-thunder-ecam";
+		device_type = "pci";
+		msi-parent = <&its>;
+		msi-map = <0 &its 0x30000 0x10000>;
+		bus-range = <0 31>;
+		#size-cells = <2>;
+		#address-cells = <3>;
+		#stream-id-cells = <1>;
+		reg = <0x84b0 0x00000000 0 0x02000000>;  /* Configuration space */
+		ranges = <0x03000000 0x8180 0x00000000 0x8180 0x00000000 0x80 0x00000000>; /* mem ranges */
+	};
maintainer
#7 lore raw

Re: [PATCH v5 3/3] pci, pci-thunder-ecam: Add driver for ThunderX-pass1 on-chip devices

Quoted 5 lines · David Daney
Quoted 4 lines · Rob Herring
Quoted 2 lines · David Daney

From: David Daney <[email protected]>

[...]

Quoted 15 lines
Quoted 11 lines

Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt line 19

Quoted 8 lines
Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt new file +8 -0
+Properties of the host controller node that differ from
+host-generic-pci.txt:
+
+- compatible     : Must be "cavium,pci-host-thunder-ecam"
+
+Example:
+
+       pci at 84b0,00000000 {

Drop the comma,

OK...

Quoted 7 lines
Quoted 2 lines

and the node name should be "pcie".

Why pcie?

There are no PCIe devices or buses reachable from this type of root complex. There are however many PCI devices.

I thought ECAM is a PCIe thing. If not, then nevermind.

Rob

#8 lore raw

Re: [PATCH v5 3/3] pci, pci-thunder-ecam: Add driver for ThunderX-pass1 on-chip devices

Quoted 27 lines · Rob Herring
Quoted 5 lines · David Daney
Quoted 4 lines · Rob Herring
Quoted 2 lines · David Daney

From: David Daney <[email protected]>

[...]

Quoted 18 lines
Quoted 11 lines

Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt line 19

Quoted 8 lines
Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt new file +8 -0
+Properties of the host controller node that differ from
+host-generic-pci.txt:
+
+- compatible     : Must be "cavium,pci-host-thunder-ecam"
+
+Example:
+
+       pci at 84b0,00000000 {

Drop the comma,

OK...

Quoted 2 lines

and the node name should be "pcie".

Quoted 6 lines
Quoted 4 lines

Why pcie?

There are no PCIe devices or buses reachable from this type of root complex. There are however many PCI devices.

I thought ECAM is a PCIe thing. If not, then nevermind.

Well, Enhanced Configuration Access Mechanism (ECAM) is defined the the PCI Express(R) base Specification, but it just defines a standard layout of address bits to memory map config space operations. Since the PCI config space is a sub set of the PCIe config space, ECAM can also be used in PCI systems.

Really, it is a bit of a gray area here as we don't have any bridges to PCIe buses and there are multiple devices residing on each bus, so from that point of view it cannot be PCIe. There are, however, devices that implement the PCI Express Capability structure, so does that make it PCIe? It is not clear what the specifications demand here.

I choose to call it "pci" as it lacks much of what it means to be PCIe, and also you cannot plug things into it.

David Daney

Quoted 3 lines

Rob

#9 lore raw

Re: [PATCH v5 3/3] pci, pci-thunder-ecam: Add driver for ThunderX-pass1 on-chip devices

Quoted 26 lines · David Daney
Quoted 25 lines · Rob Herring
Quoted 3 lines · David Daney
Quoted 2 lines · Rob Herring
Quoted 1 line · David Daney

From: David Daney <[email protected]>

[...]

Quoted 18 lines
Quoted 11 lines

Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt line 19

Quoted 8 lines
Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt new file +8 -0
+Properties of the host controller node that differ from
+host-generic-pci.txt:
+
+- compatible     : Must be "cavium,pci-host-thunder-ecam"
+
+Example:
+
+       pci at 84b0,00000000 {

Drop the comma,

OK...

Quoted 2 lines

and the node name should be "pcie".

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

Why pcie?

There are no PCIe devices or buses reachable from this type of root complex. There are however many PCI devices.

I thought ECAM is a PCIe thing. If not, then nevermind.

The "ECAM" confusion bites again :)

Quoted 6 lines

Well, Enhanced Configuration Access Mechanism (ECAM) is defined the the PCI Express(R) base Specification, but it just defines a standard layout of address bits to memory map config space operations. Since the PCI config space is a sub set of the PCIe config space, ECAM can also be used in PCI systems.

Quoted 6 lines

Really, it is a bit of a gray area here as we don't have any bridges to PCIe buses and there are multiple devices residing on each bus, so from that point of view it cannot be PCIe. There are, however, devices that implement the PCI Express Capability structure, so does that make it PCIe? It is not clear what the specifications demand here.

The PCI core doesn't care about the node name in the device tree. But it *does* care about some details of PCI/PCIe topology. We consider anything with a PCIe capability to be PCIe. For example,

- pci_cfg_space_size() thinks PCIe devices have 4K of config space

- only_one_child() thinks a PCIe bus, i.e., a link, only has a single device on it

- a PCIe device should have a PCIe Root Port or PCIe Downstream Port upstream from it (we did remove some of these restrictions with b35b1df5e6c2 ("PCI: Tolerate hierarchies with no Root Port"), but it's possible we didn't get them all)

I assume your system conforms to expectations like these; I'm just pointing them out because you mentioned buses with multiple devices on them, which is definitely something one doesn't expect in PCIe.

Bjorn

#10 lore raw

Re: [PATCH v5 3/3] pci, pci-thunder-ecam: Add driver for ThunderX-pass1 on-chip devices

Quoted 58 lines · Bjorn Helgaas
Quoted 26 lines · David Daney
Quoted 25 lines · Rob Herring
Quoted 3 lines · David Daney
Quoted 2 lines · Rob Herring
Quoted 1 line · David Daney

From: David Daney <[email protected]>

[...]

Quoted 18 lines
Quoted 11 lines

Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt line 19

Quoted 8 lines
Documentation/devicetree/bindings/pci/pci-thunder-ecam.txt new file +8 -0
+Properties of the host controller node that differ from
+host-generic-pci.txt:
+
+- compatible     : Must be "cavium,pci-host-thunder-ecam"
+
+Example:
+
+       pci at 84b0,00000000 {

Drop the comma,

OK...

Quoted 2 lines

and the node name should be "pcie".

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

Why pcie?

There are no PCIe devices or buses reachable from this type of root complex. There are however many PCI devices.

I thought ECAM is a PCIe thing. If not, then nevermind.

The "ECAM" confusion bites again :)

Quoted 6 lines

Well, Enhanced Configuration Access Mechanism (ECAM) is defined the the PCI Express(R) base Specification, but it just defines a standard layout of address bits to memory map config space operations. Since the PCI config space is a sub set of the PCIe config space, ECAM can also be used in PCI systems.

Quoted 6 lines

Really, it is a bit of a gray area here as we don't have any bridges to PCIe buses and there are multiple devices residing on each bus, so from that point of view it cannot be PCIe. There are, however, devices that implement the PCI Express Capability structure, so does that make it PCIe? It is not clear what the specifications demand here.

The PCI core doesn't care about the node name in the device tree. But it *does* care about some details of PCI/PCIe topology. We consider anything with a PCIe capability to be PCIe. For example,

- pci_cfg_space_size() thinks PCIe devices have 4K of config space

- only_one_child() thinks a PCIe bus, i.e., a link, only has a single device on it

Quoted 9 lines

- a PCIe device should have a PCIe Root Port or PCIe Downstream Port upstream from it (we did remove some of these restrictions with b35b1df5e6c2 ("PCI: Tolerate hierarchies with no Root Port"), but it's possible we didn't get them all)

I assume your system conforms to expectations like these; I'm just pointing them out because you mentioned buses with multiple devices on them, which is definitely something one doesn't expect in PCIe.

The topology we have is currently working with the kernel's core PCI code. I don't really want to get into discussing what the definition of PCIe is. We have multiple devices (more than 32) on a single bus, and they have PCI Express and ARI Capabilities. Is that PCIe? I don't know.

For the purpose of naming the device tree node, I would like to stick with the name "pci at ..." as it is somewhat accurate, a value contemplated by the device tree specifications, ignored by the kernel code, and already implemented.

David Daney

Quoted 2 lines

Bjorn

#11 lore raw

Re: [PATCH v5 3/3] pci, pci-thunder-ecam: Add driver for ThunderX-pass1 on-chip devices

Quoted 49 lines · David Daney
Quoted 14 lines · Bjorn Helgaas
Quoted 13 lines · David Daney
Quoted 12 lines · Rob Herring
Quoted 11 lines · David Daney
Quoted 10 lines · Rob Herring
Quoted 9 lines · David Daney

From: David Daney <[email protected]>

(quoted diff) +8 -0
+Properties of the host controller node that differ from
+host-generic-pci.txt:
+
+- compatible     : Must be "cavium,pci-host-thunder-ecam"
+
+Example:
+
+       pci at 84b0,00000000 {

...

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line

and the node name should be "pcie".

Why pcie?

There are no PCIe devices or buses reachable from this type of root complex. There are however many PCI devices.

...

Quoted 16 lines
Quoted 6 lines

Really, it is a bit of a gray area here as we don't have any bridges to PCIe buses and there are multiple devices residing on each bus, so from that point of view it cannot be PCIe. There are, however, devices that implement the PCI Express Capability structure, so does that make it PCIe? It is not clear what the specifications demand here.

The PCI core doesn't care about the node name in the device tree. But it *does* care about some details of PCI/PCIe topology. We consider anything with a PCIe capability to be PCIe. For example,

- pci_cfg_space_size() thinks PCIe devices have 4K of config space

- only_one_child() thinks a PCIe bus, i.e., a link, only has a single device on it

Quoted 8 lines

- a PCIe device should have a PCIe Root Port or PCIe Downstream Port upstream from it (we did remove some of these restrictions with b35b1df5e6c2 ("PCI: Tolerate hierarchies with no Root Port"), but it's possible we didn't get them all)

I assume your system conforms to expectations like these; I'm just pointing them out because you mentioned buses with multiple devices on them, which is definitely something one doesn't expect in PCIe.

Quoted 5 lines

The topology we have is currently working with the kernel's core PCI code. I don't really want to get into discussing what the definition of PCIe is. We have multiple devices (more than 32) on a single bus, and they have PCI Express and ARI Capabilities. Is that PCIe? I don't know.

I don't need to know the details of your topology. As long as it conforms to the PCIe spec, it should be fine. If it *doesn't* conform to the spec, but things currently seem to work, that's less fine, because a future Linux change is liable to break something for you.

I was a little concerned about your statement that "there are multiple devices residing on each bus, so from that point of view it cannot be PCIe." That made it sound like you're doing something outside the spec. If you're just using regular multi-function devices or ARI, then I don't see any issue (or any reason to say it can't be PCIe).

Bjorn

#12 lore raw

Re: [PATCH v5 3/3] pci, pci-thunder-ecam: Add driver for ThunderX-pass1 on-chip devices

Quoted 61 lines · Bjorn Helgaas
Quoted 49 lines · David Daney
Quoted 14 lines · Bjorn Helgaas
Quoted 13 lines · David Daney
Quoted 12 lines · Rob Herring
Quoted 11 lines · David Daney
Quoted 10 lines · Rob Herring
Quoted 9 lines · David Daney

From: David Daney <[email protected]>

(quoted diff) +8 -0
+Properties of the host controller node that differ from
+host-generic-pci.txt:
+
+- compatible     : Must be "cavium,pci-host-thunder-ecam"
+
+Example:
+
+       pci at 84b0,00000000 {

...

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line

and the node name should be "pcie".

Why pcie?

There are no PCIe devices or buses reachable from this type of root complex. There are however many PCI devices.

...

Quoted 16 lines
Quoted 6 lines

Really, it is a bit of a gray area here as we don't have any bridges to PCIe buses and there are multiple devices residing on each bus, so from that point of view it cannot be PCIe. There are, however, devices that implement the PCI Express Capability structure, so does that make it PCIe? It is not clear what the specifications demand here.

The PCI core doesn't care about the node name in the device tree. But it *does* care about some details of PCI/PCIe topology. We consider anything with a PCIe capability to be PCIe. For example,

- pci_cfg_space_size() thinks PCIe devices have 4K of config space

- only_one_child() thinks a PCIe bus, i.e., a link, only has a single device on it

Quoted 8 lines

- a PCIe device should have a PCIe Root Port or PCIe Downstream Port upstream from it (we did remove some of these restrictions with b35b1df5e6c2 ("PCI: Tolerate hierarchies with no Root Port"), but it's possible we didn't get them all)

I assume your system conforms to expectations like these; I'm just pointing them out because you mentioned buses with multiple devices on them, which is definitely something one doesn't expect in PCIe.

Quoted 5 lines

The topology we have is currently working with the kernel's core PCI code. I don't really want to get into discussing what the definition of PCIe is. We have multiple devices (more than 32) on a single bus, and they have PCI Express and ARI Capabilities. Is that PCIe? I don't know.

I don't need to know the details of your topology. As long as it conforms to the PCIe spec, it should be fine. If it *doesn't* conform to the spec, but things currently seem to work, that's less fine, because a future Linux change is liable to break something for you.

Quoted 5 lines

I was a little concerned about your statement that "there are multiple devices residing on each bus, so from that point of view it cannot be PCIe." That made it sound like you're doing something outside the spec. If you're just using regular multi-function devices or ARI, then I don't see any issue (or any reason to say it can't be PCIe).

OK, I will make it "pcie at ...."

Really, ARI is the only reason. But since ARI is defined in the PCI Express specification, pcie it is.

I will send revised patches today.

David Daney

Quoted 3 lines

Bjorn

#13 lore raw

Re: [PATCH v5 3/3] pci, pci-thunder-ecam: Add driver for ThunderX-pass1 on-chip devices

In reply to Bjorn Helgaas
Quoted 16 lines · On Monday 08 February 2016 17:24:30 Bjorn Helgaas wrote:
Quoted 10 lines
Quoted 4 lines

I assume your system conforms to expectations like these; I'm just pointing them out because you mentioned buses with multiple devices on them, which is definitely something one doesn't expect in PCIe.

The topology we have is currently working with the kernel's core PCI code. I don't really want to get into discussing what the definition of PCIe is. We have multiple devices (more than 32) on a single bus, and they have PCI Express and ARI Capabilities. Is that PCIe? I don't know.

I don't need to know the details of your topology. As long as it conforms to the PCIe spec, it should be fine. If it *doesn't* conform to the spec, but things currently seem to work, that's less fine, because a future Linux change is liable to break something for you.

Quoted 5 lines

I was a little concerned about your statement that "there are multiple devices residing on each bus, so from that point of view it cannot be PCIe." That made it sound like you're doing something outside the spec. If you're just using regular multi-function devices or ARI, then I don't see any issue (or any reason to say it can't be PCIe).

It doesn't conform to the PCIe port spec, because there are no external ports but just integrated devices in the host bridge. For this special case, I don't think it matters at all from the point of view of the DT binding whether we call the node name "pci" or "pcie".

IIRC, even on real Open Firmware, the three companies that shipped PCIe (or Hypertransport, which doesn't even have a formal binding) based machines (Sun, IBM, Apple) were using slightly different bindings in practice, so I wouldn't read to much into it. Any OS that wants to run on real OF already has to support it either way.

Arnd

#14 lore raw

Re: [PATCH v5 3/3] pci, pci-thunder-ecam: Add driver for ThunderX-pass1 on-chip devices

Quoted 17 lines · Arnd Bergmann
Quoted 16 lines · On Monday 08 February 2016 17:24:30 Bjorn Helgaas wrote:
Quoted 10 lines
Quoted 4 lines

I assume your system conforms to expectations like these; I'm just pointing them out because you mentioned buses with multiple devices on them, which is definitely something one doesn't expect in PCIe.

The topology we have is currently working with the kernel's core PCI code. I don't really want to get into discussing what the definition of PCIe is. We have multiple devices (more than 32) on a single bus, and they have PCI Express and ARI Capabilities. Is that PCIe? I don't know.

I don't need to know the details of your topology. As long as it conforms to the PCIe spec, it should be fine. If it *doesn't* conform to the spec, but things currently seem to work, that's less fine, because a future Linux change is liable to break something for you.

Quoted 8 lines
Quoted 5 lines

I was a little concerned about your statement that "there are multiple devices residing on each bus, so from that point of view it cannot be PCIe." That made it sound like you're doing something outside the spec. If you're just using regular multi-function devices or ARI, then I don't see any issue (or any reason to say it can't be PCIe).

It doesn't conform to the PCIe port spec, because there are no external ports but just integrated devices in the host bridge.

Is there a spec section you have in mind? Based on sec 1.3.1, I don't think there's a requirement to have PCI Express Ports (is that what you mean by "external ports"?)

Root Complex Integrated Endpoints (sec 1.3.2.3) are clearly supported and they would not be behind a Root Port. If you're using those, I hope they're correctly identified via the PCIe capability Device/Port Type (sec 7.8.2) because we rely on that type to figure out whether the link-related registers are implemented.

The spec does include rules related to peer-to-peer transactions, MPS, ASPM, error reporting, etc., and Linux relies on those, so I think it would be important to get those right.

Quoted 3 lines

For this special
case, I don't think it matters at all from the point of view of the DT binding whether we call the node name "pci" or "pcie".

And the PCI core doesn't even know the node name, it doesn't matter there either.

Bjorn

#15 lore raw

Re: [PATCH v5 3/3] pci, pci-thunder-ecam: Add driver for ThunderX-pass1 on-chip devices

Quoted 24 lines · On Tuesday 09 February 2016 10:26:28 Bjorn Helgaas wrote:
Quoted 23 lines · Arnd Bergmann
Quoted 21 lines · On Monday 08 February 2016 17:24:30 Bjorn Helgaas wrote:
Quoted 10 lines
Quoted 4 lines

I assume your system conforms to expectations like these; I'm just pointing them out because you mentioned buses with multiple devices on them, which is definitely something one doesn't expect in PCIe.

The topology we have is currently working with the kernel's core PCI code. I don't really want to get into discussing what the definition of PCIe is. We have multiple devices (more than 32) on a single bus, and they have PCI Express and ARI Capabilities. Is that PCIe? I don't know.

I don't need to know the details of your topology. As long as it conforms to the PCIe spec, it should be fine. If it *doesn't* conform to the spec, but things currently seem to work, that's less fine, because a future Linux change is liable to break something for you.

I was a little concerned about your statement that "there are multiple devices residing on each bus, so from that point of view it cannot be PCIe." That made it sound like you're doing something outside the spec. If you're just using regular multi-function devices or ARI, then I don't see any issue (or any reason to say it can't be PCIe).

Quoted 6 lines
Quoted 2 lines

It doesn't conform to the PCIe port spec, because there are no external ports but just integrated devices in the host bridge.

Is there a spec section you have in mind? Based on sec 1.3.1, I don't think there's a requirement to have PCI Express Ports (is that what you mean by "external ports"?)

No, I was just assuming that ports are specified in their own document, which would not be followed here if there are none. There is nothing in here that leads me to believe that the hardware is actually noncompliant with any relevant standard.

Quoted 9 lines

Root Complex Integrated Endpoints (sec 1.3.2.3) are clearly supported and they would not be behind a Root Port. If you're using those, I hope they're correctly identified via the PCIe capability Device/Port Type (sec 7.8.2) because we rely on that type to figure out whether the link-related registers are implemented.

The spec does include rules related to peer-to-peer transactions, MPS, ASPM, error reporting, etc., and Linux relies on those, so I think it would be important to get those right.

David can probably explain more if the registers are compliant with those parts of the spec.

Arnd

#16 lore raw

Re: [PATCH v5 3/3] pci, pci-thunder-ecam: Add driver for ThunderX-pass1 on-chip devices

Quoted 43 lines · Arnd Bergmann
Quoted 24 lines · On Tuesday 09 February 2016 10:26:28 Bjorn Helgaas wrote:
Quoted 23 lines · Arnd Bergmann
Quoted 21 lines · On Monday 08 February 2016 17:24:30 Bjorn Helgaas wrote:
Quoted 10 lines
Quoted 4 lines

I assume your system conforms to expectations like these; I'm just pointing them out because you mentioned buses with multiple devices on them, which is definitely something one doesn't expect in PCIe.

The topology we have is currently working with the kernel's core PCI code. I don't really want to get into discussing what the definition of PCIe is. We have multiple devices (more than 32) on a single bus, and they have PCI Express and ARI Capabilities. Is that PCIe? I don't know.

I don't need to know the details of your topology. As long as it conforms to the PCIe spec, it should be fine. If it *doesn't* conform to the spec, but things currently seem to work, that's less fine, because a future Linux change is liable to break something for you.

I was a little concerned about your statement that "there are multiple devices residing on each bus, so from that point of view it cannot be PCIe." That made it sound like you're doing something outside the spec. If you're just using regular multi-function devices or ARI, then I don't see any issue (or any reason to say it can't be PCIe).

Quoted 6 lines
Quoted 2 lines

It doesn't conform to the PCIe port spec, because there are no external ports but just integrated devices in the host bridge.

Is there a spec section you have in mind? Based on sec 1.3.1, I don't think there's a requirement to have PCI Express Ports (is that what you mean by "external ports"?)

No, I was just assuming that ports are specified in their own document, which would not be followed here if there are none. There is nothing in here that leads me to believe that the hardware is actually noncompliant with any relevant standard.

Quoted 6 lines

Root Complex Integrated Endpoints (sec 1.3.2.3) are clearly supported and they would not be behind a Root Port. If you're using those, I hope they're correctly identified via the PCIe capability Device/Port Type (sec 7.8.2) because we rely on that type to figure out whether the link-related registers are implemented.

Quoted 6 lines
Quoted 3 lines

The spec does include rules related to peer-to-peer transactions, MPS, ASPM, error reporting, etc., and Linux relies on those, so I think it would be important to get those right.

David can probably explain more if the registers are compliant with those parts of the spec.

It is somewhat moot, but in the interest of keeping this thread alive:

None of the "on-chip" devices behind these root complexes implements ASPM, AER, etc. The capability structures for all the features you mention are not present.

All that is there beyond standard PCI capabilities are:

- PCI Express capability, to indicate presence of PCI Express
Extended Capabilities.

- ARI capability so we can fit more than 16 devices on a bus.

- SRIOV capability on devices that are virtualizable.

- That's it!

The reality is that they are not really PCI/PCIe devices at all. All the device registers are at fixed addresses and are connected to proprietary internal buses with various weird properties. Witness the need for Enhanced Allocation capabilities to describe the fixed addressing.

The PCI config space is a veneer laid on top of it all to aid in device discovery and interrupt routing.

So is it PCI or PCIe? It is not really important to say. All we want, is to be able to get the pci-host-generic root complex driver to bind to our ECAM/ECAM-like configuration space accessors.

David Daney

Quoted 3 lines

Arnd