PCI: keystone: Fix outbound region mapping
diff mbox series

Message ID 20191004154811.GA31397@monakov-y.office.kontur-niirs.ru
State New
Delegated to: Lorenzo Pieralisi
Headers show
Series
  • PCI: keystone: Fix outbound region mapping
Related show

Commit Message

Yurii Monakov Oct. 4, 2019, 3:48 p.m. UTC
PCIe window memory start address should be incremented by OB_WIN_SIZE
megabytes (8 MB) instead of plain OB_WIN_SIZE (8).

Signed-off-by: Yurii Monakov <monakov.y@gmail.com>
---
 drivers/pci/controller/dwc/pci-keystone.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Murray Oct. 4, 2019, 4:05 p.m. UTC | #1
On Fri, Oct 04, 2019 at 06:48:11PM +0300, Yurii Monakov wrote:
> PCIe window memory start address should be incremented by OB_WIN_SIZE
> megabytes (8 MB) instead of plain OB_WIN_SIZE (8).
> 
> Signed-off-by: Yurii Monakov <monakov.y@gmail.com>
> ---
>  drivers/pci/controller/dwc/pci-keystone.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c
> index af677254a072..f19de60ac991 100644
> --- a/drivers/pci/controller/dwc/pci-keystone.c
> +++ b/drivers/pci/controller/dwc/pci-keystone.c
> @@ -422,7 +422,7 @@ static void ks_pcie_setup_rc_app_regs(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 * SZ_1M;

This looks fine, however are the earlier lines still correct?

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

Thanks,

Andrew Murray

>  	}
>  
>  	val = ks_pcie_app_readl(ks_pcie, CMD_STATUS);
> -- 
> 2.17.1
>
Yurii Monakov Oct. 4, 2019, 4:37 p.m. UTC | #2
> This looks fine, however are the earlier lines still correct?
Yes, according to TI Keystone PCIe datasheet pg. 3-10 OB_SIZE
register should hold log2 of actual window size in MB (bits 2-0):

0h = 1MB
1h = 2MB
2h = 4MB
3h = 8MB

But OB_OFFSET_INDEXn/OB_OFFSETn_HI register pair hold absolute
64-bit bus address, so 'start' variable sholud be incremented
by 8M to map all PCIe data space (according to the comment above
the loop).

TI confirms this bug for for kernel v4.14, but since then
some driver code relocation happend and I've decided to
report this here.

Regards,
Yurii

Patch
diff mbox series

diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c
index af677254a072..f19de60ac991 100644
--- a/drivers/pci/controller/dwc/pci-keystone.c
+++ b/drivers/pci/controller/dwc/pci-keystone.c
@@ -422,7 +422,7 @@  static void ks_pcie_setup_rc_app_regs(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 * SZ_1M;
 	}
 
 	val = ks_pcie_app_readl(ks_pcie, CMD_STATUS);