PCI: dwc: Fixes N_FTS setup
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.
--- drivers/pci/controller/dwc/pcie-designware.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-designware.c +1 -1
@@ -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
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: MoveN_FTSsetup to common setup") unnecessarily usespci->link_genin 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")Signed-off-by Vidya Sagar <[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@@ -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
Quoted 9 lines · Vidya Sagar
commit
aeaa0bfe89654("PCI: dwc: MoveN_FTSsetup to common setup") unnecessarily usespci->link_genin 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")Signed-off-by Vidya Sagar <[email protected]>
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@@ -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
PATCH v2 1/1 PCI: dwc: Fix n_fts[] array overrun
In reply to Vidya Sagarcommit 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.
---
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
@@ -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
Han Jingoo
maintainerRe: [PATCH V2] PCI: dwc: Fix n_fts[] array overrun
Quoted 6 lines · Vidya Sagar
commit
aeaa0bfe89654("PCI: dwc: MoveN_FTSsetup to common setup") incorrectly usespci->link_genin 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")Signed-off-by Vidya Sagar <[email protected]>Acked-by Jingoo Han <[email protected]>---
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@@ -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
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: MoveN_FTSsetup to common setup") incorrectly usespci->link_genin 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 HanQuoted 28 lines
Fixes aeaa0bfe8965 ("PCI: dwc: Move N_FTS setup to common setup")Signed-off-by Vidya Sagar <[email protected]>Acked-by Jingoo Han <[email protected]>---
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@@ -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
Han Jingoo
maintainerRe: [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: MoveN_FTSsetup to common setup") incorrectly usespci->link_genin 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_ftsprogramming 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 SagarQuoted 32 lines
Best regards,
Jingoo HanQuoted 28 lines
Fixes aeaa0bfe8965 ("PCI: dwc: Move N_FTS setup to common setup")Signed-off-by Vidya Sagar <[email protected]>Acked-by Jingoo Han <[email protected]>---
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@@ -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
Re: [PATCH V2] PCI: dwc: Fix n_fts[] array overrun
In reply to Vidya SagarQuoted 10 lines · Vidya Sagar
commit
aeaa0bfe89654("PCI: dwc: MoveN_FTSsetup to common setup") incorrectly usespci->link_genin 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")Signed-off-by Vidya Sagar <[email protected]>Acked-by Jingoo Han <[email protected]>
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(-)
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: MoveN_FTSsetup to common setup") incorrectly usespci->link_genin 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")Signed-off-by Vidya Sagar <[email protected]>Acked-by Jingoo Han <[email protected]>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(-)Reviewed-by Rob Herring <[email protected]>
Re: [PATCH V2] PCI: dwc: Fix n_fts[] array overrun
In reply to Vidya SagarQuoted 8 lines · Vidya Sagar
commit
aeaa0bfe89654("PCI: dwc: MoveN_FTSsetup to common setup") incorrectly usespci->link_genin 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