Enhance PCIe cadence controller driver for supporting HPA architecture
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 Enhance PCIe cadence controller driver for supporting HPA architecture
This patch enhances the Cadence PCIe controller driver to support HPA architecture. The Kconfig is added for PCIE_CADENCE_HPA config, which needs to be selected when HPA compatible PCIe controller is supported. The support for Legacy PCIe controller does not change.
--- drivers/pci/controller/cadence/Kconfig | 8 + .../pci/controller/cadence/pcie-cadence-ep.c | 12 +- .../controller/cadence/pcie-cadence-host.c | 44 ++- .../pci/controller/cadence/pcie-cadence-hpa.h | 260 ++++++++++++++++++ .../controller/cadence/pcie-cadence-legacy.h | 243 ++++++++++++++++ drivers/pci/controller/cadence/pcie-cadence.c | 42 ++- drivers/pci/controller/cadence/pcie-cadence.h | 230 +--------------- 7 files changed, 598 insertions(+), 241 deletions(-) create mode 100644 drivers/pci/controller/cadence/pcie-cadence-hpa.h create mode 100644 drivers/pci/controller/cadence/pcie-cadence-legacy.h
drivers/pci/controller/cadence/Kconfig +8 -0
@@ -6,6 +6,14 @@ menu "Cadence-based PCIe controllers" config PCIE_CADENCE bool +config PCIE_CADENCE_HPA + bool "PCIE controller HPA architecture" + help + Say Y here if you want to support Cadence PCIe Platform controller + on HPA architecture + The option should be deselected if the Cadence PCIe controller + is of legacy architecture + config PCIE_CADENCE_HOST bool depends on OF
drivers/pci/controller/cadence/pcie-cadence-ep.c +8 -4
@@ -121,7 +121,11 @@ static int cdns_pcie_ep_set_bar(struct pci_epc *epc, u8 fn, u8 vfn, reg =CDNS_PCIE_LM_EP_VFUNC_BAR_CFG (bar, fn); else reg =CDNS_PCIE_LM_EP_FUNC_BAR_CFG (bar, fn); +#ifdef CONFIG_PCIE_CADENCE_HPA + b = (bar <BAR_3 ) ? bar : bar -BAR_3 ; +#else b = (bar <BAR_4 ) ? bar : bar -BAR_4 ; +#endif if (vfn ==0 || vfn ==1 ) { cfg =cdns_pcie_readl (pcie, reg);
@@ -158,7 +162,11 @@ static void cdns_pcie_ep_clear_bar(struct pci_epc *epc, u8 fn, u8 vfn, reg =CDNS_PCIE_LM_EP_VFUNC_BAR_CFG (bar, fn); else reg =CDNS_PCIE_LM_EP_FUNC_BAR_CFG (bar, fn); +#ifdef CONFIG_PCIE_CADENCE_HPA + b = (bar <BAR_3 ) ? bar : bar -BAR_3 ; +#else b = (bar <BAR_4 ) ? bar : bar -BAR_4 ; +#endif if (vfn ==0 || vfn ==1 ) { ctrl =CDNS_PCIE_LM_BAR_CFG_CTRL_DISABLED ;
@@ -569,7 +577,6 @@ static int cdns_pcie_ep_start(struct pci_epc *epc)* BIT(0) is hardwired to 1, hence function 0 is always enabled * and can't be disabled anyway. */ -cdns_pcie_writel (pcie,CDNS_PCIE_LM_EP_FUNC_CFG , epc->function_num_map);/* * Next function field in ARI_CAP_AND_CTR register for last function
@@ -682,9 +689,6 @@ int cdns_pcie_ep_setup(struct cdns_pcie_ep *ep)if (!ep->ob_addr)return -ENOMEM ; -/* Disable all but function 0 (anyway BIT(0) is hardwired to 1). */ -cdns_pcie_writel (pcie,CDNS_PCIE_LM_EP_FUNC_CFG ,BIT (0 )); - epc =devm_pci_epc_create (dev, &cdns_pcie_epc_ops);if (IS_ERR (epc)) {dev_err (dev,"failed to create epc device\n" );
drivers/pci/controller/cadence/pcie-cadence-host.c +39 -5
96 lines not on this page · raw message
drivers/pci/controller/cadence/pcie-cadence-hpa.h new file +260 -0
260 lines not on this page · raw message
drivers/pci/controller/cadence/pcie-cadence-legacy.h new file +243 -0
243 lines not on this page · raw message
drivers/pci/controller/cadence/pcie-cadence.c +35 -7
104 lines not on this page · raw message
drivers/pci/controller/cadence/pcie-cadence.h +5 -225
247 lines not on this page · raw message
Signature · 1 line
2.27.0
Take a look at the additions of previous drivers and follow the style. For example:
2bdd5238e756 ("PCI: mt7621: Add MediaTek MT7621 PCIe host controller driver") 0e898eb8df4e ("PCI: rockchip-dwc: Add Rockchip RK356X host controller driver") da36024a4e83 ("PCI: visconti: Add Toshiba Visconti PCIe host controller driver") f3e25911a430 ("PCI: j721e: Add TI J721E PCIe driver")
After skimming the patch, it looks like this doesn't actually add a new driver, but adds support to an existing driver for some kind of different surrounding platform architecture.
Quoted 4 lines · Manikandan Karunakaran Pillai
This patch enhances the Cadence PCIe controller driver to support HPA architecture. The
Kconfigis added forPCIE_CADENCE_HPAconfig, which needs to be selected when HPA compatible PCIe controller is supported. The support for Legacy PCIe controller does not change.
Use imperative mood ("Enhance" instead of "This patch enhances ...").
Expand "HPA".
Quoted 7 lines
drivers/pci/controller/cadence/Kconfig | 8 + .../pci/controller/cadence/pcie-cadence-ep.c | 12 +- .../controller/cadence/pcie-cadence-host.c | 44 ++- .../pci/controller/cadence/pcie-cadence-hpa.h | 260 ++++++++++++++++++ .../controller/cadence/pcie-cadence-legacy.h | 243 ++++++++++++++++ drivers/pci/controller/cadence/pcie-cadence.c | 42 ++- drivers/pci/controller/cadence/pcie-cadence.h | 230 +---------------
This looks like it should be 5+ separate patches to make this reviewable. Each patch should do only *one* thing. Obviously everything must build and work correctly after each patch is added.
drivers/pci/controller/cadence/Kconfig menu "Cadence-based PCIe controllers" · line 10
Quoted 7 lines
+++ b/drivers/pci/controller/cadence/Kconfig
drivers/pci/controller/cadence/Kconfig +2
-0@@ -6,6 +6,14 @@ menu "Cadence-based PCIe controllers" config PCIE_CADENCE bool +config PCIE_CADENCE_HPA + bool "PCIE controller HPA architecture"
s/PCIE/PCIe/ to match other entries.
Change the menu item to match surrounding entries (include vendor, host/endpoint, etc).
But I don't think this is a *new* driver; it looks like it might be optional functionality for the PCIE_CADENCE_PLAT and/or PCI_J721E drivers? Maybe it needs to depend on PCIE_CADENCE?
drivers/pci/controller/cadence/Kconfig menu "Cadence-based PCIe controllers" · line 15
Quoted 5 lines
drivers/pci/controller/cadence/Kconfig +5
-0+ help + Say Y here if you want to support Cadence PCIe Platform controller + on HPA architecture + The option should be deselected if the Cadence PCIe controller + is of legacy architecture
"HPA" must be expanded here too.
Omit the "deselect part". A user has no way to identify what "legacy architecture" means here.
drivers/pci/controller/cadence/pcie-cadence-ep.c static int cdns_pcie_ep_set_bar(struct pci_epc *epc, u8 fn, u8 vfn, · line 124
Quoted 6 lines
drivers/pci/controller/cadence/pcie-cadence-ep.c +2
-0+++ b/drivers/pci/controller/cadence/pcie-cadence-ep.c@@ -121,7 +121,11 @@ static int cdns_pcie_ep_set_bar(struct pci_epc *epc, u8 fn, u8 vfn, reg =CDNS_PCIE_LM_EP_VFUNC_BAR_CFG (bar, fn); else reg =CDNS_PCIE_LM_EP_FUNC_BAR_CFG (bar, fn); +#ifdef CONFIG_PCIE_CADENCE_HPA
Nope. I don't want #ifdefs like this littered through the cadence generic code. The driver should be able to support both HPA and non-HPA in the same kernel image. You should be able to decide at run-time, not at build-time.
drivers/pci/controller/cadence/pcie-cadence-ep.c line 3
Quoted 10 lines
drivers/pci/controller/cadence/pcie-cadence-ep.c +7
-0+ b = (bar <BAR_3 ) ? bar : bar -BAR_3 ; +#else b = (bar <BAR_4 ) ? bar : bar -BAR_4 ; +#endif +++ b/drivers/pci/controller/cadence/pcie-cadence-hpa.h@@ -0,0 +1,260 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +// Copyright (c) 2017 Cadence +// Cadence PCIe Gen5(HPA) controller driver defines
Space before "(". Expand HPA.
drivers/pci/controller/cadence/pcie-cadence-hpa.h line 15
Quoted 1 line
drivers/pci/controller/cadence/pcie-cadence-hpa.h new file +1
-0+* This file contains the updates/changes for PCIE Gen5 Controller
s/PCIE/PCIe/ everywhere in commit logs and comments.
drivers/pci/controller/cadence/pcie-cadence-hpa.h line 28
Quoted 3 lines
drivers/pci/controller/cadence/pcie-cadence-hpa.h new file +3
-0+#define CDNS_PCIE_IP_REG_BANK (0x01000000) +#define CDNS_PCIE_IP_CFG_CTRL_REG_BANK (0x01003C00) +#define CDNS_PCIE_IP_AXI_MASTER_COMMON (0x02020000)
No parens needed for bare numbers.
drivers/pci/controller/cadence/pcie-cadence-hpa.h line 33
Quoted 4 lines
drivers/pci/controller/cadence/pcie-cadence-hpa.h new file +4
-0+/* Vendor ID Register */ +#define CDNS_PCIE_LM_ID (CDNS_PCIE_IP_REG_BANK + 0x1420) +#define CDNS_PCIE_LM_ID_VENDOR_MASK GENMASK(15, 0) +#define CDNS_PCIE_LM_ID_VENDOR_SHIFT 0
Omit _SHIFT definitions and use GENMASK()/FIELD_PREP()/FIELD_GET() instead.
But it looks like this is mainly a move from one file to another. A move like that should be strictly a move and shouldn't change the content at the same time.
The move should be in its own patch that does nothing other than the move, so you can ignore some of these comments for now.
drivers/pci/controller/cadence/pcie-cadence-hpa.h line 64
Quoted 1 line
drivers/pci/controller/cadence/pcie-cadence-hpa.h new file +1
-0+#define CDNS_PCIE_LM_EP_FUNC_CFG (CDNS_PCIE_IP_REG_BANK + 0x02c0)
Pick either upper-case or lower-case for hex numbers and stick to it.
drivers/pci/controller/cadence/pcie-cadence-hpa.h line 85
Quoted 5 lines
drivers/pci/controller/cadence/pcie-cadence-hpa.h new file +5
-0+#define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_ENABLE BIT(0) +#define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_IO BIT(1) +#define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_MEM (0) +#define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_32BITS (0) +#define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_PREFETCH_MEM_DISABLE (0)
These are unused. Don't add #defines that are not used.
When you do add them, indent the BIT() parts to they line up.
drivers/pci/controller/cadence/pcie-cadence.c void cdns_pcie_set_outbound_region(struct cdns_pcie *pcie, u8 busnr, u8 fn, · line 63
Quoted 9 lines
drivers/pci/controller/cadence/pcie-cadence.c +4
-0+++ b/drivers/pci/controller/cadence/pcie-cadence.c/* * Whatever Bit [23] is set or not inside DESC0 register of the outbound * PCIe descriptor, the PCI function number must be set into * Bits [26:24] of DESC0 anyway. +* for HPA, Bit [26] is set or not inside CTRL0 register of the outbound +* PCI descriptor, the PCI function num must be set into Bits [31:24] +* of DESC1 anyway.
Start sentences with a capital letter.
Add blank lines between paragraphs.
drivers/pci/controller/cadence/pcie-cadence.h line 17
Quoted 11 lines
drivers/pci/controller/cadence/pcie-cadence.h +0
-5@@ -10,213 +10,11 @@#include <linux/pci.h> #include <linux/pci-epf.h> #include <linux/phy/phy.h> - -/* Parameters for the waiting for link up routine */ -#define LINK_WAIT_MAX_RETRIES 10 -#define LINK_WAIT_USLEEP_MIN 90000 -#define LINK_WAIT_USLEEP_MAX 100000
This looks like a move of a lot of things out of pcie-cadence.h to somewhere else. A move like this should be its own patch with its own commit log.
It looks suspect because this is a generic header used by several drivers.
Bjorn
Quoted 18 lines
[PATCH] Enhance PCIe cadence controller driver for supporting HPA architecture
EXTERNAL MAIL
Take a look at the additions of previous drivers and follow the style. For example:
2bdd5238e756("PCI: mt7621: Add MediaTek MT7621 PCIe host controller
driver")
0e898eb8df4e("PCI: rockchip-dwc: Add Rockchip RK356X host controller
driver")
da36024a4e83("PCI: visconti: Add Toshiba Visconti PCIe host controller
driver")
f3e25911a430("PCI: j721e: Add TI J721E PCIe driver")
Quoted 4 lines
After skimming the patch, it looks like this doesn't actually add a new driver, but adds support to an existing driver for some kind of different surrounding platform architecture.
The patch adds support for Cadence second generation PCIe controllers, referred as High performance Architecture(HPA).
Quoted 20 lines
Quoted 4 lines · Manikandan Karunakaran Pillai
This patch enhances the Cadence PCIe controller driver to support HPA architecture. The
Kconfigis added forPCIE_CADENCE_HPAconfig, which needs to be selected when HPA compatible PCIe controller is supported. The support for Legacy PCIe controller does not change.Use imperative mood ("Enhance" instead of "This patch enhances ...").
Expand "HPA".
Quoted 8 lines
drivers/pci/controller/cadence/Kconfig | 8 + .../pci/controller/cadence/pcie-cadence-ep.c | 12 +- .../controller/cadence/pcie-cadence-host.c | 44 ++- .../pci/controller/cadence/pcie-cadence-hpa.h | 260++++++++++++++++++
.../controller/cadence/pcie-cadence-legacy.h| 243 ++++++++++++++++drivers/pci/controller/cadence/pcie-cadence.c| 42 ++-drivers/pci/controller/cadence/pcie-cadence.h| 230
+---------------
Quoted 3 lines
This looks like it should be 5+ separate patches to make this reviewable. Each patch should do only *one* thing. Obviously everything must build and work correctly after each patch is added.
Will break into smaller patches and send them
Quoted 32 lines
drivers/pci/controller/cadence/Kconfig menu "Cadence-based PCIe controllers" · line 10
Quoted 8 lines
+++ b/drivers/pci/controller/cadence/Kconfig
drivers/pci/controller/cadence/Kconfig +2
-0@@ -6,6 +6,14 @@ menu "Cadence-based PCIe controllers" config PCIE_CADENCE bool +config PCIE_CADENCE_HPA + bool "PCIE controller HPA architecture"s/PCIE/PCIe/ to match other entries.
Change the menu item to match surrounding entries (include vendor, host/endpoint, etc).
But I don't think this is a *new* driver; it looks like it might be optional functionality for the
PCIE_CADENCE_PLATand/orPCI_J721Edrivers? Maybe it needs to depend onPCIE_CADENCE?drivers/pci/controller/cadence/Kconfig menu "Cadence-based PCIe controllers" · line 15
Quoted 5 lines
drivers/pci/controller/cadence/Kconfig +5
-0+ help + Say Y here if you want to support Cadence PCIe Platform controller + on HPA architecture + The option should be deselected if the Cadence PCIe controller + is of legacy architecture"HPA" must be expanded here too.
Omit the "deselect part". A user has no way to identify what "legacy architecture" means here.
Review static int cdns_pcie_ep_set_bar(struct pci_epc *epc,
Quoted 2 lines
(quoted diff) +1
-0+++ b/drivers/pci/controller/cadence/pcie-cadence-ep.c@@ -121,7 +121,11 @@ static int cdns_pcie_ep_set_bar(struct pci_epc *epc,u8 fn, u8 vfn,
Quoted 8 lines
drivers/pci/controller/cadence/pcie-cadence-ep.c static int cdns_pcie_ep_set_bar(struct pci_epc *epc, u8 fn, u8 vfn, · line 124
Quoted 4 lines
drivers/pci/controller/cadence/pcie-cadence-ep.c +1
-0reg =CDNS_PCIE_LM_EP_VFUNC_BAR_CFG (bar, fn); else reg =CDNS_PCIE_LM_EP_FUNC_BAR_CFG (bar, fn); +#ifdef CONFIG_PCIE_CADENCE_HPA Nope. I don't want #ifdefs like this littered through the cadence generic code. The driver should be able to support both HPA and non-HPA in the same kernel image. You should be able to decide at run-time, not at build-time.
Cadence PCIe controller does not have a version register that could be used to check the architecture, however one of the PCIe config space registers provides different reset values for the different architectures. This register will be used to support the HPA and non-HPA in the same kernel image.
Quoted 84 lines
drivers/pci/controller/cadence/pcie-cadence-ep.c line 2
Quoted 9 lines
drivers/pci/controller/cadence/pcie-cadence-ep.c +5
-0+ b = (bar <BAR_3 ) ? bar : bar -BAR_3 ;#else b = (bar <BAR_4 ) ? bar : bar -BAR_4 ; +#endif +++ b/drivers/pci/controller/cadence/pcie-cadence-hpa.h@@ -0,0 +1,260 @@ +/* SPDX-License-Identifier: GPL-2.0 */ // Copyright (c) 2017 Cadence +// Cadence PCIe Gen5(HPA) controller driver defines Space before "(". Expand HPA.
drivers/pci/controller/cadence/pcie-cadence-hpa.h line 15
Quoted 1 line
drivers/pci/controller/cadence/pcie-cadence-hpa.h new file +1
-0+* This file contains the updates/changes for PCIE Gen5 Controller s/PCIE/PCIe/ everywhere in commit logs and comments.
Review line 6
Quoted 3 lines
(quoted diff) +3
-0+#define CDNS_PCIE_IP_REG_BANK (0x01000000) +#define CDNS_PCIE_IP_CFG_CTRL_REG_BANK (0x01003C00) #define +CDNS_PCIE_IP_AXI_MASTER_COMMON (0x02020000)No parens needed for bare numbers.
Review line 8
Quoted 2 lines
(quoted diff) +2
-0+/* Vendor ID Register */ +#define CDNS_PCIE_LM_ID (CDNS_PCIE_IP_REG_BANK +
0x1420)Review line 10
Quoted 2 lines
(quoted diff) +2
-0+#define CDNS_PCIE_LM_ID_VENDOR_MASK GENMASK(15, 0) +#define CDNS_PCIE_LM_ID_VENDOR_SHIFT 0Omit
_SHIFTdefinitions and use GENMASK()/FIELD_PREP()/FIELD_GET() instead.But it looks like this is mainly a move from one file to another. A move like that should be strictly a move and shouldn't change the content at the same time.
The move should be in its own patch that does nothing other than the move, so you can ignore some of these comments for now.
Review line 11
Quoted 1 line
(quoted diff) +1
-0+#define CDNS_PCIE_LM_EP_FUNC_CFG (CDNS_PCIE_IP_REG_BANK +
0x02c0)Pick either upper-case or lower-case for hex numbers and stick to it.
Review line 16
Quoted 5 lines
(quoted diff) +5
-0+#define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_ENABLE BIT(0) #define +CDNS_PCIE_LM_RC_BAR_CFG_BAR0_IO BIT(1) #define +CDNS_PCIE_LM_RC_BAR_CFG_BAR0_MEM (0) #define +CDNS_PCIE_LM_RC_BAR_CFG_BAR0_32BITS (0) #define +CDNS_PCIE_LM_RC_BAR_CFG_BAR0_PREFETCH_MEM_DISABLE (0)These are unused. Don't add #defines that are not used.
When you do add them, indent the
BIT()parts to they line up.drivers/pci/controller/cadence/pcie-cadence.c void cdns_pcie_set_outbound_region(struct cdns_pcie *pcie, u8 busnr, u8 fn, · line 63
Quoted 9 lines
drivers/pci/controller/cadence/pcie-cadence.c +4
-0+++ b/drivers/pci/controller/cadence/pcie-cadence.c/* * Whatever Bit [23] is set or not inside DESC0 register of the outbound * PCIe descriptor, the PCI function number must be set into * Bits [26:24] of DESC0 anyway. +* for HPA, Bit [26] is set or not inside CTRL0 register of the outbound +* PCI descriptor, the PCI function num must be set into Bits [31:24] +* of DESC1 anyway. Start sentences with a capital letter.
Add blank lines between paragraphs.
drivers/pci/controller/cadence/pcie-cadence.h line 17
Quoted 11 lines
drivers/pci/controller/cadence/pcie-cadence.h +0
-5@@ -10,213 +10,11 @@#include <linux/pci.h> #include <linux/pci-epf.h> #include <linux/phy/phy.h> - -/* Parameters for the waiting for link up routine */ -#define LINK_WAIT_MAX_RETRIES 10 -#define LINK_WAIT_USLEEP_MIN 90000 -#define LINK_WAIT_USLEEP_MAX 100000This looks like a move of a lot of things out of
pcie-cadence.hto somewhere else. A move like this should be its own patch with its own commit log.It looks suspect because this is a generic header used by several drivers.
Bjorn