Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

vfio: selftests: Centralize IOMMU mode name definitions

Replace scattered string literals with MODE_* macros in iommu.h. This
provides a single source of truth for IOMMU mode name strings.

Signed-off-by: Alex Mastro <amastro@fb.com>
Reviewed-by: David Matlack <dmatlack@google.com>
Tested-by: David Matlack <dmatlack@google.com>
Link: https://lore.kernel.org/r/20260114-map-mmio-test-v3-1-44e036d95e64@fb.com
Signed-off-by: Alex Williamson <alex@shazbot.org>

authored by

Alex Mastro and committed by
Alex Williamson
03b7c2d7 ffc987b3

+13 -7
+6
tools/testing/selftests/vfio/lib/include/libvfio/iommu.h
··· 61 61 62 62 struct iommu_iova_range *iommu_iova_ranges(struct iommu *iommu, u32 *nranges); 63 63 64 + #define MODE_VFIO_TYPE1_IOMMU "vfio_type1_iommu" 65 + #define MODE_VFIO_TYPE1V2_IOMMU "vfio_type1v2_iommu" 66 + #define MODE_IOMMUFD_COMPAT_TYPE1 "iommufd_compat_type1" 67 + #define MODE_IOMMUFD_COMPAT_TYPE1V2 "iommufd_compat_type1v2" 68 + #define MODE_IOMMUFD "iommufd" 69 + 64 70 /* 65 71 * Generator for VFIO selftests fixture variants that replicate across all 66 72 * possible IOMMU modes. Tests must define FIXTURE_VARIANT_ADD_IOMMU_MODE()
+6 -6
tools/testing/selftests/vfio/lib/iommu.c
··· 20 20 #include "../../../kselftest.h" 21 21 #include <libvfio.h> 22 22 23 - const char *default_iommu_mode = "iommufd"; 23 + const char *default_iommu_mode = MODE_IOMMUFD; 24 24 25 25 /* Reminder: Keep in sync with FIXTURE_VARIANT_ADD_ALL_IOMMU_MODES(). */ 26 26 static const struct iommu_mode iommu_modes[] = { 27 27 { 28 - .name = "vfio_type1_iommu", 28 + .name = MODE_VFIO_TYPE1_IOMMU, 29 29 .container_path = "/dev/vfio/vfio", 30 30 .iommu_type = VFIO_TYPE1_IOMMU, 31 31 }, 32 32 { 33 - .name = "vfio_type1v2_iommu", 33 + .name = MODE_VFIO_TYPE1V2_IOMMU, 34 34 .container_path = "/dev/vfio/vfio", 35 35 .iommu_type = VFIO_TYPE1v2_IOMMU, 36 36 }, 37 37 { 38 - .name = "iommufd_compat_type1", 38 + .name = MODE_IOMMUFD_COMPAT_TYPE1, 39 39 .container_path = "/dev/iommu", 40 40 .iommu_type = VFIO_TYPE1_IOMMU, 41 41 }, 42 42 { 43 - .name = "iommufd_compat_type1v2", 43 + .name = MODE_IOMMUFD_COMPAT_TYPE1V2, 44 44 .container_path = "/dev/iommu", 45 45 .iommu_type = VFIO_TYPE1v2_IOMMU, 46 46 }, 47 47 { 48 - .name = "iommufd", 48 + .name = MODE_IOMMUFD, 49 49 }, 50 50 }; 51 51
+1 -1
tools/testing/selftests/vfio/vfio_dma_mapping_test.c
··· 165 165 * IOMMUFD compatibility-mode does not support huge mappings when 166 166 * using VFIO_TYPE1_IOMMU. 167 167 */ 168 - if (!strcmp(variant->iommu_mode, "iommufd_compat_type1")) 168 + if (!strcmp(variant->iommu_mode, MODE_IOMMUFD_COMPAT_TYPE1)) 169 169 mapping_size = SZ_4K; 170 170 171 171 ASSERT_EQ(0, rc);