mirror of https://github.com/torvalds/linux.git
vfio: selftests: Rename struct vfio_dma_region to dma_region
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> Reviewed-by: Raghavendra Rao Ananta <rananta@google.com> Signed-off-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20251126231733.3302983-11-dmatlack@google.com Signed-off-by: Alex Williamson <alex@shazbot.org>
This commit is contained in:
parent
28a84da744
commit
9a659d74f2
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue