iommu: Split off default domain allocation from group assignment
authorJoerg Roedel <jroedel@suse.de>
Wed, 29 Apr 2020 13:36:49 +0000 (15:36 +0200)
committerJoerg Roedel <jroedel@suse.de>
Tue, 5 May 2020 12:36:12 +0000 (14:36 +0200)
commitdeac0b3bed26bb5d04486696b1071d8ec3851100
tree0463da9d8dc4b60a147046e0e43dd21789e07c80
parentcf193888bfbd3d57e03a511e49d26f7d9c6f76df
iommu: Split off default domain allocation from group assignment

When a bus is initialized with iommu-ops, all devices on the bus are
scanned and iommu-groups are allocated for them, and each groups will
also get a default domain allocated.

Until now this happened as soon as the group was created and the first
device added to it. When other devices with different default domain
requirements were added to the group later on, the default domain was
re-allocated, if possible.

This resulted in some back and forth and unnecessary allocations, so
change the flow to defer default domain allocation until all devices
have been added to their respective IOMMU groups.

The default domains are allocated for newly allocated groups after
each device on the bus is handled and was probed by the IOMMU driver.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Link: https://lore.kernel.org/r/20200429133712.31431-12-joro@8bytes.org
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/iommu.c