If both legacy IOMMU bindings and generic bindings are present, iommu_add_dt_device can be called twice. Do not return error in that case, that way there is no need to check for -EEXIST at the call sites. Remove the one existing -EEXIT check, now unneeded.
Signed-off-by: Stefano Stabellini <stefano.stabell...@xilinx.com> --- Changes in v5: - new patch --- xen/drivers/passthrough/device_tree.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthrough/device_tree.c index 999b831d90..32526ecabb 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -140,8 +140,13 @@ int iommu_add_dt_device(struct dt_device_node *np) if ( !ops ) return -EINVAL; + /* + * Some Device Trees may expose both legacy SMMU and generic + * IOMMU bindings together. If both are present, the device + * can be already added. + */ if ( dev_iommu_fwspec_get(dev) ) - return -EEXIST; + return 0; /* * According to the Documentation/devicetree/bindings/iommu/iommu.txt @@ -254,7 +259,7 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, struct domain *d, * already added to the IOMMU (positive result). Such happens after * re-creating guest domain. */ - if ( ret < 0 && ret != -EEXIST ) + if ( ret < 0 ) { printk(XENLOG_G_ERR "Failed to add %s to the IOMMU\n", dt_node_full_name(dev)); -- 2.17.1