From: Vikram Garhwal <vikram.garhwal@amd.com>
To: Michal Orzel <michal.orzel@amd.com>
Cc: xen-devel@lists.xenproject.org, julien@xen.org, sstabellini@kernel.org
Subject: Re: [XEN][PATCH v11 14/20] common/device_tree: Add rwlock for dt_host
Date: Tue, 5 Sep 2023 11:38:37 -0400 [thread overview]
Message-ID: <ZPdLfWX5KFKjXmQK@amd.com> (raw)
In-Reply-To: <227d9107-5f5c-b773-639e-ee59a7047a27@amd.com>
Hi,
On Mon, Sep 04, 2023 at 01:09:52PM +0200, Michal Orzel wrote:
>
>
> On 01/09/2023 06:59, Vikram Garhwal wrote:
> > Dynamic programming ops will modify the dt_host and there might be other
> > functions which are browsing the dt_host at the same time. To avoid the race
> > conditions, adding rwlock for browsing the dt_host during runtime. dt_host
> > writer will be added in the follow-up patch for device tree overlay
> > functionalities.
> >
> > Reason behind adding rwlock instead of spinlock:
> > For now, dynamic programming is the sole modifier of dt_host in Xen during
> > run time. All other access functions like iommu_release_dt_device() are
> > just reading the dt_host during run-time. So, there is a need to protect
> > others from browsing the dt_host while dynamic programming is modifying
> > it. rwlock is better suitable for this task as spinlock won't be able to
> > differentiate between read and write access.
> >
> > Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
> > Reviewed-by: Michal Orzel <michal.orzel@amd.com>
> > ---
> > Changes from v10:
> > Add ASSERT for iommu_assign_dt_device() and iommu_add_dt_device().
> > Changes from v9:
> > Update commit message and fix indentation.
> > Add ASSERT() for iommu_deassign_dt_device() and iommu_remove_dt_device().
> > Fix code styles.
> > Remove rwlock_init in unflatten_device_tree() and do DEFINE_RWLOCK in
> > device-tree.c
> > Changes from v7:
> > Keep one lock for dt_host instead of lock for each node under dt_host.
> > ---
> > ---
> > xen/common/device_tree.c | 1 +
> > xen/drivers/passthrough/device_tree.c | 28 +++++++++++++++++++++++++--
> > xen/include/xen/device_tree.h | 7 +++++++
> > 3 files changed, 34 insertions(+), 2 deletions(-)
> >
> > diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
> > index f38f51ec0b..b1c2952951 100644
> > --- a/xen/common/device_tree.c
> > +++ b/xen/common/device_tree.c
> > @@ -31,6 +31,7 @@ dt_irq_xlate_func dt_irq_xlate;
> > 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
> > diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthrough/device_tree.c
> > index 80f6efc606..1f9cfccf95 100644
> > --- a/xen/drivers/passthrough/device_tree.c
> > +++ b/xen/drivers/passthrough/device_tree.c
> > @@ -31,6 +31,8 @@ int iommu_assign_dt_device(struct domain *d, struct dt_device_node *dev)
> > int rc = -EBUSY;
> > struct domain_iommu *hd = dom_iommu(d);
> >
> > + ASSERT(system_state <= SYS_STATE_active || rw_is_locked(&dt_host_lock));
> This looks not right (I know Julien suggested this). The second part will be checked only if state > active i.e. suspend/resume.
> I think this wants to be:
> ASSERT(system_state < SYS_STATE_active || rw_is_locked(&dt_host_lock));
> so that once the state is >= active, we require dt_host_lock to be locked.
I rechecked this, you are right! Will update it to check the lock only for
>= active.
>
> ~Michal
next prev parent reply other threads:[~2023-09-05 15:39 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-01 4:59 [XEN][PATCH v11 00/20] dynamic node programming using overlay dtbo Vikram Garhwal
2023-09-01 4:59 ` [XEN][PATCH v11 01/20] common/device_tree: handle memory allocation failure in __unflatten_device_tree() Vikram Garhwal
2023-09-01 4:59 ` [XEN][PATCH v11 02/20] common/device_tree.c: unflatten_device_tree() propagate errors Vikram Garhwal
2023-09-01 4:59 ` [XEN][PATCH v11 03/20] xen/arm/device: Remove __init from function type Vikram Garhwal
2023-09-06 0:23 ` Stefano Stabellini
2023-09-01 4:59 ` [XEN][PATCH v11 04/20] common/device_tree: Export __unflatten_device_tree() Vikram Garhwal
2023-09-01 4:59 ` [XEN][PATCH v11 05/20] xen/arm: Add CONFIG_OVERLAY_DTB Vikram Garhwal
2023-09-06 0:24 ` Stefano Stabellini
2023-09-01 4:59 ` [XEN][PATCH v11 06/20] libfdt: Keep fdt functions after init for CONFIG_OVERLAY_DTB Vikram Garhwal
2023-09-01 4:59 ` [XEN][PATCH v11 07/20] libfdt: overlay: change overlay_get_target() Vikram Garhwal
2023-09-01 4:59 ` [XEN][PATCH v11 08/20] xen/device-tree: Add dt_find_node_by_path_from() to find nodes in device tree Vikram Garhwal
2023-09-01 4:59 ` [XEN][PATCH v11 09/20] xen/iommu: Move spin_lock from iommu_dt_device_is_assigned to caller Vikram Garhwal
2023-09-06 0:28 ` Stefano Stabellini
2023-09-01 4:59 ` [XEN][PATCH v11 10/20] xen/iommu: protect iommu_add_dt_device() with dtdevs_lock Vikram Garhwal
2023-09-06 0:29 ` Stefano Stabellini
2023-09-01 4:59 ` [XEN][PATCH v11 11/20] xen/iommu: Introduce iommu_remove_dt_device() Vikram Garhwal
2023-09-04 10:31 ` Michal Orzel
2023-09-06 0:35 ` Stefano Stabellini
2023-09-01 4:59 ` [XEN][PATCH v11 12/20] xen/smmu: Add remove_device callback for smmu_iommu ops Vikram Garhwal
2023-09-04 10:38 ` Michal Orzel
2023-09-05 15:22 ` Vikram Garhwal
2023-09-06 0:37 ` Stefano Stabellini
2023-09-01 4:59 ` [XEN][PATCH v11 13/20] asm/smp.h: Fix circular dependency for device_tree.h and rwlock.h Vikram Garhwal
2023-09-01 4:59 ` [XEN][PATCH v11 14/20] common/device_tree: Add rwlock for dt_host Vikram Garhwal
2023-09-04 11:09 ` Michal Orzel
2023-09-05 15:38 ` Vikram Garhwal [this message]
2023-09-06 0:53 ` Stefano Stabellini
2023-09-01 4:59 ` [XEN][PATCH v11 15/20] arm/asm/setup.h: Update struct map_range_data to add rangeset Vikram Garhwal
2023-09-04 11:29 ` Michal Orzel
2023-09-06 0:42 ` Stefano Stabellini
2023-09-01 4:59 ` [XEN][PATCH v11 16/20] xen/arm: Implement device tree node removal functionalities Vikram Garhwal
2023-09-06 0:48 ` Stefano Stabellini
2023-09-01 4:59 ` [XEN][PATCH v11 17/20] xen/arm: Implement device tree node addition functionalities Vikram Garhwal
2023-09-06 0:53 ` Stefano Stabellini
2023-09-01 4:59 ` [XEN][PATCH v11 18/20] tools/libs/ctrl: Implement new xc interfaces for dt overlay Vikram Garhwal
2023-09-01 4:59 ` [XEN][PATCH v11 19/20] tools/libs/light: Implement new libxl functions for device tree overlay ops Vikram Garhwal
2023-09-01 4:59 ` [XEN][PATCH v11 20/20] tools/xl: Add new xl command overlay for device tree overlay support Vikram Garhwal
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=ZPdLfWX5KFKjXmQK@amd.com \
--to=vikram.garhwal@amd.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=sstabellini@kernel.org \
--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.