Skip to content

Commit f12fc61

Browse files
Simon Xuesmb49
authored andcommitted
iommu/rockchip: prevent iommus dead loop when two masters share one IOMMU
BugLink: https://bugs.launchpad.net/bugs/2122072 commit 62e062a29ad5133f67c20b333ba0a952a99161ae upstream. When two masters share an IOMMU, calling ops->of_xlate during the second master's driver init may overwrite iommu->domain set by the first. This causes the check if (iommu->domain == domain) in rk_iommu_attach_device() to fail, resulting in the same iommu->node being added twice to &rk_domain->iommus, which can lead to an infinite loop in subsequent &rk_domain->iommus operations. Cc: <stable@vger.kernel.org> Fixes: 25c2325 ("iommu/rockchip: Add missing set_platform_dma_ops callback") Signed-off-by: Simon Xue <xxm@rock-chips.com> Reviewed-by: Robin Murphy <robin.murphy@arm.com> Link: https://lore.kernel.org/r/20250623020018.584802-1-xxm@rock-chips.com Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Noah Wager <noah.wager@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent df6d85f commit f12fc61

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/iommu/rockchip-iommu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,6 @@ static int rk_iommu_of_xlate(struct device *dev,
11551155
iommu_dev = of_find_device_by_node(args->np);
11561156

11571157
data->iommu = platform_get_drvdata(iommu_dev);
1158-
data->iommu->domain = &rk_identity_domain;
11591158
dev_iommu_priv_set(dev, data);
11601159

11611160
platform_device_put(iommu_dev);
@@ -1193,6 +1192,8 @@ static int rk_iommu_probe(struct platform_device *pdev)
11931192
if (!iommu)
11941193
return -ENOMEM;
11951194

1195+
iommu->domain = &rk_identity_domain;
1196+
11961197
platform_set_drvdata(pdev, iommu);
11971198
iommu->dev = dev;
11981199
iommu->num_mmu = 0;

0 commit comments

Comments
 (0)