From: Vikram Garhwal <vikram.garhwal@amd.com>
To: Michal Orzel <michal.orzel@amd.com>
Cc: xen-devel@lists.xenproject.org, sstabellini@kernel.org,
julien@xen.org, "Jan Beulich" <jbeulich@suse.com>,
"Paul Durrant" <paul@xen.org>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [XEN][PATCH v10 11/20] xen/iommu: Introduce iommu_remove_dt_device()
Date: Thu, 31 Aug 2023 19:01:04 -0700 [thread overview]
Message-ID: <ZPFF4Hnp0Skc38IE@amd.com> (raw)
In-Reply-To: <4f5236f4-39c3-ddc7-3570-2b6bfcd514dd@amd.com>
On Thu, Aug 31, 2023 at 09:32:48AM +0200, Michal Orzel wrote:
>
>
> On 31/08/2023 09:23, Michal Orzel wrote:
> >
> >
> > On 30/08/2023 19:48, Vikram Garhwal wrote:
> >> Hi Michal,
> >> On Tue, Aug 29, 2023 at 10:23:30AM +0200, Michal Orzel wrote:
> >>>
> >>>
> >>> On 25/08/2023 10:02, Vikram Garhwal wrote:
> >>>> Remove master device from the IOMMU. This will be helpful when removing the
> >>>> overlay nodes using dynamic programming during run time.
> >>>>
> >>>> Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
> >>>> Acked-by: Jan Beulich <jbeulich@suse.com>
> >>>
> >>> You don't seem to handle Julien remarks for this patch made in v9.
> >>> I will forward them here to avoid answering to old version, but for the future, do not carry the exact same patch
> >>> if you haven't yet addressed someone's remarks.
> >> This got skipped as I cannot find direct email from Julien. The only email reply
> >> on this patch is can find is from: xen-devel-bounces@lists.xenproject.org and
> >> this got messed up with other larger set of email xen-devel sends.
> >>
> >> Did you get direct email?
> >>>
> >>>>
> >>>> ---
> >>>> Changes from v7:
> >>>> Add check if IOMMU is enabled.
> >>>> Fix indentation of fail.
> >>>> ---
> >>>> ---
> >>>> xen/drivers/passthrough/device_tree.c | 44 +++++++++++++++++++++++++++
> >>>> xen/include/xen/iommu.h | 1 +
> >>>> 2 files changed, 45 insertions(+)
> >>>>
> >>>> diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthrough/device_tree.c
> >>>> index 1202eac625..3fad65fb69 100644
> >>>> --- a/xen/drivers/passthrough/device_tree.c
> >>>> +++ b/xen/drivers/passthrough/device_tree.c
> >>>> @@ -128,6 +128,50 @@ int iommu_release_dt_devices(struct domain *d)
> >>>> return 0;
> >>>> }
> >>>>
> >>>> +int iommu_remove_dt_device(struct dt_device_node *np)
> >>>> +{
> >>>> + const struct iommu_ops *ops = iommu_get_ops();
> >>>> + struct device *dev = dt_to_dev(np);
> >>>> + int rc;
> >>>> +
> >>>> + if ( !iommu_enabled )
> >>>> + return 1;
> >>> J:
> >>> The caller doesn't seem to check if the error code is > 0. So can we
> >>> instead return a -ERRNO?
> >> Will change the check in caller. I want to keep this as it as so it looks
> >> similar to iommu_add_dt_device().
> >>>
> >>> If you want to continue to return a value > 0 then I think it should be
> >>> documented in a comment like we did for iommu_add_dt_device().
> >>>
> >> Will add comment before iommu_remove_dt_device().
> >>>> +
> >>>> + if ( !ops )
> >>>> + return -EOPNOTSUPP;
> >>>> +
> >>>> + spin_lock(&dtdevs_lock);
> >>>> +
> >>>> + if ( iommu_dt_device_is_assigned_locked(np) )
> >>>> + {
> >>>> + rc = -EBUSY;
> >>>> + goto fail;
> >>>> + }
> >>>> +
> >>>> + /*
> >>>> + * The driver which supports generic IOMMU DT bindings must have this
> >>>> + * callback implemented.
> >>>> + */
> >>> J:
> >>> I have questioned this message in v7 and I still question it. I guess
> >>> you copied the comment on top of add_device(), this was add there
> >>> because we have a different way to add legacy device.
> >>>
> >>> But here there are no such requirement. In fact, you are not adding the
> >>> the callback to all the IOMMU drivers... Yet all of them support the
> >>> generic IOMMU DT bindings.
> >> Will change this.
> >>>
> >>>> + if ( !ops->remove_device )
> >>>> + {
> >>>> + rc = -EOPNOTSUPP;
> >>>> + goto fail;
> >>>> + }
> >>>> +
> >>>> + /*
> >>>> + * Remove master device from the IOMMU if latter is present and available.
> >>> J:
> >>> I read this as this will not return an error if the device is protected.
> >>> However, AFAICT, the implement in the SMMU driver provided in this
> >>> series will return an error. So I would suggest to replace this sentence
> >>> with:
> >>>
> >>> de-register the device from the IOMMU driver.
> >> Will change the comment.
> >>>
> >>>> + * The driver is responsible for removing is_protected flag.
> >>> J:
> >>> Can you add an assert in the 'if ( !rc )' block to confirm that
> >>> is_protected was effectively removed. Something like:
> >>>
> >>> ASSERT(!dt_device_is_protected(dev));
> >> Is ASSERT really required here. remove callback can return before setting is_protected as false.
> > I think Julien wanted to add extra check to make sure driver behaves as expected.
> > That said, his suggestion is incorrect since the callback can return before clearing the flag.
> > So, if ASSERT is required, this should be:
> > ASSERT(rc || !dt_device_is_protected(dev));
> > so that we check for is_protected being false only on callback returning success (i.e. 0).
> I wrote this based on iommu_add_dt_device(), which does:
> if ( !rc )
> rc = ops->add_device(0, dev);
>
> but looking at iommu_remove_dt_device(), where you have:
> rc = ops->remove_device(0, dev);
> if ( !rc )
> iommu_fwspec_free(dev);
>
> you should do what Stefano suggested (i.e. just add ASSERT into ( !rc ) block)
Added it in v11.
>
> ~Michal
next prev parent reply other threads:[~2023-09-01 2:01 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-25 8:02 [XEN][PATCH v10 00/20] dynamic node programming using overlay dtbo Vikram Garhwal
2023-08-25 8:02 ` [XEN][PATCH v10 01/20] common/device_tree: handle memory allocation failure in __unflatten_device_tree() Vikram Garhwal
2023-08-25 8:02 ` [XEN][PATCH v10 02/20] common/device_tree.c: unflatten_device_tree() propagate errors Vikram Garhwal
2023-08-28 1:41 ` Henry Wang
2023-08-29 7:09 ` Michal Orzel
2023-08-29 22:24 ` Stefano Stabellini
2023-08-25 8:02 ` [XEN][PATCH v10 03/20] xen/arm/device: Remove __init from function type Vikram Garhwal
2023-08-28 1:53 ` Henry Wang
2023-08-28 16:21 ` Vikram Garhwal
2023-08-29 7:17 ` Michal Orzel
2023-08-30 17:16 ` Vikram Garhwal
2023-08-25 8:02 ` [XEN][PATCH v10 04/20] common/device_tree: Export __unflatten_device_tree() Vikram Garhwal
2023-08-25 8:02 ` [XEN][PATCH v10 05/20] xen/arm: Add CONFIG_OVERLAY_DTB Vikram Garhwal
2023-08-29 7:23 ` Michal Orzel
2023-08-30 17:16 ` Vikram Garhwal
2023-08-25 8:02 ` [XEN][PATCH v10 06/20] libfdt: Keep fdt functions after init for CONFIG_OVERLAY_DTB Vikram Garhwal
2023-08-25 8:02 ` [XEN][PATCH v10 07/20] libfdt: overlay: change overlay_get_target() Vikram Garhwal
2023-08-25 8:02 ` [XEN][PATCH v10 08/20] xen/device-tree: Add device_tree_find_node_by_path() to find nodes in device tree Vikram Garhwal
2023-08-28 1:59 ` Henry Wang
2023-08-29 7:41 ` Michal Orzel
2023-08-29 22:27 ` Stefano Stabellini
2023-08-25 8:02 ` [XEN][PATCH v10 09/20] xen/iommu: Move spin_lock from iommu_dt_device_is_assigned to caller Vikram Garhwal
2023-08-29 8:05 ` Michal Orzel
2023-08-30 17:20 ` Vikram Garhwal
2023-08-25 8:02 ` [XEN][PATCH v10 10/20] xen/iommu: protect iommu_add_dt_device() with dtdevs_lock Vikram Garhwal
2023-08-28 16:29 ` Vikram Garhwal
2023-08-25 8:02 ` [XEN][PATCH v10 11/20] xen/iommu: Introduce iommu_remove_dt_device() Vikram Garhwal
2023-08-29 8:23 ` Michal Orzel
2023-08-30 17:48 ` Vikram Garhwal
2023-08-31 0:35 ` Stefano Stabellini
2023-08-31 7:23 ` Michal Orzel
2023-08-31 7:32 ` Michal Orzel
2023-09-01 2:01 ` Vikram Garhwal [this message]
2023-08-25 8:02 ` [XEN][PATCH v10 12/20] xen/smmu: Add remove_device callback for smmu_iommu ops Vikram Garhwal
2023-08-29 8:51 ` Michal Orzel
2023-08-29 22:45 ` Stefano Stabellini
2023-08-30 9:17 ` Michal Orzel
2023-08-25 8:02 ` [XEN][PATCH v10 13/20] asm/smp.h: Fix circular dependency for device_tree.h and rwlock.h Vikram Garhwal
2023-08-25 8:02 ` [XEN][PATCH v10 14/20] common/device_tree: Add rwlock for dt_host Vikram Garhwal
2023-08-28 16:26 ` Vikram Garhwal
2023-08-29 9:27 ` Michal Orzel
2023-08-25 8:02 ` [XEN][PATCH v10 15/20] arm/asm/setup.h: Update struct map_range_data to add rangeset Vikram Garhwal
2023-08-29 12:16 ` Michal Orzel
2023-08-25 8:02 ` [XEN][PATCH v10 16/20] xen/arm: Implement device tree node removal functionalities Vikram Garhwal
2023-08-29 23:45 ` Stefano Stabellini
2023-08-25 8:02 ` [XEN][PATCH v10 17/20] xen/arm: Implement device tree node addition functionalities Vikram Garhwal
2023-08-29 23:45 ` Stefano Stabellini
2023-08-25 8:02 ` [XEN][PATCH v10 18/20] tools/libs/ctrl: Implement new xc interfaces for dt overlay Vikram Garhwal
2023-08-25 8:02 ` [XEN][PATCH v10 19/20] tools/libs/light: Implement new libxl functions for device tree overlay ops Vikram Garhwal
2023-08-25 8:02 ` [XEN][PATCH v10 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=ZPFF4Hnp0Skc38IE@amd.com \
--to=vikram.garhwal@amd.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=paul@xen.org \
--cc=roger.pau@citrix.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.