Skip to content

iommufd: Remove iommufd_hw_pagetable_has_group

Nicolin Chen linux-iommu lkml 2 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 40 repliesIn review
  2. v13 patches 1 replySuperseded

Changes in v2 from the cover letter

* Fixed a copy-n-paste mistake at a lockdep_assert_held() line

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3iommufd: Add devices_users to track the hw_pagetable usage by devicedrivers/iommu/iommufd/device.c drivers/iommu/iommufd/hw_pagetable.c drivers/iommu/iommufd/iommufd_private.h+17 -324 replies
2/3iommufd/device: Make hwpt_list list_add/del symmetricdrivers/iommu/iommufd/device.c+12 -146 replies
3/3iommufd/device: Change iommufd_hw_pagetable_has_group to device centricdrivers/iommu/iommufd/device.c drivers/iommu/iommufd/hw_pagetable.c drivers/iommu/iommufd/iommufd_private.h+12 -3510 replies

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchKevin Tian
1/3
2/3R-b
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/3] iommufd: Remove iommufd_hw_pagetable_has_group

The iommufd_hw_pagetable_has_group is not a device-centric API and has been a bit of a hack. And it needs to keep tracking an attached device list on the hw_pagetable, and a device lock to protect the device list.

However, the coming domain replacement series can overcomplicate this list/lock solution, especially to handle nested hw_pagetable use cases. So, as a preparatory series, remove the device list/lock and also fix the iommufd_hw_pagetable_has_group hack.

The iommufd_hw_pagetable_has_group() using the device list could be replaced with a domain-pointer comparison between the hwpt->domain and iommu_get_domain_for_dev(). The piece of dependency on list_empty() of the device list can be also replaced with a refcount. Yet, the removal of the device lock might introduce a race condition, so the ioas mutex can be moved as an alternative protection.

You can also find this series on Github:
https://github.com/nicolinc/iommufd/commits/remove_iommufd_hw_pagetable_has_group

Changelog
v1->v2:
* Fixed a copy-n-paste mistake at a lockdep_assert_held() line

Thanks
Nicolin Chen

Nicolin Chen (2):
iommufd/device: Make hwpt_list list_add/del symmetric iommufd/device: Change iommufd_hw_pagetable_has_group to device
centric

Yi Liu (1):
iommufd: Add devices_users to track the hw_pagetable usage by device

 drivers/iommu/iommufd/device.c          | 72 ++++++++++---------------
 drivers/iommu/iommufd/hw_pagetable.c    | 16 ++++--
 drivers/iommu/iommufd/iommufd_private.h |  3 +-
 3 files changed, 40 insertions(+), 51 deletions(-)
Signature · 1 line
2.39.1