iommufd/access: Add internal APIs for HW queue to use
authorNicolin Chen <nicolinc@nvidia.com>
Thu, 10 Jul 2025 05:59:02 +0000 (22:59 -0700)
committerJason Gunthorpe <jgg@nvidia.com>
Thu, 10 Jul 2025 15:38:51 +0000 (12:38 -0300)
commit1c26c3bbdee11f3fad0c74b8f09aef488dcf4b62
treed525c725423c73e2366936e45f42ed6a21b83b73
parent0e3e0b0c08e388cd9e05bb4d17534bd36bedc9fe
iommufd/access: Add internal APIs for HW queue to use

The new HW queue object, as an internal iommufd object, wants to reuse the
struct iommufd_access to pin some iova range in the iopt.

However, an access generally takes the refcount of an ictx. So, in such an
internal case, a deadlock could happen when the release of the ictx has to
wait for the release of the access first when releasing a hw_queue object,
which could wait for the release of the ictx that is refcounted:
    ictx --releases--> hw_queue --releases--> access
      ^                                         |
      |_________________releases________________v

To address this, add a set of lightweight internal APIs to unlink the ictx
and the access, i.e. no ictx refcounting by the access:
    ictx --releases--> hw_queue --releases--> access

Then, there's no point in setting the access->ictx. So simply define !ictx
as an flag for an internal use and add an inline helper.

Link: https://patch.msgid.link/r/d8d84bf99cbebec56034b57b966a3d431385b90d.1752126748.git.nicolinc@nvidia.com
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/iommu/iommufd/device.c
drivers/iommu/iommufd/iommufd_private.h