]> Gentwo Git Trees - linux/.git/commit
iommufd/selftest: Add refcount to mock_iommu_device
authorNicolin Chen <nicolinc@nvidia.com>
Tue, 5 Nov 2024 20:04:26 +0000 (12:04 -0800)
committerJason Gunthorpe <jgg@nvidia.com>
Tue, 12 Nov 2024 15:46:18 +0000 (11:46 -0400)
commit86070569450eec1a3b6a358be90a99cab87aa425
tree5b56731eae8f3d0cc008b24b7bcf7acdf83c8f95
parent18f819901d53b8d1101d3227c87b0d623e9d78f6
iommufd/selftest: Add refcount to mock_iommu_device

For an iommu_dev that can unplug (so far only this selftest does so), the
viommu->iommu_dev pointer has no guarantee of its life cycle after it is
copied from the idev->dev->iommu->iommu_dev.

Track the user count of the iommu_dev. Postpone the exit routine using a
completion, if refcount is unbalanced. The refcount inc/dec will be added
in the following patch.

Link: https://patch.msgid.link/r/33f28d64841b497eebef11b49a571e03103c5d24.1730836219.git.nicolinc@nvidia.com
Suggested-by: Jason Gunthorpe <jgg@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/selftest.c