Skip to content

Commit d9d3ced

Browse files
rmurphy-armjoergroedel
authored andcommitted
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: bcb81ac ("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>
1 parent 280e5a3 commit d9d3ced

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

drivers/iommu/ipmmu-vmsa.c

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,31 +1081,24 @@ static int ipmmu_probe(struct platform_device *pdev)
10811081
}
10821082
}
10831083

1084+
platform_set_drvdata(pdev, mmu);
10841085
/*
10851086
* Register the IPMMU to the IOMMU subsystem in the following cases:
10861087
* - R-Car Gen2 IPMMU (all devices registered)
10871088
* - R-Car Gen3 IPMMU (leaf devices only - skip root IPMMU-MM device)
10881089
*/
1089-
if (!mmu->features->has_cache_leaf_nodes || !ipmmu_is_root(mmu)) {
1090-
ret = iommu_device_sysfs_add(&mmu->iommu, &pdev->dev, NULL,
1091-
dev_name(&pdev->dev));
1092-
if (ret)
1093-
return ret;
1094-
1095-
ret = iommu_device_register(&mmu->iommu, &ipmmu_ops, &pdev->dev);
1096-
if (ret)
1097-
return ret;
1098-
}
1090+
if (mmu->features->has_cache_leaf_nodes && ipmmu_is_root(mmu))
1091+
return 0;
10991092

1100-
/*
1101-
* We can't create the ARM mapping here as it requires the bus to have
1102-
* an IOMMU, which only happens when bus_set_iommu() is called in
1103-
* ipmmu_init() after the probe function returns.
1104-
*/
1093+
ret = iommu_device_sysfs_add(&mmu->iommu, &pdev->dev, NULL, dev_name(&pdev->dev));
1094+
if (ret)
1095+
return ret;
11051096

1106-
platform_set_drvdata(pdev, mmu);
1097+
ret = iommu_device_register(&mmu->iommu, &ipmmu_ops, &pdev->dev);
1098+
if (ret)
1099+
iommu_device_sysfs_remove(&mmu->iommu);
11071100

1108-
return 0;
1101+
return ret;
11091102
}
11101103

11111104
static void ipmmu_remove(struct platform_device *pdev)

0 commit comments

Comments
 (0)