Skip to contentSkip to conversation

Add support to configure DWC for ECRC

PATCH Superseded Vidya Sagar 2 participants 6 messages Oct 25, 2020 – Oct 26, 2020

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

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.

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 |  2 ++
 drivers/pci/pci.h                            |  2 ++
 drivers/pci/pcie/aer.c                       | 11 +++++++++++
 4 files changed, 21 insertions(+), 2 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 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.

---
 drivers/pci/pci.h      |  2 ++
 drivers/pci/pcie/aer.c | 11 +++++++++++
 2 files changed, 13 insertions(+)
drivers/pci/pci.h +2 -0
index fa12f7cbc1a0..325fdbf91dde 100644
@@ -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
index 65dff5f3457a..24363c895aba 100644
@@ -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 1 if ECRC policy is enabled and 0 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
#2 lore raw

PATCH 2/2 PCI: dwc: Add support to configure for ECRC

In reply to 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.

---
 drivers/pci/controller/dwc/pcie-designware.c | 8 ++++++--
 drivers/pci/controller/dwc/pcie-designware.h | 2 ++
 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pcie-designware.c +6 -2
index b5e438b70cd5..810dcbdbe869 100644
@@ -245,7 +245,7 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, u8 func_no,
 				 lower_32_bits(pci_addr));
 	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);
+	val = type | PCIE_ATU_FUNC_NUM(func_no) | pci->td << 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);
@@ -295,7 +295,8 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no,
 	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));
+			   PCIE_ATU_FUNC_NUM(func_no) |
+			   pci->td << PCIE_ATU_TD_SHIFT);
 	dw_pcie_writel_dbi(pci, PCIE_ATU_CR2, PCIE_ATU_ENABLE);
 
 	/*
@@ -565,6 +566,9 @@ void dw_pcie_setup(struct dw_pcie *pci)
 	dev_dbg(pci->dev, "iATU unroll: %s\n", pci->iatu_unroll_enabled ?
 		"enabled" : "disabled");
 
+	if (pci->version == 0x490A)
+		pci->td = pcie_is_ecrc_enabled();
+
 	if (pci->link_gen > 0)
 		dw_pcie_link_set_max_speed(pci, pci->link_gen);
 
drivers/pci/controller/dwc/pcie-designware.h +2 -0
index 21dd06831b50..d34723e42e79 100644
@@ -90,6 +90,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)
@@ -276,6 +277,7 @@ struct dw_pcie {
 	int			num_lanes;
 	int			link_gen;
 	u8			n_fts[2];
+	bool			td;	/* TLP Digest (for ECRC purpose) */
 };
 
 #define to_dw_pcie_from_pp(port) container_of((port), struct dw_pcie, pp)
Signature · 1 line
2.17.1
maintainer
#3 lore raw

Re: [PATCH 2/2] PCI: dwc: Add support to configure for ECRC

Quoted 59 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.

---
 drivers/pci/controller/dwc/pcie-designware.c | 8 ++++++--
 drivers/pci/controller/dwc/pcie-designware.h | 2 ++
 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pcie-designware.c +6 -2
index b5e438b70cd5..810dcbdbe869 100644
@@ -245,7 +245,7 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, u8 func_no,
 				 lower_32_bits(pci_addr));
 	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);
+	val = type | PCIE_ATU_FUNC_NUM(func_no) | pci->td << 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);
@@ -295,7 +295,8 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no,
 	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));
+			   PCIE_ATU_FUNC_NUM(func_no) |
+			   pci->td << PCIE_ATU_TD_SHIFT);
 	dw_pcie_writel_dbi(pci, PCIE_ATU_CR2, PCIE_ATU_ENABLE);
 
 	/*
@@ -565,6 +566,9 @@ void dw_pcie_setup(struct dw_pcie *pci)
 	dev_dbg(pci->dev, "iATU unroll: %s\n", pci->iatu_unroll_enabled ?
 		"enabled" : "disabled");
 
+	if (pci->version == 0x490A)
+		pci->td = pcie_is_ecrc_enabled();
+
 	if (pci->link_gen > 0)
 		dw_pcie_link_set_max_speed(pci, pci->link_gen);
 
drivers/pci/controller/dwc/pcie-designware.h +1 -0
index 21dd06831b50..d34723e42e79 100644
@@ -90,6 +90,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)

drivers/pci/controller/dwc/pcie-designware.h struct dw_pcie { · line 280

Quoted 4 lines
drivers/pci/controller/dwc/pcie-designware.h +1 -0
@@ -276,6 +277,7 @@ struct dw_pcie {
 	int			num_lanes;
 	int			link_gen;
 	u8			n_fts[2];
+	bool			td;	/* TLP Digest (for ECRC purpose) */

If possible, don't add a new variable to 'dw_pcie' structure.
Please find a way to set TD bit without adding a new variable to 'dw_pcie' structure'.

Best regards,
Jingoo Han

Quoted 5 lines
drivers/pci/controller/dwc/pcie-designware.h +0 -0
 };
 
 #define to_dw_pcie_from_pp(port) container_of((port), struct dw_pcie, pp)
Signature · 1 line
2.17.1
#4 lore raw

Re: [PATCH 2/2] PCI: dwc: Add support to configure for ECRC

Quoted 62 lines · Jingoo Han

External email: Use caution opening links or attachments

Quoted 58 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.

---
  drivers/pci/controller/dwc/pcie-designware.c | 8 ++++++--
  drivers/pci/controller/dwc/pcie-designware.h | 2 ++
  2 files changed, 8 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pcie-designware.c +6 -2
index b5e438b70cd5..810dcbdbe869 100644
@@ -245,7 +245,7 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, u8 func_no,
                                lower_32_bits(pci_addr));
       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);
+     val = type | PCIE_ATU_FUNC_NUM(func_no) | pci->td << 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);
@@ -295,7 +295,8 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no,
       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));
+                        PCIE_ATU_FUNC_NUM(func_no) |
+                        pci->td << PCIE_ATU_TD_SHIFT);
       dw_pcie_writel_dbi(pci, PCIE_ATU_CR2, PCIE_ATU_ENABLE);
 
       /*
@@ -565,6 +566,9 @@ void dw_pcie_setup(struct dw_pcie *pci)
       dev_dbg(pci->dev, "iATU unroll: %s\n", pci->iatu_unroll_enabled ?
               "enabled" : "disabled");
 
+     if (pci->version == 0x490A)
+             pci->td = pcie_is_ecrc_enabled();
+
       if (pci->link_gen > 0)
               dw_pcie_link_set_max_speed(pci, pci->link_gen);
 
drivers/pci/controller/dwc/pcie-designware.h +1 -0
index 21dd06831b50..d34723e42e79 100644
@@ -90,6 +90,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)
Quoted 8 lines

drivers/pci/controller/dwc/pcie-designware.h struct dw_pcie { · line 280

Quoted 5 lines
drivers/pci/controller/dwc/pcie-designware.h +1 -0
@@ -276,6 +277,7 @@ struct dw_pcie {
       int                     num_lanes;
       int                     link_gen;
       u8                      n_fts[2];
+     bool                    td;     /* TLP Digest (for ECRC purpose) */

If possible, don't add a new variable to 'dw_pcie' structure.
Please find a way to set TD bit without adding a new variable to 'dw_pcie' structure'.

I can use pcie_is_ecrc_enabled() directly in place of pci->td. That should be fine right? BTW, curious to know if there is any specific reason behind asking not to add any new variables to 'dw_pcie' structure?

Quoted 10 lines

Best regards,
Jingoo Han

Quoted 5 lines
drivers/pci/controller/dwc/pcie-designware.h +0 -1
  };
 
  #define to_dw_pcie_from_pp(port) container_of((port), struct dw_pcie, pp)
--

2.17.1

maintainer
#5 lore raw

Re: [PATCH 2/2] PCI: dwc: Add support to configure for ECRC

Quoted 73 lines · Vidya Sagar
Quoted 62 lines · Jingoo Han

External email: Use caution opening links or attachments

Quoted 58 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.

---
  drivers/pci/controller/dwc/pcie-designware.c | 8 ++++++--
  drivers/pci/controller/dwc/pcie-designware.h | 2 ++
  2 files changed, 8 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pcie-designware.c +6 -2
index b5e438b70cd5..810dcbdbe869 100644
@@ -245,7 +245,7 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, u8 func_no,
                                lower_32_bits(pci_addr));
       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);
+     val = type | PCIE_ATU_FUNC_NUM(func_no) | pci->td << 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);
@@ -295,7 +295,8 @@ static void __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no,
       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));
+                        PCIE_ATU_FUNC_NUM(func_no) |
+                        pci->td << PCIE_ATU_TD_SHIFT);
       dw_pcie_writel_dbi(pci, PCIE_ATU_CR2, PCIE_ATU_ENABLE);
 
       /*
@@ -565,6 +566,9 @@ void dw_pcie_setup(struct dw_pcie *pci)
       dev_dbg(pci->dev, "iATU unroll: %s\n", pci->iatu_unroll_enabled ?
               "enabled" : "disabled");
 
+     if (pci->version == 0x490A)
+             pci->td = pcie_is_ecrc_enabled();
+
       if (pci->link_gen > 0)
               dw_pcie_link_set_max_speed(pci, pci->link_gen);
 
drivers/pci/controller/dwc/pcie-designware.h +1 -0
index 21dd06831b50..d34723e42e79 100644
@@ -90,6 +90,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)
Quoted 8 lines

drivers/pci/controller/dwc/pcie-designware.h struct dw_pcie { · line 280

Quoted 5 lines
drivers/pci/controller/dwc/pcie-designware.h +1 -0
@@ -276,6 +277,7 @@ struct dw_pcie {
       int                     num_lanes;
       int                     link_gen;
       u8                      n_fts[2];
+     bool                    td;     /* TLP Digest (for ECRC purpose) */

If possible, don't add a new variable to 'dw_pcie' structure.
Please find a way to set TD bit without adding a new variable to 'dw_pcie' structure'.

Quoted 4 lines

I can use pcie_is_ecrc_enabled() directly in place of pci->td. That should be fine right? BTW, curious to know if there is any specific reason behind asking not to add any new variables to 'dw_pcie' structure?

Vice versa, what is the reason to add a new variable 'td' to 'dw_pcie' structure? It is not good to add a new variable to the global structure without any specific reason.

Quoted 10 lines
Quoted 1 line

Best regards,
Jingoo Han

Quoted 5 lines
  };

#define to_dw_pcie_from_pp(port) container_of((port), struct dw_pcie, pp)
--
2.17.1