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 <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>
This commit is contained in:
Mostafa Saleh 2025-11-03 12:33:51 +00:00 committed by Joerg Roedel
parent 699b059962
commit a3c24b6d7c
2 changed files with 22 additions and 14 deletions

View 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

View file

@ -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");