Skip to contentSkip to conversation

iommu/arm-smmu: Play nice on non-ARM/SMMU systems

PATCH New Thierry Reding 2 participants 3 messages Nov 7, 2014 – Nov 11, 2014 IOMMU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/arm-smmu: Play nice on non-ARM/SMMU systems

From: Thierry Reding <[email protected]>

Currently the driver registers IOMMU bus operations for all busses even if no ARM SMMU is present on a system. Depending on the driver probing order this prevents the driver for the real IOMMU to register itself as the bus-wide IOMMU.

---
 drivers/iommu/arm-smmu.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/iommu/arm-smmu.c +12 -0
index 60558f794922..e154826d8b1d 100644
@@ -2072,8 +2072,20 @@ static struct platform_driver arm_smmu_driver = {
 
 static int __init arm_smmu_init(void)
 {
+	struct device_node *np;
 	int ret;
 
+	/*
+	 * Play nice with systems that don't have an ARM SMMU by checking that
+	 * an ARM SMMU exists in the system before proceeding with the driver
+	 * and IOMMU bus operation registration.
+	 */
+	np = of_find_matching_node(NULL, arm_smmu_of_match);
+	if (!np)
+		return 0;
+
+	of_node_put(np);
+
 	ret = platform_driver_register(&arm_smmu_driver);
 	if (ret)
 		return ret;
Signature · 1 line
2.1.3
#1 lore raw

PATCH 1/1 iommu/arm-smmu: Play nice on non-ARM/SMMU systems

Quoted 24 lines · Thierry Reding

From: Thierry Reding <[email protected]>

Currently the driver registers IOMMU bus operations for all busses even if no ARM SMMU is present on a system. Depending on the driver probing order this prevents the driver for the real IOMMU to register itself as the bus-wide IOMMU.

---
 drivers/iommu/arm-smmu.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/iommu/arm-smmu.c +2 -0
index 60558f794922..e154826d8b1d 100644
@@ -2072,8 +2072,20 @@ static struct platform_driver arm_smmu_driver = {
 
 static int __init arm_smmu_init(void)
 {
+	struct device_node *np;
 	int ret;
 
+	/*

drivers/iommu/arm-smmu.c static struct platform_driver arm_smmu_driver = { · line 2088

Quoted 10 lines
drivers/iommu/arm-smmu.c +10 -0
+	 * Play nice with systems that don't have an ARM SMMU by checking that
+	 * an ARM SMMU exists in the system before proceeding with the driver
+	 * and IOMMU bus operation registration.
+	 */
+	np = of_find_matching_node(NULL, arm_smmu_of_match);
+	if (!np)
+		return 0;
+
+	of_node_put(np);
+

Hopefully, this will be solved shortly by the of_iommu_configure series I've been dragging my feet with recently. However, since that's not done yet, this looks like the best thing for now, even if it's a bit of a bodge.

Have you checked/updated other IOMMMU drivers too?

Will

#2 lore raw

PATCH 1/1 iommu/arm-smmu: Play nice on non-ARM/SMMU systems

Quoted 40 lines · Will Deacon
Quoted 24 lines · Thierry Reding

From: Thierry Reding <[email protected]>

Currently the driver registers IOMMU bus operations for all busses even if no ARM SMMU is present on a system. Depending on the driver probing order this prevents the driver for the real IOMMU to register itself as the bus-wide IOMMU.

---
 drivers/iommu/arm-smmu.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/iommu/arm-smmu.c +2 -0
index 60558f794922..e154826d8b1d 100644
@@ -2072,8 +2072,20 @@ static struct platform_driver arm_smmu_driver = {
 
 static int __init arm_smmu_init(void)
 {
+	struct device_node *np;
 	int ret;
 
+	/*

drivers/iommu/arm-smmu.c static struct platform_driver arm_smmu_driver = { · line 2088

Quoted 10 lines
drivers/iommu/arm-smmu.c +10 -0
+	 * Play nice with systems that don't have an ARM SMMU by checking that
+	 * an ARM SMMU exists in the system before proceeding with the driver
+	 * and IOMMU bus operation registration.
+	 */
+	np = of_find_matching_node(NULL, arm_smmu_of_match);
+	if (!np)
+		return 0;
+
+	of_node_put(np);
+

Hopefully, this will be solved shortly by the of_iommu_configure series I've been dragging my feet with recently. However, since that's not done yet, this looks like the best thing for now, even if it's a bit of a bodge.

Quoted 1 line

Have you checked/updated other IOMMMU drivers too?

ARM SMMU was the only one being enabled on 64-bit where I noticed this, but from a quick glance a couple of the other ARM driver are affected as well. I'll see if I can find the time to come up with a similar patch.

Of course if these IOMMU drivers were proper drivers and bind to a device, then this problem wouldn't exist in the first place.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141111/4f1cb4d7/attachment.sig>