xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: julien.grall@arm.com
Cc: Stefano Stabellini <stefanos@xilinx.com>,
	sstabellini@kernel.org, andrii_anisov@epam.com,
	Achin.Gupta@arm.com, xen-devel@lists.xen.org,
	Volodymyr_Babchuk@epam.com
Subject: [Xen-devel] [PATCH v6 1/8] xen/arm: introduce handle_device_interrupts
Date: Thu, 26 Sep 2019 16:11:37 -0700	[thread overview]
Message-ID: <20190926231144.16297-1-sstabellini@kernel.org> (raw)
In-Reply-To: <alpine.DEB.2.21.1909261608430.2594@sstabellini-ThinkPad-T480s>

Move the interrupt handling code out of handle_device to a new function
so that it can be reused for dom0less VMs (it will be used in later
patches).

Signed-off-by: Stefano Stabellini <stefanos@xilinx.com>
Acked-by: Julien Grall <julien.grall@arm.com>
---
Changes in v4:
- rename handle_interrupts to handle_device_interrupts
- improve in-code comment
- remove return 1 if mapping is done
- use unsigned

Changes in v3:
- add patch

The diff is hard to read but I just moved the interrupts related code
from handle_devices to a new function handle_device_interrupts, and very
little else.
---
 xen/arch/arm/domain_build.c | 80 +++++++++++++++++++++++--------------
 1 file changed, 51 insertions(+), 29 deletions(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index a0fee1ef13..21985628f0 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1239,41 +1239,22 @@ static int __init map_device_children(struct domain *d,
 }
 
 /*
- * For a given device node:
- *  - Give permission to the guest to manage IRQ and MMIO range
- *  - Retrieve the IRQ configuration (i.e edge/level) from device tree
- * When the device is not marked for guest passthrough:
- *  - Assign the device to the guest if it's protected by an IOMMU
- *  - Map the IRQs and iomem regions to DOM0
+ * handle_device_interrupts retrieves the interrupts configuration from
+ * a device tree node and maps those interrupts to the target domain.
+ *
+ * Returns:
+ *   < 0 error
+ *   0   success
  */
-static int __init handle_device(struct domain *d, struct dt_device_node *dev,
-                                p2m_type_t p2mt)
+static int __init handle_device_interrupts(struct domain *d,
+                                           struct dt_device_node *dev,
+                                           bool need_mapping)
 {
-    unsigned int nirq;
-    unsigned int naddr;
-    unsigned int i;
+    unsigned int i, nirq;
     int res;
     struct dt_raw_irq rirq;
-    u64 addr, size;
-    bool need_mapping = !dt_device_for_passthrough(dev);
 
     nirq = dt_number_of_irq(dev);
-    naddr = dt_number_of_address(dev);
-
-    dt_dprintk("%s passthrough = %d nirq = %d naddr = %u\n",
-               dt_node_full_name(dev), need_mapping, nirq, naddr);
-
-    if ( dt_device_is_protected(dev) && need_mapping )
-    {
-        dt_dprintk("%s setup iommu\n", dt_node_full_name(dev));
-        res = iommu_assign_dt_device(d, dev);
-        if ( res )
-        {
-            printk(XENLOG_ERR "Failed to setup the IOMMU for %s\n",
-                   dt_node_full_name(dev));
-            return res;
-        }
-    }
 
     /* Give permission and map IRQs */
     for ( i = 0; i < nirq; i++ )
@@ -1310,6 +1291,47 @@ static int __init handle_device(struct domain *d, struct dt_device_node *dev,
             return res;
     }
 
+    return 0;
+}
+
+/*
+ * For a given device node:
+ *  - Give permission to the guest to manage IRQ and MMIO range
+ *  - Retrieve the IRQ configuration (i.e edge/level) from device tree
+ * When the device is not marked for guest passthrough:
+ *  - Assign the device to the guest if it's protected by an IOMMU
+ *  - Map the IRQs and iomem regions to DOM0
+ */
+static int __init handle_device(struct domain *d, struct dt_device_node *dev,
+                                p2m_type_t p2mt)
+{
+    unsigned int naddr;
+    unsigned int i;
+    int res;
+    u64 addr, size;
+    bool need_mapping = !dt_device_for_passthrough(dev);
+
+    naddr = dt_number_of_address(dev);
+
+    dt_dprintk("%s passthrough = %d naddr = %u\n",
+               dt_node_full_name(dev), need_mapping, naddr);
+
+    if ( dt_device_is_protected(dev) && need_mapping )
+    {
+        dt_dprintk("%s setup iommu\n", dt_node_full_name(dev));
+        res = iommu_assign_dt_device(d, dev);
+        if ( res )
+        {
+            printk(XENLOG_ERR "Failed to setup the IOMMU for %s\n",
+                   dt_node_full_name(dev));
+            return res;
+        }
+    }
+
+    res = handle_device_interrupts(d, dev, need_mapping);
+    if ( res < 0 )
+        return res;
+
     /* Give permission and map MMIOs */
     for ( i = 0; i < naddr; i++ )
     {
-- 
2.17.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-09-26 23:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-26 23:11 [Xen-devel] [PATCH v6 0/8] dom0less device assignment Stefano Stabellini
2019-09-26 23:11 ` Stefano Stabellini [this message]
2019-09-26 23:11 ` [Xen-devel] [PATCH v6 2/8] xen/arm: export device_tree_get_reg and device_tree_get_u32 Stefano Stabellini
2019-09-26 23:11 ` [Xen-devel] [PATCH v6 3/8] xen/arm: introduce kinfo->phandle_gic Stefano Stabellini
2019-09-29  9:15   ` Julien Grall
2019-09-26 23:11 ` [Xen-devel] [PATCH v6 4/8] xen/arm: copy dtb fragment to guest dtb Stefano Stabellini
2019-09-29  9:19   ` Julien Grall
2019-09-26 23:11 ` [Xen-devel] [PATCH v6 5/8] xen/arm: assign devices to boot domains Stefano Stabellini
2019-09-29  9:43   ` Julien Grall
2019-09-30 21:12     ` Stefano Stabellini
2019-10-01  9:25       ` Julien Grall
2019-09-26 23:11 ` [Xen-devel] [PATCH v6 6/8] xen/arm: handle "multiboot, device-tree" compatible nodes Stefano Stabellini
2019-09-26 23:11 ` [Xen-devel] [PATCH v6 7/8] xen/arm: introduce nr_spis Stefano Stabellini
2019-09-29  9:48   ` Julien Grall
2019-09-26 23:11 ` [Xen-devel] [PATCH v6 8/8] xen/arm: add dom0-less device assignment info to docs Stefano Stabellini

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=20190926231144.16297-1-sstabellini@kernel.org \
    --to=sstabellini@kernel.org \
    --cc=Achin.Gupta@arm.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrii_anisov@epam.com \
    --cc=julien.grall@arm.com \
    --cc=stefanos@xilinx.com \
    --cc=xen-devel@lists.xen.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).