[PATCH v3 10/18] vfio: selftests: Rename struct vfio_dma_region to dma_region

David Matlack
2025-11-21T18:14:55Z

Rename struct vfio_dma_region to dma_region. This is in preparation for
separating the VFIO PCI device library code from the IOMMU library code.
This name change also better reflects the fact that DMA mappings can be
managed by either VFIO or IOMMUFD. i.e. the "vfio_" prefix is
misleading.

Reviewed-by: Alex Mastro <amastro@fb.com>
Tested-by: Alex Mastro <amastro@fb.com>
Signed-off-by: David Matlack <dmatlack@google.com>
---
tools/testing/selftests/vfio/lib/include/vfio_util.h | 12 ++++++------
tools/testing/selftests/vfio/lib/vfio_pci_device.c | 12 ++++++------
tools/testing/selftests/vfio/vfio_dma_mapping_test.c | 12 ++++++------
tools/testing/selftests/vfio/vfio_pci_driver_test.c | 6 +++---
4 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/tools/testing/selftests/vfio/lib/include/vfio_util.h b/tools/testing/selftests/vfio/lib/include/vfio_util.h
index babbf90688e8..7784422116de 100644
--- a/tools/testing/selftests/vfio/lib/include/vfio_util.h
+++ b/tools/testing/selftests/vfio/lib/include/vfio_util.h
@@ -80,7 +80,7 @@ typedef u64 iova_t;

#define INVALID_IOVA UINT64_MAX

-struct vfio_dma_region {
+struct dma_region {
struct list_head link;
void *vaddr;
iova_t iova;
@@ -154,7 +154,7 @@ struct vfio_pci_driver {
bool memcpy_in_progress;

/* Region to be used by the driver (e.g. for in-memory descriptors) */
- struct vfio_dma_region region;
+ struct dma_region region;

/* The maximum size that can be passed to memcpy_start(). */
u64 max_memcpy_size;
@@ -236,20 +236,20 @@ void iova_allocator_cleanup(struct iova_allocator *allocator);
iova_t iova_allocator_alloc(struct iova_allocator *allocator, size_t size);

int __vfio_pci_dma_map(struct vfio_pci_device *device,
- struct vfio_dma_region *region);
+ struct dma_region *region);
int __vfio_pci_dma_unmap(struct vfio_pci_device *device,
- struct vfio_dma_region *region,
+ struct dma_region *region,
u64 *unmapped);
int __vfio_pci_dma_unmap_all(struct vfio_pci_device *device, u64 *unmapped);

static inline void vfio_pci_dma_map(struct vfio_pci_device *device,
- struct vfio_dma_region *region)
+ struct dma_region *region)
{
VFIO_ASSERT_EQ(__vfio_pci_dma_map(device, region), 0);
}

static inline void vfio_pci_dma_unmap(struct vfio_pci_device *device,
- struct vfio_dma_region *region)
+ struct dma_region *region)
{
VFIO_ASSERT_EQ(__vfio_pci_dma_unmap(device, region, NULL), 0);
}
diff --git a/tools/testing/selftests/vfio/lib/vfio_pci_device.c b/tools/testing/selftests/vfio/lib/vfio_pci_device.c
index f3aea724695d..877b145cef63 100644
--- a/tools/testing/selftests/vfio/lib/vfio_pci_device.c
+++ b/tools/testing/selftests/vfio/lib/vfio_pci_device.c
@@ -275,7 +275,7 @@ iova_t iova_allocator_alloc(struct iova_allocator *allocator, size_t size)

iova_t __to_iova(struct vfio_pci_device *device, void *vaddr)
{
- struct vfio_dma_region *region;
+ struct dma_region *region;

list_for_each_entry(region, &device->iommu->dma_regions, link) {
if (vaddr < region->vaddr)
@@ -387,7 +387,7 @@ static void vfio_pci_irq_get(struct vfio_pci_device *device, u32 index,
}

static int vfio_iommu_dma_map(struct vfio_pci_device *device,
- struct vfio_dma_region *region)
+ struct dma_region *region)
{
struct vfio_iommu_type1_dma_map args = {
.argsz = sizeof(args),
@@ -404,7 +404,7 @@ static int vfio_iommu_dma_map(struct vfio_pci_device *device,
}

static int iommufd_dma_map(struct vfio_pci_device *device,
- struct vfio_dma_region *region)
+ struct dma_region *region)
{
struct iommu_ioas_map args = {
.size = sizeof(args),
@@ -424,7 +424,7 @@ static int iommufd_dma_map(struct vfio_pci_device *device,
}

int __vfio_pci_dma_map(struct vfio_pci_device *device,
- struct vfio_dma_region *region)
+ struct dma_region *region)
{
int ret;

@@ -480,7 +480,7 @@ static int iommufd_dma_unmap(int fd, u64 iova, u64 length, u32 ioas_id,
}

int __vfio_pci_dma_unmap(struct vfio_pci_device *device,
- struct vfio_dma_region *region, u64 *unmapped)
+ struct dma_region *region, u64 *unmapped)
{
int ret;

@@ -504,7 +504,7 @@ int __vfio_pci_dma_unmap(struct vfio_pci_device *device,
int __vfio_pci_dma_unmap_all(struct vfio_pci_device *device, u64 *unmapped)
{
int ret;
- struct vfio_dma_region *curr, *next;
+ struct dma_region *curr, *next;

if (device->iommu->iommufd)
ret = iommufd_dma_unmap(device->iommu->iommufd, 0, UINT64_MAX,
diff --git a/tools/testing/selftests/vfio/vfio_dma_mapping_test.c b/tools/testing/selftests/vfio/vfio_dma_mapping_test.c
index 4727feb214c8..289af4665803 100644
--- a/tools/testing/selftests/vfio/vfio_dma_mapping_test.c
+++ b/tools/testing/selftests/vfio/vfio_dma_mapping_test.c
@@ -136,7 +136,7 @@ TEST_F(vfio_dma_mapping_test, dma_map_unmap)
{
const u64 size = variant->size ?: getpagesize();
const int flags = variant->mmap_flags;
- struct vfio_dma_region region;
+ struct dma_region region;
struct iommu_mapping mapping;
u64 mapping_size = size;
u64 unmapped;
@@ -208,7 +208,7 @@ TEST_F(vfio_dma_mapping_test, dma_map_unmap)
FIXTURE(vfio_dma_map_limit_test) {
struct iommu *iommu;
struct vfio_pci_device *device;
- struct vfio_dma_region region;
+ struct dma_region region;
size_t mmap_size;
};

@@ -227,7 +227,7 @@ FIXTURE_VARIANT_ADD_ALL_IOMMU_MODES();

FIXTURE_SETUP(vfio_dma_map_limit_test)
{
- struct vfio_dma_region *region = &self->region;
+ struct dma_region *region = &self->region;
struct iommu_iova_range *ranges;
u64 region_size = getpagesize();
iova_t last_iova;
@@ -264,7 +264,7 @@ FIXTURE_TEARDOWN(vfio_dma_map_limit_test)

TEST_F(vfio_dma_map_limit_test, unmap_range)
{
- struct vfio_dma_region *region = &self->region;
+ struct dma_region *region = &self->region;
u64 unmapped;
int rc;

@@ -278,7 +278,7 @@ TEST_F(vfio_dma_map_limit_test, unmap_range)

TEST_F(vfio_dma_map_limit_test, unmap_all)
{
- struct vfio_dma_region *region = &self->region;
+ struct dma_region *region = &self->region;
u64 unmapped;
int rc;

@@ -292,7 +292,7 @@ TEST_F(vfio_dma_map_limit_test, unmap_all)

TEST_F(vfio_dma_map_limit_test, overflow)
{
- struct vfio_dma_region *region = &self->region;
+ struct dma_region *region = &self->region;
int rc;

region->iova = ~(iova_t)0 & ~(region->size - 1);
diff --git a/tools/testing/selftests/vfio/vfio_pci_driver_test.c b/tools/testing/selftests/vfio/vfio_pci_driver_test.c
index b0c7d812de1f..057aa9bbe13e 100644
--- a/tools/testing/selftests/vfio/vfio_pci_driver_test.c
+++ b/tools/testing/selftests/vfio/vfio_pci_driver_test.c
@@ -20,7 +20,7 @@ static const char *device_bdf;

static void region_setup(struct vfio_pci_device *device,
struct iova_allocator *iova_allocator,
- struct vfio_dma_region *region, u64 size)
+ struct dma_region *region, u64 size)
{
const int flags = MAP_SHARED | MAP_ANONYMOUS;
const int prot = PROT_READ | PROT_WRITE;
@@ -37,7 +37,7 @@ static void region_setup(struct vfio_pci_device *device,
}

static void region_teardown(struct vfio_pci_device *device,
- struct vfio_dma_region *region)
+ struct dma_region *region)
{
vfio_pci_dma_unmap(device, region);
VFIO_ASSERT_EQ(munmap(region->vaddr, region->size), 0);
@@ -47,7 +47,7 @@ FIXTURE(vfio_pci_driver_test) {
struct iommu *iommu;
struct vfio_pci_device *device;
struct iova_allocator *iova_allocator;
- struct vfio_dma_region memcpy_region;
+ struct dma_region memcpy_region;
void *vaddr;
int msi_fd;

--
2.52.0.rc2.455.g230fcf2819-goog