diff mbox series

[for-4.13] xen/arm: boot with device trees with "mmu-masters" and "iommus"

Message ID 20190930205618.29942-1-sstabellini@kernel.org (mailing list archive)
State New, archived
Headers show
Series [for-4.13] xen/arm: boot with device trees with "mmu-masters" and "iommus" | expand

Commit Message

Stefano Stabellini Sept. 30, 2019, 8:56 p.m. UTC
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.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
---
 xen/drivers/passthrough/device_tree.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

Comments

Oleksandr Tyshchenko Oct. 1, 2019, 3:16 p.m. UTC | #1
On 30.09.19 23:56, Stefano Stabellini wrote:

Hi Stefano

> 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.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
> ---
>   xen/drivers/passthrough/device_tree.c | 17 ++++++++++++++++-
>   1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthrough/device_tree.c
> index cc900bac70..27e265b936 100644
> --- a/xen/drivers/passthrough/device_tree.c
> +++ b/xen/drivers/passthrough/device_tree.c
> @@ -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;

Patch looks correct and quite well described...


You can add (if needed):

Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Julien Grall Oct. 2, 2019, 5:02 p.m. UTC | #2
+Juergen

Hi,

On 10/1/19 4:16 PM, Oleksandr wrote:
> 
> On 30.09.19 23:56, Stefano Stabellini wrote:
> 
> Hi Stefano
> 
>> 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.
>>
>> Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
>> ---
>>   xen/drivers/passthrough/device_tree.c | 17 ++++++++++++++++-
>>   1 file changed, 16 insertions(+), 1 deletion(-)
>>
>> diff --git a/xen/drivers/passthrough/device_tree.c 
>> b/xen/drivers/passthrough/device_tree.c
>> index cc900bac70..27e265b936 100644
>> --- a/xen/drivers/passthrough/device_tree.c
>> +++ b/xen/drivers/passthrough/device_tree.c
>> @@ -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;
> 
> Patch looks correct and quite well described...
> 
> 
> You can add (if needed):
> 
> Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

Acked-by: Julien Grall <julien.grall@arm.com>

Cheers,
Jürgen Groß Oct. 4, 2019, 4:46 a.m. UTC | #3
On 02.10.19 19:02, Julien Grall wrote:
> +Juergen
> 
> Hi,
> 
> On 10/1/19 4:16 PM, Oleksandr wrote:
>>
>> On 30.09.19 23:56, Stefano Stabellini wrote:
>>
>> Hi Stefano
>>
>>> 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.
>>>
>>> Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>

Release-acked-by: Juergen Gross <jgross@suse.com>


Juergen
diff mbox series

Patch

diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthrough/device_tree.c
index cc900bac70..27e265b936 100644
--- a/xen/drivers/passthrough/device_tree.c
+++ b/xen/drivers/passthrough/device_tree.c
@@ -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;