adding PCI support to AXS10x
Subsystems (5)
v7 cover adding PCI support to AXS10x
This patch set has the goal to add suppport for DesignWare PCIe RC in ARC AXS10x. It includes the necessary tweaks to the ARC architecture, necessary tweaks to the PCI subsystem and a new driver (pcie-synopsys). This new driver will be used extensively in the PCIe RC Prototyping Kit.
The patches were produced against Bjorn Helgaas' repository. It was properly tested in an IP Prototyping Kit.
Joao Pinto (2):
PCI support added to ARC
add new platform driver for PCI RC
.../devicetree/bindings/pci/pcie-synopsys.txt | 33 +++ MAINTAINERS | 7 + arch/arc/Kconfig | 23 ++ arch/arc/include/asm/dma.h | 5 + arch/arc/include/asm/io.h | 9 + arch/arc/include/asm/pci.h | 31 +++ arch/arc/kernel/Makefile | 1 + arch/arc/kernel/pcibios.c | 23 ++ arch/arc/plat-axs10x/Kconfig | 1 + drivers/pci/Makefile | 1 + drivers/pci/host/Kconfig | 8 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pcie-synopsys.c | 257 +++++++++++++++++++++ 13 files changed, 400 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/pcie-synopsys.txt create mode 100644 arch/arc/include/asm/pci.h create mode 100644 arch/arc/kernel/pcibios.c create mode 100644 drivers/pci/host/pcie-synopsys.c
Signature · 1 line
1.8.1.5
PATCH v7 1/2 PCI support added to ARC
This patch adds PCI support to ARC and updates drivers/pci Makefile enabling the ARC arch to use the generic PCI setup functions.
---
Change v6 -> v7 (Bjorn Helgaas):
- Parenthesis removed from definitions
Change v5 -> v6 (Vineet Gupta):
- Removed EXPORT_SYMBOL(pcibios_fixup_bus) from pcibios.c
Change v4 -> v5 (Vineet Gupta):
- pcibios.c unused functions, variables and includes were removed
- ioremap.c has no need for changes (no patch is necessary)
- pci.h unused functions and variables were removed
Change v3 -> v4:
- Nothing changed (just to keep up with patch set version).
Change v2 -> v3 (Bjorn Helgaas):
- arch/arc/kernel/pcibios.c unused functions were removed and also the arch/arc/include/asm/mach/pci.h was removed because was no longer necessary Change v1 -> v2:
- In arch/arc/Kconfig, the new menu entry (Bus Configuration) was moved to the slot between sourcing of drivers/Kconfig and fs/Kconfig (Vineet Gupta)
- In arch/arc/plat-axs10x/Kconfig the "select MIGHT_HAVE_PCI" option was placed in order as suggested (Vineet Gupta)
- ioport_map() and ioport_unmap() were static inlined and included in the io.h (Vineet Gupta)
- pcibios_min_io and pcibios_min_mem declaration moved topcibios.c (Vineet Gupta)
- pr_err() replaced by dev_err() in pcibios_enable_device() (Bjorn Helgaas)
- string simplified in pcibios_enable_device() (Vineet Gupta)
- pci_host_bridge_window structure was replaced by resource_entry structure, and list_for_each_entry() for resource_list_for_each_entry() in pcibios.c
arch/arc/Kconfig | 23 +++++++++++++++++++++++ arch/arc/include/asm/dma.h | 5 +++++ arch/arc/include/asm/io.h | 9 +++++++++ arch/arc/include/asm/pci.h | 31 +++++++++++++++++++++++++++++++ arch/arc/kernel/Makefile | 1 + arch/arc/kernel/pcibios.c | 23 +++++++++++++++++++++++ arch/arc/plat-axs10x/Kconfig | 1 + drivers/pci/Makefile | 1 + 8 files changed, 94 insertions(+) create mode 100644 arch/arc/include/asm/pci.h create mode 100644 arch/arc/kernel/pcibios.c
arch/arc/Kconfig +23 -0
@@ -19,6 +19,7 @@ config ARC select GENERIC_FIND_FIRST_BIT # for now, we don't need GENERIC_IRQ_PROBE, CONFIG_GENERIC_IRQ_CHIP select GENERIC_IRQ_SHOW + select GENERIC_PCI_IOMAP select GENERIC_PENDING_IRQ if SMP select GENERIC_SMP_IDLE_THREAD select HAVE_ARCH_KGDB
@@ -39,6 +40,9 @@ config ARC select PERF_USE_VMALLOC select HAVE_DEBUG_STACKOVERFLOW +config MIGHT_HAVE_PCI + bool + config TRACE_IRQFLAGS_SUPPORT def_bool y
@@ -570,6 +574,25 @@ endmenu # "ARC Architecture Configuration" source "mm/Kconfig" source "net/Kconfig" source "drivers/Kconfig" + +menu "Bus Support" + +config PCI + bool "PCI support" if MIGHT_HAVE_PCI + help + PCI is the name of a bus system, i.e. the way the CPU talks to the other stuff inside + your box.Find out if your board/platform have PCI. + Note: PCIE support for Synopsys Device will be available only when + HAPS DX is configured with PCIE RC bitmap. If you have PCI, say Y, otherwise N. + +config PCI_SYSCALL + def_bool PCI + +source "drivers/pci/Kconfig" +source "drivers/pci/pcie/Kconfig" + +endmenu + source "fs/Kconfig" source "arch/arc/Kconfig.debug" source "security/Kconfig"
arch/arc/include/asm/dma.h +5 -0
@@ -10,5 +10,10 @@#define ASM_ARC_DMA_H #define MAX_DMA_ADDRESS 0xC0000000 +#ifdef CONFIG_PCI +extern int isa_dma_bridge_buggy; +#else +#define isa_dma_bridge_buggy 0 +#endif #endif
arch/arc/include/asm/io.h +9 -0
@@ -16,6 +16,15 @@extern void __iomem *ioremap (unsigned long physaddr,unsigned long size);extern void __iomem *ioremap_prot (phys_addr_t offset,unsigned long size,unsigned long flags); +static inline void __iomem *ioport_map (unsigned long port,unsigned int nr) +{ +return (void __iomem *)port; +} + +static inline void ioport_unmap (void __iomem *addr) +{ +} +extern void iounmap (const void __iomem *addr);#define ioremap_nocache (phy, sz) ioremap(phy, sz)
arch/arc/include/asm/pci.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef _ASM_ARC_PCI_H +#define _ASM_ARC_PCI_H + +#ifdef __KERNEL__ +#include <asm-generic/pci-dma-compat.h> +#include <asm-generic/pci-bridge.h> + +#include <linux/ioport.h> + +#define PCIBIOS_MIN_IO 0x100 +#define PCIBIOS_MIN_MEM 0x100000 + +#define pcibios_assign_all_busses () 1 +/* +* The PCI address space does equal the physical memory address space. +* The networking and block device layers use this boolean for bounce +* buffer decisions. +*/ +#define PCI_DMA_BUS_IS_PHYS 1 + +#endif /* __KERNEL__ */ + +#endif /* _ASM_ARC_PCI_H */
arch/arc/kernel/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-y := arcksyms.o setup.o irq.o time.o reset.o ptrace.o process.o devtree.o obj-y += signal.o traps.o sys.o troubleshoot.o stacktrace.o disasm.o clk.o obj-$(CONFIG_ISA_ARCOMPACT) += entry-compact.o intc-compact.o obj-$(CONFIG_ISA_ARCV2) += entry-arcv2.o intc-arcv2.o +obj-$(CONFIG_PCI) += pcibios.o obj-$(CONFIG_MODULES) += arcksyms.o module.o obj-$(CONFIG_SMP) += smp.o
arch/arc/kernel/pcibios.c new file +23 -0
@@ -0,0 +1,23 @@ +/* +* Copyright (C) 2014-2015 Synopsys, Inc. (www.synopsys.com) +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +*/ + +#include <linux/pci.h> + +/* +* We don't have to worry about legacy ISA devices, so nothing to do here +*/ +resource_size_t pcibios_align_resource (void *data,const struct resource *res, +resource_size_t size,resource_size_t align) +{ +return res->start; +} + +void pcibios_fixup_bus (struct pci_bus *bus) +{ +}
arch/arc/plat-axs10x/Kconfig +1 -0
@@ -11,6 +11,7 @@ menuconfig ARC_PLAT_AXS10X select DW_APB_ICTL select GPIO_DWAPB select OF_GPIO + select MIGHT_HAVE_PCI select GENERIC_IRQ_CHIP select ARCH_REQUIRE_GPIOLIB help
drivers/pci/Makefile +1 -0
@@ -32,6 +32,7 @@ obj-$(CONFIG_PCI_IOV) += iov.o # Some architectures use the generic PCI setup functions # obj-$(CONFIG_ALPHA) += setup-irq.o +obj-$(CONFIG_ARC) += setup-irq.o obj-$(CONFIG_ARM) += setup-irq.o obj-$(CONFIG_ARM64) += setup-irq.o obj-$(CONFIG_UNICORE32) += setup-irq.o
Signature · 1 line
1.8.1.5
Re: [PATCH v7 1/2] PCI support added to ARC
Quoted 4 lines · Joao Pinto
This patch adds PCI support to ARC and updates
drivers/pciMakefileenabling the ARC arch to use the generic PCI setup functions.Signed-off-by Joao Pinto <jpinto at synopsys.com>
@Bjorn - feel free to pull this patch into your tree !
Thx,
-Vineet
PATCH v7 2/2 add new platform driver for PCI RC
In reply to Joao PintoThis patch adds a new driver that will be the reference platform driver for all PCI RC IP Protoyping Kits based on ARC SDP.
This patch is composed by:
-MAINTAINERS file was updated to include the new driver -Documentation/devicetree/bindings/pci was updated to include the new driver documentation
-New driver called pcie-synopsys
---
Change v6 -> v7 (Bjorn Helgaas):
- driver name was changed from pcie-snpsdev to pcie-synopsys
- driver internals (functions and certain variables) also changed name accordingly
- devicetree bindings documentation also changed accordingly
- quirk function dw_pcie_link_retrain() was removed (tests were made successfully without it)
- driver was changed to meet pci standards (link up confirmation routine, init rc functions, etc.)
- EPROBE_DEFER were removed
Change v5 -> v6:
- Nothing changed (just to keep up with patch set version). Change v4 -> v5:
- Nothing changed (just to keep up with patch set version). Changes v3 -> v4 (Bjorn Helgaas):
- ARCH dependencies were added to the drivers/pci/host/kconfig for the PCIE_SNPSDEV.
Changes v2 -> v3 (Bjorn Helgaas):
- link init stuff was moved to a snpsdev_pcie_establish_link() function in pcie-snpsdev
- pcie-snpsdev driver declaration was changed to be more
standard (Bjorn Helgaas)
- pcie-designware' dw_pcie_link_retrain() now use standard registers from pci-regs.h (Bjorn Helgaas)
- pcie-snpsdev.txt was complemented with more info (Mark Rutland) Changes v1 -> v2 (Bjorn Helgaas):
- Fixups snpsdev_pcie_fixup_bridge() and snpsdev_pcie_fixup_res() were removed from the driver (these functions were for specific tests only and not usefull in mainline)
- Driver' comments were reviewed (fix Typos and excessive comments removal)
- Removed unnecessary definitions in the driver source (PCIE_PHY_CTRL and PCIE_PHY_STAT)
.../devicetree/bindings/pci/pcie-synopsys.txt | 33 +++ MAINTAINERS | 7 + drivers/pci/host/Kconfig | 8 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pcie-synopsys.c | 257 +++++++++++++++++++++ 5 files changed, 306 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/pcie-synopsys.txt create mode 100644 drivers/pci/host/pcie-synopsys.c
Documentation/devicetree/bindings/pci/pcie-synopsys.txt new file +33 -0
@@ -0,0 +1,33 @@ +Synopsys PCI RC IP Prototyping Kit +---------------------------------- + +This is the reference platform driver to be used in the Synopsys PCI Root +Complex IP Prototyping Kit. + +Required properties: +- compatible: set to "snps,pcie-synopsys"; +- reg: base address and length of the pcie controller registers. +- #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. +- interrupts: one interrupt source for MSI interrupts, followed by interrupt + source for hardware related interrupts. +- #interrupt-cells: set to <1> +- num-lanes: set to <1>; + +Example configuration: + + pcie: pcie at 0xdffff000 { + compatible = "snps,pcie-synopsys"; + reg = <0xdffff000 0x1000>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + ranges = <0x00000800 0 0xd0000000 0xd0000000 0 0x00002000>, + <0x81000000 0 0x00000000 0xde000000 0 0x00010000>, + <0x82000000 0 0xd0400000 0xd0400000 0 0x0d000000>; + interrupts = <25>, <24>; + #interrupt-cells = <1>; + num-lanes = <1>; + };
MAINTAINERS +7 -0
@@ -8230,6 +8230,13 @@ S: Maintained F: Documentation/devicetree/bindings/pci/hisilicon-pcie.txt F: drivers/pci/host/pcie-hisi.c +PCI DRIVER FOR SYNOPSYS PROTOTYPING DEVICE +M: Joao Pinto <jpinto at synopsys.com> +L: linux-pci at vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/pci/pcie-snpsdev.txt +F: drivers/pci/host/pcie-snpsdev.c + PCMCIA SUBSYSTEM P: Linux PCMCIA Team L: linux-pcmcia at lists.infradead.org
drivers/pci/host/Kconfig +8 -0
@@ -172,4 +172,12 @@ config PCI_HISI help Say Y here if you want PCIe controller support on HiSilicon HIP05 SoC +config PCIE_SYNOPSYS + bool "Platform Driver for Synopsys Device" + depends on ARC && OF + select PCIEPORTBUS + select PCIE_DW + help + Say Y here if you want to enable PCIe controller support on the + Synopsys IP Prototyping Kits. endmenu
drivers/pci/host/Makefile +1 -0
@@ -20,3 +20,4 @@ obj-$(CONFIG_PCIE_IPROC_BCMA) += pcie-iproc-bcma.o obj-$(CONFIG_PCIE_ALTERA) += pcie-altera.o obj-$(CONFIG_PCIE_ALTERA_MSI) += pcie-altera-msi.o obj-$(CONFIG_PCI_HISI) += pcie-hisi.o +obj-$(CONFIG_PCIE_SYNOPSYS) += pcie-synopsys.o
drivers/pci/host/pcie-synopsys.c new file +257 -0
257 lines not on this page · raw message
Signature · 1 line
1.8.1.5
Re: [PATCH v7 2/2] add new platform driver for PCI RC
Quoted 10 lines · Joao Pinto
This patch adds a new driver that will be the reference platform driver for all PCI RC IP Protoyping Kits based on ARC SDP.
This patch is composed by:(quoted diff) +0
-2-MAINTAINERS file was updated to include the new driver -Documentation/devicetree/bindings/pci was updated to include the newdriver documentation
-New driver called pcie-synopsysSigned-off-by Joao Pinto <jpinto at synopsys.com>
I applied the following changes. Mostly whitespace/comment cleanup, but also removed some include files that I don't think you need and added a message when the link fails to come up. Please test and make sure this still works.
Bjorn
drivers/pci/host/pcie-synopsys.c +13 -20
@@ -3,7 +3,7 @@* * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) * -* Authors: Manjunath Bettegowda <manjumb at synopsys.com>, +* Authors: Manjunath Bettegowda <manjumb at synopsys.com> * Jie Deng <jiedeng at synopsys.com> * Joao Pinto <jpinto at synopsys.com> *
@@ -12,17 +12,13 @@* published by the Free Software Foundation. */ -#include <linux/clk.h> #include <linux/delay.h> -#include <linux/gpio.h> #include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/module.h> -#include <linux/of_gpio.h> #include <linux/pci.h> #include <linux/platform_device.h> #include <linux/resource.h> -#include <linux/signal.h> #include <linux/types.h> #include "pcie-designware.h"
@@ -38,8 +34,8 @@ struct synopsys_pcie {*/ }; -#define PCI_EQUAL_CONTROL_PHY 0x00000707 -#define PCIE_PHY_DEBUG_R1_LINK_UP 0x00000010 +#define PCI_EQUAL_CONTROL_PHY 0x00000707 +#define PCIE_PHY_DEBUG_R1_LINK_UP 0x00000010/* PCIe Port Logic registers (memory-mapped) */ #define PLR_OFFSET 0x700
@@ -56,8 +52,6 @@ static irqreturn_t synopsys_pcie_msi_irq_handler(int irq, void *arg) {struct pcie_port *pp = arg; -dw_handle_msi_irq (pp); -return dw_handle_msi_irq (pp); }
@@ -74,9 +68,9 @@ static int synopsys_pcie_deassert_core_reset(struct pcie_port *pp)static void synopsys_pcie_establish_link (struct pcie_port *pp) { -int retries =0 ; +int retries; -/* check if the link is up or not */ +/* wait for link to come up */ for (retries =0 ; retries <10 ; retries++) {if (dw_pcie_link_up (pp)) {dev_info (pp->dev,"Link up\n" );
@@ -84,6 +78,8 @@ static void synopsys_pcie_establish_link(struct pcie_port *pp) }mdelay (100 ); } + +dev_err (pp->dev,"Link fail\n" ); }/*
@@ -142,21 +138,18 @@ static int synopsys_add_pcie_port(struct pcie_port *pp,int ret; pp->irq =platform_get_irq (pdev,1 ); -if (pp->irq <0 )return pp->irq; ret =devm_request_irq (&pdev->dev, pp->irq, synopsys_pcie_irq_handler,IRQF_SHARED ,"synopsys-pcie" , pp); -if (ret) { -dev_err (&pdev->dev,"failed to request irq\n" ); +dev_err (&pdev->dev,"failed to request IRQ %d\n" , pp->irq);return ret; }if (IS_ENABLED (CONFIG_PCI_MSI )) { pp->msi_irq =platform_get_irq (pdev,0 ); -if (pp->msi_irq <0 )return pp->msi_irq;
@@ -164,7 +157,8 @@ static int synopsys_add_pcie_port(struct pcie_port *pp, synopsys_pcie_msi_irq_handler, IRQF_SHARED, "synopsys-pcie-msi", pp);if (ret) { -dev_err (&pdev->dev,"failed to request msi irq\n" ); +dev_err (&pdev->dev,"failed to request MSI IRQ %d\n" , + pp->msi_irq);return ret; } }
@@ -194,18 +188,18 @@ static int synopsys_add_pcie_port(struct pcie_port *pp,/** * synopsys_pcie_probe() -* This function gets called as part of pcie registration. if the id matches +* This function gets called as part of PCIe registration. If the ID matches * the platform driver framework will call this function. * * @pdev: Pointer to the platform_device structure * -* Returns zero on success; Negative errorno on failure +* Returns zero on success; Negative errno on failure */ static int synopsys_pcie_probe (struct platform_device *pdev) {struct synopsys_pcie *synopsys_pcie;struct pcie_port *pp; -struct resource *res;/* Resource from DT */ +struct resource *res;int ret; synopsys_pcie = devm_kzalloc(&pdev->dev, sizeof(*synopsys_pcie),
@@ -217,7 +211,6 @@ static int synopsys_pcie_probe(struct platform_device *pdev) pp->dev = &pdev->dev; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!res)return -ENODEV ;
Re: [PATCH v7 2/2] add new platform driver for PCI RC
In reply to Joao PintoQuoted 10 lines · On Monday 01 February 2016 18:07:45 Joao Pinto wrote:
This patch adds a new driver that will be the reference platform driver for all PCI RC IP Protoyping Kits based on ARC SDP.
This patch is composed by:(quoted diff) +0
-2-MAINTAINERS file was updated to include the new driver -Documentation/devicetree/bindings/pci was updated to include the newdriver documentation
-New driver called pcie-synopsysSigned-off-by Joao Pinto <jpinto at synopsys.com>
I must have completely missed all the earlier submissions and just happened to see this one now that it was merged.
I have a couple of comments, maybe you can send a follow up patch to address them:
Documentation/devicetree/bindings/pci/pcie-synopsys.txt line 8
Quoted 7 lines
+----------------------------------
Documentation/devicetree/bindings/pci/pcie-synopsys.txt new file +6
-0+ +This is the reference platform driver to be used in the Synopsys PCI Root +Complex IP Prototyping Kit. + +Required properties: +- compatible: set to "snps,pcie-synopsys";
Please also include the exact version of the designware PCIe part that is used in here, such as "snps,dw-pcie-1.234". I'm sure you can find out the version.
"snps,pcie-synopsys" by itself is about the worst possible compatible string because it says nothing about the specific hardware. Half the machines we support all have a designware PCIe host that was made by synopsys. Please use the name of the SoC for the most specific string.
Quoted 9 lines
+- reg: base address and length of the pcie controller registers. +- #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. +- interrupts: one interrupt source for MSI interrupts, followed by interruptDocumentation/devicetree/bindings/pci/pcie-synopsys.txt new file +3
-0+ source for hardware related interrupts. +- #interrupt-cells: set to <1> +- num-lanes: set to <1>;
Documentation/devicetree/bindings/pci/pcie-synopsys.txt line 27
Quoted 10 lines
Documentation/devicetree/bindings/pci/pcie-synopsys.txt new file +10
-0+ +Example configuration: + + pcie: pcie at 0xdffff000 { + compatible = "snps,pcie-synopsys"; + reg = <0xdffff000 0x1000>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + ranges = <0x00000800 0 0xd0000000 0xd0000000 0 0x00002000>,
This line looks misplaced here and does not match the documentation. It's probably a leftover from an earlier version that had the config space in the ranges, so you need to remove that.
drivers/pci/host/pcie-synopsys.c line 53
Quoted 5 lines
drivers/pci/host/pcie-synopsys.c new file +5
-0+/* This handler was created for future work */ +static irqreturn_t synopsys_pcie_irq_handler (int irq,void *arg) +{ +return IRQ_NONE ; +}
It's not harmful, but we generally don't add code "for future work", better remove it for now.
drivers/pci/host/pcie-synopsys.c line 87
Quoted 13 lines
drivers/pci/host/pcie-synopsys.c new file +13
-0+static void synopsys_pcie_establish_link (struct pcie_port *pp) +{ +int retries =0 ; + +/* check if the link is up or not */ +for (retries =0 ; retries <10 ; retries++) { +if (dw_pcie_link_up (pp)) { +dev_info (pp->dev,"Link up\n" ); +return ; + } +mdelay (100 ); + } +}
That mdelay() needs to be an msleep(). You should never waste a whole second worth of CPU time in a driver.
Arnd
Re: [PATCH v7 2/2] add new platform driver for PCI RC
Quoted 17 lines · Arnd Bergmann
drivers/pci/host/pcie-synopsys.c line 87
Quoted 13 lines · On Monday 01 February 2016 18:07:45 Joao Pinto wrote:
drivers/pci/host/pcie-synopsys.c new file +13
-0+static void synopsys_pcie_establish_link (struct pcie_port *pp) +{ +int retries =0 ; + +/* check if the link is up or not */ +for (retries =0 ; retries <10 ; retries++) { +if (dw_pcie_link_up (pp)) { +dev_info (pp->dev,"Link up\n" ); +return ; + } +mdelay (100 ); + } +}That
mdelay()needs to be anmsleep(). You should never waste a whole second worth of CPU time in a driver.
There are six other copies of this code, and two of them (exynos and spear) have the same problem.
Bjorn
Re: [PATCH v7 2/2] add new platform driver for PCI RC
Quoted 19 lines · On Tuesday 02 February 2016 17:14:49 Bjorn Helgaas wrote:
Quoted 17 lines · Arnd Bergmann
drivers/pci/host/pcie-synopsys.c line 87
Quoted 13 lines · On Monday 01 February 2016 18:07:45 Joao Pinto wrote:
drivers/pci/host/pcie-synopsys.c new file +13
-0+static void synopsys_pcie_establish_link (struct pcie_port *pp) +{ +int retries =0 ; + +/* check if the link is up or not */ +for (retries =0 ; retries <10 ; retries++) { +if (dw_pcie_link_up (pp)) { +dev_info (pp->dev,"Link up\n" ); +return ; + } +mdelay (100 ); + } +}That
mdelay()needs to be anmsleep(). You should never waste a whole second worth of CPU time in a driver.
Quoted 2 lines
There are six other copies of this code, and two of them (exynos and spear) have the same problem.
Good point. Maybe move one (correct) copy into the main driver file and have it called by the other drivers?
IIRC there were some problems in drivers that did a similar function from the config space accessors where you cannot call msleep(), but this driver is not one of them.
Arnd
Re: [PATCH v7 2/2] add new platform driver for PCI RC
In reply to Arnd BergmannHi Joao & Arnd,
Quoted 10 lines · Arnd Bergmann
Quoted 9 lines · On Monday 01 February 2016 18:07:45 Joao Pinto wrote:
This patch adds a new driver that will be the reference platform driver for all PCI RC IP Protoyping Kits based on ARC SDP.
This patch is composed by:(quoted diff) +0
-2-MAINTAINERS file was updated to include the new driver -Documentation/devicetree/bindings/pci was updated to include the newdriver documentation
-New driver called pcie-synopsys
Quoted 7 lines
Quoted 1 line
Signed-off-by Joao Pinto <[email protected]>I must have completely missed all the earlier submissions and just happened to see this one now that it was merged.
I have a couple of comments, maybe you can send a follow up patch to address them:
These seem pretty easy to address, so I pulled these patches out of for-linus temporarily while we fix them.
Joao, you can just fix the mdelay() in your driver; don't worry about fixing other drivers with the same problem or consolidating them.
Bjorn
Quoted 73 lines
Documentation/devicetree/bindings/pci/pcie-synopsys.txt line 8
Quoted 7 lines
+----------------------------------
Documentation/devicetree/bindings/pci/pcie-synopsys.txt new file +6
-0+ +This is the reference platform driver to be used in the Synopsys PCI Root +Complex IP Prototyping Kit. + +Required properties: +- compatible: set to "snps,pcie-synopsys";Please also include the exact version of the designware PCIe part that is used in here, such as "snps,dw-pcie-1.234". I'm sure you can find out the version.
"snps,pcie-synopsys" by itself is about the worst possible compatible string because it says nothing about the specific hardware. Half the machines we support all have a designware PCIe host that was made by synopsys. Please use the name of the SoC for the most specific string.
Quoted 9 lines
+- reg: base address and length of the pcie controller registers. +- #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. +- interrupts: one interrupt source for MSI interrupts, followed by interruptDocumentation/devicetree/bindings/pci/pcie-synopsys.txt new file +3
-0+ source for hardware related interrupts. +- #interrupt-cells: set to <1> +- num-lanes: set to <1>;Documentation/devicetree/bindings/pci/pcie-synopsys.txt line 27
Quoted 10 lines
Documentation/devicetree/bindings/pci/pcie-synopsys.txt new file +10
-0+ +Example configuration: + + pcie: pcie@0xdffff000 { + compatible = "snps,pcie-synopsys"; + reg = <0xdffff000 0x1000>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + ranges = <0x00000800 0 0xd0000000 0xd0000000 0 0x00002000>,This line looks misplaced here and does not match the documentation. It's probably a leftover from an earlier version that had the config space in the ranges, so you need to remove that.
drivers/pci/host/pcie-synopsys.c line 53
Quoted 5 lines
drivers/pci/host/pcie-synopsys.c new file +5
-0+/* This handler was created for future work */ +static irqreturn_t synopsys_pcie_irq_handler (int irq,void *arg) +{ +return IRQ_NONE ; +}It's not harmful, but we generally don't add code "for future work", better remove it for now.
drivers/pci/host/pcie-synopsys.c line 87
Quoted 13 lines
drivers/pci/host/pcie-synopsys.c new file +13
-0+static void synopsys_pcie_establish_link (struct pcie_port *pp) +{ +int retries =0 ; + +/* check if the link is up or not */ +for (retries =0 ; retries <10 ; retries++) { +if (dw_pcie_link_up (pp)) { +dev_info (pp->dev,"Link up\n" ); +return ; + } +mdelay (100 ); + } +}That
mdelay()needs to be anmsleep(). You should never waste a whole second worth of CPU time in a driver.Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 2/2] add new platform driver for PCI RC
Hi Bjorn,
Are these tasks enough?
- replace mdelay() for msleep()
- remove synopsys_pcie_irq_handler()
- replace "snps,pcie-synopsys" for "snps,pcie-synopsys-ipk"?
- rename the driver to pcie-synopsys-ipk?
- update the devicetree documentation referring that the ranges also include the config space
Joao
Quoted 102 lines · Bjorn Helgaas
Hi Joao & Arnd,
Quoted 10 lines · Arnd Bergmann
Quoted 9 lines · On Monday 01 February 2016 18:07:45 Joao Pinto wrote:
This patch adds a new driver that will be the reference platform driver for all PCI RC IP Protoyping Kits based on ARC SDP.
This patch is composed by:(quoted diff) +0
-2-MAINTAINERS file was updated to include the new driver -Documentation/devicetree/bindings/pci was updated to include the newdriver documentation
-New driver called pcie-synopsysQuoted 7 lines
Quoted 1 line
Signed-off-by Joao Pinto <[email protected]>I must have completely missed all the earlier submissions and just happened to see this one now that it was merged.
I have a couple of comments, maybe you can send a follow up patch to address them:
These seem pretty easy to address, so I pulled these patches out of for-linus temporarily while we fix them.
Joao, you can just fix the
mdelay()in your driver; don't worry about fixing other drivers with the same problem or consolidating them.Bjorn
Quoted 73 lines
Documentation/devicetree/bindings/pci/pcie-synopsys.txt line 8
Quoted 7 lines
+----------------------------------
Documentation/devicetree/bindings/pci/pcie-synopsys.txt new file +6
-0+ +This is the reference platform driver to be used in the Synopsys PCI Root +Complex IP Prototyping Kit. + +Required properties: +- compatible: set to "snps,pcie-synopsys";Please also include the exact version of the designware PCIe part that is used in here, such as "snps,dw-pcie-1.234". I'm sure you can find out the version.
"snps,pcie-synopsys" by itself is about the worst possible compatible string because it says nothing about the specific hardware. Half the machines we support all have a designware PCIe host that was made by synopsys. Please use the name of the SoC for the most specific string.
Quoted 9 lines
+- reg: base address and length of the pcie controller registers. +- #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. +- interrupts: one interrupt source for MSI interrupts, followed by interruptDocumentation/devicetree/bindings/pci/pcie-synopsys.txt new file +3
-0+ source for hardware related interrupts. +- #interrupt-cells: set to <1> +- num-lanes: set to <1>;Documentation/devicetree/bindings/pci/pcie-synopsys.txt line 27
Quoted 10 lines
Documentation/devicetree/bindings/pci/pcie-synopsys.txt new file +10
-0+ +Example configuration: + + pcie: pcie@0xdffff000 { + compatible = "snps,pcie-synopsys"; + reg = <0xdffff000 0x1000>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + ranges = <0x00000800 0 0xd0000000 0xd0000000 0 0x00002000>,This line looks misplaced here and does not match the documentation. It's probably a leftover from an earlier version that had the config space in the ranges, so you need to remove that.
drivers/pci/host/pcie-synopsys.c line 53
Quoted 5 lines
drivers/pci/host/pcie-synopsys.c new file +5
-0+/* This handler was created for future work */ +static irqreturn_t synopsys_pcie_irq_handler (int irq,void *arg) +{ +return IRQ_NONE ; +}It's not harmful, but we generally don't add code "for future work", better remove it for now.
drivers/pci/host/pcie-synopsys.c line 87
Quoted 13 lines
drivers/pci/host/pcie-synopsys.c new file +13
-0+static void synopsys_pcie_establish_link (struct pcie_port *pp) +{ +int retries =0 ; + +/* check if the link is up or not */ +for (retries =0 ; retries <10 ; retries++) { +if (dw_pcie_link_up (pp)) { +dev_info (pp->dev,"Link up\n" ); +return ; + } +mdelay (100 ); + } +}That
mdelay()needs to be anmsleep(). You should never waste a whole second worth of CPU time in a driver.Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 2/2] add new platform driver for PCI RC
Quoted 6 lines · Joao Pinto
Hi Bjorn,
Are these tasks enough?
- replace
mdelay()formsleep()
- removesynopsys_pcie_irq_handler()
Above are fine with me.
Quoted 1 line
- replace "snps,pcie-synopsys" for "snps,pcie-synopsys-ipk"?
This is a question for Arnd.
Quoted 1 line
- rename the driver to pcie-synopsys-ipk?
It doesn't seem necessary to me to include both "synopsys" and "ipk" in the filename and the driver name. Take a look at what the existing drivers do, and do something similar.
Quoted 2 lines
- update the devicetree documentation referring that the ranges also include the config space
Another one for Arnd.
Quoted 104 lines · Bjorn Helgaas
Quoted 102 lines
Hi Joao & Arnd,
Quoted 10 lines · Arnd Bergmann
Quoted 9 lines · On Monday 01 February 2016 18:07:45 Joao Pinto wrote:
This patch adds a new driver that will be the reference platform driver for all PCI RC IP Protoyping Kits based on ARC SDP.
This patch is composed by:(quoted diff) +0
-2-MAINTAINERS file was updated to include the new driver -Documentation/devicetree/bindings/pci was updated to include the newdriver documentation
-New driver called pcie-synopsysQuoted 7 lines
Quoted 1 line
Signed-off-by Joao Pinto <jpinto at synopsys.com>I must have completely missed all the earlier submissions and just happened to see this one now that it was merged.
I have a couple of comments, maybe you can send a follow up patch to address them:
These seem pretty easy to address, so I pulled these patches out of for-linus temporarily while we fix them.
Joao, you can just fix the
mdelay()in your driver; don't worry about fixing other drivers with the same problem or consolidating them.Bjorn
Quoted 73 lines
Documentation/devicetree/bindings/pci/pcie-synopsys.txt line 8
Quoted 7 lines
+----------------------------------
Documentation/devicetree/bindings/pci/pcie-synopsys.txt new file +6
-0+ +This is the reference platform driver to be used in the Synopsys PCI Root +Complex IP Prototyping Kit. + +Required properties: +- compatible: set to "snps,pcie-synopsys";Please also include the exact version of the designware PCIe part that is used in here, such as "snps,dw-pcie-1.234". I'm sure you can find out the version.
"snps,pcie-synopsys" by itself is about the worst possible compatible string because it says nothing about the specific hardware. Half the machines we support all have a designware PCIe host that was made by synopsys. Please use the name of the SoC for the most specific string.
Quoted 9 lines
+- reg: base address and length of the pcie controller registers. +- #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. +- interrupts: one interrupt source for MSI interrupts, followed by interruptDocumentation/devicetree/bindings/pci/pcie-synopsys.txt new file +3
-0+ source for hardware related interrupts. +- #interrupt-cells: set to <1> +- num-lanes: set to <1>;Documentation/devicetree/bindings/pci/pcie-synopsys.txt line 27
Quoted 10 lines
Documentation/devicetree/bindings/pci/pcie-synopsys.txt new file +10
-0+ +Example configuration: + + pcie: pcie at 0xdffff000 { + compatible = "snps,pcie-synopsys"; + reg = <0xdffff000 0x1000>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + ranges = <0x00000800 0 0xd0000000 0xd0000000 0 0x00002000>,This line looks misplaced here and does not match the documentation. It's probably a leftover from an earlier version that had the config space in the ranges, so you need to remove that.
drivers/pci/host/pcie-synopsys.c line 53
Quoted 5 lines
drivers/pci/host/pcie-synopsys.c new file +5
-0+/* This handler was created for future work */ +static irqreturn_t synopsys_pcie_irq_handler (int irq,void *arg) +{ +return IRQ_NONE ; +}It's not harmful, but we generally don't add code "for future work", better remove it for now.
drivers/pci/host/pcie-synopsys.c line 87
Quoted 13 lines
drivers/pci/host/pcie-synopsys.c new file +13
-0+static void synopsys_pcie_establish_link (struct pcie_port *pp) +{ +int retries =0 ; + +/* check if the link is up or not */ +for (retries =0 ; retries <10 ; retries++) { +if (dw_pcie_link_up (pp)) { +dev_info (pp->dev,"Link up\n" ); +return ; + } +mdelay (100 ); + } +}That
mdelay()needs to be anmsleep(). You should never waste a whole second worth of CPU time in a driver.Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 2/2] add new platform driver for PCI RC
Quoted 11 lines · On Wednesday 03 February 2016 12:38:44 Bjorn Helgaas wrote:
Quoted 1 line · Joao Pinto
- replace "snps,pcie-synopsys" for "snps,pcie-synopsys-ipk"?
This is a question for Arnd.
Quoted 1 line
- rename the driver to pcie-synopsys-ipk?
It doesn't seem necessary to me to include both "synopsys" and "ipk" in the filename and the driver name. Take a look at what the existing drivers do, and do something similar.
The "synopsys" can go away, it's already in the vendor field of the string. "ipk" is still a bit unspecific, I was hoping to see a specific chip and/or version of the PCIe part. Something like
compatible = "snps,ipk2040-pcie", "snps,ipk-pcie", "snps,dw-pcie-1.23", "snps,dw-pcie";
which would indicate that there is a chip called "ipk2040" in a family called "ipk", and this includes the designware pcie implementation in version 1.23.
Quoted 4 lines
Quoted 2 lines
- update the devicetree documentation referring that the ranges also include the config space
Another one for Arnd.
This one is wrong, the ranges should *not* include the config space, and if they currently do, you must change the driver. The generic dw-pcie driver still accepts the config space in the ranges for backwards compatibility with some of the earlier front-ends that mistakenly did this, but new driver should not do the same, and we should probably add some code in the common driver to prevent it for front-ends other than the ones we have to keep compatibility with.
Arnd
Re: [PATCH v7 2/2] add new platform driver for PCI RC
Hi Arnd and Bjorn,
Quoted 13 lines · Arnd Bergmann
Quoted 11 lines · On Wednesday 03 February 2016 12:38:44 Bjorn Helgaas wrote:
Quoted 1 line · Joao Pinto
- replace "snps,pcie-synopsys" for "snps,pcie-synopsys-ipk"?
This is a question for Arnd.
Quoted 1 line
- rename the driver to pcie-synopsys-ipk?
It doesn't seem necessary to me to include both "synopsys" and "ipk" in the filename and the driver name. Take a look at what the existing drivers do, and do something similar.
Quoted 9 lines
The "synopsys" can go away, it's already in the vendor field of the string. "ipk" is still a bit unspecific, I was hoping to see a specific chip and/or version of the PCIe part. Something like
compatible = "snps,ipk2040-pcie", "snps,ipk-pcie", "snps,dw-pcie-1.23", "snps,dw-pcie";which would indicate that there is a chip called "ipk2040" in a family called "ipk", and this includes the designware pcie implementation in version 1.23.
"snps,dw-pcie" seems a good idea!
Quoted 12 lines
Quoted 4 lines
Quoted 2 lines
- update the devicetree documentation referring that the ranges also include the config space
Another one for Arnd.
This one is wrong, the ranges should *not* include the config space, and if they currently do, you must change the driver. The generic dw-pcie driver still accepts the config space in the ranges for backwards compatibility with some of the earlier front-ends that mistakenly did this, but new driver should not do the same, and we should probably add some code in the common driver to prevent it for front-ends other than the ones we have to keep compatibility with.
I am going to remove the config space from the ranges and test the driver.
Quoted 2 lines
Arnd
Thanks.
Re: [PATCH v7 2/2] add new platform driver for PCI RC
Quoted 4 lines · On Thursday 04 February 2016 11:10:55 Joao Pinto wrote:
Quoted 4 lines
The "synopsys" can go away, it's already in the vendor field of the string. "ipk" is still a bit unspecific, I was hoping to see a specific chip and/or version of the PCIe part. Something like
Quoted 8 lines
Quoted 5 lines
compatible = "snps,ipk2040-pcie", "snps,ipk-pcie", "snps,dw-pcie-1.23", "snps,dw-pcie";which would indicate that there is a chip called "ipk2040" in a family called "ipk", and this includes the designware pcie implementation in version 1.23.
"snps,dw-pcie" seems a good idea!
Just to clarify: I really meant you should put all four of the strings into the compatible property.
Arnd
Re: [PATCH v7 2/2] add new platform driver for PCI RC
In reply to Bjorn HelgaasHi Bjorn,
Quoted 9 lines · Bjorn Helgaas
Quoted 6 lines · Joao Pinto
Hi Bjorn,
Are these tasks enough?
- replace
mdelay()formsleep()
- removesynopsys_pcie_irq_handler()Above are fine with me.
Ok, I'll to that.
Thanks.
Re: [PATCH v7 2/2] add new platform driver for PCI RC
Hi Bjorn and Arnd,
Removing the irq_handler causes the irq request to fail because in request_threaded_irq() both handler and thread_fn are NULL.
What's the typical procedure for this?
Joao
Quoted 17 lines · Joao Pinto
Hi Bjorn,
Quoted 9 lines · Bjorn Helgaas
Quoted 6 lines · Joao Pinto
Hi Bjorn,
Are these tasks enough?
- replace
mdelay()formsleep()
- removesynopsys_pcie_irq_handler()Above are fine with me.
Ok, I'll to that.
Thanks.
Re: [PATCH v7 2/2] add new platform driver for PCI RC
Quoted 7 lines · On Thursday 04 February 2016 14:09:26 Joao Pinto wrote:
Hi Bjorn and Arnd,
Removing the
irq_handlercauses the irq request to fail because inrequest_threaded_irq()both handler andthread_fnare NULL.What's the typical procedure for this?
Don't call request_irq? ;-)
Arnd
Bjorn Helgaas
AppliedQuoted 22 lines · Joao Pinto
This patch set has the goal to add suppport for DesignWare PCIe RC in ARC AXS10x. It includes the necessary tweaks to the ARC architecture, necessary tweaks to the PCI subsystem and a new driver (pcie-synopsys). This new driver will be used extensively in the PCIe RC Prototyping Kit.
The patches were produced against Bjorn Helgaas' repository. It was properly tested in an IP Prototyping Kit.
Joao Pinto (2):
PCI support added to ARC
add new platform driver for PCI RC.../devicetree/bindings/pci/pcie-synopsys.txt | 33 +++ MAINTAINERS | 7 + arch/arc/Kconfig | 23 ++ arch/arc/include/asm/dma.h | 5 + arch/arc/include/asm/io.h | 9 + arch/arc/include/asm/pci.h | 31 +++ arch/arc/kernel/Makefile | 1 + arch/arc/kernel/pcibios.c | 23 ++ arch/arc/plat-axs10x/Kconfig | 1 + drivers/pci/Makefile | 1 +
Quoted 8 lines
drivers/pci/host/Kconfig | 8 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pcie-synopsys.c | 257 +++++++++++++++++++++ 13 files changed, 400 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/pcie-synopsys.txt create mode 100644 arch/arc/include/asm/pci.h create mode 100644 arch/arc/kernel/pcibios.c create mode 100644 drivers/pci/host/pcie-synopsys.c
I applied these to pci/host-synopsys, and I plan to merge them for v4.5.
Bjorn
Hi Bjorn,
Thanks. Could you please send me the git URL for me to give it a try?
Joao
Quoted 36 lines · Bjorn Helgaas
Quoted 22 lines · Joao Pinto
This patch set has the goal to add suppport for DesignWare PCIe RC in ARC AXS10x. It includes the necessary tweaks to the ARC architecture, necessary tweaks to the PCI subsystem and a new driver (pcie-synopsys). This new driver will be used extensively in the PCIe RC Prototyping Kit.
The patches were produced against Bjorn Helgaas' repository. It was properly tested in an IP Prototyping Kit.
Joao Pinto (2):
PCI support added to ARC
add new platform driver for PCI RC.../devicetree/bindings/pci/pcie-synopsys.txt | 33 +++ MAINTAINERS | 7 + arch/arc/Kconfig | 23 ++ arch/arc/include/asm/dma.h | 5 + arch/arc/include/asm/io.h | 9 + arch/arc/include/asm/pci.h | 31 +++ arch/arc/kernel/Makefile | 1 + arch/arc/kernel/pcibios.c | 23 ++ arch/arc/plat-axs10x/Kconfig | 1 + drivers/pci/Makefile | 1 +Quoted 8 lines
drivers/pci/host/Kconfig | 8 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pcie-synopsys.c | 257 +++++++++++++++++++++ 13 files changed, 400 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/pcie-synopsys.txt create mode 100644 arch/arc/include/asm/pci.h create mode 100644 arch/arc/kernel/pcibios.c create mode 100644 drivers/pci/host/pcie-synopsys.cI applied these to pci/host-synopsys, and I plan to merge them for v4.5.
Bjorn
Found it. Thanks.
Quoted 43 lines · Joao Pinto
Hi Bjorn,
Thanks. Could you please send me the git URL for me to give it a try?Joao
Quoted 36 lines · Bjorn Helgaas
Quoted 22 lines · Joao Pinto
This patch set has the goal to add suppport for DesignWare PCIe RC in ARC AXS10x. It includes the necessary tweaks to the ARC architecture, necessary tweaks to the PCI subsystem and a new driver (pcie-synopsys). This new driver will be used extensively in the PCIe RC Prototyping Kit.
The patches were produced against Bjorn Helgaas' repository. It was properly tested in an IP Prototyping Kit.
Joao Pinto (2):
PCI support added to ARC
add new platform driver for PCI RC.../devicetree/bindings/pci/pcie-synopsys.txt | 33 +++ MAINTAINERS | 7 + arch/arc/Kconfig | 23 ++ arch/arc/include/asm/dma.h | 5 + arch/arc/include/asm/io.h | 9 + arch/arc/include/asm/pci.h | 31 +++ arch/arc/kernel/Makefile | 1 + arch/arc/kernel/pcibios.c | 23 ++ arch/arc/plat-axs10x/Kconfig | 1 + drivers/pci/Makefile | 1 +Quoted 8 lines
drivers/pci/host/Kconfig | 8 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pcie-synopsys.c | 257 +++++++++++++++++++++ 13 files changed, 400 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/pcie-synopsys.txt create mode 100644 arch/arc/include/asm/pci.h create mode 100644 arch/arc/kernel/pcibios.c create mode 100644 drivers/pci/host/pcie-synopsys.cI applied these to pci/host-synopsys, and I plan to merge them for v4.5.
Bjorn