RE: [PATCH v4 14/17] iommu: Consolidate the default_domain setup to one function

Tian, Kevin
2023-04-20T07:57:46Z

> From: Jason Gunthorpe <jgg@nvidia.com>
> Sent: Wednesday, April 12, 2023 9:52 PM
>
> Make iommu_change_dev_def_domain() general enough to setup the initial
> default_domain or replace it with a new default_domain. Call the new
> function iommu_setup_default_domain() and make it the only place in the
> code that stores to group->default_domain.
>
> Consolidate the three copies of the default_domain setup sequence. The
> flow
> flow requires:
>
> - Determining the domain type to use
> - Checking if the current default domain is the same type
> - Allocating a domain
> - Doing iommu_create_device_direct_mappings()
> - Attaching it to devices
> - Store group->default_domain
>
> This adjusts the domain allocation from the prior patch to be able to
> detect if each of the allocation steps is already the domain we already
> have, which is a more robust version of what change default domain was
> already doing.
>
> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

Reviewed-by: Kevin Tian <kevin.tian@intel.com>