Lines Matching +full:out +full:-
1 // SPDX-License-Identifier: GPL-2.0
3 * UHCI-specific debugging code. Invaluable when something
10 * (C) Copyright 1999-2001 Johannes Erdfelt
18 #include "uhci-hcd.h"
46 char *out = buf; in uhci_show_td() local
51 out += sprintf(out, "%*s[%p] link (%08x) ", space, "", td, in uhci_show_td()
52 hc32_to_cpu(uhci, td->link)); in uhci_show_td()
53 out += sprintf(out, "e%d %s%s%s%s%s%s%s%s%s%sLength=%x ", in uhci_show_td()
66 if (out - buf > len) in uhci_show_td()
75 spid = "OUT"; in uhci_show_td()
85 out += sprintf(out, "MaxLen=%x DT%d EndPt=%x Dev=%x, PID=%x(%s) ", in uhci_show_td()
92 out += sprintf(out, "(buf=%08x)\n", hc32_to_cpu(uhci, td->buffer)); in uhci_show_td()
95 if (out - buf > len) in uhci_show_td()
96 out += sprintf(out, " ...\n"); in uhci_show_td()
97 return out - buf; in uhci_show_td()
103 char *out = buf; in uhci_show_urbp() local
109 out += sprintf(out, "urb_priv [%p] ", urbp); in uhci_show_urbp()
110 out += sprintf(out, "urb [%p] ", urbp->urb); in uhci_show_urbp()
111 out += sprintf(out, "qh [%p] ", urbp->qh); in uhci_show_urbp()
112 out += sprintf(out, "Dev=%d ", usb_pipedevice(urbp->urb->pipe)); in uhci_show_urbp()
113 out += sprintf(out, "EP=%x(%s) ", usb_pipeendpoint(urbp->urb->pipe), in uhci_show_urbp()
114 (usb_pipein(urbp->urb->pipe) ? "IN" : "OUT")); in uhci_show_urbp()
115 if (out - buf > len) in uhci_show_urbp()
118 switch (usb_pipetype(urbp->urb->pipe)) { in uhci_show_urbp()
126 out += sprintf(out, "%s%s", ptype, (urbp->fsbr ? " FSBR" : "")); in uhci_show_urbp()
127 out += sprintf(out, " Actlen=%d%s", urbp->urb->actual_length, in uhci_show_urbp()
128 (urbp->qh->type == USB_ENDPOINT_XFER_CONTROL ? in uhci_show_urbp()
129 "-8" : "")); in uhci_show_urbp()
131 if (urbp->urb->unlinked) in uhci_show_urbp()
132 out += sprintf(out, " Unlinked=%d", urbp->urb->unlinked); in uhci_show_urbp()
133 out += sprintf(out, "\n"); in uhci_show_urbp()
135 if (out - buf > len) in uhci_show_urbp()
139 list_for_each_entry(td, &urbp->td_list, list) { in uhci_show_urbp()
140 if (urbp->qh->type != USB_ENDPOINT_XFER_ISOC && in uhci_show_urbp()
142 out += sprintf(out, "%*s%d: ", space + 2, "", i); in uhci_show_urbp()
143 out += uhci_show_td(uhci, td, out, in uhci_show_urbp()
144 len - (out - buf), 0); in uhci_show_urbp()
145 if (out - buf > len) in uhci_show_urbp()
155 out += sprintf(out, in uhci_show_urbp()
159 if (out - buf > len) in uhci_show_urbp()
160 out += sprintf(out, " ...\n"); in uhci_show_urbp()
162 return out - buf; in uhci_show_urbp()
168 char *out = buf; in uhci_show_qh() local
173 switch (qh->type) { in uhci_show_qh()
181 out += sprintf(out, "%*s[%p] %s QH link (%08x) element (%08x)\n", in uhci_show_qh()
183 hc32_to_cpu(uhci, qh->link), in uhci_show_qh()
185 if (qh->type == USB_ENDPOINT_XFER_ISOC) in uhci_show_qh()
186 out += sprintf(out, in uhci_show_qh()
188 space, "", qh->period, qh->phase, qh->load, in uhci_show_qh()
189 qh->iso_frame, qh->iso_packet_desc); in uhci_show_qh()
190 else if (qh->type == USB_ENDPOINT_XFER_INT) in uhci_show_qh()
191 out += sprintf(out, "%*s period %d phase %d load %d us\n", in uhci_show_qh()
192 space, "", qh->period, qh->phase, qh->load); in uhci_show_qh()
193 if (out - buf > len) in uhci_show_qh()
197 out += sprintf(out, "%*s Element points to QH (bug?)\n", space, ""); in uhci_show_qh()
200 out += sprintf(out, "%*s Depth traverse\n", space, ""); in uhci_show_qh()
203 out += sprintf(out, "%*s Bit 3 set (bug?)\n", space, ""); in uhci_show_qh()
206 out += sprintf(out, "%*s Element is NULL (bug?)\n", space, ""); in uhci_show_qh()
208 if (out - buf > len) in uhci_show_qh()
211 if (list_empty(&qh->queue)) { in uhci_show_qh()
212 out += sprintf(out, "%*s queue is empty\n", space, ""); in uhci_show_qh()
213 if (qh == uhci->skel_async_qh) { in uhci_show_qh()
214 out += uhci_show_td(uhci, uhci->term_td, out, in uhci_show_qh()
215 len - (out - buf), 0); in uhci_show_qh()
216 if (out - buf > len) in uhci_show_qh()
220 struct urb_priv *urbp = list_entry(qh->queue.next, in uhci_show_qh()
222 struct uhci_td *td = list_entry(urbp->td_list.next, in uhci_show_qh()
226 out += sprintf(out, "%*s Element != First TD\n", in uhci_show_qh()
229 list_for_each_entry(urbp, &qh->queue, node) { in uhci_show_qh()
231 out += uhci_show_urbp(uhci, urbp, out, in uhci_show_qh()
232 len - (out - buf), space + 2); in uhci_show_qh()
233 if (out - buf > len) in uhci_show_qh()
240 out += sprintf(out, "%*s Skipped %d URBs\n", in uhci_show_qh()
244 if (out - buf > len) in uhci_show_qh()
247 if (qh->dummy_td) { in uhci_show_qh()
248 out += sprintf(out, "%*s Dummy TD\n", space, ""); in uhci_show_qh()
249 out += uhci_show_td(uhci, qh->dummy_td, out, in uhci_show_qh()
250 len - (out - buf), 0); in uhci_show_qh()
251 if (out - buf > len) in uhci_show_qh()
256 if (out - buf > len) in uhci_show_qh()
257 out += sprintf(out, " ...\n"); in uhci_show_qh()
259 return out - buf; in uhci_show_qh()
283 switch (uhci->rh_state) { in uhci_show_root_hub_state()
289 rh_state = "auto-stopped"; break; in uhci_show_root_hub_state()
301 return sprintf(buf, "Root-hub state: %s FSBR: %d\n", in uhci_show_root_hub_state()
302 rh_state, uhci->fsbr_is_on); in uhci_show_root_hub_state()
307 char *out = buf; in uhci_show_status() local
323 out += sprintf(out, " usbcmd = %04x %s%s%s%s%s%s%s%s\n", in uhci_show_status()
333 if (out - buf > len) in uhci_show_status()
336 out += sprintf(out, " usbstat = %04x %s%s%s%s%s%s\n", in uhci_show_status()
344 if (out - buf > len) in uhci_show_status()
347 out += sprintf(out, " usbint = %04x\n", usbint); in uhci_show_status()
348 out += sprintf(out, " usbfrnum = (%d)%03x\n", (usbfrnum >> 10) & 1, in uhci_show_status()
350 out += sprintf(out, " flbaseadd = %08x\n", flbaseadd); in uhci_show_status()
351 out += sprintf(out, " sof = %02x\n", sof); in uhci_show_status()
352 if (out - buf > len) in uhci_show_status()
355 out += uhci_show_sc(1, portsc1, out); in uhci_show_status()
356 if (out - buf > len) in uhci_show_status()
359 out += uhci_show_sc(2, portsc2, out); in uhci_show_status()
360 if (out - buf > len) in uhci_show_status()
363 out += sprintf(out, in uhci_show_status()
365 uhci->frame_number, uhci->frame_number & 1023, in uhci_show_status()
366 uhci->last_iso_frame, uhci->last_iso_frame & 1023); in uhci_show_status()
369 if (out - buf > len) in uhci_show_status()
370 out += sprintf(out, " ...\n"); in uhci_show_status()
371 return out - buf; in uhci_show_status()
376 char *out = buf; in uhci_sprint_schedule() local
390 out += uhci_show_root_hub_state(uhci, out); in uhci_sprint_schedule()
391 if (out - buf > len) in uhci_sprint_schedule()
393 out += sprintf(out, "HC status\n"); in uhci_sprint_schedule()
394 out += uhci_show_status(uhci, out, len - (out - buf)); in uhci_sprint_schedule()
395 if (out - buf > len) in uhci_sprint_schedule()
398 out += sprintf(out, "Periodic load table\n"); in uhci_sprint_schedule()
400 out += sprintf(out, "\t%d", uhci->load[i]); in uhci_sprint_schedule()
402 *out++ = '\n'; in uhci_sprint_schedule()
404 out += sprintf(out, "Total: %d, #INT: %d, #ISO: %d\n", in uhci_sprint_schedule()
405 uhci->total_load, in uhci_sprint_schedule()
406 uhci_to_hcd(uhci)->self.bandwidth_int_reqs, in uhci_sprint_schedule()
407 uhci_to_hcd(uhci)->self.bandwidth_isoc_reqs); in uhci_sprint_schedule()
411 out += sprintf(out, "Frame List\n"); in uhci_sprint_schedule()
417 if (out - buf > len) in uhci_sprint_schedule()
420 td = uhci->frame_cpu[i]; in uhci_sprint_schedule()
421 link = uhci->frame[i]; in uhci_sprint_schedule()
426 out += sprintf(out, "- Frame %d -> (%08x)\n", in uhci_sprint_schedule()
431 head = &td->fl_list; in uhci_sprint_schedule()
435 tmp = tmp->next; in uhci_sprint_schedule()
438 out += sprintf(out, in uhci_sprint_schedule()
440 if (out - buf > len) in uhci_sprint_schedule()
446 out += uhci_show_td(uhci, td, out, in uhci_sprint_schedule()
447 len - (out - buf), 4); in uhci_sprint_schedule()
448 if (out - buf > len) in uhci_sprint_schedule()
451 link = td->link; in uhci_sprint_schedule()
459 out += sprintf(out, in uhci_sprint_schedule()
460 "- Frame %d -> (%08x)\n", in uhci_sprint_schedule()
464 out += sprintf(out, in uhci_sprint_schedule()
467 if (out - buf > len) in uhci_sprint_schedule()
472 nframes -= j; in uhci_sprint_schedule()
475 out += sprintf(out, "Skipped %d bad links\n", nerrs); in uhci_sprint_schedule()
477 out += sprintf(out, "Skeleton QHs\n"); in uhci_sprint_schedule()
479 if (out - buf > len) in uhci_sprint_schedule()
486 qh = uhci->skelqh[i]; in uhci_sprint_schedule()
487 out += sprintf(out, "- skel_%s_qh\n", qh_names[i]); in uhci_sprint_schedule()
488 out += uhci_show_qh(uhci, qh, out, len - (out - buf), 4); in uhci_sprint_schedule()
489 if (out - buf > len) in uhci_sprint_schedule()
494 if (qh_element(qh) != LINK_TO_TD(uhci, uhci->term_td)) { in uhci_sprint_schedule()
495 out += sprintf(out, in uhci_sprint_schedule()
497 if (out - buf > len) in uhci_sprint_schedule()
502 link = LINK_TO_QH(uhci, uhci->skel_term_qh); in uhci_sprint_schedule()
506 head = &qh->node; in uhci_sprint_schedule()
507 tmp = head->next; in uhci_sprint_schedule()
511 tmp = tmp->next; in uhci_sprint_schedule()
513 out += uhci_show_qh(uhci, qh, out, in uhci_sprint_schedule()
514 len - (out - buf), 4); in uhci_sprint_schedule()
515 if (out - buf > len) in uhci_sprint_schedule()
518 if (!fsbr_link && qh->skel >= SKEL_FSBR) in uhci_sprint_schedule()
521 if ((cnt -= 10) > 0) in uhci_sprint_schedule()
522 out += sprintf(out, " Skipped %d QHs\n", cnt); in uhci_sprint_schedule()
528 link = LINK_TO_QH(uhci, uhci->skel_async_qh); in uhci_sprint_schedule()
529 else if (!uhci->fsbr_is_on) in uhci_sprint_schedule()
532 link = LINK_TO_QH(uhci, uhci->skel_term_qh); in uhci_sprint_schedule()
534 if (qh->link != link) in uhci_sprint_schedule()
535 out += sprintf(out, in uhci_sprint_schedule()
538 if (out - buf > len) in uhci_sprint_schedule()
543 if (out - buf > len) in uhci_sprint_schedule()
544 out += sprintf(out, " ...\n"); in uhci_sprint_schedule()
546 return out - buf; in uhci_sprint_schedule()
560 struct uhci_hcd *uhci = inode->i_private; in uhci_debug_open()
566 return -ENOMEM; in uhci_debug_open()
568 up->data = kmalloc(MAX_OUTPUT, GFP_KERNEL); in uhci_debug_open()
569 if (!up->data) { in uhci_debug_open()
571 return -ENOMEM; in uhci_debug_open()
574 up->size = 0; in uhci_debug_open()
575 spin_lock_irqsave(&uhci->lock, flags); in uhci_debug_open()
576 if (uhci->is_initialized) in uhci_debug_open()
577 up->size = uhci_sprint_schedule(uhci, up->data, in uhci_debug_open()
578 MAX_OUTPUT - EXTRA_SPACE); in uhci_debug_open()
579 spin_unlock_irqrestore(&uhci->lock, flags); in uhci_debug_open()
581 file->private_data = up; in uhci_debug_open()
588 struct uhci_debug *up = file->private_data; in uhci_debug_lseek()
589 return no_seek_end_llseek_size(file, off, whence, up->size); in uhci_debug_lseek()
595 struct uhci_debug *up = file->private_data; in uhci_debug_read()
596 return simple_read_from_buffer(buf, nbytes, ppos, up->data, up->size); in uhci_debug_read()
601 struct uhci_debug *up = file->private_data; in uhci_debug_release()
603 kfree(up->data); in uhci_debug_release()