iommufd: Make iommufd_hw_pagetable_alloc() do iopt_table_add_domain()
authorJason Gunthorpe <jgg@nvidia.com>
Wed, 1 Mar 2023 19:30:23 +0000 (15:30 -0400)
committerJason Gunthorpe <jgg@nvidia.com>
Mon, 6 Mar 2023 14:51:57 +0000 (10:51 -0400)
commit339fbf3ae144263725ccb7694cd2366d5e0c6ebf
treee09e6620947c64bf7b7fa43278346ecc388ebd15
parent7e7ec8a5692105450bbfde8c310af606e216add0
iommufd: Make iommufd_hw_pagetable_alloc() do iopt_table_add_domain()

The HWPT is always linked to an IOAS and once a HWPT exists its domain
should be fully mapped. This ended up being split up into device.c during
a two phase creation that was a bit confusing.

Move the iopt_table_add_domain() into iommufd_hw_pagetable_alloc() by
having it call back to device.c to complete the domain attach in the
required order.

Calling iommufd_hw_pagetable_alloc() with immediate_attach = false will
work on most drivers, but notably the SMMU drivers will fail because they
can't decide what kind of domain to create until they are attached. This
will be fixed when the domain_alloc function can take in a struct device.

Link: https://lore.kernel.org/r/6-v3-ae9c2975a131+2e1e8-iommufd_hwpt_jgg@nvidia.com
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/iommu/iommufd/device.c
drivers/iommu/iommufd/hw_pagetable.c
drivers/iommu/iommufd/iommufd_private.h