]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: Add test for mapping IOMMUs for PCI devices
authorMark Kettenis <kettenis@openbsd.org>
Sat, 21 Jan 2023 19:27:57 +0000 (20:27 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 27 Jan 2023 19:47:58 +0000 (14:47 -0500)
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>
arch/sandbox/dts/test.dts
test/dm/iommu.c

index 9d96e479ca82a180cb0cb1ae5af026efc4f52f6a..8c0592767029fa63927bda49fbd466226e738875 100644 (file)
                #size-cells = <2>;
                ranges = <0x02000000 0 0x10000000 0x10000000 0 0x2000000
                                0x01000000 0 0x20000000 0x20000000 0 0x2000>;
+               iommu-map = <0x0010 &iommu 0 1>;
+               iommu-map-mask = <0xfffffff8>;
                pci@0,0 {
                        compatible = "pci-generic";
                        reg = <0x0000 0 0 0 0>;
index 6f932ef233fa092dc181c93dde85e6ae35415004..62d38f1214ac7fee52b6adc1330456b095ffa3eb 100644 (file)
@@ -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);