diff mbox

[Xen-devel,v4,27/33] tools/libxl: Create a per-arch function to map IRQ to a domain

Message ID 1426793399-6283-28-git-send-email-julien.grall@linaro.org
State New
Headers show

Commit Message

Julien Grall March 19, 2015, 7:29 p.m. UTC
ARM and x86 use a different hypercall to map an IRQ to a domain.

The hypercall to give IRQ permission to the domain as also been moved
on the x86 specific function as ARM guest won't be able to manage the IRQ.
We may want to support it later.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>

---
    Changes in v4:
        - Patch added
---
 tools/libxl/libxl_arch.h   |  4 ++++
 tools/libxl/libxl_arm.c    |  7 +++++++
 tools/libxl/libxl_create.c |  6 ++----
 tools/libxl/libxl_x86.c    | 13 +++++++++++++
 4 files changed, 26 insertions(+), 4 deletions(-)

Comments

Julien Grall March 31, 2015, 12:33 p.m. UTC | #1
Hi Ian,

On 31/03/15 12:26, Ian Campbell wrote:
> On Thu, 2015-03-19 at 19:29 +0000, Julien Grall wrote:
>> ARM and x86 use a different hypercall to map an IRQ to a domain.
>>
>> The hypercall to give IRQ permission to the domain as also been moved
> 
> "has also been".
> 
>> on the x86 specific function as ARM guest won't be able to manage the IRQ.
> 
> s/on the/to be an/?

Yes, I will fix it in the next version.

>> We may want to support it later.
>>
>> Signed-off-by: Julien Grall <julien.grall@linaro.org>
>> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
>> Cc: Wei Liu <wei.liu2@citrix.com>
> 
> Acked-by: Ian Campbell <ian.campbell@citrix.com>

Thanks,
diff mbox

Patch

diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h
index cae64c0..77b1f2a 100644
--- a/tools/libxl/libxl_arch.h
+++ b/tools/libxl/libxl_arch.h
@@ -39,4 +39,8 @@  int libxl__arch_vnuma_build_vmemrange(libxl__gc *gc,
                                       uint32_t domid,
                                       libxl_domain_build_info *b_info,
                                       libxl__domain_build_state *state);
+
+/* arch specific irq map function */
+int libxl__arch_domain_map_irq(libxl__gc *gc, uint32_t domid, int irq);
+
 #endif
diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index 2407c2e..06e940b 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -742,6 +742,13 @@  int libxl__arch_vnuma_build_vmemrange(libxl__gc *gc,
     return libxl__vnuma_build_vmemrange_pv_generic(gc, domid, info, state);
 }
 
+int libxl__arch_domain_map_irq(libxl__gc *gc, uint32_t domid, int irq)
+{
+    return xc_domain_bind_pt_irq(CTX->xch, domid, irq, PT_IRQ_TYPE_SPI,
+                                 0 /* Not used */, 0 /* Not used */,
+                                 0 /* Not used */, irq);
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index e5a343f..15b464e 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1205,11 +1205,9 @@  static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
 
         LOG(DEBUG, "dom%d irq %d", domid, irq);
 
-        ret = irq >= 0 ? xc_physdev_map_pirq(CTX->xch, domid, irq, &irq)
+        ret = irq >= 0 ? libxl__arch_domain_map_irq(gc, domid, irq)
                        : -EOVERFLOW;
-        if (!ret)
-            ret = xc_domain_irq_permission(CTX->xch, domid, irq, 1);
-        if (ret < 0) {
+        if (ret) {
             LOGE(ERROR, "failed give dom%d access to irq %d", domid, irq);
             ret = ERROR_FAIL;
             goto error_out;
diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c
index 3149896..9f6ec18 100644
--- a/tools/libxl/libxl_x86.c
+++ b/tools/libxl/libxl_x86.c
@@ -427,6 +427,19 @@  out:
     return rc;
 }
 
+int libxl__arch_domain_map_irq(libxl__gc *gc, uint32_t domid, int irq)
+{
+    int ret;
+
+    ret = xc_physdev_map_pirq(CTX->xch, domid, irq, &irq);
+    if (ret)
+        return ret;
+
+    ret = xc_domain_irq_permission(CTX->xch, domid, irq, 1);
+
+    return ret;
+}
+
 /*
  * Local variables:
  * mode: C