struct dt_device_node *dt_host;
/* Interrupt controller node*/
const struct dt_device_node *dt_interrupt_controller;
+DEFINE_RWLOCK(dt_host_lock);
/**
* struct dt_alias_prop - Alias property in 'aliases' node
int rc = -EBUSY;
struct domain_iommu *hd = dom_iommu(d);
+ ASSERT(system_state < SYS_STATE_active || rw_is_locked(&dt_host_lock));
+
if ( !is_iommu_enabled(d) )
return -EINVAL;
const struct domain_iommu *hd = dom_iommu(d);
int rc;
+ ASSERT(rw_is_locked(&dt_host_lock));
+
if ( !is_iommu_enabled(d) )
return -EINVAL;
if ( !is_iommu_enabled(d) )
return 0;
+ read_lock(&dt_host_lock);
+
list_for_each_entry_safe(dev, _dev, &hd->dt_devices, domain_list)
{
rc = iommu_deassign_dt_device(d, dev);
{
dprintk(XENLOG_ERR, "Failed to deassign %s in domain %u\n",
dt_node_full_name(dev), d->domain_id);
+ read_unlock(&dt_host_lock);
+
return rc;
}
}
+ read_unlock(&dt_host_lock);
+
return 0;
}
struct device *dev = dt_to_dev(np);
int rc;
+ ASSERT(rw_is_locked(&dt_host_lock));
+
if ( !iommu_enabled )
return 1;
struct device *dev = dt_to_dev(np);
int rc = 1, index = 0;
+ ASSERT(system_state < SYS_STATE_active || rw_is_locked(&dt_host_lock));
+
if ( !iommu_enabled )
return 1;
int ret;
struct dt_device_node *dev;
+ read_lock(&dt_host_lock);
+
switch ( domctl->cmd )
{
case XEN_DOMCTL_assign_device:
}
if ( d == dom_io )
- return -EINVAL;
+ {
+ ret = -EINVAL;
+ break;
+ }
ret = iommu_add_dt_device(dev);
if ( ret < 0 )
break;
if ( d == dom_io )
- return -EINVAL;
+ {
+ ret = -EINVAL;
+ break;
+ }
ret = iommu_deassign_dt_device(d, dev);
break;
}
+ read_unlock(&dt_host_lock);
+
return ret;
}
#include <xen/string.h>
#include <xen/types.h>
#include <xen/list.h>
+#include <xen/rwlock.h>
#define DEVICE_TREE_MAX_DEPTH 16
*/
extern const struct dt_device_node *dt_interrupt_controller;
+/*
+ * Lock that protects r/w updates to unflattened device tree i.e. dt_host during
+ * runtime. Lock may not be taken for boot only code.
+ */
+extern rwlock_t dt_host_lock;
+
/**
* Find the interrupt controller
* For the moment we handle only one interrupt controller: the first