Kernel PCIe主机控制器驱动程序-资源分配问题

Kernel PCIe主机控制器驱动程序-资源分配问题,kernel,device-driver,pci,Kernel,Device Driver,Pci,我正在开发基于Synopsys DW IP的PCIe主机控制器驱动程序。这是基于x86的,这里没有BIOS编程。 因此,我需要以ARM方式进行初始化编码,这可以在arch/ARM/kernel/bios32.c上找到。 我正在重用主线3.14内核中提供的drivers/pci/host/pcie designware.c驱动程序。 我的端点(EP)设备需要在BAR0/1和BAR2/3寄存器中设置两个4K的内存空间,作为不可预取寄存器 现在,我可以枚举总线1上的EP设备,我可以读取设备/供应商ID

我正在开发基于Synopsys DW IP的PCIe主机控制器驱动程序。这是基于x86的,这里没有BIOS编程。 因此,我需要以ARM方式进行初始化编码,这可以在arch/ARM/kernel/bios32.c上找到。 我正在重用主线3.14内核中提供的drivers/pci/host/pcie designware.c驱动程序。 我的端点(EP)设备需要在BAR0/1和BAR2/3寄存器中设置两个4K的内存空间,作为不可预取寄存器

现在,我可以枚举总线1上的EP设备,我可以读取设备/供应商ID、类和功能。但无法看到EP上的条正确编程

在DT文件中,对于范围,我提供了一个作为IO mem的内存和一个作为mem空间的内存,如下所示:

  #address-cells = <3>;
#size-cells = <2>;
ranges = <0x00000800 0 0xe4480000 0xe4480000 0 0x00002000 /* configuration space */
      0x81000000 0 0          0xe4482000 0 0x00001000 /* downstream I/O */
      0x82000000 0 0xe2083000 0xe4483000 0 0x00001000>; /* non-prefetchable memory */
/sys/bus/pci # lspci
00:00.0 Class 0604: f00d:8087
01:00.0 Class 0d40: d00f:8086
[  123.710000] pci 0000:01:00.0: [d00f:8086] type 00 class 0x0d4000
**[  123.710000] pci 0000:01:00.0: reg 0x10: [mem 0x00000000-0x00000fff 64bit]
[  123.710000] pci 0000:01:00.0: reg 0x18: [mem 0x00000000-0x000000ff 64bit]
[  123.710000] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x00000fff]
[  123.710000] pci 0000:01:00.0: reg 0x24: [mem 0x00000000-0x0000ffff]
[  123.710000] pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x000007ff pref]**
[  123.710000] pci 0000:01:00.0: supports D1
[  123.710000] pci 0000:01:00.0: PME# supported from D0 D1 D3hot D3cold
[  123.710000] pci 0000:01:00.0: PME# disabled
[  125.230000] pci_bus 0000:01: bus scan returning with max=01
[  125.230000] pci 0000:00:00.0: scanning [bus 01-01] behind bridge, pass 1
[  125.230000] pci_bus 0000:00: bus scan returning with max=01
[  125.230000] pci 0000:01:00.0: BAR 5: can't assign mem (size 0x10000)
[  125.230000] pci 0000:01:00.0: BAR 0: can't assign mem (size 0x1000)
[  125.230000] pci 0000:01:00.0: BAR 4: can't assign mem (size 0x1000)
[  125.230000] pci 0000:01:00.0: BAR 6: can't assign mem pref (size 0x800)
[  125.230000] pci 0000:01:00.0: BAR 2: can't assign mem (size 0x100)
[  125.230000] pci 0000:00:00.0: not setting up bridge for bus 0000:01
我觉得,我可以在我的驱动程序中硬编码这些条形码编程,并且仍然可以工作。 但是我想适当地分配这些资源,以便pci驱动程序(与EP通信的测试驱动程序)能够使用pci_dev及其资源来提取所有这些信息,而无需硬编码

扫描总线1时,我的dmesg如下所示:

  #address-cells = <3>;
#size-cells = <2>;
ranges = <0x00000800 0 0xe4480000 0xe4480000 0 0x00002000 /* configuration space */
      0x81000000 0 0          0xe4482000 0 0x00001000 /* downstream I/O */
      0x82000000 0 0xe2083000 0xe4483000 0 0x00001000>; /* non-prefetchable memory */
/sys/bus/pci # lspci
00:00.0 Class 0604: f00d:8087
01:00.0 Class 0d40: d00f:8086
[  123.710000] pci 0000:01:00.0: [d00f:8086] type 00 class 0x0d4000
**[  123.710000] pci 0000:01:00.0: reg 0x10: [mem 0x00000000-0x00000fff 64bit]
[  123.710000] pci 0000:01:00.0: reg 0x18: [mem 0x00000000-0x000000ff 64bit]
[  123.710000] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x00000fff]
[  123.710000] pci 0000:01:00.0: reg 0x24: [mem 0x00000000-0x0000ffff]
[  123.710000] pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x000007ff pref]**
[  123.710000] pci 0000:01:00.0: supports D1
[  123.710000] pci 0000:01:00.0: PME# supported from D0 D1 D3hot D3cold
[  123.710000] pci 0000:01:00.0: PME# disabled
[  125.230000] pci_bus 0000:01: bus scan returning with max=01
[  125.230000] pci 0000:00:00.0: scanning [bus 01-01] behind bridge, pass 1
[  125.230000] pci_bus 0000:00: bus scan returning with max=01
[  125.230000] pci 0000:01:00.0: BAR 5: can't assign mem (size 0x10000)
[  125.230000] pci 0000:01:00.0: BAR 0: can't assign mem (size 0x1000)
[  125.230000] pci 0000:01:00.0: BAR 4: can't assign mem (size 0x1000)
[  125.230000] pci 0000:01:00.0: BAR 6: can't assign mem pref (size 0x800)
[  125.230000] pci 0000:01:00.0: BAR 2: can't assign mem (size 0x100)
[  125.230000] pci 0000:00:00.0: not setting up bridge for bus 0000:01
我对PCIE非常陌生,在实现PCIE的同时进行学习。 非常感谢您的建议或指点