Skip to contentSkip to conversation

xen/arm: boot with device trees with "mmu-masters" and "iommus"

PATCH In review Stefano Stabellini 4 participants 4 messages Sep 30, 2019 – Oct 4, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: boot with device trees with "mmu-masters" and "iommus"

Some Device Trees may expose both legacy SMMU and generic IOMMU bindings together. However, the SMMU driver in Xen is only supporting the legacy SMMU bindings, leading to fatal initialization errors at boot time.

This patch fixes the booting problem by adding a check to
iommu_add_dt_device: if the Xen driver doesn't support the new generic bindings, and the device is behind an IOMMU, do not return error. The following iommu_assign_dt_device should succeed.

This check will become superfluous, hence removable, once the Xen SMMU driver gets support for the generic IOMMU bindings.

---
 xen/drivers/passthrough/device_tree.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
xen/drivers/passthrough/device_tree.c +16 -1
index cc900bac70..27e265b936 100644
@@ -155,7 +155,22 @@ int iommu_add_dt_device(struct dt_device_node *np)
          * these callback implemented.
          */
         if ( !ops->add_device || !ops->dt_xlate )
-            return -EINVAL;
+        {
+            /*
+             * Some Device Trees may expose both legacy SMMU and generic
+             * IOMMU bindings together. However, the SMMU driver is only
+             * supporting the former and will protect them during the
+             * initialization. So we need to skip them and not return
+             * error here.
+             *
+             * XXX: This can be dropped when the SMMU is able to deal
+             * with generic bindings.
+             */
+            if ( dt_device_is_protected(np) )
+                return 0;
+            else
+                return -EINVAL;
+        }
 
         if ( !dt_device_is_available(iommu_spec.np) )
             break;
Signature · 7 lines
2.17.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by Oleksandr Tyshchenko on v1 1/1
#1 lore raw

On 30.09.19 23:56, Stefano Stabellini wrote:

Hi Stefano

Quoted 35 lines

Some Device Trees may expose both legacy SMMU and generic IOMMU bindings together. However, the SMMU driver in Xen is only supporting the legacy SMMU bindings, leading to fatal initialization errors at boot time.

This patch fixes the booting problem by adding a check to
iommu_add_dt_device: if the Xen driver doesn't support the new generic bindings, and the device is behind an IOMMU, do not return error. The following iommu_assign_dt_device should succeed.

This check will become superfluous, hence removable, once the Xen SMMU driver gets support for the generic IOMMU bindings.

---
  xen/drivers/passthrough/device_tree.c | 17 ++++++++++++++++-
  1 file changed, 16 insertions(+), 1 deletion(-)
xen/drivers/passthrough/device_tree.c +9 -1
index cc900bac70..27e265b936 100644
@@ -155,7 +155,22 @@ int iommu_add_dt_device(struct dt_device_node *np)
           * these callback implemented.
           */
          if ( !ops->add_device || !ops->dt_xlate )
-            return -EINVAL;
+        {
+            /*
+             * Some Device Trees may expose both legacy SMMU and generic
+             * IOMMU bindings together. However, the SMMU driver is only
+             * supporting the former and will protect them during the
+             * initialization. So we need to skip them and not return
+             * error here.
+             *
+             * XXX: This can be dropped when the SMMU is able to deal

xen/drivers/passthrough/device_tree.c int iommu_add_dt_device(struct dt_device_node *np) · line 176

Quoted 10 lines
xen/drivers/passthrough/device_tree.c +7 -0
+             * with generic bindings.
+             */
+            if ( dt_device_is_protected(np) )
+                return 0;
+            else
+                return -EINVAL;
+        }
 
          if ( !dt_device_is_available(iommu_spec.np) )
              break;

Patch looks correct and quite well described...

You can add (if needed):

Signature · 9 lines
Regards,

Oleksandr Tyshchenko


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by
#2 lore raw

+Juergen

Hi,

Quoted 53 lines · Oleksandr

On 30.09.19 23:56, Stefano Stabellini wrote:

Hi Stefano

Quoted 34 lines

Some Device Trees may expose both legacy SMMU and generic IOMMU bindings together. However, the SMMU driver in Xen is only supporting the legacy SMMU bindings, leading to fatal initialization errors at boot time.

This patch fixes the booting problem by adding a check to
iommu_add_dt_device: if the Xen driver doesn't support the new generic bindings, and the device is behind an IOMMU, do not return error. The following iommu_assign_dt_device should succeed.

This check will become superfluous, hence removable, once the Xen SMMU driver gets support for the generic IOMMU bindings.

---
  xen/drivers/passthrough/device_tree.c | 17 ++++++++++++++++-

  1 file changed, 16 insertions(+), 1 deletion(-)
xen/drivers/passthrough/device_tree.c +8 -1
index cc900bac70..27e265b936 100644
@@ -155,7 +155,22 @@ int iommu_add_dt_device(struct dt_device_node *np)
            * these callback implemented.
            */
           if ( !ops->add_device || !ops->dt_xlate )
-            return -EINVAL;
+        {
+            /*
+             * Some Device Trees may expose both legacy SMMU and generic
+             * IOMMU bindings together. However, the SMMU driver is only
+             * supporting the former and will protect them during the
+             * initialization. So we need to skip them and not return
+             * error here.
+             *

xen/drivers/passthrough/device_tree.c int iommu_add_dt_device(struct dt_device_node *np) · line 175

Quoted 10 lines
xen/drivers/passthrough/device_tree.c +8 -0
+             * XXX: This can be dropped when the SMMU is able to deal
+             * with generic bindings.
+             */
+            if ( dt_device_is_protected(np) )
+                return 0;
+            else
+                return -EINVAL;
+        }
           if ( !dt_device_is_available(iommu_spec.np) )
               break;

Patch looks correct and quite well described...

Quoted 3 lines

You can add (if needed):

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#3 lore raw
Quoted 23 lines · Julien Grall

+Juergen

Hi,

Quoted 18 lines · Oleksandr

On 30.09.19 23:56, Stefano Stabellini wrote:

Hi Stefano

Quoted 13 lines

Some Device Trees may expose both legacy SMMU and generic IOMMU bindings together. However, the SMMU driver in Xen is only supporting the legacy SMMU bindings, leading to fatal initialization errors at boot time.

This patch fixes the booting problem by adding a check to
iommu_add_dt_device: if the Xen driver doesn't support the new generic bindings, and the device is behind an IOMMU, do not return error. The following iommu_assign_dt_device should succeed.

This check will become superfluous, hence removable, once the Xen SMMU driver gets support for the generic IOMMU bindings.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel