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,
"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: Tue, 29 Aug 2023 10:23:30 +0200 [thread overview]
Message-ID: <079c831a-bf1e-5489-562b-01cf4e3e6b02@amd.com> (raw)
In-Reply-To: <20230825080222.14247-12-vikram.garhwal@amd.com>
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.
>
> ---
> 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?
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().
> +
> + 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.
> + 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.
> + * 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));
This would help to confirm the driver is respecting what you expect.
> + */
> + rc = ops->remove_device(0, dev);
> +
> + if ( !rc )
> + iommu_fwspec_free(dev);
> +
> + fail:
> + spin_unlock(&dtdevs_lock);
> + return rc;
> +}
> +
> int iommu_add_dt_device(struct dt_device_node *np)
> {
> const struct iommu_ops *ops = iommu_get_ops();
> diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
> index 110693c59f..a8e9bc9a2d 100644
> --- a/xen/include/xen/iommu.h
> +++ b/xen/include/xen/iommu.h
> @@ -233,6 +233,7 @@ int iommu_add_dt_device(struct dt_device_node *np);
>
> int iommu_do_dt_domctl(struct xen_domctl *domctl, struct domain *d,
> XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl);
> +int iommu_remove_dt_device(struct dt_device_node *np);
>
> #endif /* HAS_DEVICE_TREE */
>
~Michal
next prev parent reply other threads:[~2023-08-29 8:24 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 [this message]
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
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=079c831a-bf1e-5489-562b-01cf4e3e6b02@amd.com \
--to=michal.orzel@amd.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=paul@xen.org \
--cc=roger.pau@citrix.com \
--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.