Skip to contentSkip to conversation

iommu: A couple of urgent fixes

PATCH Applied Thierry Reding 4 participants 8 messages Feb 6, 2015 – Feb 25, 2015 2 messages not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover iommu: A couple of urgent fixes

From: Thierry Reding <[email protected]>

Hi Joerg,

Here are a couple of urgent fixes for a regression on old Tegra devices related to IOMMU support. The issue is that many drivers think it's a good idea to register IOMMU support unconditionally, which is not the smart thing to do at all on multi-platform kernels. This probably went unnoticed for a while because the offending drivers aren't enabled in any of the multi-platform default configurations. Fedora ARM has their own config where the offending drivers did get enabled, hence caused a regression on Tegra20. I would expect the same regression to exist on a number of other SoCs, possibly all that support IOMMU.

I've tried to keep the patches minimal in the hopes of still getting this into v3.19-rc8 or the final release to avoid the regression.

Changes in v2:
- avoid potential leak by dropping references to device tree nodes
- remove fixups from module exit functions since they are unused

Thierry

Thierry Reding (4):
iommu/exynos: Play nice in multi-platform builds iommu/omap: Play nice in multi-platform builds iommu/rockchip: Play nice in multi-platform builds iommu/msm: Mark driver BROKEN

 drivers/iommu/Kconfig          | 1 +
 drivers/iommu/exynos-iommu.c   | 7 +++++++
 drivers/iommu/omap-iommu.c     | 7 +++++++
 drivers/iommu/rockchip-iommu.c | 7 +++++++
 4 files changed, 22 insertions(+)
Signature · 1 line
2.1.3

A message that is not in the archive (sent off-list or not yet received): 1423219448-22683-1-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH v2 1/4 iommu/exynos: Play nice in multi-platform builds

From: Thierry Reding <[email protected]>

The Exynos System MMU driver unconditionally executes code and registers a struct iommu_ops with the platform bus irrespective of whether it runs on an Exynos SoC or not. This causes problems in multi-platform kernels where drivers for other SoCs will no longer be able to register their own struct iommu_ops or even try to use a struct iommu_ops for an IOMMU that obviously isn't there.

The smallest fix I could think of is to check for the existence of any Exynos System MMU devices in the device tree and skip initialization otherwise.

This fixes a problem on Tegra20 where the DRM driver will try to use the obviously non-existent Exynos System MMU.

---
Changes in v2:
- drop reference to struct device_node

 drivers/iommu/exynos-iommu.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/iommu/exynos-iommu.c +7 -0
index 7ce52737c7a1..dc14fec4ede1 100644
@@ -1186,8 +1186,15 @@ static const struct iommu_ops exynos_iommu_ops = {
 
 static int __init exynos_iommu_init(void)
 {
+	struct device_node *np;
 	int ret;
 
+	np = of_find_matching_node(NULL, sysmmu_of_match);
+	if (!np)
+		return 0;
+
+	of_node_put(np);
+
 	lv2table_kmem_cache = kmem_cache_create("exynos-iommu-lv2table",
 				LV2TABLE_SIZE, LV2TABLE_SIZE, 0, NULL);
 	if (!lv2table_kmem_cache) {
Signature · 1 line
2.1.3
#3 lore raw

PATCH v2 2/4 iommu/omap: Play nice in multi-platform builds

In reply to a message not in the archive

From: Thierry Reding <[email protected]>

The OMAP IOMMU driver unconditionally executes code and registers a struct iommu_ops with the platform bus irrespective of whether it runs on an OMAP SoC or not. This causes problems in multi-platform kernels where drivers for other SoCs will no longer be able to register their own struct iommu_ops or even try to use a struct iommu_ops for an IOMMU that obviously isn't there.

The smallest fix I could think of is to check for the existence of any OMAP IOMMU devices in the device tree and skip initialization otherwise.

This fixes a problem on Tegra20 where the DRM driver will try to use the obviously non-existent OMAP IOMMU.

Cc Tony Lindgren <[email protected]>
Cc Suman Anna <[email protected]>
Cc Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/[email protected]>

---
Changes in v2:
- do not fix up module exit function since it's dead code
- drop reference to struct device_node

 drivers/iommu/omap-iommu.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/iommu/omap-iommu.c +7 -0
index f59f857b702e..a4ba851825c2 100644
@@ -1376,6 +1376,13 @@ static int __init omap_iommu_init(void)
 	struct kmem_cache *p;
 	const unsigned long flags = SLAB_HWCACHE_ALIGN;
 	size_t align = 1 << 10; /* L2 pagetable alignement */
+	struct device_node *np;
+
+	np = of_find_matching_node(NULL, omap_iommu_of_match);
+	if (!np)
+		return 0;
+
+	of_node_put(np);
 
 	p = kmem_cache_create("iopte_cache", IOPTE_TABLE_SIZE, align, flags,
 			      iopte_cachep_ctor);
Signature · 1 line
2.1.3

A message that is not in the archive (sent off-list or not yet received): 1423219448-22683-3-git-send-email-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#5 lore raw

Re: [PATCH v2 2/4] iommu/omap: Play nice in multi-platform builds

Hi Thierry,

Thank you for the patch.

Quoted 12 lines · On Friday 06 February 2015 11:44:06 Thierry Reding wrote:

From: Thierry Reding <[email protected]>

The OMAP IOMMU driver unconditionally executes code and registers a struct iommu_ops with the platform bus irrespective of whether it runs on an OMAP SoC or not. This causes problems in multi-platform kernels where drivers for other SoCs will no longer be able to register their own struct iommu_ops or even try to use a struct iommu_ops for an IOMMU that obviously isn't there.

The smallest fix I could think of is to check for the existence of any OMAP IOMMU devices in the device tree and skip initialization otherwise.

Quoted 8 lines

This fixes a problem on Tegra20 where the DRM driver will try to use the obviously non-existent OMAP IOMMU.

Cc Tony Lindgren <[email protected]>
Cc Suman Anna <[email protected]>
Cc Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/[email protected]>
Quoted 26 lines

---
Changes in v2:
- do not fix up module exit function since it's dead code
- drop reference to struct device_node

 drivers/iommu/omap-iommu.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/iommu/omap-iommu.c +7 -0
index f59f857b702e..a4ba851825c2 100644
@@ -1376,6 +1376,13 @@ static int __init omap_iommu_init(void)
 	struct kmem_cache *p;
 	const unsigned long flags = SLAB_HWCACHE_ALIGN;
 	size_t align = 1 << 10; /* L2 pagetable alignement */
+	struct device_node *np;
+
+	np = of_find_matching_node(NULL, omap_iommu_of_match);
+	if (!np)
+		return 0;
+
+	of_node_put(np);
 
 	p = kmem_cache_create("iopte_cache", IOPTE_TABLE_SIZE, align, flags,
 			      iopte_cachep_ctor);
Signature · 3 lines
Regards,

Laurent Pinchart
#6 lore raw

PATCH v2 3/4 iommu/rockchip: Play nice in multi-platform builds

In reply to a message not in the archive

From: Thierry Reding <[email protected]>

The Rockchip IOMMU driver unconditionally executes code and registers a struct iommu_ops with the platform bus irrespective of whether it runs on a Rockchip SoC or not. This causes problems in multi-platform kernels where drivers for other SoCs will no longer be able to register their own struct iommu_ops or even try to use a struct iommu_ops for an IOMMU that obviously isn't there.

The smallest fix I could think of is to check for the existence of any Rockchip IOMMU devices in the device tree and skip initialization otherwise.

This fixes a problem on Tegra20 where the DRM driver will try to use the obviously non-existent Rockchip IOMMU.

---
Changes in v2:
- do not fix up module exit function since it's dead code
- drop reference to struct device_node

 drivers/iommu/rockchip-iommu.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/iommu/rockchip-iommu.c +7 -0
index 6a8b1ec4a48a..9f74fddcd304 100644
@@ -1015,8 +1015,15 @@ static struct platform_driver rk_iommu_driver = {
 
 static int __init rk_iommu_init(void)
 {
+	struct device_node *np;
 	int ret;
 
+	np = of_find_matching_node(NULL, rk_iommu_dt_ids);
+	if (!np)
+		return 0;
+
+	of_node_put(np);
+
 	ret = bus_set_iommu(&platform_bus_type, &rk_iommu_ops);
 	if (ret)
 		return ret;
Signature · 1 line
2.1.3
#7 lore raw

PATCH v2 4/4 iommu/msm: Mark driver BROKEN

In reply to a message not in the archive

From: Thierry Reding <[email protected]>

The MSM IOMMU driver unconditionally calls bus_set_iommu(), which is a very stupid thing to do on multi-platform kernels. While marking the driver BROKEN may seem a little extreme, there is no other way to make the driver skip initialization. One of the problems is that it doesn't have devicetree binding documentation and the driver doesn't contain a struct of_device_id table either, so no way to check that it is indeed valid to set up the IOMMU operations for this driver.

This fixes a problem on Tegra20 where the DRM driver will try to use the obviously non-existent MSM IOMMU.

Marking the driver BROKEN shouldn't do any harm, since there aren't any users currently. There is no struct of_device_id table, so the device can't be instantiated from device tree, and I couldn't find any code that would instantiate a matching platform_device either, so the driver is effectively unused.

---
 drivers/iommu/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/iommu/Kconfig +1 -0
index b280f0e21c8c..619bfd7bab1a 100644
@@ -63,6 +63,7 @@ config MSM_IOMMU
 	bool "MSM IOMMU Support"
 	depends on ARM
 	depends on ARCH_MSM8X60 || ARCH_MSM8960 || COMPILE_TEST
+	depends on BROKEN
 	select IOMMU_API
 	help
 	  Support for the IOMMUs found on certain Qualcomm SOCs.
Signature · 1 line
2.1.3
#8 lore raw
In reply to a message not in the archive

Hi Thierry,

Quoted 14 lines · Thierry Reding

From: Thierry Reding <[email protected]>

Hi Joerg,

Here are a couple of urgent fixes for a regression on old Tegra devices related to IOMMU support. The issue is that many drivers think it's a good idea to register IOMMU support unconditionally, which is not the smart thing to do at all on multi-platform kernels. This probably went unnoticed for a while because the offending drivers aren't enabled in any of the multi-platform default configurations. Fedora ARM has their own config where the offending drivers did get enabled, hence caused a regression on Tegra20. I would expect the same regression to exist on a number of other SoCs, possibly all that support IOMMU.

Quoted 6 lines

I've tried to keep the patches minimal in the hopes of still getting this into v3.19-rc8 or the final release to avoid the regression.

Changes in v2:
- avoid potential leak by dropping references to device tree nodes
- remove fixups from module exit functions since they are unused

Thanks for the revised patches, tested them on the OMAP platforms. I was not able to apply the iommu/msm patch though against 3.19-rc7 cleanly.

regards
Suman

Quoted 14 lines

Thierry

Thierry Reding (4):
iommu/exynos: Play nice in multi-platform builds iommu/omap: Play nice in multi-platform builds iommu/rockchip: Play nice in multi-platform builds iommu/msm: Mark driver BROKEN

 drivers/iommu/Kconfig          | 1 +
 drivers/iommu/exynos-iommu.c   | 7 +++++++
 drivers/iommu/omap-iommu.c     | 7 +++++++
 drivers/iommu/rockchip-iommu.c | 7 +++++++
 4 files changed, 22 insertions(+)
Applied
#9 lore raw
In reply to a message not in the archive
Quoted 5 lines · Thierry Reding

Thierry Reding (4):
iommu/exynos: Play nice in multi-platform builds iommu/omap: Play nice in multi-platform builds iommu/rockchip: Play nice in multi-platform builds iommu/msm: Mark driver BROKEN

Applied to my fixes branch.