iommu/vt-d: Handle race between registration and device probe
authorRobin Murphy <robin.murphy@arm.com>
Mon, 15 Aug 2022 16:20:02 +0000 (17:20 +0100)
committerJoerg Roedel <jroedel@suse.de>
Wed, 7 Sep 2022 12:25:01 +0000 (14:25 +0200)
commitc919739ce4721ecf7b96b99253b032df30fcf19b
tree15e18eb7ab4559eed9c5cb8941d43c9c0cec46fb
parentca25ec247aadbff98083e92c5e79c198a16cd2db
iommu/vt-d: Handle race between registration and device probe

Currently we rely on registering all our instances before initially
allowing any .probe_device calls via bus_set_iommu(). In preparation for
phasing out the latter, make sure we won't inadvertently return success
for a device associated with a known but not yet registered instance,
otherwise we'll run straight into iommu_group_get_for_dev() trying to
use NULL ops.

That also highlights an issue with intel_iommu_get_resv_regions() taking
dmar_global_lock from within a section where intel_iommu_init() already
holds it, which already exists via probe_acpi_namespace_devices() when
an ANDD device is probed, but gets more obvious with the upcoming change
to iommu_device_register(). Since they are both read locks it manages
not to deadlock in practice, and a more in-depth rework of this locking
is underway, so no attempt is made to address it here.

Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Link: https://lore.kernel.org/r/579f2692291bcbfc3ac64f7456fcff0d629af131.1660572783.git.robin.murphy@arm.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/intel/iommu.c