Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb remove debug printf



details:   https://anonhg.NetBSD.org/src/rev/17ee0efc43d3
branches:  trunk
changeset: 364696:17ee0efc43d3
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Wed Apr 06 21:51:29 2022 +0000

description:
remove debug printf

diffstat:

 sys/dev/usb/ehci.c       |   13 +-
 sys/dev/usb/if_smscreg.h |    4 +-
 sys/dev/usb/if_urtwn.c   |    7 +-
 sys/dev/usb/ubt.c        |   28 +++-
 sys/dev/usb/uhub.c       |   28 ++++-
 sys/dev/usb/ukbd.c       |    7 +-
 sys/dev/usb/usb_subr.c   |   17 ++-
 sys/dev/usb/usbdi.c      |   10 +-
 sys/dev/usb/uvideo.c     |   34 ++--
 sys/dev/usb/xhci.c       |  281 ++++++++++++++++++++++++++++++----------------
 sys/dev/usb/xhcireg.h    |   11 +-
 11 files changed, 291 insertions(+), 149 deletions(-)

diffs (truncated from 848 to 300 lines):

diff -r 0213000511b5 -r 17ee0efc43d3 sys/dev/usb/ehci.c
--- a/sys/dev/usb/ehci.c        Wed Apr 06 17:37:31 2022 +0000
+++ b/sys/dev/usb/ehci.c        Wed Apr 06 21:51:29 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ehci.c,v 1.309 2022/03/13 11:29:21 riastradh Exp $ */
+/*     $NetBSD: ehci.c,v 1.310 2022/04/06 21:51:29 mlelstv Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.309 2022/03/13 11:29:21 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.310 2022/04/06 21:51:29 mlelstv Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -790,6 +790,9 @@
        if (eintrs & EHCI_STS_HSE) {
                printf("%s: unrecoverable error, controller halted\n",
                       device_xname(sc->sc_dev));
+#ifdef EHCI_DEBUG
+               ehci_dump();
+#endif
                /* XXX what else */
        }
        if (eintrs & EHCI_STS_PCD) {
@@ -2241,6 +2244,7 @@
        unsigned starttime = getticks();
        unsigned endtime = starttime + delta;
        unsigned now;
+       uint32_t v;
 
        KASSERT(mutex_owned(&sc->sc_lock));
 
@@ -2260,7 +2264,10 @@
        sc->sc_doorbelllwp = curlwp;
 
        /* ask for doorbell */
-       EOWRITE4(sc, EHCI_USBCMD, EOREAD4(sc, EHCI_USBCMD) | EHCI_CMD_IAAD);
+       v = EOREAD4(sc, EHCI_USBCMD);
+       if ((v & EHCI_CMD_IAAD) == 0)
+               EOWRITE4(sc, EHCI_USBCMD, v | EHCI_CMD_IAAD);
+
        DPRINTF("cmd = 0x%08jx sts = 0x%08jx",
            EOREAD4(sc, EHCI_USBCMD), EOREAD4(sc, EHCI_USBSTS), 0, 0);
 
diff -r 0213000511b5 -r 17ee0efc43d3 sys/dev/usb/if_smscreg.h
--- a/sys/dev/usb/if_smscreg.h  Wed Apr 06 17:37:31 2022 +0000
+++ b/sys/dev/usb/if_smscreg.h  Wed Apr 06 21:51:29 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_smscreg.h,v 1.6 2019/08/12 08:40:09 skrll Exp $     */
+/*     $NetBSD: if_smscreg.h,v 1.7 2022/04/06 21:51:29 mlelstv Exp $   */
 
 /*     $OpenBSD: if_smscreg.h,v 1.2 2012/09/27 12:38:11 jsg Exp $      */
 /*-
@@ -244,7 +244,7 @@
 #define SMSC_UR_GET_STATS      0xA2
 
 #define SMSC_RX_LIST_CNT       1
-#define SMSC_TX_LIST_CNT       1
+#define SMSC_TX_LIST_CNT       2
 
 #define        SMSC_CONFIG_INDEX       1       /* config number 1 */
 #define        SMSC_IFACE_IDX          0
diff -r 0213000511b5 -r 17ee0efc43d3 sys/dev/usb/if_urtwn.c
--- a/sys/dev/usb/if_urtwn.c    Wed Apr 06 17:37:31 2022 +0000
+++ b/sys/dev/usb/if_urtwn.c    Wed Apr 06 21:51:29 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_urtwn.c,v 1.101 2021/10/21 20:18:16 jnemeth Exp $   */
+/*     $NetBSD: if_urtwn.c,v 1.102 2022/04/06 21:51:29 mlelstv Exp $   */
 /*     $OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $       */
 
 /*-
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.101 2021/10/21 20:18:16 jnemeth Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.102 2022/04/06 21:51:29 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2623,7 +2623,8 @@
                                struct usbd_pipe *pipe = sc->tx_pipe[pidx];
                                usbd_clear_endpoint_stall_async(pipe);
                        }
-                       device_printf(sc->sc_dev, "device timeout\n");
+                       device_printf(sc->sc_dev, "device error %s\n",
+                                     usbd_errstr(status));
                        if_statinc(ifp, if_oerrors);
                }
                splx(s);
diff -r 0213000511b5 -r 17ee0efc43d3 sys/dev/usb/ubt.c
--- a/sys/dev/usb/ubt.c Wed Apr 06 17:37:31 2022 +0000
+++ b/sys/dev/usb/ubt.c Wed Apr 06 21:51:29 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ubt.c,v 1.64 2019/12/01 08:27:54 maxv Exp $    */
+/*     $NetBSD: ubt.c,v 1.65 2022/04/06 21:51:29 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ubt.c,v 1.64 2019/12/01 08:27:54 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ubt.c,v 1.65 2022/04/06 21:51:29 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1456,7 +1456,7 @@
                             isoc,
                             isoc->size,
                             num,
-                            USBD_FORCE_SHORT_XFER,
+                            USBD_FORCE_SHORT_XFER | USBD_SHORT_XFER_OK,
                             ubt_xmit_sco_complete);
 
        usbd_transfer(isoc->xfer);
@@ -1777,11 +1777,11 @@
                        if (m == NULL) {
                                MGETHDR(m, M_DONTWAIT, MT_DATA);
                                if (m == NULL) {
-                                       aprint_error_dev(sc->sc_dev,
+                                       device_printf(sc->sc_dev,
                                            "out of memory (xfer halted)\n");
 
                                        sc->sc_stats.err_rx++;
-                                       return;         /* lost sync */
+                                       return; /* lost sync */
                                }
 
                                ptr = mtod(m, uint8_t *);
@@ -1808,14 +1808,21 @@
                                if (want == sizeof(hci_scodata_hdr_t)) {
                                        uint32_t len =
                                            mtod(m, hci_scodata_hdr_t *)->length;
-                                       want += len;
-                                       if (len == 0 || want > MHLEN) {
-                                               aprint_error_dev(sc->sc_dev,
+                                       if (len == 0) {
+                                               ptr = mtod(m, uint8_t *);
+                                               ptr++;
+                                               got = 1;
+                                       } else if (want > MHLEN) {
+                                               device_printf(sc->sc_dev,
                                                    "packet too large %u "
                                                    "(lost sync)\n", len);
                                                sc->sc_stats.err_rx++;
+
+                                               /* lost sync */
+                                               m_freem(m);
                                                return;
-                                       }
+                                       } else
+                                               want += len;
                                }
 
                                if (got == want) {
@@ -1825,6 +1832,9 @@
                                                sc->sc_stats.err_rx++;
 
                                        m = NULL;
+                                       ptr = NULL;
+                                       got = 0;
+                                       want = 0;
                                }
                        }
 
diff -r 0213000511b5 -r 17ee0efc43d3 sys/dev/usb/uhub.c
--- a/sys/dev/usb/uhub.c        Wed Apr 06 17:37:31 2022 +0000
+++ b/sys/dev/usb/uhub.c        Wed Apr 06 21:51:29 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhub.c,v 1.159 2022/02/04 23:03:38 riastradh Exp $     */
+/*     $NetBSD: uhub.c,v 1.160 2022/04/06 21:51:29 mlelstv Exp $       */
 /*     $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $       */
 /*     $OpenBSD: uhub.c,v 1.86 2015/06/29 18:27:40 mpi Exp $ */
 
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.159 2022/02/04 23:03:38 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.160 2022/04/06 21:51:29 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -563,9 +563,29 @@
                for (port = 1; port <= hd->bNbrPorts; port++) {
                        SDT_PROBE3(usb, hub, explore, rescan,
                            dev, port, &dev->ud_hub->uh_ports[port - 1]);
-                       subdev = dev->ud_hub->uh_ports[port - 1].up_dev;
+                       up = &dev->ud_hub->uh_ports[port - 1];
+                       subdev = up->up_dev;
                        if (subdev == NULL)
                                continue;
+
+                       err = usbd_get_port_status(subdev, port, &up->up_status);
+                       if (err) {
+                               DPRINTF("uhub%jd get port stat failed, err %jd",
+                               device_unit(sc->sc_dev), err, 0, 0);
+                               continue;
+                       }
+
+                       change = UGETW(up->up_status.wPortChange);
+                       if ((change & UPS_C_PORT_ENABLED) == 0) {
+                               if (usbd_reset_port(subdev, port, &up->up_status)) {
+                                       device_printf(sc->sc_dev,
+                                       "port %d reset failed\n", port);
+                                       continue;
+                               }
+                               device_printf(sc->sc_dev,
+                                   "port %d reset succeeded\n", port);
+                       }
+
                        usbd_reattach_device(sc->sc_dev, subdev, port, NULL);
                }
        }
@@ -864,7 +884,7 @@
                         * some other serious problem.  Since we cannot leave
                         * at 0 we have to disable the port instead.
                         */
-                       aprint_error_dev(sc->sc_dev,
+                       device_printf(sc->sc_dev,
                            "device problem, disabling port %d\n", port);
                        usbd_clear_port_feature(dev, port, UHF_PORT_ENABLE);
                } else {
diff -r 0213000511b5 -r 17ee0efc43d3 sys/dev/usb/ukbd.c
--- a/sys/dev/usb/ukbd.c        Wed Apr 06 17:37:31 2022 +0000
+++ b/sys/dev/usb/ukbd.c        Wed Apr 06 21:51:29 2022 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: ukbd.c,v 1.160 2022/04/02 19:19:12 mlelstv Exp $        */
+/*      $NetBSD: ukbd.c,v 1.161 2022/04/06 21:51:29 mlelstv Exp $        */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.160 2022/04/02 19:19:12 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.161 2022/04/06 21:51:29 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1083,9 +1083,6 @@
        sc->sc_nkeycode = 0;
        d = hid_start_parse(desc, size, hid_input);
        while (hid_get_item(d, &h)) {
-               printf("ukbd: id=%d kind=%d usage=%#x flags=%#x pos=%d size=%d cnt=%d\n",
-                 h.report_ID, h.kind, h.usage, h.flags, h.loc.pos, h.loc.size, h.loc.count);
-
                /* Check for special Apple notebook FN key */
                if (HID_GET_USAGE_PAGE(h.usage) == 0x00ff &&
                    HID_GET_USAGE(h.usage) == 0x0003 &&
diff -r 0213000511b5 -r 17ee0efc43d3 sys/dev/usb/usb_subr.c
--- a/sys/dev/usb/usb_subr.c    Wed Apr 06 17:37:31 2022 +0000
+++ b/sys/dev/usb/usb_subr.c    Wed Apr 06 21:51:29 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usb_subr.c,v 1.275 2022/03/19 20:50:32 riastradh Exp $ */
+/*     $NetBSD: usb_subr.c,v 1.276 2022/04/06 21:51:29 mlelstv Exp $   */
 /*     $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $   */
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.275 2022/03/19 20:50:32 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.276 2022/04/06 21:51:29 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -247,8 +247,11 @@
        /* Wait at least two clock ticks so we know the time has passed. */
        if (bus->ub_usepolling || cold)
                delay((ms+1) * 1000);
-       else
+       else {
+int timeo = (ms*hz+999)/1000 + 1;
+if (timeo > hz/2) printf("usb_delay_ms_locked(%p) %d ticks\n",lock,timeo);
                kpause("usbdly", false, (ms*hz+999)/1000 + 1, lock);
+       }
 }
 
 void
@@ -458,8 +461,16 @@
 {
 
        mutex_enter(iface->ui_dev->ud_bus->ub_lock);
+#if 1
+if (iface->ui_busy != 0) {
+       printf("%s: addr %d not idle, busy = %"PRId64"\n",
+               device_xname(iface->ui_dev->ud_bus->ub_usbctl),
+               iface->ui_dev->ud_addr, iface->ui_busy);
+}
+#else
        KASSERTMSG(iface->ui_busy == 0, "interface is not idle,"



Home | Main Index | Thread Index | Old Index