Archive-only list for patches
 help / color / mirror / Atom feed
* [PATCH] iommufd/selftest: Remove domain_alloc_paging()
@ 2024-12-04 20:13 Jason Gunthorpe
  2024-12-06  7:24 ` Yi Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2024-12-04 20:13 UTC (permalink / raw)
  To: iommu, Joerg Roedel, Kevin Tian, Robin Murphy, Will Deacon; +Cc: patches

Since this implements domain_alloc_paging_flags() it only needs one
op. Fold mock_domain_alloc_paging() into mock_domain_alloc_paging_flags().

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 drivers/iommu/iommufd/selftest.c | 43 ++++++++++++--------------------
 1 file changed, 16 insertions(+), 27 deletions(-)

diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c
index a0de6d6d4e689c..6512c1d163481f 100644
--- a/drivers/iommu/iommufd/selftest.c
+++ b/drivers/iommu/iommufd/selftest.c
@@ -311,25 +311,6 @@ static const struct iommu_dirty_ops dirty_ops = {
 	.read_and_clear_dirty = mock_domain_read_and_clear_dirty,
 };
 
-static struct iommu_domain *mock_domain_alloc_paging(struct device *dev)
-{
-	struct mock_dev *mdev = to_mock_dev(dev);
-	struct mock_iommu_domain *mock;
-
-	mock = kzalloc(sizeof(*mock), GFP_KERNEL);
-	if (!mock)
-		return NULL;
-	mock->domain.geometry.aperture_start = MOCK_APERTURE_START;
-	mock->domain.geometry.aperture_end = MOCK_APERTURE_LAST;
-	mock->domain.pgsize_bitmap = MOCK_IO_PAGE_SIZE;
-	if (dev && mdev->flags & MOCK_FLAGS_DEVICE_HUGE_IOVA)
-		mock->domain.pgsize_bitmap |= MOCK_HUGE_PAGE_SIZE;
-	mock->domain.ops = mock_ops.default_domain_ops;
-	mock->domain.type = IOMMU_DOMAIN_UNMANAGED;
-	xa_init(&mock->pfns);
-	return &mock->domain;
-}
-
 static struct mock_iommu_domain_nested *
 __mock_domain_alloc_nested(const struct iommu_user_data *user_data)
 {
@@ -385,21 +366,30 @@ mock_domain_alloc_paging_flags(struct device *dev, u32 flags,
 	bool has_dirty_flag = flags & IOMMU_HWPT_ALLOC_DIRTY_TRACKING;
 	const u32 PAGING_FLAGS = IOMMU_HWPT_ALLOC_DIRTY_TRACKING |
 				 IOMMU_HWPT_ALLOC_NEST_PARENT;
-	bool no_dirty_ops = to_mock_dev(dev)->flags &
-			    MOCK_FLAGS_DEVICE_NO_DIRTY;
-	struct iommu_domain *domain;
+	struct mock_dev *mdev = to_mock_dev(dev);
+	bool no_dirty_ops = mdev->flags & MOCK_FLAGS_DEVICE_NO_DIRTY;
+	struct mock_iommu_domain *mock;
 
 	if (user_data)
 		return ERR_PTR(-EOPNOTSUPP);
 	if ((flags & ~PAGING_FLAGS) || (has_dirty_flag && no_dirty_ops))
 		return ERR_PTR(-EOPNOTSUPP);
 
-	domain = mock_domain_alloc_paging(dev);
-	if (!domain)
+	mock = kzalloc(sizeof(*mock), GFP_KERNEL);
+	if (!mock)
 		return ERR_PTR(-ENOMEM);
+	mock->domain.geometry.aperture_start = MOCK_APERTURE_START;
+	mock->domain.geometry.aperture_end = MOCK_APERTURE_LAST;
+	mock->domain.pgsize_bitmap = MOCK_IO_PAGE_SIZE;
+	if (dev && mdev->flags & MOCK_FLAGS_DEVICE_HUGE_IOVA)
+		mock->domain.pgsize_bitmap |= MOCK_HUGE_PAGE_SIZE;
+	mock->domain.ops = mock_ops.default_domain_ops;
+	mock->domain.type = IOMMU_DOMAIN_UNMANAGED;
+	xa_init(&mock->pfns);
+
 	if (has_dirty_flag)
-		domain->dirty_ops = &dirty_ops;
-	return domain;
+		mock->domain.dirty_ops = &dirty_ops;
+	return &mock->domain;
 }
 
 static void mock_domain_free(struct iommu_domain *domain)
@@ -713,7 +703,6 @@ static const struct iommu_ops mock_ops = {
 	.owner = THIS_MODULE,
 	.pgsize_bitmap = MOCK_IO_PAGE_SIZE,
 	.hw_info = mock_domain_hw_info,
-	.domain_alloc_paging = mock_domain_alloc_paging,
 	.domain_alloc_paging_flags = mock_domain_alloc_paging_flags,
 	.domain_alloc_nested = mock_domain_alloc_nested,
 	.capable = mock_domain_capable,

base-commit: 40384c840ea1944d7c5a392e8975ed088ecf0b37
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] iommufd/selftest: Remove domain_alloc_paging()
  2024-12-04 20:13 [PATCH] iommufd/selftest: Remove domain_alloc_paging() Jason Gunthorpe
@ 2024-12-06  7:24 ` Yi Liu
  2024-12-11  8:25 ` Tian, Kevin
  2024-12-11 18:14 ` Jason Gunthorpe
  2 siblings, 0 replies; 4+ messages in thread
From: Yi Liu @ 2024-12-06  7:24 UTC (permalink / raw)
  To: Jason Gunthorpe, iommu, Joerg Roedel, Kevin Tian, Robin Murphy,
	Will Deacon
  Cc: patches

On 2024/12/5 04:13, Jason Gunthorpe wrote:
> Since this implements domain_alloc_paging_flags() it only needs one
> op. Fold mock_domain_alloc_paging() into mock_domain_alloc_paging_flags().
> 
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

Reviewed-by: Yi Liu <yi.l.liu@intel.com>

> ---
>   drivers/iommu/iommufd/selftest.c | 43 ++++++++++++--------------------
>   1 file changed, 16 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c
> index a0de6d6d4e689c..6512c1d163481f 100644
> --- a/drivers/iommu/iommufd/selftest.c
> +++ b/drivers/iommu/iommufd/selftest.c
> @@ -311,25 +311,6 @@ static const struct iommu_dirty_ops dirty_ops = {
>   	.read_and_clear_dirty = mock_domain_read_and_clear_dirty,
>   };
>   
> -static struct iommu_domain *mock_domain_alloc_paging(struct device *dev)
> -{
> -	struct mock_dev *mdev = to_mock_dev(dev);
> -	struct mock_iommu_domain *mock;
> -
> -	mock = kzalloc(sizeof(*mock), GFP_KERNEL);
> -	if (!mock)
> -		return NULL;
> -	mock->domain.geometry.aperture_start = MOCK_APERTURE_START;
> -	mock->domain.geometry.aperture_end = MOCK_APERTURE_LAST;
> -	mock->domain.pgsize_bitmap = MOCK_IO_PAGE_SIZE;
> -	if (dev && mdev->flags & MOCK_FLAGS_DEVICE_HUGE_IOVA)
> -		mock->domain.pgsize_bitmap |= MOCK_HUGE_PAGE_SIZE;
> -	mock->domain.ops = mock_ops.default_domain_ops;
> -	mock->domain.type = IOMMU_DOMAIN_UNMANAGED;
> -	xa_init(&mock->pfns);
> -	return &mock->domain;
> -}
> -
>   static struct mock_iommu_domain_nested *
>   __mock_domain_alloc_nested(const struct iommu_user_data *user_data)
>   {
> @@ -385,21 +366,30 @@ mock_domain_alloc_paging_flags(struct device *dev, u32 flags,
>   	bool has_dirty_flag = flags & IOMMU_HWPT_ALLOC_DIRTY_TRACKING;
>   	const u32 PAGING_FLAGS = IOMMU_HWPT_ALLOC_DIRTY_TRACKING |
>   				 IOMMU_HWPT_ALLOC_NEST_PARENT;
> -	bool no_dirty_ops = to_mock_dev(dev)->flags &
> -			    MOCK_FLAGS_DEVICE_NO_DIRTY;
> -	struct iommu_domain *domain;
> +	struct mock_dev *mdev = to_mock_dev(dev);
> +	bool no_dirty_ops = mdev->flags & MOCK_FLAGS_DEVICE_NO_DIRTY;
> +	struct mock_iommu_domain *mock;
>   
>   	if (user_data)
>   		return ERR_PTR(-EOPNOTSUPP);
>   	if ((flags & ~PAGING_FLAGS) || (has_dirty_flag && no_dirty_ops))
>   		return ERR_PTR(-EOPNOTSUPP);
>   
> -	domain = mock_domain_alloc_paging(dev);
> -	if (!domain)
> +	mock = kzalloc(sizeof(*mock), GFP_KERNEL);
> +	if (!mock)
>   		return ERR_PTR(-ENOMEM);
> +	mock->domain.geometry.aperture_start = MOCK_APERTURE_START;
> +	mock->domain.geometry.aperture_end = MOCK_APERTURE_LAST;
> +	mock->domain.pgsize_bitmap = MOCK_IO_PAGE_SIZE;
> +	if (dev && mdev->flags & MOCK_FLAGS_DEVICE_HUGE_IOVA)
> +		mock->domain.pgsize_bitmap |= MOCK_HUGE_PAGE_SIZE;
> +	mock->domain.ops = mock_ops.default_domain_ops;
> +	mock->domain.type = IOMMU_DOMAIN_UNMANAGED;
> +	xa_init(&mock->pfns);
> +
>   	if (has_dirty_flag)
> -		domain->dirty_ops = &dirty_ops;
> -	return domain;
> +		mock->domain.dirty_ops = &dirty_ops;
> +	return &mock->domain;
>   }
>   
>   static void mock_domain_free(struct iommu_domain *domain)
> @@ -713,7 +703,6 @@ static const struct iommu_ops mock_ops = {
>   	.owner = THIS_MODULE,
>   	.pgsize_bitmap = MOCK_IO_PAGE_SIZE,
>   	.hw_info = mock_domain_hw_info,
> -	.domain_alloc_paging = mock_domain_alloc_paging,
>   	.domain_alloc_paging_flags = mock_domain_alloc_paging_flags,
>   	.domain_alloc_nested = mock_domain_alloc_nested,
>   	.capable = mock_domain_capable,
> 
> base-commit: 40384c840ea1944d7c5a392e8975ed088ecf0b37

-- 
Regards,
Yi Liu

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] iommufd/selftest: Remove domain_alloc_paging()
  2024-12-04 20:13 [PATCH] iommufd/selftest: Remove domain_alloc_paging() Jason Gunthorpe
  2024-12-06  7:24 ` Yi Liu
@ 2024-12-11  8:25 ` Tian, Kevin
  2024-12-11 18:14 ` Jason Gunthorpe
  2 siblings, 0 replies; 4+ messages in thread
From: Tian, Kevin @ 2024-12-11  8:25 UTC (permalink / raw)
  To: Jason Gunthorpe, iommu@lists.linux.dev, Joerg Roedel,
	Robin Murphy, Will Deacon
  Cc: patches@lists.linux.dev

> From: Jason Gunthorpe <jgg@nvidia.com>
> Sent: Thursday, December 5, 2024 4:14 AM
> 
> Since this implements domain_alloc_paging_flags() it only needs one
> op. Fold mock_domain_alloc_paging() into
> mock_domain_alloc_paging_flags().
> 
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

Reviewed-by: Kevin Tian <kevin.tian@intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iommufd/selftest: Remove domain_alloc_paging()
  2024-12-04 20:13 [PATCH] iommufd/selftest: Remove domain_alloc_paging() Jason Gunthorpe
  2024-12-06  7:24 ` Yi Liu
  2024-12-11  8:25 ` Tian, Kevin
@ 2024-12-11 18:14 ` Jason Gunthorpe
  2 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2024-12-11 18:14 UTC (permalink / raw)
  To: iommu, Joerg Roedel, Kevin Tian, Robin Murphy, Will Deacon; +Cc: patches

On Wed, Dec 04, 2024 at 04:13:39PM -0400, Jason Gunthorpe wrote:
> Since this implements domain_alloc_paging_flags() it only needs one
> op. Fold mock_domain_alloc_paging() into mock_domain_alloc_paging_flags().
> 
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
>  drivers/iommu/iommufd/selftest.c | 43 ++++++++++++--------------------
>  1 file changed, 16 insertions(+), 27 deletions(-)

Applied to iommufd for-next thanks

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-12-11 18:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-04 20:13 [PATCH] iommufd/selftest: Remove domain_alloc_paging() Jason Gunthorpe
2024-12-06  7:24 ` Yi Liu
2024-12-11  8:25 ` Tian, Kevin
2024-12-11 18:14 ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox