Commit a3c24b6d authored by Mostafa Saleh's avatar Mostafa Saleh Committed by Joerg Roedel
Browse files

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: default avatarJason Gunthorpe <jgg@nvidia.com>
Reviewed-by: default avatarPranjal Shrivastava <praan@google.com>
Signed-off-by: default avatarMostafa Saleh <smostafa@google.com>
Acked-by: default avatarWill Deacon <will@kernel.org>
Signed-off-by: default avatarJoerg Roedel <joerg.roedel@amd.com>
parent 699b0599
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+21 −13
Original line number Diff line number Diff line
@@ -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,
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,
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");