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.c...@arm.com> --- 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