mbox series

[v3,00/12] Revise the hwpt lifetime model

Message ID 0-v3-ae9c2975a131+2e1e8-iommufd_hwpt_jgg@nvidia.com (mailing list archive)
Headers show
Series Revise the hwpt lifetime model | expand

Message

Jason Gunthorpe March 1, 2023, 7:30 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 also improves the selftest handling of the mock domains so that we
can implement more testing for the hwpt model.

This is a step toward the nesting and replace series.

I have this on github:

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

v3:
 - Split patch to just make the hwpt_item handling consistent
 - Remove two confusing comments
 - Four new patches to clean up the confusing 'domain_id' in the selftest
v2: https://lore.kernel.org/r/0-v2-406f7ac07936+6a-iommufd_hwpt_jgg@nvidia.com
 - 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 (12):
  iommufd: Assert devices_lock for iommufd_hw_pagetable_has_group()
  iommufd: Add iommufd_lock_obj() around the auto-domains hwpts
  iommufd: Consistently manage hwpt_item
  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: Rename the sefltest 'device_id' to 'stdev_id'
  iommufd/selftest: Rename domain_id to stdev_id for FIXTURE
    iommufd_ioas
  iommufd/selftest: Rename domain_id to hwpt_id for FIXTURE
    iommufd_mock_domain
  iommufd/selftest: Rename the remaining mock device_id's to stdev_id
  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                | 149 +++++--------
 drivers/iommu/iommufd/hw_pagetable.c          |  70 ++++++-
 drivers/iommu/iommufd/iommufd_private.h       |  35 +++-
 drivers/iommu/iommufd/iommufd_test.h          |   2 +-
 drivers/iommu/iommufd/selftest.c              | 198 +++++++++++++++---
 tools/testing/selftests/iommu/iommufd.c       |  68 +++---
 .../selftests/iommu/iommufd_fail_nth.c        |  38 ++--
 tools/testing/selftests/iommu/iommufd_utils.h |  16 +-
 8 files changed, 368 insertions(+), 208 deletions(-)


base-commit: 8473685c99683f9e2c7e2a42ef3d3f14a79be274

Comments

Jason Gunthorpe March 6, 2023, 5:16 p.m. UTC | #1
On Wed, Mar 01, 2023 at 03:30:17PM -0400, Jason Gunthorpe wrote:
> 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 also improves the selftest handling of the mock domains so that we
> can implement more testing for the hwpt model.
> 
> This is a step toward the nesting and replace series.
> 
> I have this on github:
> 
> https://github.com/jgunthorpe/linux/commits/iommufd_hwpt
> 
> v3:
>  - Split patch to just make the hwpt_item handling consistent
>  - Remove two confusing comments
>  - Four new patches to clean up the confusing 'domain_id' in the selftest
> v2: https://lore.kernel.org/r/0-v2-406f7ac07936+6a-iommufd_hwpt_jgg@nvidia.com
>  - 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

Applied to iommufd for-next with the noted comment update

Thanks,
Jason