diff options
Diffstat (limited to 'drivers/usb/musb/musb_gadget.c')
-rw-r--r-- | drivers/usb/musb/musb_gadget.c | 122 |
1 files changed, 56 insertions, 66 deletions
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index af2a3a7addf9..6d1e975e9605 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -44,6 +44,7 @@ #include <linux/slab.h> #include "musb_core.h" +#include "musb_trace.h" /* ----------------------------------------------------------------------- */ @@ -167,15 +168,7 @@ __acquires(ep->musb->lock) if (!dma_mapping_error(&musb->g.dev, request->dma)) unmap_dma_buffer(req, musb); - if (request->status == 0) - dev_dbg(musb->controller, "%s done request %p, %d/%d\n", - ep->end_point.name, request, - req->request.actual, req->request.length); - else - dev_dbg(musb->controller, "%s request %p, %d/%d fault %d\n", - ep->end_point.name, request, - req->request.actual, req->request.length, - request->status); + trace_musb_req_gb(req); usb_gadget_giveback_request(&req->ep->end_point, &req->request); spin_lock(&musb->lock); ep->busy = busy; @@ -217,8 +210,7 @@ static void nuke(struct musb_ep *ep, const int status) } value = c->channel_abort(ep->dma); - dev_dbg(musb->controller, "%s: abort DMA --> %d\n", - ep->name, value); + musb_dbg(musb, "%s: abort DMA --> %d", ep->name, value); c->channel_release(ep->dma); ep->dma = NULL; } @@ -266,14 +258,14 @@ static void txstate(struct musb *musb, struct musb_request *req) /* Check if EP is disabled */ if (!musb_ep->desc) { - dev_dbg(musb->controller, "ep:%s disabled - ignore request\n", + musb_dbg(musb, "ep:%s disabled - ignore request", musb_ep->end_point.name); return; } /* we shouldn't get here while DMA is active ... but we do ... */ if (dma_channel_status(musb_ep->dma) == MUSB_DMA_STATUS_BUSY) { - dev_dbg(musb->controller, "dma pending...\n"); + musb_dbg(musb, "dma pending..."); return; } @@ -285,18 +277,18 @@ static void txstate(struct musb *musb, struct musb_request *req) (int)(request->length - request->actual)); if (csr & MUSB_TXCSR_TXPKTRDY) { - dev_dbg(musb->controller, "%s old packet still ready , txcsr %03x\n", + musb_dbg(musb, "%s old packet still ready , txcsr %03x", musb_ep->end_point.name, csr); return; } if (csr & MUSB_TXCSR_P_SENDSTALL) { - dev_dbg(musb->controller, "%s stalling, txcsr %03x\n", + musb_dbg(musb, "%s stalling, txcsr %03x", musb_ep->end_point.name, csr); return; } - dev_dbg(musb->controller, "hw_ep%d, maxpacket %d, fifo count %d, txcsr %03x\n", + musb_dbg(musb, "hw_ep%d, maxpacket %d, fifo count %d, txcsr %03x", epnum, musb_ep->packet_sz, fifo_count, csr); @@ -424,7 +416,7 @@ static void txstate(struct musb *musb, struct musb_request *req) } /* host may already have the data when this message shows... */ - dev_dbg(musb->controller, "%s TX/IN %s len %d/%d, txcsr %04x, fifo %d/%d\n", + musb_dbg(musb, "%s TX/IN %s len %d/%d, txcsr %04x, fifo %d/%d", musb_ep->end_point.name, use_dma ? "dma" : "pio", request->actual, request->length, musb_readw(epio, MUSB_TXCSR), @@ -450,8 +442,9 @@ void musb_g_tx(struct musb *musb, u8 epnum) req = next_request(musb_ep); request = &req->request; + trace_musb_req_tx(req); csr = musb_readw(epio, MUSB_TXCSR); - dev_dbg(musb->controller, "<== %s, txcsr %04x\n", musb_ep->end_point.name, csr); + musb_dbg(musb, "<== %s, txcsr %04x", musb_ep->end_point.name, csr); dma = is_dma_capable() ? musb_ep->dma : NULL; @@ -480,7 +473,7 @@ void musb_g_tx(struct musb *musb, u8 epnum) * SHOULD NOT HAPPEN... has with CPPI though, after * changing SENDSTALL (and other cases); harmless? */ - dev_dbg(musb->controller, "%s dma still busy?\n", musb_ep->end_point.name); + musb_dbg(musb, "%s dma still busy?", musb_ep->end_point.name); return; } @@ -497,7 +490,7 @@ void musb_g_tx(struct musb *musb, u8 epnum) /* Ensure writebuffer is empty. */ csr = musb_readw(epio, MUSB_TXCSR); request->actual += musb_ep->dma->actual_len; - dev_dbg(musb->controller, "TXCSR%d %04x, DMA off, len %zu, req %p\n", + musb_dbg(musb, "TXCSR%d %04x, DMA off, len %zu, req %p", epnum, csr, musb_ep->dma->actual_len, request); } @@ -524,7 +517,6 @@ void musb_g_tx(struct musb *musb, u8 epnum) if (csr & MUSB_TXCSR_TXPKTRDY) return; - dev_dbg(musb->controller, "sending zero pkt\n"); musb_writew(epio, MUSB_TXCSR, MUSB_TXCSR_MODE | MUSB_TXCSR_TXPKTRDY); request->zero = 0; @@ -543,7 +535,7 @@ void musb_g_tx(struct musb *musb, u8 epnum) musb_ep_select(mbase, epnum); req = musb_ep->desc ? next_request(musb_ep) : NULL; if (!req) { - dev_dbg(musb->controller, "%s idle now\n", + musb_dbg(musb, "%s idle now", musb_ep->end_point.name); return; } @@ -579,19 +571,19 @@ static void rxstate(struct musb *musb, struct musb_request *req) /* Check if EP is disabled */ if (!musb_ep->desc) { - dev_dbg(musb->controller, "ep:%s disabled - ignore request\n", + musb_dbg(musb, "ep:%s disabled - ignore request", musb_ep->end_point.name); return; } /* We shouldn't get here while DMA is active, but we do... */ if (dma_channel_status(musb_ep->dma) == MUSB_DMA_STATUS_BUSY) { - dev_dbg(musb->controller, "DMA pending...\n"); + musb_dbg(musb, "DMA pending..."); return; } if (csr & MUSB_RXCSR_P_SENDSTALL) { - dev_dbg(musb->controller, "%s stalling, RXCSR %04x\n", + musb_dbg(musb, "%s stalling, RXCSR %04x", musb_ep->end_point.name, csr); return; } @@ -766,7 +758,7 @@ static void rxstate(struct musb *musb, struct musb_request *req) } len = request->length - request->actual; - dev_dbg(musb->controller, "%s OUT/RX pio fifo %d/%d, maxpacket %d\n", + musb_dbg(musb, "%s OUT/RX pio fifo %d/%d, maxpacket %d", musb_ep->end_point.name, fifo_count, len, musb_ep->packet_sz); @@ -849,12 +841,13 @@ void musb_g_rx(struct musb *musb, u8 epnum) if (!req) return; + trace_musb_req_rx(req); request = &req->request; csr = musb_readw(epio, MUSB_RXCSR); dma = is_dma_capable() ? musb_ep->dma : NULL; - dev_dbg(musb->controller, "<== %s, rxcsr %04x%s %p\n", musb_ep->end_point.name, + musb_dbg(musb, "<== %s, rxcsr %04x%s %p", musb_ep->end_point.name, csr, dma ? " (dma)" : "", request); if (csr & MUSB_RXCSR_P_SENTSTALL) { @@ -869,18 +862,18 @@ void musb_g_rx(struct musb *musb, u8 epnum) csr &= ~MUSB_RXCSR_P_OVERRUN; musb_writew(epio, MUSB_RXCSR, csr); - dev_dbg(musb->controller, "%s iso overrun on %p\n", musb_ep->name, request); + musb_dbg(musb, "%s iso overrun on %p", musb_ep->name, request); if (request->status == -EINPROGRESS) request->status = -EOVERFLOW; } if (csr & MUSB_RXCSR_INCOMPRX) { /* REVISIT not necessarily an error */ - dev_dbg(musb->controller, "%s, incomprx\n", musb_ep->end_point.name); + musb_dbg(musb, "%s, incomprx", musb_ep->end_point.name); } if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) { /* "should not happen"; likely RXPKTRDY pending for DMA */ - dev_dbg(musb->controller, "%s busy, csr %04x\n", + musb_dbg(musb, "%s busy, csr %04x", musb_ep->end_point.name, csr); return; } @@ -894,11 +887,6 @@ void musb_g_rx(struct musb *musb, u8 epnum) request->actual += musb_ep->dma->actual_len; - dev_dbg(musb->controller, "RXCSR%d %04x, dma off, %04x, len %zu, req %p\n", - epnum, csr, - musb_readw(epio, MUSB_RXCSR), - musb_ep->dma->actual_len, request); - #if defined(CONFIG_USB_INVENTRA_DMA) || defined(CONFIG_USB_TUSB_OMAP_DMA) || \ defined(CONFIG_USB_UX500_DMA) /* Autoclear doesn't clear RxPktRdy for short packets */ @@ -996,7 +984,7 @@ static int musb_gadget_enable(struct usb_ep *ep, ok = musb->hb_iso_rx; if (!ok) { - dev_dbg(musb->controller, "no support for high bandwidth ISO\n"); + musb_dbg(musb, "no support for high bandwidth ISO"); goto fail; } musb_ep->hb_mult = (tmp >> 11) & 3; @@ -1019,7 +1007,7 @@ static int musb_gadget_enable(struct usb_ep *ep, goto fail; if (tmp > hw_ep->max_packet_sz_tx) { - dev_dbg(musb->controller, "packet size beyond hardware FIFO size\n"); + musb_dbg(musb, "packet size beyond hardware FIFO size"); goto fail; } @@ -1062,7 +1050,7 @@ static int musb_gadget_enable(struct usb_ep *ep, goto fail; if (tmp > hw_ep->max_packet_sz_rx) { - dev_dbg(musb->controller, "packet size beyond hardware FIFO size\n"); + musb_dbg(musb, "packet size beyond hardware FIFO size"); goto fail; } @@ -1174,7 +1162,7 @@ static int musb_gadget_disable(struct usb_ep *ep) spin_unlock_irqrestore(&(musb->lock), flags); - dev_dbg(musb->controller, "%s\n", musb_ep->end_point.name); + musb_dbg(musb, "%s", musb_ep->end_point.name); return status; } @@ -1186,19 +1174,17 @@ static int musb_gadget_disable(struct usb_ep *ep) struct usb_request *musb_alloc_request(struct usb_ep *ep, gfp_t gfp_flags) { struct musb_ep *musb_ep = to_musb_ep(ep); - struct musb *musb = musb_ep->musb; struct musb_request *request = NULL; request = kzalloc(sizeof *request, gfp_flags); - if (!request) { - dev_dbg(musb->controller, "not enough memory\n"); + if (!request) return NULL; - } request->request.dma = DMA_ADDR_INVALID; request->epnum = musb_ep->current_epnum; request->ep = musb_ep; + trace_musb_req_alloc(request); return &request->request; } @@ -1208,7 +1194,10 @@ struct usb_request *musb_alloc_request(struct usb_ep *ep, gfp_t gfp_flags) */ void musb_free_request(struct usb_ep *ep, struct usb_request *req) { - kfree(to_musb_request(req)); + struct musb_request *request = to_musb_request(req); + + trace_musb_req_free(request); + kfree(request); } static LIST_HEAD(buffers); @@ -1225,10 +1214,7 @@ struct free_record { */ void musb_ep_restart(struct musb *musb, struct musb_request *req) { - dev_dbg(musb->controller, "<== %s request %p len %u on hw_ep%d\n", - req->tx ? "TX/IN" : "RX/OUT", - &req->request, req->request.length, req->epnum); - + trace_musb_req_start(req); musb_ep_select(musb->mregs, req->epnum); if (req->tx) txstate(musb, req); @@ -1259,7 +1245,7 @@ static int musb_gadget_queue(struct usb_ep *ep, struct usb_request *req, if (request->ep != musb_ep) return -EINVAL; - dev_dbg(musb->controller, "<== to %s request=%p\n", ep->name, req); + trace_musb_req_enq(request); /* request is mine now... */ request->request.actual = 0; @@ -1273,7 +1259,7 @@ static int musb_gadget_queue(struct usb_ep *ep, struct usb_request *req, /* don't queue if the ep is down */ if (!musb_ep->desc) { - dev_dbg(musb->controller, "req %p queued to %s while ep %s\n", + musb_dbg(musb, "req %p queued to %s while ep %s", req, ep->name, "disabled"); status = -ESHUTDOWN; unmap_dma_buffer(request, musb); @@ -1301,9 +1287,11 @@ static int musb_gadget_dequeue(struct usb_ep *ep, struct usb_request *request) int status = 0; struct musb *musb = musb_ep->musb; - if (!ep || !request || to_musb_request(request)->ep != musb_ep) + if (!ep || !request || req->ep != musb_ep) return -EINVAL; + trace_musb_req_deq(req); + spin_lock_irqsave(&musb->lock, flags); list_for_each_entry(r, &musb_ep->req_list, list) { @@ -1311,7 +1299,8 @@ static int musb_gadget_dequeue(struct usb_ep *ep, struct usb_request *request) break; } if (r != req) { - dev_dbg(musb->controller, "request %p not queued to %s\n", request, ep->name); + dev_err(musb->controller, "request %p not queued to %s\n", + request, ep->name); status = -EINVAL; goto done; } @@ -1377,7 +1366,7 @@ static int musb_gadget_set_halt(struct usb_ep *ep, int value) request = next_request(musb_ep); if (value) { if (request) { - dev_dbg(musb->controller, "request in progress, cannot halt %s\n", + musb_dbg(musb, "request in progress, cannot halt %s", ep->name); status = -EAGAIN; goto done; @@ -1386,7 +1375,8 @@ static int musb_gadget_set_halt(struct usb_ep *ep, int value) if (musb_ep->is_in) { csr = musb_readw(epio, MUSB_TXCSR); if (csr & MUSB_TXCSR_FIFONOTEMPTY) { - dev_dbg(musb->controller, "FIFO busy, cannot halt %s\n", ep->name); + musb_dbg(musb, "FIFO busy, cannot halt %s", + ep->name); status = -EAGAIN; goto done; } @@ -1395,7 +1385,7 @@ static int musb_gadget_set_halt(struct usb_ep *ep, int value) musb_ep->wedged = 0; /* set/clear the stall and toggle bits */ - dev_dbg(musb->controller, "%s: %s stall\n", ep->name, value ? "set" : "clear"); + musb_dbg(musb, "%s: %s stall", ep->name, value ? "set" : "clear"); if (musb_ep->is_in) { csr = musb_readw(epio, MUSB_TXCSR); csr |= MUSB_TXCSR_P_WZC_BITS @@ -1422,7 +1412,7 @@ static int musb_gadget_set_halt(struct usb_ep *ep, int value) /* maybe start the first request in the queue */ if (!musb_ep->busy && !value && request) { - dev_dbg(musb->controller, "restarting the request\n"); + musb_dbg(musb, "restarting the request"); musb_ep_restart(musb, request); } @@ -1558,7 +1548,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget) case OTG_STATE_B_IDLE: /* Start SRP ... OTG not required. */ devctl = musb_readb(mregs, MUSB_DEVCTL); - dev_dbg(musb->controller, "Sending SRP: devctl: %02x\n", devctl); + musb_dbg(musb, "Sending SRP: devctl: %02x", devctl); devctl |= MUSB_DEVCTL_SESSION; musb_writeb(mregs, MUSB_DEVCTL, devctl); devctl = musb_readb(mregs, MUSB_DEVCTL); @@ -1586,7 +1576,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget) status = 0; goto done; default: - dev_dbg(musb->controller, "Unhandled wake: %s\n", + musb_dbg(musb, "Unhandled wake: %s", usb_otg_state_string(musb->xceiv->otg->state)); goto done; } @@ -1596,7 +1586,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget) power = musb_readb(mregs, MUSB_POWER); power |= MUSB_POWER_RESUME; musb_writeb(mregs, MUSB_POWER, power); - dev_dbg(musb->controller, "issue wakeup\n"); + musb_dbg(musb, "issue wakeup"); /* FIXME do this next chunk in a timer callback, no udelay */ mdelay(2); @@ -1628,7 +1618,7 @@ static void musb_pullup(struct musb *musb, int is_on) /* FIXME if on, HdrcStart; if off, HdrcStop */ - dev_dbg(musb->controller, "gadget D+ pullup %s\n", + musb_dbg(musb, "gadget D+ pullup %s", is_on ? "on" : "off"); musb_writeb(musb->mregs, MUSB_POWER, power); } @@ -1636,7 +1626,7 @@ static void musb_pullup(struct musb *musb, int is_on) #if 0 static int musb_gadget_vbus_session(struct usb_gadget *gadget, int is_active) { - dev_dbg(musb->controller, "<= %s =>\n", __func__); + musb_dbg(musb, "<= %s =>\n", __func__); /* * FIXME iff driver's softconnect flag is set (as it is during probe, @@ -2011,7 +2001,7 @@ void musb_g_suspend(struct musb *musb) u8 devctl; devctl = musb_readb(musb->mregs, MUSB_DEVCTL); - dev_dbg(musb->controller, "devctl %02x\n", devctl); + musb_dbg(musb, "musb_g_suspend: devctl %02x", devctl); switch (musb->xceiv->otg->state) { case OTG_STATE_B_IDLE: @@ -2030,7 +2020,7 @@ void musb_g_suspend(struct musb *musb) /* REVISIT if B_HOST, clear DEVCTL.HOSTREQ; * A_PERIPHERAL may need care too */ - WARNING("unhandled SUSPEND transition (%s)\n", + WARNING("unhandled SUSPEND transition (%s)", usb_otg_state_string(musb->xceiv->otg->state)); } } @@ -2047,7 +2037,7 @@ void musb_g_disconnect(struct musb *musb) void __iomem *mregs = musb->mregs; u8 devctl = musb_readb(mregs, MUSB_DEVCTL); - dev_dbg(musb->controller, "devctl %02x\n", devctl); + musb_dbg(musb, "musb_g_disconnect: devctl %02x", devctl); /* clear HR */ musb_writeb(mregs, MUSB_DEVCTL, devctl & MUSB_DEVCTL_SESSION); @@ -2064,7 +2054,7 @@ void musb_g_disconnect(struct musb *musb) switch (musb->xceiv->otg->state) { default: - dev_dbg(musb->controller, "Unhandled disconnect %s, setting a_idle\n", + musb_dbg(musb, "Unhandled disconnect %s, setting a_idle", usb_otg_state_string(musb->xceiv->otg->state)); musb->xceiv->otg->state = OTG_STATE_A_IDLE; MUSB_HST_MODE(musb); @@ -2094,7 +2084,7 @@ __acquires(musb->lock) u8 devctl = musb_readb(mbase, MUSB_DEVCTL); u8 power; - dev_dbg(musb->controller, "<== %s driver '%s'\n", + musb_dbg(musb, "<== %s driver '%s'", (devctl & MUSB_DEVCTL_BDEVICE) ? "B-Device" : "A-Device", musb->gadget_driver |