mbox series

[v2,0/7] Revise the hwpt lifetime model

Message ID 0-v2-406f7ac07936+6a-iommufd_hwpt_jgg@nvidia.com
Headers show
Series Revise the hwpt lifetime model | expand

Message

Jason Gunthorpe Feb. 22, 2023, 9:02 p.m. UTC
As discussed here is a small series to address the confusing lifetime
scheme for the hwpt. This was some leftover from prior rework that was
never fully cleaned up.

Make it clear that the ioas and ioas->hwpt_list are associated with the
hwpt during creation and never changed until it is destroyed. A hwpt with
a positive reference count is always valid for device attachment.

This is a step toward the nesting and replace series.

I have this on github:

https://github.com/jgunthorpe/linux/commits/iommufd_hwpt

v2:
 - Basically completely different
 - Add a test for HWPT cases by enhancing the mock iommu driver to be more
   complete
 - Move the device attachment as well into iommufd_hw_pagetable_alloc()
   so destroy is more symmetric
v1: https://lore.kernel.org/r/0-v1-4336b5cb2fe4+1d7-iommufd_hwpt_jgg@nvidia.com

Jason Gunthorpe (7):
  iommufd: Assert devices_lock for iommufd_hw_pagetable_has_group()
  iommufd: Add iommufd_lock_obj() around the auto-domains hwpts
  iommufd: Move ioas related HWPT destruction into
    iommufd_hw_pagetable_destroy()
  iommufd: Move iommufd_device to iommufd_private.h
  iommufd: Make iommufd_hw_pagetable_alloc() do iopt_table_add_domain()
  iommufd/selftest: Make selftest create a more complete mock device
  iommufd/selftest: Add a selftest for iommufd_device_attach() with a
    hwpt argument

 drivers/iommu/iommufd/device.c                | 150 +++++---------
 drivers/iommu/iommufd/hw_pagetable.c          |  72 ++++++-
 drivers/iommu/iommufd/iommufd_private.h       |  35 +++-
 drivers/iommu/iommufd/selftest.c              | 196 +++++++++++++++---
 tools/testing/selftests/iommu/iommufd.c       |  15 +-
 .../selftests/iommu/iommufd_fail_nth.c        |   8 -
 6 files changed, 319 insertions(+), 157 deletions(-)


base-commit: 8473685c99683f9e2c7e2a42ef3d3f14a79be274