Tool/software:
In our product based on AM6442 we see unexpected PCIe BAR assignment error when Linux Kernel is booting, the failure seams to not be severe as the attached PCIe end-point is working as expected. Nevertheless, since we are designing and developing robust products for industrial purposes we aim to do a exact root cause and understand this failure.
Our initial investigation is telling us that this failure is coming as a consequence of the dma-ranges definition of the PCIe node (pcie0_rc) in the k3-am64-main.dtsi description, the dma-ranges is defined as "dma-ranges = <0x02000000 0x0 0x0 0x0 0x0 0x00000010 0x0>" this definition expects to map 64GB address space and auf course on our system with 1GB of RAM this is failing. The reason that this is still working is that Linux Kernel PCIe stack is deciding to ignore and recycle such bogus allocations.
Can you please explain us the reason behind this dma-ranges entry, and where is this expected to be mapped on the parent bus? Also when looking into the used cadence driver (drivers/pci/controller/cadence/pcie-cadence-host.c) one can see that dma-ranges and cdns,no-bar-match-nbits properties are mutually exclusive so one of them is not needed and indeed if for example we remove the dma-ranges property the PCIe is still working as expected and the BAR 0 assignment error is not there.
Logs snipped:
Case when dma-ranges is present:
[ 1.553386] j721e-pcie f102000.pcie: host bridge /bus@f4000/pcie@f102000 ranges:
[ 1.560120] mmcblk0: p1
[ 1.565353] j721e-pcie f102000.pcie: IO 0x0068001000..0x0068010fff -> 0x0068001000
[ 1.568960] mmcblk0boot0: mmc0:0001 DG4008 4.00 MiB
[ 1.575944] j721e-pcie f102000.pcie: MEM 0x0068011000..0x006fffffff -> 0x0068011000
[ 1.582266] mmcblk0boot1: mmc0:0001 DG4008 4.00 MiB
[ 1.588928] j721e-pcie f102000.pcie: IB MEM 0x0000000000..0x00ffffffff -> 0x0000000000
[ 1.595361] mmcblk0rpmb: mmc0:0001 DG4008 4.00 MiB, chardev (243:0)
[ 1.811743] j721e-pcie f102000.pcie: Link up
[ 1.816568] j721e-pcie f102000.pcie: PCI host bridge to bus 0000:00
[ 1.822874] pci_bus 0000:00: root bus resource [bus 00-ff]
[ 1.828366] pci_bus 0000:00: root bus resource [io 0x0000-0xffff] (bus address [0x68001000-0x68010fff])
[ 1.837858] pci_bus 0000:00: root bus resource [mem 0x68011000-0x6fffffff]
[ 1.844766] pci 0000:00:00.0: [104c:b010] type 01 class 0x060400
[ 1.850782] pci 0000:00:00.0: reg 0x10: [mem 0x00000000-0xffffffff 64bit pref]
[ 1.858078] pci 0000:00:00.0: supports D1
[ 1.862086] pci 0000:00:00.0: PME# supported from D0 D1 D3hot
[ 1.869889] pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[ 1.878099] pci 0000:01:00.0: [17cb:1109] type 00 class 0x028000
[ 1.884153] pci 0000:01:00.0: reg 0x10: [mem 0x00000000-0x001fffff 64bit]
[ 1.891193] pci 0000:01:00.0: PME# supported from D0 D3hot D3cold
[ 1.897368] pci 0000:01:00.0: 4.000 Gb/s available PCIe bandwidth, limited by 5.0 GT/s PCIe x1 link at 0000:00:00.0 (capable of 15.752 Gb/s with 8.0 GT/s PCIe x2 link)
[ 1.923745] pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 01
[ 1.930413] pci 0000:00:00.0: BAR 0: no space for [mem size 0x100000000 64bit pref]
[ 1.938071] pci 0000:00:00.0: BAR 0: failed to assign [mem size 0x100000000 64bit pref]
[ 1.946074] pci 0000:00:00.0: BAR 8: assigned [mem 0x68200000-0x683fffff]
[ 1.952862] pci 0000:01:00.0: BAR 0: assigned [mem 0x68200000-0x683fffff 64bit]
[ 1.960186] pci 0000:00:00.0: PCI bridge to [bus 01]
[ 1.965150] pci 0000:00:00.0: bridge window [mem 0x68200000-0x683fffff]
Case when dma-ranges is removed:
[ 1.580175] j721e-pcie f102000.pcie: host bridge /bus@f4000/pcie@f102000 ranges:
[ 1.587659] j721e-pcie f102000.pcie: IO 0x0068001000..0x0068010fff -> 0x0068001000
[ 1.595758] j721e-pcie f102000.pcie: MEM 0x0068011000..0x006fffffff -> 0x0068011000
[ 1.815096] j721e-pcie f102000.pcie: Link up
[ 1.819921] j721e-pcie f102000.pcie: PCI host bridge to bus 0000:00
[ 1.826230] pci_bus 0000:00: root bus resource [bus 00-ff]
[ 1.831740] pci_bus 0000:00: root bus resource [io 0x0000-0xffff] (bus address [0x68001000-0x68010fff])
[ 1.841211] pci_bus 0000:00: root bus resource [mem 0x68011000-0x6fffffff]
[ 1.848117] pci 0000:00:00.0: [104c:b010] type 01 class 0x060400
[ 1.854209] pci 0000:00:00.0: supports D1
[ 1.858221] pci 0000:00:00.0: PME# supported from D0 D1 D3hot
[ 1.866014] pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[ 1.874206] pci 0000:01:00.0: [17cb:1109] type 00 class 0x028000
[ 1.880259] pci 0000:01:00.0: reg 0x10: [mem 0x00000000-0x001fffff 64bit]
[ 1.887298] pci 0000:01:00.0: PME# supported from D0 D3hot D3cold
[ 1.893473] pci 0000:01:00.0: 4.000 Gb/s available PCIe bandwidth, limited by 5.0 GT/s PCIe x1 link at 0000:00:00.0 (capable of 15.752 Gb/s with 8.0 GT/s PCIe x2 link)
[ 1.919114] pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 01
[ 1.925772] pci 0000:00:00.0: BAR 8: assigned [mem 0x68200000-0x683fffff]
[ 1.932581] pci 0000:01:00.0: BAR 0: assigned [mem 0x68200000-0x683fffff 64bit]
[ 1.939905] pci 0000:00:00.0: PCI bridge to [bus 01]
[ 1.944869] pci 0000:00:00.0: bridge window [mem 0x68200000-0x683fffff]
Thanks in advance for your valuable support!
Regards,
Aleksandar