Skip to content

Commit 62e062a

Browse files
Simon Xuejoergroedel
authored andcommitted
iommu/rockchip: prevent iommus dead loop when two masters share one IOMMU
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: <[email protected]> Fixes: 25c2325 ("iommu/rockchip: Add missing set_platform_dma_ops callback") Signed-off-by: Simon Xue <[email protected]> Reviewed-by: Robin Murphy <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 86731a2 commit 62e062a

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
@@ -1157,7 +1157,6 @@ static int rk_iommu_of_xlate(struct device *dev,
11571157
return -ENOMEM;
11581158

11591159
data->iommu = platform_get_drvdata(iommu_dev);
1160-
data->iommu->domain = &rk_identity_domain;
11611160
dev_iommu_priv_set(dev, data);
11621161

11631162
platform_device_put(iommu_dev);
@@ -1195,6 +1194,8 @@ static int rk_iommu_probe(struct platform_device *pdev)
11951194
if (!iommu)
11961195
return -ENOMEM;
11971196

1197+
iommu->domain = &rk_identity_domain;
1198+
11981199
platform_set_drvdata(pdev, iommu);
11991200
iommu->dev = dev;
12001201
iommu->num_mmu = 0;

0 commit comments

Comments
 (0)