]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iommu/rockchip: prevent iommus dead loop when two masters share one IOMMU
authorSimon Xue <xxm@rock-chips.com>
Mon, 23 Jun 2025 02:00:18 +0000 (10:00 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Jul 2025 14:03:20 +0000 (16:03 +0200)
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: 25c2325575cc ("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>
drivers/iommu/rockchip-iommu.c

index 8ff69fbf9f65db876964a7a90ca9abe1d27f65d2..36fec26d2a04ac0746bd5445ae5d7ff0bb95885a 100644 (file)
@@ -1177,7 +1177,6 @@ static int rk_iommu_of_xlate(struct device *dev,
        iommu_dev = of_find_device_by_node(args->np);
 
        data->iommu = platform_get_drvdata(iommu_dev);
-       data->iommu->domain = &rk_identity_domain;
        dev_iommu_priv_set(dev, data);
 
        platform_device_put(iommu_dev);
@@ -1217,6 +1216,8 @@ static int rk_iommu_probe(struct platform_device *pdev)
        if (!iommu)
                return -ENOMEM;
 
+       iommu->domain = &rk_identity_domain;
+
        platform_set_drvdata(pdev, iommu);
        iommu->dev = dev;
        iommu->num_mmu = 0;