All of lore.kernel.org
 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 v9 1/8] xen/arm: introduce handle_device_interrupts
Date: Thu,  3 Oct 2019 18:14:50 -0700	[thread overview]
Message-ID: <20191004011457.11126-1-sstabellini@kernel.org> (raw)
In-Reply-To: <alpine.DEB.2.21.1910031812380.30844@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 | 100 ++++++++++++++++++++++--------------
 1 file changed, 61 insertions(+), 39 deletions(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 337a89e518..fb356603e2 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1238,6 +1238,62 @@ static int __init map_device_children(struct domain *d,
     return 0;
 }
 
+/*
+ * 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_interrupts(struct domain *d,
+                                           struct dt_device_node *dev,
+                                           bool need_mapping)
+{
+    unsigned int i, nirq;
+    int res;
+    struct dt_raw_irq rirq;
+
+    nirq = dt_number_of_irq(dev);
+
+    /* Give permission and map IRQs */
+    for ( i = 0; i < nirq; i++ )
+    {
+        res = dt_device_get_raw_irq(dev, i, &rirq);
+        if ( res )
+        {
+            printk(XENLOG_ERR "Unable to retrieve irq %u for %s\n",
+                   i, dt_node_full_name(dev));
+            return res;
+        }
+
+        /*
+         * Don't map IRQ that have no physical meaning
+         * ie: IRQ whose controller is not the GIC
+         */
+        if ( rirq.controller != dt_interrupt_controller )
+        {
+            dt_dprintk("irq %u not connected to primary controller. Connected to %s\n",
+                      i, dt_node_full_name(rirq.controller));
+            continue;
+        }
+
+        res = platform_get_irq(dev, i);
+        if ( res < 0 )
+        {
+            printk(XENLOG_ERR "Unable to get irq %u for %s\n",
+                   i, dt_node_full_name(dev));
+            return res;
+        }
+
+        res = map_irq_to_domain(d, res, need_mapping, dt_node_name(dev));
+        if ( res )
+            return res;
+    }
+
+    return 0;
+}
+
 /*
  * For a given device node:
  *  - Give permission to the guest to manage IRQ and MMIO range
@@ -1250,19 +1306,16 @@ static int __init map_device_children(struct domain *d,
 static int __init handle_device(struct domain *d, struct dt_device_node *dev,
                                 p2m_type_t p2mt)
 {
-    unsigned int nirq;
     unsigned int naddr;
     unsigned int i;
     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);
+    dt_dprintk("%s passthrough = %d naddr = %u\n",
+               dt_node_full_name(dev), need_mapping, naddr);
 
     if ( need_mapping )
     {
@@ -1290,40 +1343,9 @@ static int __init handle_device(struct domain *d, struct dt_device_node *dev,
         }
     }
 
-    /* Give permission and map IRQs */
-    for ( i = 0; i < nirq; i++ )
-    {
-        res = dt_device_get_raw_irq(dev, i, &rirq);
-        if ( res )
-        {
-            printk(XENLOG_ERR "Unable to retrieve irq %u for %s\n",
-                   i, dt_node_full_name(dev));
-            return res;
-        }
-
-        /*
-         * Don't map IRQ that have no physical meaning
-         * ie: IRQ whose controller is not the GIC
-         */
-        if ( rirq.controller != dt_interrupt_controller )
-        {
-            dt_dprintk("irq %u not connected to primary controller. Connected to %s\n",
-                      i, dt_node_full_name(rirq.controller));
-            continue;
-        }
-
-        res = platform_get_irq(dev, i);
-        if ( res < 0 )
-        {
-            printk(XENLOG_ERR "Unable to get irq %u for %s\n",
-                   i, dt_node_full_name(dev));
-            return res;
-        }
-
-        res = map_irq_to_domain(d, res, need_mapping, dt_node_name(dev));
-        if ( res )
-            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-10-04  1:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-04  1:14 [Xen-devel] [PATCH v9 0/8] dom0less device assignment Stefano Stabellini
2019-10-04  1:14 ` Stefano Stabellini [this message]
2019-10-04  1:14 ` [Xen-devel] [PATCH v9 2/8] xen/arm: export device_tree_get_reg and device_tree_get_u32 Stefano Stabellini
2019-10-04  1:14 ` [Xen-devel] [PATCH v9 3/8] xen/arm: introduce kinfo->phandle_gic Stefano Stabellini
2019-10-04  1:14 ` [Xen-devel] [PATCH v9 4/8] xen/arm: copy dtb fragment to guest dtb Stefano Stabellini
2019-10-04  1:14 ` [Xen-devel] [PATCH v9 5/8] xen/arm: assign devices to boot domains Stefano Stabellini
2019-10-04  7:57   ` Julien Grall
2019-10-04  1:14 ` [Xen-devel] [PATCH v9 6/8] xen/arm: handle "multiboot, device-tree" compatible nodes Stefano Stabellini
2019-10-04  1:14 ` [Xen-devel] [PATCH v9 7/8] xen/arm: introduce nr_spis Stefano Stabellini
2019-10-04  1:14 ` [Xen-devel] [PATCH v9 8/8] xen/arm: add dom0-less device assignment info to docs Stefano Stabellini
2019-10-04  8:02   ` Julien Grall
2019-10-04  1:31 ` [Xen-devel] [PATCH v9 0/8] dom0less device assignment 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=20191004011457.11126-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 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.