Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3552

Ubuntu • Re: BAR of PCIe devices seems incorrect

$
0
0
PCIe addressing is quite complex, involving multiple mappings - it's easy to get confused. This is how it is meant to work:

1. The address shown in a pci_resource_start is the physical address of the external PCIe device. This address is inside an "outbound window", and can be thought of as part of the PCIe RC hardware. Any accesses to that address will be routed to or from the appropriate BAR on that device. When it gets there, the device will see an access at a particular PCIe address, which it translates into an offset into a particular BAR. It does not see the potentially large address that the host/Root Complex sees - the addressing worlds are independent. It therefore doesn't matter that the host's view of the physical address doesn't fit into a 32-bit window, as long as the PCIe address does.

2. If the device is a bus master, it may generate read or write accesses to 32-bit PCIe addresses. The RC may declare some "inbound windows" - mappings from PCIe addresses to system physical addresses. The most common outbound windows map system RAM or an MSI-X target into PCIe space, but there may be others.

Posting the entire output of "dmesg | grep pci" would help.

Thank you so much for your response.
Yes, my device is a bus master which has DMA transfer function. Are there any special methods to read the BAR correctly?

Here is the output of "dmesg | grep pci". 0000:02:00.0 is my PCIe device.
--
[ 0.000000] Kernel command line: reboot=w coherent_pool=1M 8250.nr_uarts=1 pci=pcie_bus_safe snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 smsc95xx.macaddr=2C:CF:67:31:7C:FD vc_mem.mem_base=0x3fc00000 vc_mem.mem_size=0x40000000 zswap.enabled=1 zswap.zpool=z3fold zswap.compressor=zstd multipath=off dwc_otg.lpm_enable=0 console=tty1 root=LABEL=writable rootfstype=ext4 rootwait fixrtc quiet splash
[ 0.559176] brcm-pcie 1000110000.pcie: host bridge /axi/pcie@110000 ranges:
[ 0.559190] brcm-pcie 1000110000.pcie: No bus range found for /axi/pcie@110000, using [bus 00-ff]
[ 0.559210] brcm-pcie 1000110000.pcie: MEM 0x1b00000000..0x1bfffffffb -> 0x0000000000
[ 0.559222] brcm-pcie 1000110000.pcie: MEM 0x1800000000..0x1affffffff -> 0x0400000000
[ 0.559233] brcm-pcie 1000110000.pcie: IB MEM 0x0000000000..0x0fffffffff -> 0x1000000000
[ 0.560491] brcm-pcie 1000110000.pcie: Forcing gen 2
[ 0.570704] brcm-pcie 1000110000.pcie: PCI host bridge to bus 0000:00
[ 0.570714] pci_bus 0000:00: root bus resource [bus 00-ff]
[ 0.570719] pci_bus 0000:00: root bus resource [mem 0x1b00000000-0x1bfffffffb] (bus address [0x00000000-0xfffffffb])
[ 0.570722] pci_bus 0000:00: root bus resource [mem 0x1800000000-0x1affffffff pref] (bus address [0x400000000-0x6ffffffff])
[ 0.570739] pci 0000:00:00.0: [14e4:2712] type 01 class 0x060400 PCIe Root Port
[ 0.570750] pci 0000:00:00.0: PCI bridge to [bus 00]
[ 0.570754] pci 0000:00:00.0: bridge window [mem 0x1b00000000-0x1b000fffff]
[ 0.570759] pci 0000:00:00.0: bridge window [mem 0x1b00000000-0x1b000fffff 64bit pref]
[ 0.570790] pci 0000:00:00.0: PME# supported from D0 D3hot
[ 0.580301] pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[ 0.688548] brcm-pcie 1000110000.pcie: clkreq-mode set to default
[ 0.688560] brcm-pcie 1000110000.pcie: link up, 2.5 GT/s PCIe x1 (!SSC)
[ 0.688604] pci 0000:01:00.0: [104c:8240] type 01 class 0x060400 PCIe to PCI/PCI-X bridge
[ 0.688644] pci 0000:01:00.0: PCI bridge to [bus 00]
[ 0.688658] pci 0000:01:00.0: bridge window [io 0x0000-0x0fff]
[ 0.688666] pci 0000:01:00.0: bridge window [mem 0x1b00000000-0x1b000fffff]
[ 0.688684] pci 0000:01:00.0: bridge window [mem 0x1b00000000-0x1b000fffff 64bit pref]
[ 0.688794] pci 0000:01:00.0: supports D1 D2
[ 0.691556] pci 0000:01:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[ 0.691636] pci_bus 0000:02: extended config space not accessible
[ 0.692685] pci_bus 0000:02: busn_res: [bus 02-ff] end is updated to 02
[ 0.692696] pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 02
[ 0.692707] pci 0000:01:00.0: PCI bridge to [bus 02]
[ 0.692723] pci 0000:00:00.0: PCI bridge to [bus 01-02]
[ 0.692732] pci 0000:00:00.0: Max Payload Size set to 512/ 512 (was 128), Max Read Rq 512
[ 0.692745] pci 0000:01:00.0: Max Payload Size set to 512/ 512 (was 128), Max Read Rq 512
[ 0.693025] pcieport 0000:00:00.0: PME: Signaling with IRQ 42
[ 0.693170] pcieport 0000:00:00.0: AER: enabled with IRQ 42
[ 0.693595] brcm-pcie 1000120000.pcie: host bridge /axi/pcie@120000 ranges:
[ 0.693603] brcm-pcie 1000120000.pcie: No bus range found for /axi/pcie@120000, using [bus 00-ff]
[ 0.693626] brcm-pcie 1000120000.pcie: MEM 0x1f00000000..0x1ffffffffb -> 0x0000000000
[ 0.693640] brcm-pcie 1000120000.pcie: MEM 0x1c00000000..0x1effffffff -> 0x0400000000
[ 0.693663] brcm-pcie 1000120000.pcie: IB MEM 0x1f00000000..0x1f003fffff -> 0x0000000000
[ 0.693676] brcm-pcie 1000120000.pcie: IB MEM 0x0000000000..0x0fffffffff -> 0x1000000000
[ 0.694790] brcm-pcie 1000120000.pcie: Forcing gen 2
[ 0.694863] brcm-pcie 1000120000.pcie: PCI host bridge to bus 0001:00
[ 0.694871] pci_bus 0001:00: root bus resource [bus 00-ff]
[ 0.694876] pci_bus 0001:00: root bus resource [mem 0x1f00000000-0x1ffffffffb] (bus address [0x00000000-0xfffffffb])
[ 0.694881] pci_bus 0001:00: root bus resource [mem 0x1c00000000-0x1effffffff pref] (bus address [0x400000000-0x6ffffffff])
[ 0.694899] pci 0001:00:00.0: [14e4:2712] type 01 class 0x060400 PCIe Root Port
[ 0.694915] pci 0001:00:00.0: PCI bridge to [bus 00]
[ 0.694921] pci 0001:00:00.0: bridge window [mem 0x1ff8000000-0x1ff80fffff]
[ 0.694969] pci 0001:00:00.0: PME# supported from D0 D3hot
[ 0.695993] pci 0001:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[ 0.800549] brcm-pcie 1000120000.pcie: clkreq-mode set to default
[ 0.800556] brcm-pcie 1000120000.pcie: link up, 5.0 GT/s PCIe x4 (!SSC)
[ 0.800584] pci 0001:01:00.0: [1de4:0001] type 00 class 0x020000 PCIe Endpoint
[ 0.800603] pci 0001:01:00.0: BAR 0 [mem 0xffffc000-0xffffffff]
[ 0.800613] pci 0001:01:00.0: BAR 1 [mem 0xffc00000-0xffffffff]
[ 0.800622] pci 0001:01:00.0: BAR 2 [mem 0xffff0000-0xffffffff]
[ 0.800712] pci 0001:01:00.0: supports D1
[ 0.800716] pci 0001:01:00.0: PME# supported from D0 D1 D3hot D3cold
[ 0.803561] pci_bus 0001:01: busn_res: [bus 01-ff] end is updated to 01
[ 0.803576] pci 0001:00:00.0: bridge window [mem 0x1f00000000-0x1f005fffff]: assigned
[ 0.803582] pci 0001:01:00.0: BAR 1 [mem 0x1f00000000-0x1f003fffff]: assigned
[ 0.803588] pci 0001:01:00.0: BAR 2 [mem 0x1f00400000-0x1f0040ffff]: assigned
[ 0.803594] pci 0001:01:00.0: BAR 0 [mem 0x1f00410000-0x1f00413fff]: assigned
[ 0.803599] pci 0001:00:00.0: PCI bridge to [bus 01]
[ 0.803604] pci 0001:00:00.0: bridge window [mem 0x1f00000000-0x1f005fffff]
[ 0.803613] pci 0001:00:00.0: Max Payload Size set to 256/ 512 (was 128), Max Read Rq 512
[ 0.803623] pci 0001:01:00.0: Max Payload Size set to 256/ 256 (was 128), Max Read Rq 512
[ 0.803833] pcieport 0001:00:00.0: enabling device (0000 -> 0002)
[ 0.803898] pcieport 0001:00:00.0: PME: Signaling with IRQ 43
[ 0.804830] pcieport 0001:00:00.0: AER: enabled with IRQ 43
[ 1.427920] input: Logitech USB Optical Mouse as /devices/platform/axi/1000120000.pcie/1f00200000.usb/xhci-hcd.0/usb2/2-2/2-2:1.0/0003:046D:C077.0001/input/input2
[ 1.446219] input: Dell Dell USB Keyboard as /devices/platform/axi/1000120000.pcie/1f00300000.usb/xhci-hcd.1/usb4/4-2/4-2:1.0/0003:413C:2003.0002/input/input3
[ 30.998970] pci 0000:02:00.0: [(vendor ID):0ce0] type 00 class 0x028000 conventional PCI endpoint
[ 30.999002] pci 0000:02:00.0: BAR 0 [mem 0x1b00000000-0x1b0003ffff]
[ 31.000117] pcieport 0000:00:00.0: bridge window [mem 0x1b00000000-0x1b000fffff]: assigned
[ 31.000126] pci 0000:01:00.0: bridge window [mem 0x1b00000000-0x1b000fffff]: assigned
[ 31.000129] pci 0000:02:00.0: BAR 0 [mem 0x1b00000000-0x1b0003ffff]: assigned
[ 31.000136] pci 0000:01:00.0: PCI bridge to [bus 02]
[ 31.000142] pci 0000:01:00.0: bridge window [mem 0x1b00000000-0x1b000fffff]
[ 283.109145] (my device driver) 0000:02:00.0: of_irq_parse_pci: failed with rc=-22
[ 283.109164] pci 0000:01:00.0: enabling device (0000 -> 0002)
[ 283.109470] pci_device_probe+0xa8/0x190
[ 283.109504] __pci_register_driver+0x54/0x68

Statistics: Posted by mrtmm — Wed Jun 12, 2024 3:50 am



Viewing all articles
Browse latest Browse all 3552

Trending Articles