@@ -83,16 +83,14 @@ fail:
return rc;
}
-static bool_t iommu_dt_device_is_assigned(const struct dt_device_node *dev)
+bool_t iommu_dt_device_is_assigned_locked(const struct dt_device_node *dev)
{
bool_t assigned = 0;
if ( !dt_device_is_protected(dev) )
return 0;
- spin_lock(&dtdevs_lock);
assigned = !list_empty(&dev->domain_list);
- spin_unlock(&dtdevs_lock);
return assigned;
}
@@ -213,27 +211,40 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, struct domain *d,
if ( (d && d->is_dying) || domctl->u.assign_device.flags )
break;
+ spin_lock(&dtdevs_lock);
+
ret = dt_find_node_by_gpath(domctl->u.assign_device.u.dt.path,
domctl->u.assign_device.u.dt.size,
&dev);
if ( ret )
+ {
+ spin_unlock(&dtdevs_lock);
break;
+ }
ret = xsm_assign_dtdevice(XSM_HOOK, d, dt_node_full_name(dev));
if ( ret )
+ {
+ spin_unlock(&dtdevs_lock);
break;
+ }
if ( domctl->cmd == XEN_DOMCTL_test_assign_device )
{
- if ( iommu_dt_device_is_assigned(dev) )
+
+ if ( iommu_dt_device_is_assigned_locked(dev) )
{
printk(XENLOG_G_ERR "%s already assigned.\n",
dt_node_full_name(dev));
ret = -EINVAL;
}
+
+ spin_unlock(&dtdevs_lock);
break;
}
+ spin_unlock(&dtdevs_lock);
+
if ( d == dom_io )
return -EINVAL;
@@ -214,6 +214,7 @@ struct msi_msg;
#include <xen/device_tree.h>
int iommu_assign_dt_device(struct domain *d, struct dt_device_node *dev);
+bool_t iommu_dt_device_is_assigned_locked(const struct dt_device_node *dev);
int iommu_deassign_dt_device(struct domain *d, struct dt_device_node *dev);
int iommu_dt_domain_init(struct domain *d);
int iommu_release_dt_devices(struct domain *d);