Skip to content

Commit 89d6387

Browse files
yiliu1765jgunthorpe
authored andcommitted
iommufd: Flow user flags for domain allocation to domain_alloc_user()
Extends iommufd_hw_pagetable_alloc() to accept user flags, the uAPI will provide the flags. Link: https://lore.kernel.org/r/20230928071528.26258-4-yi.l.liu@intel.com Reviewed-by: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Yi Liu <yi.l.liu@intel.com> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 7975b72 commit 89d6387

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

drivers/iommu/iommufd/device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ iommufd_device_auto_get_domain(struct iommufd_device *idev,
540540
}
541541

542542
hwpt = iommufd_hw_pagetable_alloc(idev->ictx, ioas, idev,
543-
immediate_attach);
543+
0, immediate_attach);
544544
if (IS_ERR(hwpt)) {
545545
destroy_hwpt = ERR_CAST(hwpt);
546546
goto out_unlock;

drivers/iommu/iommufd/hw_pagetable.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ int iommufd_hw_pagetable_enforce_cc(struct iommufd_hw_pagetable *hwpt)
6161
* @ictx: iommufd context
6262
* @ioas: IOAS to associate the domain with
6363
* @idev: Device to get an iommu_domain for
64+
* @flags: Flags from userspace
6465
* @immediate_attach: True if idev should be attached to the hwpt
6566
*
6667
* Allocate a new iommu_domain and return it as a hw_pagetable. The HWPT
@@ -73,7 +74,8 @@ int iommufd_hw_pagetable_enforce_cc(struct iommufd_hw_pagetable *hwpt)
7374
*/
7475
struct iommufd_hw_pagetable *
7576
iommufd_hw_pagetable_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas,
76-
struct iommufd_device *idev, bool immediate_attach)
77+
struct iommufd_device *idev, u32 flags,
78+
bool immediate_attach)
7779
{
7880
const struct iommu_ops *ops = dev_iommu_ops(idev->dev);
7981
struct iommufd_hw_pagetable *hwpt;
@@ -91,7 +93,7 @@ iommufd_hw_pagetable_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas,
9193
hwpt->ioas = ioas;
9294

9395
if (ops->domain_alloc_user) {
94-
hwpt->domain = ops->domain_alloc_user(idev->dev, 0);
96+
hwpt->domain = ops->domain_alloc_user(idev->dev, flags);
9597
if (IS_ERR(hwpt->domain)) {
9698
rc = PTR_ERR(hwpt->domain);
9799
hwpt->domain = NULL;
@@ -166,7 +168,8 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd)
166168
}
167169

168170
mutex_lock(&ioas->mutex);
169-
hwpt = iommufd_hw_pagetable_alloc(ucmd->ictx, ioas, idev, false);
171+
hwpt = iommufd_hw_pagetable_alloc(ucmd->ictx, ioas,
172+
idev, cmd->flags, false);
170173
if (IS_ERR(hwpt)) {
171174
rc = PTR_ERR(hwpt);
172175
goto out_unlock;

drivers/iommu/iommufd/iommufd_private.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ struct iommufd_hw_pagetable {
242242

243243
struct iommufd_hw_pagetable *
244244
iommufd_hw_pagetable_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas,
245-
struct iommufd_device *idev, bool immediate_attach);
245+
struct iommufd_device *idev, u32 flags,
246+
bool immediate_attach);
246247
int iommufd_hw_pagetable_enforce_cc(struct iommufd_hw_pagetable *hwpt);
247248
int iommufd_hw_pagetable_attach(struct iommufd_hw_pagetable *hwpt,
248249
struct iommufd_device *idev);

0 commit comments

Comments
 (0)