usb: dwc3: gadget: keep track of allocated and queued reqs
authorFelipe Balbi <felipe.balbi@linux.intel.com>
Mon, 30 May 2016 10:34:58 +0000 (13:34 +0300)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Mon, 20 Jun 2016 09:32:49 +0000 (12:32 +0300)
We will be using this information to change how we
figure out when we need LST bit. For now, just
update our counters.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/dwc3/core.h
drivers/usb/dwc3/gadget.c
drivers/usb/dwc3/trace.h

index dcdba14e10f0b4a814377093964d0a477ed2f21b..45d6de5107c733ff1ba2d9df69e3147b45c9a493 100644 (file)
@@ -497,6 +497,8 @@ struct dwc3_event_buffer {
  * @type: set to bmAttributes & USB_ENDPOINT_XFERTYPE_MASK
  * @resource_index: Resource transfer index
  * @interval: the interval on which the ISOC transfer is started
+ * @allocated_requests: number of requests allocated
+ * @queued_requests: number of requests queued for transfer
  * @name: a human readable name e.g. ep1out-bulk
  * @direction: true for TX, false for RX
  * @stream_capable: true when streams are enabled
@@ -541,6 +543,8 @@ struct dwc3_ep {
        u8                      number;
        u8                      type;
        u8                      resource_index;
+       u32                     allocated_requests;
+       u32                     queued_requests;
        u32                     interval;
 
        char                    name[20];
index e7e493b4508416971439bf66d5fd1fc5a478a1fb..1cd4b50cf35bfaa7a5f983fc9400439b7aacc943 100644 (file)
@@ -741,6 +741,8 @@ static struct usb_request *dwc3_gadget_ep_alloc_request(struct usb_ep *ep,
        req->epnum      = dep->number;
        req->dep        = dep;
 
+       dep->allocated_requests++;
+
        trace_dwc3_alloc_request(req);
 
        return &req->request;
@@ -750,7 +752,9 @@ static void dwc3_gadget_ep_free_request(struct usb_ep *ep,
                struct usb_request *request)
 {
        struct dwc3_request             *req = to_dwc3_request(request);
+       struct dwc3_ep                  *dep = to_dwc3_ep(ep);
 
+       dep->allocated_requests--;
        trace_dwc3_free_request(req);
        kfree(req);
 }
@@ -831,6 +835,8 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep,
 
        trb->ctrl |= DWC3_TRB_CTRL_HWO;
 
+       dep->queued_requests++;
+
        trace_dwc3_prepare_trb(dep, trb);
 }
 
@@ -1936,6 +1942,7 @@ static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep,
        unsigned int            s_pkt = 0;
        unsigned int            trb_status;
 
+       dep->queued_requests--;
        trace_dwc3_complete_trb(dep, trb);
 
        if ((trb->ctrl & DWC3_TRB_CTRL_HWO) && status != -ESHUTDOWN)
index cafd69fc7eb800d3ffc0c2fb94d002cde74e87b0..d24cefd191b558e8452beab674130b7ff49b893d 100644 (file)
@@ -231,6 +231,8 @@ DECLARE_EVENT_CLASS(dwc3_log_trb,
        TP_STRUCT__entry(
                __dynamic_array(char, name, DWC3_MSG_MAX)
                __field(struct dwc3_trb *, trb)
+               __field(u32, allocated)
+               __field(u32, queued)
                __field(u32, bpl)
                __field(u32, bph)
                __field(u32, size)
@@ -239,13 +241,16 @@ DECLARE_EVENT_CLASS(dwc3_log_trb,
        TP_fast_assign(
                snprintf(__get_str(name), DWC3_MSG_MAX, "%s", dep->name);
                __entry->trb = trb;
+               __entry->allocated = dep->allocated_requests;
+               __entry->queued = dep->queued_requests;
                __entry->bpl = trb->bpl;
                __entry->bph = trb->bph;
                __entry->size = trb->size;
                __entry->ctrl = trb->ctrl;
        ),
-       TP_printk("%s: trb %p buf %08x%08x size %d ctrl %08x (%c%c%c%c:%c%c:%s)",
-               __get_str(name), __entry->trb, __entry->bph, __entry->bpl,
+       TP_printk("%s: %d/%d trb %p buf %08x%08x size %d ctrl %08x (%c%c%c%c:%c%c:%s)",
+               __get_str(name), __entry->queued, __entry->allocated,
+               __entry->trb, __entry->bph, __entry->bpl,
                __entry->size, __entry->ctrl,
                __entry->ctrl & DWC3_TRB_CTRL_HWO ? 'H' : 'h',
                __entry->ctrl & DWC3_TRB_CTRL_LST ? 'L' : 'l',