From: Yi Liu <yi.l.liu@intel.com>
To: Nicolin Chen <nicolinc@nvidia.com>, <jgg@nvidia.com>,
<kevin.tian@intel.com>, <will@kernel.org>
Cc: <joro@8bytes.org>, <suravee.suthikulpanit@amd.com>,
<robin.murphy@arm.com>, <dwmw2@infradead.org>,
<baolu.lu@linux.intel.com>, <shuah@kernel.org>,
<linux-kernel@vger.kernel.org>, <iommu@lists.linux.dev>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kselftest@vger.kernel.org>, <eric.auger@redhat.com>,
<jean-philippe@linaro.org>, <mdf@kernel.org>,
<mshavit@google.com>, <shameerali.kolothum.thodi@huawei.com>,
<smostafa@google.com>
Subject: Re: [PATCH v2 04/19] iommufd: Allow pt_id to carry viommu_id for IOMMU_HWPT_ALLOC
Date: Thu, 26 Sep 2024 16:50:46 +0800 [thread overview]
Message-ID: <3ddf97a3-cf5b-4907-bbe4-296456951e6b@intel.com> (raw)
In-Reply-To: <2d469a5279ef05820d5993df752d32239878338d.1724776335.git.nicolinc@nvidia.com>
On 2024/8/28 00:59, Nicolin Chen wrote:
> Now a VIOMMU can wrap a shareable nested parent HWPT. So, it can act like
> a nested parent HWPT to allocate a nested HWPT.
>
> Support that in the IOMMU_HWPT_ALLOC ioctl handler, and update its kdoc.
>
> Also, associate a viommu to an allocating nested HWPT.
it still not quite clear to me what vIOMMU obj stands for. Here, it is a
wrapper of s2 hpwt IIUC. But in the cover letter, vIOMMU obj can instanced
per the vIOMMU units in VM. Does it mean each vIOMMU of VM can only have
one s2 HWPT?
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> ---
> drivers/iommu/iommufd/hw_pagetable.c | 24 ++++++++++++++++++++++--
> drivers/iommu/iommufd/iommufd_private.h | 1 +
> include/uapi/linux/iommufd.h | 12 ++++++------
> 3 files changed, 29 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iommu/iommufd/hw_pagetable.c b/drivers/iommu/iommufd/hw_pagetable.c
> index c21bb59c4022..06adbcc304bc 100644
> --- a/drivers/iommu/iommufd/hw_pagetable.c
> +++ b/drivers/iommu/iommufd/hw_pagetable.c
> @@ -57,6 +57,9 @@ void iommufd_hwpt_nested_destroy(struct iommufd_object *obj)
> container_of(obj, struct iommufd_hwpt_nested, common.obj);
>
> __iommufd_hwpt_destroy(&hwpt_nested->common);
> +
> + if (hwpt_nested->viommu)
> + refcount_dec(&hwpt_nested->viommu->obj.users);
> refcount_dec(&hwpt_nested->parent->common.obj.users);
> }
>
> @@ -213,6 +216,7 @@ iommufd_hwpt_paging_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas,
> */
> static struct iommufd_hwpt_nested *
> iommufd_hwpt_nested_alloc(struct iommufd_ctx *ictx,
> + struct iommufd_viommu *viommu,
> struct iommufd_hwpt_paging *parent,
> struct iommufd_device *idev, u32 flags,
> const struct iommu_user_data *user_data)
> @@ -234,13 +238,16 @@ iommufd_hwpt_nested_alloc(struct iommufd_ctx *ictx,
> return ERR_CAST(hwpt_nested);
> hwpt = &hwpt_nested->common;
>
> + if (viommu)
> + refcount_inc(&viommu->obj.users);
> + hwpt_nested->viommu = viommu;
> refcount_inc(&parent->common.obj.users);
> hwpt_nested->parent = parent;
>
> hwpt->domain = ops->domain_alloc_user(idev->dev,
> flags & ~IOMMU_HWPT_FAULT_ID_VALID,
> parent->common.domain,
> - NULL, user_data);
> + viommu, user_data);
> if (IS_ERR(hwpt->domain)) {
> rc = PTR_ERR(hwpt->domain);
> hwpt->domain = NULL;
> @@ -307,7 +314,7 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd)
> struct iommufd_hwpt_nested *hwpt_nested;
>
> hwpt_nested = iommufd_hwpt_nested_alloc(
> - ucmd->ictx,
> + ucmd->ictx, NULL,
> container_of(pt_obj, struct iommufd_hwpt_paging,
> common.obj),
> idev, cmd->flags, &user_data);
> @@ -316,6 +323,19 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd)
> goto out_unlock;
> }
> hwpt = &hwpt_nested->common;
> + } else if (pt_obj->type == IOMMUFD_OBJ_VIOMMU) {
> + struct iommufd_hwpt_nested *hwpt_nested;
> + struct iommufd_viommu *viommu;
> +
> + viommu = container_of(pt_obj, struct iommufd_viommu, obj);
> + hwpt_nested = iommufd_hwpt_nested_alloc(
> + ucmd->ictx, viommu, viommu->hwpt, idev,
> + cmd->flags, &user_data);
> + if (IS_ERR(hwpt_nested)) {
> + rc = PTR_ERR(hwpt_nested);
> + goto out_unlock;
> + }
> + hwpt = &hwpt_nested->common;
> } else {
> rc = -EINVAL;
> goto out_put_pt;
> diff --git a/drivers/iommu/iommufd/iommufd_private.h b/drivers/iommu/iommufd/iommufd_private.h
> index 154f7ba5f45c..1f2a1c133b9a 100644
> --- a/drivers/iommu/iommufd/iommufd_private.h
> +++ b/drivers/iommu/iommufd/iommufd_private.h
> @@ -313,6 +313,7 @@ struct iommufd_hwpt_paging {
> struct iommufd_hwpt_nested {
> struct iommufd_hw_pagetable common;
> struct iommufd_hwpt_paging *parent;
> + struct iommufd_viommu *viommu;
> };
>
> static inline bool hwpt_is_paging(struct iommufd_hw_pagetable *hwpt)
> diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h
> index ac77903b5cc4..51ce6a019c34 100644
> --- a/include/uapi/linux/iommufd.h
> +++ b/include/uapi/linux/iommufd.h
> @@ -430,7 +430,7 @@ enum iommu_hwpt_data_type {
> * @size: sizeof(struct iommu_hwpt_alloc)
> * @flags: Combination of enum iommufd_hwpt_alloc_flags
> * @dev_id: The device to allocate this HWPT for
> - * @pt_id: The IOAS or HWPT to connect this HWPT to
> + * @pt_id: The IOAS or HWPT or VIOMMU to connect this HWPT to
> * @out_hwpt_id: The ID of the new HWPT
> * @__reserved: Must be 0
> * @data_type: One of enum iommu_hwpt_data_type
> @@ -449,11 +449,11 @@ enum iommu_hwpt_data_type {
> * IOMMU_HWPT_DATA_NONE. The HWPT can be allocated as a parent HWPT for a
> * nesting configuration by passing IOMMU_HWPT_ALLOC_NEST_PARENT via @flags.
> *
> - * A user-managed nested HWPT will be created from a given parent HWPT via
> - * @pt_id, in which the parent HWPT must be allocated previously via the
> - * same ioctl from a given IOAS (@pt_id). In this case, the @data_type
> - * must be set to a pre-defined type corresponding to an I/O page table
> - * type supported by the underlying IOMMU hardware.
> + * A user-managed nested HWPT will be created from a given VIOMMU (wrapping a
> + * parent HWPT) or a parent HWPT via @pt_id, in which the parent HWPT must be
> + * allocated previously via the same ioctl from a given IOAS (@pt_id). In this
> + * case, the @data_type must be set to a pre-defined type corresponding to an
> + * I/O page table type supported by the underlying IOMMU hardware.
> *
> * If the @data_type is set to IOMMU_HWPT_DATA_NONE, @data_len and
> * @data_uptr should be zero. Otherwise, both @data_len and @data_uptr
--
Regards,
Yi Liu
next prev parent reply other threads:[~2024-09-26 8:46 UTC|newest]
Thread overview: 149+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-27 16:59 [PATCH v2 00/19] iommufd: Add VIOMMU infrastructure (Part-1) Nicolin Chen
2024-08-27 16:59 ` [PATCH v2 01/19] iommufd: Reorder struct forward declarations Nicolin Chen
2024-09-05 15:44 ` Jason Gunthorpe
2024-08-27 16:59 ` [PATCH v2 02/19] iommufd/viommu: Add IOMMUFD_OBJ_VIOMMU and IOMMU_VIOMMU_ALLOC ioctl Nicolin Chen
2024-09-01 2:39 ` Baolu Lu
2024-09-02 5:27 ` Nicolin Chen
2024-09-04 16:26 ` Jason Gunthorpe
2024-09-04 17:29 ` Nicolin Chen
2024-09-04 23:37 ` Jason Gunthorpe
2024-09-05 3:07 ` Nicolin Chen
2024-09-12 3:39 ` Nicolin Chen
2024-09-15 21:10 ` Jason Gunthorpe
2024-09-05 15:53 ` Jason Gunthorpe
2024-09-05 17:10 ` Nicolin Chen
2024-09-05 17:41 ` Jason Gunthorpe
2024-09-05 18:04 ` Nicolin Chen
2024-08-27 16:59 ` [PATCH v2 03/19] iommu: Pass in a viommu pointer to domain_alloc_user op Nicolin Chen
2024-09-05 15:54 ` Jason Gunthorpe
2024-09-05 17:19 ` Nicolin Chen
2024-08-27 16:59 ` [PATCH v2 04/19] iommufd: Allow pt_id to carry viommu_id for IOMMU_HWPT_ALLOC Nicolin Chen
2024-09-05 15:56 ` Jason Gunthorpe
2024-09-26 8:50 ` Yi Liu [this message]
2024-09-26 20:10 ` Nicolin Chen
2024-09-27 0:43 ` Tian, Kevin
2024-09-27 1:25 ` Nicolin Chen
2024-09-27 2:23 ` Tian, Kevin
2024-09-27 2:57 ` Nicolin Chen
2024-09-27 5:38 ` Yi Liu
2024-09-27 6:02 ` Nicolin Chen
2024-09-27 11:59 ` Jason Gunthorpe
2024-09-27 19:52 ` Nicolin Chen
2024-09-27 12:12 ` Yi Liu
2024-09-27 20:29 ` Nicolin Chen
2024-08-27 16:59 ` [PATCH v2 05/19] iommufd/selftest: Add IOMMU_VIOMMU_ALLOC test coverage Nicolin Chen
2024-08-27 16:59 ` [PATCH v2 06/19] iommufd/viommu: Add IOMMU_VIOMMU_SET/UNSET_VDEV_ID ioctl Nicolin Chen
2024-09-05 16:03 ` Jason Gunthorpe
2024-09-05 17:37 ` Nicolin Chen
2024-09-05 17:43 ` Jason Gunthorpe
2024-09-05 20:14 ` Nicolin Chen
2024-09-11 6:19 ` Tian, Kevin
2024-09-11 7:11 ` Nicolin Chen
2024-09-11 7:18 ` Tian, Kevin
2024-09-11 7:47 ` Nicolin Chen
2024-10-01 8:54 ` Nicolin Chen
2024-10-01 13:46 ` Jason Gunthorpe
2024-10-01 18:45 ` Nicolin Chen
2024-09-27 13:50 ` Mostafa Saleh
2024-09-27 14:01 ` Jason Gunthorpe
2024-09-27 14:22 ` Mostafa Saleh
2024-09-27 14:58 ` Jason Gunthorpe
2024-09-27 15:59 ` Mostafa Saleh
2024-10-04 4:32 ` Alexey Kardashevskiy
2024-10-04 5:33 ` Nicolin Chen
2024-10-04 11:41 ` Jason Gunthorpe
2024-10-04 18:13 ` Nicolin Chen
2024-10-04 18:50 ` Jason Gunthorpe
2024-10-04 19:25 ` Nicolin Chen
2024-10-04 20:17 ` Jason Gunthorpe
2024-10-04 20:33 ` Nicolin Chen
2024-10-07 17:18 ` Jason Gunthorpe
2025-04-30 7:54 ` Alexey Kardashevskiy
2025-04-30 7:58 ` Nicolin Chen
2025-05-05 17:08 ` Jason Gunthorpe
2025-05-06 2:53 ` Nicolin Chen
2025-05-06 4:35 ` Alexey Kardashevskiy
2025-05-06 4:46 ` Tian, Kevin
2025-05-06 12:58 ` Jason Gunthorpe
2025-05-06 19:55 ` Nicolin Chen
2025-05-07 12:28 ` Jason Gunthorpe
2025-05-07 11:18 ` Alexey Kardashevskiy
2025-05-07 12:24 ` Jason Gunthorpe
2025-05-09 2:57 ` Alexey Kardashevskiy
2025-05-09 22:07 ` Jason Gunthorpe
2025-05-10 12:51 ` Alexey Kardashevskiy
2025-05-12 15:31 ` Jason Gunthorpe
2024-08-27 16:59 ` [PATCH v2 07/19] iommufd/selftest: Add IOMMU_VIOMMU_SET/UNSET_VDEV_ID test coverage Nicolin Chen
2024-08-27 16:59 ` [PATCH v2 08/19] iommufd/viommu: Add cache_invalidate for IOMMU_VIOMMU_TYPE_DEFAULT Nicolin Chen
2024-09-05 16:05 ` Jason Gunthorpe
2024-08-27 16:59 ` [PATCH v2 09/19] iommufd: Allow hwpt_id to carry viommu_id for IOMMU_HWPT_INVALIDATE Nicolin Chen
2024-09-05 16:10 ` Jason Gunthorpe
2024-08-27 16:59 ` [PATCH v2 10/19] iommufd/viommu: Add vdev_id helpers for IOMMU drivers Nicolin Chen
2024-09-05 16:14 ` Jason Gunthorpe
2024-09-05 17:53 ` Nicolin Chen
2024-09-11 23:11 ` Jason Gunthorpe
2024-09-12 3:17 ` Nicolin Chen
2024-10-05 5:19 ` Nicolin Chen
2024-10-07 15:38 ` Jason Gunthorpe
2024-10-07 16:36 ` Nicolin Chen
2024-10-07 17:11 ` Jason Gunthorpe
2024-10-07 17:25 ` Nicolin Chen
2024-10-07 18:28 ` Jason Gunthorpe
2024-10-07 19:56 ` Nicolin Chen
2024-08-27 16:59 ` [PATCH v2 11/19] iommu: Add iommu_copy_struct_from_full_user_array helper Nicolin Chen
2024-08-27 16:59 ` [PATCH v2 12/19] iommufd/selftest: Add mock_viommu_invalidate_user op Nicolin Chen
2024-08-27 16:59 ` [PATCH v2 13/19] iommufd/selftest: Add IOMMU_TEST_OP_DEV_CHECK_CACHE test command Nicolin Chen
2024-08-27 16:59 ` [PATCH v2 14/19] iommufd/selftest: Add VIOMMU coverage for IOMMU_HWPT_INVALIDATE ioctl Nicolin Chen
2024-08-27 16:59 ` [PATCH v2 15/19] iommufd/viommu: Add iommufd_viommu_to_parent_domain helper Nicolin Chen
2024-08-27 16:59 ` [PATCH v2 16/19] iommu/arm-smmu-v3: Add arm_smmu_cache_invalidate_user Nicolin Chen
2024-09-05 16:23 ` Jason Gunthorpe
2024-09-05 17:56 ` Nicolin Chen
2024-08-27 16:59 ` [PATCH v2 17/19] iommu/arm-smmu-v3: Add arm_smmu_viommu_cache_invalidate Nicolin Chen
2024-09-05 16:20 ` Jason Gunthorpe
2024-09-05 18:00 ` Nicolin Chen
2024-09-05 18:21 ` Jason Gunthorpe
2024-09-11 6:25 ` Tian, Kevin
2024-09-11 7:20 ` Nicolin Chen
2024-09-11 7:50 ` Baolu Lu
2024-09-11 8:17 ` Tian, Kevin
2024-09-11 8:19 ` Baolu Lu
2024-09-11 21:08 ` Nicolin Chen
2024-09-12 4:45 ` Baolu Lu
2024-09-11 8:13 ` Tian, Kevin
2024-09-11 20:53 ` Nicolin Chen
2024-09-11 23:07 ` Jason Gunthorpe
2024-09-13 2:33 ` Tian, Kevin
2024-09-14 14:50 ` Jason Gunthorpe
2024-09-18 8:10 ` Tian, Kevin
2024-09-23 18:34 ` Jason Gunthorpe
2024-09-11 23:00 ` Jason Gunthorpe
2024-08-27 16:59 ` [PATCH v2 18/19] iommu/arm-smmu-v3: Allow ATS for IOMMU_DOMAIN_NESTED Nicolin Chen
2024-08-27 16:59 ` [PATCH v2 19/19] iommu/arm-smmu-v3: Update comments about ATS and bypass Nicolin Chen
2024-09-11 6:12 ` [PATCH v2 00/19] iommufd: Add VIOMMU infrastructure (Part-1) Tian, Kevin
2024-09-11 7:08 ` Nicolin Chen
2024-09-11 7:18 ` Tian, Kevin
2024-09-11 7:40 ` Nicolin Chen
2024-09-11 8:08 ` Tian, Kevin
2024-09-11 20:21 ` Nicolin Chen
2024-10-01 1:55 ` Alexey Kardashevskiy
2024-10-01 3:36 ` Nicolin Chen
2024-10-01 5:06 ` Alexey Kardashevskiy
2024-10-01 13:44 ` Jason Gunthorpe
2024-09-25 10:30 ` Yi Liu
2024-09-25 18:55 ` Nicolin Chen
2024-09-26 8:47 ` Yi Liu
2024-09-26 20:03 ` Nicolin Chen
2024-09-27 2:05 ` Baolu Lu
2024-09-27 6:14 ` Yi Liu
2024-09-27 5:54 ` Yi Liu
2024-09-27 6:32 ` Nicolin Chen
2024-09-27 12:12 ` Yi Liu
2024-09-27 12:20 ` Jason Gunthorpe
2024-09-29 7:19 ` Yi Liu
2024-10-01 13:48 ` Jason Gunthorpe
2024-10-01 18:40 ` Nicolin Chen
2024-09-27 20:44 ` Nicolin Chen
2024-09-29 7:16 ` Yi Liu
2024-09-30 21:59 ` Nicolin Chen
2024-10-09 7:20 ` Yi Liu
2024-10-09 12:31 ` 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=3ddf97a3-cf5b-4907-bbe4-296456951e6b@intel.com \
--to=yi.l.liu@intel.com \
--cc=baolu.lu@linux.intel.com \
--cc=dwmw2@infradead.org \
--cc=eric.auger@redhat.com \
--cc=iommu@lists.linux.dev \
--cc=jean-philippe@linaro.org \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mdf@kernel.org \
--cc=mshavit@google.com \
--cc=nicolinc@nvidia.com \
--cc=robin.murphy@arm.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=shuah@kernel.org \
--cc=smostafa@google.com \
--cc=suravee.suthikulpanit@amd.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox