yangsong8-a1 opened a new pull request, #22152:
URL: https://github.com/apache/nuttx/pull/22152
## Summary
Support more than one PCI domain (segment), with one /dev/pci for all of
them.
- struct pci_controller_s gets a domain number, and pci_ecam_register()
takes it as a new first argument.
- fdt_pci_ecam_register() registers every "pci-host-ecam-generic" node,
using its "linux,pci-domain" property, instead of only the first one.
fdt_pci_ecam_register_domain() registers a single domain.
- The /dev/pci ioctls select the controller by its domain number instead
of its position in the controller list. When no controller has the
requested domain they now return an error; before, an out-of-range
pc_domain used the list head as a controller.
- pci_ecam_get_irq() passes PCI_SBDF(domain, bus, devfn) to
up_get_legacy_irq(). PCI_SLOT() of that value is the same as of devfn,
so the GICv2 INTx mapping is unchanged.
## Impact
pci_ecam_register() has a new argument; its only in-tree caller,
fdt_pci_ecam_register(), is updated. The boards that call
fdt_pci_ecam_register() are unchanged. An ECAM node without a
"linux,pci-domain" property is now rejected (QEMU's virt DTB has it).
## Testing
Ubuntu 22.04, aarch64-none-elf-gcc 13.2.Rel1. qemu-armv8a:nsh with PCI,
PCI_QEMU_EDU and PCI debug output, GICv2 (ARM64_GIC_VERSION=2), CMake
build with no new warnings.
Upstream QEMU's virt machine has one PCIe host. These runs use our
QEMU 10.2.1 build, whose virt machine takes `npd=<n>` and adds n ECAM
hosts with linux,pci-domain 0..n-1 to the DTB. With npd=2 the domain 1
node comes first in the DTB. A test program reads the vendor/device ID
of devices 0-3 on bus 0 of domains 0 and 1 through PCIOCREAD on
/dev/pci.
qemu-system-aarch64 -nic none -cpu cortex-a53 -nographic
-machine virt,virtualization=on,gic-version=2,npd=2
-device edu,bus=pcie.0 -kernel nuttx
master: only the first ECAM node (domain 1) is scanned, so the EDU device
in domain 0 is not found; /dev/pci domain 0 is the first registered host
and domain 1 crashes:
pci_scan_bus: 00:00 [1b36:0008]
0000:00:00.0 1b36:0008
arm64_exception_handler: FAR_ELn: 0x0
dump_assert_info: Assertion failed panic: at file:
/arch/arm64/src/common/arm64_fatal.c:696 task: hello process: hello 0x402bb8ac
With this change both hosts are scanned, the EDU driver tests (polling,
INTx, DMA) pass on domain 0, and /dev/pci gives the right devices for
both domains:
pci_scan_bus: 00:00 [1b36:0008]
pci_scan_bus: 00:00 [1b36:0008]
pci_scan_bus: 00:08 [1234:11e8]
pci_qemu_edu_test_poll: TEST PASS
pci_qemu_edu_test_poll: TEST PASS
pci_qemu_edu_test_intx: TEST PASS
pci_qemu_edu_test_intx: TEST PASS
pci_qemu_edu_test_intx: TEST PASS
pci_qemu_edu_test_dma: TEST PASS
0000:00:00.0 1b36:0008
0000:00:01.0 1234:11e8
0001:00:00.0 1b36:0008
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]