APM X-Gene PCIe host controller
v9 cover APM X-Gene PCIe host controller
This patch adds support for AppliedMicro X-Gene PCIe host controller. The driver is tested on X-Gene platform with different gen1/2/3 PCIe endpoint cards.
X-Gene PCIe controller driver has depedency on the pcie arm64 arch support. Liviu Dudau from ARM has sent a patch set for pcie arm64 arch support and support for creating generic pcie bridge from device tree. Liviu's patches are available here
https://lkml.org/lkml/2014/9/8/333
If someone wishes to test PCIe on X-Gene with this patch set, above mentioned patches from Liviu must be applied before the patches in this patch set. Also please use latest xgene u-boot firmware.
changes since V8:
1. Add 'dma-coherent' attribute in device node.
changes since V7:
1. Fix outbound region mapping for IO region. Thanks Liviu for the catch.
changes since V6:
1. Port driver to changed interface as per Liviu's v10 series.
changes since V5:
1. Port driver to changed interface of 'of_create_pci_host_bridge'
2. Fix the prefetch bit setting
3. Removed bunch of register programming which is already done by firmware
changes since V4:
1. fix section mismatch warnings
2. fix the patch description
3. fix indentation
4. update read/write cfg functions by passing both addr and offset.
5. use 'time_before' for timeout.
6. remove unnecessary 'IS_ERR_OR_NULL'. Keep 'IS_ERR' for 'clk_get'
7. remove BUG_ON for pci_ioremap_io.
changes since V3:
1. remove 'struct hw_pci' and supporting ops in hw_pci
2. add code to create the host bridge from dts
3. add code to scan the the host bridge
4. modify outbound windows setup function to get resource information from 'bridge->windows'
5. add compatible string in pcie dts node with current X-Gene SOC name.
changes since V2:
1. redefined each PCI port in different PCI domain correctly.
2. removed setup_lane and setup_link functions from driver.
3. removed scan_bus wrapper and set_primary_bus hack.
4. added pci_ioremap_io for io resources.
changes since V1:
1. added PCI domain support
2. reading cpu and pci addresses from device tree to configure regions.
3. got rid of unnecessary wrappers for readl and writel.
4. got rid of endpoint configuration code.
5. added 'dma-ranges' property support to read inbound region configuration.
6. renamed host driver file to 'pci-xgene.c' from 'pcie-xgene.c'
7. dropped 'clock-names' property from bindings
8. added comments whereever requested.
Tanmay Inamdar (4):
pci:host: APM X-Gene PCIe host controller driver
arm64: dts: APM X-Gene PCIe device tree nodes
dt-bindings: pci: xgene pcie device tree bindings
MAINTAINERS: entry for APM X-Gene PCIe host driver
.../devicetree/bindings/pci/xgene-pci.txt | 57 ++ MAINTAINERS | 8 + arch/arm64/boot/dts/apm-mustang.dts | 8 + arch/arm64/boot/dts/apm-storm.dtsi | 165 ++++++ drivers/pci/host/Kconfig | 10 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pci-xgene.c | 646 +++++++++++++++++++++ 7 files changed, 895 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/xgene-pci.txt create mode 100644 drivers/pci/host/pci-xgene.c
Signature · 1 line
1.9.1
PATCH v9 1/4 pci:host: APM X-Gene PCIe host controller driver
This patch adds the AppliedMicro X-Gene SOC PCIe host controller driver. X-Gene PCIe controller supports maximum up to 8 lanes and GEN3 speed. X-Gene SOC supports maximum 5 PCIe ports.
--- drivers/pci/host/Kconfig | 10 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pci-xgene.c | 646 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 657 insertions(+) create mode 100644 drivers/pci/host/pci-xgene.c
drivers/pci/host/Kconfig +10 -0
@@ -63,4 +63,14 @@ config PCIE_SPEAR13XX help Say Y here if you want PCIe support on SPEAr13XX SoCs. +config PCI_XGENE + bool "X-Gene PCIe controller" + depends on ARCH_XGENE + depends on OF + select PCIEPORTBUS + help + Say Y here if you want internal PCI support on APM X-Gene SoC. + There are 5 internal PCIe ports available. Each port is GEN3 capable + and have varied lanes from x1 to x8. + endmenu
drivers/pci/host/Makefile +1 -0
@@ -8,3 +8,4 @@ obj-$(CONFIG_PCI_RCAR_GEN2) += pci-rcar-gen2.o obj-$(CONFIG_PCI_RCAR_GEN2_PCIE) += pcie-rcar.o obj-$(CONFIG_PCI_HOST_GENERIC) += pci-host-generic.o obj-$(CONFIG_PCIE_SPEAR13XX) += pcie-spear13xx.o +obj-$(CONFIG_PCI_XGENE) += pci-xgene.o
drivers/pci/host/pci-xgene.c new file +646 -0
646 lines not on this page · raw message
Signature · 1 line
1.9.1
Bjorn Helgaas
maintainerRe: [PATCH v9 1/4] pci:host: APM X-Gene PCIe host controller driver
Quoted 14 lines · Tanmay Inamdar
This patch adds the AppliedMicro X-Gene SOC PCIe host controller driver. X-Gene PCIe controller supports maximum up to 8 lanes and GEN3 speed. X-Gene SOC supports maximum 5 PCIe ports.
Reviewed-by Liviu Dudau <[email protected]>Signed-off-by Tanmay Inamdar <[email protected]>--- drivers/pci/host/Kconfig | 10 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pci-xgene.c | 646 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 657 insertions(+) create mode 100644 drivers/pci/host/pci-xgene.c...
drivers/pci/host/pci-xgene.c line 132
Quoted 2 lines
drivers/pci/host/pci-xgene.c new file +2
-0+static inline void +xgene_pcie_cfg_in16 (void __iomem *addr,int offset,u32 *val)
Whitespace - can fit on one line. Also others below.
Quoted 24 lines
drivers/pci/host/pci-xgene.c new file +24
-0+{ + *val =readl (addr + (offset & ~0x3 )); + +switch (offset &0x3 ) { +case 2 : + *val >>=16 ; +break ; + } + + *val &=0xFFFF ; +} + +static inline void +xgene_pcie_cfg_in8 (void __iomem *addr,int offset,u32 *val) +{ + *val =readl (addr + (offset & ~0x3 )); + +switch (offset &0x3 ) { +case 3 : + *val = *val >>24 ; +break ; +case 2 : + *val = *val >>16 ; +break ;
drivers/pci/host/pci-xgene.c line 166
Quoted 10 lines
drivers/pci/host/pci-xgene.c new file +10
-0+case 1 : + *val = *val >>8 ; +break ; + } + *val &=0xFF ; +} + +/* When the address bit [17:16] is 2'b01, the Configuration access will be +* treated as Type 1 and it will be forwarded to external PCIe device. +*/
Follow usual block comment style:
/*
* text
*/drivers/pci/host/pci-xgene.c line 321
Quoted 8 lines
...
drivers/pci/host/pci-xgene.c new file +7
-0+static void xgene_pcie_fixup_bridge (struct pci_dev *dev) +{ +int i; + +/* Hide the PCI host BARs from the kernel as their content doesn't +* fit well in the resource management +*/
This needs a better explanation than "doesn't fit well."
I *think* you're probably talking about something similar to the MVEBU
devices mentioned here:
http://lkml.kernel.org/r/CAErSpo56jB1Bf2JtYCGKXZBZqRF1jXFxGmeewPX_e6vSXueGyA at mail.gmail.com
where the device can be configured as either an endpoint or a root port, and the endpoint BARs are still visible when configured as a root port.
In any event, I'd like a description of exactly what these BARs are and wha the problem is. Presumably the BARs exist and were sized by the PCI core in __pci_read_base(). That will generate some log messages and possibly some warnings, depending on how the host bridge windows are set up.
We might eventually need a way to skip BARs like that altogether so we don't even try to size them.
Quoted 25 lines
drivers/pci/host/pci-xgene.c new file +23
-0+for (i =0 ; i <DEVICE_COUNT_RESOURCE ; i++) { + dev->resource[i].start = dev->resource[i].end =0 ; + dev->resource[i].flags =0 ; + } +dev_info (&dev->dev,"Hiding X-Gene pci host bridge resources %s\n" , +pci_name (dev)); +} +DECLARE_PCI_FIXUP_HEADER (XGENE_PCIE_VENDORID ,XGENE_PCIE_DEVICEID , + xgene_pcie_fixup_bridge); + +static void xgene_pcie_setup_ob_reg (struct xgene_pcie_port *port, +struct resource *res,u32 offset, +u64 cpu_addr,u64 pci_addr) +{ +void __iomem *base = port->csr_base + offset; +resource_size_t size =resource_size (res); +u64 restype =resource_type (res); +u64 mask =0 ; +u32 min_size; +u32 flag =EN_REG ; + +if (restype ==IORESOURCE_MEM ) { + min_size =SZ_128M ;
drivers/pci/host/pci-xgene.c line 373
Quoted 10 lines
drivers/pci/host/pci-xgene.c new file +10
-0+ }else { + min_size =128 ; + flag |=OB_LO_IO ; + } + +if (size >= min_size) + mask = ~(size -1 ) | flag; +else +dev_warn (port->dev,"res size 0x%llx less than minimum 0x%x\n" , + (u64 )size, min_size);
I'd include a %pR here to help identify the offending resource.
Quoted 4 lines
drivers/pci/host/pci-xgene.c new file +4
-0+static int xgene_pcie_map_ranges (struct xgene_pcie_port *port, +struct list_head *res, +resource_size_t io_base) +{
drivers/pci/host/pci-xgene.c line 403
Quoted 10 lines
drivers/pci/host/pci-xgene.c new file +10
-0+struct pci_host_bridge_window *window; +struct device *dev = port->dev; +int ret; + +list_for_each_entry (window, res, list) { +struct resource *res = window->res; +u64 restype =resource_type (res); + +dev_dbg (port->dev,"0x%08lx 0x%016llx...0x%016llx\n" , + res->flags, res->start, res->end);
Use %pR here.
Quoted 7 lines
drivers/pci/host/pci-xgene.c new file +7
-0+ +switch (restype) { +case IORESOURCE_IO : +xgene_pcie_setup_ob_reg (port, res,OMR3BARL , io_base, + res->start - window->offset); + ret =pci_remap_iospace (res, io_base); +if (ret <0 )
drivers/pci/host/pci-xgene.c line 420
Quoted 10 lines
drivers/pci/host/pci-xgene.c new file +10
-0+return ret; +break ; +case IORESOURCE_MEM : +xgene_pcie_setup_ob_reg (port, res,OMR1BARL , res->start, + res->start - window->offset); +break ; +case IORESOURCE_BUS : +break ; +default : +dev_err (dev,"invalid io resource!" );
If you're going to print something here, you might as well include the type that seems invalid. If you use %pR, I think it will do that automatically.
drivers/pci/host/pci-xgene.c line 427
Quoted 7 lines
drivers/pci/host/pci-xgene.c new file +7
-0+return -EINVAL ; + } + } +xgene_pcie_setup_cfg_reg (port->csr_base, port->cfg_addr); + +return 0 ; +}
Bjorn
Re: [PATCH v9 1/4] pci:host: APM X-Gene PCIe host controller driver
Hello Bjorn,
Thanks for the review and comments. Please see my inline replies.
Thanks,
Tanmay
Quoted 15 lines · Bjorn Helgaas
Quoted 13 lines · Tanmay Inamdar
This patch adds the AppliedMicro X-Gene SOC PCIe host controller driver. X-Gene PCIe controller supports maximum up to 8 lanes and GEN3 speed. X-Gene SOC supports maximum 5 PCIe ports.
Reviewed-by Liviu Dudau <[email protected]>Signed-off-by Tanmay Inamdar <[email protected]>--- drivers/pci/host/Kconfig | 10 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pci-xgene.c | 646 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 657 insertions(+) create mode 100644 drivers/pci/host/pci-xgene.c...
Quoted 4 lines
drivers/pci/host/pci-xgene.c line 132
Quoted 2 lines
drivers/pci/host/pci-xgene.c new file +2
-0+static inline void +xgene_pcie_cfg_in16 (void __iomem *addr,int offset,u32 *val)Whitespace - can fit on one line. Also others below.
Thanks. Will fix it.
Quoted 38 lines
Quoted 25 lines
drivers/pci/host/pci-xgene.c new file +24
-0+{ + *val =readl (addr + (offset & ~0x3 )); + +switch (offset &0x3 ) { +case 2 : + *val >>=16 ; +break ; + } + + *val &=0xFFFF ; +} + +static inline void +xgene_pcie_cfg_in8 (void __iomem *addr,int offset,u32 *val) +{ + *val =readl (addr + (offset & ~0x3 )); + +switch (offset &0x3 ) { +case 3 : + *val = *val >>24 ; +break ; +case 2 : + *val = *val >>16 ; +break ;drivers/pci/host/pci-xgene.c line 166
Quoted 10 lines
drivers/pci/host/pci-xgene.c new file +10
-0+case 1 : + *val = *val >>8 ; +break ; + } + *val &=0xFF ; +} + +/* When the address bit [17:16] is 2'b01, the Configuration access will be +* treated as Type 1 and it will be forwarded to external PCIe device. +*/ Follow usual block comment style:
Quoted 4 lines
/*
* text
*/Thanks. Will fix it.
Quoted 11 lines
drivers/pci/host/pci-xgene.c line 321
Quoted 8 lines
...
drivers/pci/host/pci-xgene.c new file +7
-0+static void xgene_pcie_fixup_bridge (struct pci_dev *dev) +{ +int i; + +/* Hide the PCI host BARs from the kernel as their content doesn't +* fit well in the resource management +*/ This needs a better explanation than "doesn't fit well."
Quoted 7 lines
I *think* you're probably talking about something similar to the MVEBU
devices mentioned here:
http://lkml.kernel.org/r/CAErSpo56jB1Bf2JtYCGKXZBZqRF1jXFxGmeewPX_e6vSXueGyA at mail.gmail.comwhere the device can be configured as either an endpoint or a root port, and the endpoint BARs are still visible when configured as a root port.
It is true that X-Gene PCIe port can be configured as EP, however the the FIXUP is required not because of the BARs are still visible when configured as EP in past. X-Gene PCIe port, when configured as RC, uses BAR0-BAR1 of RC's configuration space as inbound BARs. Entire DDR region is mapped in these BARs so that it is accessible for EP devices for DMA. So if the fixup is not done during enumeration, whole outbound memory resource space gets assigned to RC and nothing is left EP devices.
Quoted 2 lines
In any event, I'd like a description of exactly what these BARs are and wha the problem is.
Is it ok to put above description in comment to explain the fixup?
Quoted 4 lines
Presumably the BARs exist and were sized by the PCI core
in__pci_read_base(). That will generate some log messages and possibly some warnings, depending on how the host bridge windows are set up.
xgene-pcie 1f2b0000.pcie: PCI host bridge to bus 0000:00pci_bus 0000:00: root bus resource [bus 00-ff]pci_bus 0000:00: root bus resource [io 0x0000-0xffff]pci_bus 0000:00: root bus resource [mem 0xe180000000-0xe1ffffffff] (bus address [0x80000000-0xffffffff])pci_bus 0000:00: scanning bus
pci 0000:00:00.0: [10e8:e004] type 01 class 0x060400
pci 0000:00:00.0: reg 0x10: [mem 0x8000000000-0x807fffffff 64bit pref] pci 0000:00:00.0: supports D1 D2pci_bus 0000:00: fixups for bus
pci 0000:00:00.0: scanning [bus 01-01] behind bridge, pass 0 pci_bus 0000:01: scanning bus
pci 0000:01:00.0: [15b3:1003] type 00 class 0x020000
pci 0000:01:00.0: reg 0x10: [mem 0x00100000-0x001fffff 64bit] pci 0000:01:00.0: reg 0x18: [mem 0x00800000-0x00ffffff 64bit pref] pci 0000:01:00.0: reg 0x30: [mem 0x01000000-0x010fffff pref] pci_bus 0000:01: fixups for buspci_bus 0000:01: bus scan returning with max=01
pci 0000:00:00.0: scanning [bus 01-01] behind bridge, pass 1 pci_bus 0000:00: bus scan returning with max=01
pci 0000:00:00.0: BAR 0: assigned [mem 0xe180000000-0xe1ffffffff 64bit pref] pci 0000:00:00.0: BAR 9: no space for [mem size 0x00800000 64bit pref] pci 0000:00:00.0: BAR 9: failed to assign [mem size 0x00800000 64bit pref] pci 0000:00:00.0: BAR 8: no space for [mem size 0x00200000]
pci 0000:00:00.0: BAR 8: failed to assign [mem size 0x00200000] pci 0000:01:00.0: BAR 2: no space for [mem size 0x00800000 64bit pref] pci 0000:01:00.0: BAR 2: failed to assign [mem size 0x00800000 64bit pref] pci 0000:01:00.0: BAR 0: no space for [mem size 0x00100000 64bit] pci 0000:01:00.0: BAR 0: failed to assign [mem size 0x00100000 64bit] pci 0000:01:00.0: BAR 6: no space for [mem size 0x00100000 pref] pci 0000:01:00.0: BAR 6: failed to assign [mem size 0x00100000 pref]
Quoted 32 lines
We might eventually need a way to skip BARs like that altogether so we don't even try to size them.
Quoted 29 lines
drivers/pci/host/pci-xgene.c new file +27
-0+for (i =0 ; i <DEVICE_COUNT_RESOURCE ; i++) { + dev->resource[i].start = dev->resource[i].end =0 ; + dev->resource[i].flags =0 ; + } +dev_info (&dev->dev,"Hiding X-Gene pci host bridge resources %s\n" , +pci_name (dev)); +} +DECLARE_PCI_FIXUP_HEADER (XGENE_PCIE_VENDORID ,XGENE_PCIE_DEVICEID , + xgene_pcie_fixup_bridge); + +static void xgene_pcie_setup_ob_reg (struct xgene_pcie_port *port, +struct resource *res,u32 offset, +u64 cpu_addr,u64 pci_addr) +{ +void __iomem *base = port->csr_base + offset; +resource_size_t size =resource_size (res); +u64 restype =resource_type (res); +u64 mask =0 ; +u32 min_size; +u32 flag =EN_REG ; + +if (restype ==IORESOURCE_MEM ) { + min_size =SZ_128M ; + }else { + min_size =128 ; + flag |=OB_LO_IO ; + }
Quoted 9 lines
drivers/pci/host/pci-xgene.c line 373
Quoted 6 lines
drivers/pci/host/pci-xgene.c new file +6
-0+ +if (size >= min_size) + mask = ~(size -1 ) | flag; +else +dev_warn (port->dev,"res size 0x%llx less than minimum 0x%x\n" , + (u64 )size, min_size);I'd include a %pR here to help identify the offending resource.
Will change it in next revision.
Quoted 8 lines
Quoted 8 lines
drivers/pci/host/pci-xgene.c new file +8
-0+static int xgene_pcie_map_ranges (struct xgene_pcie_port *port, +struct list_head *res, +resource_size_t io_base) +{ +struct pci_host_bridge_window *window; +struct device *dev = port->dev; +int ret; +
Quoted 9 lines
drivers/pci/host/pci-xgene.c line 403
Quoted 6 lines
drivers/pci/host/pci-xgene.c new file +6
-0+list_for_each_entry (window, res, list) { +struct resource *res = window->res; +u64 restype =resource_type (res); + +dev_dbg (port->dev,"0x%08lx 0x%016llx...0x%016llx\n" , + res->flags, res->start, res->end);Use %pR here.
Will change it in next revision.
Quoted 18 lines
Quoted 7 lines
drivers/pci/host/pci-xgene.c new file +7
-0+ +switch (restype) { +case IORESOURCE_IO : +xgene_pcie_setup_ob_reg (port, res,OMR3BARL , io_base, + res->start - window->offset); + ret =pci_remap_iospace (res, io_base); +if (ret <0 )drivers/pci/host/pci-xgene.c line 420
Quoted 10 lines
drivers/pci/host/pci-xgene.c new file +10
-0+return ret; +break ; +case IORESOURCE_MEM : +xgene_pcie_setup_ob_reg (port, res,OMR1BARL , res->start, + res->start - window->offset); +break ; +case IORESOURCE_BUS : +break ; +default : +dev_err (dev,"invalid io resource!" );
Quoted 3 lines
If you're going to print something here, you might as well include the type that seems invalid. If you use %pR, I think it will do that automatically.
Will change it in next revision.
Quoted 9 lines
drivers/pci/host/pci-xgene.c line 427
Quoted 7 lines
drivers/pci/host/pci-xgene.c new file +7
-0+return -EINVAL ; + } + } +xgene_pcie_setup_cfg_reg (port->csr_base, port->cfg_addr); + +return 0 ; +}Bjorn
Bjorn Helgaas
maintainerRe: [PATCH v9 1/4] pci:host: APM X-Gene PCIe host controller driver
Quoted 18 lines · Tanmay Inamdar
Quoted 10 lines
drivers/pci/host/pci-xgene.c line 321
Quoted 7 lines
drivers/pci/host/pci-xgene.c new file +7
-0+static void xgene_pcie_fixup_bridge (struct pci_dev *dev) +{ +int i; + +/* Hide the PCI host BARs from the kernel as their content doesn't +* fit well in the resource management +*/ This needs a better explanation than "doesn't fit well."
Quoted 7 lines
I *think* you're probably talking about something similar to the MVEBU
devices mentioned here:
http://lkml.kernel.org/r/CAErSpo56jB1Bf2JtYCGKXZBZqRF1jXFxGmeewPX_e6vSXueGyA at mail.gmail.comwhere the device can be configured as either an endpoint or a root port, and the endpoint BARs are still visible when configured as a root port.
Quoted 8 lines
It is true that X-Gene PCIe port can be configured as EP, however the the FIXUP is required not because of the BARs are still visible when configured as EP in past. X-Gene PCIe port, when configured as RC, uses BAR0-BAR1 of RC's configuration space as inbound BARs. Entire DDR region is mapped in these BARs so that it is accessible for EP devices for DMA. So if the fixup is not done during enumeration, whole outbound memory resource space gets assigned to RC and nothing is left EP devices.
I'm not familiar with the concept of an "inbound BAR"; at least I'm not aware of anything like this in the PCI specs. I think it might reduce confusion if we avoided calling them "BARs". They happen to be at the same addresses where real BARs would be, but they certainly don't behave like real BARs.
It sounds like this is basically a trivial IOMMU that determines which DMA accesses can reach main memory.
Quoted 8 lines
Quoted 2 lines
In any event, I'd like a description of exactly what these BARs are and wha the problem is.
Is it ok to put above description in comment to explain the fixup?
Quoted 3 lines
Presumably the BARs exist and were sized by the PCI core
in__pci_read_base(). That will generate some log messages and possibly some warnings, depending on how the host bridge windows are set up.
Instead of doing this in a fixup, can you change the PCI config accessors so that when accessing these inbound DMA mapping registers, they drop writes and return zeros for reads? Then the PCI core won't think there are BARs there, and it won't mistakenly corrupt them when it tries to size them.
Bjorn
Re: [PATCH v9 1/4] pci:host: APM X-Gene PCIe host controller driver
Quoted 29 lines · Bjorn Helgaas
Quoted 18 lines · Tanmay Inamdar
Quoted 10 lines
drivers/pci/host/pci-xgene.c line 321
Quoted 7 lines
drivers/pci/host/pci-xgene.c new file +7
-0+static void xgene_pcie_fixup_bridge (struct pci_dev *dev) +{ +int i; + +/* Hide the PCI host BARs from the kernel as their content doesn't +* fit well in the resource management +*/ This needs a better explanation than "doesn't fit well."
Quoted 7 lines
I *think* you're probably talking about something similar to the MVEBU
devices mentioned here:
http://lkml.kernel.org/r/CAErSpo56jB1Bf2JtYCGKXZBZqRF1jXFxGmeewPX_e6vSXueGyA at mail.gmail.comwhere the device can be configured as either an endpoint or a root port, and the endpoint BARs are still visible when configured as a root port.
Quoted 8 lines
It is true that X-Gene PCIe port can be configured as EP, however the the FIXUP is required not because of the BARs are still visible when configured as EP in past. X-Gene PCIe port, when configured as RC, uses BAR0-BAR1 of RC's configuration space as inbound BARs. Entire DDR region is mapped in these BARs so that it is accessible for EP devices for DMA. So if the fixup is not done during enumeration, whole outbound memory resource space gets assigned to RC and nothing is left EP devices.
Quoted 5 lines
I'm not familiar with the concept of an "inbound BAR"; at least I'm not aware of anything like this in the PCI specs. I think it might reduce confusion if we avoided calling them "BARs". They happen to be at the same addresses where real BARs would be, but they certainly don't behave like real BARs.
So what does the lspci look like?
If x-gene has an otherwise correct bridge config space and only the 0/1 BARs have a non-standard meaning, that I'd agree with Bjorn, hide all access to these registers from the kernel (and tell your HW crew to read the specs, because it is very clear what those registers are supposed to do) .
If x-gene doesn't even have a bridge config space, then there are much bigger problems, and these corrupt BARs are just the start.
Jason
Re: [PATCH v9 1/4] pci:host: APM X-Gene PCIe host controller driver
Quoted 30 lines · Jason Gunthorpe
Quoted 29 lines · Bjorn Helgaas
Quoted 26 lines · Tanmay Inamdar
Quoted 10 lines
drivers/pci/host/pci-xgene.c line 321
Quoted 7 lines
drivers/pci/host/pci-xgene.c new file +7
-0+static void xgene_pcie_fixup_bridge (struct pci_dev *dev) +{ +int i; + +/* Hide the PCI host BARs from the kernel as their content doesn't +* fit well in the resource management +*/ This needs a better explanation than "doesn't fit well."
Quoted 7 lines
I *think* you're probably talking about something similar to the MVEBU
devices mentioned here:
http://lkml.kernel.org/r/CAErSpo56jB1Bf2JtYCGKXZBZqRF1jXFxGmeewPX_e6vSXueGyA at mail.gmail.comwhere the device can be configured as either an endpoint or a root port, and the endpoint BARs are still visible when configured as a root port.
It is true that X-Gene PCIe port can be configured as EP, however the the FIXUP is required not because of the BARs are still visible when configured as EP in past. X-Gene PCIe port, when configured as RC, uses BAR0-BAR1 of RC's configuration space as inbound BARs. Entire DDR region is mapped in these BARs so that it is accessible for EP devices for DMA. So if the fixup is not done during enumeration, whole outbound memory resource space gets assigned to RC and nothing is left EP devices.
Quoted 8 lines
Quoted 5 lines
I'm not familiar with the concept of an "inbound BAR"; at least I'm not aware of anything like this in the PCI specs. I think it might reduce confusion if we avoided calling them "BARs". They happen to be at the same addresses where real BARs would be, but they certainly don't behave like real BARs.
So what does the lspci look like?
[root at mustang ~]# lspci -s 0000:00:00.0 -v
0000:00:00.0 PCI bridge: Applied Micro Circuits Corp. Device e004 (rev
04) (prog-if 00 [Normal decode])
Flags: bus master, fast devsel, latency 0
Memory at <ignored> (64-bit, prefetchable)
Bus: primary=00, secondary=01, subordinate=01, sec-latency=0 Memory behind bridge: 80800000-809fffff
Prefetchable memory behind bridge: 0000000080000000-00000000807fffff
Capabilities: [40] Express Root Port (Slot+), MSI 00
Capabilities: [80] Power Management version 3
Capabilities: [100] Advanced Error Reporting
Capabilities: [180] #19
Capabilities: [150] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?> Kernel driver in use: pcieport
Quoted 6 lines
If x-gene has an otherwise correct bridge config space and only the 0/1 BARs have a non-standard meaning, that I'd agree with Bjorn, hide all access to these registers from the kernel (and tell your HW crew to read the specs, because it is very clear what those registers are supposed to do) .
Ok.
Quoted 4 lines
If x-gene doesn't even have a bridge config space, then there are much bigger problems, and these corrupt BARs are just the start.
Jason
Re: [PATCH v9 1/4] pci:host: APM X-Gene PCIe host controller driver
In reply to Bjorn HelgaasQuoted 29 lines · Bjorn Helgaas
Quoted 18 lines · Tanmay Inamdar
Quoted 10 lines
drivers/pci/host/pci-xgene.c line 321
Quoted 7 lines
drivers/pci/host/pci-xgene.c new file +7
-0+static void xgene_pcie_fixup_bridge (struct pci_dev *dev) +{ +int i; + +/* Hide the PCI host BARs from the kernel as their content doesn't +* fit well in the resource management +*/ This needs a better explanation than "doesn't fit well."
Quoted 7 lines
I *think* you're probably talking about something similar to the MVEBU
devices mentioned here:
http://lkml.kernel.org/r/CAErSpo56jB1Bf2JtYCGKXZBZqRF1jXFxGmeewPX_e6vSXueGyA at mail.gmail.comwhere the device can be configured as either an endpoint or a root port, and the endpoint BARs are still visible when configured as a root port.
Quoted 8 lines
It is true that X-Gene PCIe port can be configured as EP, however the the FIXUP is required not because of the BARs are still visible when configured as EP in past. X-Gene PCIe port, when configured as RC, uses BAR0-BAR1 of RC's configuration space as inbound BARs. Entire DDR region is mapped in these BARs so that it is accessible for EP devices for DMA. So if the fixup is not done during enumeration, whole outbound memory resource space gets assigned to RC and nothing is left EP devices.
Quoted 9 lines
I'm not familiar with the concept of an "inbound BAR"; at least I'm not aware of anything like this in the PCI specs. I think it might reduce confusion if we avoided calling them "BARs". They happen to be at the same addresses where real BARs would be, but they certainly don't behave like real BARs.
It sounds like this is basically a trivial IOMMU that determines which DMA accesses can reach main memory.
Yes. That is correct.
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
In any event, I'd like a description of exactly what these BARs are and wha the problem is.
Is it ok to put above description in comment to explain the fixup?
Quoted 3 lines
Presumably the BARs exist and were sized by the PCI core
in__pci_read_base(). That will generate some log messages and possibly some warnings, depending on how the host bridge windows are set up.
Quoted 6 lines
Instead of doing this in a fixup, can you change the PCI config accessors so that when accessing these inbound DMA mapping registers, they drop writes and return zeros for reads? Then the PCI core won't think there are BARs there, and it won't mistakenly corrupt them when it tries to size them.
I suppose this can be done. I will fix this in next revision.
Quoted 1 line
Bjorn
PATCH v9 2/4 arm64: dts: APM X-Gene PCIe device tree nodes
In reply to Tanmay InamdarThis patch adds the device tree nodes for APM X-Gene PCIe host controller and PCIe clock interface. Since X-Gene SOC supports maximum 5 ports, 5 dts nodes are added.
--- arch/arm64/boot/dts/apm-mustang.dts | 8 ++ arch/arm64/boot/dts/apm-storm.dtsi | 165 ++++++++++++++++++++++++++++++++++++ 2 files changed, 173 insertions(+)
arch/arm64/boot/dts/apm-mustang.dts +8 -0
@@ -25,6 +25,14 @@ }; }; +&pcie0clk { + status = "ok"; +}; + +&pcie0 { + status = "ok"; +}; + &serial0 { status = "ok"; };
arch/arm64/boot/dts/apm-storm.dtsi +165 -0
171 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v9 3/4 dt-bindings: pci: xgene pcie device tree bindings
In reply to Tanmay InamdarThis patch adds the bindings for X-Gene PCIe driver. The driver resides under 'drivers/pci/host/pci-xgene.c' file.
--- .../devicetree/bindings/pci/xgene-pci.txt | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/xgene-pci.txt
Documentation/devicetree/bindings/pci/xgene-pci.txt new file +57 -0
@@ -0,0 +1,57 @@ +* AppliedMicro X-Gene PCIe interface + +Required properties: +- device_type: set to "pci" +- compatible: should contain "apm,xgene-pcie" to identify the core. +- reg: A list of physical base address and length for each set of controller + registers. Must contain an entry for each entry in the reg-names + property. +- reg-names: Must include the following entries: + "csr": controller configuration registers. + "cfg": pcie configuration space registers. +- #address-cells: set to <3> +- #size-cells: set to <2> +- ranges: ranges for the outbound memory, I/O regions. +- dma-ranges: ranges for the inbound memory regions. +- #interrupt-cells: set to <1> +- interrupt-map-mask and interrupt-map: standard PCI properties + to define the mapping of the PCIe interface to interrupt + numbers. +- clocks: from common clock binding: handle to pci clock. + +Optional properties: +- status: Either "ok" or "disabled". +- dma-coherent: Present if dma operations are coherent + +Example: + +SoC specific DT Entry: + + pcie0: pcie at 1f2b0000 { + status = "disabled"; + device_type = "pci"; + compatible = "apm,xgene-storm-pcie", "apm,xgene-pcie"; + #interrupt-cells = <1>; + #size-cells = <2>; + #address-cells = <3>; + reg = < 0x00 0x1f2b0000 0x0 0x00010000 /* Controller registers */ + 0xe0 0xd0000000 0x0 0x00040000>; /* PCI config space */ + reg-names = "csr", "cfg"; + ranges = <0x01000000 0x00 0x00000000 0xe0 0x10000000 0x00 0x00010000 /* io */ + 0x02000000 0x00 0x80000000 0xe1 0x80000000 0x00 0x80000000>; /* mem */ + dma-ranges = <0x42000000 0x80 0x00000000 0x80 0x00000000 0x00 0x80000000 + 0x42000000 0x00 0x00000000 0x00 0x00000000 0x80 0x00000000>; + interrupt-map-mask = <0x0 0x0 0x0 0x7>; + interrupt-map = <0x0 0x0 0x0 0x1 &gic 0x0 0xc2 0x1 + 0x0 0x0 0x0 0x2 &gic 0x0 0xc3 0x1 + 0x0 0x0 0x0 0x3 &gic 0x0 0xc4 0x1 + 0x0 0x0 0x0 0x4 &gic 0x0 0xc5 0x1>; + dma-coherent; + clocks = <&pcie0clk 0>; + }; + + +Board specific DT Entry: + &pcie0 { + status = "ok"; + };
Signature · 1 line
1.9.1
PATCH v9 4/4 MAINTAINERS: entry for APM X-Gene PCIe host driver
In reply to Tanmay InamdarAdd entry for AppliedMicro X-Gene PCIe host driver.
--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
@@ -6941,6 +6941,14 @@ L: linux-pci at vger.kernel.org S: Maintained F: drivers/pci/host/*spear* +PCI DRIVER FOR APPLIEDMICRO XGENE +M: Tanmay Inamdar <[email protected]> +L: linux-pci at vger.kernel.org +L: linux-arm-kernel at lists.infradead.org +S: Maintained +F: Documentation/devicetree/bindings/pci/xgene-pci.txt +F: drivers/pci/host/pci-xgene.c + PCMCIA SUBSYSTEM P: Linux PCMCIA Team L: linux-pcmcia at lists.infradead.org
Signature · 1 line
1.9.1
Hi Tanmay,
Quoted 10 lines · Tanmay Inamdar
This patch adds support for AppliedMicro X-Gene PCIe host controller. The driver is tested on X-Gene platform with different gen1/2/3 PCIe endpoint cards.
X-Gene PCIe controller driver has depedency on the pcie arm64 arch support. Liviu Dudau from ARM has sent a patch set for pcie arm64 arch support and support for creating generic pcie bridge from device tree. Liviu's patches are available here
https://lkml.org/lkml/2014/9/8/333
Quoted 6 lines
If someone wishes to test PCIe on X-Gene with this patch set, above mentioned patches from Liviu must be applied before the patches in this patch set. Also please use latest xgene u-boot firmware.
changes since V8:
1. Add 'dma-coherent' attribute in device node.
I just tested your V9 patches plus Liviu's V10 PCI/ARM64 patches against 3.17-rc5 on Mustang, and the following failure is triggered:
[ 1.190131] bnx2x: Broadcom NetXtreme II 5771x/578xx 10/20-Gigabit Ethernet Driver bnx2x 1.78.19-0 (2014/02/10) [ 1.200249] tg3.c:v3.137 (May 11, 2014) [ 1.204087] ------------[ cut here ]------------ [ 1.208682] WARNING: CPU: 1 PID: 1 at drivers/pci/pci.c:131 pci_ioremap_bar+0x70/0x78() [ 1.216646] Modules linked in: [ 1.219696] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 3.17.0-rc5+ #1 [ 1.226018] Call trace: [ 1.228453] [<ffffffc0000884f0>] dump_backtrace+0x0/0x16c [ 1.233826] [<ffffffc00008866c>] show_stack+0x10/0x1c [ 1.238851] [<ffffffc0006e3210>] dump_stack+0x74/0x94 [ 1.243878] [<ffffffc0000a934c>] warn_slowpath_common+0x88/0xb0 [ 1.249767] [<ffffffc0000a9438>] warn_slowpath_null+0x14/0x20 [ 1.255485] [<ffffffc0003994c4>] pci_ioremap_bar+0x6c/0x78 [ 1.260942] [<ffffffc0005598cc>] tg3_init_one+0x148/0x16f4 [ 1.266401] [<ffffffc00039ccf0>] pci_device_probe+0x78/0xd4 [ 1.271946] [<ffffffc00042785c>] driver_probe_device+0x94/0x390 [ 1.277834] [<ffffffc000427c44>] __driver_attach+0x98/0xa0 [ 1.283293] [<ffffffc000425a54>] bus_for_each_dev+0x54/0x98 [ 1.288835] [<ffffffc00042730c>] driver_attach+0x1c/0x28 [ 1.294121] [<ffffffc000426f04>] bus_add_driver+0x164/0x240 [ 1.299663] [<ffffffc000428430>] driver_register+0x64/0x130 [ 1.305207] [<ffffffc00039c97c>] __pci_register_driver+0x3c/0x48 [ 1.311181] [<ffffffc000aa8a5c>] tg3_driver_init+0x1c/0x28 [ 1.316640] [<ffffffc0000814e0>] do_one_initcall+0xc4/0x1b4 [ 1.322186] [<ffffffc000a74b64>] kernel_init_freeable+0x1b8/0x25c [ 1.328246] [<ffffffc0006de318>] kernel_init+0xc/0xd4 [ 1.333278] ---[ end trace f4dca5ab5b436080 ]--- [ 1.337871] tg3 0000:01:00.0: Cannot map device registers, aborting [ 1.344122] tg3: probe of 0000:01:00.0 failed with error -12
Thanks,
Quoted 71 lines
changes since V7:
1. Fix outbound region mapping for IO region. Thanks Liviu for the catch.changes since V6:
1. Port driver to changed interface as per Liviu's v10 series.changes since V5:
1. Port driver to changed interface of 'of_create_pci_host_bridge'
2. Fix the prefetch bit setting
3. Removed bunch of register programming which is already done by firmwarechanges since V4:
1. fix section mismatch warnings
2. fix the patch description
3. fix indentation
4. update read/write cfg functions by passing both addr and offset.
5. use 'time_before' for timeout.
6. remove unnecessary 'IS_ERR_OR_NULL'. Keep 'IS_ERR' for 'clk_get'
7. removeBUG_ONforpci_ioremap_io.changes since V3:
1. remove 'structhw_pci' and supporting ops inhw_pci
2. add code to create the host bridge from dts
3. add code to scan the the host bridge
4. modify outbound windows setup function to get resource information from 'bridge->windows'
5. add compatible string in pcie dts node with current X-Gene SOC name.changes since V2:
1. redefined each PCI port in different PCI domain correctly.
2. removedsetup_laneandsetup_linkfunctions from driver.
3. removedscan_buswrapper andset_primary_bushack.
4. addedpci_ioremap_iofor io resources.changes since V1:
1. added PCI domain support
2. reading cpu and pci addresses from device tree to configure regions.
3. got rid of unnecessary wrappers for readl and writel.
4. got rid of endpoint configuration code.
5. added 'dma-ranges' property support to read inbound region configuration.
6. renamed host driver file to 'pci-xgene.c' from 'pcie-xgene.c'
7. dropped 'clock-names' property from bindings
8. added comments whereever requested.Tanmay Inamdar (4):
pci:host: APM X-Gene PCIe host controller driver
arm64: dts: APM X-Gene PCIe device tree nodes
dt-bindings: pci: xgene pcie device tree bindings
MAINTAINERS: entry for APM X-Gene PCIe host driver.../devicetree/bindings/pci/xgene-pci.txt | 57 ++ MAINTAINERS | 8 + arch/arm64/boot/dts/apm-mustang.dts | 8 + arch/arm64/boot/dts/apm-storm.dtsi | 165 ++++++ drivers/pci/host/Kconfig | 10 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pci-xgene.c | 646 +++++++++++++++++++++ 7 files changed, 895 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/xgene-pci.txt create mode 100644 drivers/pci/host/pci-xgene.c--
1.9.1--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 1 line
Ming Lei
Hi Ming Lei,
Quoted 47 lines · Ming Lei
Hi Tanmay,
Quoted 10 lines · Tanmay Inamdar
This patch adds support for AppliedMicro X-Gene PCIe host controller. The driver is tested on X-Gene platform with different gen1/2/3 PCIe endpoint cards.
X-Gene PCIe controller driver has depedency on the pcie arm64 arch support. Liviu Dudau from ARM has sent a patch set for pcie arm64 arch support and support for creating generic pcie bridge from device tree. Liviu's patches are available here
https://lkml.org/lkml/2014/9/8/333Quoted 6 lines
If someone wishes to test PCIe on X-Gene with this patch set, above mentioned patches from Liviu must be applied before the patches in this patch set. Also please use latest xgene u-boot firmware.
changes since V8:
1. Add 'dma-coherent' attribute in device node.I just tested your V9 patches plus Liviu's V10 PCI/ARM64 patches against 3.17-rc5 on Mustang, and the following failure is triggered:
[ 1.190131] bnx2x: Broadcom NetXtreme II 5771x/578xx 10/20-Gigabit Ethernet Driver bnx2x 1.78.19-0 (2014/02/10) [ 1.200249] tg3.c:v3.137 (May 11, 2014) [ 1.204087] ------------[ cut here ]------------ [ 1.208682] WARNING: CPU: 1 PID: 1 at drivers/pci/pci.c:131 pci_ioremap_bar+0x70/0x78() [ 1.216646] Modules linked in: [ 1.219696] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 3.17.0-rc5+ #1 [ 1.226018] Call trace: [ 1.228453] [<ffffffc0000884f0>] dump_backtrace+0x0/0x16c [ 1.233826] [<ffffffc00008866c>] show_stack+0x10/0x1c [ 1.238851] [<ffffffc0006e3210>] dump_stack+0x74/0x94 [ 1.243878] [<ffffffc0000a934c>] warn_slowpath_common+0x88/0xb0 [ 1.249767] [<ffffffc0000a9438>] warn_slowpath_null+0x14/0x20 [ 1.255485] [<ffffffc0003994c4>] pci_ioremap_bar+0x6c/0x78 [ 1.260942] [<ffffffc0005598cc>] tg3_init_one+0x148/0x16f4 [ 1.266401] [<ffffffc00039ccf0>] pci_device_probe+0x78/0xd4 [ 1.271946] [<ffffffc00042785c>] driver_probe_device+0x94/0x390 [ 1.277834] [<ffffffc000427c44>] __driver_attach+0x98/0xa0 [ 1.283293] [<ffffffc000425a54>] bus_for_each_dev+0x54/0x98 [ 1.288835] [<ffffffc00042730c>] driver_attach+0x1c/0x28 [ 1.294121] [<ffffffc000426f04>] bus_add_driver+0x164/0x240 [ 1.299663] [<ffffffc000428430>] driver_register+0x64/0x130
Quoted 10 lines
[ 1.305207] [<ffffffc00039c97c>] __pci_register_driver+0x3c/0x48 [ 1.311181] [<ffffffc000aa8a5c>] tg3_driver_init+0x1c/0x28 [ 1.316640] [<ffffffc0000814e0>] do_one_initcall+0xc4/0x1b4 [ 1.322186] [<ffffffc000a74b64>] kernel_init_freeable+0x1b8/0x25c [ 1.328246] [<ffffffc0006de318>] kernel_init+0xc/0xd4 [ 1.333278] ---[ end trace f4dca5ab5b436080 ]--- [ 1.337871] tg3 0000:01:00.0: Cannot map device registers, aborting [ 1.344122] tg3: probe of 0000:01:00.0 failed with error -12
Thanks for trying out the patches. Which firmware version are you using? We may have release new firmware version for PCI to work if not released yet.
Also can you please send out the entire boot log?
Thanks,
Tanmay
Quoted 79 lines
Thanks,
Quoted 63 lines
changes since V7:
1. Fix outbound region mapping for IO region. Thanks Liviu for the catch.changes since V6:
1. Port driver to changed interface as per Liviu's v10 series.changes since V5:
1. Port driver to changed interface of 'of_create_pci_host_bridge'
2. Fix the prefetch bit setting
3. Removed bunch of register programming which is already done by firmwarechanges since V4:
1. fix section mismatch warnings
2. fix the patch description
3. fix indentation
4. update read/write cfg functions by passing both addr and offset.
5. use 'time_before' for timeout.
6. remove unnecessary 'IS_ERR_OR_NULL'. Keep 'IS_ERR' for 'clk_get'
7. removeBUG_ONforpci_ioremap_io.changes since V3:
1. remove 'structhw_pci' and supporting ops inhw_pci
2. add code to create the host bridge from dts
3. add code to scan the the host bridge
4. modify outbound windows setup function to get resource information from 'bridge->windows'
5. add compatible string in pcie dts node with current X-Gene SOC name.changes since V2:
1. redefined each PCI port in different PCI domain correctly.
2. removedsetup_laneandsetup_linkfunctions from driver.
3. removedscan_buswrapper andset_primary_bushack.
4. addedpci_ioremap_iofor io resources.changes since V1:
1. added PCI domain support
2. reading cpu and pci addresses from device tree to configure regions.
3. got rid of unnecessary wrappers for readl and writel.
4. got rid of endpoint configuration code.
5. added 'dma-ranges' property support to read inbound region configuration.
6. renamed host driver file to 'pci-xgene.c' from 'pcie-xgene.c'
7. dropped 'clock-names' property from bindings
8. added comments whereever requested.Tanmay Inamdar (4):
pci:host: APM X-Gene PCIe host controller driver
arm64: dts: APM X-Gene PCIe device tree nodes
dt-bindings: pci: xgene pcie device tree bindings
MAINTAINERS: entry for APM X-Gene PCIe host driver.../devicetree/bindings/pci/xgene-pci.txt | 57 ++ MAINTAINERS | 8 + arch/arm64/boot/dts/apm-mustang.dts | 8 + arch/arm64/boot/dts/apm-storm.dtsi | 165 ++++++ drivers/pci/host/Kconfig | 10 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pci-xgene.c | 646 +++++++++++++++++++++ 7 files changed, 895 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/xgene-pci.txt create mode 100644 drivers/pci/host/pci-xgene.cQuoted 8 lines
--
1.9.1--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/--
Ming Lei
Hi Tanmay,
Quoted 61 lines · Tanmay Inamdar
Hi Ming Lei,
Quoted 47 lines · Ming Lei
Hi Tanmay,
Quoted 10 lines · Tanmay Inamdar
This patch adds support for AppliedMicro X-Gene PCIe host controller. The driver is tested on X-Gene platform with different gen1/2/3 PCIe endpoint cards.
X-Gene PCIe controller driver has depedency on the pcie arm64 arch support. Liviu Dudau from ARM has sent a patch set for pcie arm64 arch support and support for creating generic pcie bridge from device tree. Liviu's patches are available here
https://lkml.org/lkml/2014/9/8/333Quoted 6 lines
If someone wishes to test PCIe on X-Gene with this patch set, above mentioned patches from Liviu must be applied before the patches in this patch set. Also please use latest xgene u-boot firmware.
changes since V8:
1. Add 'dma-coherent' attribute in device node.I just tested your V9 patches plus Liviu's V10 PCI/ARM64 patches against 3.17-rc5 on Mustang, and the following failure is triggered:
[ 1.190131] bnx2x: Broadcom NetXtreme II 5771x/578xx 10/20-Gigabit Ethernet Driver bnx2x 1.78.19-0 (2014/02/10) [ 1.200249] tg3.c:v3.137 (May 11, 2014) [ 1.204087] ------------[ cut here ]------------ [ 1.208682] WARNING: CPU: 1 PID: 1 at drivers/pci/pci.c:131 pci_ioremap_bar+0x70/0x78() [ 1.216646] Modules linked in: [ 1.219696] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 3.17.0-rc5+ #1 [ 1.226018] Call trace: [ 1.228453] [<ffffffc0000884f0>] dump_backtrace+0x0/0x16c [ 1.233826] [<ffffffc00008866c>] show_stack+0x10/0x1c [ 1.238851] [<ffffffc0006e3210>] dump_stack+0x74/0x94 [ 1.243878] [<ffffffc0000a934c>] warn_slowpath_common+0x88/0xb0 [ 1.249767] [<ffffffc0000a9438>] warn_slowpath_null+0x14/0x20 [ 1.255485] [<ffffffc0003994c4>] pci_ioremap_bar+0x6c/0x78 [ 1.260942] [<ffffffc0005598cc>] tg3_init_one+0x148/0x16f4 [ 1.266401] [<ffffffc00039ccf0>] pci_device_probe+0x78/0xd4 [ 1.271946] [<ffffffc00042785c>] driver_probe_device+0x94/0x390 [ 1.277834] [<ffffffc000427c44>] __driver_attach+0x98/0xa0 [ 1.283293] [<ffffffc000425a54>] bus_for_each_dev+0x54/0x98 [ 1.288835] [<ffffffc00042730c>] driver_attach+0x1c/0x28 [ 1.294121] [<ffffffc000426f04>] bus_add_driver+0x164/0x240 [ 1.299663] [<ffffffc000428430>] driver_register+0x64/0x130Quoted 10 lines
[ 1.305207] [<ffffffc00039c97c>] __pci_register_driver+0x3c/0x48 [ 1.311181] [<ffffffc000aa8a5c>] tg3_driver_init+0x1c/0x28 [ 1.316640] [<ffffffc0000814e0>] do_one_initcall+0xc4/0x1b4 [ 1.322186] [<ffffffc000a74b64>] kernel_init_freeable+0x1b8/0x25c [ 1.328246] [<ffffffc0006de318>] kernel_init+0xc/0xd4 [ 1.333278] ---[ end trace f4dca5ab5b436080 ]--- [ 1.337871] tg3 0000:01:00.0: Cannot map device registers, aborting [ 1.344122] tg3: probe of 0000:01:00.0 failed with error -12
Quoted 3 lines
Thanks for trying out the patches. Which firmware version are you using? We may have release new firmware version for PCI to work if not released yet.
U-Boot 2013.04-mustang_sw_1.13.28-beta (Aug 25 2014 - 14:16:10)
I will check if there is newer fw available.
Quoted 1 line
Also can you please send out the entire boot log?
Please see below link:
Thanks,
--
Ming Lei
Quoted 83 lines
Thanks,
TanmayQuoted 79 lines
Thanks,
Quoted 63 lines
changes since V7:
1. Fix outbound region mapping for IO region. Thanks Liviu for the catch.changes since V6:
1. Port driver to changed interface as per Liviu's v10 series.changes since V5:
1. Port driver to changed interface of 'of_create_pci_host_bridge'
2. Fix the prefetch bit setting
3. Removed bunch of register programming which is already done by firmwarechanges since V4:
1. fix section mismatch warnings
2. fix the patch description
3. fix indentation
4. update read/write cfg functions by passing both addr and offset.
5. use 'time_before' for timeout.
6. remove unnecessary 'IS_ERR_OR_NULL'. Keep 'IS_ERR' for 'clk_get'
7. removeBUG_ONforpci_ioremap_io.changes since V3:
1. remove 'structhw_pci' and supporting ops inhw_pci
2. add code to create the host bridge from dts
3. add code to scan the the host bridge
4. modify outbound windows setup function to get resource information from 'bridge->windows'
5. add compatible string in pcie dts node with current X-Gene SOC name.changes since V2:
1. redefined each PCI port in different PCI domain correctly.
2. removedsetup_laneandsetup_linkfunctions from driver.
3. removedscan_buswrapper andset_primary_bushack.
4. addedpci_ioremap_iofor io resources.changes since V1:
1. added PCI domain support
2. reading cpu and pci addresses from device tree to configure regions.
3. got rid of unnecessary wrappers for readl and writel.
4. got rid of endpoint configuration code.
5. added 'dma-ranges' property support to read inbound region configuration.
6. renamed host driver file to 'pci-xgene.c' from 'pcie-xgene.c'
7. dropped 'clock-names' property from bindings
8. added comments whereever requested.Tanmay Inamdar (4):
pci:host: APM X-Gene PCIe host controller driver
arm64: dts: APM X-Gene PCIe device tree nodes
dt-bindings: pci: xgene pcie device tree bindings
MAINTAINERS: entry for APM X-Gene PCIe host driver.../devicetree/bindings/pci/xgene-pci.txt | 57 ++ MAINTAINERS | 8 + arch/arm64/boot/dts/apm-mustang.dts | 8 + arch/arm64/boot/dts/apm-storm.dtsi | 165 ++++++ drivers/pci/host/Kconfig | 10 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pci-xgene.c | 646 +++++++++++++++++++++ 7 files changed, 895 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/xgene-pci.txt create mode 100644 drivers/pci/host/pci-xgene.cQuoted 8 lines
--
1.9.1--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/--
Ming Lei
Signature · 1 line
Ming Lei
Bjorn Helgaas
maintainerQuoted 72 lines · Ming Lei
Hi Tanmay,
Quoted 61 lines · Tanmay Inamdar
Hi Ming Lei,
Quoted 47 lines · Ming Lei
Hi Tanmay,
Quoted 10 lines · Tanmay Inamdar
This patch adds support for AppliedMicro X-Gene PCIe host controller. The driver is tested on X-Gene platform with different gen1/2/3 PCIe endpoint cards.
X-Gene PCIe controller driver has depedency on the pcie arm64 arch support. Liviu Dudau from ARM has sent a patch set for pcie arm64 arch support and support for creating generic pcie bridge from device tree. Liviu's patches are available here
https://lkml.org/lkml/2014/9/8/333Quoted 6 lines
If someone wishes to test PCIe on X-Gene with this patch set, above mentioned patches from Liviu must be applied before the patches in this patch set. Also please use latest xgene u-boot firmware.
changes since V8:
1. Add 'dma-coherent' attribute in device node.I just tested your V9 patches plus Liviu's V10 PCI/ARM64 patches against 3.17-rc5 on Mustang, and the following failure is triggered:
[ 1.190131] bnx2x: Broadcom NetXtreme II 5771x/578xx 10/20-Gigabit Ethernet Driver bnx2x 1.78.19-0 (2014/02/10) [ 1.200249] tg3.c:v3.137 (May 11, 2014) [ 1.204087] ------------[ cut here ]------------ [ 1.208682] WARNING: CPU: 1 PID: 1 at drivers/pci/pci.c:131 pci_ioremap_bar+0x70/0x78() [ 1.216646] Modules linked in: [ 1.219696] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 3.17.0-rc5+ #1 [ 1.226018] Call trace: [ 1.228453] [<ffffffc0000884f0>] dump_backtrace+0x0/0x16c [ 1.233826] [<ffffffc00008866c>] show_stack+0x10/0x1c [ 1.238851] [<ffffffc0006e3210>] dump_stack+0x74/0x94 [ 1.243878] [<ffffffc0000a934c>] warn_slowpath_common+0x88/0xb0 [ 1.249767] [<ffffffc0000a9438>] warn_slowpath_null+0x14/0x20 [ 1.255485] [<ffffffc0003994c4>] pci_ioremap_bar+0x6c/0x78 [ 1.260942] [<ffffffc0005598cc>] tg3_init_one+0x148/0x16f4 [ 1.266401] [<ffffffc00039ccf0>] pci_device_probe+0x78/0xd4 [ 1.271946] [<ffffffc00042785c>] driver_probe_device+0x94/0x390 [ 1.277834] [<ffffffc000427c44>] __driver_attach+0x98/0xa0 [ 1.283293] [<ffffffc000425a54>] bus_for_each_dev+0x54/0x98 [ 1.288835] [<ffffffc00042730c>] driver_attach+0x1c/0x28 [ 1.294121] [<ffffffc000426f04>] bus_add_driver+0x164/0x240 [ 1.299663] [<ffffffc000428430>] driver_register+0x64/0x130Quoted 10 lines
[ 1.305207] [<ffffffc00039c97c>] __pci_register_driver+0x3c/0x48 [ 1.311181] [<ffffffc000aa8a5c>] tg3_driver_init+0x1c/0x28 [ 1.316640] [<ffffffc0000814e0>] do_one_initcall+0xc4/0x1b4 [ 1.322186] [<ffffffc000a74b64>] kernel_init_freeable+0x1b8/0x25c [ 1.328246] [<ffffffc0006de318>] kernel_init+0xc/0xd4 [ 1.333278] ---[ end trace f4dca5ab5b436080 ]--- [ 1.337871] tg3 0000:01:00.0: Cannot map device registers, aborting [ 1.344122] tg3: probe of 0000:01:00.0 failed with error -12Quoted 3 lines
Thanks for trying out the patches. Which firmware version are you using? We may have release new firmware version for PCI to work if not released yet.
U-Boot 2013.04-mustang_sw_1.13.28-beta (Aug 25 2014 - 14:16:10)
I will check if there is newer fw available.
Quoted 7 lines
Quoted 1 line
Also can you please send out the entire boot log?
Please see below link:
From Ming's log, using the v9 patches:
PCI host bridge /soc/pcie at 1f2b0000 ranges:
No bus range found for /soc/pcie at 1f2b0000, using [??? 0xffffffc3eb4292c0-0xffffffc0005e3b8c flags 0x40]
What's going on here? It looks like it's from of_pci_get_host_bridge_resources(), but I don't see how this output could happen.
IO 0xe010000000..0xe01000ffff -> 0x00000000
MEM 0xe180000000..0xe1ffffffff -> 0x80000000 xgene-pcie 1f2b0000.pcie: (rc) x1 gen-1 link up
xgene-pcie 1f2b0000.pcie: PCI host bridge to bus 0000:00
pci_bus 0000:00: root bus resource [bus 00-ff]
pci_bus 0000:00: root bus resource [io 0x0000-0xffff]
pci_bus 0000:00: root bus resource [mem 0xe180000000-0xe1ffffffff] (bus address [0x80000000-0xffffffff]) pci_bus 0000:00: scanning bus
pci 0000:00:00.0: [19aa:e008] type 01 class 0x060400
pci 0000:00:00.0: reg 0x10: [mem 0x8000000000-0x807fffffff 64bit pref]
I guess this is the "inbound BAR" that you hid in the v10 patches. Hiding it will prevent some of BAR assignment problems below. This is probably what caused the tg3 mapping problem Ming initially reported above. We tried to reassign the inbound BAR, and it took up the entire space that we thought was available for CPU accesses to the PCI bus, leaving none for the tg3 device.
Was Ming just unlucky by having an unusual configuration, e.g., with a lot of memory or something? He certainly doesn't have a complicated PCIe hierarchy. I assume you've tested this and had it work *somewhere*.
pci 0000:00:00.0: supports D1 D2
pci_bus 0000:00: fixups for bus
pci 0000:00:00.0: scanning [bus 01-01] behind bridge, pass 0 pci_bus 0000:01: scanning bus
pci 0000:01:00.0: [14e4:165a] type 00 class 0x020000
pci 0000:01:00.0: reg 0x10: [mem 0x00100000-0x0010ffff 64bit] pci 0000:01:00.0: PME# supported from D3hot
pci 0000:01:00.0: PME# disabled
pci_bus 0000:01: fixups for bus
pci_bus 0000:01: bus scan returning with max=01
pci 0000:00:00.0: scanning [bus 01-01] behind bridge, pass 1 pci_bus 0000:00: bus scan returning with max=01
pci 0000:00:00.0: BAR 0: assigned [mem 0xe180000000-0xe1ffffffff 64bit pref] pci 0000:00:00.0: BAR 8: no space for [mem size 0x00100000]
pci 0000:00:00.0: BAR 8: failed to assign [mem size 0x00100000] pci 0000:01:00.0: BAR 0: no space for [mem size 0x00010000 64bit] pci 0000:01:00.0: BAR 0: failed to assign [mem size 0x00010000 64bit] pci 0000:00:00.0: PCI bridge to [bus 01]
Quoted 79 lines · Bjorn Helgaas
Quoted 70 lines · Ming Lei
Hi Tanmay,
Quoted 61 lines · Tanmay Inamdar
Hi Ming Lei,
Quoted 47 lines · Ming Lei
Hi Tanmay,
Quoted 10 lines · Tanmay Inamdar
This patch adds support for AppliedMicro X-Gene PCIe host controller. The driver is tested on X-Gene platform with different gen1/2/3 PCIe endpoint cards.
X-Gene PCIe controller driver has depedency on the pcie arm64 arch support. Liviu Dudau from ARM has sent a patch set for pcie arm64 arch support and support for creating generic pcie bridge from device tree. Liviu's patches are available here
https://lkml.org/lkml/2014/9/8/333Quoted 6 lines
If someone wishes to test PCIe on X-Gene with this patch set, above mentioned patches from Liviu must be applied before the patches in this patch set. Also please use latest xgene u-boot firmware.
changes since V8:
1. Add 'dma-coherent' attribute in device node.I just tested your V9 patches plus Liviu's V10 PCI/ARM64 patches against 3.17-rc5 on Mustang, and the following failure is triggered:
[ 1.190131] bnx2x: Broadcom NetXtreme II 5771x/578xx 10/20-Gigabit Ethernet Driver bnx2x 1.78.19-0 (2014/02/10) [ 1.200249] tg3.c:v3.137 (May 11, 2014) [ 1.204087] ------------[ cut here ]------------ [ 1.208682] WARNING: CPU: 1 PID: 1 at drivers/pci/pci.c:131 pci_ioremap_bar+0x70/0x78() [ 1.216646] Modules linked in: [ 1.219696] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 3.17.0-rc5+ #1 [ 1.226018] Call trace: [ 1.228453] [<ffffffc0000884f0>] dump_backtrace+0x0/0x16c [ 1.233826] [<ffffffc00008866c>] show_stack+0x10/0x1c [ 1.238851] [<ffffffc0006e3210>] dump_stack+0x74/0x94 [ 1.243878] [<ffffffc0000a934c>] warn_slowpath_common+0x88/0xb0 [ 1.249767] [<ffffffc0000a9438>] warn_slowpath_null+0x14/0x20 [ 1.255485] [<ffffffc0003994c4>] pci_ioremap_bar+0x6c/0x78 [ 1.260942] [<ffffffc0005598cc>] tg3_init_one+0x148/0x16f4 [ 1.266401] [<ffffffc00039ccf0>] pci_device_probe+0x78/0xd4 [ 1.271946] [<ffffffc00042785c>] driver_probe_device+0x94/0x390 [ 1.277834] [<ffffffc000427c44>] __driver_attach+0x98/0xa0 [ 1.283293] [<ffffffc000425a54>] bus_for_each_dev+0x54/0x98 [ 1.288835] [<ffffffc00042730c>] driver_attach+0x1c/0x28 [ 1.294121] [<ffffffc000426f04>] bus_add_driver+0x164/0x240 [ 1.299663] [<ffffffc000428430>] driver_register+0x64/0x130Quoted 10 lines
[ 1.305207] [<ffffffc00039c97c>] __pci_register_driver+0x3c/0x48 [ 1.311181] [<ffffffc000aa8a5c>] tg3_driver_init+0x1c/0x28 [ 1.316640] [<ffffffc0000814e0>] do_one_initcall+0xc4/0x1b4 [ 1.322186] [<ffffffc000a74b64>] kernel_init_freeable+0x1b8/0x25c [ 1.328246] [<ffffffc0006de318>] kernel_init+0xc/0xd4 [ 1.333278] ---[ end trace f4dca5ab5b436080 ]--- [ 1.337871] tg3 0000:01:00.0: Cannot map device registers, aborting [ 1.344122] tg3: probe of 0000:01:00.0 failed with error -12Quoted 3 lines
Thanks for trying out the patches. Which firmware version are you using? We may have release new firmware version for PCI to work if not released yet.
U-Boot 2013.04-mustang_sw_1.13.28-beta (Aug 25 2014 - 14:16:10)
Quoted 7 lines
I will check if there is newer fw available.
Quoted 1 line
Also can you please send out the entire boot log?
Please see below link:
Quoted 8 lines
From Ming's log, using the v9 patches:
PCI host bridge /soc/pcie at
1f2b0000ranges:No bus range found for /soc/pcie at 1f2b0000, using [??? 0xffffffc3eb4292c0-0xffffffc0005e3b8c flags 0x40]What's going on here? It looks like it's from
of_pci_get_host_bridge_resources(), but I don't see how this output could happen.
Sorry, v9 to v11 had a bug in the print message where the range was passed as a reference. I have since fixed it in v12. I've noticed this log when preparing for v12 but somehow missed it in the change log?
Best regards,
Liviu
Quoted 42 lines
IO 0xe010000000..0xe01000ffff -> 0x00000000 MEM 0xe180000000..0xe1ffffffff -> 0x80000000xgene-pcie 1f2b0000.pcie: (rc) x1 gen-1 link up
xgene-pcie 1f2b0000.pcie: PCI host bridge to bus 0000:00
pci_bus0000:00: root bus resource [bus 00-ff]
pci_bus0000:00: root bus resource [io 0x0000-0xffff]
pci_bus0000:00: root bus resource [mem 0xe180000000-0xe1ffffffff] (bus address [0x80000000-0xffffffff])pci_bus0000:00: scanning bus
pci 0000:00:00.0: [19aa:e008] type 01 class0x060400
pci 0000:00:00.0: reg0x10: [mem 0x8000000000-0x807fffffff 64bit pref]I guess this is the "inbound BAR" that you hid in the v10 patches. Hiding it will prevent some of BAR assignment problems below. This is probably what caused the tg3 mapping problem Ming initially reported above. We tried to reassign the inbound BAR, and it took up the entire space that we thought was available for CPU accesses to the PCI bus, leaving none for the tg3 device.
Was Ming just unlucky by having an unusual configuration, e.g., with a lot of memory or something? He certainly doesn't have a complicated PCIe hierarchy. I assume you've tested this and had it work *somewhere*.
pci 0000:00:00.0: supports D1 D2
pci_bus0000:00: fixups for bus
pci 0000:00:00.0: scanning [bus 01-01] behind bridge, pass 0pci_bus0000:01: scanning bus
pci 0000:01:00.0: [14e4:165a] type 00 class0x020000
pci 0000:01:00.0: reg0x10: [mem 0x00100000-0x0010ffff 64bit] pci 0000:01:00.0: PME# supported from D3hot
pci 0000:01:00.0: PME# disabled
pci_bus0000:01: fixups for bus
pci_bus0000:01: bus scan returning with max=01
pci 0000:00:00.0: scanning [bus 01-01] behind bridge, pass 1pci_bus0000:00: bus scan returning with max=01
pci 0000:00:00.0: BAR 0: assigned [mem 0xe180000000-0xe1ffffffff 64bit pref] pci 0000:00:00.0: BAR 8: no space for [mem size0x00100000]
pci 0000:00:00.0: BAR 8: failed to assign [mem size0x00100000] pci 0000:01:00.0: BAR 0: no space for [mem size0x0001000064bit] pci 0000:01:00.0: BAR 0: failed to assign [mem size0x0001000064bit] pci 0000:00:00.0: PCI bridge to [bus 01]
Signature · 8 lines
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
?\_(?)_/?