fa02ba3
From: Thierry Reding <treding@nvidia.com>
fa02ba3
Date: Fri, 6 Feb 2015 11:44:07 +0100
fa02ba3
Subject: [PATCH] iommu/rockchip: Play nice in multi-platform builds
fa02ba3
fa02ba3
The Rockchip IOMMU driver unconditionally executes code and registers a
fa02ba3
struct iommu_ops with the platform bus irrespective of whether it runs
fa02ba3
on a Rockchip SoC or not. This causes problems in multi-platform kernels
fa02ba3
where drivers for other SoCs will no longer be able to register their
fa02ba3
own struct iommu_ops or even try to use a struct iommu_ops for an IOMMU
fa02ba3
that obviously isn't there.
fa02ba3
fa02ba3
The smallest fix I could think of is to check for the existence of any
fa02ba3
Rockchip IOMMU devices in the device tree and skip initialization
fa02ba3
otherwise.
fa02ba3
fa02ba3
This fixes a problem on Tegra20 where the DRM driver will try to use the
fa02ba3
obviously non-existent Rockchip IOMMU.
fa02ba3
fa02ba3
Reported-by: Nicolas Chauvet <kwizart@gmail.com>
fa02ba3
Cc: Heiko Stuebner <heiko@sntech.de>
fa02ba3
Cc: Daniel Kurtz <djkurtz@chromium.org>
fa02ba3
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
fa02ba3
Tested-by: Heiko Stuebner <heiko@sntech.de>
fa02ba3
Signed-off-by: Thierry Reding <treding@nvidia.com>
fa02ba3
Signed-off-by: Joerg Roedel <jroedel@suse.de>
fa02ba3
---
fa02ba3
 drivers/iommu/rockchip-iommu.c | 7 +++++++
fa02ba3
 1 file changed, 7 insertions(+)
fa02ba3
fa02ba3
diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
fa02ba3
index 6a8b1ec4a48a..9f74fddcd304 100644
fa02ba3
--- a/drivers/iommu/rockchip-iommu.c
fa02ba3
+++ b/drivers/iommu/rockchip-iommu.c
fa02ba3
@@ -1015,8 +1015,15 @@ static struct platform_driver rk_iommu_driver = {
fa02ba3
 
fa02ba3
 static int __init rk_iommu_init(void)
fa02ba3
 {
fa02ba3
+	struct device_node *np;
fa02ba3
 	int ret;
fa02ba3
 
fa02ba3
+	np = of_find_matching_node(NULL, rk_iommu_dt_ids);
fa02ba3
+	if (!np)
fa02ba3
+		return 0;
fa02ba3
+
fa02ba3
+	of_node_put(np);
fa02ba3
+
fa02ba3
 	ret = bus_set_iommu(&platform_bus_type, &rk_iommu_ops);
fa02ba3
 	if (ret)
fa02ba3
 		return ret;
fa02ba3
-- 
fa02ba3
2.1.0
fa02ba3