[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [RFC PATCH v2 06/22] ARM: vGIC: introduce locking routines for multiple IRQs



When replacing the rank lock with individual per-IRQs lock soon, we will
still need the ability to lock multiple IRQs.
Provide two helper routines which lock and unlock a number of consecutive
IRQs in the right order.
Forward-looking the locking function fills an array of pending_irq
pointers, so the lookup has only to be done once.
These routines expect that local_irq_save() has been called before the
lock routine and the respective local_irq_restore() after the unlock
function.

Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>
---
 xen/arch/arm/vgic.c        | 20 ++++++++++++++++++++
 xen/include/asm-arm/vgic.h |  4 ++++
 2 files changed, 24 insertions(+)

diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
index 21b545e..434b7e2 100644
--- a/xen/arch/arm/vgic.c
+++ b/xen/arch/arm/vgic.c
@@ -375,6 +375,26 @@ static inline unsigned int vgic_get_virq_type(struct vcpu 
*v, int n, int index)
         return IRQ_TYPE_LEVEL_HIGH;
 }
 
+void vgic_lock_irqs(struct vcpu *v, unsigned int nrirqs,
+                    unsigned int first_irq, struct pending_irq **pirqs)
+{
+    unsigned int i;
+
+    for ( i = 0; i < nrirqs; i++ )
+    {
+        pirqs[i] = irq_to_pending(v, first_irq + i);
+        spin_lock(&pirqs[i]->lock);
+    }
+}
+
+void vgic_unlock_irqs(struct pending_irq **pirqs, unsigned int nrirqs)
+{
+    int i;
+
+    for ( i = nrirqs - 1; i >= 0; i-- )
+        spin_unlock(&pirqs[i]->lock);
+}
+
 void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
 {
     const unsigned long mask = r;
diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h
index 27b5e37..ecf4969 100644
--- a/xen/include/asm-arm/vgic.h
+++ b/xen/include/asm-arm/vgic.h
@@ -194,6 +194,10 @@ static inline int REG_RANK_NR(int b, uint32_t n)
     }
 }
 
+void vgic_lock_irqs(struct vcpu *v, unsigned int nrirqs, unsigned int 
first_irq,
+                    struct pending_irq **pirqs);
+void vgic_unlock_irqs(struct pending_irq **pirqs, unsigned int nrirqs);
+
 enum gic_sgi_mode;
 
 /*
-- 
2.9.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.