2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00

iommu/ipmmu-vmsa: Register in a sensible order

IPMMU registers almost-initialised instances, but misses assigning the
drvdata to make them fully functional, so initial calls back into
ipmmu_probe_device() are likely to fail unnecessarily. Reorder this to
work as it should, also pruning the long-out-of-date comment and adding
the missing sysfs cleanup on error for good measure.

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Fixes: bcb81ac6ae ("iommu: Get DT/ACPI parsing into the proper probe path")
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/53be6667544de65a15415b699e38a9a965692e45.1742481687.git.robin.murphy@arm.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
Robin Murphy 2025-03-20 14:41:27 +00:00 committed by Joerg Roedel
parent 280e5a3010
commit d9d3cede41

View File

@ -1081,31 +1081,24 @@ static int ipmmu_probe(struct platform_device *pdev)
} }
} }
platform_set_drvdata(pdev, mmu);
/* /*
* Register the IPMMU to the IOMMU subsystem in the following cases: * Register the IPMMU to the IOMMU subsystem in the following cases:
* - R-Car Gen2 IPMMU (all devices registered) * - R-Car Gen2 IPMMU (all devices registered)
* - R-Car Gen3 IPMMU (leaf devices only - skip root IPMMU-MM device) * - R-Car Gen3 IPMMU (leaf devices only - skip root IPMMU-MM device)
*/ */
if (!mmu->features->has_cache_leaf_nodes || !ipmmu_is_root(mmu)) { if (mmu->features->has_cache_leaf_nodes && ipmmu_is_root(mmu))
ret = iommu_device_sysfs_add(&mmu->iommu, &pdev->dev, NULL, return 0;
dev_name(&pdev->dev));
if (ret)
return ret;
ret = iommu_device_register(&mmu->iommu, &ipmmu_ops, &pdev->dev); ret = iommu_device_sysfs_add(&mmu->iommu, &pdev->dev, NULL, dev_name(&pdev->dev));
if (ret) if (ret)
return ret; return ret;
}
/* ret = iommu_device_register(&mmu->iommu, &ipmmu_ops, &pdev->dev);
* We can't create the ARM mapping here as it requires the bus to have if (ret)
* an IOMMU, which only happens when bus_set_iommu() is called in iommu_device_sysfs_remove(&mmu->iommu);
* ipmmu_init() after the probe function returns.
*/
platform_set_drvdata(pdev, mmu); return ret;
return 0;
} }
static void ipmmu_remove(struct platform_device *pdev) static void ipmmu_remove(struct platform_device *pdev)