2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2001-2002 by David Brownell
|
2006-08-31 05:50:06 +08:00
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* this file is part of ehci-hcd.c */
|
|
|
|
|
2013-11-18 20:23:16 +08:00
|
|
|
#ifdef CONFIG_DYNAMIC_DEBUG
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-01-26 09:44:55 +08:00
|
|
|
/*
|
|
|
|
* check the values in the HCSPARAMS register
|
2005-04-17 06:20:36 +08:00
|
|
|
* (host controller _Structural_ parameters)
|
|
|
|
* see EHCI spec, Table 2-4 for each value
|
|
|
|
*/
|
2016-01-26 09:44:53 +08:00
|
|
|
static void dbg_hcs_params(struct ehci_hcd *ehci, char *label)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-12-15 03:54:08 +08:00
|
|
|
u32 params = ehci_readl(ehci, &ehci->caps->hcs_params);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-01-26 09:44:53 +08:00
|
|
|
ehci_dbg(ehci,
|
2005-04-17 06:20:36 +08:00
|
|
|
"%s hcs_params 0x%x dbg=%d%s cc=%d pcc=%d%s%s ports=%d\n",
|
|
|
|
label, params,
|
2016-01-26 09:44:53 +08:00
|
|
|
HCS_DEBUG_PORT(params),
|
|
|
|
HCS_INDICATOR(params) ? " ind" : "",
|
|
|
|
HCS_N_CC(params),
|
|
|
|
HCS_N_PCC(params),
|
|
|
|
HCS_PORTROUTED(params) ? "" : " ordered",
|
|
|
|
HCS_PPC(params) ? "" : " !ppc",
|
2016-01-26 09:44:57 +08:00
|
|
|
HCS_N_PORTS(params));
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Port routing, per EHCI 0.95 Spec, Section 2.2.5 */
|
2016-01-26 09:44:53 +08:00
|
|
|
if (HCS_PORTROUTED(params)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
int i;
|
2016-01-26 09:44:54 +08:00
|
|
|
char buf[46], tmp[7], byte;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
buf[0] = 0;
|
2016-01-26 09:44:53 +08:00
|
|
|
for (i = 0; i < HCS_N_PORTS(params); i++) {
|
2016-01-26 09:44:55 +08:00
|
|
|
/* FIXME MIPS won't readb() ... */
|
2016-01-26 09:44:53 +08:00
|
|
|
byte = readb(&ehci->caps->portroute[(i >> 1)]);
|
2006-08-31 05:50:06 +08:00
|
|
|
sprintf(tmp, "%d ",
|
2016-01-26 09:44:58 +08:00
|
|
|
(i & 0x1) ? byte & 0xf : (byte >> 4) & 0xf);
|
2005-04-17 06:20:36 +08:00
|
|
|
strcat(buf, tmp);
|
|
|
|
}
|
2016-01-26 09:44:53 +08:00
|
|
|
ehci_dbg(ehci, "%s portroute %s\n", label, buf);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-26 09:44:55 +08:00
|
|
|
/*
|
|
|
|
* check the values in the HCCPARAMS register
|
2005-04-17 06:20:36 +08:00
|
|
|
* (host controller _Capability_ parameters)
|
|
|
|
* see EHCI Spec, Table 2-5 for each value
|
2016-01-26 09:44:55 +08:00
|
|
|
*/
|
2016-01-26 09:44:53 +08:00
|
|
|
static void dbg_hcc_params(struct ehci_hcd *ehci, char *label)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-12-15 03:54:08 +08:00
|
|
|
u32 params = ehci_readl(ehci, &ehci->caps->hcc_params);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-01-26 09:44:53 +08:00
|
|
|
if (HCC_ISOC_CACHE(params)) {
|
|
|
|
ehci_dbg(ehci,
|
2007-05-02 00:29:37 +08:00
|
|
|
"%s hcc_params %04x caching frame %s%s%s\n",
|
|
|
|
label, params,
|
|
|
|
HCC_PGM_FRAMELISTLEN(params) ? "256/512/1024" : "1024",
|
|
|
|
HCC_CANPARK(params) ? " park" : "",
|
|
|
|
HCC_64BIT_ADDR(params) ? " 64 bit addr" : "");
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
2016-01-26 09:44:53 +08:00
|
|
|
ehci_dbg(ehci,
|
2010-06-04 15:47:54 +08:00
|
|
|
"%s hcc_params %04x thresh %d uframes %s%s%s%s%s%s%s\n",
|
2007-05-02 00:29:37 +08:00
|
|
|
label,
|
|
|
|
params,
|
|
|
|
HCC_ISOC_THRES(params),
|
|
|
|
HCC_PGM_FRAMELISTLEN(params) ? "256/512/1024" : "1024",
|
|
|
|
HCC_CANPARK(params) ? " park" : "",
|
2010-06-04 15:47:54 +08:00
|
|
|
HCC_64BIT_ADDR(params) ? " 64 bit addr" : "",
|
|
|
|
HCC_LPM(params) ? " LPM" : "",
|
|
|
|
HCC_PER_PORT_CHANGE_EVENT(params) ? " ppce" : "",
|
|
|
|
HCC_HW_PREFETCH(params) ? " hw prefetch" : "",
|
|
|
|
HCC_32FRAME_PERIODIC_LIST(params) ?
|
2012-02-17 22:06:47 +08:00
|
|
|
" 32 periodic list" : "");
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-12 05:39:44 +08:00
|
|
|
static void __maybe_unused
|
2016-01-26 09:44:53 +08:00
|
|
|
dbg_qtd(const char *label, struct ehci_hcd *ehci, struct ehci_qtd *qtd)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-05-02 00:29:37 +08:00
|
|
|
ehci_dbg(ehci, "%s td %p n%08x %08x t%08x p0=%08x\n", label, qtd,
|
|
|
|
hc32_to_cpup(ehci, &qtd->hw_next),
|
|
|
|
hc32_to_cpup(ehci, &qtd->hw_alt_next),
|
|
|
|
hc32_to_cpup(ehci, &qtd->hw_token),
|
2016-01-26 09:44:54 +08:00
|
|
|
hc32_to_cpup(ehci, &qtd->hw_buf[0]));
|
|
|
|
if (qtd->hw_buf[1])
|
2007-05-02 00:29:37 +08:00
|
|
|
ehci_dbg(ehci, " p1=%08x p2=%08x p3=%08x p4=%08x\n",
|
|
|
|
hc32_to_cpup(ehci, &qtd->hw_buf[1]),
|
|
|
|
hc32_to_cpup(ehci, &qtd->hw_buf[2]),
|
|
|
|
hc32_to_cpup(ehci, &qtd->hw_buf[3]),
|
|
|
|
hc32_to_cpup(ehci, &qtd->hw_buf[4]));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-05-12 05:39:44 +08:00
|
|
|
static void __maybe_unused
|
2016-01-26 09:44:53 +08:00
|
|
|
dbg_qh(const char *label, struct ehci_hcd *ehci, struct ehci_qh *qh)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2009-07-14 07:23:29 +08:00
|
|
|
struct ehci_qh_hw *hw = qh->hw;
|
|
|
|
|
2016-01-26 09:44:53 +08:00
|
|
|
ehci_dbg(ehci, "%s qh %p n%08x info %x %x qtd %x\n", label,
|
2009-07-14 07:23:29 +08:00
|
|
|
qh, hw->hw_next, hw->hw_info1, hw->hw_info2, hw->hw_current);
|
|
|
|
dbg_qtd("overlay", ehci, (struct ehci_qtd *) &hw->hw_qtd_next);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-05-12 05:39:44 +08:00
|
|
|
static void __maybe_unused
|
2016-01-26 09:44:53 +08:00
|
|
|
dbg_itd(const char *label, struct ehci_hcd *ehci, struct ehci_itd *itd)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2016-01-26 09:44:53 +08:00
|
|
|
ehci_dbg(ehci, "%s [%d] itd %p, next %08x, urb %p\n",
|
2007-05-02 00:29:37 +08:00
|
|
|
label, itd->frame, itd, hc32_to_cpu(ehci, itd->hw_next),
|
|
|
|
itd->urb);
|
2016-01-26 09:44:53 +08:00
|
|
|
ehci_dbg(ehci,
|
2006-08-31 05:50:06 +08:00
|
|
|
" trans: %08x %08x %08x %08x %08x %08x %08x %08x\n",
|
2007-05-02 00:29:37 +08:00
|
|
|
hc32_to_cpu(ehci, itd->hw_transaction[0]),
|
|
|
|
hc32_to_cpu(ehci, itd->hw_transaction[1]),
|
|
|
|
hc32_to_cpu(ehci, itd->hw_transaction[2]),
|
|
|
|
hc32_to_cpu(ehci, itd->hw_transaction[3]),
|
|
|
|
hc32_to_cpu(ehci, itd->hw_transaction[4]),
|
|
|
|
hc32_to_cpu(ehci, itd->hw_transaction[5]),
|
|
|
|
hc32_to_cpu(ehci, itd->hw_transaction[6]),
|
|
|
|
hc32_to_cpu(ehci, itd->hw_transaction[7]));
|
2016-01-26 09:44:53 +08:00
|
|
|
ehci_dbg(ehci,
|
2006-08-31 05:50:06 +08:00
|
|
|
" buf: %08x %08x %08x %08x %08x %08x %08x\n",
|
2007-05-02 00:29:37 +08:00
|
|
|
hc32_to_cpu(ehci, itd->hw_bufp[0]),
|
|
|
|
hc32_to_cpu(ehci, itd->hw_bufp[1]),
|
|
|
|
hc32_to_cpu(ehci, itd->hw_bufp[2]),
|
|
|
|
hc32_to_cpu(ehci, itd->hw_bufp[3]),
|
|
|
|
hc32_to_cpu(ehci, itd->hw_bufp[4]),
|
|
|
|
hc32_to_cpu(ehci, itd->hw_bufp[5]),
|
|
|
|
hc32_to_cpu(ehci, itd->hw_bufp[6]));
|
2016-01-26 09:44:53 +08:00
|
|
|
ehci_dbg(ehci, " index: %d %d %d %d %d %d %d %d\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
itd->index[0], itd->index[1], itd->index[2],
|
|
|
|
itd->index[3], itd->index[4], itd->index[5],
|
|
|
|
itd->index[6], itd->index[7]);
|
|
|
|
}
|
|
|
|
|
2007-05-12 05:39:44 +08:00
|
|
|
static void __maybe_unused
|
2016-01-26 09:44:53 +08:00
|
|
|
dbg_sitd(const char *label, struct ehci_hcd *ehci, struct ehci_sitd *sitd)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2016-01-26 09:44:53 +08:00
|
|
|
ehci_dbg(ehci, "%s [%d] sitd %p, next %08x, urb %p\n",
|
2007-05-02 00:29:37 +08:00
|
|
|
label, sitd->frame, sitd, hc32_to_cpu(ehci, sitd->hw_next),
|
|
|
|
sitd->urb);
|
2016-01-26 09:44:53 +08:00
|
|
|
ehci_dbg(ehci,
|
2006-08-31 05:50:06 +08:00
|
|
|
" addr %08x sched %04x result %08x buf %08x %08x\n",
|
2007-05-02 00:29:37 +08:00
|
|
|
hc32_to_cpu(ehci, sitd->hw_fullspeed_ep),
|
|
|
|
hc32_to_cpu(ehci, sitd->hw_uframe),
|
|
|
|
hc32_to_cpu(ehci, sitd->hw_results),
|
|
|
|
hc32_to_cpu(ehci, sitd->hw_buf[0]),
|
|
|
|
hc32_to_cpu(ehci, sitd->hw_buf[1]));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-05-12 05:39:44 +08:00
|
|
|
static int __maybe_unused
|
2016-01-26 09:44:53 +08:00
|
|
|
dbg_status_buf(char *buf, unsigned len, const char *label, u32 status)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2016-01-26 09:44:53 +08:00
|
|
|
return scnprintf(buf, len,
|
2010-06-04 15:47:54 +08:00
|
|
|
"%s%sstatus %04x%s%s%s%s%s%s%s%s%s%s%s",
|
2016-01-26 09:44:54 +08:00
|
|
|
label, label[0] ? " " : "", status,
|
2010-06-04 15:47:54 +08:00
|
|
|
(status & STS_PPCE_MASK) ? " PPCE" : "",
|
2005-04-17 06:20:36 +08:00
|
|
|
(status & STS_ASS) ? " Async" : "",
|
|
|
|
(status & STS_PSS) ? " Periodic" : "",
|
|
|
|
(status & STS_RECL) ? " Recl" : "",
|
|
|
|
(status & STS_HALT) ? " Halt" : "",
|
|
|
|
(status & STS_IAA) ? " IAA" : "",
|
|
|
|
(status & STS_FATAL) ? " FATAL" : "",
|
|
|
|
(status & STS_FLR) ? " FLR" : "",
|
|
|
|
(status & STS_PCD) ? " PCD" : "",
|
|
|
|
(status & STS_ERR) ? " ERR" : "",
|
2016-01-26 09:44:57 +08:00
|
|
|
(status & STS_INT) ? " INT" : "");
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-05-12 05:39:44 +08:00
|
|
|
static int __maybe_unused
|
2016-01-26 09:44:53 +08:00
|
|
|
dbg_intr_buf(char *buf, unsigned len, const char *label, u32 enable)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2016-01-26 09:44:53 +08:00
|
|
|
return scnprintf(buf, len,
|
2010-06-04 15:47:54 +08:00
|
|
|
"%s%sintrenable %02x%s%s%s%s%s%s%s",
|
2016-01-26 09:44:54 +08:00
|
|
|
label, label[0] ? " " : "", enable,
|
2010-06-04 15:47:54 +08:00
|
|
|
(enable & STS_PPCE_MASK) ? " PPCE" : "",
|
2005-04-17 06:20:36 +08:00
|
|
|
(enable & STS_IAA) ? " IAA" : "",
|
|
|
|
(enable & STS_FATAL) ? " FATAL" : "",
|
|
|
|
(enable & STS_FLR) ? " FLR" : "",
|
|
|
|
(enable & STS_PCD) ? " PCD" : "",
|
|
|
|
(enable & STS_ERR) ? " ERR" : "",
|
2016-01-26 09:44:57 +08:00
|
|
|
(enable & STS_INT) ? " INT" : "");
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2016-01-26 09:44:54 +08:00
|
|
|
static const char *const fls_strings[] = { "1024", "512", "256", "??" };
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static int
|
2016-01-26 09:44:53 +08:00
|
|
|
dbg_command_buf(char *buf, unsigned len, const char *label, u32 command)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2016-01-26 09:44:53 +08:00
|
|
|
return scnprintf(buf, len,
|
2010-06-04 15:47:54 +08:00
|
|
|
"%s%scommand %07x %s%s%s%s%s%s=%d ithresh=%d%s%s%s%s "
|
|
|
|
"period=%s%s %s",
|
2016-01-26 09:44:54 +08:00
|
|
|
label, label[0] ? " " : "", command,
|
2010-06-04 15:47:54 +08:00
|
|
|
(command & CMD_HIRD) ? " HIRD" : "",
|
|
|
|
(command & CMD_PPCEE) ? " PPCEE" : "",
|
|
|
|
(command & CMD_FSP) ? " FSP" : "",
|
|
|
|
(command & CMD_ASPE) ? " ASPE" : "",
|
|
|
|
(command & CMD_PSPE) ? " PSPE" : "",
|
|
|
|
(command & CMD_PARK) ? " park" : "(park)",
|
2016-01-26 09:44:53 +08:00
|
|
|
CMD_PARK_CNT(command),
|
2005-04-17 06:20:36 +08:00
|
|
|
(command >> 16) & 0x3f,
|
|
|
|
(command & CMD_LRESET) ? " LReset" : "",
|
|
|
|
(command & CMD_IAAD) ? " IAAD" : "",
|
|
|
|
(command & CMD_ASE) ? " Async" : "",
|
|
|
|
(command & CMD_PSE) ? " Periodic" : "",
|
2016-01-26 09:44:54 +08:00
|
|
|
fls_strings[(command >> 2) & 0x3],
|
2005-04-17 06:20:36 +08:00
|
|
|
(command & CMD_RESET) ? " Reset" : "",
|
2016-01-26 09:44:57 +08:00
|
|
|
(command & CMD_RUN) ? "RUN" : "HALT");
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-01-26 09:44:53 +08:00
|
|
|
dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
char *sig;
|
|
|
|
|
|
|
|
/* signaling state */
|
|
|
|
switch (status & (3 << 10)) {
|
2016-01-26 09:44:56 +08:00
|
|
|
case 0 << 10:
|
|
|
|
sig = "se0";
|
|
|
|
break;
|
|
|
|
case 1 << 10: /* low speed */
|
|
|
|
sig = "k";
|
|
|
|
break;
|
|
|
|
case 2 << 10:
|
|
|
|
sig = "j";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sig = "?";
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2016-01-26 09:44:53 +08:00
|
|
|
return scnprintf(buf, len,
|
2010-06-04 15:47:54 +08:00
|
|
|
"%s%sport:%d status %06x %d %s%s%s%s%s%s "
|
|
|
|
"sig=%s%s%s%s%s%s%s%s%s%s%s",
|
2016-01-26 09:44:54 +08:00
|
|
|
label, label[0] ? " " : "", port, status,
|
2016-01-26 09:44:58 +08:00
|
|
|
status >> 25, /*device address */
|
|
|
|
(status & PORT_SSTS) >> 23 == PORTSC_SUSPEND_STS_ACK ?
|
2010-06-04 15:47:54 +08:00
|
|
|
" ACK" : "",
|
2016-01-26 09:44:58 +08:00
|
|
|
(status & PORT_SSTS) >> 23 == PORTSC_SUSPEND_STS_NYET ?
|
2010-06-04 15:47:54 +08:00
|
|
|
" NYET" : "",
|
2016-01-26 09:44:58 +08:00
|
|
|
(status & PORT_SSTS) >> 23 == PORTSC_SUSPEND_STS_STALL ?
|
2010-06-04 15:47:54 +08:00
|
|
|
" STALL" : "",
|
2016-01-26 09:44:58 +08:00
|
|
|
(status & PORT_SSTS) >> 23 == PORTSC_SUSPEND_STS_ERR ?
|
2010-06-04 15:47:54 +08:00
|
|
|
" ERR" : "",
|
2005-04-17 06:20:36 +08:00
|
|
|
(status & PORT_POWER) ? " POWER" : "",
|
|
|
|
(status & PORT_OWNER) ? " OWNER" : "",
|
|
|
|
sig,
|
2010-06-04 15:47:54 +08:00
|
|
|
(status & PORT_LPM) ? " LPM" : "",
|
2005-04-17 06:20:36 +08:00
|
|
|
(status & PORT_RESET) ? " RESET" : "",
|
|
|
|
(status & PORT_SUSPEND) ? " SUSPEND" : "",
|
|
|
|
(status & PORT_RESUME) ? " RESUME" : "",
|
|
|
|
(status & PORT_OCC) ? " OCC" : "",
|
|
|
|
(status & PORT_OC) ? " OC" : "",
|
|
|
|
(status & PORT_PEC) ? " PEC" : "",
|
|
|
|
(status & PORT_PE) ? " PE" : "",
|
|
|
|
(status & PORT_CSC) ? " CSC" : "",
|
2007-05-02 00:29:37 +08:00
|
|
|
(status & PORT_CONNECT) ? " CONNECT" : "");
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2016-01-26 09:45:02 +08:00
|
|
|
static inline void
|
|
|
|
dbg_status(struct ehci_hcd *ehci, const char *label, u32 status)
|
|
|
|
{
|
|
|
|
char buf[80];
|
|
|
|
|
|
|
|
dbg_status_buf(buf, sizeof(buf), label, status);
|
|
|
|
ehci_dbg(ehci, "%s\n", buf);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2016-01-26 09:45:02 +08:00
|
|
|
static inline void
|
|
|
|
dbg_cmd(struct ehci_hcd *ehci, const char *label, u32 command)
|
|
|
|
{
|
|
|
|
char buf[80];
|
|
|
|
|
|
|
|
dbg_command_buf(buf, sizeof(buf), label, command);
|
|
|
|
ehci_dbg(ehci, "%s\n", buf);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2016-01-26 09:45:02 +08:00
|
|
|
static inline void
|
|
|
|
dbg_port(struct ehci_hcd *ehci, const char *label, int port, u32 status)
|
|
|
|
{
|
|
|
|
char buf[80];
|
|
|
|
|
|
|
|
dbg_port_buf(buf, sizeof(buf), label, port, status);
|
|
|
|
ehci_dbg(ehci, "%s\n", buf);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
2007-09-12 05:07:31 +08:00
|
|
|
/* troubleshooting help: expose state in debugfs */
|
|
|
|
|
|
|
|
static int debug_async_open(struct inode *, struct file *);
|
2013-10-11 23:29:13 +08:00
|
|
|
static int debug_bandwidth_open(struct inode *, struct file *);
|
2007-09-12 05:07:31 +08:00
|
|
|
static int debug_periodic_open(struct inode *, struct file *);
|
|
|
|
static int debug_registers_open(struct inode *, struct file *);
|
2010-06-04 15:47:54 +08:00
|
|
|
|
2007-09-12 05:07:31 +08:00
|
|
|
static ssize_t debug_output(struct file*, char __user*, size_t, loff_t*);
|
|
|
|
static int debug_close(struct inode *, struct file *);
|
|
|
|
|
|
|
|
static const struct file_operations debug_async_fops = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = debug_async_open,
|
|
|
|
.read = debug_output,
|
|
|
|
.release = debug_close,
|
llseek: automatically add .llseek fop
All file_operations should get a .llseek operation so we can make
nonseekable_open the default for future file operations without a
.llseek pointer.
The three cases that we can automatically detect are no_llseek, seq_lseek
and default_llseek. For cases where we can we can automatically prove that
the file offset is always ignored, we use noop_llseek, which maintains
the current behavior of not returning an error from a seek.
New drivers should normally not use noop_llseek but instead use no_llseek
and call nonseekable_open at open time. Existing drivers can be converted
to do the same when the maintainer knows for certain that no user code
relies on calling seek on the device file.
The generated code is often incorrectly indented and right now contains
comments that clarify for each added line why a specific variant was
chosen. In the version that gets submitted upstream, the comments will
be gone and I will manually fix the indentation, because there does not
seem to be a way to do that using coccinelle.
Some amount of new code is currently sitting in linux-next that should get
the same modifications, which I will do at the end of the merge window.
Many thanks to Julia Lawall for helping me learn to write a semantic
patch that does all this.
===== begin semantic patch =====
// This adds an llseek= method to all file operations,
// as a preparation for making no_llseek the default.
//
// The rules are
// - use no_llseek explicitly if we do nonseekable_open
// - use seq_lseek for sequential files
// - use default_llseek if we know we access f_pos
// - use noop_llseek if we know we don't access f_pos,
// but we still want to allow users to call lseek
//
@ open1 exists @
identifier nested_open;
@@
nested_open(...)
{
<+...
nonseekable_open(...)
...+>
}
@ open exists@
identifier open_f;
identifier i, f;
identifier open1.nested_open;
@@
int open_f(struct inode *i, struct file *f)
{
<+...
(
nonseekable_open(...)
|
nested_open(...)
)
...+>
}
@ read disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ read_no_fpos disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
... when != off
}
@ write @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ write_no_fpos @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
... when != off
}
@ fops0 @
identifier fops;
@@
struct file_operations fops = {
...
};
@ has_llseek depends on fops0 @
identifier fops0.fops;
identifier llseek_f;
@@
struct file_operations fops = {
...
.llseek = llseek_f,
...
};
@ has_read depends on fops0 @
identifier fops0.fops;
identifier read_f;
@@
struct file_operations fops = {
...
.read = read_f,
...
};
@ has_write depends on fops0 @
identifier fops0.fops;
identifier write_f;
@@
struct file_operations fops = {
...
.write = write_f,
...
};
@ has_open depends on fops0 @
identifier fops0.fops;
identifier open_f;
@@
struct file_operations fops = {
...
.open = open_f,
...
};
// use no_llseek if we call nonseekable_open
////////////////////////////////////////////
@ nonseekable1 depends on !has_llseek && has_open @
identifier fops0.fops;
identifier nso ~= "nonseekable_open";
@@
struct file_operations fops = {
... .open = nso, ...
+.llseek = no_llseek, /* nonseekable */
};
@ nonseekable2 depends on !has_llseek @
identifier fops0.fops;
identifier open.open_f;
@@
struct file_operations fops = {
... .open = open_f, ...
+.llseek = no_llseek, /* open uses nonseekable */
};
// use seq_lseek for sequential files
/////////////////////////////////////
@ seq depends on !has_llseek @
identifier fops0.fops;
identifier sr ~= "seq_read";
@@
struct file_operations fops = {
... .read = sr, ...
+.llseek = seq_lseek, /* we have seq_read */
};
// use default_llseek if there is a readdir
///////////////////////////////////////////
@ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier readdir_e;
@@
// any other fop is used that changes pos
struct file_operations fops = {
... .readdir = readdir_e, ...
+.llseek = default_llseek, /* readdir is present */
};
// use default_llseek if at least one of read/write touches f_pos
/////////////////////////////////////////////////////////////////
@ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read.read_f;
@@
// read fops use offset
struct file_operations fops = {
... .read = read_f, ...
+.llseek = default_llseek, /* read accesses f_pos */
};
@ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write.write_f;
@@
// write fops use offset
struct file_operations fops = {
... .write = write_f, ...
+ .llseek = default_llseek, /* write accesses f_pos */
};
// Use noop_llseek if neither read nor write accesses f_pos
///////////////////////////////////////////////////////////
@ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
identifier write_no_fpos.write_f;
@@
// write fops use offset
struct file_operations fops = {
...
.write = write_f,
.read = read_f,
...
+.llseek = noop_llseek, /* read and write both use no f_pos */
};
@ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write_no_fpos.write_f;
@@
struct file_operations fops = {
... .write = write_f, ...
+.llseek = noop_llseek, /* write uses no f_pos */
};
@ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
@@
struct file_operations fops = {
... .read = read_f, ...
+.llseek = noop_llseek, /* read uses no f_pos */
};
@ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
@@
struct file_operations fops = {
...
+.llseek = noop_llseek, /* no read or write fn */
};
===== End semantic patch =====
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Julia Lawall <julia@diku.dk>
Cc: Christoph Hellwig <hch@infradead.org>
2010-08-16 00:52:59 +08:00
|
|
|
.llseek = default_llseek,
|
2007-09-12 05:07:31 +08:00
|
|
|
};
|
2016-01-26 09:45:01 +08:00
|
|
|
|
2013-10-11 23:29:13 +08:00
|
|
|
static const struct file_operations debug_bandwidth_fops = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = debug_bandwidth_open,
|
|
|
|
.read = debug_output,
|
|
|
|
.release = debug_close,
|
|
|
|
.llseek = default_llseek,
|
|
|
|
};
|
2016-01-26 09:45:01 +08:00
|
|
|
|
2007-09-12 05:07:31 +08:00
|
|
|
static const struct file_operations debug_periodic_fops = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = debug_periodic_open,
|
|
|
|
.read = debug_output,
|
|
|
|
.release = debug_close,
|
llseek: automatically add .llseek fop
All file_operations should get a .llseek operation so we can make
nonseekable_open the default for future file operations without a
.llseek pointer.
The three cases that we can automatically detect are no_llseek, seq_lseek
and default_llseek. For cases where we can we can automatically prove that
the file offset is always ignored, we use noop_llseek, which maintains
the current behavior of not returning an error from a seek.
New drivers should normally not use noop_llseek but instead use no_llseek
and call nonseekable_open at open time. Existing drivers can be converted
to do the same when the maintainer knows for certain that no user code
relies on calling seek on the device file.
The generated code is often incorrectly indented and right now contains
comments that clarify for each added line why a specific variant was
chosen. In the version that gets submitted upstream, the comments will
be gone and I will manually fix the indentation, because there does not
seem to be a way to do that using coccinelle.
Some amount of new code is currently sitting in linux-next that should get
the same modifications, which I will do at the end of the merge window.
Many thanks to Julia Lawall for helping me learn to write a semantic
patch that does all this.
===== begin semantic patch =====
// This adds an llseek= method to all file operations,
// as a preparation for making no_llseek the default.
//
// The rules are
// - use no_llseek explicitly if we do nonseekable_open
// - use seq_lseek for sequential files
// - use default_llseek if we know we access f_pos
// - use noop_llseek if we know we don't access f_pos,
// but we still want to allow users to call lseek
//
@ open1 exists @
identifier nested_open;
@@
nested_open(...)
{
<+...
nonseekable_open(...)
...+>
}
@ open exists@
identifier open_f;
identifier i, f;
identifier open1.nested_open;
@@
int open_f(struct inode *i, struct file *f)
{
<+...
(
nonseekable_open(...)
|
nested_open(...)
)
...+>
}
@ read disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ read_no_fpos disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
... when != off
}
@ write @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ write_no_fpos @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
... when != off
}
@ fops0 @
identifier fops;
@@
struct file_operations fops = {
...
};
@ has_llseek depends on fops0 @
identifier fops0.fops;
identifier llseek_f;
@@
struct file_operations fops = {
...
.llseek = llseek_f,
...
};
@ has_read depends on fops0 @
identifier fops0.fops;
identifier read_f;
@@
struct file_operations fops = {
...
.read = read_f,
...
};
@ has_write depends on fops0 @
identifier fops0.fops;
identifier write_f;
@@
struct file_operations fops = {
...
.write = write_f,
...
};
@ has_open depends on fops0 @
identifier fops0.fops;
identifier open_f;
@@
struct file_operations fops = {
...
.open = open_f,
...
};
// use no_llseek if we call nonseekable_open
////////////////////////////////////////////
@ nonseekable1 depends on !has_llseek && has_open @
identifier fops0.fops;
identifier nso ~= "nonseekable_open";
@@
struct file_operations fops = {
... .open = nso, ...
+.llseek = no_llseek, /* nonseekable */
};
@ nonseekable2 depends on !has_llseek @
identifier fops0.fops;
identifier open.open_f;
@@
struct file_operations fops = {
... .open = open_f, ...
+.llseek = no_llseek, /* open uses nonseekable */
};
// use seq_lseek for sequential files
/////////////////////////////////////
@ seq depends on !has_llseek @
identifier fops0.fops;
identifier sr ~= "seq_read";
@@
struct file_operations fops = {
... .read = sr, ...
+.llseek = seq_lseek, /* we have seq_read */
};
// use default_llseek if there is a readdir
///////////////////////////////////////////
@ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier readdir_e;
@@
// any other fop is used that changes pos
struct file_operations fops = {
... .readdir = readdir_e, ...
+.llseek = default_llseek, /* readdir is present */
};
// use default_llseek if at least one of read/write touches f_pos
/////////////////////////////////////////////////////////////////
@ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read.read_f;
@@
// read fops use offset
struct file_operations fops = {
... .read = read_f, ...
+.llseek = default_llseek, /* read accesses f_pos */
};
@ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write.write_f;
@@
// write fops use offset
struct file_operations fops = {
... .write = write_f, ...
+ .llseek = default_llseek, /* write accesses f_pos */
};
// Use noop_llseek if neither read nor write accesses f_pos
///////////////////////////////////////////////////////////
@ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
identifier write_no_fpos.write_f;
@@
// write fops use offset
struct file_operations fops = {
...
.write = write_f,
.read = read_f,
...
+.llseek = noop_llseek, /* read and write both use no f_pos */
};
@ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write_no_fpos.write_f;
@@
struct file_operations fops = {
... .write = write_f, ...
+.llseek = noop_llseek, /* write uses no f_pos */
};
@ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
@@
struct file_operations fops = {
... .read = read_f, ...
+.llseek = noop_llseek, /* read uses no f_pos */
};
@ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
@@
struct file_operations fops = {
...
+.llseek = noop_llseek, /* no read or write fn */
};
===== End semantic patch =====
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Julia Lawall <julia@diku.dk>
Cc: Christoph Hellwig <hch@infradead.org>
2010-08-16 00:52:59 +08:00
|
|
|
.llseek = default_llseek,
|
2007-09-12 05:07:31 +08:00
|
|
|
};
|
2016-01-26 09:45:01 +08:00
|
|
|
|
2007-09-12 05:07:31 +08:00
|
|
|
static const struct file_operations debug_registers_fops = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = debug_registers_open,
|
|
|
|
.read = debug_output,
|
|
|
|
.release = debug_close,
|
llseek: automatically add .llseek fop
All file_operations should get a .llseek operation so we can make
nonseekable_open the default for future file operations without a
.llseek pointer.
The three cases that we can automatically detect are no_llseek, seq_lseek
and default_llseek. For cases where we can we can automatically prove that
the file offset is always ignored, we use noop_llseek, which maintains
the current behavior of not returning an error from a seek.
New drivers should normally not use noop_llseek but instead use no_llseek
and call nonseekable_open at open time. Existing drivers can be converted
to do the same when the maintainer knows for certain that no user code
relies on calling seek on the device file.
The generated code is often incorrectly indented and right now contains
comments that clarify for each added line why a specific variant was
chosen. In the version that gets submitted upstream, the comments will
be gone and I will manually fix the indentation, because there does not
seem to be a way to do that using coccinelle.
Some amount of new code is currently sitting in linux-next that should get
the same modifications, which I will do at the end of the merge window.
Many thanks to Julia Lawall for helping me learn to write a semantic
patch that does all this.
===== begin semantic patch =====
// This adds an llseek= method to all file operations,
// as a preparation for making no_llseek the default.
//
// The rules are
// - use no_llseek explicitly if we do nonseekable_open
// - use seq_lseek for sequential files
// - use default_llseek if we know we access f_pos
// - use noop_llseek if we know we don't access f_pos,
// but we still want to allow users to call lseek
//
@ open1 exists @
identifier nested_open;
@@
nested_open(...)
{
<+...
nonseekable_open(...)
...+>
}
@ open exists@
identifier open_f;
identifier i, f;
identifier open1.nested_open;
@@
int open_f(struct inode *i, struct file *f)
{
<+...
(
nonseekable_open(...)
|
nested_open(...)
)
...+>
}
@ read disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ read_no_fpos disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
... when != off
}
@ write @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ write_no_fpos @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
... when != off
}
@ fops0 @
identifier fops;
@@
struct file_operations fops = {
...
};
@ has_llseek depends on fops0 @
identifier fops0.fops;
identifier llseek_f;
@@
struct file_operations fops = {
...
.llseek = llseek_f,
...
};
@ has_read depends on fops0 @
identifier fops0.fops;
identifier read_f;
@@
struct file_operations fops = {
...
.read = read_f,
...
};
@ has_write depends on fops0 @
identifier fops0.fops;
identifier write_f;
@@
struct file_operations fops = {
...
.write = write_f,
...
};
@ has_open depends on fops0 @
identifier fops0.fops;
identifier open_f;
@@
struct file_operations fops = {
...
.open = open_f,
...
};
// use no_llseek if we call nonseekable_open
////////////////////////////////////////////
@ nonseekable1 depends on !has_llseek && has_open @
identifier fops0.fops;
identifier nso ~= "nonseekable_open";
@@
struct file_operations fops = {
... .open = nso, ...
+.llseek = no_llseek, /* nonseekable */
};
@ nonseekable2 depends on !has_llseek @
identifier fops0.fops;
identifier open.open_f;
@@
struct file_operations fops = {
... .open = open_f, ...
+.llseek = no_llseek, /* open uses nonseekable */
};
// use seq_lseek for sequential files
/////////////////////////////////////
@ seq depends on !has_llseek @
identifier fops0.fops;
identifier sr ~= "seq_read";
@@
struct file_operations fops = {
... .read = sr, ...
+.llseek = seq_lseek, /* we have seq_read */
};
// use default_llseek if there is a readdir
///////////////////////////////////////////
@ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier readdir_e;
@@
// any other fop is used that changes pos
struct file_operations fops = {
... .readdir = readdir_e, ...
+.llseek = default_llseek, /* readdir is present */
};
// use default_llseek if at least one of read/write touches f_pos
/////////////////////////////////////////////////////////////////
@ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read.read_f;
@@
// read fops use offset
struct file_operations fops = {
... .read = read_f, ...
+.llseek = default_llseek, /* read accesses f_pos */
};
@ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write.write_f;
@@
// write fops use offset
struct file_operations fops = {
... .write = write_f, ...
+ .llseek = default_llseek, /* write accesses f_pos */
};
// Use noop_llseek if neither read nor write accesses f_pos
///////////////////////////////////////////////////////////
@ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
identifier write_no_fpos.write_f;
@@
// write fops use offset
struct file_operations fops = {
...
.write = write_f,
.read = read_f,
...
+.llseek = noop_llseek, /* read and write both use no f_pos */
};
@ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write_no_fpos.write_f;
@@
struct file_operations fops = {
... .write = write_f, ...
+.llseek = noop_llseek, /* write uses no f_pos */
};
@ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
@@
struct file_operations fops = {
... .read = read_f, ...
+.llseek = noop_llseek, /* read uses no f_pos */
};
@ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
@@
struct file_operations fops = {
...
+.llseek = noop_llseek, /* no read or write fn */
};
===== End semantic patch =====
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Julia Lawall <julia@diku.dk>
Cc: Christoph Hellwig <hch@infradead.org>
2010-08-16 00:52:59 +08:00
|
|
|
.llseek = default_llseek,
|
2007-09-12 05:07:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct dentry *ehci_debug_root;
|
|
|
|
|
|
|
|
struct debug_buffer {
|
|
|
|
ssize_t (*fill_func)(struct debug_buffer *); /* fill method */
|
|
|
|
struct usb_bus *bus;
|
|
|
|
struct mutex mutex; /* protect filling of buffer */
|
|
|
|
size_t count; /* number of characters filled into buffer */
|
2008-09-18 23:06:21 +08:00
|
|
|
char *output_buf;
|
|
|
|
size_t alloc_size;
|
2007-09-12 05:07:31 +08:00
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-01-26 09:45:02 +08:00
|
|
|
static inline char speed_char(u32 info1)
|
|
|
|
{
|
|
|
|
switch (info1 & (3 << 12)) {
|
|
|
|
case QH_FULL_SPEED:
|
|
|
|
return 'f';
|
|
|
|
case QH_LOW_SPEED:
|
|
|
|
return 'l';
|
|
|
|
case QH_HIGH_SPEED:
|
|
|
|
return 'h';
|
|
|
|
default:
|
|
|
|
return '?';
|
|
|
|
}
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-05-02 00:29:37 +08:00
|
|
|
static inline char token_mark(struct ehci_hcd *ehci, __hc32 token)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-05-02 00:29:37 +08:00
|
|
|
__u32 v = hc32_to_cpu(ehci, token);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (v & QTD_STS_ACTIVE)
|
|
|
|
return '*';
|
|
|
|
if (v & QTD_STS_HALT)
|
|
|
|
return '-';
|
2016-01-26 09:44:53 +08:00
|
|
|
if (!IS_SHORT_READ(v))
|
2005-04-17 06:20:36 +08:00
|
|
|
return ' ';
|
|
|
|
/* tries to advance through hw_alt_next */
|
|
|
|
return '/';
|
|
|
|
}
|
|
|
|
|
2016-01-26 09:45:00 +08:00
|
|
|
static void qh_lines(struct ehci_hcd *ehci, struct ehci_qh *qh,
|
|
|
|
char **nextp, unsigned *sizep)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
u32 scratch;
|
|
|
|
u32 hw_curr;
|
|
|
|
struct list_head *entry;
|
|
|
|
struct ehci_qtd *td;
|
|
|
|
unsigned temp;
|
|
|
|
unsigned size = *sizep;
|
|
|
|
char *next = *nextp;
|
|
|
|
char mark;
|
2008-04-28 14:00:16 +08:00
|
|
|
__le32 list_end = EHCI_LIST_END(ehci);
|
2009-07-14 07:23:29 +08:00
|
|
|
struct ehci_qh_hw *hw = qh->hw;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-07-14 07:23:29 +08:00
|
|
|
if (hw->hw_qtd_next == list_end) /* NEC does this */
|
2005-04-17 06:20:36 +08:00
|
|
|
mark = '@';
|
|
|
|
else
|
2009-07-14 07:23:29 +08:00
|
|
|
mark = token_mark(ehci, hw->hw_token);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (mark == '/') { /* qh_alt_next controls qh advance? */
|
2009-07-14 07:23:29 +08:00
|
|
|
if ((hw->hw_alt_next & QTD_MASK(ehci))
|
|
|
|
== ehci->async->hw->hw_alt_next)
|
2005-04-17 06:20:36 +08:00
|
|
|
mark = '#'; /* blocked */
|
2009-07-14 07:23:29 +08:00
|
|
|
else if (hw->hw_alt_next == list_end)
|
2005-04-17 06:20:36 +08:00
|
|
|
mark = '.'; /* use hw_qtd_next */
|
|
|
|
/* else alt_next points to some other qtd */
|
|
|
|
}
|
2009-07-14 07:23:29 +08:00
|
|
|
scratch = hc32_to_cpup(ehci, &hw->hw_info1);
|
|
|
|
hw_curr = (mark == '*') ? hc32_to_cpup(ehci, &hw->hw_current) : 0;
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size,
|
2015-11-21 02:53:45 +08:00
|
|
|
"qh/%p dev%d %cs ep%d %08x %08x (%08x%c %s nak%d)"
|
|
|
|
" [cur %08x next %08x buf[0] %08x]",
|
2005-04-17 06:20:36 +08:00
|
|
|
qh, scratch & 0x007f,
|
|
|
|
speed_char (scratch),
|
|
|
|
(scratch >> 8) & 0x000f,
|
2009-07-14 07:23:29 +08:00
|
|
|
scratch, hc32_to_cpup(ehci, &hw->hw_info2),
|
|
|
|
hc32_to_cpup(ehci, &hw->hw_token), mark,
|
|
|
|
(cpu_to_hc32(ehci, QTD_TOGGLE) & hw->hw_token)
|
2005-04-17 06:20:36 +08:00
|
|
|
? "data1" : "data0",
|
2015-11-21 02:53:45 +08:00
|
|
|
(hc32_to_cpup(ehci, &hw->hw_alt_next) >> 1) & 0x0f,
|
|
|
|
hc32_to_cpup(ehci, &hw->hw_current),
|
|
|
|
hc32_to_cpup(ehci, &hw->hw_qtd_next),
|
|
|
|
hc32_to_cpup(ehci, &hw->hw_buf[0]));
|
2005-04-17 06:20:36 +08:00
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
|
|
|
|
/* hc may be modifying the list as we read it ... */
|
2016-01-26 09:44:53 +08:00
|
|
|
list_for_each(entry, &qh->qtd_list) {
|
2016-01-26 09:44:56 +08:00
|
|
|
char *type;
|
|
|
|
|
2016-01-26 09:44:53 +08:00
|
|
|
td = list_entry(entry, struct ehci_qtd, qtd_list);
|
2007-05-02 00:29:37 +08:00
|
|
|
scratch = hc32_to_cpup(ehci, &td->hw_token);
|
2005-04-17 06:20:36 +08:00
|
|
|
mark = ' ';
|
2016-01-26 09:45:06 +08:00
|
|
|
if (hw_curr == td->qtd_dma) {
|
2005-04-17 06:20:36 +08:00
|
|
|
mark = '*';
|
2016-01-26 09:45:06 +08:00
|
|
|
} else if (hw->hw_qtd_next == cpu_to_hc32(ehci, td->qtd_dma)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
mark = '+';
|
2016-01-26 09:45:06 +08:00
|
|
|
} else if (QTD_LENGTH(scratch)) {
|
2009-07-14 07:23:29 +08:00
|
|
|
if (td->hw_alt_next == ehci->async->hw->hw_alt_next)
|
2005-04-17 06:20:36 +08:00
|
|
|
mark = '#';
|
2007-05-02 00:29:37 +08:00
|
|
|
else if (td->hw_alt_next != list_end)
|
2005-04-17 06:20:36 +08:00
|
|
|
mark = '/';
|
|
|
|
}
|
2016-01-26 09:44:56 +08:00
|
|
|
switch ((scratch >> 8) & 0x03) {
|
|
|
|
case 0:
|
|
|
|
type = "out";
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
type = "in";
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
type = "setup";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
type = "?";
|
|
|
|
break;
|
|
|
|
}
|
2016-01-26 09:44:59 +08:00
|
|
|
temp = scnprintf(next, size,
|
2015-11-21 02:53:45 +08:00
|
|
|
"\n\t%p%c%s len=%d %08x urb %p"
|
|
|
|
" [td %08x buf[0] %08x]",
|
2016-01-26 09:44:56 +08:00
|
|
|
td, mark, type,
|
2005-04-17 06:20:36 +08:00
|
|
|
(scratch >> 16) & 0x7fff,
|
|
|
|
scratch,
|
2015-11-21 02:53:45 +08:00
|
|
|
td->urb,
|
|
|
|
(u32) td->qtd_dma,
|
|
|
|
hc32_to_cpup(ehci, &td->hw_buf[0]));
|
2005-04-17 06:20:36 +08:00
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
if (temp == size)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2016-01-26 09:44:59 +08:00
|
|
|
temp = scnprintf(next, size, "\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
|
|
|
|
done:
|
|
|
|
*sizep = size;
|
|
|
|
*nextp = next;
|
|
|
|
}
|
|
|
|
|
2007-09-12 05:07:31 +08:00
|
|
|
static ssize_t fill_async_buffer(struct debug_buffer *buf)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct usb_hcd *hcd;
|
|
|
|
struct ehci_hcd *ehci;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned temp, size;
|
|
|
|
char *next;
|
|
|
|
struct ehci_qh *qh;
|
|
|
|
|
2007-09-12 05:07:31 +08:00
|
|
|
hcd = bus_to_hcd(buf->bus);
|
2016-01-26 09:44:53 +08:00
|
|
|
ehci = hcd_to_ehci(hcd);
|
2008-09-18 23:06:21 +08:00
|
|
|
next = buf->output_buf;
|
|
|
|
size = buf->alloc_size;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-09-12 05:07:31 +08:00
|
|
|
*next = 0;
|
|
|
|
|
2016-01-26 09:44:55 +08:00
|
|
|
/*
|
|
|
|
* dumps a snapshot of the async schedule.
|
2005-04-17 06:20:36 +08:00
|
|
|
* usually empty except for long-term bulk reads, or head.
|
|
|
|
* one QH per line, and TDs we know about
|
|
|
|
*/
|
2016-01-26 09:44:53 +08:00
|
|
|
spin_lock_irqsave(&ehci->lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
for (qh = ehci->async->qh_next.qh; size > 0 && qh; qh = qh->qh_next.qh)
|
2016-01-26 09:44:53 +08:00
|
|
|
qh_lines(ehci, qh, &next, &size);
|
2013-03-23 01:31:45 +08:00
|
|
|
if (!list_empty(&ehci->async_unlink) && size > 0) {
|
2012-07-11 23:21:38 +08:00
|
|
|
temp = scnprintf(next, size, "\nunlink =\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
|
2013-03-23 01:31:45 +08:00
|
|
|
list_for_each_entry(qh, &ehci->async_unlink, unlink_node) {
|
|
|
|
if (size <= 0)
|
|
|
|
break;
|
|
|
|
qh_lines(ehci, qh, &next, &size);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2016-01-26 09:44:53 +08:00
|
|
|
spin_unlock_irqrestore(&ehci->lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-09-18 23:06:21 +08:00
|
|
|
return strlen(buf->output_buf);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2013-10-11 23:29:13 +08:00
|
|
|
static ssize_t fill_bandwidth_buffer(struct debug_buffer *buf)
|
|
|
|
{
|
|
|
|
struct ehci_hcd *ehci;
|
2013-10-12 10:16:21 +08:00
|
|
|
struct ehci_tt *tt;
|
|
|
|
struct ehci_per_sched *ps;
|
2013-10-11 23:29:13 +08:00
|
|
|
unsigned temp, size;
|
|
|
|
char *next;
|
|
|
|
unsigned i;
|
|
|
|
u8 *bw;
|
2013-10-12 10:16:21 +08:00
|
|
|
u16 *bf;
|
|
|
|
u8 budget[EHCI_BANDWIDTH_SIZE];
|
2013-10-11 23:29:13 +08:00
|
|
|
|
|
|
|
ehci = hcd_to_ehci(bus_to_hcd(buf->bus));
|
|
|
|
next = buf->output_buf;
|
|
|
|
size = buf->alloc_size;
|
|
|
|
|
|
|
|
*next = 0;
|
|
|
|
|
|
|
|
spin_lock_irq(&ehci->lock);
|
|
|
|
|
|
|
|
/* Dump the HS bandwidth table */
|
|
|
|
temp = scnprintf(next, size,
|
|
|
|
"HS bandwidth allocation (us per microframe)\n");
|
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
for (i = 0; i < EHCI_BANDWIDTH_SIZE; i += 8) {
|
|
|
|
bw = &ehci->bandwidth[i];
|
|
|
|
temp = scnprintf(next, size,
|
|
|
|
"%2u: %4u%4u%4u%4u%4u%4u%4u%4u\n",
|
|
|
|
i, bw[0], bw[1], bw[2], bw[3],
|
|
|
|
bw[4], bw[5], bw[6], bw[7]);
|
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
}
|
2013-10-12 10:16:21 +08:00
|
|
|
|
|
|
|
/* Dump all the FS/LS tables */
|
|
|
|
list_for_each_entry(tt, &ehci->tt_list, tt_list) {
|
|
|
|
temp = scnprintf(next, size,
|
|
|
|
"\nTT %s port %d FS/LS bandwidth allocation (us per frame)\n",
|
|
|
|
dev_name(&tt->usb_tt->hub->dev),
|
|
|
|
tt->tt_port + !!tt->usb_tt->multi);
|
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
|
|
|
|
bf = tt->bandwidth;
|
|
|
|
temp = scnprintf(next, size,
|
|
|
|
" %5u%5u%5u%5u%5u%5u%5u%5u\n",
|
|
|
|
bf[0], bf[1], bf[2], bf[3],
|
|
|
|
bf[4], bf[5], bf[6], bf[7]);
|
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
|
|
|
|
temp = scnprintf(next, size,
|
|
|
|
"FS/LS budget (us per microframe)\n");
|
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
compute_tt_budget(budget, tt);
|
|
|
|
for (i = 0; i < EHCI_BANDWIDTH_SIZE; i += 8) {
|
|
|
|
bw = &budget[i];
|
|
|
|
temp = scnprintf(next, size,
|
|
|
|
"%2u: %4u%4u%4u%4u%4u%4u%4u%4u\n",
|
|
|
|
i, bw[0], bw[1], bw[2], bw[3],
|
|
|
|
bw[4], bw[5], bw[6], bw[7]);
|
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
}
|
|
|
|
list_for_each_entry(ps, &tt->ps_list, ps_list) {
|
|
|
|
temp = scnprintf(next, size,
|
|
|
|
"%s ep %02x: %4u @ %2u.%u+%u mask %04x\n",
|
|
|
|
dev_name(&ps->udev->dev),
|
|
|
|
ps->ep->desc.bEndpointAddress,
|
|
|
|
ps->tt_usecs,
|
|
|
|
ps->bw_phase, ps->phase_uf,
|
|
|
|
ps->bw_period, ps->cs_mask);
|
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
}
|
|
|
|
}
|
2013-10-11 23:29:13 +08:00
|
|
|
spin_unlock_irq(&ehci->lock);
|
|
|
|
|
|
|
|
return next - buf->output_buf;
|
|
|
|
}
|
|
|
|
|
2016-01-26 09:45:08 +08:00
|
|
|
static unsigned output_buf_tds_dir(char *buf, struct ehci_hcd *ehci,
|
|
|
|
struct ehci_qh_hw *hw, struct ehci_qh *qh, unsigned size)
|
|
|
|
{
|
|
|
|
u32 scratch = hc32_to_cpup(ehci, &hw->hw_info1);
|
|
|
|
struct ehci_qtd *qtd;
|
|
|
|
char *type = "";
|
|
|
|
unsigned temp = 0;
|
|
|
|
|
|
|
|
/* count tds, get ep direction */
|
|
|
|
list_for_each_entry(qtd, &qh->qtd_list, qtd_list) {
|
|
|
|
temp++;
|
|
|
|
switch ((hc32_to_cpu(ehci, qtd->hw_token) >> 8) & 0x03) {
|
|
|
|
case 0:
|
|
|
|
type = "out";
|
|
|
|
continue;
|
|
|
|
case 1:
|
|
|
|
type = "in";
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return scnprintf(buf, size, " (%c%d ep%d%s [%d/%d] q%d p%d)",
|
|
|
|
speed_char(scratch), scratch & 0x007f,
|
|
|
|
(scratch >> 8) & 0x000f, type, qh->ps.usecs,
|
|
|
|
qh->ps.c_usecs, temp, 0x7ff & (scratch >> 16));
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#define DBG_SCHED_LIMIT 64
|
2007-09-12 05:07:31 +08:00
|
|
|
static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct usb_hcd *hcd;
|
|
|
|
struct ehci_hcd *ehci;
|
|
|
|
unsigned long flags;
|
|
|
|
union ehci_shadow p, *seen;
|
|
|
|
unsigned temp, size, seen_count;
|
|
|
|
char *next;
|
|
|
|
unsigned i;
|
2007-05-02 00:29:37 +08:00
|
|
|
__hc32 tag;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-01-26 09:45:07 +08:00
|
|
|
seen = kmalloc_array(DBG_SCHED_LIMIT, sizeof(*seen), GFP_ATOMIC);
|
2015-04-30 17:32:50 +08:00
|
|
|
if (!seen)
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
seen_count = 0;
|
|
|
|
|
2007-09-12 05:07:31 +08:00
|
|
|
hcd = bus_to_hcd(buf->bus);
|
2016-01-26 09:44:53 +08:00
|
|
|
ehci = hcd_to_ehci(hcd);
|
2008-09-18 23:06:21 +08:00
|
|
|
next = buf->output_buf;
|
|
|
|
size = buf->alloc_size;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size, "size = %d\n", ehci->periodic_size);
|
2005-04-17 06:20:36 +08:00
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
|
2016-01-26 09:44:55 +08:00
|
|
|
/*
|
|
|
|
* dump a snapshot of the periodic schedule.
|
2005-04-17 06:20:36 +08:00
|
|
|
* iso changes, interrupt usually doesn't.
|
|
|
|
*/
|
2016-01-26 09:44:53 +08:00
|
|
|
spin_lock_irqsave(&ehci->lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
for (i = 0; i < ehci->periodic_size; i++) {
|
2016-01-26 09:44:54 +08:00
|
|
|
p = ehci->pshadow[i];
|
2016-01-26 09:44:53 +08:00
|
|
|
if (likely(!p.ptr))
|
2005-04-17 06:20:36 +08:00
|
|
|
continue;
|
2016-01-26 09:44:54 +08:00
|
|
|
tag = Q_NEXT_TYPE(ehci, ehci->periodic[i]);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size, "%4d: ", i);
|
2005-04-17 06:20:36 +08:00
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
|
|
|
|
do {
|
2009-07-14 07:23:29 +08:00
|
|
|
struct ehci_qh_hw *hw;
|
|
|
|
|
2007-05-02 00:29:37 +08:00
|
|
|
switch (hc32_to_cpu(ehci, tag)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
case Q_TYPE_QH:
|
2009-07-14 07:23:29 +08:00
|
|
|
hw = p.qh->hw;
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size, " qh%d-%04x/%p",
|
2013-10-11 23:29:03 +08:00
|
|
|
p.qh->ps.period,
|
2007-05-02 00:29:37 +08:00
|
|
|
hc32_to_cpup(ehci,
|
2009-07-14 07:23:29 +08:00
|
|
|
&hw->hw_info2)
|
2005-04-17 06:20:36 +08:00
|
|
|
/* uframe masks */
|
2005-08-05 09:06:41 +08:00
|
|
|
& (QH_CMASK | QH_SMASK),
|
2005-04-17 06:20:36 +08:00
|
|
|
p.qh);
|
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
/* don't repeat what follows this qh */
|
|
|
|
for (temp = 0; temp < seen_count; temp++) {
|
2016-01-26 09:44:54 +08:00
|
|
|
if (seen[temp].ptr != p.ptr)
|
2005-04-17 06:20:36 +08:00
|
|
|
continue;
|
2008-09-18 23:06:38 +08:00
|
|
|
if (p.qh->qh_next.ptr) {
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size,
|
2005-04-17 06:20:36 +08:00
|
|
|
" ...");
|
2008-09-18 23:06:38 +08:00
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* show more info the first time around */
|
2008-09-18 23:06:38 +08:00
|
|
|
if (temp == seen_count) {
|
2016-01-26 09:45:08 +08:00
|
|
|
temp = output_buf_tds_dir(next, ehci,
|
|
|
|
hw, p.qh, size);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (seen_count < DBG_SCHED_LIMIT)
|
2016-01-26 09:44:54 +08:00
|
|
|
seen[seen_count++].qh = p.qh;
|
2016-01-26 09:45:06 +08:00
|
|
|
} else {
|
2005-04-17 06:20:36 +08:00
|
|
|
temp = 0;
|
2016-01-26 09:45:06 +08:00
|
|
|
}
|
2012-09-20 05:00:55 +08:00
|
|
|
tag = Q_NEXT_TYPE(ehci, hw->hw_next);
|
|
|
|
p = p.qh->qh_next;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case Q_TYPE_FSTN:
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size,
|
2005-04-17 06:20:36 +08:00
|
|
|
" fstn-%8x/%p", p.fstn->hw_prev,
|
|
|
|
p.fstn);
|
2007-05-02 00:29:37 +08:00
|
|
|
tag = Q_NEXT_TYPE(ehci, p.fstn->hw_next);
|
2005-04-17 06:20:36 +08:00
|
|
|
p = p.fstn->fstn_next;
|
|
|
|
break;
|
|
|
|
case Q_TYPE_ITD:
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size,
|
2005-04-17 06:20:36 +08:00
|
|
|
" itd/%p", p.itd);
|
2007-05-02 00:29:37 +08:00
|
|
|
tag = Q_NEXT_TYPE(ehci, p.itd->hw_next);
|
2005-04-17 06:20:36 +08:00
|
|
|
p = p.itd->itd_next;
|
|
|
|
break;
|
|
|
|
case Q_TYPE_SITD:
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size,
|
2005-04-17 06:20:36 +08:00
|
|
|
" sitd%d-%04x/%p",
|
2013-10-11 23:29:03 +08:00
|
|
|
p.sitd->stream->ps.period,
|
2007-05-02 00:29:37 +08:00
|
|
|
hc32_to_cpup(ehci, &p.sitd->hw_uframe)
|
2005-04-17 06:20:36 +08:00
|
|
|
& 0x0000ffff,
|
|
|
|
p.sitd);
|
2007-05-02 00:29:37 +08:00
|
|
|
tag = Q_NEXT_TYPE(ehci, p.sitd->hw_next);
|
2005-04-17 06:20:36 +08:00
|
|
|
p = p.sitd->sitd_next;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
} while (p.ptr);
|
|
|
|
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size, "\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
}
|
2016-01-26 09:44:53 +08:00
|
|
|
spin_unlock_irqrestore(&ehci->lock, flags);
|
|
|
|
kfree(seen);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-09-18 23:06:21 +08:00
|
|
|
return buf->alloc_size - size;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
#undef DBG_SCHED_LIMIT
|
|
|
|
|
2011-08-19 04:31:30 +08:00
|
|
|
static const char *rh_state_string(struct ehci_hcd *ehci)
|
|
|
|
{
|
|
|
|
switch (ehci->rh_state) {
|
|
|
|
case EHCI_RH_HALTED:
|
|
|
|
return "halted";
|
|
|
|
case EHCI_RH_SUSPENDED:
|
|
|
|
return "suspended";
|
|
|
|
case EHCI_RH_RUNNING:
|
|
|
|
return "running";
|
2012-07-11 23:21:48 +08:00
|
|
|
case EHCI_RH_STOPPING:
|
|
|
|
return "stopping";
|
2011-08-19 04:31:30 +08:00
|
|
|
}
|
|
|
|
return "?";
|
|
|
|
}
|
|
|
|
|
2007-09-12 05:07:31 +08:00
|
|
|
static ssize_t fill_registers_buffer(struct debug_buffer *buf)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct usb_hcd *hcd;
|
|
|
|
struct ehci_hcd *ehci;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned temp, size, i;
|
2016-01-26 09:44:54 +08:00
|
|
|
char *next, scratch[80];
|
|
|
|
static char fmt[] = "%*s\n";
|
|
|
|
static char label[] = "";
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-09-12 05:07:31 +08:00
|
|
|
hcd = bus_to_hcd(buf->bus);
|
2016-01-26 09:44:53 +08:00
|
|
|
ehci = hcd_to_ehci(hcd);
|
2008-09-18 23:06:21 +08:00
|
|
|
next = buf->output_buf;
|
|
|
|
size = buf->alloc_size;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-01-26 09:44:53 +08:00
|
|
|
spin_lock_irqsave(&ehci->lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-06-23 04:39:10 +08:00
|
|
|
if (!HCD_HW_ACCESSIBLE(hcd)) {
|
2016-01-26 09:44:53 +08:00
|
|
|
size = scnprintf(next, size,
|
2008-10-02 23:47:15 +08:00
|
|
|
"bus %s, device %s\n"
|
2005-05-08 04:21:50 +08:00
|
|
|
"%s\n"
|
2005-04-17 06:20:36 +08:00
|
|
|
"SUSPENDED (no register access)\n",
|
|
|
|
hcd->self.controller->bus->name,
|
2008-05-02 12:02:41 +08:00
|
|
|
dev_name(hcd->self.controller),
|
2005-05-08 04:21:50 +08:00
|
|
|
hcd->product_desc);
|
2005-04-17 06:20:36 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Capability Registers */
|
2011-05-04 02:11:57 +08:00
|
|
|
i = HC_VERSION(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase));
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size,
|
2008-10-02 23:47:15 +08:00
|
|
|
"bus %s, device %s\n"
|
2005-05-08 04:21:50 +08:00
|
|
|
"%s\n"
|
2011-08-19 04:31:30 +08:00
|
|
|
"EHCI %x.%02x, rh state %s\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
hcd->self.controller->bus->name,
|
2008-05-02 12:02:41 +08:00
|
|
|
dev_name(hcd->self.controller),
|
2005-05-08 04:21:50 +08:00
|
|
|
hcd->product_desc,
|
2011-08-19 04:31:30 +08:00
|
|
|
i >> 8, i & 0x0ff, rh_state_string(ehci));
|
2005-04-17 06:20:36 +08:00
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
|
2005-05-08 04:21:50 +08:00
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
/* EHCI 0.96 and later may have "extended capabilities" */
|
2013-12-05 19:21:32 +08:00
|
|
|
if (dev_is_pci(hcd->self.controller)) {
|
2005-05-08 04:21:50 +08:00
|
|
|
struct pci_dev *pdev;
|
|
|
|
u32 offset, cap, cap2;
|
2016-01-26 09:44:58 +08:00
|
|
|
unsigned count = 256 / 4;
|
2005-05-08 04:21:50 +08:00
|
|
|
|
|
|
|
pdev = to_pci_dev(ehci_to_hcd(ehci)->self.controller);
|
2007-05-02 00:29:37 +08:00
|
|
|
offset = HCC_EXT_CAPS(ehci_readl(ehci,
|
|
|
|
&ehci->caps->hcc_params));
|
2005-05-08 04:21:50 +08:00
|
|
|
while (offset && count--) {
|
2016-01-26 09:44:53 +08:00
|
|
|
pci_read_config_dword(pdev, offset, &cap);
|
2005-05-08 04:21:50 +08:00
|
|
|
switch (cap & 0xff) {
|
|
|
|
case 1:
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size,
|
2005-05-08 04:21:50 +08:00
|
|
|
"ownership %08x%s%s\n", cap,
|
|
|
|
(cap & (1 << 24)) ? " linux" : "",
|
|
|
|
(cap & (1 << 16)) ? " firmware" : "");
|
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
|
|
|
|
offset += 4;
|
2016-01-26 09:44:53 +08:00
|
|
|
pci_read_config_dword(pdev, offset, &cap2);
|
|
|
|
temp = scnprintf(next, size,
|
2005-05-08 04:21:50 +08:00
|
|
|
"SMI sts/enable 0x%08x\n", cap2);
|
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
break;
|
|
|
|
case 0: /* illegal reserved capability */
|
|
|
|
cap = 0;
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
default: /* unknown */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
temp = (cap >> 8) & 0xff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-01-26 09:44:55 +08:00
|
|
|
/* FIXME interpret both types of params */
|
2006-12-15 03:54:08 +08:00
|
|
|
i = ehci_readl(ehci, &ehci->caps->hcs_params);
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size, "structural params 0x%08x\n", i);
|
2005-04-17 06:20:36 +08:00
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
|
2006-12-15 03:54:08 +08:00
|
|
|
i = ehci_readl(ehci, &ehci->caps->hcc_params);
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size, "capability params 0x%08x\n", i);
|
2005-04-17 06:20:36 +08:00
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
|
|
|
|
/* Operational Registers */
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = dbg_status_buf(scratch, sizeof(scratch), label,
|
2006-12-15 03:54:08 +08:00
|
|
|
ehci_readl(ehci, &ehci->regs->status));
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size, fmt, temp, scratch);
|
2005-04-17 06:20:36 +08:00
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = dbg_command_buf(scratch, sizeof(scratch), label,
|
2006-12-15 03:54:08 +08:00
|
|
|
ehci_readl(ehci, &ehci->regs->command));
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size, fmt, temp, scratch);
|
2005-04-17 06:20:36 +08:00
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = dbg_intr_buf(scratch, sizeof(scratch), label,
|
2006-12-15 03:54:08 +08:00
|
|
|
ehci_readl(ehci, &ehci->regs->intr_enable));
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size, fmt, temp, scratch);
|
2005-04-17 06:20:36 +08:00
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size, "uframe %04x\n",
|
2011-10-12 22:39:14 +08:00
|
|
|
ehci_read_frame_index(ehci));
|
2005-04-17 06:20:36 +08:00
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
|
2016-01-26 09:44:53 +08:00
|
|
|
for (i = 1; i <= HCS_N_PORTS(ehci->hcs_params); i++) {
|
|
|
|
temp = dbg_port_buf(scratch, sizeof(scratch), label, i,
|
2007-05-02 00:29:37 +08:00
|
|
|
ehci_readl(ehci,
|
|
|
|
&ehci->regs->port_status[i - 1]));
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size, fmt, temp, scratch);
|
2005-04-17 06:20:36 +08:00
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
2005-05-08 04:21:50 +08:00
|
|
|
if (i == HCS_DEBUG_PORT(ehci->hcs_params) && ehci->debug) {
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size,
|
2005-05-08 04:21:50 +08:00
|
|
|
" debug control %08x\n",
|
2007-05-02 00:29:37 +08:00
|
|
|
ehci_readl(ehci,
|
|
|
|
&ehci->debug->control));
|
2005-05-08 04:21:50 +08:00
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2013-03-23 01:31:45 +08:00
|
|
|
if (!list_empty(&ehci->async_unlink)) {
|
2012-07-11 23:21:38 +08:00
|
|
|
temp = scnprintf(next, size, "async unlink qh %p\n",
|
2013-03-23 01:31:45 +08:00
|
|
|
list_first_entry(&ehci->async_unlink,
|
|
|
|
struct ehci_qh, unlink_node));
|
2005-04-17 06:20:36 +08:00
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef EHCI_STATS
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size,
|
2012-07-11 23:21:38 +08:00
|
|
|
"irq normal %ld err %ld iaa %ld (lost %ld)\n",
|
|
|
|
ehci->stats.normal, ehci->stats.error, ehci->stats.iaa,
|
2005-04-17 06:20:36 +08:00
|
|
|
ehci->stats.lost_iaa);
|
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
|
2016-01-26 09:44:53 +08:00
|
|
|
temp = scnprintf(next, size, "complete %ld unlink %ld\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
ehci->stats.complete, ehci->stats.unlink);
|
|
|
|
size -= temp;
|
|
|
|
next += temp;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
done:
|
2016-01-26 09:44:53 +08:00
|
|
|
spin_unlock_irqrestore(&ehci->lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-09-18 23:06:21 +08:00
|
|
|
return buf->alloc_size - size;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-09-12 05:07:31 +08:00
|
|
|
static struct debug_buffer *alloc_buffer(struct usb_bus *bus,
|
2016-01-26 09:45:00 +08:00
|
|
|
ssize_t (*fill_func)(struct debug_buffer *))
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-09-12 05:07:31 +08:00
|
|
|
struct debug_buffer *buf;
|
|
|
|
|
2016-01-26 09:45:05 +08:00
|
|
|
buf = kzalloc(sizeof(*buf), GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-09-12 05:07:31 +08:00
|
|
|
if (buf) {
|
|
|
|
buf->bus = bus;
|
|
|
|
buf->fill_func = fill_func;
|
|
|
|
mutex_init(&buf->mutex);
|
2008-09-18 23:06:21 +08:00
|
|
|
buf->alloc_size = PAGE_SIZE;
|
2007-09-12 05:07:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return buf;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-09-12 05:07:31 +08:00
|
|
|
static int fill_buffer(struct debug_buffer *buf)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-09-12 05:07:31 +08:00
|
|
|
int ret = 0;
|
|
|
|
|
2008-09-18 23:06:21 +08:00
|
|
|
if (!buf->output_buf)
|
2010-11-09 07:10:52 +08:00
|
|
|
buf->output_buf = vmalloc(buf->alloc_size);
|
2007-09-12 05:07:31 +08:00
|
|
|
|
2008-09-18 23:06:21 +08:00
|
|
|
if (!buf->output_buf) {
|
2007-09-12 05:07:31 +08:00
|
|
|
ret = -ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = buf->fill_func(buf);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-09-12 05:07:31 +08:00
|
|
|
if (ret >= 0) {
|
|
|
|
buf->count = ret;
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
return ret;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-09-12 05:07:31 +08:00
|
|
|
static ssize_t debug_output(struct file *file, char __user *user_buf,
|
2016-01-26 09:45:00 +08:00
|
|
|
size_t len, loff_t *offset)
|
2007-09-12 05:07:31 +08:00
|
|
|
{
|
|
|
|
struct debug_buffer *buf = file->private_data;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
mutex_lock(&buf->mutex);
|
|
|
|
if (buf->count == 0) {
|
|
|
|
ret = fill_buffer(buf);
|
|
|
|
if (ret != 0) {
|
|
|
|
mutex_unlock(&buf->mutex);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mutex_unlock(&buf->mutex);
|
|
|
|
|
|
|
|
ret = simple_read_from_buffer(user_buf, len, offset,
|
2008-09-18 23:06:21 +08:00
|
|
|
buf->output_buf, buf->count);
|
2007-09-12 05:07:31 +08:00
|
|
|
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int debug_close(struct inode *inode, struct file *file)
|
|
|
|
{
|
|
|
|
struct debug_buffer *buf = file->private_data;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-09-12 05:07:31 +08:00
|
|
|
if (buf) {
|
2009-06-06 20:31:49 +08:00
|
|
|
vfree(buf->output_buf);
|
2007-09-12 05:07:31 +08:00
|
|
|
kfree(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2013-10-11 23:29:13 +08:00
|
|
|
|
2007-09-12 05:07:31 +08:00
|
|
|
static int debug_async_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
|
|
|
file->private_data = alloc_buffer(inode->i_private, fill_async_buffer);
|
|
|
|
|
|
|
|
return file->private_data ? 0 : -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2013-10-11 23:29:13 +08:00
|
|
|
static int debug_bandwidth_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
|
|
|
file->private_data = alloc_buffer(inode->i_private,
|
|
|
|
fill_bandwidth_buffer);
|
|
|
|
|
|
|
|
return file->private_data ? 0 : -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2007-09-12 05:07:31 +08:00
|
|
|
static int debug_periodic_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
2008-09-18 23:06:21 +08:00
|
|
|
struct debug_buffer *buf;
|
2016-01-26 09:45:03 +08:00
|
|
|
|
2008-09-18 23:06:21 +08:00
|
|
|
buf = alloc_buffer(inode->i_private, fill_periodic_buffer);
|
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
2007-09-12 05:07:31 +08:00
|
|
|
|
2016-01-26 09:44:58 +08:00
|
|
|
buf->alloc_size = (sizeof(void *) == 4 ? 6 : 8) * PAGE_SIZE;
|
2008-09-18 23:06:21 +08:00
|
|
|
file->private_data = buf;
|
|
|
|
return 0;
|
2007-09-12 05:07:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int debug_registers_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
|
|
|
file->private_data = alloc_buffer(inode->i_private,
|
|
|
|
fill_registers_buffer);
|
|
|
|
|
|
|
|
return file->private_data ? 0 : -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2016-01-26 09:44:53 +08:00
|
|
|
static inline void create_debug_files(struct ehci_hcd *ehci)
|
2007-09-12 05:07:31 +08:00
|
|
|
{
|
|
|
|
struct usb_bus *bus = &ehci_to_hcd(ehci)->self;
|
|
|
|
|
|
|
|
ehci->debug_dir = debugfs_create_dir(bus->bus_name, ehci_debug_root);
|
|
|
|
if (!ehci->debug_dir)
|
2010-07-28 22:33:28 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!debugfs_create_file("async", S_IRUGO, ehci->debug_dir, bus,
|
|
|
|
&debug_async_fops))
|
|
|
|
goto file_error;
|
|
|
|
|
2013-10-11 23:29:13 +08:00
|
|
|
if (!debugfs_create_file("bandwidth", S_IRUGO, ehci->debug_dir, bus,
|
|
|
|
&debug_bandwidth_fops))
|
|
|
|
goto file_error;
|
|
|
|
|
2010-07-28 22:33:28 +08:00
|
|
|
if (!debugfs_create_file("periodic", S_IRUGO, ehci->debug_dir, bus,
|
|
|
|
&debug_periodic_fops))
|
|
|
|
goto file_error;
|
|
|
|
|
|
|
|
if (!debugfs_create_file("registers", S_IRUGO, ehci->debug_dir, bus,
|
|
|
|
&debug_registers_fops))
|
|
|
|
goto file_error;
|
|
|
|
|
2007-09-12 05:07:31 +08:00
|
|
|
return;
|
|
|
|
|
2010-07-28 22:33:28 +08:00
|
|
|
file_error:
|
|
|
|
debugfs_remove_recursive(ehci->debug_dir);
|
2007-09-12 05:07:31 +08:00
|
|
|
}
|
|
|
|
|
2016-01-26 09:44:53 +08:00
|
|
|
static inline void remove_debug_files(struct ehci_hcd *ehci)
|
2007-09-12 05:07:31 +08:00
|
|
|
{
|
2010-07-28 22:33:28 +08:00
|
|
|
debugfs_remove_recursive(ehci->debug_dir);
|
2007-09-12 05:07:31 +08:00
|
|
|
}
|
|
|
|
|
2016-04-30 03:19:56 +08:00
|
|
|
#else /* CONFIG_DYNAMIC_DEBUG */
|
|
|
|
|
|
|
|
static inline void dbg_hcs_params(struct ehci_hcd *ehci, char *label) { }
|
|
|
|
static inline void dbg_hcc_params(struct ehci_hcd *ehci, char *label) { }
|
|
|
|
|
|
|
|
static inline void __maybe_unused dbg_qh(const char *label,
|
|
|
|
struct ehci_hcd *ehci, struct ehci_qh *qh) { }
|
|
|
|
|
|
|
|
static inline int __maybe_unused dbg_status_buf(const char *buf,
|
|
|
|
unsigned int len, const char *label, u32 status)
|
|
|
|
{ return 0; }
|
|
|
|
|
|
|
|
static inline int __maybe_unused dbg_command_buf(const char *buf,
|
|
|
|
unsigned int len, const char *label, u32 command)
|
|
|
|
{ return 0; }
|
|
|
|
|
|
|
|
static inline int __maybe_unused dbg_intr_buf(const char *buf,
|
|
|
|
unsigned int len, const char *label, u32 enable)
|
|
|
|
{ return 0; }
|
|
|
|
|
|
|
|
static inline int __maybe_unused dbg_port_buf(char *buf,
|
|
|
|
unsigned int len, const char *label, int port, u32 status)
|
|
|
|
{ return 0; }
|
|
|
|
|
|
|
|
static inline void dbg_status(struct ehci_hcd *ehci, const char *label,
|
|
|
|
u32 status) { }
|
|
|
|
static inline void dbg_cmd(struct ehci_hcd *ehci, const char *label,
|
|
|
|
u32 command) { }
|
|
|
|
static inline void dbg_port(struct ehci_hcd *ehci, const char *label,
|
|
|
|
int port, u32 status) { }
|
|
|
|
|
|
|
|
static inline void create_debug_files(struct ehci_hcd *bus) { }
|
|
|
|
static inline void remove_debug_files(struct ehci_hcd *bus) { }
|
|
|
|
|
2016-01-26 09:45:09 +08:00
|
|
|
#endif /* CONFIG_DYNAMIC_DEBUG */
|