diff mbox

[Xen-devel,v7,12/12] xen/arm: introduce GIC_PRI_TO_GUEST macro

Message ID 1396969969-18973-12-git-send-email-stefano.stabellini@eu.citrix.com
State New
Headers show

Commit Message

Stefano Stabellini April 8, 2014, 3:12 p.m. UTC
GICH_LR registers and GICH_VMCR only support 5 bits for guest irq
priorities.
Introduce a macro to reduce the 8-bit priority fields to 5 bits; use it
in gic.c.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 xen/arch/arm/gic.c        |    6 +++---
 xen/include/asm-arm/gic.h |    2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)

Comments

Ian Campbell April 23, 2014, 1:32 p.m. UTC | #1
On Tue, 2014-04-08 at 16:12 +0100, Stefano Stabellini wrote:
> GICH_LR registers and GICH_VMCR only support 5 bits for guest irq
> priorities.
> Introduce a macro to reduce the 8-bit priority fields to 5 bits; use it
> in gic.c.
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

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

But my comments on #11 might change some of this...
> +										    5 bits for guest irq prority */

typo: priority

also hard tabs.

>  
> 
>  #ifndef __ASSEMBLY__
diff mbox

Patch

diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index 9295ccf..a4a1ddc 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -636,7 +636,7 @@  static inline void gic_set_lr(int lr, struct pending_irq *p,
     BUG_ON(lr < 0);
     BUG_ON(state & ~(GICH_LR_STATE_MASK<<GICH_LR_STATE_SHIFT));
 
-    lr_reg = state | ((p->priority >> 3) << GICH_LR_PRIORITY_SHIFT) |
+    lr_reg = state | (GIC_PRI_TO_GUEST(p->priority) << GICH_LR_PRIORITY_SHIFT) |
         ((p->irq & GICH_LR_VIRTUAL_MASK) << GICH_LR_VIRTUAL_SHIFT);
     if ( p->desc != NULL )
         lr_reg |= GICH_LR_HW | (p->desc->irq << GICH_LR_PHYSICAL_SHIFT);
@@ -850,7 +850,7 @@  int gic_events_need_delivery(void)
             if ( p->priority < max_priority )
                 max_priority = p->priority;
         }
-        if ( (p->priority >> 3) >= mask_priority )
+        if ( GIC_PRI_TO_GUEST(p->priority) >= mask_priority )
             break;
         lrs--;
         if ( lrs == 0 )
@@ -860,7 +860,7 @@  int gic_events_need_delivery(void)
     spin_unlock_irqrestore(&v->arch.vgic.lock, flags);
 
     if ( max_priority < active_priority &&
-         (max_priority >> 3) < mask_priority )
+         GIC_PRI_TO_GUEST(max_priority) < mask_priority )
         return 1;
     else
         return 0;
diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h
index 5d8f7f1..e3dae52 100644
--- a/xen/include/asm-arm/gic.h
+++ b/xen/include/asm-arm/gic.h
@@ -152,6 +152,8 @@ 
 #define GIC_PRI_IRQ        0xa0
 #define GIC_PRI_IPI        0x90 /* IPIs must preempt normal interrupts */
 #define GIC_PRI_HIGHEST    0x80 /* Higher priorities belong to Secure-World */
+#define GIC_PRI_TO_GUEST(pri) (pri >> 3) /* GICH_LR and GICH_VMCR only support
+										    5 bits for guest irq prority */
 
 
 #ifndef __ASSEMBLY__