ia64/xen-unstable

changeset 3655:924777207448

bitkeeper revision 1.1159.212.89 (42042bd8voKSmpFkxv2_28yjflPbmQ)

Merge ssh://srg//auto/groups/xeno/BK/xeno.bk
into equilibrium.research:/home/irchomes/mwilli2/src/xen-3.0-devel.bk
author mwilli2@equilibrium.research
date Sat Feb 05 02:13:44 2005 +0000 (2005-02-05)
parents 32d29625d39b 03c49d1bcd6b
children d7d832886f82
files linux-2.6.10-xen-sparse/drivers/xen/usbback/common.h linux-2.6.10-xen-sparse/drivers/xen/usbback/interface.c linux-2.6.10-xen-sparse/drivers/xen/usbback/usbback.c linux-2.6.10-xen-sparse/drivers/xen/usbfront/usbfront.c linux-2.6.10-xen-sparse/drivers/xen/usbfront/xhci.h xen/include/public/io/usbif.h
line diff
     1.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/usbback/common.h	Fri Feb 04 22:48:21 2005 +0000
     1.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/usbback/common.h	Sat Feb 05 02:13:44 2005 +0000
     1.3 @@ -38,10 +38,8 @@ struct usbif_priv_st {
     1.4      unsigned long    shmem_frame;
     1.5      unsigned int     evtchn;
     1.6      int              irq;
     1.7 -    /* Comms information. */
     1.8 -    usbif_t      *usb_ring_base; /* ioremap()'ed ptr to shmem_frame. */
     1.9 -    USBIF_RING_IDX     usb_req_cons;  /* Request consumer. */
    1.10 -    USBIF_RING_IDX     usb_resp_prod; /* Private version of resp. producer. */
    1.11 +    /* Comms Information */
    1.12 +    usbif_back_ring_t usb_ring;
    1.13      /* Private fields. */
    1.14      enum { DISCONNECTED, DISCONNECTING, CONNECTED } status;
    1.15      /*
    1.16 @@ -49,11 +47,10 @@ struct usbif_priv_st {
    1.17       * We therefore need to store the id from the original request.
    1.18       */
    1.19      u8                   disconnect_rspid;
    1.20 -    usbif_priv_t *hash_next;
    1.21 +    usbif_priv_t        *hash_next;
    1.22      struct list_head     usbif_list;
    1.23      spinlock_t           usb_ring_lock;
    1.24      atomic_t             refcnt;
    1.25 -    atomic_t             work_scheduled;
    1.26  
    1.27      struct work_struct work;
    1.28  };
    1.29 @@ -80,7 +77,8 @@ usbif_priv_t *usbif_find(domid_t domid);
    1.30  void usbif_interface_init(void);
    1.31  void usbif_ctrlif_init(void);
    1.32  
    1.33 -void usbif_deschedule(usbif_priv_t *usbif);
    1.34 +void usbif_deschedule(usbif_priv_t *up);
    1.35 +void remove_from_usbif_list(usbif_priv_t *up);
    1.36  
    1.37  irqreturn_t usbif_be_int(int irq, void *dev_id, struct pt_regs *regs);
    1.38  
     2.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/usbback/interface.c	Fri Feb 04 22:48:21 2005 +0000
     2.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/usbback/interface.c	Sat Feb 05 02:13:44 2005 +0000
     2.3 @@ -43,7 +43,7 @@ static void __usbif_disconnect_complete(
     2.4       * must still be notified to the remote driver.
     2.5       */
     2.6      unbind_evtchn_from_irq(usbif->evtchn);
     2.7 -    vfree(usbif->usb_ring_base);
     2.8 +    vfree(usbif->usb_ring.sring);
     2.9  
    2.10      /* Construct the deferred response message. */
    2.11      cmsg.type         = CMSG_USBIF_BE;
    2.12 @@ -153,6 +153,7 @@ void usbif_connect(usbif_be_connect_t *c
    2.13      pgprot_t      prot;
    2.14      int           error;
    2.15      usbif_priv_t *up;
    2.16 +    usbif_sring_t *sring;
    2.17  
    2.18      up = usbif_find(domid);
    2.19      if ( unlikely(up == NULL) )
    2.20 @@ -192,10 +193,13 @@ void usbif_connect(usbif_be_connect_t *c
    2.21          return;
    2.22      }
    2.23  
    2.24 +    sring = (usbif_sring_t *)vma->addr;
    2.25 +    SHARED_RING_INIT(USBIF_RING, sring);
    2.26 +    BACK_RING_INIT(USBIF_RING, &up->usb_ring, sring);
    2.27 +
    2.28      up->evtchn        = evtchn;
    2.29      up->irq           = bind_evtchn_to_irq(evtchn);
    2.30      up->shmem_frame   = shmem_frame;
    2.31 -    up->usb_ring_base = (usbif_t *)vma->addr;
    2.32      up->status        = CONNECTED;
    2.33      usbif_get(up);
    2.34  
     3.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/usbback/usbback.c	Fri Feb 04 22:48:21 2005 +0000
     3.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/usbback/usbback.c	Sat Feb 05 02:13:44 2005 +0000
     3.3 @@ -86,7 +86,7 @@ static pending_req_t pending_reqs[MAX_PE
     3.4  static unsigned char pending_ring[MAX_PENDING_REQS];
     3.5  static spinlock_t pend_prod_lock;
     3.6  
     3.7 -/* NB. We use a different index type to differentiate from shared blk rings. */
     3.8 +/* NB. We use a different index type to differentiate from shared usb rings. */
     3.9  typedef unsigned int PEND_RING_IDX;
    3.10  #define MASK_PEND_IDX(_i) ((_i)&(MAX_PENDING_REQS-1))
    3.11  static PEND_RING_IDX pending_prod, pending_cons;
    3.12 @@ -391,17 +391,17 @@ irqreturn_t usbif_be_int(int irq, void *
    3.13  
    3.14  static int do_usb_io_op(usbif_priv_t *up, int max_to_do)
    3.15  {
    3.16 -    usbif_t *usb_ring = up->usb_ring_base;
    3.17 +    usbif_back_ring_t *usb_ring = &up->usb_ring;
    3.18      usbif_request_t *req;
    3.19 -    USBIF_RING_IDX i, rp;
    3.20 +    RING_IDX i, rp;
    3.21      int more_to_do = 0;
    3.22  
    3.23 -    rp = usb_ring->req_prod;
    3.24 +    rp = usb_ring->sring->req_prod;
    3.25      rmb(); /* Ensure we see queued requests up to 'rp'. */
    3.26      
    3.27      /* Take items off the comms ring, taking care not to overflow. */
    3.28 -    for ( i = up->usb_req_cons; 
    3.29 -          (i != rp) && ((i-up->usb_resp_prod) != USBIF_RING_SIZE);
    3.30 +    for ( i = usb_ring->req_cons; 
    3.31 +          (i != rp) && !RING_REQUEST_CONS_OVERFLOW(USBIF_RING, usb_ring, i);
    3.32            i++ )
    3.33      {
    3.34          if ( (max_to_do-- == 0) || (NR_PENDING_REQS == MAX_PENDING_REQS) )
    3.35 @@ -410,7 +410,7 @@ static int do_usb_io_op(usbif_priv_t *up
    3.36              break;
    3.37          }
    3.38  
    3.39 -        req = &usb_ring->ring[MASK_USBIF_IDX(i)].req;
    3.40 +        req = RING_GET_REQUEST(USBIF_RING, usb_ring, i);
    3.41          
    3.42          switch ( req->operation )
    3.43          {
    3.44 @@ -435,7 +435,7 @@ static int do_usb_io_op(usbif_priv_t *up
    3.45          }
    3.46      }
    3.47  
    3.48 -    up->usb_req_cons = i;
    3.49 +    usb_ring->req_cons = i;
    3.50  
    3.51      return more_to_do;
    3.52  }
    3.53 @@ -783,11 +783,11 @@ static void make_response(usbif_priv_t *
    3.54  {
    3.55      usbif_response_t *resp;
    3.56      unsigned long     flags;
    3.57 +    usbif_back_ring_t *usb_ring = &up->usb_ring;
    3.58  
    3.59      /* Place on the response ring for the relevant domain. */ 
    3.60      spin_lock_irqsave(&up->usb_ring_lock, flags);
    3.61 -    resp = &up->usb_ring_base->
    3.62 -        ring[MASK_USBIF_IDX(up->usb_resp_prod)].resp;
    3.63 +    resp = RING_GET_RESPONSE(USBIF_RING, usb_ring, usb_ring->rsp_prod_pvt);
    3.64      resp->id        = id;
    3.65      resp->operation = op;
    3.66      resp->status    = st;
    3.67 @@ -797,7 +797,8 @@ static void make_response(usbif_priv_t *
    3.68  
    3.69      dump_response(resp);
    3.70  
    3.71 -    up->usb_ring_base->resp_prod = ++up->usb_resp_prod;
    3.72 +    usb_ring->rsp_prod_pvt++;
    3.73 +    RING_PUSH_RESPONSES(USBIF_RING, usb_ring);
    3.74      spin_unlock_irqrestore(&up->usb_ring_lock, flags);
    3.75  
    3.76      /* Kick the relevant domain. */
     4.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/usbfront/usbfront.c	Fri Feb 04 22:48:21 2005 +0000
     4.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/usbfront/usbfront.c	Sat Feb 05 02:13:44 2005 +0000
     4.3 @@ -119,7 +119,7 @@ static void xhci_drain_ring(void);
     4.4  
     4.5  #define MAX_URB_LOOP	2048		/* Maximum number of linked URB's */
     4.6  
     4.7 -struct xhci *xhci;
     4.8 +static struct xhci *xhci;
     4.9  
    4.10  enum { USBIF_STATE_CONNECTED = 2,
    4.11         USBIF_STATE_DISCONNECTED = 1,
    4.12 @@ -128,10 +128,60 @@ enum { USBIF_STATE_CONNECTED = 2,
    4.13  
    4.14  static int awaiting_reset = 0;
    4.15  
    4.16 +#ifdef DEBUG
    4.17 +
    4.18 +static void dump_urb(struct urb *urb)
    4.19 +{
    4.20 +    printk(KERN_DEBUG "dumping urb @ %p\n"
    4.21 +           "  hcpriv = %p\n"
    4.22 +           "  next = %p\n"
    4.23 +           "  dev = %p\n"
    4.24 +           "  pipe = 0x%lx\n"
    4.25 +           "  status = %d\n"
    4.26 +           "  transfer_flags = 0x%lx\n"
    4.27 +           "  transfer_buffer = %p\n"
    4.28 +           "  transfer_buffer_length = %d\n"
    4.29 +           "  actual_length = %d\n"
    4.30 +           "  bandwidth = %d\n"
    4.31 +           "  setup_packet = %p\n",
    4.32 +           urb, urb->hcpriv, urb->next, urb->dev, urb->pipe, urb->status,
    4.33 +           urb->transfer_flags, urb->transfer_buffer, urb->transfer_buffer_length,
    4.34 +           urb->actual_length, urb->bandwidth, urb->setup_packet);
    4.35 +    if ( urb->setup_packet != NULL )
    4.36 +        printk(KERN_DEBUG
    4.37 +               "setup = { 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x }\n",
    4.38 +               urb->setup_packet[0], urb->setup_packet[1], urb->setup_packet[2], urb->setup_packet[3],
    4.39 +               urb->setup_packet[4], urb->setup_packet[5], urb->setup_packet[6], urb->setup_packet[7]);
    4.40 +    printk(KERN_DEBUG "complete = %p\n"
    4.41 +           "interval = %d\n", urb->complete, urb->interval);
    4.42 +        
    4.43 +}
    4.44 +
    4.45 +static void xhci_show_resp(usbif_response_t *r)
    4.46 +{
    4.47 +        printk(KERN_DEBUG "dumping response @ %p\n"
    4.48 +               "  id=0x%lx\n"
    4.49 +               "  op=0x%x\n"
    4.50 +               "  data=0x%x\n"
    4.51 +               "  status=0x%x\n"
    4.52 +               "  length=0x%lx\n",
    4.53 +               r->id, r->operation, r->data, r->status, r->length);
    4.54 +}
    4.55 +
    4.56 +#define DPRINK(...) printk(KERN_DEBUG __VA_ARGS__)
    4.57 +
    4.58 +#else /* DEBUG */
    4.59 +
    4.60 +#define dump_urb(blah) ((void)0)
    4.61 +#define xhci_show_resp(blah) ((void)0)
    4.62 +#define DPRINTK(blah,...) ((void)0)
    4.63 +
    4.64 +#endif /* DEBUG */
    4.65 +
    4.66  /**
    4.67   * xhci_construct_isoc - add isochronous information to a request
    4.68   */
    4.69 -int xhci_construct_isoc(usbif_request_t *req, struct urb *urb)
    4.70 +static int xhci_construct_isoc(usbif_request_t *req, struct urb *urb)
    4.71  {
    4.72          usbif_iso_t *schedule;
    4.73          int i;
    4.74 @@ -155,56 +205,28 @@ int xhci_construct_isoc(usbif_request_t 
    4.75          return 0;
    4.76  }
    4.77  
    4.78 -#define USBIF_RING_FULL ((xhci->usbif->req_prod - xhci->usb_resp_cons) == USBIF_RING_SIZE)
    4.79 -
    4.80 -static void dump_urb(struct urb *urb)
    4.81 -{
    4.82 -        printk("dumping urb @ %p\n", urb);
    4.83 -        
    4.84 -        printk("hcpriv = %p\n", urb->hcpriv);
    4.85 -        printk("next = %p\n", urb->next);
    4.86 -        printk("dev = %p\n", urb->dev);
    4.87 -        printk("pipe = 0x%lx\n", urb->pipe);
    4.88 -        printk("status = %d\n", urb->status);
    4.89 -        printk("transfer_flags = 0x%lx\n", urb->transfer_flags);
    4.90 -        printk("transfer_buffer = %p\n", urb->transfer_buffer);
    4.91 -        printk("transfer_buffer_length = %d\n", urb->transfer_buffer_length);
    4.92 -        printk("actual_length = %d\n", urb->actual_length);
    4.93 -        printk("bandwidth = %d\n", urb->bandwidth);
    4.94 -        printk("setup_packet = %p\n", urb->setup_packet);
    4.95 -	if ( urb->setup_packet != NULL )
    4.96 -	          printk("setup = { 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
    4.97 -               urb->setup_packet[0], urb->setup_packet[1], urb->setup_packet[2], urb->setup_packet[3],
    4.98 -               urb->setup_packet[4], urb->setup_packet[5], urb->setup_packet[6], urb->setup_packet[7]);
    4.99 -        printk("complete = %p\n", urb->complete);
   4.100 -        printk("interval = %d\n", urb->interval);
   4.101 -        
   4.102 -}
   4.103 -
   4.104 -
   4.105 -static int
   4.106 -xhci_queue_req(struct urb *urb)
   4.107 +static int xhci_queue_req(struct urb *urb)
   4.108  {
   4.109          usbif_request_t *req;
   4.110 -        usbif_t *usbif = xhci->usbif;
   4.111 +        usbif_front_ring_t *usb_ring = &xhci->usb_ring;
   4.112  
   4.113 -#if 0
   4.114 -        printk("usbif = %p, req_prod = %d (@ 0x%lx), resp_prod = %d, resp_cons = %d\n",
   4.115 +#if DEBUG
   4.116 +        printk(KERN_DEBUG
   4.117 +               "usbif = %p, req_prod = %d (@ 0x%lx), resp_prod = %d, resp_cons = %d\n",
   4.118                 usbif, usbif->req_prod, virt_to_machine(&usbif->req_prod),
   4.119                 usbif->resp_prod, xhci->usb_resp_cons);
   4.120  #endif
   4.121          
   4.122  
   4.123 -/* 	printk("Usbif_priv %p, want IO at 0x%lx\n", urb->hcpriv, virt_to_machine(urb->transfer_buffer)); */
   4.124 -
   4.125 -        if ( USBIF_RING_FULL )
   4.126 +        if ( RING_FULL(USBIF_RING, usb_ring) )
   4.127          {
   4.128 -                printk("xhci_queue_req(): USB ring full, not queuing request\n");
   4.129 +                printk(KERN_WARNING
   4.130 +                       "xhci_queue_req(): USB ring full, not queuing request\n");
   4.131                  return -ENOBUFS;
   4.132          }
   4.133  
   4.134          /* Stick something in the shared communications ring. */
   4.135 -        req = &usbif->ring[MASK_USBIF_IDX(usbif->req_prod)].req;
   4.136 +	req = RING_GET_REQUEST(USBIF_RING, usb_ring, usb_ring->req_prod_pvt);
   4.137  
   4.138          req->operation       = USBIF_OP_IO;
   4.139          req->port            = 0; /* We don't care what the port is. */
   4.140 @@ -232,37 +254,38 @@ xhci_queue_req(struct urb *urb)
   4.141          else
   4.142                  memset(req->setup, 0, 8);
   4.143          
   4.144 -        wmb();
   4.145 -
   4.146 -        usbif->req_prod++;
   4.147 +        usb_ring->req_prod_pvt++;
   4.148 +        RING_PUSH_REQUESTS(USBIF_RING, usb_ring);
   4.149  
   4.150  	notify_via_evtchn(xhci->evtchn);
   4.151  
   4.152 -	//	dump_urb(urb);
   4.153 +        DPRINTK("Queued request for an URB.\n");
   4.154 +        dump_urb(urb);
   4.155  
   4.156          return -EINPROGRESS;
   4.157  }
   4.158  
   4.159 -static inline usbif_request_t *
   4.160 -xhci_queue_probe(usbif_vdev_t port)
   4.161 +static inline usbif_request_t *xhci_queue_probe(usbif_vdev_t port)
   4.162  {
   4.163          usbif_request_t *req;
   4.164 -        usbif_t *usbif = xhci->usbif;
   4.165 +        usbif_front_ring_t *usb_ring = &xhci->usb_ring;
   4.166  
   4.167 -#if 0
   4.168 -	printk("queuing probe: req_prod = %d (@ 0x%lx), resp_prod = %d, resp_cons = %d\n",
   4.169 +#if DEBUG
   4.170 +	printk(KERN_DEBUG
   4.171 +               "queuing probe: req_prod = %d (@ 0x%lx), resp_prod = %d, resp_cons = %d\n",
   4.172  	       usbif->req_prod, virt_to_machine(&usbif->req_prod),
   4.173  	       usbif->resp_prod, xhci->usb_resp_cons);
   4.174  #endif
   4.175          
   4.176 -        if ( USBIF_RING_FULL )
   4.177 +        if ( RING_FULL(USBIF_RING, usb_ring) )
   4.178          {
   4.179 -                printk("xhci_queue_probe(): USB ring full, not queuing request\n");
   4.180 +                printk(KERN_WARNING
   4.181 +                       "xhci_queue_probe(): USB ring full, not queuing request\n");
   4.182                  return NULL;
   4.183          }
   4.184  
   4.185          /* Stick something in the shared communications ring. */
   4.186 -        req = &usbif->ring[MASK_USBIF_IDX(usbif->req_prod)].req;
   4.187 +        req = RING_GET_REQUEST(USBIF_RING, usb_ring, usb_ring->req_prod_pvt);
   4.188  
   4.189          req->operation       = USBIF_OP_PROBE;
   4.190          req->port            = port;
   4.191 @@ -277,34 +300,31 @@ xhci_queue_probe(usbif_vdev_t port)
   4.192  	req->endpoint        = 0;
   4.193  	req->speed           = 0;
   4.194  
   4.195 -        wmb();
   4.196 -
   4.197 -        usbif->req_prod++;
   4.198 +        usb_ring->req_prod_pvt++;
   4.199 +        RING_PUSH_REQUESTS(USBIF_RING, usb_ring);
   4.200  
   4.201  	notify_via_evtchn(xhci->evtchn);
   4.202  
   4.203          return req;
   4.204  }
   4.205  
   4.206 -static int
   4.207 -xhci_port_reset(usbif_vdev_t port)
   4.208 +static int xhci_port_reset(usbif_vdev_t port)
   4.209  {
   4.210          usbif_request_t *req;
   4.211 -        usbif_t *usbif = xhci->usbif;
   4.212 +        usbif_front_ring_t *usb_ring = &xhci->usb_ring;
   4.213  
   4.214          /* We only reset one port at a time, so we only need one variable per
   4.215           * hub. */
   4.216          awaiting_reset = 1;
   4.217          
   4.218          /* Stick something in the shared communications ring. */
   4.219 -        req = &usbif->ring[MASK_USBIF_IDX(usbif->req_prod)].req;
   4.220 +	req = RING_GET_REQUEST(USBIF_RING, usb_ring, usb_ring->req_prod_pvt);
   4.221  
   4.222          req->operation       = USBIF_OP_RESET;
   4.223          req->port            = port;
   4.224          
   4.225 -        wmb();
   4.226 -
   4.227 -        usbif->req_prod++;
   4.228 +        usb_ring->req_prod_pvt++;
   4.229 +	RING_PUSH_REQUESTS(USBIF_RING, usb_ring);
   4.230  
   4.231  	notify_via_evtchn(xhci->evtchn);
   4.232  
   4.233 @@ -317,12 +337,6 @@ xhci_port_reset(usbif_vdev_t port)
   4.234          return awaiting_reset;
   4.235  }
   4.236  
   4.237 -static void xhci_show_resp(usbif_response_t *r)
   4.238 -{
   4.239 -        printk("id=0x%lx, op=0x%x, data=0x%x, status=0x%x, length=0x%lx\n",
   4.240 -               r->id, r->operation, r->data, r->status, r->length);
   4.241 -}
   4.242 -
   4.243  
   4.244  /*
   4.245   * Only the USB core should call xhci_alloc_dev and xhci_free_dev
   4.246 @@ -457,10 +471,8 @@ static int xhci_submit_urb(struct urb *u
   4.247  	struct urb *eurb;
   4.248  	int bustime;
   4.249  
   4.250 -#if 0
   4.251 -        printk("submitting urb @ %p for dev @ %p, devnum = %d path %s\n",
   4.252 -               urb, urb->dev, urb->dev->devnum, urb->dev->devpath);
   4.253 -#endif
   4.254 +        DPRINTK("URB submitted to XHCI driver.\n");
   4.255 +        dump_urb(urb);
   4.256  
   4.257  	if (!urb)
   4.258  		return -EINVAL;
   4.259 @@ -471,12 +483,7 @@ static int xhci_submit_urb(struct urb *u
   4.260  	}
   4.261  
   4.262          if ( urb->dev->devpath == NULL )
   4.263 -        {
   4.264 -                printk("BARF!\n");
   4.265                  BUG();
   4.266 -        }
   4.267 -        
   4.268 -        
   4.269  
   4.270  	usb_inc_dev_use(urb->dev);
   4.271  
   4.272 @@ -517,10 +524,6 @@ static int xhci_submit_urb(struct urb *u
   4.273  		goto out;
   4.274  	}
   4.275  
   4.276 -	if ( usb_pipedevice(urb->pipe) == 1 )
   4.277 -	  printk("dev = %p, dev->path = %s, rh.dev = %p, rh.dev.devnum = %d rh.dev->path = %s!\n",
   4.278 -		 urb->dev, urb->dev->devpath, xhci->rh.dev, xhci->rh.dev->devnum, xhci->rh.dev->devpath);
   4.279 -
   4.280  	switch (usb_pipetype(urb->pipe)) {
   4.281  	case PIPE_CONTROL:
   4.282  		ret = xhci_queue_req(urb);
   4.283 @@ -768,7 +771,7 @@ static int xhci_unlink_urb(struct urb *u
   4.284  }
   4.285  
   4.286  
   4.287 -struct usb_operations xhci_device_operations = {
   4.288 +static struct usb_operations xhci_device_operations = {
   4.289  	.allocate = xhci_alloc_dev,
   4.290  	.deallocate = xhci_free_dev,
   4.291          /* It doesn't look like any drivers actually care what the frame number
   4.292 @@ -1094,7 +1097,6 @@ static int rh_submit_urb(struct urb *urb
   4.293  		}
   4.294  		break;
   4.295  	case RH_SET_ADDRESS:
   4.296 -	  printk("setting root hub device to %d\n", wValue);
   4.297  		xhci->rh.devnum = wValue;
   4.298  		OK(0);
   4.299  	case RH_GET_DESCRIPTOR:
   4.300 @@ -1266,14 +1268,14 @@ static void xhci_finish_completion(void)
   4.301  	spin_unlock_irqrestore(&xhci->complete_list_lock, flags);
   4.302  }
   4.303  
   4.304 -void receive_usb_reset(usbif_response_t *resp)
   4.305 +static void receive_usb_reset(usbif_response_t *resp)
   4.306  {
   4.307      awaiting_reset = resp->status;
   4.308      rmb();
   4.309      
   4.310  }
   4.311  
   4.312 -void receive_usb_probe(usbif_response_t *resp)
   4.313 +static void receive_usb_probe(usbif_response_t *resp)
   4.314  {
   4.315      spin_lock(&xhci->rh.port_state_lock);
   4.316  
   4.317 @@ -1281,8 +1283,6 @@ void receive_usb_probe(usbif_response_t 
   4.318      {
   4.319          if ( resp->status == 1 )
   4.320          {
   4.321 -/* 	  printk("hey hey, there's a device on port %d\n", resp->data); */
   4.322 -
   4.323              /* If theres a device there and there wasn't one before there must
   4.324               * have been a connection status change. */
   4.325              if( xhci->rh.ports[resp->data].cs == 0 )
   4.326 @@ -1290,20 +1290,19 @@ void receive_usb_probe(usbif_response_t 
   4.327                  xhci->rh.ports[resp->data].cs = 1;
   4.328                  xhci->rh.ports[resp->data].ccs = 1;
   4.329                  xhci->rh.ports[resp->data].cs_chg = 1;
   4.330 -/* 		printk("Look at device on port %d that wasn't there before\n", resp->data); */
   4.331  	    }
   4.332          }
   4.333          else
   4.334 -            printk("receive_usb_probe(): unexpected status %d for port %d\n",
   4.335 +            printk(KERN_WARNING "receive_usb_probe(): unexpected status %d for port %d\n",
   4.336                     resp->status, resp->data);
   4.337      }
   4.338      else if ( resp->status < 0)
   4.339 -        printk("receive_usb_probe(): got error status %d\n", resp->status);
   4.340 +        printk(KERN_WARNING "receive_usb_probe(): got error status %d\n", resp->status);
   4.341  
   4.342      spin_unlock(&xhci->rh.port_state_lock);
   4.343  }
   4.344  
   4.345 -void receive_usb_io(usbif_response_t *resp)
   4.346 +static void receive_usb_io(usbif_response_t *resp)
   4.347  {
   4.348          struct urb_priv *urbp = (struct urb_priv *)resp->id;
   4.349          struct urb *urb = urbp->urb;
   4.350 @@ -1333,33 +1332,25 @@ void receive_usb_io(usbif_response_t *re
   4.351  static void xhci_drain_ring(void)
   4.352  {
   4.353  	struct list_head *tmp, *head;
   4.354 -	usbif_t *usb_ring = xhci->usbif;
   4.355 +	usbif_front_ring_t *usb_ring = &xhci->usb_ring;
   4.356  	usbif_response_t *resp;
   4.357 -        USBIF_RING_IDX i, rp;
   4.358 +        RING_IDX i, rp;
   4.359  
   4.360          /* Walk the ring here to get responses, updating URBs to show what
   4.361           * completed. */
   4.362          
   4.363 -        rp = usb_ring->resp_prod;
   4.364 +        rp = usb_ring->sring->rsp_prod;
   4.365          rmb(); /* Ensure we see queued requests up to 'rp'. */
   4.366  
   4.367          /* Take items off the comms ring, taking care not to overflow. */
   4.368 -        for ( i = xhci->usb_resp_cons; 
   4.369 -              (i != rp) && ((i-usb_ring->req_prod) != USBIF_RING_SIZE);
   4.370 -              i++ )
   4.371 +        for ( i = usb_ring->rsp_cons; i != rp; i++ )
   4.372          {
   4.373 -            resp = &usb_ring->ring[MASK_USBIF_IDX(i)].resp;
   4.374 +            resp = RING_GET_RESPONSE(USBIF_RING, usb_ring, i);
   4.375              
   4.376              /* May need to deal with batching and with putting a ceiling on
   4.377                 the number dispatched for performance and anti-dos reasons */
   4.378  
   4.379 -#if 0
   4.380 -            printk("usbfront: Processing response:\n");
   4.381 -            printk("          id = 0x%x\n", resp->id);
   4.382 -            printk("          op = %d\n", resp->operation);
   4.383 -            printk("          status = %d\n", resp->status);
   4.384 -            printk("          length = %d\n", resp->length);
   4.385 -#endif            
   4.386 +            xhci_show_resp(resp);
   4.387  
   4.388              switch ( resp->operation )
   4.389              {
   4.390 @@ -1376,13 +1367,14 @@ static void xhci_drain_ring(void)
   4.391                  break;
   4.392  
   4.393              default:
   4.394 -                printk("error: unknown USB io operation response [%d]\n",
   4.395 -                       usb_ring->ring[i].req.operation);
   4.396 +                printk(KERN_WARNING
   4.397 +                       "error: unknown USB io operation response [%d]\n",
   4.398 +                       resp->operation);
   4.399                  break;
   4.400              }
   4.401          }
   4.402  
   4.403 -        xhci->usb_resp_cons = i;
   4.404 +        usb_ring->rsp_cons = i;
   4.405  
   4.406  	/* Walk the list of pending URB's to see which ones completed and do
   4.407           * callbacks, etc. */
   4.408 @@ -1414,22 +1406,6 @@ static void free_xhci(struct xhci *xhci)
   4.409  	kfree(xhci);
   4.410  }
   4.411  
   4.412 -/* /\* */
   4.413 -/*  * De-allocate all resources.. */
   4.414 -/*  *\/ */
   4.415 -/* static void release_xhci(struct xhci *xhci) */
   4.416 -/* { */
   4.417 -/* 	if (xhci->irq >= 0) { */
   4.418 -/* 		free_irq(xhci->irq, xhci); */
   4.419 -/* 		xhci->irq = -1; */
   4.420 -/* 	} */
   4.421 -
   4.422 -/*         /\* Get the ring back from the backend domain.  Then free it.  Hmmmm. */
   4.423 -/*          * Lets ignore this for now - not particularly useful. *\/ */
   4.424 -
   4.425 -/* 	free_xhci(xhci); */
   4.426 -/* } */
   4.427 -
   4.428  /**
   4.429   * Initialise a new virtual root hub for a new USB device channel.
   4.430   */
   4.431 @@ -1500,10 +1476,6 @@ static int alloc_xhci(void)
   4.432  /*
   4.433   * error exits:
   4.434   */
   4.435 -err_start_root_hub:
   4.436 -	free_irq(xhci->irq, xhci);
   4.437 -	xhci->irq = -1;
   4.438 -
   4.439  err_alloc_root_hub:
   4.440  	usb_free_bus(xhci->bus);
   4.441  	xhci->bus = NULL;
   4.442 @@ -1520,7 +1492,7 @@ static void usbif_status_change(usbif_fe
   4.443      ctrl_msg_t                   cmsg;
   4.444      usbif_fe_interface_connect_t up;
   4.445      long rc;
   4.446 -    usbif_t *usbif;
   4.447 +    usbif_sring_t *sring;
   4.448  
   4.449      switch ( status->status )
   4.450      {
   4.451 @@ -1540,15 +1512,16 @@ static void usbif_status_change(usbif_fe
   4.452          }
   4.453  
   4.454          /* Move from CLOSED to DISCONNECTED state. */
   4.455 -        xhci->usbif = usbif = (usbif_t *)__get_free_page(GFP_KERNEL);
   4.456 -        usbif->req_prod = usbif->resp_prod = 0;
   4.457 +        sring = (usbif_sring_t *)__get_free_page(GFP_KERNEL);
   4.458 +        SHARED_RING_INIT(USBIF_RING, sring);
   4.459 +        FRONT_RING_INIT(USBIF_RING, &xhci->usb_ring, sring);
   4.460          xhci->state  = USBIF_STATE_DISCONNECTED;
   4.461  
   4.462          /* Construct an interface-CONNECT message for the domain controller. */
   4.463          cmsg.type      = CMSG_USBIF_FE;
   4.464          cmsg.subtype   = CMSG_USBIF_FE_INTERFACE_CONNECT;
   4.465          cmsg.length    = sizeof(usbif_fe_interface_connect_t);
   4.466 -        up.shmem_frame = virt_to_machine(usbif) >> PAGE_SHIFT;
   4.467 +        up.shmem_frame = virt_to_machine(sring) >> PAGE_SHIFT;
   4.468          memcpy(cmsg.msg, &up, sizeof(up));
   4.469          
   4.470          /* Tell the controller to bring up the interface. */
   4.471 @@ -1571,8 +1544,6 @@ static void usbif_status_change(usbif_fe
   4.472          xhci->rh.ports = kmalloc (sizeof(xhci_port_t) * xhci->rh.numports, GFP_KERNEL);
   4.473          memset(xhci->rh.ports, 0, sizeof(xhci_port_t) * xhci->rh.numports);
   4.474  
   4.475 -        printk("rh.dev @ %p\n", xhci->rh.dev);
   4.476 -
   4.477  	usb_connect(xhci->rh.dev);
   4.478  
   4.479  	if (usb_new_device(xhci->rh.dev) != 0) {
   4.480 @@ -1589,8 +1560,8 @@ static void usbif_status_change(usbif_fe
   4.481                                 SA_SAMPLE_RANDOM, "usbif", xhci)) )
   4.482                  printk(KERN_ALERT"usbfront request_irq failed (%ld)\n",rc);
   4.483  
   4.484 -	printk(KERN_INFO __FILE__ ": USB XHCI: SHM at %p (0x%lx), EVTCHN %d IRQ %d\n",
   4.485 -               xhci->usbif, virt_to_machine(xhci->usbif), xhci->evtchn, xhci->irq);
   4.486 +	DPRINTK(KERN_INFO __FILE__ ": USB XHCI: SHM at %p (0x%lx), EVTCHN %d IRQ %d\n",
   4.487 +               xhci->usb_ring.sring, virt_to_machine(xhci->usbif), xhci->evtchn, xhci->irq);
   4.488  
   4.489          xhci->state = USBIF_STATE_CONNECTED;
   4.490          
   4.491 @@ -1685,7 +1656,7 @@ static int __init xhci_hcd_init(void)
   4.492          }
   4.493          
   4.494          if (xhci->state != USBIF_STATE_CONNECTED)
   4.495 -            printk(KERN_INFO "Timeout connecting USB frontend driver!\n");
   4.496 +            printk(KERN_WARNING "Timeout connecting USB frontend driver!\n");
   4.497  	
   4.498  	return 0;
   4.499  
   4.500 @@ -1702,7 +1673,7 @@ errbuf_failed:
   4.501  static void __exit xhci_hcd_cleanup(void) 
   4.502  {
   4.503  	if (kmem_cache_destroy(xhci_up_cachep))
   4.504 -		printk(KERN_INFO "xhci: not all urb_priv's were freed\n");
   4.505 +		printk(KERN_WARNING "xhci: not all urb_priv's were freed\n");
   4.506  
   4.507  //        release_xhci(); do some calls here
   4.508  
     5.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/usbfront/xhci.h	Fri Feb 04 22:48:21 2005 +0000
     5.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/usbfront/xhci.h	Sat Feb 05 02:13:44 2005 +0000
     5.3 @@ -104,7 +104,7 @@ struct xhci {
     5.4  
     5.5          spinlock_t response_lock;
     5.6  
     5.7 -        usbif_t *usbif;
     5.8 +        usbif_front_ring_t usb_ring;
     5.9          int usb_resp_cons;
    5.10  };
    5.11  
     6.1 --- a/xen/include/public/io/usbif.h	Fri Feb 04 22:48:21 2005 +0000
     6.2 +++ b/xen/include/public/io/usbif.h	Sat Feb 05 02:13:44 2005 +0000
     6.3 @@ -12,17 +12,10 @@
     6.4  #define usbif_vdev_t   u16
     6.5  #define usbif_sector_t u64
     6.6  
     6.7 -#define USBIF_OP_IO      0
     6.8 +#define USBIF_OP_IO      0 /* Request IO to a device */
     6.9  #define USBIF_OP_PROBE   1 /* Is there a device on this port? */
    6.10  #define USBIF_OP_RESET   2 /* Reset a virtual USB port.       */
    6.11  
    6.12 -/* NB. Ring size must be small enough for sizeof(usbif_ring_t) <= PAGE_SIZE. */
    6.13 -#define USBIF_RING_SIZE        64
    6.14 -
    6.15 -/* XXX this does not want to be here!  it really ought to be dynamic but it can
    6.16 - * live here for now */
    6.17 -#define NUM_PORTS 1
    6.18 -
    6.19  typedef struct {
    6.20      unsigned long  id;           /*  0: private guest value, echoed in resp  */
    6.21      u8             operation;    /*  4: USBIF_OP_???                         */
    6.22 @@ -44,6 +37,7 @@ typedef struct {
    6.23      unsigned long num_iso;        /* 34 : length of iso schedule */
    6.24      unsigned long timeout;        /* 38: timeout in ms */
    6.25  } PACKED usbif_request_t; /* 42 */
    6.26 +
    6.27  /* Data we need to pass:
    6.28   * - Transparently handle short packets or complain at us?
    6.29   */
    6.30 @@ -60,46 +54,8 @@ typedef struct {
    6.31  #define USBIF_RSP_ERROR  -1 /* non-specific 'error' */
    6.32  #define USBIF_RSP_OKAY    0 /* non-specific 'okay'  */
    6.33  
    6.34 -/*
    6.35 - * We use a special capitalised type name because it is _essential_ that all 
    6.36 - * arithmetic on indexes is done on an integer type of the correct size.
    6.37 - */
    6.38 -typedef u32 USBIF_RING_IDX;
    6.39 -
    6.40 -/*
    6.41 - * Ring indexes are 'free running'. That is, they are not stored modulo the
    6.42 - * size of the ring buffer. The following macro converts a free-running counter
    6.43 - * into a value that can directly index a ring-buffer array.
    6.44 - */
    6.45 -#define MASK_USBIF_IDX(_i) ((_i)&(USBIF_RING_SIZE-1))
    6.46 -
    6.47 -typedef struct {
    6.48 -    USBIF_RING_IDX req_prod;  /*  0: Request producer. Updated by front-end. */
    6.49 -    USBIF_RING_IDX resp_prod; /*  4: Response producer. Updated by back-end. */
    6.50 -
    6.51 -    union {                   /*  8 */
    6.52 -        usbif_request_t  req;
    6.53 -        usbif_response_t resp;
    6.54 -    } PACKED ring[USBIF_RING_SIZE];
    6.55 -} PACKED usbif_t;
    6.56 -
    6.57 -
    6.58 -
    6.59 -/*
    6.60 - * USBIF_OP_PROBE:
    6.61 - * The request format for a probe request is constrained as follows:
    6.62 - *  @operation   == USBIF_OP_PROBE
    6.63 - *  @nr_segments == size of probe buffer in pages
    6.64 - *  @device      == unused (zero)
    6.65 - *  @id          == any value (echoed in response message)
    6.66 - *  @sector_num  == unused (zero)
    6.67 - *  @frame_and_sects == list of page-sized buffers.
    6.68 - *                       (i.e., @first_sect == 0, @last_sect == 7).
    6.69 - * 
    6.70 - * The response is a list of vdisk_t elements copied into the out-of-band
    6.71 - * probe buffer. On success the response status field contains the number
    6.72 - * of vdisk_t elements.
    6.73 - */
    6.74 +#define USBIF_RING RING_PARAMS(usbif_request_t, usbif_response_t, PAGE_SIZE)
    6.75 +DEFINE_RING_TYPES(usbif, USBIF_RING);
    6.76  
    6.77  typedef struct {
    6.78      unsigned long length; /* IN = expected, OUT = actual */