Skip to content

Commit d61927d

Browse files
committed
iommufd/selftest: Remove domain_alloc_paging()
Since this implements domain_alloc_paging_flags() it only needs one op. Fold mock_domain_alloc_paging() into mock_domain_alloc_paging_flags(). Link: https://patch.msgid.link/r/[email protected] Reviewed-by: Kevin Tian <[email protected]> Reviewed-by: Yi Liu <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent fac04ef commit d61927d

File tree

1 file changed

+16
-27
lines changed

1 file changed

+16
-27
lines changed

drivers/iommu/iommufd/selftest.c

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -311,25 +311,6 @@ static const struct iommu_dirty_ops dirty_ops = {
311311
.read_and_clear_dirty = mock_domain_read_and_clear_dirty,
312312
};
313313

314-
static struct iommu_domain *mock_domain_alloc_paging(struct device *dev)
315-
{
316-
struct mock_dev *mdev = to_mock_dev(dev);
317-
struct mock_iommu_domain *mock;
318-
319-
mock = kzalloc(sizeof(*mock), GFP_KERNEL);
320-
if (!mock)
321-
return NULL;
322-
mock->domain.geometry.aperture_start = MOCK_APERTURE_START;
323-
mock->domain.geometry.aperture_end = MOCK_APERTURE_LAST;
324-
mock->domain.pgsize_bitmap = MOCK_IO_PAGE_SIZE;
325-
if (dev && mdev->flags & MOCK_FLAGS_DEVICE_HUGE_IOVA)
326-
mock->domain.pgsize_bitmap |= MOCK_HUGE_PAGE_SIZE;
327-
mock->domain.ops = mock_ops.default_domain_ops;
328-
mock->domain.type = IOMMU_DOMAIN_UNMANAGED;
329-
xa_init(&mock->pfns);
330-
return &mock->domain;
331-
}
332-
333314
static struct mock_iommu_domain_nested *
334315
__mock_domain_alloc_nested(const struct iommu_user_data *user_data)
335316
{
@@ -385,21 +366,30 @@ mock_domain_alloc_paging_flags(struct device *dev, u32 flags,
385366
bool has_dirty_flag = flags & IOMMU_HWPT_ALLOC_DIRTY_TRACKING;
386367
const u32 PAGING_FLAGS = IOMMU_HWPT_ALLOC_DIRTY_TRACKING |
387368
IOMMU_HWPT_ALLOC_NEST_PARENT;
388-
bool no_dirty_ops = to_mock_dev(dev)->flags &
389-
MOCK_FLAGS_DEVICE_NO_DIRTY;
390-
struct iommu_domain *domain;
369+
struct mock_dev *mdev = to_mock_dev(dev);
370+
bool no_dirty_ops = mdev->flags & MOCK_FLAGS_DEVICE_NO_DIRTY;
371+
struct mock_iommu_domain *mock;
391372

392373
if (user_data)
393374
return ERR_PTR(-EOPNOTSUPP);
394375
if ((flags & ~PAGING_FLAGS) || (has_dirty_flag && no_dirty_ops))
395376
return ERR_PTR(-EOPNOTSUPP);
396377

397-
domain = mock_domain_alloc_paging(dev);
398-
if (!domain)
378+
mock = kzalloc(sizeof(*mock), GFP_KERNEL);
379+
if (!mock)
399380
return ERR_PTR(-ENOMEM);
381+
mock->domain.geometry.aperture_start = MOCK_APERTURE_START;
382+
mock->domain.geometry.aperture_end = MOCK_APERTURE_LAST;
383+
mock->domain.pgsize_bitmap = MOCK_IO_PAGE_SIZE;
384+
if (dev && mdev->flags & MOCK_FLAGS_DEVICE_HUGE_IOVA)
385+
mock->domain.pgsize_bitmap |= MOCK_HUGE_PAGE_SIZE;
386+
mock->domain.ops = mock_ops.default_domain_ops;
387+
mock->domain.type = IOMMU_DOMAIN_UNMANAGED;
388+
xa_init(&mock->pfns);
389+
400390
if (has_dirty_flag)
401-
domain->dirty_ops = &dirty_ops;
402-
return domain;
391+
mock->domain.dirty_ops = &dirty_ops;
392+
return &mock->domain;
403393
}
404394

405395
static void mock_domain_free(struct iommu_domain *domain)
@@ -713,7 +703,6 @@ static const struct iommu_ops mock_ops = {
713703
.owner = THIS_MODULE,
714704
.pgsize_bitmap = MOCK_IO_PAGE_SIZE,
715705
.hw_info = mock_domain_hw_info,
716-
.domain_alloc_paging = mock_domain_alloc_paging,
717706
.domain_alloc_paging_flags = mock_domain_alloc_paging_flags,
718707
.domain_alloc_nested = mock_domain_alloc_nested,
719708
.capable = mock_domain_capable,

0 commit comments

Comments
 (0)