PCI: cadence: Retrain Link to work around Gen2
Subsystems (4)
v8 cover PCI: cadence: Retrain Link to work around Gen2
Cadence controller will not initiate autonomous speed change if strapped as Gen2. The Retrain Link bit is set as quirk to enable this speed change. Adding a quirk flag for defective IP. In future IP revisions this will not be applicable.
Version history:
Changes in v8:
- Adding a new function cdns_pcie_host_start_link(). Changes in v7:
- Changing the commit title of patch 1 in this series.
- Added a return value for function cdns_pcie_retrain(). Changes in v6:
- Move the position of function cdns_pcie_host_wait_for_link to remove compilation error. No changes in code. Separate patch for this.
Changes in v5:
- Remove the compatible string based setting of quirk flag.
- Removed additional Link Up Check
- Removed quirk from pcie-cadence-plat.c and added in pci-j721e.c Changes in v4:
- Added a quirk flag based on a new compatible string.
- Change of api for link up: cdns_pcie_host_wait_for_link(). Changes in v3:
- To set retrain link bit,checking device capability & link status.
- 32bit read in place of 8bit.
- Minor correction in patch comment.
- Change in variable & macro name.
Changes in v2:
- 16bit read in place of 8bit.
Nadeem Athani (2):
PCI: cadence: Shifting of a function to support new code.
PCI: cadence: Retrain Link to work around Gen2 training defect.
drivers/pci/controller/cadence/pci-j721e.c | 3 + drivers/pci/controller/cadence/pcie-cadence-host.c | 81 +++++++++++++++++----- drivers/pci/controller/cadence/pcie-cadence.h | 11 ++- 3 files changed, 76 insertions(+), 19 deletions(-)
Signature · 1 line
2.15.0
PATCH v8 1/2 PCI: cadence: Shifting of a function to support new code.
Moving the function cdns_pcie_host_wait_for_link() further up in the file, as it's going to be used by upcoming additional code in the driver.
--- drivers/pci/controller/cadence/pcie-cadence-host.c | 33 +++++++++++----------- 1 file changed, 16 insertions(+), 17 deletions(-)
drivers/pci/controller/cadence/pcie-cadence-host.c +16 -17
@@ -77,6 +77,22 @@ static struct pci_ops cdns_pcie_host_ops = { .write = pci_generic_config_write, }; +static int cdns_pcie_host_wait_for_link (struct cdns_pcie *pcie) +{ +struct device *dev = pcie->dev; +int retries; + +/* Check if the link is up or not */ +for (retries =0 ; retries <LINK_WAIT_MAX_RETRIES ; retries++) { +if (cdns_pcie_link_up (pcie)) { +dev_info (dev,"Link up\n" ); +return 0 ; + } +usleep_range (LINK_WAIT_USLEEP_MIN ,LINK_WAIT_USLEEP_MAX ); + } + +return -ETIMEDOUT ; +}static int cdns_pcie_host_init_root_port (struct cdns_pcie_rc *rc) {
@@ -398,23 +414,6 @@ static int cdns_pcie_host_init(struct device *dev,return cdns_pcie_host_init_address_translation (rc); } -static int cdns_pcie_host_wait_for_link (struct cdns_pcie *pcie) -{ -struct device *dev = pcie->dev; -int retries; - -/* Check if the link is up or not */ -for (retries =0 ; retries <LINK_WAIT_MAX_RETRIES ; retries++) { -if (cdns_pcie_link_up (pcie)) { -dev_info (dev,"Link up\n" ); -return 0 ; - } -usleep_range (LINK_WAIT_USLEEP_MIN ,LINK_WAIT_USLEEP_MAX ); - } - -return -ETIMEDOUT ; -} -int cdns_pcie_host_setup (struct cdns_pcie_rc *rc) {struct device *dev = rc->pcie.dev;
Signature · 1 line
2.15.0
PATCH v8 2/2 PCI: cadence: Retrain Link to work around Gen2 training defect.
In reply to Nadeem AthaniCadence controller will not initiate autonomous speed change if strapped as Gen2. The Retrain Link bit is set as quirk to enable this speed change.
--- drivers/pci/controller/cadence/pci-j721e.c | 3 ++ drivers/pci/controller/cadence/pcie-cadence-host.c | 48 +++++++++++++++++++++- drivers/pci/controller/cadence/pcie-cadence.h | 11 ++++- 3 files changed, 60 insertions(+), 2 deletions(-)
drivers/pci/controller/cadence/pci-j721e.c +3 -0
@@ -64,6 +64,7 @@ enum j721e_pcie_mode {struct j721e_pcie_data {enum j721e_pcie_mode mode; +bool quirk_retrain_flag; };static inline u32 j721e_pcie_user_readl (struct j721e_pcie *pcie,u32 offset)
@@ -280,6 +281,7 @@ static struct pci_ops cdns_ti_pcie_host_ops = {static const struct j721e_pcie_data j721e_pcie_rc_data = { .mode =PCI_MODE_RC , + .quirk_retrain_flag = true, };static const struct j721e_pcie_data j721e_pcie_ep_data = {
@@ -388,6 +390,7 @@ static int j721e_pcie_probe(struct platform_device *pdev) bridge->ops = &cdns_ti_pcie_host_ops; rc =pci_host_bridge_priv (bridge); + rc->quirk_retrain_flag = data->quirk_retrain_flag; cdns_pcie = &rc->pcie; cdns_pcie->dev = dev;
drivers/pci/controller/cadence/pcie-cadence-host.c +47 -1
60 lines not on this page · raw message
drivers/pci/controller/cadence/pcie-cadence.h +10 -1
@@ -119,7 +119,7 @@* Root Port Registers (PCI configuration space for the root port function) */ #define CDNS_PCIE_RP_BASE 0x00200000 - +#define CDNS_PCIE_RP_CAP_OFFSET 0xc0/* * Address Translation Registers
@@ -291,6 +291,7 @@ struct cdns_pcie {* @device_id: PCI device ID * @avail_ib_bar: Satus of RP_BAR0, RP_BAR1 and RP_NO_BAR if it's free or * available +* @quirk_retrain_flag: Retrain link as quirk for PCIe Gen2 */ struct cdns_pcie_rc {struct cdns_pcie pcie;
@@ -299,6 +300,7 @@ struct cdns_pcie_rc {u32 vendor_id;u32 device_id;bool avail_ib_bar[CDNS_PCIE_RP_MAX_IB ]; +bool quirk_retrain_flag; };/**
@@ -414,6 +416,13 @@ static inline void cdns_pcie_rp_writew(struct cdns_pcie *pcie,cdns_pcie_write_sz (addr,0x2 , value); } +static inline u16 cdns_pcie_rp_readw (struct cdns_pcie *pcie,u32 reg) +{ +void __iomem *addr = pcie->reg_base +CDNS_PCIE_RP_BASE + reg; + +return cdns_pcie_read_sz (addr,0x2 ); +} +/* Endpoint Function register access */ static inline void cdns_pcie_ep_fn_writeb (struct cdns_pcie *pcie,u8 fn,u32 reg,u8 value)
Signature · 1 line
2.15.0
Lorenzo Pieralisi
AppliedQuoted 29 lines · Nadeem Athani
Cadence controller will not initiate autonomous speed change if strapped as Gen2. The Retrain Link bit is set as quirk to enable this speed change. Adding a quirk flag for defective IP. In future IP revisions this will not be applicable.
Version history:
Changes in v8:
- Adding a new functioncdns_pcie_host_start_link(). Changes in v7:
- Changing the commit title of patch 1 in this series.
- Added a return value for functioncdns_pcie_retrain(). Changes in v6:
- Move the position of functioncdns_pcie_host_wait_for_linkto remove compilation error. No changes in code. Separate patch for this.
Changes in v5:
- Remove the compatible string based setting of quirk flag.
- Removed additional Link Up Check
- Removed quirk frompcie-cadence-plat.cand added inpci-j721e.cChanges in v4:
- Added a quirk flag based on a new compatible string.
- Change of api for link up:cdns_pcie_host_wait_for_link(). Changes in v3:
- To set retrain link bit,checking device capability & link status.
- 32bit read in place of 8bit.
- Minor correction in patch comment.
- Change in variable & macro name.
Changes in v2:
- 16bit read in place of 8bit.
Quoted 1 line
[...]
Applied to pci/cadence, squashed two commits together since it makes no sense to keep them separate. Also, please check:
git log --oneline
when writing patches to keep the changes uniform, I had to edit your commit.
Thanks,
Lorenzo