All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vikram Garhwal <fnu.vikram@xilinx.com>
To: <xen-devel@lists.xenproject.org>
Cc: <sstabellini@kernel.org>, <julien@xen.org>,
	<bertrand.marquis@arm.com>, <volodymyr_babchuk@epam.com>,
	Vikram Garhwal <fnu.vikram@xilinx.com>,
	Jan Beulich <jbeulich@suse.com>, Paul Durrant <paul@xen.org>
Subject: [XEN][RFC PATCH v3 09/14] xen/iommu: Introduce iommu_remove_dt_device()
Date: Tue, 8 Mar 2022 11:46:59 -0800	[thread overview]
Message-ID: <20220308194704.14061-10-fnu.vikram@xilinx.com> (raw)
In-Reply-To: <20220308194704.14061-1-fnu.vikram@xilinx.com>

Remove master device from the IOMMU.

Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com>
---
 xen/drivers/passthrough/device_tree.c | 38 +++++++++++++++++++++++++++
 xen/include/xen/iommu.h               |  2 ++
 2 files changed, 40 insertions(+)

diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthrough/device_tree.c
index 776809a8f2..5cd0b20c77 100644
--- a/xen/drivers/passthrough/device_tree.c
+++ b/xen/drivers/passthrough/device_tree.c
@@ -125,6 +125,44 @@ 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 ( !ops )
+        return -EOPNOTSUPP;
+
+    spin_lock(&dtdevs_lock);
+
+    if ( iommu_dt_device_is_assigned_lock(np) ) {
+        rc = -EBUSY;
+        goto fail;
+    }
+
+    /*
+     * The driver which supports generic IOMMU DT bindings must have
+     * these callback implemented.
+     */
+    if ( !ops->remove_device ) {
+        rc = -EOPNOTSUPP;
+        goto fail;
+    }
+
+    /*
+     * Remove master device from the IOMMU if latter is present and available.
+     */
+    rc = ops->remove_device(0, dev);
+
+    if ( rc == 0 )
+        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 b18e7760a2..64871e5cb8 100644
--- a/xen/include/xen/iommu.h
+++ b/xen/include/xen/iommu.h
@@ -215,6 +215,8 @@ int iommu_release_dt_devices(struct domain *d);
  */
 int iommu_add_dt_device(struct dt_device_node *np);
 
+int iommu_remove_dt_device(struct dt_device_node *np);
+
 int iommu_do_dt_domctl(struct xen_domctl *, struct domain *,
                        XEN_GUEST_HANDLE_PARAM(xen_domctl_t));
 
-- 
2.17.1



  parent reply	other threads:[~2022-03-08 19:47 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-08 19:46 [XEN][RFC PATCH v3 00/14] dynamic node programming using overlay dtbo Vikram Garhwal
2022-03-08 19:46 ` [XEN][RFC PATCH v3 01/14] xen/arm/device: Remove __init from function type Vikram Garhwal
2022-03-14 12:31   ` Luca Fancellu
2022-03-15 22:29     ` Vikram Garhwal
2022-03-15 22:42     ` Vikram Garhwal
2022-03-08 19:46 ` [XEN][RFC PATCH v3 02/14] xen/arm: Add CONFIG_OVERLAY_DTB Vikram Garhwal
2022-03-14 12:42   ` Luca Fancellu
2022-03-08 19:46 ` [XEN][RFC PATCH v3 03/14] libfdt: Keep fdt functions after init for CONFIG_OVERLAY_DTB Vikram Garhwal
2022-05-17 17:36   ` Julien Grall
2022-03-08 19:46 ` [XEN][RFC PATCH v3 04/14] libfdt: overlay: change overlay_get_target() Vikram Garhwal
2022-03-14 14:55   ` Luca Fancellu
2022-05-17 17:51   ` Julien Grall
2022-03-08 19:46 ` [XEN][RFC PATCH v3 05/14] xen/device-tree: Add _dt_find_node_by_path() to find nodes in device tree Vikram Garhwal
2022-03-14 15:35   ` Luca Fancellu
2022-03-08 19:46 ` [XEN][RFC PATCH v3 06/14] xen/smmu: Add remove_device callback for smmu_iommu ops Vikram Garhwal
2022-03-14 15:45   ` Luca Fancellu
2022-03-08 19:46 ` [XEN][RFC PATCH v3 07/14] xen/iommu: Move spin_lock from iommu_dt_device_is_assigned to caller Vikram Garhwal
2022-03-14 15:58   ` Luca Fancellu
2022-05-17 18:19   ` Julien Grall
2022-03-08 19:46 ` [XEN][RFC PATCH v3 08/14] xen/iommu: protect iommu_add_dt_device() with dtdevs_lock Vikram Garhwal
2022-03-14 17:34   ` Luca Fancellu
2022-03-08 19:46 ` Vikram Garhwal [this message]
2022-03-14 17:50   ` [XEN][RFC PATCH v3 09/14] xen/iommu: Introduce iommu_remove_dt_device() Luca Fancellu
2022-12-07  5:21     ` Vikram Garhwal
2022-03-08 19:47 ` [XEN][RFC PATCH v3 10/14] xen/arm: Implement device tree node removal functionalities Vikram Garhwal
2022-03-15 10:10   ` Luca Fancellu
2022-05-18 18:31   ` Julien Grall
2022-12-07  1:37     ` Vikram Garhwal
2022-12-07 16:50       ` Julien Grall
2022-05-19  8:13   ` Julien Grall
2022-03-08 19:47 ` [XEN][RFC PATCH v3 11/14] xen/arm: Implement device tree node addition functionalities Vikram Garhwal
2022-03-15 10:40   ` Luca Fancellu
2022-05-18 19:03   ` Julien Grall
2022-03-08 19:47 ` [XEN][RFC PATCH v3 12/14] tools/libs/ctrl: Implement new xc interfaces for dt overlay Vikram Garhwal
2022-03-15 10:49   ` Luca Fancellu
2022-03-17 15:47   ` Anthony PERARD
2022-03-08 19:47 ` [XEN][RFC PATCH v3 13/14] tools/libs/light: Implement new libxl functions for device tree overlay ops Vikram Garhwal
2022-03-15 10:58   ` Luca Fancellu
2022-03-17 17:45   ` Anthony PERARD
2022-03-08 19:47 ` [XEN][RFC PATCH v3 14/14] tools/xl: Add new xl command overlay for device tree overlay support Vikram Garhwal
2022-03-15 12:11   ` Luca Fancellu
2022-03-17 18:18   ` Anthony PERARD

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=20220308194704.14061-10-fnu.vikram@xilinx.com \
    --to=fnu.vikram@xilinx.com \
    --cc=bertrand.marquis@arm.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=paul@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=volodymyr_babchuk@epam.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.