Add support to configure DWC for ECRC
Subsystems (4)
v3 cover Add support to configure DWC for ECRC
This series has two patches.
Patch-1: Adds a public API to query if the system has ECRC policty turned on.
Patch-2: DesignWare core PCIe IP has a TLP Digest (TD) override bit in one of its control registers of ATU. This bit needs to be programmed for proper ECRC functionality. This is currently identified as an issue with DesignWare IP version 4.90a. DWC code queries the PCIe sub-system through the API added in Patch-1 to find out if ECRC is turned on or not and configures ATU accordingly.
V3:
* Addressed Ethan Zhao's comments for patch-1
V2:
* Addressed Jingoo's review comments
Vidya Sagar (2):
PCI/AER: Add pcie_is_ecrc_enabled() API
PCI: dwc: Add support to configure for ECRC
drivers/pci/controller/dwc/pcie-designware.c | 8 ++++++-- drivers/pci/controller/dwc/pcie-designware.h | 1 + drivers/pci/pci.h | 2 ++ drivers/pci/pcie/aer.c | 11 +++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-)
Signature · 1 line
2.17.1
PATCH v3 1/2 PCI/AER: Add pcie_is_ecrc_enabled() API
Adds pcie_is_ecrc_enabled() API to let other sub-systems (like DesignWare) to query if ECRC policy is enabled and perform any configuration required in those respective sub-systems.
---
V3:
* Address Ethan Zhao's comments
* Added 'Reviewed-by: Jingoo Han <[email protected]>'
V2:
* None from V1
drivers/pci/pci.h | 2 ++ drivers/pci/pcie/aer.c | 11 +++++++++++ 2 files changed, 13 insertions(+)
drivers/pci/pci.h +2 -0
@@ -575,9 +575,11 @@ static inline void pcie_aspm_powersave_config_link(struct pci_dev *pdev) { }#ifdef CONFIG_PCIE_ECRC void pcie_set_ecrc_checking (struct pci_dev *dev);void pcie_ecrc_get_policy (char *str); +bool pcie_is_ecrc_enabled (void );#else static inline void pcie_set_ecrc_checking (struct pci_dev *dev) { }static inline void pcie_ecrc_get_policy (char *str) { } +static inline bool pcie_is_ecrc_enabled (void ) {return false; }#endif #ifdef CONFIG_PCIE_PTM
drivers/pci/pcie/aer.c +11 -0
@@ -207,6 +207,17 @@ void pcie_ecrc_get_policy(char *str) ecrc_policy = i; } + +/** +* pcie_is_ecrc_enabled - returns if ECRC is enabled in the system or not +* +* Returns true if ECRC policy is enabled and false otherwise +*/ +bool pcie_is_ecrc_enabled (void ) +{ +return ecrc_policy ==ECRC_POLICY_ON ; +} +EXPORT_SYMBOL (pcie_is_ecrc_enabled);#endif /* CONFIG_PCIE_ECRC */ #define PCI_EXP_AER_FLAGS (PCI_EXP_DEVCTL_CERE | PCI_EXP_DEVCTL_NFERE | \
Signature · 1 line
2.17.1
PATCH v3 2/2 PCI: dwc: Add support to configure for ECRC
In reply to Vidya SagarDesignWare core has a TLP digest (TD) override bit in one of the control registers of ATU. This bit also needs to be programmed for proper ECRC functionality. This is currently identified as an issue with DesignWare IP version 4.90a. This patch does the required programming in ATU upon querying the system policy for ECRC.
---
V3:
* Added 'Reviewed-by: Jingoo Han <[email protected]>'
V2:
* Addressed Jingoo's review comment
* Removed saving 'td' bit information in 'dw_pcie' structure
drivers/pci/controller/dwc/pcie-designware.c | 8 ++++++-- drivers/pci/controller/dwc/pcie-designware.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pcie-designware.c +6 -2
@@ -246,6 +246,8 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, u8 func_no,dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_UPPER_TARGET ,upper_32_bits (pci_addr)); val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A ) + val = val |pcie_is_ecrc_enabled () <<PCIE_ATU_TD_SHIFT ; val =upper_32_bits (size -1 ) ? val |PCIE_ATU_INCREASE_REGION_SIZE : val;dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_REGION_CTRL1 , val);
@@ -294,8 +296,10 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, lower_32_bits(pci_addr));dw_pcie_writel_dbi (pci,PCIE_ATU_UPPER_TARGET ,upper_32_bits (pci_addr)); -dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , type | -PCIE_ATU_FUNC_NUM (func_no)); + val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A ) + val = val |pcie_is_ecrc_enabled () <<PCIE_ATU_TD_SHIFT ; +dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , val);dw_pcie_writel_dbi (pci,PCIE_ATU_CR2 ,PCIE_ATU_ENABLE );/*
drivers/pci/controller/dwc/pcie-designware.h +1 -0
@@ -89,6 +89,7 @@#define PCIE_ATU_TYPE_IO 0x2#define PCIE_ATU_TYPE_CFG0 0x4#define PCIE_ATU_TYPE_CFG1 0x5 +#define PCIE_ATU_TD_SHIFT 8#define PCIE_ATU_FUNC_NUM (pf) ((pf) << 20)#define PCIE_ATU_CR2 0x908#define PCIE_ATU_ENABLE BIT(31)
Signature · 1 line
2.17.1
Re: [PATCH V3 2/2] PCI: dwc: Add support to configure for ECRC
Quoted 9 lines · Vidya Sagar
DesignWare core has a TLP digest (TD) override bit in one of the control registers of ATU. This bit also needs to be programmed for proper ECRC functionality. This is currently identified as an issue with DesignWare IP version 4.90a. This patch does the required programming in ATU upon querying the system policy for ECRC.
Signed-off-by Vidya Sagar <[email protected]>Reviewed-by Jingoo Han <[email protected]>
No, it should be Acked-by. I gave you Acked-by, not Reviewed-by.
Best regards,
Jingoo Han
Quoted 11 lines
---
V3:
* Added 'Reviewed-by: Jingoo Han <[email protected]>'V2:
* Addressed Jingoo's review comment
* Removed saving 'td' bit information in 'dw_pcie' structuredrivers/pci/controller/dwc/pcie-designware.c | 8 ++++++-- drivers/pci/controller/dwc/pcie-designware.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)
[...]
Re: [PATCH V3 2/2] PCI: dwc: Add support to configure for ECRC
Quoted 11 lines · Jingoo Han
External email: Use caution opening links or attachments
Quoted 7 lines · Vidya Sagar
DesignWare core has a TLP digest (TD) override bit in one of the control registers of ATU. This bit also needs to be programmed for proper ECRC functionality. This is currently identified as an issue with DesignWare IP version 4.90a. This patch does the required programming in ATU upon querying the system policy for ECRC.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Vidya Sagar <[email protected]>Reviewed-by Jingoo Han <[email protected]>No, it should be Acked-by. I gave you Acked-by, not Reviewed-by.
Acked-by Jingoo Han <[email protected]>
Apologies. My bad. I saw the 'Reviewed-by' of the other patch (i.e. PCI/AER: Add pcie_is_ecrc_enabled() API) and put that for this patch as well. I'll update.
Quoted 19 lines
Best regards,
Jingoo HanQuoted 11 lines
---
V3:
* Added 'Reviewed-by: Jingoo Han <[email protected]>'V2:
* Addressed Jingoo's review comment
* Removed saving 'td' bit information in 'dw_pcie' structuredrivers/pci/controller/dwc/pcie-designware.c | 8 ++++++-- drivers/pci/controller/dwc/pcie-designware.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)[...]
Rob Herring
reviewerRe: [PATCH V3 2/2] PCI: dwc: Add support to configure for ECRC
In reply to Vidya SagarQuoted 35 lines · Vidya Sagar
DesignWare core has a TLP digest (TD) override bit in one of the control registers of ATU. This bit also needs to be programmed for proper ECRC functionality. This is currently identified as an issue with DesignWare IP version 4.90a. This patch does the required programming in ATU upon querying the system policy for ECRC.
Signed-off-by Vidya Sagar <[email protected]>Reviewed-by Jingoo Han <[email protected]>---
V3:
* Added 'Reviewed-by: Jingoo Han <[email protected]>'V2:
* Addressed Jingoo's review comment
* Removed saving 'td' bit information in 'dw_pcie' structuredrivers/pci/controller/dwc/pcie-designware.c | 8 ++++++-- drivers/pci/controller/dwc/pcie-designware.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)drivers/pci/controller/dwc/pcie-designware.c +2
-0@@ -246,6 +246,8 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, u8 func_no,dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_UPPER_TARGET ,upper_32_bits (pci_addr)); val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A ) + val = val |pcie_is_ecrc_enabled () <<PCIE_ATU_TD_SHIFT ; val =upper_32_bits (size -1 ) ? val |PCIE_ATU_INCREASE_REGION_SIZE : val;dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_REGION_CTRL1 , val);
drivers/pci/controller/dwc/pcie-designware.c static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, · line 300
Quoted 7 lines
drivers/pci/controller/dwc/pcie-designware.c +2
-2@@ -294,8 +296,10 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, lower_32_bits(pci_addr));dw_pcie_writel_dbi (pci,PCIE_ATU_UPPER_TARGET ,upper_32_bits (pci_addr)); -dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , type | -PCIE_ATU_FUNC_NUM (func_no)); + val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A )
Is this even possible? Are the non-unroll ATU registers available post 4.80?
Rob
Re: [PATCH V3 2/2] PCI: dwc: Add support to configure for ECRC
Quoted 40 lines · Rob Herring
External email: Use caution opening links or attachments
Quoted 36 lines · Vidya Sagar
DesignWare core has a TLP digest (TD) override bit in one of the control registers of ATU. This bit also needs to be programmed for proper ECRC functionality. This is currently identified as an issue with DesignWare IP version 4.90a. This patch does the required programming in ATU upon querying the system policy for ECRC.
Signed-off-by Vidya Sagar <[email protected]>Reviewed-by Jingoo Han <[email protected]>---
V3:
* Added 'Reviewed-by: Jingoo Han <[email protected]>'V2:
* Addressed Jingoo's review comment
* Removed saving 'td' bit information in 'dw_pcie' structuredrivers/pci/controller/dwc/pcie-designware.c | 8 ++++++-- drivers/pci/controller/dwc/pcie-designware.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)drivers/pci/controller/dwc/pcie-designware.c +2
-0@@ -246,6 +246,8 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, u8 func_no,dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_UPPER_TARGET ,upper_32_bits (pci_addr)); val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A ) + val = val |pcie_is_ecrc_enabled () <<PCIE_ATU_TD_SHIFT ; val =upper_32_bits (size -1 ) ? val |PCIE_ATU_INCREASE_REGION_SIZE : val;dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_REGION_CTRL1 , val);@@ -294,8 +296,10 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, lower_32_bits(pci_addr));
Quoted 8 lines
drivers/pci/controller/dwc/pcie-designware.c static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, · line 300
Quoted 6 lines
drivers/pci/controller/dwc/pcie-designware.c +2
-2dw_pcie_writel_dbi (pci,PCIE_ATU_UPPER_TARGET ,upper_32_bits (pci_addr)); -dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , type | -PCIE_ATU_FUNC_NUM (func_no)); + val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A )Is this even possible? Are the non-unroll ATU registers available post 4.80?
I'm not sure. Gustavo might have information about this. I made this change so that it is taken care off even if they available.
Quoted 3 lines
Rob
RE: [PATCH V3 2/2] PCI: dwc: Add support to configure for ECRC
Quoted 51 lines · Vidya Sagar
Quoted 40 lines · Rob Herring
External email: Use caution opening links or attachments
Quoted 36 lines · Vidya Sagar
DesignWare core has a TLP digest (TD) override bit in one of the control registers of ATU. This bit also needs to be programmed for proper ECRC functionality. This is currently identified as an issue with DesignWare IP version 4.90a. This patch does the required programming in ATU upon querying the system policy for ECRC.
Signed-off-by Vidya Sagar <[email protected]>Reviewed-by Jingoo Han <[email protected]>---
V3:
* Added 'Reviewed-by: Jingoo Han <[email protected]>'V2:
* Addressed Jingoo's review comment
* Removed saving 'td' bit information in 'dw_pcie' structuredrivers/pci/controller/dwc/pcie-designware.c | 8 ++++++-- drivers/pci/controller/dwc/pcie-designware.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)drivers/pci/controller/dwc/pcie-designware.c +2
-0@@ -246,6 +246,8 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, u8 func_no,dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_UPPER_TARGET ,upper_32_bits (pci_addr)); val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A ) + val = val |pcie_is_ecrc_enabled () <<PCIE_ATU_TD_SHIFT ; val =upper_32_bits (size -1 ) ? val |PCIE_ATU_INCREASE_REGION_SIZE : val;dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_REGION_CTRL1 , val);@@ -294,8 +296,10 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, lower_32_bits(pci_addr));Quoted 8 lines
drivers/pci/controller/dwc/pcie-designware.c static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, · line 300
Quoted 6 lines
drivers/pci/controller/dwc/pcie-designware.c +2
-2dw_pcie_writel_dbi (pci,PCIE_ATU_UPPER_TARGET ,upper_32_bits (pci_addr)); -dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , type | -PCIE_ATU_FUNC_NUM (func_no)); + val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A )Is this even possible? Are the non-unroll ATU registers available post 4.80?
Quoted 2 lines
I'm not sure. Gustavo might have information about this. I made this change so that it is taken care off even if they available.
The Synopsys DesignWare PCIe IP is highly configurable, therefore is dependable on what the design team has configured for their solution. Although Synopsys doesn't recommend the use of non-unroll ATU, the customers are free to select what they want for their design.
-Gustavo
Quoted 4 lines
Quoted 4 lines
Rob
Rob Herring
reviewerRe: [PATCH V3 2/2] PCI: dwc: Add support to configure for ECRC
Quoted 54 lines · Gustavo Pimentel
Quoted 51 lines · Vidya Sagar
Quoted 48 lines · Rob Herring
External email: Use caution opening links or attachments
Quoted 35 lines · Vidya Sagar
DesignWare core has a TLP digest (TD) override bit in one of the control registers of ATU. This bit also needs to be programmed for proper ECRC functionality. This is currently identified as an issue with DesignWare IP version 4.90a. This patch does the required programming in ATU upon querying the system policy for ECRC.
Signed-off-by Vidya Sagar <[email protected]>Reviewed-by Jingoo Han <[email protected]>---
V3:
* Added 'Reviewed-by: Jingoo Han <[email protected]>'V2:
* Addressed Jingoo's review comment
* Removed saving 'td' bit information in 'dw_pcie' structuredrivers/pci/controller/dwc/pcie-designware.c | 8 ++++++-- drivers/pci/controller/dwc/pcie-designware.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)drivers/pci/controller/dwc/pcie-designware.c +2
-0@@ -246,6 +246,8 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, u8 func_no,dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_UPPER_TARGET ,upper_32_bits (pci_addr)); val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A ) + val = val |pcie_is_ecrc_enabled () <<PCIE_ATU_TD_SHIFT ; val =upper_32_bits (size -1 ) ? val |PCIE_ATU_INCREASE_REGION_SIZE : val;dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_REGION_CTRL1 , val);drivers/pci/controller/dwc/pcie-designware.c static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, · line 300
Quoted 7 lines
drivers/pci/controller/dwc/pcie-designware.c +2
-2@@ -294,8 +296,10 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, lower_32_bits(pci_addr));dw_pcie_writel_dbi (pci,PCIE_ATU_UPPER_TARGET ,upper_32_bits (pci_addr)); -dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , type | -PCIE_ATU_FUNC_NUM (func_no)); + val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A )Is this even possible? Are the non-unroll ATU registers available post 4.80?
Quoted 7 lines
Quoted 2 lines
I'm not sure. Gustavo might have information about this. I made this change so that it is taken care off even if they available.
The Synopsys DesignWare PCIe IP is highly configurable, therefore is dependable on what the design team has configured for their solution. Although Synopsys doesn't recommend the use of non-unroll ATU, the customers are free to select what they want for their design.
Okay, then there's a bug in the driver if the version is set to 0x480A or later and non-unroll is used:
if (pci->version >= 0x480A || (!pci->version &&
dw_pcie_iatu_unroll_enabled(pci))) {Probably can just drop the version checking. The detection should always work.
Rob
RE: [PATCH V3 2/2] PCI: dwc: Add support to configure for ECRC
Quoted 64 lines · Rob Herring
Quoted 54 lines · Gustavo Pimentel
Quoted 51 lines · Vidya Sagar
Quoted 48 lines · Rob Herring
External email: Use caution opening links or attachments
Quoted 35 lines · Vidya Sagar
DesignWare core has a TLP digest (TD) override bit in one of the control registers of ATU. This bit also needs to be programmed for proper ECRC functionality. This is currently identified as an issue with DesignWare IP version 4.90a. This patch does the required programming in ATU upon querying the system policy for ECRC.
Signed-off-by Vidya Sagar <[email protected]>Reviewed-by Jingoo Han <[email protected]>---
V3:
* Added 'Reviewed-by: Jingoo Han <[email protected]>'V2:
* Addressed Jingoo's review comment
* Removed saving 'td' bit information in 'dw_pcie' structuredrivers/pci/controller/dwc/pcie-designware.c | 8 ++++++-- drivers/pci/controller/dwc/pcie-designware.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)drivers/pci/controller/dwc/pcie-designware.c +2
-0@@ -246,6 +246,8 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, u8 func_no,dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_UPPER_TARGET ,upper_32_bits (pci_addr)); val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A ) + val = val |pcie_is_ecrc_enabled () <<PCIE_ATU_TD_SHIFT ; val =upper_32_bits (size -1 ) ? val |PCIE_ATU_INCREASE_REGION_SIZE : val;dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_REGION_CTRL1 , val);drivers/pci/controller/dwc/pcie-designware.c static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, · line 300
Quoted 7 lines
drivers/pci/controller/dwc/pcie-designware.c +2
-2@@ -294,8 +296,10 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, lower_32_bits(pci_addr));dw_pcie_writel_dbi (pci,PCIE_ATU_UPPER_TARGET ,upper_32_bits (pci_addr)); -dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , type | -PCIE_ATU_FUNC_NUM (func_no)); + val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A )Is this even possible? Are the non-unroll ATU registers available post 4.80?
Quoted 7 lines
Quoted 2 lines
I'm not sure. Gustavo might have information about this. I made this change so that it is taken care off even if they available.
The Synopsys DesignWare PCIe IP is highly configurable, therefore is dependable on what the design team has configured for their solution. Although Synopsys doesn't recommend the use of non-unroll ATU, the customers are free to select what they want for their design.
Quoted 7 lines
Okay, then there's a bug in the driver if the version is set to
0x480Aor later and non-unroll is used:if (
pci->version>=0x480A|| (!pci->version &&dw_pcie_iatu_unroll_enabled(pci))) {Probably can just drop the version checking. The detection should always work.
Hi Rob,
The "detection" is based on the assumption that the read value on PCIE_ATU_VIEWPORT register is 0xffffffff (which is a hard-coded value by design), if it's true then the iATU is unrolled and the function returns 1, otherwise is non-unrolled returns 0. So like you said it should always work, however, this code behavior was changed by Kishon on the following patch 2aadcb0cd39 ("PCI: dwc: Fix ATU identification for designware version >= 4.80"). His patch makes me believe that on keystone platform the read operation on that register causes some unpredicted behavior leads his platform to crash/abort, that's why he created this alternative version approach to avoid the "detection" algorithm.
From what I'm seeing the only drivers that use this "version" approach are the keystone and intel-gw (which probably doesn't need it).
To summarize, this is a workaround so that the keystone driver doesn't break independent of the controller IP version.
-Gustavo
Quoted 2 lines
Rob
Rob Herring
reviewerRe: [PATCH V3 2/2] PCI: dwc: Add support to configure for ECRC
Quoted 59 lines · Gustavo Pimentel
Quoted 56 lines · Rob Herring
Quoted 54 lines · Gustavo Pimentel
Quoted 51 lines · Vidya Sagar
Quoted 48 lines · Rob Herring
External email: Use caution opening links or attachments
Quoted 35 lines · Vidya Sagar
DesignWare core has a TLP digest (TD) override bit in one of the control registers of ATU. This bit also needs to be programmed for proper ECRC functionality. This is currently identified as an issue with DesignWare IP version 4.90a. This patch does the required programming in ATU upon querying the system policy for ECRC.
Signed-off-by Vidya Sagar <[email protected]>Reviewed-by Jingoo Han <[email protected]>---
V3:
* Added 'Reviewed-by: Jingoo Han <[email protected]>'V2:
* Addressed Jingoo's review comment
* Removed saving 'td' bit information in 'dw_pcie' structuredrivers/pci/controller/dwc/pcie-designware.c | 8 ++++++-- drivers/pci/controller/dwc/pcie-designware.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)drivers/pci/controller/dwc/pcie-designware.c +2
-0@@ -246,6 +246,8 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, u8 func_no,dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_UPPER_TARGET ,upper_32_bits (pci_addr)); val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A ) + val = val |pcie_is_ecrc_enabled () <<PCIE_ATU_TD_SHIFT ; val =upper_32_bits (size -1 ) ? val |PCIE_ATU_INCREASE_REGION_SIZE : val;dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_REGION_CTRL1 , val);drivers/pci/controller/dwc/pcie-designware.c static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, · line 300
Quoted 7 lines
drivers/pci/controller/dwc/pcie-designware.c +2
-2@@ -294,8 +296,10 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, lower_32_bits(pci_addr));dw_pcie_writel_dbi (pci,PCIE_ATU_UPPER_TARGET ,upper_32_bits (pci_addr)); -dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , type | -PCIE_ATU_FUNC_NUM (func_no)); + val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A )Is this even possible? Are the non-unroll ATU registers available post 4.80?
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
I'm not sure. Gustavo might have information about this. I made this change so that it is taken care off even if they available.
The Synopsys DesignWare PCIe IP is highly configurable, therefore is dependable on what the design team has configured for their solution. Although Synopsys doesn't recommend the use of non-unroll ATU, the customers are free to select what they want for their design.
Then given the feature is not really tied to the IP version, using version wasn't really a good choice. A better choice would have been a quirk flag that platforms could set. Perhaps called 'iatu_unroll_enabled'...
Quoted 10 lines
Quoted 7 lines
Okay, then there's a bug in the driver if the version is set to
0x480Aor later and non-unroll is used:if (
pci->version>=0x480A|| (!pci->version &&dw_pcie_iatu_unroll_enabled(pci))) {Probably can just drop the version checking. The detection should always work.
Hi Rob,
Quoted 10 lines
The "detection" is based on the assumption that the read value on
PCIE_ATU_VIEWPORTregister is0xffffffff(which is a hard-coded value by design), if it's true then the iATU is unrolled and the function returns 1, otherwise is non-unrolled returns 0. So like you said it should always work, however, this code behavior was changed by Kishon on the following patch2aadcb0cd39("PCI: dwc: Fix ATU identification for designware version >= 4.80"). His patch makes me believe that on keystone platform the read operation on that register causes some unpredicted behavior leads his platform to crash/abort, that's why he created this alternative version approach to avoid the "detection" algorithm.
Ah, h/w designers and their love for bus aborts...
Quoted 5 lines
From what I'm seeing the only drivers that use this "version" approach are the keystone and intel-gw (which probably doesn't need it).
To summarize, this is a workaround so that the keystone driver doesn't break independent of the controller IP version.
Keystone is also broken in another way. The dts files claim 16 in and out regions, but the ATU region is 4KB. It would need 8KB for 16 regions as unroll has a stride of 512bytes for each region.
Rob
Re: [PATCH V3 2/2] PCI: dwc: Add support to configure for ECRC
In reply to Vidya SagarQuoted 5 lines · Vidya Sagar
DesignWare core has a TLP digest (TD) override bit in one of the control registers of ATU. This bit also needs to be programmed for proper ECRC functionality. This is currently identified as an issue with DesignWare IP version 4.90a. This patch does the required programming in ATU upon querying the system policy for ECRC.
I guess this is a hardware defect, right?
How much of a problem would it be if we instead added a "no_ecrc" quirk for this hardware so we never enabled ECRC?
IIUC, the current Linux support of ECRC is a single choice at
boot-time: by default ECRC is not enabled, but if you boot with "pci=ecrc=on", we turn on ECRC for every device.
That seems like the minimal support, but I think the spec allows ECRC to be enabled selectively, on individual devices. I can imagine a sysfs knob that would allow us to enable/disable ECRC per-device at run-time.
If we had such a sysfs knob, it would be pretty ugly and maybe impractical to work around this hardware issue. So I'm a little bit hesitant to add functionality that might have to be removed in the future.
Quoted 55 lines
Signed-off-by Vidya Sagar <[email protected]>Reviewed-by Jingoo Han <[email protected]>---
V3:
* Added 'Reviewed-by: Jingoo Han <[email protected]>'V2:
* Addressed Jingoo's review comment
* Removed saving 'td' bit information in 'dw_pcie' structuredrivers/pci/controller/dwc/pcie-designware.c | 8 ++++++-- drivers/pci/controller/dwc/pcie-designware.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)drivers/pci/controller/dwc/pcie-designware.c +6
-2@@ -246,6 +246,8 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, u8 func_no,dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_UPPER_TARGET ,upper_32_bits (pci_addr)); val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A ) + val = val |pcie_is_ecrc_enabled () <<PCIE_ATU_TD_SHIFT ; val =upper_32_bits (size -1 ) ? val |PCIE_ATU_INCREASE_REGION_SIZE : val;dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_REGION_CTRL1 , val);@@ -294,8 +296,10 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, lower_32_bits(pci_addr));dw_pcie_writel_dbi (pci,PCIE_ATU_UPPER_TARGET ,upper_32_bits (pci_addr)); -dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , type | -PCIE_ATU_FUNC_NUM (func_no)); + val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A ) + val = val |pcie_is_ecrc_enabled () <<PCIE_ATU_TD_SHIFT ; +dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , val);dw_pcie_writel_dbi (pci,PCIE_ATU_CR2 ,PCIE_ATU_ENABLE );/* drivers/pci/controller/dwc/pcie-designware.h +1
-0@@ -89,6 +89,7 @@#define PCIE_ATU_TYPE_IO 0x2#define PCIE_ATU_TYPE_CFG0 0x4#define PCIE_ATU_TYPE_CFG1 0x5 +#define PCIE_ATU_TD_SHIFT 8#define PCIE_ATU_FUNC_NUM (pf) ((pf) << 20)#define PCIE_ATU_CR2 0x908#define PCIE_ATU_ENABLE BIT(31)Signature · 1 line
2.17.1
Re: [PATCH V3 2/2] PCI: dwc: Add support to configure for ECRC
Quoted 11 lines · Bjorn Helgaas
External email: Use caution opening links or attachments
Quoted 5 lines · Vidya Sagar
DesignWare core has a TLP digest (TD) override bit in one of the control registers of ATU. This bit also needs to be programmed for proper ECRC functionality. This is currently identified as an issue with DesignWare IP version 4.90a. This patch does the required programming in ATU upon querying the system policy for ECRC.
I guess this is a hardware defect, right?
Yes. This is common across all DWC implementations (version 4.90 precisely)
Quoted 3 lines
How much of a problem would it be if we instead added a "
no_ecrc" quirk for this hardware so we never enabled ECRC?
Well, on Tegra for some of the high fidelity use cases, ECRC is required to be turned on and if it can be done safely with these patches, why shouldn't we not enable ECRC at all?
Quoted 10 lines
IIUC, the current Linux support of ECRC is a single choice at
boot-time: by default ECRC is not enabled, but if you boot with "pci=ecrc=on", we turn on ECRC for every device.That seems like the minimal support, but I think the spec allows ECRC to be enabled selectively, on individual devices. I can imagine a sysfs knob that would allow us to enable/disable ECRC per-device at run-time.
Quoted 4 lines
If we had such a sysfs knob, it would be pretty ugly and maybe impractical to work around this hardware issue. So I'm a little bit hesitant to add functionality that might have to be removed in the future.
Agree with this. But since it is a boot-time choice at this point, I think we can still go ahead with this approach to have a working ECRC mechanism right? I don't see any sysfs knob for AER controlling at this point.
Quoted 56 lines
Quoted 56 lines
Signed-off-by Vidya Sagar <[email protected]>Reviewed-by Jingoo Han <[email protected]>---
V3:
* Added 'Reviewed-by: Jingoo Han <[email protected]>'V2:
* Addressed Jingoo's review comment
* Removed saving 'td' bit information in 'dw_pcie' structuredrivers/pci/controller/dwc/pcie-designware.c | 8 ++++++-- drivers/pci/controller/dwc/pcie-designware.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)drivers/pci/controller/dwc/pcie-designware.c +6
-2@@ -246,6 +246,8 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, u8 func_no,dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_UPPER_TARGET ,upper_32_bits (pci_addr)); val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A ) + val = val |pcie_is_ecrc_enabled () <<PCIE_ATU_TD_SHIFT ; val =upper_32_bits (size -1 ) ? val |PCIE_ATU_INCREASE_REGION_SIZE : val;dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_REGION_CTRL1 , val);@@ -294,8 +296,10 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, lower_32_bits(pci_addr));dw_pcie_writel_dbi (pci,PCIE_ATU_UPPER_TARGET ,upper_32_bits (pci_addr)); -dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , type | -PCIE_ATU_FUNC_NUM (func_no)); + val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A ) + val = val |pcie_is_ecrc_enabled () <<PCIE_ATU_TD_SHIFT ; +dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , val);dw_pcie_writel_dbi (pci,PCIE_ATU_CR2 ,PCIE_ATU_ENABLE );/* drivers/pci/controller/dwc/pcie-designware.h +1
-1@@ -89,6 +89,7 @@#define PCIE_ATU_TYPE_IO 0x2#define PCIE_ATU_TYPE_CFG0 0x4#define PCIE_ATU_TYPE_CFG1 0x5 +#define PCIE_ATU_TD_SHIFT 8#define PCIE_ATU_FUNC_NUM (pf) ((pf) << 20)#define PCIE_ATU_CR2 0x908#define PCIE_ATU_ENABLE BIT(31) --2.17.1
Re: [PATCH V3 2/2] PCI: dwc: Add support to configure for ECRC
Quoted 26 lines · Vidya Sagar
Quoted 8 lines · Bjorn Helgaas
Quoted 5 lines · Vidya Sagar
DesignWare core has a TLP digest (TD) override bit in one of the control registers of ATU. This bit also needs to be programmed for proper ECRC functionality. This is currently identified as an issue with DesignWare IP version 4.90a. This patch does the required programming in ATU upon querying the system policy for ECRC.
I guess this is a hardware defect, right?
Yes. This is common across all DWC implementations (version 4.90 precisely)
Quoted 2 lines
How much of a problem would it be if we instead added a "
no_ecrc" quirk for this hardware so we never enabled ECRC?Well, on Tegra for some of the high fidelity use cases, ECRC is required to be turned on and if it can be done safely with these patches, why shouldn't we not enable ECRC at all?
Quoted 9 lines
IIUC, the current Linux support of ECRC is a single choice at
boot-time: by default ECRC is not enabled, but if you boot with "pci=ecrc=on", we turn on ECRC for every device.That seems like the minimal support, but I think the spec allows ECRC to be enabled selectively, on individual devices. I can imagine a sysfs knob that would allow us to enable/disable ECRC per-device at run-time.
Quoted 8 lines
Quoted 4 lines
If we had such a sysfs knob, it would be pretty ugly and maybe impractical to work around this hardware issue. So I'm a little bit hesitant to add functionality that might have to be removed in the future.
Agree with this. But since it is a boot-time choice at this point, I think we can still go ahead with this approach to have a working ECRC mechanism right? I don't see any sysfs knob for AER controlling at this point.
I don't want to do anything that will prevent us from adding per-device ECRC control in the future.
My concern is that if we add a run-time sysfs knob in the future, the user experience on this hardware will be poor because there's no convenient path to twiddle the PCIE_ATU_TD bit when the generic code changes the AER Control bit.
What is the failure mode in these scenarios:
- User boots with defaults, ECRC is disabled.
- User enables ECRC via sysfs.
- What happens here? ECRC is enabled via AER Control but not via DWC TD bit. I assume ECRC doesn't work. Does it cause PCIe errors (malformed TLP, etc)?
Or this one:
- User boots with "pci=ecrc=on", ECRC is enabled.
- ECRC works fine.
- User disables ECRC via sysfs.
- What happens here? ECRC is disabled via AER Control, but DWC TD bit thinks it's still enabled.
If you enabled ECRC unconditionally on DWC and the sysfs knob had no effect, I'd be OK with that. I'm more worried about what happens when the AER bit and the DWC TD bit are set so they don't match. What is the failure mode there?
Quoted 55 lines
Quoted 55 lines
Quoted 55 lines
Signed-off-by Vidya Sagar <[email protected]>Reviewed-by Jingoo Han <[email protected]>---
V3:
* Added 'Reviewed-by: Jingoo Han <[email protected]>'V2:
* Addressed Jingoo's review comment
* Removed saving 'td' bit information in 'dw_pcie' structuredrivers/pci/controller/dwc/pcie-designware.c | 8 ++++++-- drivers/pci/controller/dwc/pcie-designware.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)drivers/pci/controller/dwc/pcie-designware.c +6
-2@@ -246,6 +246,8 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, u8 func_no,dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_UPPER_TARGET ,upper_32_bits (pci_addr)); val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A ) + val = val |pcie_is_ecrc_enabled () <<PCIE_ATU_TD_SHIFT ; val =upper_32_bits (size -1 ) ? val |PCIE_ATU_INCREASE_REGION_SIZE : val;dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_REGION_CTRL1 , val);@@ -294,8 +296,10 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, lower_32_bits(pci_addr));dw_pcie_writel_dbi (pci,PCIE_ATU_UPPER_TARGET ,upper_32_bits (pci_addr)); -dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , type | -PCIE_ATU_FUNC_NUM (func_no)); + val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A ) + val = val |pcie_is_ecrc_enabled () <<PCIE_ATU_TD_SHIFT ; +dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , val);dw_pcie_writel_dbi (pci,PCIE_ATU_CR2 ,PCIE_ATU_ENABLE );/* drivers/pci/controller/dwc/pcie-designware.h +1
-1@@ -89,6 +89,7 @@#define PCIE_ATU_TYPE_IO 0x2#define PCIE_ATU_TYPE_CFG0 0x4#define PCIE_ATU_TYPE_CFG1 0x5 +#define PCIE_ATU_TD_SHIFT 8#define PCIE_ATU_FUNC_NUM (pf) ((pf) << 20)#define PCIE_ATU_CR2 0x908#define PCIE_ATU_ENABLE BIT(31) --2.17.1
Re: [PATCH V3 2/2] PCI: dwc: Add support to configure for ECRC
Quoted 39 lines · Bjorn Helgaas
External email: Use caution opening links or attachments
Quoted 26 lines · Vidya Sagar
Quoted 8 lines · Bjorn Helgaas
Quoted 5 lines · Vidya Sagar
DesignWare core has a TLP digest (TD) override bit in one of the control registers of ATU. This bit also needs to be programmed for proper ECRC functionality. This is currently identified as an issue with DesignWare IP version 4.90a. This patch does the required programming in ATU upon querying the system policy for ECRC.
I guess this is a hardware defect, right?
Yes. This is common across all DWC implementations (version 4.90 precisely)
Quoted 2 lines
How much of a problem would it be if we instead added a "
no_ecrc" quirk for this hardware so we never enabled ECRC?Well, on Tegra for some of the high fidelity use cases, ECRC is required to be turned on and if it can be done safely with these patches, why shouldn't we not enable ECRC at all?
Quoted 9 lines
IIUC, the current Linux support of ECRC is a single choice at
boot-time: by default ECRC is not enabled, but if you boot with "pci=ecrc=on", we turn on ECRC for every device.That seems like the minimal support, but I think the spec allows ECRC to be enabled selectively, on individual devices. I can imagine a sysfs knob that would allow us to enable/disable ECRC per-device at run-time.
Quoted 8 lines
Quoted 4 lines
If we had such a sysfs knob, it would be pretty ugly and maybe impractical to work around this hardware issue. So I'm a little bit hesitant to add functionality that might have to be removed in the future.
Agree with this. But since it is a boot-time choice at this point, I think we can still go ahead with this approach to have a working ECRC mechanism right? I don't see any sysfs knob for AER controlling at this point.
Quoted 7 lines
I don't want to do anything that will prevent us from adding per-device ECRC control in the future.
My concern is that if we add a run-time sysfs knob in the future, the user experience on this hardware will be poor because there's no convenient path to twiddle the
PCIE_ATU_TDbit when the generic code changes the AER Control bit.
Agree.
Can we add it to the documentation that run time changing of ECRC settings are not supported on this (i.e. Tegra194) platform (or for that matter on any SoC with PCIe based on DesignWare core version 4.90A). By 'not supported', I meant that the ECRC digest part may not work but the normal functionality will continue to work without reporting any AER errors. I tried to emulate the following scenarios on Tegra194 silicon and here are my observations. FWIW, I'm referring to the PCIe spec Rev 5.0 Ver 1.0 (22 May 2019)
Quoted 8 lines
What is the failure mode in these scenarios:
- User boots with defaults, ECRC is disabled.
- User enables ECRC via sysfs.
- What happens here? ECRC is enabled via AER Control but not via DWC TD bit. I assume ECRC doesn't work. Does it cause PCIe errors (malformed TLP, etc)?
Since DWC TD bit is not programmed, for all the transactions that go through ATU, TLP Digest won't get generated (although AER registers indicate that ECRC should get generated). As per the spec section "2.7.1 ECRC Rules"
---
If a device Function is enabled to generate ECRC, it must calculate and apply ECRC for all TLPs originated by the Function
---
So the RP would be violating the PCIe spec, but it doesn't result in any error because the same section has the following rule as well
---
If a device Function is enabled to check ECRC, it must do so for all TLPs with ECRC where the device is the ultimate PCI Express Receiver
Note that it is still possible for the Function to receive TLPs without
ECRC, and these are processed normally - this is not an error
---
so, even if the EP has ECRC check enabled, because of the above rule, it just processes those packets without ECRC as normal packets. Basically, whoever is enabling ECRC run time gets cheated as transactions routed through ATU don't really have ECRC digest
Quoted 8 lines
Or this one:
- User boots with "pci=ecrc=on", ECRC is enabled.
- ECRC works fine.
- User disables ECRC via sysfs.
- What happens here? ECRC is disabled via AER Control, but DWC TD bit thinks it's still enabled.
In this case, the EP doesn't have ECRC check enabled but receives TLPs with ECRC digest. This again won't result in any error because of the section "2.2.3 TLP Digest Rules" which says
---
If an intermediate or ultimate PCI Express Receiver of the TLP does not support ECRC checking, the Receiver must ignore the TLP Digest
---
So the EP just ignores the TLP Digest and process the TLP normally.
Although functionality wise there is no issue here, there could be some impact on the perf because of the extra DWord data. This is again debatable as the perf/data path is typically from EP's DMA engine to host system memory and not config/BAR accesses.
Quoted 5 lines
If you enabled ECRC unconditionally on DWC and the sysfs knob had no effect, I'd be OK with that. I'm more worried about what happens when the AER bit and the DWC TD bit are set so they don't match. What is the failure mode there?
Based on the above experiments, we can as well keep the DWC TD bit programmed unconditionally and it won't lead to any errors. As mentioned before, the only downside of it is the extra DWord in each ATU routed TLP which may load the bus (in downstream direction) with no real benefit as such.
Please let me know where can we go from here.
I can push a different patch to keep DWC TD bit always programmed if that is the best approach to take at this point.
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Signed-off-by Vidya Sagar <[email protected]>Reviewed-by Jingoo Han <[email protected]>---
V3:
* Added 'Reviewed-by: Jingoo Han <[email protected]>'V2:
* Addressed Jingoo's review comment
* Removed saving 'td' bit information in 'dw_pcie' structuredrivers/pci/controller/dwc/pcie-designware.c | 8 ++++++-- drivers/pci/controller/dwc/pcie-designware.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)drivers/pci/controller/dwc/pcie-designware.c +6
-2@@ -246,6 +246,8 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, u8 func_no,dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_UPPER_TARGET ,upper_32_bits (pci_addr)); val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A ) + val = val |pcie_is_ecrc_enabled () <<PCIE_ATU_TD_SHIFT ; val =upper_32_bits (size -1 ) ? val |PCIE_ATU_INCREASE_REGION_SIZE : val;dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_REGION_CTRL1 , val);@@ -294,8 +296,10 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, lower_32_bits(pci_addr));dw_pcie_writel_dbi (pci,PCIE_ATU_UPPER_TARGET ,upper_32_bits (pci_addr)); -dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , type | -PCIE_ATU_FUNC_NUM (func_no)); + val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A ) + val = val |pcie_is_ecrc_enabled () <<PCIE_ATU_TD_SHIFT ; +dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , val);dw_pcie_writel_dbi (pci,PCIE_ATU_CR2 ,PCIE_ATU_ENABLE );/* drivers/pci/controller/dwc/pcie-designware.h +1
-1@@ -89,6 +89,7 @@#define PCIE_ATU_TYPE_IO 0x2#define PCIE_ATU_TYPE_CFG0 0x4#define PCIE_ATU_TYPE_CFG1 0x5 +#define PCIE_ATU_TD_SHIFT 8#define PCIE_ATU_FUNC_NUM (pf) ((pf) << 20)#define PCIE_ATU_CR2 0x908#define PCIE_ATU_ENABLE BIT(31) --2.17.1
Re: [PATCH V3 2/2] PCI: dwc: Add support to configure for ECRC
Quoted 116 lines · Vidya Sagar
Quoted 36 lines · Bjorn Helgaas
Quoted 26 lines · Vidya Sagar
Quoted 8 lines · Bjorn Helgaas
Quoted 5 lines · Vidya Sagar
DesignWare core has a TLP digest (TD) override bit in one of the control registers of ATU. This bit also needs to be programmed for proper ECRC functionality. This is currently identified as an issue with DesignWare IP version 4.90a. This patch does the required programming in ATU upon querying the system policy for ECRC.
I guess this is a hardware defect, right?
Yes. This is common across all DWC implementations (version 4.90 precisely)
Quoted 2 lines
How much of a problem would it be if we instead added a "
no_ecrc" quirk for this hardware so we never enabled ECRC?Well, on Tegra for some of the high fidelity use cases, ECRC is required to be turned on and if it can be done safely with these patches, why shouldn't we not enable ECRC at all?
Quoted 9 lines
IIUC, the current Linux support of ECRC is a single choice at
boot-time: by default ECRC is not enabled, but if you boot with "pci=ecrc=on", we turn on ECRC for every device.That seems like the minimal support, but I think the spec allows ECRC to be enabled selectively, on individual devices. I can imagine a sysfs knob that would allow us to enable/disable ECRC per-device at run-time.
Quoted 8 lines
Quoted 4 lines
If we had such a sysfs knob, it would be pretty ugly and maybe impractical to work around this hardware issue. So I'm a little bit hesitant to add functionality that might have to be removed in the future.
Agree with this. But since it is a boot-time choice at this point, I think we can still go ahead with this approach to have a working ECRC mechanism right? I don't see any sysfs knob for AER controlling at this point.
Quoted 7 lines
I don't want to do anything that will prevent us from adding per-device ECRC control in the future.
My concern is that if we add a run-time sysfs knob in the future, the user experience on this hardware will be poor because there's no convenient path to twiddle the
PCIE_ATU_TDbit when the generic code changes the AER Control bit.Agree.
Can we add it to the documentation that run time changing of ECRC settings are not supported on this (i.e. Tegra194) platform (or for that matter on any SoC with PCIe based on DesignWare core version 4.90A). By 'not supported', I meant that the ECRC digest part may not work but the normal functionality will continue to work without reporting any AER errors. I tried to emulate the following scenarios on Tegra194 silicon and here are my observations.
FWIW, I'm referring to the PCIe spec Rev 5.0 Ver 1.0 (22 May 2019)Quoted 7 lines
What is the failure mode in these scenarios:
- User boots with defaults, ECRC is disabled.
- User enables ECRC via sysfs.
- What happens here? ECRC is enabled via AER Control but not via DWC TD bit. I assume ECRC doesn't work. Does it cause PCIe errors (malformed TLP, etc)?Since DWC TD bit is not programmed, for all the transactions that go through ATU, TLP Digest won't get generated (although AER registers indicate that ECRC should get generated).
As per the spec section "2.7.1 ECRC Rules"---
If a device Function is enabled to generate ECRC, it must calculate and apply ECRC for all TLPs originated by the Function
---So the RP would be violating the PCIe spec, but it doesn't result in any error because the same section has the following rule as well
---
If a device Function is enabled to check ECRC, it must do so for all TLPs with ECRC where the device is the ultimate PCI Express Receiver
Note that it is still possible for the Function to receive TLPs without
ECRC, and these are processed normally - this is not an error
---so, even if the EP has ECRC check enabled, because of the above rule, it just processes those packets without ECRC as normal packets. Basically, whoever is enabling ECRC run time gets cheated as transactions routed through ATU don't really have ECRC digest
Quoted 7 lines
Or this one:
- User boots with "pci=ecrc=on", ECRC is enabled.
- ECRC works fine.
- User disables ECRC via sysfs.
- What happens here? ECRC is disabled via AER Control, but DWC TD bit thinks it's still enabled.In this case, the EP doesn't have ECRC check enabled but receives TLPs with ECRC digest. This again won't result in any error because of the section "2.2.3 TLP Digest Rules" which says
---
If an intermediate or ultimate PCI Express Receiver of the TLP does not support ECRC checking, the Receiver must ignore the TLP Digest
---So the EP just ignores the TLP Digest and process the TLP normally. Although functionality wise there is no issue here, there could be some impact on the perf because of the extra DWord data. This is again debatable as the perf/data path is typically from EP's DMA engine to host system memory and not config/BAR accesses.
Quoted 5 lines
If you enabled ECRC unconditionally on DWC and the sysfs knob had no effect, I'd be OK with that. I'm more worried about what happens when the AER bit and the DWC TD bit are set so they don't match. What is the failure mode there?
Quoted 5 lines
Based on the above experiments, we can as well keep the DWC TD bit programmed unconditionally and it won't lead to any errors. As mentioned before, the only downside of it is the extra DWord in each ATU routed TLP which may load the bus (in downstream direction) with no real benefit as such.
IIUC the issue only affects traffic from the Root Port to the Endpoint, and traffic going upstream is unaffected. Here's what I think happens based on the RP and EP settings, please correct me if wrong:
1) RP TD+ ECRC_gen+ generates ECRC
EP ECRC_check- ignores ECRC
EP ECRC_check+ checks ECRC 2) RP TD+ ECRC_gen- generates ECRC when it shouldn't (defect)
EP ECRC_check- ignores ECRC
EP ECRC_check+ checks ECRC (may signal errors) 3) RP TD- ECRC_gen+ fails to generate ECRC (defect)
EP ECRC_check- ignores ECRC
EP ECRC_check+ handles TLPs without ECRC normally,but cannot detect ECRC errors
4) RP TD- ECRC_gen- no ECRC generated (as expected)
EP ECRC_check- ignores ECRC
EP ECRC_check+ handles TLPs without ECRC normallyIf my assumptions above are correct, this defect never causes extra errors like Malformed TLP, etc, to be signaled regardless of the AER ECRC_check settings.
The only functional problem is that in case 3, the EP *should* be able to check and signal ECRC errors, but it cannot because the RP doesn't generate ECRC.
Case 2 is a performance issue because we add the extra dword in every TLP going downstream. That doesn't seem unreasonable since this is just config and BAR accesses. The EP may detect ECRC errors when we don't think the RP is even generating ECRC, but in general we won't enable checking in the EP unless we also enable generation in the RP.
So I think setting the DWC TD bit unconditionally seems like a pretty good solution.
Quoted 59 lines
Please let me know where can we go from here.
I can push a different patch to keep DWC TD bit always programmed if that is the best approach to take at this point.Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Signed-off-by Vidya Sagar <[email protected]>Reviewed-by Jingoo Han <[email protected]>---
V3:
* Added 'Reviewed-by: Jingoo Han <[email protected]>'V2:
* Addressed Jingoo's review comment
* Removed saving 'td' bit information in 'dw_pcie' structuredrivers/pci/controller/dwc/pcie-designware.c | 8 ++++++-- drivers/pci/controller/dwc/pcie-designware.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)drivers/pci/controller/dwc/pcie-designware.c +6
-2@@ -246,6 +246,8 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, u8 func_no,dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_UPPER_TARGET ,upper_32_bits (pci_addr)); val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A ) + val = val |pcie_is_ecrc_enabled () <<PCIE_ATU_TD_SHIFT ; val =upper_32_bits (size -1 ) ? val |PCIE_ATU_INCREASE_REGION_SIZE : val;dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_REGION_CTRL1 , val);@@ -294,8 +296,10 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, lower_32_bits(pci_addr));dw_pcie_writel_dbi (pci,PCIE_ATU_UPPER_TARGET ,upper_32_bits (pci_addr)); -dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , type | -PCIE_ATU_FUNC_NUM (func_no)); + val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A ) + val = val |pcie_is_ecrc_enabled () <<PCIE_ATU_TD_SHIFT ; +dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , val);dw_pcie_writel_dbi (pci,PCIE_ATU_CR2 ,PCIE_ATU_ENABLE );/* drivers/pci/controller/dwc/pcie-designware.h +1
-1@@ -89,6 +89,7 @@#define PCIE_ATU_TYPE_IO 0x2#define PCIE_ATU_TYPE_CFG0 0x4#define PCIE_ATU_TYPE_CFG1 0x5 +#define PCIE_ATU_TD_SHIFT 8#define PCIE_ATU_FUNC_NUM (pf) ((pf) << 20)#define PCIE_ATU_CR2 0x908#define PCIE_ATU_ENABLE BIT(31) --2.17.1
Re: [PATCH V3 2/2] PCI: dwc: Add support to configure for ECRC
Quoted 144 lines · Bjorn Helgaas
External email: Use caution opening links or attachments
Quoted 116 lines · Vidya Sagar
Quoted 36 lines · Bjorn Helgaas
Quoted 26 lines · Vidya Sagar
Quoted 8 lines · Bjorn Helgaas
Quoted 5 lines · Vidya Sagar
DesignWare core has a TLP digest (TD) override bit in one of the control registers of ATU. This bit also needs to be programmed for proper ECRC functionality. This is currently identified as an issue with DesignWare IP version 4.90a. This patch does the required programming in ATU upon querying the system policy for ECRC.
I guess this is a hardware defect, right?
Yes. This is common across all DWC implementations (version 4.90 precisely)
Quoted 2 lines
How much of a problem would it be if we instead added a "
no_ecrc" quirk for this hardware so we never enabled ECRC?Well, on Tegra for some of the high fidelity use cases, ECRC is required to be turned on and if it can be done safely with these patches, why shouldn't we not enable ECRC at all?
Quoted 9 lines
IIUC, the current Linux support of ECRC is a single choice at
boot-time: by default ECRC is not enabled, but if you boot with "pci=ecrc=on", we turn on ECRC for every device.That seems like the minimal support, but I think the spec allows ECRC to be enabled selectively, on individual devices. I can imagine a sysfs knob that would allow us to enable/disable ECRC per-device at run-time.
Quoted 8 lines
Quoted 4 lines
If we had such a sysfs knob, it would be pretty ugly and maybe impractical to work around this hardware issue. So I'm a little bit hesitant to add functionality that might have to be removed in the future.
Agree with this. But since it is a boot-time choice at this point, I think we can still go ahead with this approach to have a working ECRC mechanism right? I don't see any sysfs knob for AER controlling at this point.
Quoted 7 lines
I don't want to do anything that will prevent us from adding per-device ECRC control in the future.
My concern is that if we add a run-time sysfs knob in the future, the user experience on this hardware will be poor because there's no convenient path to twiddle the
PCIE_ATU_TDbit when the generic code changes the AER Control bit.Agree.
Can we add it to the documentation that run time changing of ECRC settings are not supported on this (i.e. Tegra194) platform (or for that matter on any SoC with PCIe based on DesignWare core version 4.90A). By 'not supported', I meant that the ECRC digest part may not work but the normal functionality will continue to work without reporting any AER errors. I tried to emulate the following scenarios on Tegra194 silicon and here are my observations.
FWIW, I'm referring to the PCIe spec Rev 5.0 Ver 1.0 (22 May 2019)Quoted 7 lines
What is the failure mode in these scenarios:
- User boots with defaults, ECRC is disabled.
- User enables ECRC via sysfs.
- What happens here? ECRC is enabled via AER Control but not via DWC TD bit. I assume ECRC doesn't work. Does it cause PCIe errors (malformed TLP, etc)?Since DWC TD bit is not programmed, for all the transactions that go through ATU, TLP Digest won't get generated (although AER registers indicate that ECRC should get generated).
As per the spec section "2.7.1 ECRC Rules"---
If a device Function is enabled to generate ECRC, it must calculate and apply ECRC for all TLPs originated by the Function
---So the RP would be violating the PCIe spec, but it doesn't result in any error because the same section has the following rule as well
---
If a device Function is enabled to check ECRC, it must do so for all TLPs with ECRC where the device is the ultimate PCI Express Receiver
Note that it is still possible for the Function to receive TLPs without
ECRC, and these are processed normally - this is not an error
---so, even if the EP has ECRC check enabled, because of the above rule, it just processes those packets without ECRC as normal packets. Basically, whoever is enabling ECRC run time gets cheated as transactions routed through ATU don't really have ECRC digest
Quoted 7 lines
Or this one:
- User boots with "pci=ecrc=on", ECRC is enabled.
- ECRC works fine.
- User disables ECRC via sysfs.
- What happens here? ECRC is disabled via AER Control, but DWC TD bit thinks it's still enabled.In this case, the EP doesn't have ECRC check enabled but receives TLPs with ECRC digest. This again won't result in any error because of the section "2.2.3 TLP Digest Rules" which says
---
If an intermediate or ultimate PCI Express Receiver of the TLP does not support ECRC checking, the Receiver must ignore the TLP Digest
---So the EP just ignores the TLP Digest and process the TLP normally. Although functionality wise there is no issue here, there could be some impact on the perf because of the extra DWord data. This is again debatable as the perf/data path is typically from EP's DMA engine to host system memory and not config/BAR accesses.
Quoted 5 lines
If you enabled ECRC unconditionally on DWC and the sysfs knob had no effect, I'd be OK with that. I'm more worried about what happens when the AER bit and the DWC TD bit are set so they don't match. What is the failure mode there?
Quoted 5 lines
Based on the above experiments, we can as well keep the DWC TD bit programmed unconditionally and it won't lead to any errors. As mentioned before, the only downside of it is the extra DWord in each ATU routed TLP which may load the bus (in downstream direction) with no real benefit as such.
IIUC the issue only affects traffic from the Root Port to the Endpoint, and traffic going upstream is unaffected. Here's what I think happens based on the RP and EP settings, please correct me if wrong:
1) RP TD+ ECRC_gen+ generates ECRC EP ECRC_check- ignores ECRC EP ECRC_check+ checks ECRC2) RP TD+ ECRC_gen- generates ECRC when it shouldn't (defect) EP ECRC_check- ignores ECRC EP ECRC_check+ checks ECRC (may signal errors)3) RP TD- ECRC_gen+ fails to generate ECRC (defect) EP ECRC_check- ignores ECRC EP ECRC_check+ handles TLPs without ECRC normally,but cannot detect ECRC errors
Quoted 7 lines
4) RP TD- ECRC_gen- no ECRC generated (as expected) EP ECRC_check- ignores ECRC EP ECRC_check+ handles TLPs without ECRC normallyIf my assumptions above are correct, this defect never causes extra errors like Malformed TLP, etc, to be signaled regardless of the AER
ECRC_checksettings.
Yes.
Quoted 4 lines
The only functional problem is that in case 3, the EP *should* be able to check and signal ECRC errors, but it cannot because the RP doesn't generate ECRC.
Yes. Thats correct
Quoted 9 lines
Case 2 is a performance issue because we add the extra dword in every TLP going downstream. That doesn't seem unreasonable since this is just config and BAR accesses. The EP may detect ECRC errors when we don't think the RP is even generating ECRC, but in general we won't enable checking in the EP unless we also enable generation in the RP.
So I think setting the DWC TD bit unconditionally seems like a pretty good solution.
Ok. Sure. I'll push a patch to program DWC TD bit unconditionally then. Thanks for your insights and guidance.
Quoted 60 lines
Quoted 60 lines
Please let me know where can we go from here.
I can push a different patch to keep DWC TD bit always programmed if that is the best approach to take at this point.Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Signed-off-by Vidya Sagar <[email protected]>Reviewed-by Jingoo Han <[email protected]>---
V3:
* Added 'Reviewed-by: Jingoo Han <[email protected]>'V2:
* Addressed Jingoo's review comment
* Removed saving 'td' bit information in 'dw_pcie' structuredrivers/pci/controller/dwc/pcie-designware.c | 8 ++++++-- drivers/pci/controller/dwc/pcie-designware.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)drivers/pci/controller/dwc/pcie-designware.c +6
-2@@ -246,6 +246,8 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, u8 func_no,dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_UPPER_TARGET ,upper_32_bits (pci_addr)); val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A ) + val = val |pcie_is_ecrc_enabled () <<PCIE_ATU_TD_SHIFT ; val =upper_32_bits (size -1 ) ? val |PCIE_ATU_INCREASE_REGION_SIZE : val;dw_pcie_writel_ob_unroll (pci, index,PCIE_ATU_UNR_REGION_CTRL1 , val);@@ -294,8 +296,10 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, lower_32_bits(pci_addr));dw_pcie_writel_dbi (pci,PCIE_ATU_UPPER_TARGET ,upper_32_bits (pci_addr)); -dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , type | -PCIE_ATU_FUNC_NUM (func_no)); + val = type |PCIE_ATU_FUNC_NUM (func_no); +if (pci->version ==0x490A ) + val = val |pcie_is_ecrc_enabled () <<PCIE_ATU_TD_SHIFT ; +dw_pcie_writel_dbi (pci,PCIE_ATU_CR1 , val);dw_pcie_writel_dbi (pci,PCIE_ATU_CR2 ,PCIE_ATU_ENABLE );/* drivers/pci/controller/dwc/pcie-designware.h +1
-1@@ -89,6 +89,7 @@#define PCIE_ATU_TYPE_IO 0x2#define PCIE_ATU_TYPE_CFG0 0x4#define PCIE_ATU_TYPE_CFG1 0x5 +#define PCIE_ATU_TD_SHIFT 8#define PCIE_ATU_FUNC_NUM (pf) ((pf) << 20)#define PCIE_ATU_CR2 0x908#define PCIE_ATU_ENABLE BIT(31) --2.17.1