[PATCH v7 9/9] iommu/arm-smmu-v3: Add unit tests for arm_smmu_write_entry

Nicolin Chen nicolinc at nvidia.com
Wed Apr 17 01:09:40 PDT 2024


On Tue, Apr 16, 2024 at 04:28:20PM -0300, Jason Gunthorpe wrote:
> Add tests for some of the more common STE update operations that we expect
> to see, as well as some artificial STE updates to test the edges of
> arm_smmu_write_entry. These also serve as a record of which common
> operation is expected to be hitless, and how many syncs they require.
> 
> arm_smmu_write_entry implements a generic algorithm that updates an STE/CD
> to any other abritrary STE/CD configuration. The update requires a
> sequence of write+sync operations with some invariants that must be held
> true after each sync. arm_smmu_write_entry lends itself well to
> unit-testing since the function's interaction with the STE/CD is already
> abstracted by input callbacks that we can hook to introspect into the
> sequence of operations. We can use these hooks to guarantee that
> invariants are held throughout the entire update operation.
> 
> Link: https://lore.kernel.org/r/20240106083617.1173871-3-mshavit@google.com
> Signed-off-by: Michael Shavit <mshavit at google.com>
> Signed-off-by: Jason Gunthorpe <jgg at nvidia.com>
> ---
>  drivers/iommu/Kconfig                         |  12 +-
>  drivers/iommu/arm/arm-smmu-v3/Makefile        |   2 +
>  .../iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c   |   6 +-
>  .../iommu/arm/arm-smmu-v3/arm-smmu-v3-test.c  | 467 ++++++++++++++++++
>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c   |  36 +-
>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h   |  30 ++
 
> +config ARM_SMMU_V3_KUNIT_TEST
> +	tristate "KUnit tests for arm-smmu-v3 driver"  if !KUNIT_ALL_TESTS
> +	depends on KUNIT
> +	default KUNIT_ALL_TESTS
> +	help
> +	  Enable this option to unit-test arm-smmu-v3 driver functions.
> +
> +	  If unsure, say N.

Forgot that my SVA sanity doesn't cover this patch. And it looks
like some problems here when building it with "=m":

ERROR: modpost: missing MODULE_LICENSE() in drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-test.o
ERROR: modpost: "arm_smmu_make_cdtable_ste" [drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-test.ko] undefined!
ERROR: modpost: "arm_smmu_make_bypass_ste" [drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-test.ko] undefined!
ERROR: modpost: "arm_smmu_make_abort_ste" [drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-test.ko] undefined!
ERROR: modpost: "arm_smmu_make_s2_domain_ste" [drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-test.ko] undefined!
ERROR: modpost: "arm_smmu_get_ste_used" [drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-test.ko] undefined!
ERROR: modpost: "arm_smmu_write_entry" [drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-test.ko] undefined!

Likely needs MODULE_LICENSE and some EXPORT_SYMBOLs.

With built-in '=y' and a MODULE_LICENSE, tests passed:
[   13.244780] KTAP version 1
[   13.247542] 1..1
[   13.249421]     KTAP version 1
[   13.252538]     # Subtest: arm-smmu-v3-kunit-test
[   13.257344]     1..16
[   13.259727]     ok 1 arm_smmu_v3_write_ste_test_bypass_to_abort
[   13.259789]     ok 2 arm_smmu_v3_write_ste_test_abort_to_bypass
[   13.265895]     ok 3 arm_smmu_v3_write_ste_test_cdtable_to_abort
[   13.271988]     ok 4 arm_smmu_v3_write_ste_test_abort_to_cdtable
[   13.278172]     ok 5 arm_smmu_v3_write_ste_test_cdtable_to_bypass
[   13.284353]     ok 6 arm_smmu_v3_write_ste_test_bypass_to_cdtable
[   13.290636]     ok 7 arm_smmu_v3_write_ste_test_cdtable_s1dss_change
[   13.296917]     ok 8 arm_smmu_v3_write_ste_test_s1dssbypass_to_stebypass
[   13.303464]     ok 9 arm_smmu_v3_write_ste_test_stebypass_to_s1dssbypass
[   13.310357]     ok 10 arm_smmu_v3_write_ste_test_s2_to_abort
[   13.317265]     ok 11 arm_smmu_v3_write_ste_test_abort_to_s2
[   13.323104]     ok 12 arm_smmu_v3_write_ste_test_s2_to_bypass
[   13.328937]     ok 13 arm_smmu_v3_write_ste_test_bypass_to_s2
[   13.334861]     ok 14 arm_smmu_v3_write_ste_test_s1_to_s2
[   13.340787]     ok 15 arm_smmu_v3_write_ste_test_s2_to_s1
[   13.346364]     ok 16 arm_smmu_v3_write_ste_test_non_hitless
[   13.351883] # arm-smmu-v3-kunit-test: pass:16 fail:0 skip:0 total:16
[   13.357667] # Totals: pass:16 fail:0 skip:0 total:16
[   13.364163] ok 1 arm-smmu-v3-kunit-test

Once those are fixed,
Tested-by: Nicolin Chen <nicolinc at nvidia.com>



More information about the linux-arm-kernel mailing list