RE: [PATCH v2 5/7] iommufd: Make iommufd_hw_pagetable_alloc() do iopt_table_add_domain()

Tian, Kevin
2023-02-23T09:03:39Z

> From: Jason Gunthorpe <jgg@nvidia.com>
> Sent: Thursday, February 23, 2023 5:03 AM
>
> 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.
>

Is below understanding correct on how to retire immediate_attach?

1) immediate_attach=true in auto domain path for back compat (what
this patch does);

2) immediate_attach=false when adding hwpt_alloc() uAPI and VT-d
support;

3) fix domain_alloc() to take struct device so the SMMU drivers can
decide the domain info w/o relying on attach;

4) remove immediate_attach and enable hwpt_alloc() on SMMU.

Of course 3) doesn't need to wait. If it happens before 2) is merged
then 2/4) can come together.