mbox series

[v25,00/15] PCI: dwc: rcar-gen4: Add R-Car Gen4 PCIe support

Message ID 20231018085631.1121289-1-yoshihiro.shimoda.uh@renesas.com (mailing list archive)
Headers show
Series PCI: dwc: rcar-gen4: Add R-Car Gen4 PCIe support | expand

Message

Yoshihiro Shimoda Oct. 18, 2023, 8:56 a.m. UTC
Add R-Car S4-8 (R-Car Gen4) PCIe controller for both host and endpoint modes.
To support them, modify PCIe DesignWare common codes.

Changes from v24:
https://lore.kernel.org/linux-pci/20231011071423.249458-1-yoshihiro.shimoda.uh@renesas.com/
 - Based on the latest pci.git / next branch.
 - Reordering the patches. (This is suggested by Bjorn.)
 - Drop "PCI: dwc: Disable two BARs to avoid unnecessary memory assignment"
   because break other platforms.
 - Modify the patch for the latest next branch in the patch 04/15.
 - Add specific-setting by using dbi2 again in the patch 12/15.
 - Modify commend of the specific-setting in the patch 12/15. Serge suggested
   this on v23 but I missed to modify this on v24.
 - Fix for -Wincompatible-function-pointer-types-strict  int the patch 13/15.

Changes from v23:
https://lore.kernel.org/linux-pci/20230926122431.3974714-1-yoshihiro.shimoda.uh@renesas.com/
 - Based on the latest pci.git / next branch.
 - Remove Link tag and Krzysztof's s-o-b tags from all patches.
 - Drop "PCI: dwc: Expose dw_pcie_write_dbi2() to module".
 - Add "PCI: dwc: Disable two BARs to avoid unnecessary memory assignment".
 - Add Reviewed-by in the patch 0[137]/16 and the patch 1[24]/16.
 - Fix typo in the patch 14/16.
 - Fix error messages and commit descriptions in the patch 1[234]/16.
 - Change the subjects in the patch 1[34]/16.
 - Use aplhabetical order on Kconfig in the patch 1[34]/16.
 - Drop DWC spec code in the patch 13/16. 

Changes from v22:
https://lore.kernel.org/linux-pci/20230925072130.3901087-1-yoshihiro.shimoda.uh@renesas.com/
 - Based on the latest pci.git / next branch.
 - Add Reviewed-by in the patch 12/16.
 - Move a few endpoint related code from the patch 13/16 to 14/16.
 - Change subjects in the patch 1[34]/16.
 - Modify the code for readability in the patch 14/16.

Yoshihiro Shimoda (15):
  PCI: Add T_PVPERL macro
  PCI: dwc: Add dw_pcie_link_set_max_link_width()
  PCI: dwc: Add missing PCI_EXP_LNKCAP_MLW handling
  PCI: tegra194: Drop PCI_EXP_LNKSTA_NLW setting
  PCI: dwc: endpoint: Add multiple PFs support for dbi2
  PCI: dwc: Add EDMA_UNROLL capability flag
  PCI: dwc: Expose dw_pcie_ep_exit() to module
  PCI: dwc: endpoint: Introduce .pre_init() and .deinit()
  dt-bindings: PCI: dwc: Update maxItems of reg and reg-names
  dt-bindings: PCI: renesas: Add R-Car Gen4 PCIe Host
  dt-bindings: PCI: renesas: Add R-Car Gen4 PCIe Endpoint
  PCI: rcar-gen4: Add R-Car Gen4 PCIe controller support for host mode
  PCI: rcar-gen4: Add endpoint mode support
  MAINTAINERS: Update PCI DRIVER FOR RENESAS R-CAR for R-Car Gen4
  misc: pci_endpoint_test: Add Device ID for R-Car S4-8 PCIe controller

 .../bindings/pci/rcar-gen4-pci-ep.yaml        | 115 ++++
 .../bindings/pci/rcar-gen4-pci-host.yaml      | 127 +++++
 .../bindings/pci/snps,dw-pcie-common.yaml     |   4 +-
 .../bindings/pci/snps,dw-pcie-ep.yaml         |   4 +-
 .../devicetree/bindings/pci/snps,dw-pcie.yaml |   4 +-
 MAINTAINERS                                   |   1 +
 drivers/misc/pci_endpoint_test.c              |   4 +
 drivers/pci/controller/dwc/Kconfig            |  25 +
 drivers/pci/controller/dwc/Makefile           |   1 +
 .../pci/controller/dwc/pcie-designware-ep.c   |  45 +-
 drivers/pci/controller/dwc/pcie-designware.c  | 101 ++--
 drivers/pci/controller/dwc/pcie-designware.h  |   8 +-
 drivers/pci/controller/dwc/pcie-rcar-gen4.c   | 527 ++++++++++++++++++
 drivers/pci/controller/dwc/pcie-tegra194.c    |   6 -
 drivers/pci/pci.h                             |   3 +
 15 files changed, 906 insertions(+), 69 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pci/rcar-gen4-pci-ep.yaml
 create mode 100644 Documentation/devicetree/bindings/pci/rcar-gen4-pci-host.yaml
 create mode 100644 drivers/pci/controller/dwc/pcie-rcar-gen4.c

Comments

Bjorn Helgaas Oct. 19, 2023, 3:10 a.m. UTC | #1
On Wed, Oct 18, 2023 at 05:56:16PM +0900, Yoshihiro Shimoda wrote:
> Add R-Car S4-8 (R-Car Gen4) PCIe controller for both host and endpoint modes.
> To support them, modify PCIe DesignWare common codes.
> 
> Changes from v24:
> https://lore.kernel.org/linux-pci/20231011071423.249458-1-yoshihiro.shimoda.uh@renesas.com/
>  - Based on the latest pci.git / next branch.
>  - Reordering the patches. (This is suggested by Bjorn.)
>  - Drop "PCI: dwc: Disable two BARs to avoid unnecessary memory assignment"
>    because break other platforms.

Does R-Car Gen4 still work without this patch?

The previous commit log said host mode didn't work:

  PCI: dwc: Disable two BARs to avoid unnecessary memory assignment

  According to the section 3.5.7.2 "RC Mode" in DWC PCIe Dual Mode
  Rev.5.20a, we should disable two BARs to avoid unnecessary memory
  assignment during device enumeration. Otherwise, Renesas R-Car Gen4
  PCIe controllers cannot work correctly in host mode.

(from
https://lore.kernel.org/r/20231011071423.249458-9-yoshihiro.shimoda.uh@renesas.com)

I don't think we want to merge the driver unless it actually works.

Bjorn
Yoshihiro Shimoda Oct. 19, 2023, 4:08 a.m. UTC | #2
Hello Bjorn,

> From: Bjorn Helgaas, Sent: Thursday, October 19, 2023 12:11 PM
> 
> On Wed, Oct 18, 2023 at 05:56:16PM +0900, Yoshihiro Shimoda wrote:
> > Add R-Car S4-8 (R-Car Gen4) PCIe controller for both host and endpoint modes.
> > To support them, modify PCIe DesignWare common codes.
> >
> > Changes from v24:
> >
<snip URL>
> >  - Based on the latest pci.git / next branch.
> >  - Reordering the patches. (This is suggested by Bjorn.)
> >  - Drop "PCI: dwc: Disable two BARs to avoid unnecessary memory assignment"
> >    because break other platforms.
> 
> Does R-Car Gen4 still work without this patch?

Yes, R-Car Gen4 still work without this patch because I added this code into
the patch 12/15 again:

---
+static int rcar_gen4_pcie_host_init(struct dw_pcie_rp *pp)
+{
...
+	/*
+	 * According to the section 3.5.7.2 "RC Mode" in DWC PCIe Dual Mode
+	 * Rev.5.20a and 3.5.6.1 "RC mode" in DWC PCIe RC databook v5.20a, we
+	 * should disable two BARs to avoid unnecessary memory assignment
+	 * during device enumeration.
+	 */
+	dw_pcie_writel_dbi2(dw, PCI_BASE_ADDRESS_0, 0x0);
+	dw_pcie_writel_dbi2(dw, PCI_BASE_ADDRESS_1, 0x0);
---

I also mentioned about this on the cover-letter like below, but it may be difficult
to understand. I'm sorry about lack explanation... I should have explained one sentence
about that...

>> - Add specific-setting by using dbi2 again in the patch 12/15.
>> - Modify commend of the specific-setting in the patch 12/15. Serge suggested
>>   this on v23 but I missed to modify this on v24.

> The previous commit log said host mode didn't work:
> 
>   PCI: dwc: Disable two BARs to avoid unnecessary memory assignment
> 
>   According to the section 3.5.7.2 "RC Mode" in DWC PCIe Dual Mode
>   Rev.5.20a, we should disable two BARs to avoid unnecessary memory
>   assignment during device enumeration. Otherwise, Renesas R-Car Gen4
>   PCIe controllers cannot work correctly in host mode.
> 
> (from https://lore.kernel.org/all/20231011071423.249458-9-yoshihiro.shimoda.uh@renesas.com/)
> 
> I don't think we want to merge the driver unless it actually works.

I understood it.

Best regards,
Yoshihiro Shimoda

> Bjorn
Bjorn Helgaas Oct. 19, 2023, 2:09 p.m. UTC | #3
On Thu, Oct 19, 2023 at 04:08:52AM +0000, Yoshihiro Shimoda wrote:
> > From: Bjorn Helgaas, Sent: Thursday, October 19, 2023 12:11 PM
> > On Wed, Oct 18, 2023 at 05:56:16PM +0900, Yoshihiro Shimoda wrote:
> > > Add R-Car S4-8 (R-Car Gen4) PCIe controller for both host and endpoint modes.
> > > To support them, modify PCIe DesignWare common codes.
> > >
> > > Changes from v24:
> > >
> <snip URL>
> > >  - Based on the latest pci.git / next branch.
> > >  - Reordering the patches. (This is suggested by Bjorn.)
> > >  - Drop "PCI: dwc: Disable two BARs to avoid unnecessary memory assignment"
> > >    because break other platforms.
> > 
> > Does R-Car Gen4 still work without this patch?
> 
> Yes, R-Car Gen4 still work without this patch because I added this code into
> the patch 12/15 again:
> 
> ---
> +static int rcar_gen4_pcie_host_init(struct dw_pcie_rp *pp)
> +{
> ...
> +	/*
> +	 * According to the section 3.5.7.2 "RC Mode" in DWC PCIe Dual Mode
> +	 * Rev.5.20a and 3.5.6.1 "RC mode" in DWC PCIe RC databook v5.20a, we
> +	 * should disable two BARs to avoid unnecessary memory assignment
> +	 * during device enumeration.
> +	 */
> +	dw_pcie_writel_dbi2(dw, PCI_BASE_ADDRESS_0, 0x0);
> +	dw_pcie_writel_dbi2(dw, PCI_BASE_ADDRESS_1, 0x0);

Great, thanks!

Bjorn
Krzysztof WilczyƄski Oct. 20, 2023, 12:18 p.m. UTC | #4
Hello,

> Add R-Car S4-8 (R-Car Gen4) PCIe controller for both host and endpoint modes.
> To support them, modify PCIe DesignWare common codes.
[...]

Applied to controller/rcar, thank you!

[01/15] PCI: Add T_PVPERL macro
        https://git.kernel.org/pci/pci/c/164f66be0c25
[02/15] PCI: dwc: Add dw_pcie_link_set_max_link_width()
        https://git.kernel.org/pci/pci/c/a9a1bcba9025
[03/15] PCI: dwc: Add missing PCI_EXP_LNKCAP_MLW handling
        https://git.kernel.org/pci/pci/c/89db0793c9f2
[04/15] PCI: tegra194: Drop PCI_EXP_LNKSTA_NLW setting
        https://git.kernel.org/pci/pci/c/1a9745476cae
[05/15] PCI: dwc: endpoint: Add multiple PFs support for dbi2
        https://git.kernel.org/pci/pci/c/7873b49b41b9
[06/15] PCI: dwc: Add EDMA_UNROLL capability flag
        https://git.kernel.org/pci/pci/c/1896d17f9168
[07/15] PCI: dwc: Expose dw_pcie_ep_exit() to module
        https://git.kernel.org/pci/pci/c/2066b41a2ef8
[08/15] PCI: dwc: endpoint: Introduce .pre_init() and .deinit()
        https://git.kernel.org/pci/pci/c/52b4edbc304c
[09/15] dt-bindings: PCI: dwc: Update maxItems of reg and reg-names
        https://git.kernel.org/pci/pci/c/7e8fcf83c48a
[10/15] dt-bindings: PCI: renesas: Add R-Car Gen4 PCIe Host
        https://git.kernel.org/pci/pci/c/e8858cc55f62
[11/15] dt-bindings: PCI: renesas: Add R-Car Gen4 PCIe Endpoint
        https://git.kernel.org/pci/pci/c/5df0306d03c9
[12/15] PCI: rcar-gen4: Add R-Car Gen4 PCIe controller support for host mode
        https://git.kernel.org/pci/pci/c/8227bf7a81e6
[13/15] PCI: rcar-gen4: Add endpoint mode support
        https://git.kernel.org/pci/pci/c/d3c54d8ba855
[14/15] MAINTAINERS: Update PCI DRIVER FOR RENESAS R-CAR for R-Car Gen4
        https://git.kernel.org/pci/pci/c/2c1cca77c894
[15/15] misc: pci_endpoint_test: Add Device ID for R-Car S4-8 PCIe controller
        https://git.kernel.org/pci/pci/c/a21169341a16

	Krzysztof