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

Jason Gunthorpe
2023-02-23T13:08:10Z

On Thu, Feb 23, 2023 at 09:03:14AM +0000, Tian, Kevin wrote:
> > 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);

yes

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

yes

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

Yes, this is where Robin's patches are going.

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

Sort of, the domain_alloc_user already takes in the device so SMMU can
be fixed for that API immediately, in theory, but it looks like some
amount of work to get there.

Jason