|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [XEN][PATCH v5 08/17] xen/iommu: Move spin_lock from iommu_dt_device_is_assigned to caller
Hi Vikram,
It looks like you didn't take into account any of my remarks made for v4.
I will repeat them here.
On 11/04/2023 21:16, Vikram Garhwal wrote:
>
>
> Rename iommu_dt_device_is_assigned() to iommu_dt_device_is_assigned_lock().
s/lock/locked
>
> Moving spin_lock to caller was done to prevent the concurrent access to
> iommu_dt_device_is_assigned while doing add/remove/assign/deassign.
>
> Signed-off-by: Vikram Garhwal <vikram.garhwal@xxxxxxx>
> Reviewed-by: Luca Fancellu <luca.fancellu@xxxxxxx>
> ---
> xen/drivers/passthrough/device_tree.c | 23 +++++++++++++++++++----
> 1 file changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/xen/drivers/passthrough/device_tree.c
> b/xen/drivers/passthrough/device_tree.c
> index 1c32d7b50c..bb4cf7784d 100644
> --- a/xen/drivers/passthrough/device_tree.c
> +++ b/xen/drivers/passthrough/device_tree.c
> @@ -83,16 +83,15 @@ fail:
> return rc;
> }
>
> -static bool_t iommu_dt_device_is_assigned(const struct dt_device_node *dev)
> +static bool_t
> + iommu_dt_device_is_assigned_locked(const struct dt_device_node *dev)
This should not be indented.
> {
> 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 +212,43 @@ 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);
> +
Please, do not add blank line between spin_unlock and break. It does not
improve readability.
> break;
> + }
>
> ret = xsm_assign_dtdevice(XSM_HOOK, d, dt_node_full_name(dev));
> if ( ret )
> + {
> + spin_unlock(&dtdevs_lock);
> +
same here.
~Michal
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |