From: Mostafa Saleh Date: Mon, 3 Nov 2025 12:33:51 +0000 (+0000) Subject: iommu/io-pgtable-arm-selftests: Modularize the test X-Git-Tag: v6.19-rc1~133^2^8~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3c24b6d7cd6047fb9e234586e484391be335b4f;p=thirdparty%2Fkernel%2Flinux.git iommu/io-pgtable-arm-selftests: Modularize the test 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 Reviewed-by: Pranjal Shrivastava Signed-off-by: Mostafa Saleh Acked-by: Will Deacon Signed-off-by: Joerg Roedel --- diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index c9ae3221cd6f5..6eca8b3a17e99 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -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 diff --git a/drivers/iommu/io-pgtable-arm-selftests.c b/drivers/iommu/io-pgtable-arm-selftests.c index 5da6d4b699208..8361d01b49c51 100644 --- a/drivers/iommu/io-pgtable-arm-selftests.c +++ b/drivers/iommu/io-pgtable-arm-selftests.c @@ -15,28 +15,28 @@ #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");