diff options
author | Mark Kettenis <kettenis@openbsd.org> | 2023-01-21 20:27:57 +0100 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-01-27 14:47:58 -0500 |
commit | 08386da0c65c5669a447f763ab4cd91d9efc7cd1 (patch) | |
tree | 222d72a09c35031b7cee499ffda32240d5cdc506 /test | |
parent | 1fc2329121e403a4d7dbffa4c4fda5a756043e4a (diff) | |
download | u-boot-08386da0c65c5669a447f763ab4cd91d9efc7cd1.tar.gz |
test: Add test for mapping IOMMUs for PCI devices
Test that we correctly probe an IOMMU that is mapped by an
"iommu-map" device tree property of a PCIe controller node.
Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/dm/iommu.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/dm/iommu.c b/test/dm/iommu.c index 6f932ef233..62d38f1214 100644 --- a/test/dm/iommu.c +++ b/test/dm/iommu.c @@ -68,3 +68,33 @@ static int dm_test_iommu_noiommu(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_iommu_noiommu, UT_TESTF_SCAN_FDT); + +static int dm_test_iommu_pci(struct unit_test_state *uts) +{ + struct udevice *dev; + + ut_assertok(uclass_find_device(UCLASS_IOMMU, 0, &dev)); + ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED)); + + /* Probing P2SB probes the IOMMU through the "iommu-map" property */ + ut_assertok(uclass_probe_all(UCLASS_P2SB)); + ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED); + + return 0; +} +DM_TEST(dm_test_iommu_pci, UT_TESTF_SCAN_FDT); + +static int dm_test_iommu_pci_noiommu(struct unit_test_state *uts) +{ + struct udevice *dev; + + ut_assertok(uclass_find_device(UCLASS_IOMMU, 0, &dev)); + ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED)); + + /* Probing PMC should not probe the IOMMU */ + ut_assertok(uclass_probe_all(UCLASS_ACPI_PMC)); + ut_assert(!(dev_get_flags(dev) & DM_FLAG_ACTIVATED)); + + return 0; +} +DM_TEST(dm_test_iommu_pci_noiommu, UT_TESTF_SCAN_FDT); |