ia64/xen-unstable

changeset 1243:328b9b7ee67e

bitkeeper revision 1.825.4.6 (40645529V38YcP4nuYrPCmsUH5J_Bw)

sched.h, irq.h, physdev.c, irq.c:
Final piece of guest-PIRQ functionality in Xen.
author kaf24@scramble.cl.cam.ac.uk
date Fri Mar 26 16:07:05 2004 +0000 (2004-03-26)
parents e2d412f4b445
children 8a73ba812e21
files xen/arch/i386/irq.c xen/common/physdev.c xen/include/xen/irq.h xen/include/xen/sched.h
line diff
     1.1 --- a/xen/arch/i386/irq.c	Fri Mar 26 15:17:44 2004 +0000
     1.2 +++ b/xen/arch/i386/irq.c	Fri Mar 26 16:07:05 2004 +0000
     1.3 @@ -941,7 +941,8 @@ int setup_irq(unsigned int irq, struct i
     1.4  
     1.5  #define IRQ_MAX_GUESTS 7
     1.6  typedef struct {
     1.7 -    unsigned int nr_guests;
     1.8 +    unsigned short nr_guests;
     1.9 +    unsigned short in_flight;
    1.10      struct task_struct *guest[IRQ_MAX_GUESTS];
    1.11  } irq_guest_action_t;
    1.12  
    1.13 @@ -955,10 +956,39 @@ static void __do_IRQ_guest(int irq)
    1.14      for ( i = 0; i < action->nr_guests; i++ )
    1.15      {
    1.16          p = action->guest[i];
    1.17 +        if ( !test_and_set_bit(irq, &p->pirq_mask) )
    1.18 +            action->in_flight++;
    1.19          send_guest_pirq(p, irq);
    1.20      }
    1.21  }
    1.22  
    1.23 +int pirq_guest_unmask(struct task_struct *p)
    1.24 +{
    1.25 +    irq_desc_t *desc;
    1.26 +    int i, j, pirq;
    1.27 +    u32 m;
    1.28 +    shared_info_t *s = p->shared_info;
    1.29 +
    1.30 +    for ( i = 0; i < 2; i++ )
    1.31 +    {
    1.32 +        m = p->pirq_mask[i];
    1.33 +        while ( (j = ffs(m)) != 0 )
    1.34 +        {
    1.35 +            m &= ~(1 << --j);
    1.36 +            pirq = (i << 5) + j;
    1.37 +            desc = &irq_desc[pirq];
    1.38 +            spin_lock_irq(&desc->lock);
    1.39 +            if ( !test_bit(p->pirq_to_evtchn[pirq], &s->evtchn_mask[0]) &&
    1.40 +                 test_and_clear_bit(pirq, &p->pirq_mask) &&
    1.41 +                 (--((irq_guest_action_t *)desc->action)->in_flight == 0) )
    1.42 +                desc->handler->end(pirq);
    1.43 +            spin_unlock_irq(&desc->lock);
    1.44 +        }
    1.45 +    }
    1.46 +
    1.47 +    return 0;
    1.48 +}
    1.49 +
    1.50  int pirq_guest_bind(struct task_struct *p, int irq)
    1.51  {
    1.52      unsigned long flags;
    1.53 @@ -983,7 +1013,8 @@ int pirq_guest_bind(struct task_struct *
    1.54              goto out;
    1.55  
    1.56          action->nr_guests = 0;
    1.57 -
    1.58 +        action->in_flight = 0;
    1.59 +        
    1.60          desc->depth = 0;
    1.61          desc->status |= IRQ_GUEST;
    1.62          desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT | IRQ_WAITING);
    1.63 @@ -1014,6 +1045,10 @@ int pirq_guest_unbind(struct task_struct
    1.64  
    1.65      action = (irq_guest_action_t *)desc->action;
    1.66  
    1.67 +    if ( test_and_clear_bit(irq, &p->pirq_mask) &&
    1.68 +         (--action->in_flight == 0) )
    1.69 +        desc->handler->end(irq);
    1.70 +
    1.71      if ( action->nr_guests == 1 )
    1.72      {
    1.73          desc->action = NULL;
     2.1 --- a/xen/common/physdev.c	Fri Mar 26 15:17:44 2004 +0000
     2.2 +++ b/xen/common/physdev.c	Fri Mar 26 16:07:05 2004 +0000
     2.3 @@ -564,12 +564,6 @@ static long pci_find_irq(int seg, int bu
     2.4  }
     2.5  
     2.6  
     2.7 -static long pci_unmask_irq(void)
     2.8 -{
     2.9 -    return 0;
    2.10 -}
    2.11 -
    2.12 -
    2.13  /*
    2.14   * demux hypervisor call.
    2.15   */
    2.16 @@ -604,7 +598,7 @@ long do_physdev_op(physdev_op_t *uop)
    2.17          break;
    2.18  
    2.19      case PHYSDEVOP_UNMASK_IRQ:
    2.20 -        ret = pci_unmask_irq();
    2.21 +        ret = pirq_guest_unmask(current);
    2.22          break;
    2.23  
    2.24      default:
     3.1 --- a/xen/include/xen/irq.h	Fri Mar 26 15:17:44 2004 +0000
     3.2 +++ b/xen/include/xen/irq.h	Fri Mar 26 16:07:05 2004 +0000
     3.3 @@ -58,6 +58,7 @@ extern hw_irq_controller no_irq_type;
     3.4  extern void no_action(int cpl, void *dev_id, struct pt_regs *regs);
     3.5  
     3.6  struct task_struct;
     3.7 +extern int pirq_guest_unmask(struct task_struct *p);
     3.8  extern int pirq_guest_bind(struct task_struct *p, int irq);
     3.9  extern int pirq_guest_unbind(struct task_struct *p, int irq);
    3.10  
     4.1 --- a/xen/include/xen/sched.h	Fri Mar 26 15:17:44 2004 +0000
     4.2 +++ b/xen/include/xen/sched.h	Fri Mar 26 16:07:05 2004 +0000
     4.3 @@ -163,6 +163,7 @@ struct task_struct
     4.4       */
     4.5      u16 pirq_to_evtchn[64];
     4.6      u16 virq_to_evtchn[NR_VIRQS];
     4.7 +    u32 pirq_mask[2];
     4.8  
     4.9      /* Physical I/O */
    4.10      spinlock_t       pcidev_lock;