[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN][RFC PATCH v4 07/16] xen/iommu: Move spin_lock from iommu_dt_device_is_assigned to caller


  • To: Vikram Garhwal <vikram.garhwal@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Mon, 23 Jan 2023 10:54:42 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=I+ChblAooxSW6QftgYEoMsg2d3B2eVain5PW+PHapxY=; b=T4Azov7srwkH3JnYzkBYz7OTSkrBDB8QJMcVttexiae8+8/0qaU6Or++0ioTfnia+FHF4d/W1Aunk9Jf8FMn3F382uTAzfn1DWg5IydLGG6BPmz39K7zcOs56F1sJ1r1zRebplucfogVR2647i/z549RlVaA8WBBdMKUVRylQZ58R82+/K2cH5ANKkj2LVUGPUKQwFUi8a6T0ulB1pMPUVzRhJylVLGtXIwUEqJOcmGC9OqsA4uZ/X06oik6GTz8jVESLU1E44kgTtnZaBRSrBwg/DmOkl1Fs2squP9LACnsPDEJ6F2iZfQLL4XXNKy6UDkOUpwz/X9DlH32PDflrw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P+Ix8zQCLQLg+3Jy/GU64tC+Ru0t1rOrbvdLCr1rMyfTo6zynRv8PBi76yNmoBfmMiNzavPIRHlnBrFSnlVGydJzPQ338u/ZzC9+4GHTkQcoYcgEGPmG5BI9RzigHdZS2Cv04VaBpyoqikJgp0YbWnQrFSB/VSQch8rupb5ffcvQfgKHKqu1XuJkhQn6Lgdf7OFbJmX1tKWwFY6DhMtiGvYyKiMme+7ujqudVi59Lr+iqqPPoYOggbBkbbXuLBS1LEc5QDzttmOiQGz1FPH1USaytsBIN9ufCxhO2HswpLXIC5fXwF7h7XrHFHjHuWaG5MbZhSGF5PDDdvJqu9+ieg==
  • Cc: <sstabellini@xxxxxxxxxx>, <julien@xxxxxxx>, <Luca.Fancellu@xxxxxxx>
  • Delivery-date: Mon, 23 Jan 2023 09:55:11 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Vikram,

On 07/12/2022 07:18, 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);
> +
I think removing a blank line here and in other places would look better.

~Michal



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.