Skip to contentSkip to conversation

PCI: dwc: Fixes N_FTS setup

PATCH In review Vidya Sagar 5 participants 10 messages Sep 19, 2022 – Oct 27, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: dwc: Fixes N_FTS setup

commit aeaa0bfe89654 ("PCI: dwc: Move N_FTS setup to common setup") unnecessarily uses pci->link_gen in deriving the index to the n_fts[] array also introducing the issue of accessing beyond the boundaries of array for greater than Gen-2 speeds. This change fixes that issue.

Fixes aeaa0bfe8965 ("PCI: dwc: Move N_FTS setup to common setup")
---
 drivers/pci/controller/dwc/pcie-designware.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-designware.c +1 -1
index c6725c519a47..9e4d96e5a3f5 100644
@@ -641,7 +641,7 @@ void dw_pcie_setup(struct dw_pcie *pci)
 	if (pci->n_fts[1]) {
 		val = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL);
 		val &= ~PORT_LOGIC_N_FTS_MASK;
-		val |= pci->n_fts[pci->link_gen - 1];
+		val |= pci->n_fts[1];
 		dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
 	}
 
Signature · 1 line
2.17.1
#1 lore raw

In subject, "Fix" (not "Fixes") so it's an imperative verb. Maybe "Fix n_fts[] array overrun" to be more specific.

Quoted 2 lines · Vidya Sagar

commit aeaa0bfe89654 ("PCI: dwc: Move N_FTS setup to common setup") unnecessarily uses pci->link_gen in deriving the index to the

Not just "unnecessarily"; using pci->link_gen is *incorrect* since only [0] and [1] are defined.

Quoted 26 lines

n_fts[] array also introducing the issue of accessing beyond the boundaries of array for greater than Gen-2 speeds. This change fixes that issue.

Fixes aeaa0bfe8965 ("PCI: dwc: Move N_FTS setup to common setup")
---
 drivers/pci/controller/dwc/pcie-designware.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-designware.c +1 -1
index c6725c519a47..9e4d96e5a3f5 100644
@@ -641,7 +641,7 @@ void dw_pcie_setup(struct dw_pcie *pci)
 	if (pci->n_fts[1]) {
 		val = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL);
 		val &= ~PORT_LOGIC_N_FTS_MASK;
-		val |= pci->n_fts[pci->link_gen - 1];
+		val |= pci->n_fts[1];
 		dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
 	}
 
Signature · 1 line
2.17.1
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Vidya Sagar
Quoted 9 lines · Vidya Sagar

commit aeaa0bfe89654 ("PCI: dwc: Move N_FTS setup to common setup") unnecessarily uses pci->link_gen in deriving the index to the n_fts[] array also introducing the issue of accessing beyond the boundaries of array for greater than Gen-2 speeds. This change fixes that issue.

Fixes aeaa0bfe8965 ("PCI: dwc: Move N_FTS setup to common setup")

Please send a V2 patch that addresses Bjorn's feedback. Thank you.

Best regards,
Jingoo Han

Quoted 20 lines
---
 drivers/pci/controller/dwc/pcie-designware.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-designware.c +1 -2
index c6725c519a47..9e4d96e5a3f5 100644
@@ -641,7 +641,7 @@ void dw_pcie_setup(struct dw_pcie *pci)
        if (pci->n_fts[1]) {
                val = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL);
                val &= ~PORT_LOGIC_N_FTS_MASK;
-               val |= pci->n_fts[pci->link_gen - 1];
+               val |= pci->n_fts[1];
                dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
        }
 
--

2.17.1

#3 lore raw

PATCH v2 1/1 PCI: dwc: Fix n_fts[] array overrun

In reply to Vidya Sagar

commit aeaa0bfe89654 ("PCI: dwc: Move N_FTS setup to common setup") incorrectly uses pci->link_gen in deriving the index to the n_fts[] array also introducing the issue of accessing beyond the boundaries of array for greater than Gen-2 speeds. This change fixes that issue.

Fixes aeaa0bfe8965 ("PCI: dwc: Move N_FTS setup to common setup")

---
V2:
* Addressed review comments from Bjorn
* Added "Acked-by: Jingoo Han <[email protected]>"

 drivers/pci/controller/dwc/pcie-designware.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-designware.c +1 -1
index 650a7f22f9d0..3df687667f27 100644
@@ -649,7 +649,7 @@ void dw_pcie_setup(struct dw_pcie *pci)
 	if (pci->n_fts[1]) {
 		val = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL);
 		val &= ~PORT_LOGIC_N_FTS_MASK;
-		val |= pci->n_fts[pci->link_gen - 1];
+		val |= pci->n_fts[1];
 		dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
 	}
 
Signature · 1 line
2.17.1
maintainer
#4 lore raw

Re: [PATCH V2] PCI: dwc: Fix n_fts[] array overrun

Quoted 6 lines · Vidya Sagar

commit aeaa0bfe89654 ("PCI: dwc: Move N_FTS setup to common setup") incorrectly uses pci->link_gen in deriving the index to the n_fts[] array also introducing the issue of accessing beyond the boundaries of array for greater than Gen-2 speeds. This change fixes that issue.

Dear Vidya,

I am just ok with this patch. By the way, do we need another patch to generalize this setting? Currently, this code targets only Gen1 and Gen2. But, in my opinion,
it is possible that this driver can be used for more than Gen2, later. PCIe Gen6
standard is available and Synopsys has their solution for Gen6. So, would you send a new patch to generalize this thing, later?
Thank you.

Best regards,
Jingoo Han

Quoted 28 lines
Fixes aeaa0bfe8965 ("PCI: dwc: Move N_FTS setup to common setup")

---
V2:
* Addressed review comments from Bjorn
* Added "Acked-by: Jingoo Han <[email protected]>"

 drivers/pci/controller/dwc/pcie-designware.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-designware.c +1 -2
index 650a7f22f9d0..3df687667f27 100644
@@ -649,7 +649,7 @@ void dw_pcie_setup(struct dw_pcie *pci)
        if (pci->n_fts[1]) {
                val = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL);
                val &= ~PORT_LOGIC_N_FTS_MASK;
-               val |= pci->n_fts[pci->link_gen - 1];
+               val |= pci->n_fts[1];
                dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
        }
 
--

2.17.1

#5 lore raw

Re: [PATCH V2] PCI: dwc: Fix n_fts[] array overrun

Quoted 13 lines · Han Jingoo

External email: Use caution opening links or attachments

Quoted 6 lines · Vidya Sagar

commit aeaa0bfe89654 ("PCI: dwc: Move N_FTS setup to common setup") incorrectly uses pci->link_gen in deriving the index to the n_fts[] array also introducing the issue of accessing beyond the boundaries of array for greater than Gen-2 speeds. This change fixes that issue.

Dear Vidya,

Quoted 8 lines

I am just ok with this patch. By the way, do we need another patch to generalize this setting? Currently, this code targets only Gen1 and Gen2. But, in my opinion,
it is possible that this driver can be used for more than Gen2, later. PCIe Gen6
standard is available and Synopsys has their solution for Gen6. So, would you send a new patch to generalize this thing, later?
Thank you.

As I mentioned in the commit message, current code is incorrectly using 'gen' in the index and ideally n_fts programming has nothing to do with the speed and hence I tried to remove the 'gen' reference in the current patch. So, the same code (after applying this patch) should work for any future Synopsys IP versions supporting higher speeds.

Thanks,
Vidya Sagar

Quoted 32 lines

Best regards,
Jingoo Han

Quoted 28 lines
Fixes aeaa0bfe8965 ("PCI: dwc: Move N_FTS setup to common setup")

---
V2:
* Addressed review comments from Bjorn
* Added "Acked-by: Jingoo Han <[email protected]>"

  drivers/pci/controller/dwc/pcie-designware.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-designware.c +1 -2
index 650a7f22f9d0..3df687667f27 100644
@@ -649,7 +649,7 @@ void dw_pcie_setup(struct dw_pcie *pci)
         if (pci->n_fts[1]) {
                 val = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL);
                 val &= ~PORT_LOGIC_N_FTS_MASK;
-               val |= pci->n_fts[pci->link_gen - 1];
+               val |= pci->n_fts[1];
                 dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
         }
 
--

2.17.1

maintainer
#6 lore raw

Re: [PATCH V2] PCI: dwc: Fix n_fts[] array overrun

Quoted 23 lines · On Wed, Sep 28, 2022 Vidya Sagar <[email protected]> wrote:
Quoted 13 lines · Han Jingoo

External email: Use caution opening links or attachments

Quoted 6 lines · Vidya Sagar

commit aeaa0bfe89654 ("PCI: dwc: Move N_FTS setup to common setup") incorrectly uses pci->link_gen in deriving the index to the n_fts[] array also introducing the issue of accessing beyond the boundaries of array for greater than Gen-2 speeds. This change fixes that issue.

Dear Vidya,

Quoted 8 lines

I am just ok with this patch. By the way, do we need another patch to generalize this setting? Currently, this code targets only Gen1 and Gen2. But, in my opinion,
it is possible that this driver can be used for more than Gen2, later. PCIe Gen6
standard is available and Synopsys has their solution for Gen6. So, would you send a new patch to generalize this thing, later?
Thank you.

Quoted 5 lines

As I mentioned in the commit message, current code is incorrectly using 'gen' in the index and ideally n_fts programming has nothing to do with the speed and hence I tried to remove the 'gen' reference in the current patch. So, the same code (after applying this patch) should work for any future Synopsys IP versions supporting higher speeds.

I see. Thank you for your confirmation.

Best regards,
Jingoo Han

Quoted 36 lines

Thanks,
Vidya Sagar

Quoted 32 lines

Best regards,
Jingoo Han

Quoted 28 lines
Fixes aeaa0bfe8965 ("PCI: dwc: Move N_FTS setup to common setup")

---
V2:
* Addressed review comments from Bjorn
* Added "Acked-by: Jingoo Han <[email protected]>"

  drivers/pci/controller/dwc/pcie-designware.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-designware.c +1 -2
index 650a7f22f9d0..3df687667f27 100644
@@ -649,7 +649,7 @@ void dw_pcie_setup(struct dw_pcie *pci)
         if (pci->n_fts[1]) {
                 val = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL);
                 val &= ~PORT_LOGIC_N_FTS_MASK;
-               val |= pci->n_fts[pci->link_gen - 1];
+               val |= pci->n_fts[1];
                 dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
         }
 
--

2.17.1

reviewer Reviewed-by on v2 1/1
#7 lore raw

Re: [PATCH V2] PCI: dwc: Fix n_fts[] array overrun

In reply to Vidya Sagar
Quoted 10 lines · Vidya Sagar

commit aeaa0bfe89654 ("PCI: dwc: Move N_FTS setup to common setup") incorrectly uses pci->link_gen in deriving the index to the n_fts[] array also introducing the issue of accessing beyond the boundaries of array for greater than Gen-2 speeds. This change fixes that issue.

Fixes aeaa0bfe8965 ("PCI: dwc: Move N_FTS setup to common setup")
Quoted 7 lines

---
V2:
* Addressed review comments from Bjorn
* Added "Acked-by: Jingoo Han <[email protected]>"

 drivers/pci/controller/dwc/pcie-designware.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#8 lore raw

Re: [PATCH V2] PCI: dwc: Fix n_fts[] array overrun

Hi Lorenzo,
Do you have any further comments for this patch?

Thanks,
Vidya Sagar

Quoted 24 lines · Rob Herring

External email: Use caution opening links or attachments

Quoted 10 lines · Vidya Sagar

commit aeaa0bfe89654 ("PCI: dwc: Move N_FTS setup to common setup") incorrectly uses pci->link_gen in deriving the index to the n_fts[] array also introducing the issue of accessing beyond the boundaries of array for greater than Gen-2 speeds. This change fixes that issue.

Fixes aeaa0bfe8965 ("PCI: dwc: Move N_FTS setup to common setup")
Quoted 7 lines

---
V2:
* Addressed review comments from Bjorn
* Added "Acked-by: Jingoo Han <[email protected]>"

  drivers/pci/controller/dwc/pcie-designware.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
maintainer Applied
#9 lore raw

Re: [PATCH V2] PCI: dwc: Fix n_fts[] array overrun

In reply to Vidya Sagar
Quoted 8 lines · Vidya Sagar

commit aeaa0bfe89654 ("PCI: dwc: Move N_FTS setup to common setup") incorrectly uses pci->link_gen in deriving the index to the n_fts[] array also introducing the issue of accessing beyond the boundaries of array for greater than Gen-2 speeds. This change fixes that issue.

[...]

Applied to pci/dwc, thanks!

[1/1] PCI: dwc: Fix n_fts[] array overrun

      https://git.kernel.org/lpieralisi/pci/c/66110361281b

Thanks,
Lorenzo