PCI: Add support to the Cadence PCIe controller
Subsystems (4)
v4 cover PCI: Add support to the Cadence PCIe controller
Hi all,
this series of patches adds support to the Cadence PCIe controller. It was tested on a ARM64 platform emulated by a Palladium running the pci-next kernel.
The host mode was tested with some PCIe devices connected to the Palladium through a speed-bridge. Some of those devices were a USB host controller and a SATA controller. The PCIe host controller was also tested with a second controller configured in endpoint mode and connected back to back to the first controller.
The EndPoint Controller (EPC) driver was removed only because I didn't have time to take all Kishon's comments into account. However, using a fixed patch based on patch 7 of the v2 series + another patch fixing the EPF device name chosen by pci_epf_make(), I was abled to probe both function 0 and function 1 of the of the 2nd Cadence PCIe controller configured in endpoint mode (new hardware design since v2 so function 1 is now available).
Currently I'm facing 2 issues, which I didn't have enough time to investigate and to fix yet:
1 - when the vendor:device IDs are set to 104c:b500 for both functions, then I remove both devfn (echo 1 > /sys/bus/pci/devices/$BDF/remove) before scanning the PCI bus again (echo 1 > /sys/bus/pci/rescan), the PCI enumeration fails reporting that the PCI memory is exhausted.
2 - when I set the vendor:device IDs to 104c:0100 for function 0 and 104c:b500 and remove only function 1 before scanning the PCI bus again, I now pass the PCI enumeration. I also pass the 'pcitest -b <BAR>' test but I fail on the MSI test ('pcitest -m <MSI>').
I'm still investigating on those issues.
Best regards,
Cyrille
ChangeLog
v3 -> v4:
- split patch 3 from v3 into patches 3 and 4.
- remove unused cdns_pcie_reset_outbound_region() from old patch 6 (new patch 7).
- other patches are unchanged.
v2 -> v3:
- rebase on today's linux-pci/next (20180110)
patch1:
- rework the commit message of patch 1 and add two new comments on why endpoint library users must be linked after the endpoint library itself and why the dwc rule uses obj-y instead of obj-$(CONFIG_PCIE_CONFIG_DW).
- update patch 1 to add missing ifdef CONFIG_PCI / endif in drivers/pci/dwc/Makefile around the obj-$(CONFIG_ARM64) += pcie-hisi.o rule, like for the other obj-$(CONFIG_ARM64) rules in drivers/pci/host/Makefile.
patch2: unchanged
patch3:
- update patch 3 so the bridge hooks/members initialization is left to the host bridges probe routines.
patch4: unchanged
patch5:
- collect 'Reviewed-by' tag from Rob Herring for the DT bindings.
patch6:
- remove explanation in the commit message on why obj-$(CONFIG_PCIE_CANDENCE) is placed after obj-$(CONFIG_PCI_ENDPOINT) in drivers/pci/Makefile since a comment on it has been added into patch1.
- remove menuconfig PCI_CADENCE in drivers/pci/cadence/Kconfig to match drivers/pci/dwc/Kconfig.
- adapt patch6 to the changes done in patch3 for the pci_host_probe() function.
v1 -> v2:
- add new properties in the device-tree bindings: 'cdns,max-outbound-regions' and 'cdns,no-bar-match-nbits'.
- add a new patch to regroup all makefile rules in drivers/pci/Makefile, hence cleaning drivers/Makefile up.
- change the license text to use the recommanded format:
// SPDX-License-Identifier: GPL-2.0
- add a new patch updating the API of the EPC library to add support to multi-function devices.
- add a 2 new patches to share more common code between host controller drivers
- remove some useless tests
- add more comments in both drivers.
- fix DT bindings examples
- remove useless init of the primary, secondary and sub-ordinate bus numbers in the PCI configuration space of the root port.
- remove cdns_pcie_ep_stop() function and rework cdns_pcie_ep_start() function
Cyrille Pitchen (6):
PCI: Regroup all PCI related entries into drivers/pci/Makefile
PCI: OF: Add generic function to parse and allocate PCI resources
PCI: generic: fix missing call of pci_free_resource_list()
PCI: Add generic function to probe PCI host controllers
PCI: Add vendor ID for Cadence
PCI: cadence: Add host driver for Cadence PCIe controller
Scott Telford (1):
dt-bindings: PCI: cadence: Add DT bindings for Cadence PCIe host
controller
.../bindings/pci/cdns,cdns-pcie-host.txt | 60 ++++ MAINTAINERS | 7 + drivers/Makefile | 5 +- drivers/pci/Kconfig | 2 + drivers/pci/Makefile | 14 +- drivers/pci/cadence/Kconfig | 16 + drivers/pci/cadence/Makefile | 3 + drivers/pci/cadence/pcie-cadence-host.c | 336 +++++++++++++++++++++ drivers/pci/cadence/pcie-cadence.c | 56 ++++ drivers/pci/cadence/pcie-cadence.h | 194 ++++++++++++ drivers/pci/dwc/Makefile | 2 + drivers/pci/host/Makefile | 2 + drivers/pci/host/pci-host-common.c | 72 +---- drivers/pci/of.c | 51 ++++ drivers/pci/probe.c | 33 ++ include/linux/pci.h | 10 + include/linux/pci_ids.h | 2 + 17 files changed, 790 insertions(+), 75 deletions(-) create mode 100644 Documentation/devicetree/bindings/pci/cdns,cdns-pcie-host.txt create mode 100644 drivers/pci/cadence/Kconfig create mode 100644 drivers/pci/cadence/Makefile create mode 100644 drivers/pci/cadence/pcie-cadence-host.c create mode 100644 drivers/pci/cadence/pcie-cadence.c create mode 100644 drivers/pci/cadence/pcie-cadence.h
Signature · 6 lines
2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 1/7 PCI: Regroup all PCI related entries into drivers/pci/Makefile
Clean up drivers/Makefile by moving the pci/endpoint and pci/dwc entries from drivers/Makefile into drivers/pci/Makefile.
Since we don't want to introduce any dependency between CONFIG_PCI and CONFIG_PCI_ENDPOINT, we now always execute drivers/pci/Makefile.
Hence all Makefiles in drivers/pci/ were updated accordingly so no file is compiled when CONFIG_PCI is not defined.
Also, we add a comment to reinforce that EPC and EPF libraries must be initialized before their users. Hence built-in EPC drivers, such as those of Designware, are linked after the endpoint core libraries.
Finally, we add another comment to explain why obj-y has been chosen instead of obj-$(CONFIG_PCIE_DW) to parse the dwc/ sub-folder.
--- drivers/Makefile | 5 +---- drivers/pci/Kconfig | 1 + drivers/pci/Makefile | 13 ++++++++++--- drivers/pci/dwc/Makefile | 2 ++ drivers/pci/host/Makefile | 2 ++ 5 files changed, 16 insertions(+), 7 deletions(-)
drivers/Makefile +1 -4
@@ -16,10 +16,7 @@ obj-$(CONFIG_PINCTRL) += pinctrl/ obj-$(CONFIG_GPIOLIB) += gpio/ obj-y += pwm/ -obj-$(CONFIG_PCI) += pci/ -obj-$(CONFIG_PCI_ENDPOINT) += pci/endpoint/ -# PCI dwc controller drivers -obj-y += pci/dwc/ +obj-y += pci/ obj-$(CONFIG_PARISC) += parisc/ obj-$(CONFIG_RAPIDIO) += rapidio/
drivers/pci/Kconfig +1 -0
@@ -125,6 +125,7 @@ config PCI_PASID config PCI_LABEL def_bool y if (DMI || ACPI) + depends on PCI select NLS config PCI_HYPERV
drivers/pci/Makefile +10 -3
@@ -3,12 +3,15 @@ # Makefile for the PCI bus specific drivers. # -obj-y += access.o bus.o probe.o host-bridge.o remove.o pci.o \ +obj-$(CONFIG_PCI) += access.o bus.o probe.o host-bridge.o remove.o pci.o \ pci-driver.o search.o pci-sysfs.o rom.o setup-res.o \ irq.o vpd.o setup-bus.o vc.o mmap.o setup-irq.o +ifdef CONFIG_PCI obj-$(CONFIG_PROC_FS) += proc.o obj-$(CONFIG_SYSFS) += slot.o +obj-$(CONFIG_OF) += of.o +endif obj-$(CONFIG_PCI_QUIRKS) += quirks.o
@@ -44,10 +47,14 @@ obj-$(CONFIG_PCI_ECAM) += ecam.o obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += xen-pcifront.o -obj-$(CONFIG_OF) += of.o - ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG # PCI host controller drivers obj-y += host/ obj-y += switch/ + +obj-$(CONFIG_PCI_ENDPOINT) += endpoint/ + +# Endpoint library must be initialized before its users +# pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW +obj-y += dwc/
drivers/pci/dwc/Makefile +2 -0
@@ -25,4 +25,6 @@ obj-$(CONFIG_PCIE_HISI_STB) += pcie-histb.o # ARM64 and use internal ifdefs to only build the pieces we need # depending on whether ACPI, the DT driver, or both are enabled. +ifdef CONFIG_PCI obj-$(CONFIG_ARM64) += pcie-hisi.o +endif
drivers/pci/host/Makefile +2 -0
@@ -34,6 +34,8 @@ obj-$(CONFIG_VMD) += vmd.o # ARM64 and use internal ifdefs to only build the pieces we need # depending on whether ACPI, the DT driver, or both are enabled. +ifdef CONFIG_PCI obj-$(CONFIG_ARM64) += pci-thunder-ecam.o obj-$(CONFIG_ARM64) += pci-thunder-pem.o obj-$(CONFIG_ARM64) += pci-xgene.o +endif
Signature · 6 lines
2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 2/7 PCI: OF: Add generic function to parse and allocate PCI resources
In reply to Cyrille PitchenThe patch moves the gen_pci_parse_request_of_pci_ranges() function from drivers/pci/host/pci-host-common.c into drivers/pci/of.c to easily share common source code between PCI host drivers.
--- drivers/pci/host/pci-host-common.c | 49 ++---------------------------------- drivers/pci/of.c | 51 ++++++++++++++++++++++++++++++++++++++ include/linux/pci.h | 9 +++++++ 3 files changed, 62 insertions(+), 47 deletions(-)
drivers/pci/host/pci-host-common.c +2 -47
@@ -24,50 +24,6 @@#include <linux/pci-ecam.h> #include <linux/platform_device.h> -static int gen_pci_parse_request_of_pci_ranges (struct device *dev, -struct list_head *resources,struct resource **bus_range) -{ -int err, res_valid =0 ; -struct device_node *np = dev->of_node; -resource_size_t iobase; -struct resource_entry *win, *tmp; - - err =of_pci_get_host_bridge_resources (np,0 ,0xff , resources, &iobase); -if (err) -return err; - - err =devm_request_pci_bus_resources (dev, resources); -if (err) -return err; - -resource_list_for_each_entry_safe (win, tmp, resources) { -struct resource *res = win->res; - -switch (resource_type (res)) { -case IORESOURCE_IO : - err =pci_remap_iospace (res, iobase); -if (err) { -dev_warn (dev,"error %d: failed to map resource %pR\n" , - err, res); -resource_list_destroy_entry (win); - } -break ; -case IORESOURCE_MEM : - res_valid |= !(res->flags &IORESOURCE_PREFETCH ); -break ; -case IORESOURCE_BUS : - *bus_range = res; -break ; - } - } - -if (res_valid) -return 0 ; - -dev_err (dev,"non-prefetchable memory resource required\n" ); -return -EINVAL ; -} -static void gen_pci_unmap_cfg (void *ptr) {pci_ecam_free ((struct pci_config_window *)ptr);
@@ -82,9 +38,9 @@ static struct pci_config_window *gen_pci_init(struct device *dev,struct pci_config_window *cfg;/* Parse our PCI ranges and request their resources */ - err =gen_pci_parse_request_of_pci_ranges (dev, resources, &bus_range); + err =pci_parse_request_of_pci_ranges (dev, resources, &bus_range);if (err) - goto err_out; +return ERR_PTR (err); err =of_address_to_resource (dev->of_node,0 , &cfgres);if (err) {
@@ -135,7 +91,6 @@ int pci_host_common_probe(struct platform_device *pdev,of_pci_check_probe_only ();/* Parse and map our Configuration Space windows */ -INIT_LIST_HEAD (&resources); cfg =gen_pci_init (dev, &resources, ops);if (IS_ERR (cfg))return PTR_ERR (cfg);
drivers/pci/of.c +51 -0
54 lines not on this page · raw message
include/linux/pci.h +9 -0
@@ -2163,6 +2163,9 @@ void pci_release_of_node(struct pci_dev *dev);void pci_set_bus_of_node (struct pci_bus *bus);void pci_release_bus_of_node (struct pci_bus *bus);struct irq_domain *pci_host_bridge_of_msi_domain (struct pci_bus *bus); +int pci_parse_request_of_pci_ranges (struct device *dev, +struct list_head *resources, +struct resource **bus_range);/* Arch may override this (weak) */ struct device_node *pcibios_get_phb_of_node (struct pci_bus *bus);
@@ -2187,6 +2190,12 @@ static inline struct device_node * pci_device_to_OF_node(const struct pci_dev *pdev) { return NULL; }static inline struct irq_domain *pci_host_bridge_of_msi_domain (struct pci_bus *bus) {return NULL ; } +static inline int pci_parse_request_of_pci_ranges (struct device *dev, +struct list_head *resources, +struct resource **bus_range) +{ +return -EINVAL ; +}#endif /* CONFIG_OF */ #ifdef CONFIG_ACPI
Signature · 1 line
2.11.0
PATCH v4 3/7 PCI: generic: fix missing call of pci_free_resource_list()
In reply to Cyrille PitchenCall pci_free_resource_list() from pci_host_common_probe() when probing fails, as done inside gen_pci_init() when this later function fails.
--- drivers/pci/host/pci-host-common.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/host/pci-host-common.c +1 -0
@@ -110,6 +110,7 @@ int pci_host_common_probe(struct platform_device *pdev, ret =pci_scan_root_bus_bridge (bridge);if (ret <0 ) {dev_err (dev,"Scanning root bridge failed" ); +pci_free_resource_list (&resources);return ret; }
Signature · 1 line
2.11.0
PATCH v4 4/7 PCI: Add generic function to probe PCI host controllers
In reply to Cyrille PitchenThis patchs moves generic source code from drivers/pci/host/pci-host-common.c into drivers/pci/probe.c.
Indeed the extracted lines of code were duplicated by many host controller drivers. Regrouping them into a generic function gives a change to properly share this code without introducing a useless dependency to PCI_HOST_COMMON, which selects PCI_ECAM when not needed by most host controller drivers.
--- drivers/pci/host/pci-host-common.c | 22 +--------------------- drivers/pci/probe.c | 33 +++++++++++++++++++++++++++++++++ include/linux/pci.h | 1 + 3 files changed, 35 insertions(+), 21 deletions(-)
drivers/pci/host/pci-host-common.c +1 -21
@@ -72,7 +72,6 @@ int pci_host_common_probe(struct platform_device *pdev,const char *type;struct device *dev = &pdev->dev;struct device_node *np = dev->of_node; -struct pci_bus *bus, *child;struct pci_host_bridge *bridge;struct pci_config_window *cfg;struct list_head resources;
@@ -107,30 +106,11 @@ int pci_host_common_probe(struct platform_device *pdev, bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle; - ret =pci_scan_root_bus_bridge (bridge); + ret =pci_host_probe (bridge);if (ret <0 ) { -dev_err (dev,"Scanning root bridge failed" );pci_free_resource_list (&resources);return ret; } - bus = bridge->bus; - -/* -* We insert PCI resources into the iomem_resource and -* ioport_resource trees in either pci_bus_claim_resources() -* or pci_bus_assign_resources(). -*/ -if (pci_has_flag (PCI_PROBE_ONLY )) { -pci_bus_claim_resources (bus); - }else { -pci_bus_size_bridges (bus); -pci_bus_assign_resources (bus); - -list_for_each_entry (child, &bus->children, node) -pcie_bus_configure_settings (child); - } - -pci_bus_add_devices (bus);return 0 ; }
drivers/pci/probe.c +33 -0
@@ -2685,6 +2685,39 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, }EXPORT_SYMBOL_GPL (pci_create_root_bus); +int pci_host_probe (struct pci_host_bridge *bridge) +{ +struct pci_bus *bus, *child; +int ret; + + ret =pci_scan_root_bus_bridge (bridge); +if (ret <0 ) { +dev_err (bridge->dev.parent,"Scanning root bridge failed" ); +return ret; + } + + bus = bridge->bus; + +/* +* We insert PCI resources into the iomem_resource and +* ioport_resource trees in either pci_bus_claim_resources() +* or pci_bus_assign_resources(). +*/ +if (pci_has_flag (PCI_PROBE_ONLY )) { +pci_bus_claim_resources (bus); + }else { +pci_bus_size_bridges (bus); +pci_bus_assign_resources (bus); + +list_for_each_entry (child, &bus->children, node) +pcie_bus_configure_settings (child); + } + +pci_bus_add_devices (bus); +return 0 ; +} +EXPORT_SYMBOL_GPL (pci_host_probe); +int pci_bus_insert_busn_res (struct pci_bus *b,int bus,int bus_max) {struct resource *res = &b->busn_res;
include/linux/pci.h +1 -0
@@ -879,6 +879,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);struct pci_bus *pci_create_root_bus (struct device *parent,int bus,struct pci_ops *ops,void *sysdata,struct list_head *resources); +int pci_host_probe (struct pci_host_bridge *bridge);int pci_bus_insert_busn_res (struct pci_bus *b,int bus,int busmax);int pci_bus_update_busn_res_end (struct pci_bus *b,int busmax);void pci_bus_release_busn_res (struct pci_bus *b);
Signature · 1 line
2.11.0
PATCH v4 5/7 PCI: Add vendor ID for Cadence
In reply to Cyrille PitchenThis patch adds a new PCI vendor ID for Cadence.
--- include/linux/pci_ids.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/pci_ids.h +2 -0
@@ -2381,6 +2381,8 @@#define PCI_VENDOR_ID_LENOVO 0x17aa +#define PCI_VENDOR_ID_CDNS 0x17cd +#define PCI_VENDOR_ID_ARECA 0x17d3#define PCI_DEVICE_ID_ARECA_1110 0x1110#define PCI_DEVICE_ID_ARECA_1120 0x1120
Signature · 1 line
2.11.0
PATCH v4 6/7 dt-bindings: PCI: cadence: Add DT bindings for Cadence PCIe host controller
In reply to Cyrille PitchenFrom: Scott Telford <[email protected]>
This patch adds documentation for the DT bindings of the Cadence PCIe controller when configured in host (Root Complex) mode.
--- .../bindings/pci/cdns,cdns-pcie-host.txt | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/cdns,cdns-pcie-host.txt
Documentation/devicetree/bindings/pci/cdns,cdns-pcie-host.txt new file +60 -0
@@ -0,0 +1,60 @@ +* Cadence PCIe host controller + +This PCIe controller inherits the base properties defined in +host-generic-pci.txt. + +Required properties: +- compatible: Should contain "cdns,cdns-pcie-host" to identify the IP used. +- reg: Should contain the controller register base address, PCIe configuration + window base address, and AXI interface region base address respectively. +- reg-names: Must be "reg", "cfg" and "mem" respectively. +- #address-cells: Set to <3> +- #size-cells: Set to <2> +- device_type: Set to "pci" +- ranges: Ranges for the PCI memory and I/O 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. + +Optional properties: +- cdns,max-outbound-regions: Set to maximum number of outbound regions + (default 32) +- cdns,no-bar-match-nbits: Set into the no BAR match register to configure the + number of least significant bits kept during inbound (PCIe -> AXI) address + translations (default 32) +- vendor-id: The PCI vendor ID (16 bits, default is design dependent) +- device-id: The PCI device ID (16 bits, default is design dependent) + +Example: + +pcie@fb000000 { + compatible = "cdns,cdns-pcie-host"; + device_type = "pci"; + #address-cells = <3>; + #size-cells = <2>; + bus-range = <0x0 0xff>; + linux,pci-domain = <0>; + cdns,max-outbound-regions = <16>; + cdns,no-bar-match-nbits = <32>; + vendor-id = /bits/ 16 <0x17cd>; + device-id = /bits/ 16 <0x0200>; + + reg = <0x0 0xfb000000 0x0 0x01000000>, + <0x0 0x41000000 0x0 0x00001000>, + <0x0 0x40000000 0x0 0x04000000>; + reg-names = "reg", "cfg", "mem"; + + ranges = <0x02000000 0x0 0x42000000 0x0 0x42000000 0x0 0x1000000>, + <0x01000000 0x0 0x43000000 0x0 0x43000000 0x0 0x0010000>; + + #interrupt-cells = <0x1>; + + interrupt-map = <0x0 0x0 0x0 0x1 &gic 0x0 0x0 0x0 14 0x1 + 0x0 0x0 0x0 0x2 &gic 0x0 0x0 0x0 15 0x1 + 0x0 0x0 0x0 0x3 &gic 0x0 0x0 0x0 16 0x1 + 0x0 0x0 0x0 0x4 &gic 0x0 0x0 0x0 17 0x1>; + + interrupt-map-mask = <0x0 0x0 0x0 0x7>; + + msi-parent = <&its_pci>; +};
Signature · 1 line
2.11.0
PATCH v4 7/7 PCI: cadence: Add host driver for Cadence PCIe controller
In reply to Cyrille PitchenThis patch adds support to the Cadence PCIe controller in host mode.
--- MAINTAINERS | 7 + drivers/pci/Kconfig | 1 + drivers/pci/Makefile | 1 + drivers/pci/cadence/Kconfig | 16 ++ drivers/pci/cadence/Makefile | 3 + drivers/pci/cadence/pcie-cadence-host.c | 336 ++++++++++++++++++++++++++++++++ drivers/pci/cadence/pcie-cadence.c | 56 ++++++ drivers/pci/cadence/pcie-cadence.h | 194 ++++++++++++++++++ 8 files changed, 614 insertions(+) create mode 100644 drivers/pci/cadence/Kconfig create mode 100644 drivers/pci/cadence/Makefile create mode 100644 drivers/pci/cadence/pcie-cadence-host.c create mode 100644 drivers/pci/cadence/pcie-cadence.c create mode 100644 drivers/pci/cadence/pcie-cadence.h
MAINTAINERS +7 -0
@@ -10402,6 +10402,13 @@ S: Maintained F: Documentation/devicetree/bindings/pci/pci-armada8k.txt F: drivers/pci/dwc/pcie-armada8k.c +PCI DRIVER FOR CADENCE PCIE IP +M: Alan Douglas <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/pci/cdns,*.txt +F: drivers/pci/cadence/pcie-cadence* + PCI DRIVER FOR FREESCALE LAYERSCAPE M: Minghuan Lian <[email protected]> M: Mingkai Hu <[email protected]>
drivers/pci/Kconfig +1 -0
@@ -136,6 +136,7 @@ config PCI_HYPERV PCI devices from a PCI backend to support PCI driver domains. source "drivers/pci/hotplug/Kconfig" +source "drivers/pci/cadence/Kconfig" source "drivers/pci/dwc/Kconfig" source "drivers/pci/host/Kconfig" source "drivers/pci/endpoint/Kconfig"
drivers/pci/Makefile +1 -0
@@ -56,5 +56,6 @@ obj-y += switch/ obj-$(CONFIG_PCI_ENDPOINT) += endpoint/ # Endpoint library must be initialized before its users +obj-$(CONFIG_PCIE_CADENCE) += cadence/ # pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW obj-y += dwc/
drivers/pci/cadence/Kconfig new file +16 -0
@@ -0,0 +1,16 @@ +menu "Cadence PCIe controllers support" + +config PCIE_CADENCE + bool + +config PCIE_CADENCE_HOST + bool "Cadence PCIe host controller" + depends on OF + select IRQ_DOMAIN + select PCIE_CADENCE + help + Say Y here if you want to support the Cadence PCIe controller in host + mode. This PCIe controller may be embedded into many different vendors + SoCs. + +endmenu
drivers/pci/cadence/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_PCIE_CADENCE) += pcie-cadence.o +obj-$(CONFIG_PCIE_CADENCE_HOST) += pcie-cadence-host.o
drivers/pci/cadence/pcie-cadence-host.c new file +336 -0
336 lines not on this page · raw message
drivers/pci/cadence/pcie-cadence.c new file +56 -0
56 lines not on this page · raw message
drivers/pci/cadence/pcie-cadence.h new file +194 -0
194 lines not on this page · raw message
Signature · 1 line
2.11.0
Le 18/01/2018 à 23:52, Cyrille Pitchen a écrit :
Quoted 28 lines
Hi all,
this series of patches adds support to the Cadence PCIe controller. It was tested on a ARM64 platform emulated by a Palladium running the pci-next kernel.
The host mode was tested with some PCIe devices connected to the Palladium through a speed-bridge. Some of those devices were a USB host controller and a SATA controller. The PCIe host controller was also tested with a second controller configured in endpoint mode and connected back to back to the first controller.
The EndPoint Controller (EPC) driver was removed only because I didn't have time to take all Kishon's comments into account. However, using a fixed patch based on patch 7 of the v2 series + another patch fixing the EPF device name chosen by
pci_epf_make(), I was abled to probe both function 0 and function 1 of the of the 2nd Cadence PCIe controller configured in endpoint mode (new hardware design since v2 so function 1 is now available).Currently I'm facing 2 issues, which I didn't have enough time to investigate and to fix yet:
1 - when the vendor:device IDs are set to 104c:b500 for both functions, then I remove both devfn (echo 1 >
/sys/bus/pci/devices/$BDF/remove) before scanning the PCI bus again (echo 1 >/sys/bus/pci/rescan), the PCI enumeration fails reporting that the PCI memory is exhausted.
Quoted 7 lines
2 - when I set the vendor:device IDs to 104c:0100 for function 0 and 104c:b500 and remove only function 1 before scanning the PCI bus again, I now pass the PCI enumeration. I also pass the 'pcitest -b <BAR>' test but I fail on the MSI test ('pcitest -m <MSI>').
I'm still investigating on those issues.
Both issues fixed:
1 - For the 1st issue, I was removing endpoint devfn instead of the host controller itself. Then when I configured and enabled the 2nd endpoint function (endpoint side) before scanning the PCI bus again (host side), the memory window for the PCI bridge was not resized, hence there was no space left for BARs of the 2nd endpoint fonction.
Now that I remove the host controller itself (bus 0, dev 0, func 0) instead of the endpoint functions, it works:
# BDF="0000:00:00.0"
# echo 1 > /sys/bus/pci/devices/$BDF/remove # echo 1 > /sys/bus/pci/rescan
The memory window for the PCI bridge is resized as needed and the 6 BARs of each endpoint function can successfully be allocated during the new PCI enumeration.
2 - For the 2nd issue, I added a new parameter to cdns_pcie_set_outbound_region() to pass the function number and now pcitest -m [1 - 32] [-D <device>] works for both endpoint functions.
Finally, I'm able to use both endpoint functions at the same time with pcitest. I guess I'll send v5 within few days moving the endpoint controller driver back into the series.
Best regards,
Cyrille
Quoted 97 lines
Best regards,
Cyrille
ChangeLog
v3 -> v4:
- split patch 3 from v3 into patches 3 and 4.
- remove unusedcdns_pcie_reset_outbound_region()from old patch 6 (new patch 7).
- other patches are unchanged.v2 -> v3:
- rebase on today's linux-pci/next (20180110)
patch1:
- rework the commit message of patch 1 and add two new comments on why endpoint library users must be linked after the endpoint library itself and why the dwc rule uses obj-y instead of obj-$(CONFIG_PCIE_CONFIG_DW).
- update patch 1 to add missing ifdefCONFIG_PCI/ endif indrivers/pci/dwc/Makefilearound the obj-$(CONFIG_ARM64) += pcie-hisi.o rule, like for the other obj-$(CONFIG_ARM64) rules indrivers/pci/host/Makefile.patch2: unchanged
patch3:
- update patch 3 so the bridge hooks/members initialization is left to the host bridges probe routines.patch4: unchanged
patch5:
- collect 'Reviewed-by' tag from Rob Herring for the DT bindings.patch6:
- remove explanation in the commit message on why obj-$(CONFIG_PCIE_CANDENCE) is placed after obj-$(CONFIG_PCI_ENDPOINT) indrivers/pci/Makefilesince a comment on it has been added into patch1.
- remove menuconfigPCI_CADENCEindrivers/pci/cadence/Kconfigto matchdrivers/pci/dwc/Kconfig.
- adapt patch6 to the changes done in patch3 for thepci_host_probe()function.v1 -> v2:
- add new properties in the device-tree bindings: 'cdns,max-outbound-regions' and 'cdns,no-bar-match-nbits'.
- add a new patch to regroup all makefile rules indrivers/pci/Makefile, hence cleaningdrivers/Makefileup.
- change the license text to use the recommanded format:
// SPDX-License-Identifier: GPL-2.0
- add a new patch updating the API of the EPC library to add support to multi-function devices.
- add a 2 new patches to share more common code between host controller drivers
- remove some useless tests
- add more comments in both drivers.
- fix DT bindings examples
- remove useless init of the primary, secondary and sub-ordinate bus numbers in the PCI configuration space of the root port.
- removecdns_pcie_ep_stop()function and reworkcdns_pcie_ep_start()functionCyrille Pitchen (6):
PCI: Regroup all PCI related entries intodrivers/pci/Makefile
PCI: OF: Add generic function to parse and allocate PCI resources
PCI: generic: fix missing call ofpci_free_resource_list()
PCI: Add generic function to probe PCI host controllers
PCI: Add vendor ID for Cadence
PCI: cadence: Add host driver for Cadence PCIe controllerScott Telford (1):
dt-bindings: PCI: cadence: Add DT bindings for Cadence PCIe host
controller.../bindings/pci/cdns,cdns-pcie-host.txt | 60 ++++ MAINTAINERS | 7 + drivers/Makefile | 5 +- drivers/pci/Kconfig | 2 + drivers/pci/Makefile | 14 +- drivers/pci/cadence/Kconfig | 16 + drivers/pci/cadence/Makefile | 3 + drivers/pci/cadence/pcie-cadence-host.c | 336 +++++++++++++++++++++ drivers/pci/cadence/pcie-cadence.c | 56 ++++ drivers/pci/cadence/pcie-cadence.h | 194 ++++++++++++ drivers/pci/dwc/Makefile | 2 + drivers/pci/host/Makefile | 2 + drivers/pci/host/pci-host-common.c | 72 +---- drivers/pci/of.c | 51 ++++ drivers/pci/probe.c | 33 ++ include/linux/pci.h | 10 + include/linux/pci_ids.h | 2 + 17 files changed, 790 insertions(+), 75 deletions(-) create mode 100644 Documentation/devicetree/bindings/pci/cdns,cdns-pcie-host.txt create mode 100644 drivers/pci/cadence/Kconfig create mode 100644 drivers/pci/cadence/Makefile create mode 100644 drivers/pci/cadence/pcie-cadence-host.c create mode 100644 drivers/pci/cadence/pcie-cadence.c create mode 100644 drivers/pci/cadence/pcie-cadence.h
Signature · 3 lines
Cyrille Pitchen, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com