]> Gentwo Git Trees - linux/.git/commitdiff
iommu/io-pgtable-arm-selftests: Modularize the test
authorMostafa Saleh <smostafa@google.com>
Mon, 3 Nov 2025 12:33:51 +0000 (12:33 +0000)
committerJoerg Roedel <joerg.roedel@amd.com>
Thu, 13 Nov 2025 15:25:32 +0000 (16:25 +0100)
Remove the __init constraint, as the test will be converted to KUnit,
it can run on-demand after later.

Also, as KUnit can be a module, make this test modular.

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Signed-off-by: Mostafa Saleh <smostafa@google.com>
Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
drivers/iommu/Kconfig
drivers/iommu/io-pgtable-arm-selftests.c

index c9ae3221cd6f50bc65bb9890b311bb461af4c53d..6eca8b3a17e992a2b43587aa4617601f5ca827bc 100644 (file)
@@ -41,7 +41,7 @@ config IOMMU_IO_PGTABLE_LPAE
          up to 48-bits in size.
 
 config IOMMU_IO_PGTABLE_LPAE_SELFTEST
-       bool "LPAE selftests"
+       tristate "LPAE selftests"
        depends on IOMMU_IO_PGTABLE_LPAE
        help
          Enable self-tests for LPAE page table allocator. This performs
index 5da6d4b699208809381ba40651e2c75e1c982980..8361d01b49c515a4fa79d14e5969d0673ced7479 100644 (file)
 
 #include "io-pgtable-arm.h"
 
-static struct io_pgtable_cfg *cfg_cookie __initdata;
+static struct io_pgtable_cfg *cfg_cookie;
 
-static void __init dummy_tlb_flush_all(void *cookie)
+static void dummy_tlb_flush_all(void *cookie)
 {
        WARN_ON(cookie != cfg_cookie);
 }
 
-static void __init dummy_tlb_flush(unsigned long iova, size_t size,
-                                  size_t granule, void *cookie)
+static void dummy_tlb_flush(unsigned long iova, size_t size,
+                           size_t granule, void *cookie)
 {
        WARN_ON(cookie != cfg_cookie);
        WARN_ON(!(size & cfg_cookie->pgsize_bitmap));
 }
 
-static void __init dummy_tlb_add_page(struct iommu_iotlb_gather *gather,
-                                     unsigned long iova, size_t granule,
-                                     void *cookie)
+static void dummy_tlb_add_page(struct iommu_iotlb_gather *gather,
+                              unsigned long iova, size_t granule,
+                              void *cookie)
 {
        dummy_tlb_flush(iova, granule, granule, cookie);
 }
 
-static const struct iommu_flush_ops dummy_tlb_ops __initconst = {
+static const struct iommu_flush_ops dummy_tlb_ops = {
        .tlb_flush_all  = dummy_tlb_flush_all,
        .tlb_flush_walk = dummy_tlb_flush,
        .tlb_add_page   = dummy_tlb_add_page,
@@ -47,9 +47,9 @@ static const struct iommu_flush_ops dummy_tlb_ops __initconst = {
                -EFAULT;                                                \
 })
 
-static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
+static int arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
 {
-       static const enum io_pgtable_fmt fmts[] __initconst = {
+       static const enum io_pgtable_fmt fmts[] = {
                ARM_64_LPAE_S1,
                ARM_64_LPAE_S2,
        };
@@ -150,15 +150,15 @@ static int __init arm_lpae_run_tests(struct io_pgtable_cfg *cfg)
        return 0;
 }
 
-static int __init arm_lpae_do_selftests(void)
+static int arm_lpae_do_selftests(void)
 {
-       static const unsigned long pgsize[] __initconst = {
+       static const unsigned long pgsize[] = {
                SZ_4K | SZ_2M | SZ_1G,
                SZ_16K | SZ_32M,
                SZ_64K | SZ_512M,
        };
 
-       static const unsigned int address_size[] __initconst = {
+       static const unsigned int address_size[] = {
                32, 36, 40, 42, 44, 48,
        };
 
@@ -198,4 +198,12 @@ static int __init arm_lpae_do_selftests(void)
 
        return fail ? -EFAULT : 0;
 }
+
+static void arm_lpae_exit_selftests(void)
+{
+}
+
 subsys_initcall(arm_lpae_do_selftests);
+module_exit(arm_lpae_exit_selftests);
+MODULE_DESCRIPTION("io-pgtable-arm library selftest");
+MODULE_LICENSE("GPL");