Ping
On Sat, Nov 27, 2021 at 09:36:32PM +0300, Mikhail wrote:
> While fiddling with ehci.c and fighting with urndis I noticed that most
> of the debugging printf's use explicit names, which is inconvenient for
> grep'ing. Also, couple of items used wrong function names
> (ehci_check_intr instead of ehci_check_qh_intr).
>
> Compilation tested with DIAGNOSTIC and EHCI_DEBUG defines.
>
> diff --git sys/dev/usb/ehci.c sys/dev/usb/ehci.c
> index afc423dbbb6..37ff3beeb7a 100644
> --- sys/dev/usb/ehci.c
> +++ sys/dev/usb/ehci.c
> @@ -314,10 +314,10 @@ ehci_init(struct ehci_softc *sc)
> sc->sc_offs = EREAD1(sc, EHCI_CAPLENGTH);
>
> sparams = EREAD4(sc, EHCI_HCSPARAMS);
> - DPRINTF(("ehci_init: sparams=0x%x\n", sparams));
> + DPRINTF(("%s: sparams=0x%x\n", __func__, sparams));
> sc->sc_noport = EHCI_HCS_N_PORTS(sparams);
> cparams = EREAD4(sc, EHCI_HCCPARAMS);
> - DPRINTF(("ehci_init: cparams=0x%x\n", cparams));
> + DPRINTF(("%s: cparams=0x%x\n", __func__, cparams));
>
> /* MUST clear segment register if 64 bit capable. */
> if (EHCI_HCC_64BIT(cparams))
> @@ -521,7 +521,7 @@ ehci_intr1(struct ehci_softc *sc)
> /* In case the interrupt occurs before initialization has completed. */
> if (sc == NULL) {
> #ifdef DIAGNOSTIC
> - printf("ehci_intr1: sc == NULL\n");
> + printf("%s: sc == NULL\n", __func__);
> #endif
> return (0);
> }
> @@ -704,7 +704,7 @@ ehci_check_qh_intr(struct ehci_softc *sc, struct
> usbd_xfer *xfer)
> * short packet (SPD and not ACTIVE).
> */
> if (letoh32(lsqtd->qtd.qtd_status) & EHCI_QTD_ACTIVE) {
> - DPRINTFN(12, ("ehci_check_intr: active ex=%p\n", ex));
> + DPRINTFN(12, ("%s: active ex=%p\n", __func__, ex));
> for (sqtd = ex->sqtdstart; sqtd != lsqtd; sqtd=sqtd->nextqtd) {
> usb_syncmem(&sqtd->dma,
> sqtd->offs + offsetof(struct ehci_qtd, qtd_status),
> @@ -724,7 +724,7 @@ ehci_check_qh_intr(struct ehci_softc *sc, struct
> usbd_xfer *xfer)
> if (EHCI_QTD_GET_BYTES(status) != 0)
> goto done;
> }
> - DPRINTFN(12, ("ehci_check_intr: ex=%p std=%p still active\n",
> + DPRINTFN(12, ("%s: ex=%p std=%p still active\n", __func__,
> ex, ex->sqtdstart));
> usb_syncmem(&lsqtd->dma,
> lsqtd->offs + offsetof(struct ehci_qtd, qtd_status),
> @@ -876,7 +876,7 @@ ehci_idone(struct usbd_xfer *xfer)
> int s = splhigh();
> if (ex->isdone) {
> splx(s);
> - printf("ehci_idone: ex=%p is done!\n", ex);
> + printf("%s: ex=%p is done!\n", __func__, ex);
> return;
> }
> ex->isdone = 1;
> @@ -904,8 +904,8 @@ ehci_idone(struct usbd_xfer *xfer)
> }
>
> cerr = EHCI_QTD_GET_CERR(status);
> - DPRINTFN(/*10*/2, ("ehci_idone: len=%d, actlen=%d, cerr=%d, "
> - "status=0x%x\n", xfer->length, actlen, cerr, status));
> + DPRINTFN(/*10*/2, ("%s: len=%d, actlen=%d, cerr=%d, "
> + "status=0x%x\n", __func__, xfer->length, actlen, cerr, status));
> xfer->actlen = actlen;
> if ((status & EHCI_QTD_HALTED) != 0) {
> if ((status & EHCI_QTD_BABBLE) == 0 && cerr > 0)
> @@ -920,7 +920,7 @@ ehci_idone(struct usbd_xfer *xfer)
> usbd_xfer_isread(xfer) ?
> BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
> usb_transfer_complete(xfer);
> - DPRINTFN(/*12*/2, ("ehci_idone: ex=%p done\n", ex));
> + DPRINTFN(/*12*/2, ("%s: ex=%p done\n", __func__, ex));
> }
>
> void
> @@ -1367,7 +1367,7 @@ ehci_open(struct usbd_pipe *pipe)
> int ival, speed, naks;
> int hshubaddr, hshubport;
>
> - DPRINTFN(1, ("ehci_open: pipe=%p, addr=%d, endpt=%d\n",
> + DPRINTFN(1, ("%s: pipe=%p, addr=%d, endpt=%d\n", __func__,
> pipe, addr, ed->bEndpointAddress));
>
> if (sc->sc_bus.dying)
> @@ -1408,7 +1408,7 @@ ehci_open(struct usbd_pipe *pipe)
> speed = EHCI_QH_SPEED_HIGH;
> break;
> default:
> - panic("ehci_open: bad device speed %d", dev->speed);
> + panic("%s: bad device speed %d", __func__, dev->speed);
> }
>
> /*
> @@ -1512,18 +1512,18 @@ ehci_open(struct usbd_pipe *pipe)
> }
> /* Spec page 271 says intervals > 16 are invalid */
> if (ed->bInterval == 0 || ed->bInterval > 16) {
> - printf("ehci: opening pipe with invalid bInterval\n");
> + printf("%s: opening pipe with invalid bInterval\n",
> __func__);
> return (USBD_INVAL);
> }
> if (UGETW(ed->wMaxPacketSize) == 0) {
> - printf("ehci: zero length endpoint open request\n");
> + printf("%s: zero length endpoint open request\n",
> __func__);
> return (USBD_INVAL);
> }
> epipe->u.isoc.next_frame = 0;
> epipe->u.isoc.cur_xfers = 0;
> break;
> default:
> - DPRINTF(("ehci: bad xfer type %d\n", xfertype));
> + DPRINTF(("%s: bad xfer type %d\n", __func__, xfertype));
> return (USBD_INVAL);
> }
> return (USBD_NORMAL_COMPLETION);
> @@ -1641,7 +1641,7 @@ ehci_sync_hc(struct ehci_softc *sc)
> rw_exit_write(&sc->sc_doorbell_lock);
> #ifdef DIAGNOSTIC
> if (error)
> - printf("ehci_sync_hc: tsleep() = %d\n", error);
> + printf("%s: tsleep() = %d\n", __func__, error);
> #endif
> }
>
> @@ -1841,7 +1841,7 @@ ehci_root_ctrl_start(struct usbd_xfer *xfer)
> }
> break;
> case C(UR_GET_DESCRIPTOR, UT_READ_DEVICE):
> - DPRINTFN(8,("ehci_root_ctrl_start: wValue=0x%04x\n", value));
> + DPRINTFN(8,("%s: wValue=0x%04x\n", __func__, value));
> switch(value >> 8) {
> case UDESC_DEVICE:
> if ((value & 0xff) != 0) {
> @@ -1954,8 +1954,8 @@ ehci_root_ctrl_start(struct usbd_xfer *xfer)
> case C(UR_CLEAR_FEATURE, UT_WRITE_CLASS_DEVICE):
> break;
> case C(UR_CLEAR_FEATURE, UT_WRITE_CLASS_OTHER):
> - DPRINTFN(8, ("ehci_root_ctrl_start: UR_CLEAR_PORT_FEATURE "
> - "port=%d feature=%d\n", index, value));
> + DPRINTFN(8, ("%s: UR_CLEAR_PORT_FEATURE "
> + "port=%d feature=%d\n", __func__, index, value));
> if (index < 1 || index > sc->sc_noport) {
> err = USBD_IOERROR;
> goto ret;
> @@ -1973,12 +1973,10 @@ ehci_root_ctrl_start(struct usbd_xfer *xfer)
> EOWRITE4(sc, port, v &~ EHCI_PS_PP);
> break;
> case UHF_PORT_TEST:
> - DPRINTFN(2,("ehci_root_ctrl_start: "
> - "clear port test %d\n", index));
> + DPRINTFN(2,("%s: clear port test %d\n", __func__,
> index));
> break;
> case UHF_PORT_INDICATOR:
> - DPRINTFN(2,("ehci_root_ctrl_start: "
> - "clear port index %d\n", index));
> + DPRINTFN(2,("%s: clear port index %d\n", __func__,
> index));
> EOWRITE4(sc, port, v &~ EHCI_PS_PIC);
> break;
> case UHF_C_PORT_CONNECTION:
> @@ -2029,7 +2027,7 @@ ehci_root_ctrl_start(struct usbd_xfer *xfer)
> totlen = len;
> break;
> case C(UR_GET_STATUS, UT_READ_CLASS_OTHER):
> - DPRINTFN(8,("ehci_root_ctrl_start: get port status i=%d\n",
> + DPRINTFN(8,("%s: get port status i=%d\n", __func__,
> index));
> if (index < 1 || index > sc->sc_noport) {
> err = USBD_IOERROR;
> @@ -2040,7 +2038,7 @@ ehci_root_ctrl_start(struct usbd_xfer *xfer)
> goto ret;
> }
> v = EOREAD4(sc, EHCI_PORTSC(index));
> - DPRINTFN(8,("ehci_root_ctrl_start: port status=0x%04x\n", v));
> + DPRINTFN(8,("%s: port status=0x%04x\n", __func__, v));
> i = UPS_HIGH_SPEED;
> if (v & EHCI_PS_CS) i |= UPS_CURRENT_CONNECT_STATUS;
> if (v & EHCI_PS_PE) i |= UPS_PORT_ENABLED;
> @@ -2085,7 +2083,7 @@ ehci_root_ctrl_start(struct usbd_xfer *xfer)
> ehci_disown(sc, index, 0);
> break;
> case UHF_PORT_RESET:
> - DPRINTFN(5,("ehci_root_ctrl_start: reset port %d\n",
> + DPRINTFN(5,("%s: reset port %d\n", __func__,
> index));
> if (EHCI_PS_IS_LOWSPEED(v)) {
> /* Low speed device, give up ownership. */
> @@ -2128,17 +2126,14 @@ ehci_root_ctrl_start(struct usbd_xfer *xfer)
> index, v));
> break;
> case UHF_PORT_POWER:
> - DPRINTFN(2,("ehci_root_ctrl_start: "
> - "set port power %d\n", index));
> + DPRINTFN(2,("%s: set port power %d\n", __func__,
> index));
> EOWRITE4(sc, port, v | EHCI_PS_PP);
> break;
> case UHF_PORT_TEST:
> - DPRINTFN(2,("ehci_root_ctrl_start: "
> - "set port test %d\n", index));
> + DPRINTFN(2,("%s: set port test %d\n", __func__, index));
> break;
> case UHF_PORT_INDICATOR:
> - DPRINTFN(2,("ehci_root_ctrl_start: "
> - "set port ind %d\n", index));
> + DPRINTFN(2,("%s: set port ind %d\n", __func__, index));
> EOWRITE4(sc, port, v | EHCI_PS_PIC);
> break;
> default:
> @@ -2257,7 +2252,7 @@ ehci_alloc_sqh(struct ehci_softc *sc)
>
> s = splusb();
> if (sc->sc_freeqhs == NULL) {
> - DPRINTFN(2, ("ehci_alloc_sqh: allocating chunk\n"));
> + DPRINTFN(2, ("%s: allocating chunk\n", __func__));
> err = usb_allocmem(&sc->sc_bus, EHCI_SQH_SIZE * EHCI_SQH_CHUNK,
> EHCI_PAGE_SIZE, USB_DMA_COHERENT, &dma);
> if (err)
> @@ -2305,7 +2300,7 @@ ehci_alloc_sqtd(struct ehci_softc *sc)
>
> s = splusb();
> if (sc->sc_freeqtds == NULL) {
> - DPRINTFN(2, ("ehci_alloc_sqtd: allocating chunk\n"));
> + DPRINTFN(2, ("%s: allocating chunk\n", __func__));
> err = usb_allocmem(&sc->sc_bus, EHCI_SQTD_SIZE*EHCI_SQTD_CHUNK,
> EHCI_PAGE_SIZE, USB_DMA_COHERENT, &dma);
> if (err)
> @@ -2354,7 +2349,7 @@ ehci_alloc_sqtd_chain(struct ehci_softc *sc, u_int
> alen, struct usbd_xfer *xfer,
> int rd = usbd_xfer_isread(xfer);
> struct usb_dma *dma = &xfer->dmabuf;
>
> - DPRINTFN(alen<4*4096,("ehci_alloc_sqtd_chain: start len=%d\n", alen));
> + DPRINTFN(alen<4*4096,("%s: start len=%d\n", __func__, alen));
>
> len = alen;
> iscontrol = UE_GET_XFERTYPE(xfer->pipe->endpoint->edesc->bmAttributes)
> ==
> @@ -2395,8 +2390,8 @@ ehci_alloc_sqtd_chain(struct ehci_softc *sc, u_int
> alen, struct usbd_xfer *xfer,
> EHCI_PAGE_OFFSET(dataphys);
>
> if (curlen > len) {
> - DPRINTFN(1,("ehci_alloc_sqtd_chain: curlen=%u "
> - "len=%u offs=0x%x\n", curlen, len,
> + DPRINTFN(1,("%s: curlen=%u "
> + "len=%u offs=0x%x\n", __func__, curlen, len,
> EHCI_PAGE_OFFSET(dataphys)));
> DPRINTFN(1,("lastpage=0x%x page=0x%x
> phys=0x%x\n",
> dataphyslastpage, dataphyspage, dataphys));
> @@ -2405,12 +2400,12 @@ ehci_alloc_sqtd_chain(struct ehci_softc *sc, u_int
> alen, struct usbd_xfer *xfer,
>
> /* the length must be a multiple of the max size */
> curlen -= curlen % mps;
> - DPRINTFN(1,("ehci_alloc_sqtd_chain: multiple QTDs, "
> - "curlen=%u\n", curlen));
> + DPRINTFN(1,("%s: multiple QTDs, "
> + "curlen=%u\n", __func__, curlen));
> }
>
> - DPRINTFN(4,("ehci_alloc_sqtd_chain: dataphys=0x%08x "
> - "dataphyslastpage=0x%08x len=%u curlen=%u\n",
> + DPRINTFN(4,("%s: dataphys=0x%08x "
> + "dataphyslastpage=0x%08x len=%u curlen=%u\n", __func__,
> dataphys, dataphyslastpage, len, curlen));
> len -= curlen;
>
> @@ -2436,7 +2431,7 @@ ehci_alloc_sqtd_chain(struct ehci_softc *sc, u_int
> alen, struct usbd_xfer *xfer,
> a = EHCI_PAGE(a);
> #ifdef DIAGNOSTIC
> if (i >= EHCI_QTD_NBUFFERS) {
> - printf("ehci_alloc_sqtd_chain: i=%d\n", i);
> + printf("%s: i=%d\n", __func__, i);
> goto nomem;
> }
> #endif
> @@ -2448,9 +2443,9 @@ ehci_alloc_sqtd_chain(struct ehci_softc *sc, u_int
> alen, struct usbd_xfer *xfer,
> cur->qtd.qtd_status = htole32(qtdstatus |
> EHCI_QTD_SET_BYTES(curlen));
> cur->len = curlen;
> - DPRINTFN(10,("ehci_alloc_sqtd_chain: cbp=0x%08x end=0x%08x\n",
> + DPRINTFN(10,("%s: cbp=0x%08x end=0x%08x\n", __func__,
> dataphys, dataphys + curlen));
> - DPRINTFN(10,("ehci_alloc_sqtd_chain: curlen=%u\n", curlen));
> + DPRINTFN(10,("%s: curlen=%u\n", __func__, curlen));
> if (iscontrol) {
> /*
> * adjust the toggle based on the number of packets
> @@ -2466,7 +2461,7 @@ ehci_alloc_sqtd_chain(struct ehci_softc *sc, u_int
> alen, struct usbd_xfer *xfer,
> }
> usb_syncmem(&cur->dma, cur->offs, sizeof(cur->qtd),
> BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
> - DPRINTFN(10,("ehci_alloc_sqtd_chain: extend chain\n"));
> + DPRINTFN(10,("%s: extend chain\n", __func__));
> dataphys += curlen;
> cur = next;
> }
> @@ -2475,14 +2470,14 @@ ehci_alloc_sqtd_chain(struct ehci_softc *sc, u_int
> alen, struct usbd_xfer *xfer,
> BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
> *ep = cur;
>
> - DPRINTFN(10,("ehci_alloc_sqtd_chain: return sqtd=%p sqtdend=%p\n",
> + DPRINTFN(10,("%s: return sqtd=%p sqtdend=%p\n", __func__,
> *sp, *ep));
>
> return (USBD_NORMAL_COMPLETION);
>
> nomem:
> /* XXX free chain */
> - DPRINTFN(-1,("ehci_alloc_sqtd_chain: no memory\n"));
> + DPRINTFN(-1,("%s: no memory\n", __func__));
> return (USBD_NOMEM);
> }
>
> @@ -2492,7 +2487,7 @@ ehci_free_sqtd_chain(struct ehci_softc *sc, struct
> ehci_xfer *ex)
> struct ehci_pipe *epipe = (struct ehci_pipe *)ex->xfer.pipe;
> struct ehci_soft_qtd *sqtd, *next;
>
> - DPRINTFN(10,("ehci_free_sqtd_chain: sqtd=%p\n", ex->sqtdstart));
> + DPRINTFN(10,("%s: sqtd=%p\n", __func__, ex->sqtdstart));
>
> for (sqtd = ex->sqtdstart; sqtd != NULL; sqtd = next) {
> next = sqtd->nextqtd;
> @@ -2628,20 +2623,20 @@ ehci_abort_xfer(struct usbd_xfer *xfer, usbd_status
> status)
> }
>
> if (xfer->device->bus->intr_context)
> - panic("ehci_abort_xfer: not in process context");
> + panic("%s: not in process context", __func__);
>
> /*
> * If an abort is already in progress then just wait for it to
> * complete and return.
> */
> if (ex->ehci_xfer_flags & EHCI_XFER_ABORTING) {
> - DPRINTFN(2, ("ehci_abort_xfer: already aborting\n"));
> + DPRINTFN(2, ("%s: already aborting\n", __func__));
> /* No need to wait if we're aborting from a timeout. */
> if (status == USBD_TIMEOUT)
> return;
> /* Override the status which might be USBD_TIMEOUT. */
> xfer->status = status;
> - DPRINTFN(2, ("ehci_abort_xfer: waiting for abort to finish\n"));
> + DPRINTFN(2, ("%s: waiting for abort to finish\n", __func__));
> ex->ehci_xfer_flags |= EHCI_XFER_ABORTWAIT;
> while (ex->ehci_xfer_flags & EHCI_XFER_ABORTING)
> tsleep_nsec(&ex->ehci_xfer_flags, PZERO, "ehciaw",
> INFSLP);
> @@ -3040,7 +3035,7 @@ ehci_device_bulk_start(struct usbd_xfer *xfer)
> ex->sqtdend = dataend;
> #ifdef DIAGNOSTIC
> if (!ex->isdone) {
> - printf("ehci_device_bulk_start: not done, ex=%p\n", ex);
> + printf("%s: not done, ex=%p\n", __func__, ex);
> }
> ex->isdone = 0;
> #endif
> @@ -3154,7 +3149,7 @@ ehci_device_intr_start(struct usbd_xfer *xfer)
> ex->sqtdend = dataend;
> #ifdef DIAGNOSTIC
> if (!ex->isdone)
> - printf("ehci_device_intr_start: not done, ex=%p\n", ex);
> + printf("%s: not done, ex=%p\n", __func__, ex);
> ex->isdone = 0;
> #endif
>
> @@ -3218,7 +3213,7 @@ ehci_device_intr_done(struct usbd_xfer *xfer)
> ex->sqtdend = dataend;
> #ifdef DIAGNOSTIC
> if (!ex->isdone) {
> - printf("ehci_device_intr_done: not done, ex=%p\n",
> + printf("%s: not done, ex=%p\n", __func__,
> ex);
> }
> ex->isdone = 0;
>