Re: [RFC PATCH V3 1/4] pci: APM X-Gene PCIe controller driver
On Monday 03 February 2014, Jason Gunthorpe wrote: > On Mon, Feb 03, 2014 at 09:12:32PM +0100, Arnd Bergmann wrote: > > > Are you sure that is true for the root bridge as well? I don't > > remember the details, but I though that for the host bridge, > > we don't actually look at the BARs at all. > > That is right, but this isn't a host bridge device, it is a PCI-PCI > bridge with root complex registers. The root complex bridge is not the > same as the host bridge. > > Unfortunately the implementation is non-conforming. :( Ok, I see. I was probably asking the wrong question then earlier when I tried to find out what this is. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH V3 1/4] pci: APM X-Gene PCIe controller driver
On Mon, Feb 03, 2014 at 09:12:32PM +0100, Arnd Bergmann wrote: > Are you sure that is true for the root bridge as well? I don't > remember the details, but I though that for the host bridge, > we don't actually look at the BARs at all. That is right, but this isn't a host bridge device, it is a PCI-PCI bridge with root complex registers. The root complex bridge is not the same as the host bridge. Unfortunately the implementation is non-conforming. :( Jason -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH V3 1/4] pci: APM X-Gene PCIe controller driver
On Mon, Feb 3, 2014 at 12:12 PM, Arnd Bergmann wrote: > On Monday 03 February 2014 11:42:22 Tanmay Inamdar wrote: >> On Thu, Jan 30, 2014 at 6:16 AM, Arnd Bergmann wrote: >> > On Friday 24 January 2014, Tanmay Inamdar wrote: >> > >> >> +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 >> >> + */ >> >> + 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); >> > >> > Shouldn't this be gone now that the host bridge is correctly shown >> > at the domain root? >> >> In inbound region configuration, whole DDR space is mapped into the >> BAR of RC. When Linux PCI mid-layer starts enumerating, it reads the >> size of BAR of RC and tries to fit it into the memory resource. First >> thing is that the outbound memory is not enough to map the inbound BAR >> space. This creates problem with the resource management logic and >> second thing is that, it is not required to map inbound BAR space RC >> bar as no one will be accessing it further. >> >> As Jason suggested, Bridge BAR's should be 0 size unless the bridge >> itself has registers. However this is not the case with XGene PCIe >> controller. It may have been inherited from the legacy design. >> 'arch/powerpc/sysdev/ppc4xx_pci.c' has similar fixup function. > > Are you sure that is true for the root bridge as well? I don't > remember the details, but I though that for the host bridge, > we don't actually look at the BARs at all. > >> > If you want to try out the I/O space, I'd suggest using an Intel >> > e1000 network card, which has both memory and i/o space. There >> > is a patch at http://www.spinics.net/lists/linux-pci/msg27684.html >> > that lets you check the I/O registers on it, or you can go >> > through /dev/port from user space. >> > >> > I also haven't seen your patch that adds pci_ioremap_io() for >> > arm64. It would be helpful to keep it in the same patch >> > series, since it won't build without this patch. >> >> I will post the arm64 pci patch along with next revision of this >> driver. That will cover the 'pci_ioremap_io' as well. > > Please note that today, Liviu Dudau has also posted patches for this, > so you should coordinate a bit. Yes. Just looking at his patches. Looks similar to what I have. I will wait till your solution shapes up. > > Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH V3 1/4] pci: APM X-Gene PCIe controller driver
On Monday 03 February 2014 11:42:22 Tanmay Inamdar wrote: > On Thu, Jan 30, 2014 at 6:16 AM, Arnd Bergmann wrote: > > On Friday 24 January 2014, Tanmay Inamdar wrote: > > > >> +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 > >> + */ > >> + 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); > > > > Shouldn't this be gone now that the host bridge is correctly shown > > at the domain root? > > In inbound region configuration, whole DDR space is mapped into the > BAR of RC. When Linux PCI mid-layer starts enumerating, it reads the > size of BAR of RC and tries to fit it into the memory resource. First > thing is that the outbound memory is not enough to map the inbound BAR > space. This creates problem with the resource management logic and > second thing is that, it is not required to map inbound BAR space RC > bar as no one will be accessing it further. > > As Jason suggested, Bridge BAR's should be 0 size unless the bridge > itself has registers. However this is not the case with XGene PCIe > controller. It may have been inherited from the legacy design. > 'arch/powerpc/sysdev/ppc4xx_pci.c' has similar fixup function. Are you sure that is true for the root bridge as well? I don't remember the details, but I though that for the host bridge, we don't actually look at the BARs at all. > > If you want to try out the I/O space, I'd suggest using an Intel > > e1000 network card, which has both memory and i/o space. There > > is a patch at http://www.spinics.net/lists/linux-pci/msg27684.html > > that lets you check the I/O registers on it, or you can go > > through /dev/port from user space. > > > > I also haven't seen your patch that adds pci_ioremap_io() for > > arm64. It would be helpful to keep it in the same patch > > series, since it won't build without this patch. > > I will post the arm64 pci patch along with next revision of this > driver. That will cover the 'pci_ioremap_io' as well. Please note that today, Liviu Dudau has also posted patches for this, so you should coordinate a bit. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH V3 1/4] pci: APM X-Gene PCIe controller driver
On Thu, Jan 30, 2014 at 6:16 AM, Arnd Bergmann wrote: > On Friday 24 January 2014, Tanmay Inamdar wrote: > >> +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 >> + */ >> + 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); > > Shouldn't this be gone now that the host bridge is correctly shown > at the domain root? In inbound region configuration, whole DDR space is mapped into the BAR of RC. When Linux PCI mid-layer starts enumerating, it reads the size of BAR of RC and tries to fit it into the memory resource. First thing is that the outbound memory is not enough to map the inbound BAR space. This creates problem with the resource management logic and second thing is that, it is not required to map inbound BAR space RC bar as no one will be accessing it further. As Jason suggested, Bridge BAR's should be 0 size unless the bridge itself has registers. However this is not the case with XGene PCIe controller. It may have been inherited from the legacy design. 'arch/powerpc/sysdev/ppc4xx_pci.c' has similar fixup function. > >> +static int xgene_pcie_setup(int nr, struct pci_sys_data *sys) >> +{ >> + struct xgene_pcie_port *pp = sys->private_data; >> + struct resource *io = &pp->realio; >> + >> + io->start = sys->domain * SZ_64K; >> + io->end = io->start + SZ_64K; >> + io->flags = pp->io.res.flags; >> + io->name = "PCI IO"; >> + pci_ioremap_io(io->start, pp->io.res.start); >> + >> + pci_add_resource_offset(&sys->resources, io, sys->io_offset); >> + sys->mem_offset = pp->mem.res.start - pp->mem.pci_addr; >> + pci_add_resource_offset(&sys->resources, &pp->mem.res, >> + sys->mem_offset); >> + return 1; >> +} > > Thanks for bringing back the I/O space handling. > > You don't seem to set sys->io_offset anywhere, but each of the > ports listed in your DT starts a local bus I/O register range > at port 0. > > AFAICT, you need to add (somewhere) > > sys->io_offset = pp->realio.start - pp->io.pci_addr; > > but there could be something else missing. You clearly haven't > tested if the I/O space actually works. That is correct :-). Could not find the card. Thanks for the patch below. > > If you want to try out the I/O space, I'd suggest using an Intel > e1000 network card, which has both memory and i/o space. There > is a patch at http://www.spinics.net/lists/linux-pci/msg27684.html > that lets you check the I/O registers on it, or you can go > through /dev/port from user space. > > I also haven't seen your patch that adds pci_ioremap_io() for > arm64. It would be helpful to keep it in the same patch > series, since it won't build without this patch. I will post the arm64 pci patch along with next revision of this driver. That will cover the 'pci_ioremap_io' as well. > > Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH V3 1/4] pci: APM X-Gene PCIe controller driver
On Friday 24 January 2014, Tanmay Inamdar wrote: > +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 > + */ > + 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); Shouldn't this be gone now that the host bridge is correctly shown at the domain root? > +static int xgene_pcie_setup(int nr, struct pci_sys_data *sys) > +{ > + struct xgene_pcie_port *pp = sys->private_data; > + struct resource *io = &pp->realio; > + > + io->start = sys->domain * SZ_64K; > + io->end = io->start + SZ_64K; > + io->flags = pp->io.res.flags; > + io->name = "PCI IO"; > + pci_ioremap_io(io->start, pp->io.res.start); > + > + pci_add_resource_offset(&sys->resources, io, sys->io_offset); > + sys->mem_offset = pp->mem.res.start - pp->mem.pci_addr; > + pci_add_resource_offset(&sys->resources, &pp->mem.res, > + sys->mem_offset); > + return 1; > +} Thanks for bringing back the I/O space handling. You don't seem to set sys->io_offset anywhere, but each of the ports listed in your DT starts a local bus I/O register range at port 0. AFAICT, you need to add (somewhere) sys->io_offset = pp->realio.start - pp->io.pci_addr; but there could be something else missing. You clearly haven't tested if the I/O space actually works. If you want to try out the I/O space, I'd suggest using an Intel e1000 network card, which has both memory and i/o space. There is a patch at http://www.spinics.net/lists/linux-pci/msg27684.html that lets you check the I/O registers on it, or you can go through /dev/port from user space. I also haven't seen your patch that adds pci_ioremap_io() for arm64. It would be helpful to keep it in the same patch series, since it won't build without this patch. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH V3 1/4] pci: APM X-Gene PCIe controller driver
This patch adds the AppliedMicro X-Gene SOC PCIe controller driver. X-Gene PCIe controller supports maximum upto 8 lanes and GEN3 speed. X-Gene has maximum 5 PCIe ports supported. Signed-off-by: Tanmay Inamdar --- drivers/pci/host/Kconfig | 10 + drivers/pci/host/Makefile|1 + drivers/pci/host/pci-xgene.c | 784 ++ 3 files changed, 795 insertions(+) create mode 100644 drivers/pci/host/pci-xgene.c diff --git a/drivers/pci/host/Kconfig b/drivers/pci/host/Kconfig index 47d46c6..19ce97d 100644 --- a/drivers/pci/host/Kconfig +++ b/drivers/pci/host/Kconfig @@ -33,4 +33,14 @@ config PCI_RCAR_GEN2 There are 3 internal PCI controllers available with a single built-in EHCI/OHCI host controller present on each one. +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 diff --git a/drivers/pci/host/Makefile b/drivers/pci/host/Makefile index 13fb333..34c7c36 100644 --- a/drivers/pci/host/Makefile +++ b/drivers/pci/host/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_PCI_IMX6) += pci-imx6.o 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_XGENE) += pci-xgene.o diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c new file mode 100644 index 000..650a860 --- /dev/null +++ b/drivers/pci/host/pci-xgene.c @@ -0,0 +1,784 @@ +/** + * APM X-Gene PCIe Driver + * + * Copyright (c) 2013 Applied Micro Circuits Corporation. + * + * Author: Tanmay Inamdar . + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PCIECORE_LTSSM 0x4c +#define PCIECORE_CTLANDSTATUS 0x50 +#define PIPE_PHY_RATE_RD(src) ((0xc000 & (u32)(src)) >> 0xe) +#define INTXSTATUSMASK 0x6c +#define PIM1_1L0x80 +#define IBAR2 0x98 +#define IR2MSK 0x9c +#define PIM2_1L0xa0 +#define IBAR3L 0xb4 +#define IR3MSKL0xbc +#define PIM3_1L0xc4 +#define OMR1BARL 0x100 +#define OMR2BARL 0x118 +#define CFGBARL0x154 +#define CFGBARH0x158 +#define CFGCTL 0x15c +#define RTDID 0x160 +#define BRIDGE_CFG_0 0x2000 +#define BRIDGE_CFG_1 0x2004 +#define BRIDGE_CFG_4 0x2010 +#define BRIDGE_CFG_32 0x2030 +#define BRIDGE_CFG_14 0x2038 +#define BRIDGE_CTRL_1 0x2204 +#define BRIDGE_CTRL_2 0x2208 +#define BRIDGE_CTRL_5 0x2214 +#define BRIDGE_STATUS_00x2600 +#define MEM_RAM_SHUTDOWN0xd070 +#define BLOCK_MEM_RDY 0xd074 + +#define DEVICE_PORT_TYPE_MASK 0x03c0 +#define PM_FORCE_RP_MODE_MASK 0x0400 +#define SWITCH_PORT_MODE_MASK 0x0800 +#define CLASS_CODE_MASK0xff00 +#define LINK_UP_MASK 0x0100 +#define AER_OPTIONAL_ERROR_EN 0xffc0 +#define XGENE_PCIE_DEV_CTRL0x2f0f +#define AXI_EP_CFG_ACCESS 0x1 +#define ENABLE_ASPM0x0800 +#define XGENE_PORT_TYPE_RC 0x0500 +#define BLOCK_MEM_RDY_VAL 0x +#define EN_COHERENCY 0xF000 +#define EN_REG 0x0001 +#define OB_LO_IO 0x0002 +#define XGENE_PCIE_VENDORID0xE008 +#define XGENE_PCIE_DEVICEID0xE004 +#define XGENE_PCIE_TIMEOUT (500*1000) /* us */ +#define XGENE_LTSSM_DETECT_WAIT20 +#define XGENE_LTSSM_L0_WAIT4 +#define SZ_1T (SZ_1G*1024ULL) + +struct xgene_res_cfg { + struct resource res; + u6