This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/PROCESSOR-SDK-K2L: Bug in PCIe driver (drivers/pci/dwc/pci-keystone.c)

Part Number: PROCESSOR-SDK-K2L

Tool/software: Linux

Hi All!

I've found bug in Keystone II PCIe driver. Looking at the function ks_pcie_setup_mem_space (drivers/pci/dwc/pci-keystone.c:601 in PSDK 05.01.00.11):

val = ilog2(OB_WIN_SIZE);
ks_pcie_app_writel(ks_pcie, OB_SIZE, val);

/* Using Direct 1:1 mapping of RC <-> PCI memory space */
for (i = 0; i < num_ob_windows && (start < end); i++) {
    ks_pcie_app_writel(ks_pcie, OB_OFFSET_INDEX(i),
                       lower_32_bits(start) | OB_ENABLEN);
    ks_pcie_app_writel(ks_pcie, OB_OFFSET_HI(i),
                       upper_32_bits(start));
    start += OB_WIN_SIZE;
}

Here OB_WIN_SIZE is declared as 8, so outbound index start address is incremented by 8 instead of 8M.

Consider following patch:

diff --git a/drivers/pci/dwc/pci-keystone.c b/drivers/pci/dwc/pci-keystone.c
index be1b23e2eee..6f2294fe204 100644
--- a/drivers/pci/dwc/pci-keystone.c
+++ b/drivers/pci/dwc/pci-keystone.c
@@ -623,7 +623,7 @@ static void ks_pcie_setup_mem_space(struct keystone_pcie *ks_pcie)
                                   lower_32_bits(start) | OB_ENABLEN);
                ks_pcie_app_writel(ks_pcie, OB_OFFSET_HI(i),
                                   upper_32_bits(start));
-               start += OB_WIN_SIZE;
+               start += (OB_WIN_SIZE << 20);
        }
 
        val = ks_pcie_app_readl(ks_pcie, CMD_STATUS);

Best Regards,

Yurii