diff mbox

[3/7] xen/arm: Prepare SMMU resources for protected devices

Message ID 1498792511-25149-4-git-send-email-Wei.Chen@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Chen June 30, 2017, 3:15 a.m. UTC
In previous code, while we are constructing Dom0, we will assign
all devices except passthrough devices to Dom0. In the later, when
we start the DomU, the assign_device will prepare SMMU resources
for the devices passthrough to DomU. This is ok when we kept the
add_device code in assign_device. But currently, we have separated
add_device from assign_device. If we don't prepare SMMU resources
for passthrough devices, these devices would not work properly in
DomU.

So, while we are handling all devices DT node in construction Dom0,
we will call add_device to prepare SMMU resources for all protected
devices, regardless of passthrough or not.

Signed-off-by: Wei Chen <Wei.Chen@arm.com>
---
 xen/arch/arm/domain_build.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Stefano Stabellini July 3, 2017, 10:05 p.m. UTC | #1
On Fri, 30 Jun 2017, Wei Chen wrote:
> In previous code, while we are constructing Dom0, we will assign
> all devices except passthrough devices to Dom0. In the later, when
> we start the DomU, the assign_device will prepare SMMU resources
> for the devices passthrough to DomU. This is ok when we kept the
> add_device code in assign_device. But currently, we have separated
> add_device from assign_device. If we don't prepare SMMU resources
> for passthrough devices, these devices would not work properly in
> DomU.
> 
> So, while we are handling all devices DT node in construction Dom0,
> we will call add_device to prepare SMMU resources for all protected
> devices, regardless of passthrough or not.
> 
> Signed-off-by: Wei Chen <Wei.Chen@arm.com>

Acked-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
>  xen/arch/arm/domain_build.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index c6776d7..6aea427 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1082,6 +1082,18 @@ static int handle_device(struct domain *d, struct dt_device_node *dev,
>      dt_dprintk("%s passthrough = %d nirq = %d naddr = %u\n",
>                 dt_node_full_name(dev), need_mapping, nirq, naddr);
>  
> +    /*
> +     * If this device is behind the SMMU, the add_device callback will
> +     * prepare resource for it. Otherwise, add_device has no effect.
> +     */
> +    res = iommu_add_dt_device(d, dev);
> +    if ( res )
> +    {
> +        printk(XENLOG_ERR "Failed to add device to IOMMU for %s\n",
> +               dt_node_full_name(dev));
> +        return res;
> +    }
> +
>      if ( dt_device_is_protected(dev) && need_mapping )
>      {
>          dt_dprintk("%s setup iommu\n", dt_node_full_name(dev));
> -- 
> 2.7.4
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> https://lists.xen.org/xen-devel
>
diff mbox

Patch

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index c6776d7..6aea427 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1082,6 +1082,18 @@  static int handle_device(struct domain *d, struct dt_device_node *dev,
     dt_dprintk("%s passthrough = %d nirq = %d naddr = %u\n",
                dt_node_full_name(dev), need_mapping, nirq, naddr);
 
+    /*
+     * If this device is behind the SMMU, the add_device callback will
+     * prepare resource for it. Otherwise, add_device has no effect.
+     */
+    res = iommu_add_dt_device(d, dev);
+    if ( res )
+    {
+        printk(XENLOG_ERR "Failed to add device to IOMMU for %s\n",
+               dt_node_full_name(dev));
+        return res;
+    }
+
     if ( dt_device_is_protected(dev) && need_mapping )
     {
         dt_dprintk("%s setup iommu\n", dt_node_full_name(dev));