From: Yi Liu <yi.l.liu@intel.com>
To: Jason Gunthorpe <jgg@nvidia.com>, <iommu@lists.linux.dev>,
Joerg Roedel <joro@8bytes.org>, Kevin Tian <kevin.tian@intel.com>,
Robin Murphy <robin.murphy@arm.com>,
Will Deacon <will@kernel.org>
Cc: <patches@lists.linux.dev>
Subject: Re: [PATCH] iommufd/selftest: Remove domain_alloc_paging()
Date: Fri, 6 Dec 2024 15:24:05 +0800 [thread overview]
Message-ID: <55d8952d-5628-44cc-8e01-2effea9bbdd4@intel.com> (raw)
In-Reply-To: <0-v1-8a3e7e21ff6a+1745d-iommufd_paging_flags_jgg@nvidia.com>
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
next prev parent reply other threads:[~2024-12-06 7:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-04 20:13 [PATCH] iommufd/selftest: Remove domain_alloc_paging() Jason Gunthorpe
2024-12-06 7:24 ` Yi Liu [this message]
2024-12-11 8:25 ` Tian, Kevin
2024-12-11 18:14 ` Jason Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55d8952d-5628-44cc-8e01-2effea9bbdd4@intel.com \
--to=yi.l.liu@intel.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=patches@lists.linux.dev \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.