ia64/xen-unstable

changeset 11010:ce619ad2d139

[XEN] Make per-cpu pending EOI interrupt info explicitly PER_CPU.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Aug 08 14:29:16 2006 +0100 (2006-08-08)
parents 7e9699af7e12
children 5fc926b58609
files xen/arch/x86/irq.c
line diff
     1.1 --- a/xen/arch/x86/irq.c	Tue Aug 08 14:18:57 2006 +0100
     1.2 +++ b/xen/arch/x86/irq.c	Tue Aug 08 14:29:16 2006 +0100
     1.3 @@ -160,11 +160,12 @@ typedef struct {
     1.4   * Stack of interrupts awaiting EOI on each CPU. These must be popped in
     1.5   * order, as only the current highest-priority pending irq can be EOIed.
     1.6   */
     1.7 -static struct {
     1.8 +struct pending_eoi {
     1.9      u8 vector; /* Vector awaiting EOI */
    1.10      u8 ready;  /* Ready for EOI now?  */
    1.11 -} pending_eoi[NR_CPUS][NR_VECTORS] __cacheline_aligned;
    1.12 -#define pending_eoi_sp(cpu) (pending_eoi[cpu][NR_VECTORS-1].vector)
    1.13 +};
    1.14 +static DEFINE_PER_CPU(struct pending_eoi, pending_eoi[NR_VECTORS]);
    1.15 +#define pending_eoi_sp(p) ((p)[NR_VECTORS-1].vector)
    1.16  
    1.17  static void __do_IRQ_guest(int vector)
    1.18  {
    1.19 @@ -172,7 +173,8 @@ static void __do_IRQ_guest(int vector)
    1.20      irq_desc_t         *desc = &irq_desc[vector];
    1.21      irq_guest_action_t *action = (irq_guest_action_t *)desc->action;
    1.22      struct domain      *d;
    1.23 -    int                 i, sp, cpu = smp_processor_id();
    1.24 +    int                 i, sp;
    1.25 +    struct pending_eoi *peoi = this_cpu(pending_eoi);
    1.26  
    1.27      if ( unlikely(action->nr_guests == 0) )
    1.28      {
    1.29 @@ -185,13 +187,13 @@ static void __do_IRQ_guest(int vector)
    1.30  
    1.31      if ( action->ack_type == ACKTYPE_EOI )
    1.32      {
    1.33 -        sp = pending_eoi_sp(cpu);
    1.34 -        ASSERT((sp == 0) || (pending_eoi[cpu][sp-1].vector < vector));
    1.35 +        sp = pending_eoi_sp(peoi);
    1.36 +        ASSERT((sp == 0) || (peoi[sp-1].vector < vector));
    1.37          ASSERT(sp < (NR_VECTORS-1));
    1.38 -        pending_eoi[cpu][sp].vector = vector;
    1.39 -        pending_eoi[cpu][sp].ready = 0;
    1.40 -        pending_eoi_sp(cpu) = sp+1;
    1.41 -        cpu_set(cpu, action->cpu_eoi_map);
    1.42 +        peoi[sp].vector = vector;
    1.43 +        peoi[sp].ready = 0;
    1.44 +        pending_eoi_sp(peoi) = sp+1;
    1.45 +        cpu_set(smp_processor_id(), action->cpu_eoi_map);
    1.46      }
    1.47  
    1.48      for ( i = 0; i < action->nr_guests; i++ )
    1.49 @@ -207,43 +209,45 @@ static void __do_IRQ_guest(int vector)
    1.50  /* Flush all ready EOIs from the top of this CPU's pending-EOI stack. */
    1.51  static void flush_ready_eoi(void *unused)
    1.52  {
    1.53 -    irq_desc_t *desc;
    1.54 -    int         vector, sp, cpu = smp_processor_id();
    1.55 +    struct pending_eoi *peoi = this_cpu(pending_eoi);
    1.56 +    irq_desc_t         *desc;
    1.57 +    int                 vector, sp;
    1.58  
    1.59      ASSERT(!local_irq_is_enabled());
    1.60  
    1.61 -    sp = pending_eoi_sp(cpu);
    1.62 +    sp = pending_eoi_sp(peoi);
    1.63  
    1.64 -    while ( (--sp >= 0) && pending_eoi[cpu][sp].ready )
    1.65 +    while ( (--sp >= 0) && peoi[sp].ready )
    1.66      {
    1.67 -        vector = pending_eoi[cpu][sp].vector;
    1.68 +        vector = peoi[sp].vector;
    1.69          desc = &irq_desc[vector];
    1.70          spin_lock(&desc->lock);
    1.71          desc->handler->end(vector);
    1.72          spin_unlock(&desc->lock);
    1.73      }
    1.74  
    1.75 -    pending_eoi_sp(cpu) = sp+1;
    1.76 +    pending_eoi_sp(peoi) = sp+1;
    1.77  }
    1.78  
    1.79  static void __set_eoi_ready(irq_desc_t *desc)
    1.80  {
    1.81      irq_guest_action_t *action = (irq_guest_action_t *)desc->action;
    1.82 -    int                 vector, sp, cpu = smp_processor_id();
    1.83 +    struct pending_eoi *peoi = this_cpu(pending_eoi);
    1.84 +    int                 vector, sp;
    1.85  
    1.86      vector = desc - irq_desc;
    1.87  
    1.88      if ( !(desc->status & IRQ_GUEST) ||
    1.89           (action->in_flight != 0) ||
    1.90 -         !cpu_test_and_clear(cpu, action->cpu_eoi_map) )
    1.91 +         !cpu_test_and_clear(smp_processor_id(), action->cpu_eoi_map) )
    1.92          return;
    1.93  
    1.94 -    sp = pending_eoi_sp(cpu);
    1.95 +    sp = pending_eoi_sp(peoi);
    1.96      do {
    1.97          ASSERT(sp > 0);
    1.98 -    } while ( pending_eoi[cpu][--sp].vector != vector );
    1.99 -    ASSERT(!pending_eoi[cpu][sp].ready);
   1.100 -    pending_eoi[cpu][sp].ready = 1;
   1.101 +    } while ( peoi[--sp].vector != vector );
   1.102 +    ASSERT(!peoi[sp].ready);
   1.103 +    peoi[sp].ready = 1;
   1.104  }
   1.105  
   1.106  /* Mark specified IRQ as ready-for-EOI (if it really is) and attempt to EOI. */
   1.107 @@ -269,16 +273,17 @@ static void flush_all_pending_eoi(void *
   1.108  {
   1.109      irq_desc_t         *desc;
   1.110      irq_guest_action_t *action;
   1.111 -    int                 i, vector, sp, cpu = smp_processor_id();
   1.112 +    struct pending_eoi *peoi = this_cpu(pending_eoi);
   1.113 +    int                 i, vector, sp;
   1.114  
   1.115      ASSERT(!local_irq_is_enabled());
   1.116  
   1.117 -    sp = pending_eoi_sp(cpu);
   1.118 +    sp = pending_eoi_sp(peoi);
   1.119      while ( --sp >= 0 )
   1.120      {
   1.121 -        if ( pending_eoi[cpu][sp].ready )
   1.122 +        if ( peoi[sp].ready )
   1.123              continue;
   1.124 -        vector = pending_eoi[cpu][sp].vector;
   1.125 +        vector = peoi[sp].vector;
   1.126          desc = &irq_desc[vector];
   1.127          spin_lock(&desc->lock);
   1.128          action = (irq_guest_action_t *)desc->action;