Qualcomm PCIe driver and designware fixes
Subsystems (4)
v5 cover Qualcomm PCIe driver and designware fixes
Hi,
I'm sending v5 with following changes:
- in 1/5 - replace wmb() call with PCIE_ATU_CR2 register read.
- in 3/5 - addressed comments from Born Helgaas about usage of a standard PCI capabilities register names and rename link training function to the way that other Designware based drivers use.
- in 5/5 - addressed a comment from Bjorn Andersson about regulator label duplication.
Comments are welcome!
The previous v4 of the patch set can be found at [1].
regards,
Stan
[1] https://lkml.org/lkml/2015/12/3/370
Stanimir Varbanov (5):
PCI: designware: ensure ATU is enabled before IO/conf space accesses
DT: PCI: qcom: Document PCIe devicetree bindings
PCI: qcom: Add Qualcomm PCIe controller driver
ARM: dts: apq8064: add pcie devicetree node
ARM: dts: ifc6410: enable pcie dt node for this board
.../devicetree/bindings/pci/qcom,pcie.txt | 233 ++++++++ MAINTAINERS | 7 + arch/arm/boot/dts/qcom-apq8064-ifc6410.dts | 26 + arch/arm/boot/dts/qcom-apq8064.dtsi | 36 ++ drivers/pci/host/Kconfig | 10 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pcie-designware.c | 7 + drivers/pci/host/pcie-qcom.c | 617 ++++++++++++++++++++ 8 files changed, 937 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/qcom,pcie.txt create mode 100644 drivers/pci/host/pcie-qcom.c
Signature · 1 line
1.7.9.5
PATCH v5 1/5 PCI: designware: ensure ATU is enabled before IO/conf space accesses
There is no guarantees that enabling ATU will hit the hardware immediately, and subsequent accesses to configuration / IO spaces are reliable. So fixing this by read back PCIE_ATU_CR2 register just after writing.
Without such a fix the PCI device enumeration during kernel boot is not reliable, and reading configuration space for particular PCI device on the bus returns zero aka no device.
--- drivers/pci/host/pcie-designware.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/pci/host/pcie-designware.c +7 -0
@@ -154,6 +154,8 @@ static int dw_pcie_wr_own_conf(struct pcie_port *pp, int where, int size,static void dw_pcie_prog_outbound_atu (struct pcie_port *pp,int index,int type,u64 cpu_addr,u64 pci_addr,u32 size) { +u32 val; +dw_pcie_writel_rc (pp,PCIE_ATU_REGION_OUTBOUND | index,PCIE_ATU_VIEWPORT );dw_pcie_writel_rc (pp,lower_32_bits (cpu_addr),PCIE_ATU_LOWER_BASE );
@@ -164,6 +166,11 @@ static void dw_pcie_prog_outbound_atu(struct pcie_port *pp, int index,dw_pcie_writel_rc (pp,upper_32_bits (pci_addr),PCIE_ATU_UPPER_TARGET );dw_pcie_writel_rc (pp, type,PCIE_ATU_CR1 );dw_pcie_writel_rc (pp,PCIE_ATU_ENABLE ,PCIE_ATU_CR2 ); +/* +* ensure that the ATU enable has been happaned before accessing +* pci configuration/io spaces through dw_pcie_cfg_[read|write]. +*/ +dw_pcie_readl_rc (pp,PCIE_ATU_CR2 , &val); }static struct irq_chip dw_msi_irq_chip = {
Signature · 1 line
1.7.9.5
Re: [PATCH v5 1/5] PCI: designware: ensure ATU is enabled before IO/conf space accesses
Quoted 10 lines · Stanimir Varbanov
There is no guarantees that enabling ATU will hit the hardware immediately, and subsequent accesses to configuration / IO spaces are reliable. So fixing this by read back
PCIE_ATU_CR2register just after writing.Without such a fix the PCI device enumeration during kernel boot is not reliable, and reading configuration space for particular PCI device on the bus returns zero aka no device.
Signed-off-by Stanimir Varbanov <[email protected]>
Re: [PATCH v5 1/5] PCI: designware: ensure ATU is enabled before IO/conf space accesses
Quoted 7 lines · Pratyush Anand
Quoted 5 lines · Stanimir Varbanov
There is no guarantees that enabling ATU will hit the hardware immediately, and subsequent accesses to configuration / IO spaces are reliable. So fixing this by read back
PCIE_ATU_CR2register just after writing.
Quoted 7 lines
Quoted 5 lines
Without such a fix the PCI device enumeration during kernel boot is not reliable, and reading configuration space for particular PCI device on the bus returns zero aka no device.
Signed-off-by Stanimir Varbanov <[email protected]>Acked-by Pratyush Anand <[email protected]>
Bjorn, Do you want to resend the whole patchset with collected acks and tested tags?
Signature · 2 lines
regards, Stan
Re: [PATCH v5 1/5] PCI: designware: ensure ATU is enabled before IO/conf space accesses
In reply to Stanimir Varbanov[+cc Jisheng]
Quoted 28 lines · Stanimir Varbanov
There is no guarantees that enabling ATU will hit the hardware immediately, and subsequent accesses to configuration / IO spaces are reliable. So fixing this by read back
PCIE_ATU_CR2register just after writing.Without such a fix the PCI device enumeration during kernel boot is not reliable, and reading configuration space for particular PCI device on the bus returns zero aka no device.
Signed-off-by Stanimir Varbanov <[email protected]>--- drivers/pci/host/pcie-designware.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/pci/host/pcie-designware.c +2
-0@@ -154,6 +154,8 @@ static int dw_pcie_wr_own_conf(struct pcie_port *pp, int where, int size,static void dw_pcie_prog_outbound_atu (struct pcie_port *pp,int index,int type,u64 cpu_addr,u64 pci_addr,u32 size) { +u32 val; +dw_pcie_writel_rc (pp,PCIE_ATU_REGION_OUTBOUND | index,PCIE_ATU_VIEWPORT );dw_pcie_writel_rc (pp,lower_32_bits (cpu_addr),PCIE_ATU_LOWER_BASE );
drivers/pci/host/pcie-designware.c static void dw_pcie_prog_outbound_atu(struct pcie_port *pp, int index, · line 173
Quoted 8 lines
drivers/pci/host/pcie-designware.c +5
-0@@ -164,6 +166,11 @@ static void dw_pcie_prog_outbound_atu(struct pcie_port *pp, int index,dw_pcie_writel_rc (pp,upper_32_bits (pci_addr),PCIE_ATU_UPPER_TARGET );dw_pcie_writel_rc (pp, type,PCIE_ATU_CR1 );dw_pcie_writel_rc (pp,PCIE_ATU_ENABLE ,PCIE_ATU_CR2 ); +/* +* ensure that the ATU enable has been happaned before accessing +* pci configuration/io spaces through dw_pcie_cfg_[read|write]. +*/ +dw_pcie_readl_rc (pp,PCIE_ATU_CR2 , &val);
This particular fix makes sense to me.
But I have a larger question about how the ATU works. I see these definitions:
#define PCIE_ATU_TYPE_MEM #define PCIE_ATU_TYPE_IO #define PCIE_ATU_TYPE_CFG0 #define PCIE_ATU_TYPE_CFG1
and these uses:
- In dw_pcie_host_init(), set PCIE_ATU_TYPE_MEM for unit 1 (but only if rd_other_conf is not overridden)
- In dw_pcie_rd_other_conf() and dw_pcie_wr_other_conf(),
set PCIE_ATU_TYPE_CFG0 before config access to own bus;
set PCIE_ATU_TYPE_CFG1 before config access to other bus;
set PCIE_ATU_TYPE_IO after completionI'm confused:
1) I assume PCIE_ATU_TYPE_MEM is for access to PCI memory space. Why is that initialization related to rd_other_conf? Shouldn't that be set up always? A comment here would be nice, to clarify that this is not related to the subsequent dw_pcie_wr_own_conf() calls.
2) Why doesn't dw_pcie_host_init() use dw_pcie_rd_conf() instead of dw_pcie_rd_own_conf()? Using pci_read_config_dword() might be even better. Using the internal interfaces piecemeal like we do today is just an opportunity for doing it wrong.
3) The definitions and your comment about "accessing PCI configuration/io spaces" suggest that the ATU must be programmed differently for accesses to PCI config space vs. I/O space. If that's the case, we'd need some kind of mutex to protect inl(), etc., during config accesses. For example, in this scenario:
thread A thread B
--------------------------------------------- ----------
pci_read_config_dword()
dw_pcie_prog_outbound_atu(PCIE_ATU_TYPE_CFG0)
inl()
dw_pcie_cfg_read()
readl()
dw_pcie_prog_outbound_atu(PCIE_ATU_TYPE_IO)
inl()Do both inl() calls by thread B work correctly, even though the ATU seems to be programmed for CFG0 for the first but IO for the second?
Bjorn
Re: [PATCH v5 1/5] PCI: designware: ensure ATU is enabled before IO/conf space accesses
Dear Bjorn,
Quoted 60 lines · On Wed, 6 Jan 2016 12:20:03 -0600 Bjorn Helgaas wrote:
[+cc Jisheng]
Quoted 28 lines · Stanimir Varbanov
There is no guarantees that enabling ATU will hit the hardware immediately, and subsequent accesses to configuration / IO spaces are reliable. So fixing this by read back
PCIE_ATU_CR2register just after writing.Without such a fix the PCI device enumeration during kernel boot is not reliable, and reading configuration space for particular PCI device on the bus returns zero aka no device.
Signed-off-by Stanimir Varbanov <[email protected]>--- drivers/pci/host/pcie-designware.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/pci/host/pcie-designware.c +2
-0@@ -154,6 +154,8 @@ static int dw_pcie_wr_own_conf(struct pcie_port *pp, int where, int size,static void dw_pcie_prog_outbound_atu (struct pcie_port *pp,int index,int type,u64 cpu_addr,u64 pci_addr,u32 size) { +u32 val; +dw_pcie_writel_rc (pp,PCIE_ATU_REGION_OUTBOUND | index,PCIE_ATU_VIEWPORT );dw_pcie_writel_rc (pp,lower_32_bits (cpu_addr),PCIE_ATU_LOWER_BASE );drivers/pci/host/pcie-designware.c static void dw_pcie_prog_outbound_atu(struct pcie_port *pp, int index, · line 173
Quoted 8 lines
drivers/pci/host/pcie-designware.c +5
-0@@ -164,6 +166,11 @@ static void dw_pcie_prog_outbound_atu(struct pcie_port *pp, int index,dw_pcie_writel_rc (pp,upper_32_bits (pci_addr),PCIE_ATU_UPPER_TARGET );dw_pcie_writel_rc (pp, type,PCIE_ATU_CR1 );dw_pcie_writel_rc (pp,PCIE_ATU_ENABLE ,PCIE_ATU_CR2 ); +/* +* ensure that the ATU enable has been happaned before accessing +* pci configuration/io spaces through dw_pcie_cfg_[read|write]. +*/ +dw_pcie_readl_rc (pp,PCIE_ATU_CR2 , &val);This particular fix makes sense to me.
But I have a larger question about how the ATU works. I see these definitions:
#define PCIE_ATU_TYPE_MEM #define PCIE_ATU_TYPE_IO #define PCIE_ATU_TYPE_CFG0 #define PCIE_ATU_TYPE_CFG1and these uses:
- In
dw_pcie_host_init(), setPCIE_ATU_TYPE_MEMfor unit 1 (but only ifrd_other_confis not overridden)- In
dw_pcie_rd_other_conf()anddw_pcie_wr_other_conf(),set PCIE_ATU_TYPE_CFG0 before config access to own bus; set PCIE_ATU_TYPE_CFG1 before config access to other bus; set PCIE_ATU_TYPE_IO after completion
Quoted 6 lines
I'm confused:
1) I assume
PCIE_ATU_TYPE_MEMis for access to PCI memory space. Why is that initialization related tord_other_conf? Shouldn't that be set up always? A comment here would be nice, to clarify that this is not related to the subsequentdw_pcie_wr_own_conf()calls.
Indeed, the comment is necessary. I forget the reason until read the code carefully again. The reason here is
If the platform provides ->rd_other_conf, it means the platform doesn't support ATU, it uses its own address translation component rather than ATU, so we should ignore ATU programming for this kind of platform.
I have sent out one patch to add this comment.
Quoted 5 lines
2) Why doesn't
dw_pcie_host_init()usedw_pcie_rd_conf()instead ofdw_pcie_rd_own_conf()? Usingpci_read_config_dword()might be even better. Using the internal interfaces piecemeal like we do today is just an opportunity for doing it wrong.
IMHO, the reason is during host_init, the pci bus etc. are not initialized, from another side, the code is really accessing its own conf registers.
Quoted 4 lines
3) The definitions and your comment about "accessing PCI configuration/io spaces" suggest that the ATU must be programmed differently for accesses to PCI config space vs. I/O space. If that's
Yes.
Quoted 7 lines
the case, we'd need some kind of mutex to protect
inl(), etc., during config accesses. For example, in this scenario:thread A thread B
--------------------------------------------- ----------
pci_read_config_dword()
dw_pcie_prog_outbound_atu(PCIE_ATU_TYPE_CFG0)
Quoted 9 lines
inl() dw_pcie_cfg_read() readl() dw_pcie_prog_outbound_atu(PCIE_ATU_TYPE_IO) inl()Do both
inl()calls by thread B work correctly, even though the ATU seems to be programmed for CFG0 for the first but IO for the second?
Indeed, there's such race issue as you and RMK pointed out.
IMHO, we need support:
1. platforms which contain three or more iATUs, there's no need to mux iATU usage: one ATU for IO, one for cfg and another for MEM. But how to get the number of iATUs, DT? eg. "snps,atu_num = 3"
2. platforms which contain only two iATUs, add mechanism to protect the cfg vs IO race. Could you please give suggestions to how to achieve this goal?
Thanks,
Jisheng
PATCH v5 2/5 DT: PCI: qcom: Document PCIe devicetree bindings
In reply to Stanimir VarbanovFrom: Stanimir Varbanov <[email protected]>
Document Qualcomm PCIe driver devicetree bindings.
--- .../devicetree/bindings/pci/qcom,pcie.txt | 233 ++++++++++++++++++++ 1 file changed, 233 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/qcom,pcie.txt
Documentation/devicetree/bindings/pci/qcom,pcie.txt new file +233 -0
@@ -0,0 +1,233 @@ +* Qualcomm PCI express root complex + +- compatible: + Usage: required + Value type: <stringlist> + Definition: Value should contain + - "qcom,pcie-ipq8064" for ipq8064 + - "qcom,pcie-apq8064" for apq8064 + - "qcom,pcie-apq8084" for apq8084 + +- reg: + Usage: required + Value type: <prop-encoded-array> + Definition: Register ranges as listed in the reg-names property + +- reg-names: + Usage: required + Value type: <stringlist> + Definition: Must include the following entries + - "parf" Qualcomm specific registers + - "dbi" Designware PCIe registers + - "elbi" External local bus interface registers + - "config" PCIe configuration space + +- device_type: + Usage: required + Value type: <string> + Definition: Should be "pci". As specified in designware-pcie.txt + +- #address-cells: + Usage: required + Value type: <u32> + Definition: Should be set to 3. As specified in designware-pcie.txt + +- #size-cells: + Usage: required + Value type: <u32> + Definition: Should be set 2. As specified in designware-pcie.txt + +- ranges: + Usage: required + Value type: <prop-encoded-array> + Definition: As specified in designware-pcie.txt + +- interrupts: + Usage: required + Value type: <prop-encoded-array> + Definition: MSI interrupt + +- interrupt-names: + Usage: required + Value type: <stringlist> + Definition: Should contain "msi" + +- #interrupt-cells: + Usage: required + Value type: <u32> + Definition: Should be 1. As specified in designware-pcie.txt + +- interrupt-map-mask: + Usage: required + Value type: <prop-encoded-array> + Definition: As specified in designware-pcie.txt + +- interrupt-map: + Usage: required + Value type: <prop-encoded-array> + Definition: As specified in designware-pcie.txt + +- clocks: + Usage: required + Value type: <prop-encoded-array> + Definition: List of phandle and clock specifier pairs as listed + in clock-names property + +- clock-names: + Usage: required + Value type: <stringlist> + Definition: Should contain the following entries + - "iface" Configuration AHB clock + +- clock-names: + Usage: required for ipq/apq8064 + Value type: <stringlist> + Definition: Should contain the following entries + - "core" Clocks the pcie hw block + - "phy" Clocks the pcie PHY block +- clock-names: + Usage: required for apq8084 + Value type: <stringlist> + Definition: Should contain the following entries + - "aux" Auxiliary (AUX) clock + - "bus_master" Master AXI clock + - "bus_slave" Slave AXI clock +- resets: + Usage: required + Value type: <prop-encoded-array> + Definition: List of phandle and reset specifier pairs as listed + in reset-names property + +- reset-names: + Usage: required for ipq/apq8064 + Value type: <stringlist> + Definition: Should contain the following entries + - "axi" AXI reset + - "ahb" AHB reset + - "por" POR reset + - "pci" PCI reset + - "phy" PHY reset + +- reset-names: + Usage: required for apq8084 + Value type: <stringlist> + Definition: Should contain the following entries + - "core" Core reset + +- power-domains: + Usage: required for apq8084 + Value type: <prop-encoded-array> + Definition: A phandle and power domain specifier pair to the + power domain which is responsible for collapsing + and restoring power to the peripheral + +- vdda-supply: + Usage: required + Value type: <phandle> + Definition: A phandle to the core analog power supply + +- vdda_phy-supply: + Usage: required for ipq/apq8064 + Value type: <phandle> + Definition: A phandle to the analog power supply for PHY + +- vdda_refclk-supply: + Usage: required for ipq/apq8064 + Value type: <phandle> + Definition: A phandle to the analog power supply for IC which generates + reference clock + +- phys: + Usage: required for apq8084 + Value type: <phandle> + Definition: List of phandle(s) as listed in phy-names property + +- phy-names: + Usage: required for apq8084 + Value type: <stringlist> + Definition: Should contain "pciephy" + +- <name>-gpios: + Usage: optional + Value type: <prop-encoded-array> + Definition: List of phandle and gpio specifier pairs. Should contain + - "perst-gpios" PCIe endpoint reset signal line + - "wake-gpios" PCIe endpoint wake signal line + +* Example for ipq/apq8064 + pcie at 1b500000 { + compatible = "qcom,pcie-apq8064", "qcom,pcie-ipq8064", "snps,dw-pcie"; + reg = <0x1b500000 0x1000 + 0x1b502000 0x80 + 0x1b600000 0x100 + 0x0ff00000 0x100000>; + reg-names = "dbi", "elbi", "parf", "config"; + device_type = "pci"; + linux,pci-domain = <0>; + bus-range = <0x00 0xff>; + num-lanes = <1>; + #address-cells = <3>; + #size-cells = <2>; + ranges = <0x81000000 0 0 0x0fe00000 0 0x00100000 /* I/O */ + 0x82000000 0 0 0x08000000 0 0x07e00000>; /* memory */ + interrupts = <GIC_SPI 238 IRQ_TYPE_NONE>; + interrupt-names = "msi"; + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 0x7>; + interrupt-map = <0 0 0 1 &intc 0 36 IRQ_TYPE_LEVEL_HIGH>, /* int_a */ + <0 0 0 2 &intc 0 37 IRQ_TYPE_LEVEL_HIGH>, /* int_b */ + <0 0 0 3 &intc 0 38 IRQ_TYPE_LEVEL_HIGH>, /* int_c */ + <0 0 0 4 &intc 0 39 IRQ_TYPE_LEVEL_HIGH>; /* int_d */ + clocks = <&gcc PCIE_A_CLK>, + <&gcc PCIE_H_CLK>, + <&gcc PCIE_PHY_CLK>; + clock-names = "core", "iface", "phy"; + resets = <&gcc PCIE_ACLK_RESET>, + <&gcc PCIE_HCLK_RESET>, + <&gcc PCIE_POR_RESET>, + <&gcc PCIE_PCI_RESET>, + <&gcc PCIE_PHY_RESET>; + reset-names = "axi", "ahb", "por", "pci", "phy"; + pinctrl-0 = <&pcie_pins_default>; + pinctrl-names = "default"; + }; + +* Example for apq8084 + pcie0 at fc520000 { + compatible = "qcom,pcie-apq8084", "snps,dw-pcie"; + reg = <0xfc520000 0x2000>, + <0xff000000 0x1000>, + <0xff001000 0x1000>, + <0xff002000 0x2000>; + reg-names = "parf", "dbi", "elbi", "config"; + device_type = "pci"; + linux,pci-domain = <0>; + bus-range = <0x00 0xff>; + num-lanes = <1>; + #address-cells = <3>; + #size-cells = <2>; + ranges = <0x81000000 0 0 0xff200000 0 0x00100000 /* I/O */ + 0x82000000 0 0x00300000 0xff300000 0 0x00d00000>; /* memory */ + interrupts = <GIC_SPI 243 IRQ_TYPE_NONE>; + interrupt-names = "msi"; + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 0x7>; + interrupt-map = <0 0 0 1 &intc 0 244 IRQ_TYPE_LEVEL_HIGH>, /* int_a */ + <0 0 0 2 &intc 0 245 IRQ_TYPE_LEVEL_HIGH>, /* int_b */ + <0 0 0 3 &intc 0 247 IRQ_TYPE_LEVEL_HIGH>, /* int_c */ + <0 0 0 4 &intc 0 248 IRQ_TYPE_LEVEL_HIGH>; /* int_d */ + clocks = <&gcc GCC_PCIE_0_CFG_AHB_CLK>, + <&gcc GCC_PCIE_0_MSTR_AXI_CLK>, + <&gcc GCC_PCIE_0_SLV_AXI_CLK>, + <&gcc GCC_PCIE_0_AUX_CLK>; + clock-names = "iface", "master_bus", "slave_bus", "aux"; + resets = <&gcc GCC_PCIE_0_BCR>; + reset-names = "core"; + power-domains = <&gcc PCIE0_GDSC>; + vdda-supply = <&pma8084_l3>; + phys = <&pciephy0>; + phy-names = "pciephy"; + perst-gpio = <&tlmm 70 GPIO_ACTIVE_LOW>; + pinctrl-0 = <&pcie0_pins_default>; + pinctrl-names = "default"; + };
Signature · 1 line
1.7.9.5
PATCH v5 3/5 PCI: qcom: Add Qualcomm PCIe controller driver
In reply to Stanimir VarbanovFrom: Stanimir Varbanov <[email protected]>
The PCIe driver reuse the Designware common code for host and MSI initialization, and also program the Qualcomm application specific registers.
--- MAINTAINERS | 7 + drivers/pci/host/Kconfig | 10 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pcie-qcom.c | 617 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 635 insertions(+) create mode 100644 drivers/pci/host/pcie-qcom.c
MAINTAINERS +7 -0
@@ -8247,6 +8247,13 @@ S: Maintained F: Documentation/devicetree/bindings/pci/hisilicon-pcie.txt F: drivers/pci/host/pcie-hisi.c +PCIE DRIVER FOR QUALCOMM MSM +M: Stanimir Varbanov <[email protected]> +L: linux-pci at vger.kernel.org +L: linux-arm-msm at vger.kernel.org +S: Maintained +F: drivers/pci/host/*qcom* + PCMCIA SUBSYSTEM P: Linux PCMCIA Team L: linux-pcmcia at lists.infradead.org
drivers/pci/host/Kconfig +10 -0
@@ -172,4 +172,14 @@ config PCI_HISI help Say Y here if you want PCIe controller support on HiSilicon HIP05 SoC +config PCIE_QCOM + bool "Qualcomm PCIe controller" + depends on ARCH_QCOM && OF || COMPILE_TEST + select PCIE_DW + select PCIEPORTBUS + help + Say Y here to enable PCIe controller support on Qualcomm SoCs. The + PCIe controller use Designware core plus Qualcomm specific hardware + wrappers. + 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_QCOM) += pcie-qcom.o
drivers/pci/host/pcie-qcom.c new file +617 -0
617 lines not on this page · raw message
Signature · 1 line
1.7.9.5
kbuild test robot
build bot[PATCH] PCI: qcom: fix ptr_ret.cocci warnings
drivers/pci/host/pcie-qcom.c:188:1-3: WARNING: PTR_ERR_OR_ZERO can be used drivers/pci/host/pcie-qcom.c:220:1-3: WARNING: PTR_ERR_OR_ZERO can be used
drivers/pci/host/pcie-qcom.c:188:1-3: WARNING: PTR_ERR_OR_ZERO can be used drivers/pci/host/pcie-qcom.c:220:1-3: WARNING: PTR_ERR_OR_ZERO can be used
Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
Generated by: scripts/coccinelle/api/ptr_ret.cocci
---
pcie-qcom.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/pci/host/pcie-qcom.c +2 -8
@@ -185,10 +185,7 @@ static int qcom_pcie_get_resources_v0(streturn PTR_ERR (res->por_reset); res->phy_reset =devm_reset_control_get (dev,"phy" ); -if (IS_ERR (res->phy_reset)) -return PTR_ERR (res->phy_reset); - -return 0 ; +return PTR_ERR_OR_ZERO (res->phy_reset); }static int qcom_pcie_get_resources_v1 (struct qcom_pcie *pcie)
@@ -217,10 +214,7 @@ static int qcom_pcie_get_resources_v1(streturn PTR_ERR (res->slave_bus); res->core =devm_reset_control_get (dev,"core" ); -if (IS_ERR (res->core)) -return PTR_ERR (res->core); - -return 0 ; +return PTR_ERR_OR_ZERO (res->core); }static void qcom_pcie_deinit_v0 (struct qcom_pcie *pcie)
kbuild test robot
build botRe: [PATCH v5 3/5] PCI: qcom: Add Qualcomm PCIe controller driver
In reply to Stanimir Varbanovurl: https://github.com/0day-ci/linux/commits/Stanimir-Varbanov/Qualcomm-PCIe-driver-and-designware-fixes/20151218-205427
Hi Stanimir,
[auto build test WARNING on next-20151218]
[also build test WARNING on v4.4-rc5]
[cannot apply to pci/next robh/for-next v4.4-rc5 v4.4-rc4 v4.4-rc3]
coccinelle warnings: (new ones prefixed by >>)
>> drivers/pci/host/pcie-qcom.c:188:1-3: WARNING: PTR_ERR_OR_ZERO can be used
drivers/pci/host/pcie-qcom.c:220:1-3: WARNING: PTR_ERR_OR_ZERO can be used
Please review and possibly fold the followup patch.
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH v5 3/5] PCI: qcom: Add Qualcomm PCIe controller driver
Quoted 9 lines · kbuild test robot
Hi Stanimir,
[auto build test WARNING on next-20151218]
[also build test WARNING on v4.4-rc5]
[cannot apply to pci/next robh/for-next v4.4-rc5 v4.4-rc4 v4.4-rc3]
Quoted 7 lines
coccinelle warnings: (new ones prefixed by >>)
Quoted 1 line
Quoted 1 line
drivers/pci/host/pcie-qcom.c:188:1-3: WARNING:
PTR_ERR_OR_ZEROcan be useddrivers/pci/host/pcie-qcom.c:220:1-3: WARNING:
PTR_ERR_OR_ZEROcan be usedPlease review and possibly fold the followup patch.
I disagree with this "recommendation" as it's only outcome will be asymmetry.
I think this script should be changed to only warn if there's a single IS_ERR/PTR_ERR at the end of the function, not if there's a list of them and this would replace the last one.
Regards,
Bjorn
Re: [PATCH v5 3/5] PCI: qcom: Add Qualcomm PCIe controller driver
Quoted 6 lines · Bjorn Andersson
I disagree with this "recommendation" as it's only outcome will be asymmetry.
I think this script should be changed to only warn if there's a single IS_ERR/PTR_ERR at the end of the function, not if there's a list of them and this would replace the last one.
Agreed, looks like a false positive, and I think it's best to ignore the warning here, but not change the script that seems reasonable in general.
Arnd
PATCH v5 4/5 ARM: dts: apq8064: add pcie devicetree node
In reply to Stanimir VarbanovAdd the pcie dt node so that it can probe and used.
--- arch/arm/boot/dts/qcom-apq8064.dtsi | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
arch/arm/boot/dts/qcom-apq8064.dtsi +36 -0
@@ -705,5 +705,41 @@ compatible = "qcom,tcsr-apq8064", "syscon"; reg = <0x1a400000 0x100>; }; + + pcie: pci at 1b500000 { + compatible = "qcom,pcie-apq8064", "snps,dw-pcie"; + reg = <0x1b500000 0x1000 + 0x1b502000 0x80 + 0x1b600000 0x100 + 0x0ff00000 0x100000>; + reg-names = "dbi", "elbi", "parf", "config"; + device_type = "pci"; + linux,pci-domain = <0>; + bus-range = <0x00 0xff>; + num-lanes = <1>; + #address-cells = <3>; + #size-cells = <2>; + ranges = <0x81000000 0 0 0x0fe00000 0 0x00100000 /* I/O */ + 0x82000000 0 0 0x08000000 0 0x07e00000>; /* memory */ + interrupts = <GIC_SPI 238 IRQ_TYPE_NONE>; + interrupt-names = "msi"; + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 0x7>; + interrupt-map = <0 0 0 1 &intc 0 36 IRQ_TYPE_LEVEL_HIGH>, /* int_a */ + <0 0 0 2 &intc 0 37 IRQ_TYPE_LEVEL_HIGH>, /* int_b */ + <0 0 0 3 &intc 0 38 IRQ_TYPE_LEVEL_HIGH>, /* int_c */ + <0 0 0 4 &intc 0 39 IRQ_TYPE_LEVEL_HIGH>; /* int_d */ + clocks = <&gcc PCIE_A_CLK>, + <&gcc PCIE_H_CLK>, + <&gcc PCIE_PHY_REF_CLK>; + clock-names = "core", "iface", "phy"; + resets = <&gcc PCIE_ACLK_RESET>, + <&gcc PCIE_HCLK_RESET>, + <&gcc PCIE_POR_RESET>, + <&gcc PCIE_PCI_RESET>, + <&gcc PCIE_PHY_RESET>; + reset-names = "axi", "ahb", "por", "pci", "phy"; + status = "disabled"; + }; }; };
Signature · 1 line
1.7.9.5
PATCH v5 5/5 ARM: dts: ifc6410: enable pcie dt node for this board
In reply to Stanimir VarbanovEnable pcie dt node and fill pcie dt node with regulator, pinctrl and reset gpio, to use the pcie on the ifc6410 board.
--- arch/arm/boot/dts/qcom-apq8064-ifc6410.dts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
arch/arm/boot/dts/qcom-apq8064-ifc6410.dts +26 -0
@@ -47,6 +47,18 @@ bias-disable; }; }; + + pcie_pins: pcie_pinmux { + mux { + pins = "gpio27"; + function = "gpio"; + }; + conf { + pins = "gpio27"; + drive-strength = <12>; + bias-disable; + }; + }; }; rpm at 108000 {
@@ -123,6 +135,10 @@ lvs1 { bias-pull-down; }; + + lvs6 { + bias-pull-down; + }; }; };
@@ -231,6 +247,16 @@ status = "okay"; }; + pci at 1b500000 { + status = "ok"; + vdda-supply = <&pm8921_s3>; + vdda_phy-supply = <&pm8921_lvs6>; + vdda_refclk-supply = <&ext_3p3v>; + pinctrl-0 = <&pcie_pins>; + pinctrl-names = "default"; + perst-gpio = <&tlmm_pinmux 27 GPIO_ACTIVE_LOW>; + }; + qcom,ssbi at 500000 { pmic at 0 { gpio at 150 {
Signature · 1 line
1.7.9.5
Bjorn Helgaas
AppliedQuoted 26 lines · Stanimir Varbanov
Hi,
I'm sending v5 with following changes:
- in 1/5 - replacewmb()call withPCIE_ATU_CR2register read.
- in 3/5 - addressed comments from Born Helgaas about usage of a standard PCI capabilities register names and rename link training function to the way that other Designware based drivers use.
- in 5/5 - addressed a comment from Bjorn Andersson about regulator label duplication.Comments are welcome!
The previous v4 of the patch set can be found at [1].
regards,
Stan[1] https://lkml.org/lkml/2015/12/3/370
Stanimir Varbanov (5):
PCI: designware: ensure ATU is enabled before IO/conf space accesses
DT: PCI: qcom: Document PCIe devicetree bindings
PCI: qcom: Add Qualcomm PCIe controller driver
ARM: dts: apq8064: add pcie devicetree node
ARM: dts: ifc6410: enable pcie dt node for this board
Quoted 11 lines
.../devicetree/bindings/pci/qcom,pcie.txt | 233 ++++++++ MAINTAINERS | 7 + arch/arm/boot/dts/qcom-apq8064-ifc6410.dts | 26 + arch/arm/boot/dts/qcom-apq8064.dtsi | 36 ++ drivers/pci/host/Kconfig | 10 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pcie-designware.c | 7 + drivers/pci/host/pcie-qcom.c | 617 ++++++++++++++++++++ 8 files changed, 937 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/qcom,pcie.txt create mode 100644 drivers/pci/host/pcie-qcom.c
Applied to pci/host-qcom for v4.5, with Pratyush's ack on the first patch. Thanks!