ia64/xen-unstable

changeset 2924:7ed93ab784b6

bitkeeper revision 1.1159.1.398 (4190c2a3yFTT9r-Ede8ilkq-wZrXkg)

Add focus to pirqs and interdomain evtchns.
author cl349@freefall.cl.cam.ac.uk
date Tue Nov 09 13:14:11 2004 +0000 (2004-11-09)
parents 5eaad90b54c0
children e8a2c91dfc4f
files xen/arch/x86/irq.c xen/common/event_channel.c xen/include/xen/event.h xen/include/xen/irq.h xen/include/xen/sched.h
line diff
     1.1 --- a/xen/arch/x86/irq.c	Tue Nov 09 13:12:34 2004 +0000
     1.2 +++ b/xen/arch/x86/irq.c	Tue Nov 09 13:14:11 2004 +0000
     1.3 @@ -188,22 +188,22 @@ typedef struct {
     1.4      u8 nr_guests;
     1.5      u8 in_flight;
     1.6      u8 shareable;
     1.7 -    struct domain *guest[IRQ_MAX_GUESTS];
     1.8 +    struct exec_domain *guest[IRQ_MAX_GUESTS];
     1.9  } irq_guest_action_t;
    1.10  
    1.11  static void __do_IRQ_guest(int irq)
    1.12  {
    1.13      irq_desc_t         *desc = &irq_desc[irq];
    1.14      irq_guest_action_t *action = (irq_guest_action_t *)desc->action;
    1.15 -    struct domain      *d;
    1.16 +    struct exec_domain *ed;
    1.17      int                 i;
    1.18  
    1.19      for ( i = 0; i < action->nr_guests; i++ )
    1.20      {
    1.21 -        d = action->guest[i];
    1.22 -        if ( !test_and_set_bit(irq, &d->pirq_mask) )
    1.23 +        ed = action->guest[i];
    1.24 +        if ( !test_and_set_bit(irq, &ed->domain->pirq_mask) )
    1.25              action->in_flight++;
    1.26 -        send_guest_pirq(d, irq);
    1.27 +        send_guest_pirq(ed, irq);
    1.28      }
    1.29  }
    1.30  
    1.31 @@ -235,8 +235,9 @@ int pirq_guest_unmask(struct domain *d)
    1.32      return 0;
    1.33  }
    1.34  
    1.35 -int pirq_guest_bind(struct domain *d, int irq, int will_share)
    1.36 +int pirq_guest_bind(struct exec_domain *ed, int irq, int will_share)
    1.37  {
    1.38 +    struct domain      *d = ed->domain;
    1.39      irq_desc_t         *desc = &irq_desc[irq];
    1.40      irq_guest_action_t *action;
    1.41      unsigned long       flags;
    1.42 @@ -296,7 +297,7 @@ int pirq_guest_bind(struct domain *d, in
    1.43          goto out;
    1.44      }
    1.45  
    1.46 -    action->guest[action->nr_guests++] = d;
    1.47 +    action->guest[action->nr_guests++] = ed;
    1.48  
    1.49   out:
    1.50      spin_unlock_irqrestore(&desc->lock, flags);
    1.51 @@ -330,7 +331,7 @@ int pirq_guest_unbind(struct domain *d, 
    1.52      else
    1.53      {
    1.54          i = 0;
    1.55 -        while ( action->guest[i] != d )
    1.56 +        while ( action->guest[i] && action->guest[i]->domain != d )
    1.57              i++;
    1.58          memmove(&action->guest[i], &action->guest[i+1], IRQ_MAX_GUESTS-i-1);
    1.59          action->nr_guests--;
     2.1 --- a/xen/common/event_channel.c	Tue Nov 09 13:12:34 2004 +0000
     2.2 +++ b/xen/common/event_channel.c	Tue Nov 09 13:14:11 2004 +0000
     2.3 @@ -96,6 +96,7 @@ static long evtchn_bind_interdomain(evtc
     2.4  {
     2.5  #define ERROR_EXIT(_errno) do { rc = (_errno); goto out; } while ( 0 )
     2.6      struct domain *d1, *d2;
     2.7 +    struct exec_domain *ed1, *ed2;
     2.8      int            port1 = bind->port1, port2 = bind->port2;
     2.9      domid_t        dom1 = bind->dom1, dom2 = bind->dom2;
    2.10      long           rc = 0;
    2.11 @@ -119,6 +120,9 @@ static long evtchn_bind_interdomain(evtc
    2.12          return -ESRCH;
    2.13      }
    2.14  
    2.15 +    ed1 = d1->exec_domain[0];   /* XXX */
    2.16 +    ed2 = d2->exec_domain[0];   /* XXX */
    2.17 +
    2.18      /* Avoid deadlock by first acquiring lock of domain with smaller id. */
    2.19      if ( d1 < d2 )
    2.20      {
    2.21 @@ -167,7 +171,7 @@ static long evtchn_bind_interdomain(evtc
    2.22          break;
    2.23  
    2.24      case ECS_INTERDOMAIN:
    2.25 -        if ( d1->event_channel[port1].u.interdomain.remote_dom != d2 )
    2.26 +        if ( d1->event_channel[port1].u.interdomain.remote_dom != ed2 )
    2.27              ERROR_EXIT(-EINVAL);
    2.28          if ( (d1->event_channel[port1].u.interdomain.remote_port != port2) &&
    2.29               (bind->port2 != 0) )
    2.30 @@ -193,7 +197,7 @@ static long evtchn_bind_interdomain(evtc
    2.31          break;
    2.32  
    2.33      case ECS_INTERDOMAIN:
    2.34 -        if ( d2->event_channel[port2].u.interdomain.remote_dom != d1 )
    2.35 +        if ( d2->event_channel[port2].u.interdomain.remote_dom != ed1 )
    2.36              ERROR_EXIT(-EINVAL);
    2.37          if ( (d2->event_channel[port2].u.interdomain.remote_port != port1) &&
    2.38               (bind->port1 != 0) )
    2.39 @@ -209,11 +213,11 @@ static long evtchn_bind_interdomain(evtc
    2.40       * Everything checked out okay -- bind <dom1,port1> to <dom2,port2>.
    2.41       */
    2.42  
    2.43 -    d1->event_channel[port1].u.interdomain.remote_dom  = d2;
    2.44 +    d1->event_channel[port1].u.interdomain.remote_dom  = ed2;
    2.45      d1->event_channel[port1].u.interdomain.remote_port = (u16)port2;
    2.46      d1->event_channel[port1].state                     = ECS_INTERDOMAIN;
    2.47      
    2.48 -    d2->event_channel[port2].u.interdomain.remote_dom  = d1;
    2.49 +    d2->event_channel[port2].u.interdomain.remote_dom  = ed1;
    2.50      d2->event_channel[port2].u.interdomain.remote_port = (u16)port1;
    2.51      d2->event_channel[port2].state                     = ECS_INTERDOMAIN;
    2.52  
    2.53 @@ -284,7 +288,7 @@ static long evtchn_bind_pirq(evtchn_bind
    2.54          goto out;
    2.55  
    2.56      d->pirq_to_evtchn[pirq] = port;
    2.57 -    rc = pirq_guest_bind(d, pirq, 
    2.58 +    rc = pirq_guest_bind(current, pirq, 
    2.59                           !!(bind->flags & BIND_PIRQ__WILL_SHARE));
    2.60      if ( rc != 0 )
    2.61      {
    2.62 @@ -346,7 +350,7 @@ static long __evtchn_close(struct domain
    2.63      case ECS_INTERDOMAIN:
    2.64          if ( d2 == NULL )
    2.65          {
    2.66 -            d2 = chn1[port1].u.interdomain.remote_dom;
    2.67 +            d2 = chn1[port1].u.interdomain.remote_dom->domain;
    2.68  
    2.69              /* If we unlock d1 then we could lose d2. Must get a reference. */
    2.70              if ( unlikely(!get_domain(d2)) )
    2.71 @@ -370,7 +374,7 @@ static long __evtchn_close(struct domain
    2.72                  goto again;
    2.73              }
    2.74          }
    2.75 -        else if ( d2 != chn1[port1].u.interdomain.remote_dom )
    2.76 +        else if ( d2 != chn1[port1].u.interdomain.remote_dom->domain )
    2.77          {
    2.78              rc = -EINVAL;
    2.79              goto out;
    2.80 @@ -383,7 +387,7 @@ static long __evtchn_close(struct domain
    2.81              BUG();
    2.82          if ( chn2[port2].state != ECS_INTERDOMAIN )
    2.83              BUG();
    2.84 -        if ( chn2[port2].u.interdomain.remote_dom != d1 )
    2.85 +        if ( chn2[port2].u.interdomain.remote_dom->domain != d1 )
    2.86              BUG();
    2.87  
    2.88          chn2[port2].state = ECS_UNBOUND;
    2.89 @@ -433,7 +437,8 @@ static long evtchn_close(evtchn_close_t 
    2.90  
    2.91  static long evtchn_send(int lport)
    2.92  {
    2.93 -    struct domain *ld = current->domain, *rd;
    2.94 +    struct domain *ld = current->domain;
    2.95 +    struct exec_domain *rd;
    2.96      int            rport;
    2.97  
    2.98      spin_lock(&ld->event_channel_lock);
    2.99 @@ -494,7 +499,8 @@ static long evtchn_status(evtchn_status_
   2.100          break;
   2.101      case ECS_INTERDOMAIN:
   2.102          status->status = EVTCHNSTAT_interdomain;
   2.103 -        status->u.interdomain.dom  = chn[port].u.interdomain.remote_dom->id;
   2.104 +        status->u.interdomain.dom  =
   2.105 +            chn[port].u.interdomain.remote_dom->domain->id;
   2.106          status->u.interdomain.port = chn[port].u.interdomain.remote_port;
   2.107          break;
   2.108      case ECS_PIRQ:
     3.1 --- a/xen/include/xen/event.h	Tue Nov 09 13:12:34 2004 +0000
     3.2 +++ b/xen/include/xen/event.h	Tue Nov 09 13:14:11 2004 +0000
     3.3 @@ -20,9 +20,9 @@
     3.4   * may require explicit memory barriers.
     3.5   */
     3.6  
     3.7 -static inline void evtchn_set_pending(struct domain *d, int port)
     3.8 +static inline void evtchn_set_pending(struct exec_domain *ed, int port)
     3.9  {
    3.10 -    struct exec_domain *ed = d->exec_domain[0];
    3.11 +    struct domain *d = ed->domain;
    3.12      shared_info_t *s = d->shared_info;
    3.13      int            running;
    3.14  
    3.15 @@ -57,8 +57,7 @@ static inline void evtchn_set_pending(st
    3.16   */
    3.17  static inline void send_guest_virq(struct exec_domain *ed, int virq)
    3.18  {
    3.19 -    struct domain *d = ed->domain;
    3.20 -    evtchn_set_pending(d, d->virq_to_evtchn[virq]);
    3.21 +    evtchn_set_pending(ed, ed->domain->virq_to_evtchn[virq]);
    3.22  }
    3.23  
    3.24  /*
    3.25 @@ -66,9 +65,9 @@ static inline void send_guest_virq(struc
    3.26   *  @d:        Domain to which physical IRQ should be sent
    3.27   *  @pirq:     Physical IRQ number
    3.28   */
    3.29 -static inline void send_guest_pirq(struct domain *d, int pirq)
    3.30 +static inline void send_guest_pirq(struct exec_domain *ed, int pirq)
    3.31  {
    3.32 -    evtchn_set_pending(d, d->pirq_to_evtchn[pirq]);
    3.33 +    evtchn_set_pending(ed, ed->domain->pirq_to_evtchn[pirq]);
    3.34  }
    3.35  
    3.36  #define event_pending(_d)                                     \
     4.1 --- a/xen/include/xen/irq.h	Tue Nov 09 13:12:34 2004 +0000
     4.2 +++ b/xen/include/xen/irq.h	Tue Nov 09 13:14:11 2004 +0000
     4.3 @@ -65,8 +65,9 @@ extern hw_irq_controller no_irq_type;
     4.4  extern void no_action(int cpl, void *dev_id, struct xen_regs *regs);
     4.5  
     4.6  struct domain;
     4.7 +struct exec_domain;
     4.8  extern int pirq_guest_unmask(struct domain *p);
     4.9 -extern int pirq_guest_bind(struct domain *p, int irq, int will_share);
    4.10 +extern int pirq_guest_bind(struct exec_domain *p, int irq, int will_share);
    4.11  extern int pirq_guest_unbind(struct domain *p, int irq);
    4.12  extern int pirq_guest_bindable(int irq, int will_share);
    4.13  
     5.1 --- a/xen/include/xen/sched.h	Tue Nov 09 13:12:34 2004 +0000
     5.2 +++ b/xen/include/xen/sched.h	Tue Nov 09 13:14:11 2004 +0000
     5.3 @@ -42,8 +42,8 @@ typedef struct event_channel_st
     5.4              domid_t remote_domid;
     5.5          } __attribute__ ((packed)) unbound; /* state == ECS_UNBOUND */
     5.6          struct {
     5.7 -            u16            remote_port;
     5.8 -            struct domain *remote_dom;
     5.9 +            u16                 remote_port;
    5.10 +            struct exec_domain *remote_dom;
    5.11          } __attribute__ ((packed)) interdomain; /* state == ECS_INTERDOMAIN */
    5.12          u16 pirq; /* state == ECS_PIRQ */
    5.13          u16 virq; /* state == ECS_VIRQ */