diff mbox

[Xen-devel,RFC,17/19] libxl/arm: Rename set_interrupt_ppi to set_interrupt and handle SPIs

Message ID 1402935486-29136-18-git-send-email-julien.grall@linaro.org
State Accepted, archived
Headers show

Commit Message

Julien Grall June 16, 2014, 4:18 p.m. UTC
The function will be used later during device passthrough to create
interrupts in the device tree. Those interrupts are usually SPIs.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
---
 tools/libxl/libxl_arm.c |   26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

Comments

Ian Campbell July 3, 2014, 11:58 a.m. UTC | #1
On Mon, 2014-06-16 at 17:18 +0100, Julien Grall wrote:
> The function will be used later during device passthrough to create
> interrupts in the device tree. Those interrupts are usually SPIs.
> 
> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

Acked-by: Ian Campbell <ian.campbell@citrix.com>

Could this and the previous patch be applied today? I don't see any
dependency on what went before and they seem reasonable cleanups
regardless of the rest of the series.

Ian.
Julien Grall July 3, 2014, 12:04 p.m. UTC | #2
Hi Ian,

On 07/03/2014 12:58 PM, Ian Campbell wrote:
> On Mon, 2014-06-16 at 17:18 +0100, Julien Grall wrote:
>> The function will be used later during device passthrough to create
>> interrupts in the device tree. Those interrupts are usually SPIs.
>>
>> Signed-off-by: Julien Grall <julien.grall@linaro.org>
>> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
>> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> 
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
> 
> Could this and the previous patch be applied today? I don't see any
> dependency on what went before and they seem reasonable cleanups
> regardless of the rest of the series.

They have no dependencies on the other patches of the series. You can
apply them without any issue.

Regards,
Ian Campbell July 3, 2014, 2:04 p.m. UTC | #3
On Thu, 2014-07-03 at 13:04 +0100, Julien Grall wrote:
> Hi Ian,
> 
> On 07/03/2014 12:58 PM, Ian Campbell wrote:
> > On Mon, 2014-06-16 at 17:18 +0100, Julien Grall wrote:
> >> The function will be used later during device passthrough to create
> >> interrupts in the device tree. Those interrupts are usually SPIs.
> >>
> >> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> >> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> >> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> > 
> > Acked-by: Ian Campbell <ian.campbell@citrix.com>
> > 
> > Could this and the previous patch be applied today? I don't see any
> > dependency on what went before and they seem reasonable cleanups
> > regardless of the rest of the series.
> 
> They have no dependencies on the other patches of the series. You can
> apply them without any issue.

I have done so.

Thanks,
Ian.
diff mbox

Patch

diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index 1edb87a..e19e2f4 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -64,14 +64,20 @@  static void set_cell(be32 **cellp, int size, uint64_t val)
     (*cellp) += cells;
 }
 
-static void set_interrupt_ppi(gic_interrupt interrupt, unsigned int irq,
-                              unsigned int cpumask, unsigned int level)
+static void set_interrupt(gic_interrupt interrupt, unsigned int irq,
+                          unsigned int cpumask, unsigned int level)
 {
     be32 *cells = interrupt;
+    int is_ppi = (irq < 32);
+
+    /* SGIs are not describe in the device tree */
+    assert(irq >= 16);
+
+    irq -= (is_ppi) ? 16: 32; /* PPIs start at 16, SPIs at 32 */
 
     /* See linux Documentation/devictree/bindings/arm/gic.txt */
-    set_cell(&cells, 1, 1); /* is a PPI */
-    set_cell(&cells, 1, irq - 16); /* PPIs start at 16 */
+    set_cell(&cells, 1, is_ppi); /* is a PPI? */
+    set_cell(&cells, 1, irq);
     set_cell(&cells, 1, (cpumask << 8) | level);
 }
 
@@ -355,12 +361,9 @@  static int make_timer_node(libxl__gc *gc, void *fdt, const struct arch_info *ain
     res = fdt_property_compat(gc, fdt, 1, ainfo->timer_compat);
     if (res) return res;
 
-    set_interrupt_ppi(ints[0], GUEST_TIMER_PHYS_S_PPI, 0xf,
-                      DT_IRQ_TYPE_LEVEL_LOW);
-    set_interrupt_ppi(ints[1], GUEST_TIMER_PHYS_NS_PPI, 0xf,
-                      DT_IRQ_TYPE_LEVEL_LOW);
-    set_interrupt_ppi(ints[2], GUEST_TIMER_VIRT_PPI, 0xf,
-                      DT_IRQ_TYPE_LEVEL_LOW);
+    set_interrupt(ints[0], GUEST_TIMER_PHYS_S_PPI, 0xf, DT_IRQ_TYPE_LEVEL_LOW);
+    set_interrupt(ints[1], GUEST_TIMER_PHYS_NS_PPI, 0xf, DT_IRQ_TYPE_LEVEL_LOW);
+    set_interrupt(ints[2], GUEST_TIMER_VIRT_PPI, 0xf, DT_IRQ_TYPE_LEVEL_LOW);
 
     res = fdt_property_interrupts(gc, fdt, ints, 3);
     if (res) return res;
@@ -398,8 +401,7 @@  static int make_hypervisor_node(libxl__gc *gc, void *fdt,
      *  - Active-low level-sensitive
      *  - All cpus
      */
-    set_interrupt_ppi(intr, GUEST_EVTCHN_PPI, 0xf,
-                      DT_IRQ_TYPE_LEVEL_LOW);
+    set_interrupt(intr, GUEST_EVTCHN_PPI, 0xf, DT_IRQ_TYPE_LEVEL_LOW);
 
     res = fdt_property_interrupts(gc, fdt, &intr, 1);
     if (res) return res;