# HG changeset patch # User mwilli2@equilibrium.research # Date 1107569576 0 # Node ID 03c49d1bcd6b1c07a0ca2baee45992b63903c3e5 # Parent d3f0465c034edf58dcf8424c74184cda495d57ac bitkeeper revision 1.1159.243.1 (42042ba8OAh4EZUckgdGWWSqRLutaQ) Various cleanups, including a move to the new ring macros. diff -r d3f0465c034e -r 03c49d1bcd6b linux-2.6.10-xen-sparse/drivers/xen/usbback/common.h --- a/linux-2.6.10-xen-sparse/drivers/xen/usbback/common.h Fri Feb 04 02:25:03 2005 +0000 +++ b/linux-2.6.10-xen-sparse/drivers/xen/usbback/common.h Sat Feb 05 02:12:56 2005 +0000 @@ -38,10 +38,8 @@ struct usbif_priv_st { unsigned long shmem_frame; unsigned int evtchn; int irq; - /* Comms information. */ - usbif_t *usb_ring_base; /* ioremap()'ed ptr to shmem_frame. */ - USBIF_RING_IDX usb_req_cons; /* Request consumer. */ - USBIF_RING_IDX usb_resp_prod; /* Private version of resp. producer. */ + /* Comms Information */ + usbif_back_ring_t usb_ring; /* Private fields. */ enum { DISCONNECTED, DISCONNECTING, CONNECTED } status; /* @@ -49,11 +47,10 @@ struct usbif_priv_st { * We therefore need to store the id from the original request. */ u8 disconnect_rspid; - usbif_priv_t *hash_next; + usbif_priv_t *hash_next; struct list_head usbif_list; spinlock_t usb_ring_lock; atomic_t refcnt; - atomic_t work_scheduled; struct work_struct work; }; @@ -80,7 +77,8 @@ usbif_priv_t *usbif_find(domid_t domid); void usbif_interface_init(void); void usbif_ctrlif_init(void); -void usbif_deschedule(usbif_priv_t *usbif); +void usbif_deschedule(usbif_priv_t *up); +void remove_from_usbif_list(usbif_priv_t *up); irqreturn_t usbif_be_int(int irq, void *dev_id, struct pt_regs *regs); diff -r d3f0465c034e -r 03c49d1bcd6b linux-2.6.10-xen-sparse/drivers/xen/usbback/interface.c --- a/linux-2.6.10-xen-sparse/drivers/xen/usbback/interface.c Fri Feb 04 02:25:03 2005 +0000 +++ b/linux-2.6.10-xen-sparse/drivers/xen/usbback/interface.c Sat Feb 05 02:12:56 2005 +0000 @@ -43,7 +43,7 @@ static void __usbif_disconnect_complete( * must still be notified to the remote driver. */ unbind_evtchn_from_irq(usbif->evtchn); - vfree(usbif->usb_ring_base); + vfree(usbif->usb_ring.sring); /* Construct the deferred response message. */ cmsg.type = CMSG_USBIF_BE; @@ -153,6 +153,7 @@ void usbif_connect(usbif_be_connect_t *c pgprot_t prot; int error; usbif_priv_t *up; + usbif_sring_t *sring; up = usbif_find(domid); if ( unlikely(up == NULL) ) @@ -192,10 +193,13 @@ void usbif_connect(usbif_be_connect_t *c return; } + sring = (usbif_sring_t *)vma->addr; + SHARED_RING_INIT(USBIF_RING, sring); + BACK_RING_INIT(USBIF_RING, &up->usb_ring, sring); + up->evtchn = evtchn; up->irq = bind_evtchn_to_irq(evtchn); up->shmem_frame = shmem_frame; - up->usb_ring_base = (usbif_t *)vma->addr; up->status = CONNECTED; usbif_get(up); diff -r d3f0465c034e -r 03c49d1bcd6b linux-2.6.10-xen-sparse/drivers/xen/usbback/usbback.c --- a/linux-2.6.10-xen-sparse/drivers/xen/usbback/usbback.c Fri Feb 04 02:25:03 2005 +0000 +++ b/linux-2.6.10-xen-sparse/drivers/xen/usbback/usbback.c Sat Feb 05 02:12:56 2005 +0000 @@ -86,7 +86,7 @@ static pending_req_t pending_reqs[MAX_PE static unsigned char pending_ring[MAX_PENDING_REQS]; static spinlock_t pend_prod_lock; -/* NB. We use a different index type to differentiate from shared blk rings. */ +/* NB. We use a different index type to differentiate from shared usb rings. */ typedef unsigned int PEND_RING_IDX; #define MASK_PEND_IDX(_i) ((_i)&(MAX_PENDING_REQS-1)) static PEND_RING_IDX pending_prod, pending_cons; @@ -391,17 +391,17 @@ irqreturn_t usbif_be_int(int irq, void * static int do_usb_io_op(usbif_priv_t *up, int max_to_do) { - usbif_t *usb_ring = up->usb_ring_base; + usbif_back_ring_t *usb_ring = &up->usb_ring; usbif_request_t *req; - USBIF_RING_IDX i, rp; + RING_IDX i, rp; int more_to_do = 0; - rp = usb_ring->req_prod; + rp = usb_ring->sring->req_prod; rmb(); /* Ensure we see queued requests up to 'rp'. */ /* Take items off the comms ring, taking care not to overflow. */ - for ( i = up->usb_req_cons; - (i != rp) && ((i-up->usb_resp_prod) != USBIF_RING_SIZE); + for ( i = usb_ring->req_cons; + (i != rp) && !RING_REQUEST_CONS_OVERFLOW(USBIF_RING, usb_ring, i); i++ ) { if ( (max_to_do-- == 0) || (NR_PENDING_REQS == MAX_PENDING_REQS) ) @@ -410,7 +410,7 @@ static int do_usb_io_op(usbif_priv_t *up break; } - req = &usb_ring->ring[MASK_USBIF_IDX(i)].req; + req = RING_GET_REQUEST(USBIF_RING, usb_ring, i); switch ( req->operation ) { @@ -435,7 +435,7 @@ static int do_usb_io_op(usbif_priv_t *up } } - up->usb_req_cons = i; + usb_ring->req_cons = i; return more_to_do; } @@ -783,11 +783,11 @@ static void make_response(usbif_priv_t * { usbif_response_t *resp; unsigned long flags; + usbif_back_ring_t *usb_ring = &up->usb_ring; /* Place on the response ring for the relevant domain. */ spin_lock_irqsave(&up->usb_ring_lock, flags); - resp = &up->usb_ring_base-> - ring[MASK_USBIF_IDX(up->usb_resp_prod)].resp; + resp = RING_GET_RESPONSE(USBIF_RING, usb_ring, usb_ring->rsp_prod_pvt); resp->id = id; resp->operation = op; resp->status = st; @@ -797,7 +797,8 @@ static void make_response(usbif_priv_t * dump_response(resp); - up->usb_ring_base->resp_prod = ++up->usb_resp_prod; + usb_ring->rsp_prod_pvt++; + RING_PUSH_RESPONSES(USBIF_RING, usb_ring); spin_unlock_irqrestore(&up->usb_ring_lock, flags); /* Kick the relevant domain. */ diff -r d3f0465c034e -r 03c49d1bcd6b linux-2.6.10-xen-sparse/drivers/xen/usbfront/usbfront.c --- a/linux-2.6.10-xen-sparse/drivers/xen/usbfront/usbfront.c Fri Feb 04 02:25:03 2005 +0000 +++ b/linux-2.6.10-xen-sparse/drivers/xen/usbfront/usbfront.c Sat Feb 05 02:12:56 2005 +0000 @@ -119,7 +119,7 @@ static void xhci_drain_ring(void); #define MAX_URB_LOOP 2048 /* Maximum number of linked URB's */ -struct xhci *xhci; +static struct xhci *xhci; enum { USBIF_STATE_CONNECTED = 2, USBIF_STATE_DISCONNECTED = 1, @@ -128,10 +128,60 @@ enum { USBIF_STATE_CONNECTED = 2, static int awaiting_reset = 0; +#ifdef DEBUG + +static void dump_urb(struct urb *urb) +{ + printk(KERN_DEBUG "dumping urb @ %p\n" + " hcpriv = %p\n" + " next = %p\n" + " dev = %p\n" + " pipe = 0x%lx\n" + " status = %d\n" + " transfer_flags = 0x%lx\n" + " transfer_buffer = %p\n" + " transfer_buffer_length = %d\n" + " actual_length = %d\n" + " bandwidth = %d\n" + " setup_packet = %p\n", + urb, urb->hcpriv, urb->next, urb->dev, urb->pipe, urb->status, + urb->transfer_flags, urb->transfer_buffer, urb->transfer_buffer_length, + urb->actual_length, urb->bandwidth, urb->setup_packet); + if ( urb->setup_packet != NULL ) + printk(KERN_DEBUG + "setup = { 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x }\n", + urb->setup_packet[0], urb->setup_packet[1], urb->setup_packet[2], urb->setup_packet[3], + urb->setup_packet[4], urb->setup_packet[5], urb->setup_packet[6], urb->setup_packet[7]); + printk(KERN_DEBUG "complete = %p\n" + "interval = %d\n", urb->complete, urb->interval); + +} + +static void xhci_show_resp(usbif_response_t *r) +{ + printk(KERN_DEBUG "dumping response @ %p\n" + " id=0x%lx\n" + " op=0x%x\n" + " data=0x%x\n" + " status=0x%x\n" + " length=0x%lx\n", + r->id, r->operation, r->data, r->status, r->length); +} + +#define DPRINK(...) printk(KERN_DEBUG __VA_ARGS__) + +#else /* DEBUG */ + +#define dump_urb(blah) ((void)0) +#define xhci_show_resp(blah) ((void)0) +#define DPRINTK(blah,...) ((void)0) + +#endif /* DEBUG */ + /** * xhci_construct_isoc - add isochronous information to a request */ -int xhci_construct_isoc(usbif_request_t *req, struct urb *urb) +static int xhci_construct_isoc(usbif_request_t *req, struct urb *urb) { usbif_iso_t *schedule; int i; @@ -155,56 +205,28 @@ int xhci_construct_isoc(usbif_request_t return 0; } -#define USBIF_RING_FULL ((xhci->usbif->req_prod - xhci->usb_resp_cons) == USBIF_RING_SIZE) - -static void dump_urb(struct urb *urb) -{ - printk("dumping urb @ %p\n", urb); - - printk("hcpriv = %p\n", urb->hcpriv); - printk("next = %p\n", urb->next); - printk("dev = %p\n", urb->dev); - printk("pipe = 0x%lx\n", urb->pipe); - printk("status = %d\n", urb->status); - printk("transfer_flags = 0x%lx\n", urb->transfer_flags); - printk("transfer_buffer = %p\n", urb->transfer_buffer); - printk("transfer_buffer_length = %d\n", urb->transfer_buffer_length); - printk("actual_length = %d\n", urb->actual_length); - printk("bandwidth = %d\n", urb->bandwidth); - printk("setup_packet = %p\n", urb->setup_packet); - if ( urb->setup_packet != NULL ) - printk("setup = { 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", - urb->setup_packet[0], urb->setup_packet[1], urb->setup_packet[2], urb->setup_packet[3], - urb->setup_packet[4], urb->setup_packet[5], urb->setup_packet[6], urb->setup_packet[7]); - printk("complete = %p\n", urb->complete); - printk("interval = %d\n", urb->interval); - -} - - -static int -xhci_queue_req(struct urb *urb) +static int xhci_queue_req(struct urb *urb) { usbif_request_t *req; - usbif_t *usbif = xhci->usbif; + usbif_front_ring_t *usb_ring = &xhci->usb_ring; -#if 0 - printk("usbif = %p, req_prod = %d (@ 0x%lx), resp_prod = %d, resp_cons = %d\n", +#if DEBUG + printk(KERN_DEBUG + "usbif = %p, req_prod = %d (@ 0x%lx), resp_prod = %d, resp_cons = %d\n", usbif, usbif->req_prod, virt_to_machine(&usbif->req_prod), usbif->resp_prod, xhci->usb_resp_cons); #endif -/* printk("Usbif_priv %p, want IO at 0x%lx\n", urb->hcpriv, virt_to_machine(urb->transfer_buffer)); */ - - if ( USBIF_RING_FULL ) + if ( RING_FULL(USBIF_RING, usb_ring) ) { - printk("xhci_queue_req(): USB ring full, not queuing request\n"); + printk(KERN_WARNING + "xhci_queue_req(): USB ring full, not queuing request\n"); return -ENOBUFS; } /* Stick something in the shared communications ring. */ - req = &usbif->ring[MASK_USBIF_IDX(usbif->req_prod)].req; + req = RING_GET_REQUEST(USBIF_RING, usb_ring, usb_ring->req_prod_pvt); req->operation = USBIF_OP_IO; req->port = 0; /* We don't care what the port is. */ @@ -232,37 +254,38 @@ xhci_queue_req(struct urb *urb) else memset(req->setup, 0, 8); - wmb(); - - usbif->req_prod++; + usb_ring->req_prod_pvt++; + RING_PUSH_REQUESTS(USBIF_RING, usb_ring); notify_via_evtchn(xhci->evtchn); - // dump_urb(urb); + DPRINTK("Queued request for an URB.\n"); + dump_urb(urb); return -EINPROGRESS; } -static inline usbif_request_t * -xhci_queue_probe(usbif_vdev_t port) +static inline usbif_request_t *xhci_queue_probe(usbif_vdev_t port) { usbif_request_t *req; - usbif_t *usbif = xhci->usbif; + usbif_front_ring_t *usb_ring = &xhci->usb_ring; -#if 0 - printk("queuing probe: req_prod = %d (@ 0x%lx), resp_prod = %d, resp_cons = %d\n", +#if DEBUG + printk(KERN_DEBUG + "queuing probe: req_prod = %d (@ 0x%lx), resp_prod = %d, resp_cons = %d\n", usbif->req_prod, virt_to_machine(&usbif->req_prod), usbif->resp_prod, xhci->usb_resp_cons); #endif - if ( USBIF_RING_FULL ) + if ( RING_FULL(USBIF_RING, usb_ring) ) { - printk("xhci_queue_probe(): USB ring full, not queuing request\n"); + printk(KERN_WARNING + "xhci_queue_probe(): USB ring full, not queuing request\n"); return NULL; } /* Stick something in the shared communications ring. */ - req = &usbif->ring[MASK_USBIF_IDX(usbif->req_prod)].req; + req = RING_GET_REQUEST(USBIF_RING, usb_ring, usb_ring->req_prod_pvt); req->operation = USBIF_OP_PROBE; req->port = port; @@ -277,34 +300,31 @@ xhci_queue_probe(usbif_vdev_t port) req->endpoint = 0; req->speed = 0; - wmb(); - - usbif->req_prod++; + usb_ring->req_prod_pvt++; + RING_PUSH_REQUESTS(USBIF_RING, usb_ring); notify_via_evtchn(xhci->evtchn); return req; } -static int -xhci_port_reset(usbif_vdev_t port) +static int xhci_port_reset(usbif_vdev_t port) { usbif_request_t *req; - usbif_t *usbif = xhci->usbif; + usbif_front_ring_t *usb_ring = &xhci->usb_ring; /* We only reset one port at a time, so we only need one variable per * hub. */ awaiting_reset = 1; /* Stick something in the shared communications ring. */ - req = &usbif->ring[MASK_USBIF_IDX(usbif->req_prod)].req; + req = RING_GET_REQUEST(USBIF_RING, usb_ring, usb_ring->req_prod_pvt); req->operation = USBIF_OP_RESET; req->port = port; - wmb(); - - usbif->req_prod++; + usb_ring->req_prod_pvt++; + RING_PUSH_REQUESTS(USBIF_RING, usb_ring); notify_via_evtchn(xhci->evtchn); @@ -317,12 +337,6 @@ xhci_port_reset(usbif_vdev_t port) return awaiting_reset; } -static void xhci_show_resp(usbif_response_t *r) -{ - printk("id=0x%lx, op=0x%x, data=0x%x, status=0x%x, length=0x%lx\n", - r->id, r->operation, r->data, r->status, r->length); -} - /* * Only the USB core should call xhci_alloc_dev and xhci_free_dev @@ -457,10 +471,8 @@ static int xhci_submit_urb(struct urb *u struct urb *eurb; int bustime; -#if 0 - printk("submitting urb @ %p for dev @ %p, devnum = %d path %s\n", - urb, urb->dev, urb->dev->devnum, urb->dev->devpath); -#endif + DPRINTK("URB submitted to XHCI driver.\n"); + dump_urb(urb); if (!urb) return -EINVAL; @@ -471,12 +483,7 @@ static int xhci_submit_urb(struct urb *u } if ( urb->dev->devpath == NULL ) - { - printk("BARF!\n"); BUG(); - } - - usb_inc_dev_use(urb->dev); @@ -517,10 +524,6 @@ static int xhci_submit_urb(struct urb *u goto out; } - if ( usb_pipedevice(urb->pipe) == 1 ) - printk("dev = %p, dev->path = %s, rh.dev = %p, rh.dev.devnum = %d rh.dev->path = %s!\n", - urb->dev, urb->dev->devpath, xhci->rh.dev, xhci->rh.dev->devnum, xhci->rh.dev->devpath); - switch (usb_pipetype(urb->pipe)) { case PIPE_CONTROL: ret = xhci_queue_req(urb); @@ -768,7 +771,7 @@ static int xhci_unlink_urb(struct urb *u } -struct usb_operations xhci_device_operations = { +static struct usb_operations xhci_device_operations = { .allocate = xhci_alloc_dev, .deallocate = xhci_free_dev, /* It doesn't look like any drivers actually care what the frame number @@ -1094,7 +1097,6 @@ static int rh_submit_urb(struct urb *urb } break; case RH_SET_ADDRESS: - printk("setting root hub device to %d\n", wValue); xhci->rh.devnum = wValue; OK(0); case RH_GET_DESCRIPTOR: @@ -1266,14 +1268,14 @@ static void xhci_finish_completion(void) spin_unlock_irqrestore(&xhci->complete_list_lock, flags); } -void receive_usb_reset(usbif_response_t *resp) +static void receive_usb_reset(usbif_response_t *resp) { awaiting_reset = resp->status; rmb(); } -void receive_usb_probe(usbif_response_t *resp) +static void receive_usb_probe(usbif_response_t *resp) { spin_lock(&xhci->rh.port_state_lock); @@ -1281,8 +1283,6 @@ void receive_usb_probe(usbif_response_t { if ( resp->status == 1 ) { -/* printk("hey hey, there's a device on port %d\n", resp->data); */ - /* If theres a device there and there wasn't one before there must * have been a connection status change. */ if( xhci->rh.ports[resp->data].cs == 0 ) @@ -1290,20 +1290,19 @@ void receive_usb_probe(usbif_response_t xhci->rh.ports[resp->data].cs = 1; xhci->rh.ports[resp->data].ccs = 1; xhci->rh.ports[resp->data].cs_chg = 1; -/* printk("Look at device on port %d that wasn't there before\n", resp->data); */ } } else - printk("receive_usb_probe(): unexpected status %d for port %d\n", + printk(KERN_WARNING "receive_usb_probe(): unexpected status %d for port %d\n", resp->status, resp->data); } else if ( resp->status < 0) - printk("receive_usb_probe(): got error status %d\n", resp->status); + printk(KERN_WARNING "receive_usb_probe(): got error status %d\n", resp->status); spin_unlock(&xhci->rh.port_state_lock); } -void receive_usb_io(usbif_response_t *resp) +static void receive_usb_io(usbif_response_t *resp) { struct urb_priv *urbp = (struct urb_priv *)resp->id; struct urb *urb = urbp->urb; @@ -1333,33 +1332,25 @@ void receive_usb_io(usbif_response_t *re static void xhci_drain_ring(void) { struct list_head *tmp, *head; - usbif_t *usb_ring = xhci->usbif; + usbif_front_ring_t *usb_ring = &xhci->usb_ring; usbif_response_t *resp; - USBIF_RING_IDX i, rp; + RING_IDX i, rp; /* Walk the ring here to get responses, updating URBs to show what * completed. */ - rp = usb_ring->resp_prod; + rp = usb_ring->sring->rsp_prod; rmb(); /* Ensure we see queued requests up to 'rp'. */ /* Take items off the comms ring, taking care not to overflow. */ - for ( i = xhci->usb_resp_cons; - (i != rp) && ((i-usb_ring->req_prod) != USBIF_RING_SIZE); - i++ ) + for ( i = usb_ring->rsp_cons; i != rp; i++ ) { - resp = &usb_ring->ring[MASK_USBIF_IDX(i)].resp; + resp = RING_GET_RESPONSE(USBIF_RING, usb_ring, i); /* May need to deal with batching and with putting a ceiling on the number dispatched for performance and anti-dos reasons */ -#if 0 - printk("usbfront: Processing response:\n"); - printk(" id = 0x%x\n", resp->id); - printk(" op = %d\n", resp->operation); - printk(" status = %d\n", resp->status); - printk(" length = %d\n", resp->length); -#endif + xhci_show_resp(resp); switch ( resp->operation ) { @@ -1376,13 +1367,14 @@ static void xhci_drain_ring(void) break; default: - printk("error: unknown USB io operation response [%d]\n", - usb_ring->ring[i].req.operation); + printk(KERN_WARNING + "error: unknown USB io operation response [%d]\n", + resp->operation); break; } } - xhci->usb_resp_cons = i; + usb_ring->rsp_cons = i; /* Walk the list of pending URB's to see which ones completed and do * callbacks, etc. */ @@ -1414,22 +1406,6 @@ static void free_xhci(struct xhci *xhci) kfree(xhci); } -/* /\* */ -/* * De-allocate all resources.. */ -/* *\/ */ -/* static void release_xhci(struct xhci *xhci) */ -/* { */ -/* if (xhci->irq >= 0) { */ -/* free_irq(xhci->irq, xhci); */ -/* xhci->irq = -1; */ -/* } */ - -/* /\* Get the ring back from the backend domain. Then free it. Hmmmm. */ -/* * Lets ignore this for now - not particularly useful. *\/ */ - -/* free_xhci(xhci); */ -/* } */ - /** * Initialise a new virtual root hub for a new USB device channel. */ @@ -1500,10 +1476,6 @@ static int alloc_xhci(void) /* * error exits: */ -err_start_root_hub: - free_irq(xhci->irq, xhci); - xhci->irq = -1; - err_alloc_root_hub: usb_free_bus(xhci->bus); xhci->bus = NULL; @@ -1520,7 +1492,7 @@ static void usbif_status_change(usbif_fe ctrl_msg_t cmsg; usbif_fe_interface_connect_t up; long rc; - usbif_t *usbif; + usbif_sring_t *sring; switch ( status->status ) { @@ -1540,15 +1512,16 @@ static void usbif_status_change(usbif_fe } /* Move from CLOSED to DISCONNECTED state. */ - xhci->usbif = usbif = (usbif_t *)__get_free_page(GFP_KERNEL); - usbif->req_prod = usbif->resp_prod = 0; + sring = (usbif_sring_t *)__get_free_page(GFP_KERNEL); + SHARED_RING_INIT(USBIF_RING, sring); + FRONT_RING_INIT(USBIF_RING, &xhci->usb_ring, sring); xhci->state = USBIF_STATE_DISCONNECTED; /* Construct an interface-CONNECT message for the domain controller. */ cmsg.type = CMSG_USBIF_FE; cmsg.subtype = CMSG_USBIF_FE_INTERFACE_CONNECT; cmsg.length = sizeof(usbif_fe_interface_connect_t); - up.shmem_frame = virt_to_machine(usbif) >> PAGE_SHIFT; + up.shmem_frame = virt_to_machine(sring) >> PAGE_SHIFT; memcpy(cmsg.msg, &up, sizeof(up)); /* Tell the controller to bring up the interface. */ @@ -1571,8 +1544,6 @@ static void usbif_status_change(usbif_fe xhci->rh.ports = kmalloc (sizeof(xhci_port_t) * xhci->rh.numports, GFP_KERNEL); memset(xhci->rh.ports, 0, sizeof(xhci_port_t) * xhci->rh.numports); - printk("rh.dev @ %p\n", xhci->rh.dev); - usb_connect(xhci->rh.dev); if (usb_new_device(xhci->rh.dev) != 0) { @@ -1589,8 +1560,8 @@ static void usbif_status_change(usbif_fe SA_SAMPLE_RANDOM, "usbif", xhci)) ) printk(KERN_ALERT"usbfront request_irq failed (%ld)\n",rc); - printk(KERN_INFO __FILE__ ": USB XHCI: SHM at %p (0x%lx), EVTCHN %d IRQ %d\n", - xhci->usbif, virt_to_machine(xhci->usbif), xhci->evtchn, xhci->irq); + DPRINTK(KERN_INFO __FILE__ ": USB XHCI: SHM at %p (0x%lx), EVTCHN %d IRQ %d\n", + xhci->usb_ring.sring, virt_to_machine(xhci->usbif), xhci->evtchn, xhci->irq); xhci->state = USBIF_STATE_CONNECTED; @@ -1685,7 +1656,7 @@ static int __init xhci_hcd_init(void) } if (xhci->state != USBIF_STATE_CONNECTED) - printk(KERN_INFO "Timeout connecting USB frontend driver!\n"); + printk(KERN_WARNING "Timeout connecting USB frontend driver!\n"); return 0; @@ -1702,7 +1673,7 @@ errbuf_failed: static void __exit xhci_hcd_cleanup(void) { if (kmem_cache_destroy(xhci_up_cachep)) - printk(KERN_INFO "xhci: not all urb_priv's were freed\n"); + printk(KERN_WARNING "xhci: not all urb_priv's were freed\n"); // release_xhci(); do some calls here diff -r d3f0465c034e -r 03c49d1bcd6b linux-2.6.10-xen-sparse/drivers/xen/usbfront/xhci.h --- a/linux-2.6.10-xen-sparse/drivers/xen/usbfront/xhci.h Fri Feb 04 02:25:03 2005 +0000 +++ b/linux-2.6.10-xen-sparse/drivers/xen/usbfront/xhci.h Sat Feb 05 02:12:56 2005 +0000 @@ -104,7 +104,7 @@ struct xhci { spinlock_t response_lock; - usbif_t *usbif; + usbif_front_ring_t usb_ring; int usb_resp_cons; }; diff -r d3f0465c034e -r 03c49d1bcd6b xen/include/public/io/usbif.h --- a/xen/include/public/io/usbif.h Fri Feb 04 02:25:03 2005 +0000 +++ b/xen/include/public/io/usbif.h Sat Feb 05 02:12:56 2005 +0000 @@ -12,17 +12,10 @@ #define usbif_vdev_t u16 #define usbif_sector_t u64 -#define USBIF_OP_IO 0 +#define USBIF_OP_IO 0 /* Request IO to a device */ #define USBIF_OP_PROBE 1 /* Is there a device on this port? */ #define USBIF_OP_RESET 2 /* Reset a virtual USB port. */ -/* NB. Ring size must be small enough for sizeof(usbif_ring_t) <= PAGE_SIZE. */ -#define USBIF_RING_SIZE 64 - -/* XXX this does not want to be here! it really ought to be dynamic but it can - * live here for now */ -#define NUM_PORTS 1 - typedef struct { unsigned long id; /* 0: private guest value, echoed in resp */ u8 operation; /* 4: USBIF_OP_??? */ @@ -44,6 +37,7 @@ typedef struct { unsigned long num_iso; /* 34 : length of iso schedule */ unsigned long timeout; /* 38: timeout in ms */ } PACKED usbif_request_t; /* 42 */ + /* Data we need to pass: * - Transparently handle short packets or complain at us? */ @@ -60,46 +54,8 @@ typedef struct { #define USBIF_RSP_ERROR -1 /* non-specific 'error' */ #define USBIF_RSP_OKAY 0 /* non-specific 'okay' */ -/* - * We use a special capitalised type name because it is _essential_ that all - * arithmetic on indexes is done on an integer type of the correct size. - */ -typedef u32 USBIF_RING_IDX; - -/* - * Ring indexes are 'free running'. That is, they are not stored modulo the - * size of the ring buffer. The following macro converts a free-running counter - * into a value that can directly index a ring-buffer array. - */ -#define MASK_USBIF_IDX(_i) ((_i)&(USBIF_RING_SIZE-1)) - -typedef struct { - USBIF_RING_IDX req_prod; /* 0: Request producer. Updated by front-end. */ - USBIF_RING_IDX resp_prod; /* 4: Response producer. Updated by back-end. */ - - union { /* 8 */ - usbif_request_t req; - usbif_response_t resp; - } PACKED ring[USBIF_RING_SIZE]; -} PACKED usbif_t; - - - -/* - * USBIF_OP_PROBE: - * The request format for a probe request is constrained as follows: - * @operation == USBIF_OP_PROBE - * @nr_segments == size of probe buffer in pages - * @device == unused (zero) - * @id == any value (echoed in response message) - * @sector_num == unused (zero) - * @frame_and_sects == list of page-sized buffers. - * (i.e., @first_sect == 0, @last_sect == 7). - * - * The response is a list of vdisk_t elements copied into the out-of-band - * probe buffer. On success the response status field contains the number - * of vdisk_t elements. - */ +#define USBIF_RING RING_PARAMS(usbif_request_t, usbif_response_t, PAGE_SIZE) +DEFINE_RING_TYPES(usbif, USBIF_RING); typedef struct { unsigned long length; /* IN = expected, OUT = actual */