diff options
author | Jason Gunthorpe <jgg@nvidia.com> | 2023-07-17 21:12:04 +0300 |
---|---|---|
committer | Jason Gunthorpe <jgg@nvidia.com> | 2023-07-26 16:19:47 +0300 |
commit | d03f1336fd91b87ad218dd398265332b1cd2c68c (patch) | |
tree | 64cb5954570ad41c039939c7d5c9c66fc73ca415 /drivers/iommu/iommufd/iommufd_private.h | |
parent | 1d149ab2e0062a98b3676d6ee0aaa34be16f4d4f (diff) | |
download | linux-d03f1336fd91b87ad218dd398265332b1cd2c68c.tar.xz |
iommufd: Move putting a hwpt to a helper function
Next patch will need to call this from two places.
Link: https://lore.kernel.org/r/8-v8-6659224517ea+532-iommufd_alloc_jgg@nvidia.com
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Tested-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Diffstat (limited to 'drivers/iommu/iommufd/iommufd_private.h')
-rw-r--r-- | drivers/iommu/iommufd/iommufd_private.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/iommu/iommufd/iommufd_private.h b/drivers/iommu/iommufd/iommufd_private.h index 6e11d6ef71ee..8bdbef8bd878 100644 --- a/drivers/iommu/iommufd/iommufd_private.h +++ b/drivers/iommu/iommufd/iommufd_private.h @@ -260,6 +260,16 @@ struct iommufd_hw_pagetable * iommufd_hw_pagetable_detach(struct iommufd_device *idev); void iommufd_hw_pagetable_destroy(struct iommufd_object *obj); +static inline void iommufd_hw_pagetable_put(struct iommufd_ctx *ictx, + struct iommufd_hw_pagetable *hwpt) +{ + lockdep_assert_not_held(&hwpt->ioas->mutex); + if (hwpt->auto_domain) + iommufd_object_destroy_user(ictx, &hwpt->obj); + else + refcount_dec(&hwpt->obj.users); +} + struct iommufd_group { struct kref ref; struct mutex lock; |