All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Orzel <michal.orzel@amd.com>
To: Vikram Garhwal <vikram.garhwal@amd.com>,
	<xen-devel@lists.xenproject.org>
Cc: <sstabellini@kernel.org>, <julien@xen.org>, <Luca.Fancellu@arm.com>
Subject: Re: [XEN][RFC PATCH v4 07/16] xen/iommu: Move spin_lock from iommu_dt_device_is_assigned to caller
Date: Mon, 23 Jan 2023 10:54:42 +0100	[thread overview]
Message-ID: <3949c194-114c-cd4f-3f7c-c57d423a7955@amd.com> (raw)
In-Reply-To: <20221207061815.7404-1-vikram.garhwal@amd.com>

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@amd.com>
> Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
> ---
>  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


      parent reply	other threads:[~2023-01-23  9:55 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07  6:18 [XEN][RFC PATCH v4 07/16] xen/iommu: Move spin_lock from iommu_dt_device_is_assigned to caller Vikram Garhwal
2022-12-07  6:18 ` [XEN][RFC PATCH v4 08/16] xen/iommu: protect iommu_add_dt_device() with dtdevs_lock Vikram Garhwal
2022-12-07  6:18 ` [XEN][RFC PATCH v4 09/16] xen/iommu: Introduce iommu_remove_dt_device() Vikram Garhwal
2023-01-23 10:00   ` Michal Orzel
2023-01-23 10:06     ` Julien Grall
2023-02-10  7:06     ` Vikram Garhwal
2022-12-07  6:18 ` [XEN][RFC PATCH v4 10/16] asm/smp.h: move cpu related function to asm/cpu.h Vikram Garhwal
2022-12-07  8:38   ` Jan Beulich
2022-12-07 16:28   ` Julien Grall
2022-12-07 19:39     ` Vikram Garhwal
2022-12-08  8:18       ` Jan Beulich
2022-12-07  6:18 ` [XEN][RFC PATCH v4 11/16] common/device_tree: Add rwlock for dt_host Vikram Garhwal
2022-12-07 16:31   ` Julien Grall
2023-02-01 17:05     ` Vikram Garhwal
2023-02-10 18:48       ` Julien Grall
2022-12-07  6:18 ` [XEN][RFC PATCH v4 12/16] xen/arm: Implement device tree node removal functionalities Vikram Garhwal
2022-12-07  8:41   ` Jan Beulich
2023-02-01 17:21     ` Vikram Garhwal
2023-01-24  9:01   ` Michal Orzel
2023-02-10 23:24     ` Vikram Garhwal
2022-12-07  6:18 ` [XEN][RFC PATCH v4 13/16] xen/arm: Implement device tree node addition functionalities Vikram Garhwal
2023-01-24 10:56   ` Michal Orzel
2022-12-07  6:18 ` [XEN][RFC PATCH v4 14/16] tools/libs/ctrl: Implement new xc interfaces for dt overlay Vikram Garhwal
2022-12-09 16:07   ` Anthony PERARD
2022-12-07  6:18 ` [XEN][RFC PATCH v4 15/16] tools/libs/light: Implement new libxl functions for device tree overlay ops Vikram Garhwal
2022-12-09 16:59   ` Anthony PERARD
2023-02-01 17:22     ` Vikram Garhwal
2022-12-07  6:18 ` [XEN][RFC PATCH v4 16/16] tools/xl: Add new xl command overlay for device tree overlay support Vikram Garhwal
2022-12-09 17:55   ` Anthony PERARD
2023-02-01 17:24     ` Vikram Garhwal
2023-01-23  9:54 ` Michal Orzel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3949c194-114c-cd4f-3f7c-c57d423a7955@amd.com \
    --to=michal.orzel@amd.com \
    --cc=Luca.Fancellu@arm.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=vikram.garhwal@amd.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.