Re: [PATCH 11/13] PCI/P2PDMA: Add KUnit tests for ACS routing decisions
From: Logan Gunthorpe
Date: Tue Aug 04 2026 - 18:38:14 EST
On 2026-08-02 09:09, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@xxxxxxxxxx>
>
> Add a KUnit suite exercising the ACS peer-to-peer routing logic:
>
> - pci_acs_p2pdma_decision(): the full PCIe table 6-11 truth table,
> including the Egress Control Vector branches (bit set/clear, with and
> without Request Redirect and Completion Redirect) that require a
> switch implementing the Egress Control Vector and so cannot be
> reached on commonly available hardware.
>
> - pci_acs_egress_port_valid(): the vector-size boundary, including the
> "size 0 encodes 256 bits" case.
>
> - pci_acs_egress_ctrl_set(): driven through a fake pci_ops returning
> canned config space, covering target Port Number extraction from
> LNKCAP, the vector DWORD offset (target_port / 32), the bit position
> (target_port % 32), the -ERANGE bound, and the unsupported-port
> guards -- all without real hardware.
>
> Run with:
>
> cat > /tmp/pci-acs.kunitconfig <<'EOF'
> CONFIG_KUNIT=y
> CONFIG_PCI=y
> CONFIG_ZONE_DEVICE=y
> CONFIG_MEMORY_HOTPLUG=y
> CONFIG_MEMORY_HOTREMOVE=y
> CONFIG_SPARSEMEM_VMEMMAP=y
> CONFIG_PCI_P2PDMA=y
> CONFIG_PCI_ACS_KUNIT_TEST=y
> EOF
>
> ./tools/testing/kunit/kunit.py run --arch=x86_64 \
> --kunitconfig=/tmp/pci-acs.kunitconfig --jobs=$(nproc) pci_acs
>
> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx>
> Assisted-by: Claude Opus 4.8 <noreply@xxxxxxxxxxxxx>
Great, I like having Kunit tests for this kind of things. Thanks!
Reviewd-by: Logan Gunthorpe <logang@xxxxxxxxxxxx>