Skip to content

Commit 5af35e9

Browse files
Simon Xuegregkh
authored andcommitted
iommu/rockchip: prevent iommus dead loop when two masters share one IOMMU
commit 62e062a 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>
1 parent f27cf15 commit 5af35e9

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

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
return -ENOMEM;
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)