25 static inline void debug_urb_submitted(
struct imx21 *
imx21,
struct urb *
urb) {}
28 static inline void debug_urb_unlinked(
struct imx21 *
imx21,
struct urb *
urb) {}
29 static inline void debug_urb_queued_for_etd(
struct imx21 *
imx21,
31 static inline void debug_urb_queued_for_dmem(
struct imx21 *
imx21,
33 static inline void debug_etd_allocated(
struct imx21 *
imx21) {}
34 static inline void debug_etd_freed(
struct imx21 *
imx21) {}
35 static inline void debug_dmem_allocated(
struct imx21 *
imx21,
int size) {}
36 static inline void debug_dmem_freed(
struct imx21 *
imx21,
int size) {}
37 static inline void debug_isoc_submitted(
struct imx21 *
imx21,
39 static inline void debug_isoc_completed(
struct imx21 *
imx21,
47 static const char *dir_labels[] = {
54 static const char *speed_labels[] = {
59 static const char *format_labels[] = {
66 static inline struct debug_stats *stats_for_urb(
struct imx21 *
imx21,
69 return usb_pipeisoc(urb->pipe) ?
70 &imx21->isoc_stats : &imx21->nonisoc_stats;
75 stats_for_urb(imx21, urb)->submitted++;
81 stats_for_urb(imx21, urb)->completed_failed++;
83 stats_for_urb(imx21, urb)->completed_ok++;
86 static void debug_urb_unlinked(
struct imx21 *imx21,
struct urb *urb)
88 stats_for_urb(imx21, urb)->unlinked++;
91 static void debug_urb_queued_for_etd(
struct imx21 *imx21,
struct urb *urb)
93 stats_for_urb(imx21, urb)->queue_etd++;
96 static void debug_urb_queued_for_dmem(
struct imx21 *imx21,
struct urb *urb)
98 stats_for_urb(imx21, urb)->queue_dmem++;
101 static inline void debug_etd_allocated(
struct imx21 *imx21)
103 imx21->etd_usage.maximum =
max(
104 ++(imx21->etd_usage.value),
105 imx21->etd_usage.maximum);
108 static inline void debug_etd_freed(
struct imx21 *imx21)
110 imx21->etd_usage.value--;
113 static inline void debug_dmem_allocated(
struct imx21 *imx21,
int size)
115 imx21->dmem_usage.value +=
size;
116 imx21->dmem_usage.maximum =
max(
117 imx21->dmem_usage.value,
118 imx21->dmem_usage.maximum);
121 static inline void debug_dmem_freed(
struct imx21 *imx21,
int size)
123 imx21->dmem_usage.value -=
size;
127 static void debug_isoc_submitted(
struct imx21 *imx21,
130 struct debug_isoc_trace *
trace = &imx21->isoc_trace[
131 imx21->isoc_trace_index++];
133 imx21->isoc_trace_index %=
ARRAY_SIZE(imx21->isoc_trace);
134 trace->schedule_frame = td->
frame;
135 trace->submit_frame =
frame;
136 trace->request_len = td->
len;
140 static inline void debug_isoc_completed(
struct imx21 *imx21,
143 struct debug_isoc_trace *
trace, *trace_failed;
147 trace = imx21->isoc_trace;
148 for (i = 0; i <
ARRAY_SIZE(imx21->isoc_trace); i++, trace++) {
149 if (trace->td == td) {
150 trace->done_frame =
frame;
151 trace->done_len = len;
160 trace_failed = &imx21->isoc_trace_failed[
161 imx21->isoc_trace_index_failed++];
164 imx21->isoc_trace_failed);
165 *trace_failed = *
trace;
170 static char *format_ep(
struct usb_host_endpoint *ep,
char *
buf,
int bufsize)
173 snprintf(buf, bufsize,
"ep_%02x (type:%02X kaddr:%p)",
174 ep->desc.bEndpointAddress,
175 usb_endpoint_type(&ep->desc),
182 static char *format_etd_dword0(
u32 value,
char *buf,
int bufsize)
185 "addr=%d ep=%d dir=%s speed=%s format=%s halted=%d",
189 speed_labels[(value >>
DW0_SPEED) & 0x01],
195 static int debug_status_show(
struct seq_file *
s,
void *
v)
197 struct imx21 *imx21 = s->
private;
198 int etds_allocated = 0;
199 int etds_sw_busy = 0;
200 int etds_hw_busy = 0;
202 int queued_for_etd = 0;
203 int queued_for_dmem = 0;
204 unsigned int dmem_bytes = 0;
220 if (etd_enable_mask & (1<<i))
225 dmem_bytes += dmem->
size;
235 spin_unlock_irqrestore(&imx21->lock, flags);
239 "ETDs allocated: %
d/%
d (
max=%
d)\
n"
242 "DMEM allocated: %
d/%
d (
max=%
d)\
n"
244 "Queued waiting
for ETD: %
d\
n"
245 "Queued waiting
for DMEM: %
d\
n",
250 dmem_bytes,
DMEM_SIZE, imx21->dmem_usage.maximum,
260 struct imx21 *imx21 = s->private;
272 format_ep(dmem->ep, ep_text,
sizeof(ep_text)));
274 spin_unlock_irqrestore(&imx21->lock, flags);
281 struct imx21 *imx21 = s->private;
290 for (i = 0, etd = imx21->
etd; i < USB_NUM_ETD; i++, etd++) {
294 urb_priv = etd->
urb->hcpriv;
296 state = urb_priv->
state;
310 format_ep(etd->
ep, buf,
sizeof(buf)),
318 for (j = 0; j < 4; j++) {
319 dword = etd_readl(imx21, i, j);
322 format_etd_dword0(dword, buf,
sizeof(buf));
333 "dword %d: submitted=%08X cur=%08X [%s]\n",
335 etd->submitted_dwords[j],
342 spin_unlock_irqrestore(&imx21->
lock, flags);
347 static void debug_statistics_show_one(
struct seq_file *s,
348 const char *
name,
struct debug_stats *
stats)
351 "submitted URBs: %lu\n"
352 "completed OK: %lu\n"
353 "completed failed: %lu\n"
355 "queued for ETD: %lu\n"
356 "queued for DMEM: %lu\n\n",
360 stats->completed_failed,
366 static int debug_statistics_show(
struct seq_file *s,
void *v)
368 struct imx21 *imx21 = s->
private;
373 debug_statistics_show_one(s,
"nonisoc", &imx21->nonisoc_stats);
374 debug_statistics_show_one(s,
"isoc", &imx21->isoc_stats);
375 seq_printf(s,
"unblock kludge triggers: %lu\n", imx21->debug_unblocks);
376 spin_unlock_irqrestore(&imx21->
lock, flags);
381 static void debug_isoc_show_one(
struct seq_file *s,
382 const char *
name,
int index,
struct debug_isoc_trace *trace)
386 "scheduled frame %d (%d)\n"
387 "submitted frame %d (%d)\n"
388 "completed frame %d (%d)\n"
389 "requested length=%d\n"
390 "completed length=%d\n\n",
393 trace->schedule_frame, trace->schedule_frame & 0xFFFF,
394 trace->submit_frame, trace->submit_frame & 0xFFFF,
395 trace->done_frame, trace->done_frame & 0xFFFF,
400 static int debug_isoc_show(
struct seq_file *s,
void *v)
402 struct imx21 *imx21 = s->
private;
403 struct debug_isoc_trace *
trace;
409 trace = imx21->isoc_trace_failed;
410 for (i = 0; i <
ARRAY_SIZE(imx21->isoc_trace_failed); i++, trace++)
411 debug_isoc_show_one(s,
"isoc failed", i, trace);
413 trace = imx21->isoc_trace;
414 for (i = 0; i <
ARRAY_SIZE(imx21->isoc_trace); i++, trace++)
415 debug_isoc_show_one(s,
"isoc", i, trace);
417 spin_unlock_irqrestore(&imx21->
lock, flags);
448 .
open = debug_status_open,
455 .
open = debug_dmem_open,
462 .
open = debug_etd_open,
469 .
open = debug_statistics_open,
476 .
open = debug_isoc_open,
485 if (!imx21->debug_root)
486 goto failed_create_rootdir;
489 imx21->debug_root, imx21, &debug_status_fops))
493 imx21->debug_root, imx21, &debug_dmem_fops))
497 imx21->debug_root, imx21, &debug_etd_fops))
501 imx21->debug_root, imx21, &debug_statistics_fops))
505 imx21->debug_root, imx21, &debug_isoc_fops))
513 failed_create_rootdir:
514 imx21->debug_root =
NULL;
520 if (imx21->debug_root) {
522 imx21->debug_root =
NULL;