CVS commit: [netbsd-8] src/sys/external/bsd/dwc2
Module Name:src Committed By: bouyer Date: Thu Dec 5 16:59:35 UTC 2019 Modified Files: src/sys/external/bsd/dwc2 [netbsd-8]: dwc2.c Log Message: Pull up following revision(s) (requested by skrll in ticket #1468): sys/external/bsd/dwc2/dwc2.c: revision 1.60 sys/external/bsd/dwc2/dwc2.c: revision 1.61 sys/external/bsd/dwc2/dwc2.c: revision 1.62 sys/external/bsd/dwc2/dwc2.c: revision 1.63 sys/external/bsd/dwc2/dwc2.c: revision 1.64 sys/external/bsd/dwc2/dwc2.c: revision 1.65 sys/external/bsd/dwc2/dwc2.c: revision 1.66 KNF Make dwc2debug sysctl'able Need for previous Use size_t for loop count variable Calulate the right lenght for isoc transfer and the usb_syncmem PR/54696: Kernel panic in bus_dma.c on Raspberry Pi 3B/3B+ build fix Consistency. To generate a diff of this commit: cvs rdiff -u -r1.46.2.3 -r1.46.2.4 src/sys/external/bsd/dwc2/dwc2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/dwc2/dwc2.c diff -u src/sys/external/bsd/dwc2/dwc2.c:1.46.2.3 src/sys/external/bsd/dwc2/dwc2.c:1.46.2.4 --- src/sys/external/bsd/dwc2/dwc2.c:1.46.2.3 Thu Sep 27 14:52:26 2018 +++ src/sys/external/bsd/dwc2/dwc2.c Thu Dec 5 16:59:35 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dwc2.c,v 1.46.2.3 2018/09/27 14:52:26 martin Exp $ */ +/* $NetBSD: dwc2.c,v 1.46.2.4 2019/12/05 16:59:35 bouyer Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -30,19 +30,21 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.46.2.3 2018/09/27 14:52:26 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.46.2.4 2019/12/05 16:59:35 bouyer Exp $"); #include "opt_usb.h" #include -#include -#include -#include + +#include #include -#include +#include +#include #include #include -#include +#include +#include +#include #include @@ -74,6 +76,33 @@ __KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.4 } while (0) #define DPRINTF(...) DPRINTFN(1, __VA_ARGS__) int dwc2debug = 0; + +SYSCTL_SETUP(sysctl_hw_dwc2_setup, "sysctl hw.dwc2 setup") +{ + int err; + const struct sysctlnode *rnode; + const struct sysctlnode *cnode; + + err = sysctl_createv(clog, 0, NULL, , + CTLFLAG_PERMANENT, CTLTYPE_NODE, "dwc2", + SYSCTL_DESCR("dwc2 global controls"), + NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL); + + if (err) + goto fail; + + /* control debugging printfs */ + err = sysctl_createv(clog, 0, , , + CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, + "debug", SYSCTL_DESCR("Enable debugging output"), + NULL, 0, , sizeof(dwc2debug), CTL_CREATE, CTL_EOL); + if (err) + goto fail; + + return; +fail: + aprint_error("%s: sysctl_createv failed (err = %d)\n", __func__, err); +} #else #define DPRINTF(...) do { } while (0) #define DPRINTFN(...) do { } while (0) @@ -953,7 +982,6 @@ dwc2_device_start(struct usbd_xfer *xfer uint32_t off = 0; int retval, err; int alloc_bandwidth = 0; - int i; DPRINTFN(1, "xfer=%p pipe=%p\n", xfer, xfer->ux_pipe); @@ -993,6 +1021,14 @@ dwc2_device_start(struct usbd_xfer *xfer DPRINTFN(3, "req = %p dma = %" PRIxBUSADDR " len %d dir %s\n", KERNADDR(>req_dma, 0), DMAADDR(>req_dma, 0), len, dir == UE_DIR_IN ? "in" : "out"); + } else if (xfertype == UE_ISOCHRONOUS) { + DPRINTFN(3, "xfer=%p nframes=%d flags=%d addr=%d endpt=%d," + " mps=%d dir %s\n", xfer, xfer->ux_nframes, xfer->ux_flags, addr, + epnum, mps, dir == UT_READ ? "in" :"out"); + + len = 0; + for (size_t i = 0; i < xfer->ux_nframes; i++) + len += xfer->ux_frlengths[i]; } else { DPRINTFN(3, "xfer=%p len=%d flags=%d addr=%d endpt=%d," " mps=%d dir %s\n", xfer, xfer->ux_length, xfer->ux_flags, addr, @@ -1086,8 +1122,9 @@ dwc2_device_start(struct usbd_xfer *xfer KASSERTMSG(xfer->ux_nframes == 0 || xfertype == UE_ISOCHRONOUS, "nframes %d xfertype %d\n", xfer->ux_nframes, xfertype); - for (off = i = 0; i < xfer->ux_nframes; ++i) { - DPRINTFN(3, "xfer=%p frame=%d offset=%d length=%d\n", xfer, i, + off = 0; + for (size_t i = 0; i < xfer->ux_nframes; ++i) { + DPRINTFN(3, "xfer=%p frame=%zd offset=%d length=%d\n", xfer, i, off, xfer->ux_frlengths[i]); dwc2_hcd_urb_set_iso_desc_params(dwc2_urb, i, off, @@ -1467,22 +1504,21 @@ void dwc2_host_complete(struct dwc2_hsot DPRINTFN(3, "xfer=%p actlen=%d\n", xfer, xfer->ux_actlen); if (xfertype == UE_ISOCHRONOUS) { - int i; - xfer->ux_actlen = 0; - for (i = 0; i < xfer->ux_nframes; ++i) { + for (size_t i = 0; i < xfer->ux_nframes; ++i) { xfer->ux_frlengths[i] = dwc2_hcd_urb_get_iso_desc_actual_length( urb, i); + DPRINTFN(1, "xfer=%p frame=%zu length=%d\n", xfer, i, + xfer->ux_frlengths[i]); xfer->ux_actlen += xfer->ux_frlengths[i]; } + DPRINTFN(1, "xfer=%p actlen=%d (isoc)\n", xfer, xfer->ux_actlen); } if (xfertype == UE_ISOCHRONOUS && dbg_perio()) { - int i; - - for (i =
CVS commit: [netbsd-8] src/sys/external/bsd/dwc2/dist
Module Name:src Committed By: martin Date: Mon Aug 13 12:03:41 UTC 2018 Modified Files: src/sys/external/bsd/dwc2/dist [netbsd-8]: dwc2_hcdintr.c Log Message: Pull up following revision(s) (requested by skrll in ticket #971): sys/external/bsd/dwc2/dist/dwc2_hcdintr.c: revision 1.15 Fixup previous to not break ping protocol. My bad. To generate a diff of this commit: cvs rdiff -u -r1.13.10.1 -r1.13.10.2 \ src/sys/external/bsd/dwc2/dist/dwc2_hcdintr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/dwc2/dist/dwc2_hcdintr.c diff -u src/sys/external/bsd/dwc2/dist/dwc2_hcdintr.c:1.13.10.1 src/sys/external/bsd/dwc2/dist/dwc2_hcdintr.c:1.13.10.2 --- src/sys/external/bsd/dwc2/dist/dwc2_hcdintr.c:1.13.10.1 Wed Aug 8 10:36:08 2018 +++ src/sys/external/bsd/dwc2/dist/dwc2_hcdintr.c Mon Aug 13 12:03:41 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: dwc2_hcdintr.c,v 1.13.10.1 2018/08/08 10:36:08 martin Exp $ */ +/* $NetBSD: dwc2_hcdintr.c,v 1.13.10.2 2018/08/13 12:03:41 martin Exp $ */ /* * hcd_intr.c - DesignWare HS OTG Controller host-mode interrupt handling @@ -40,7 +40,7 @@ * This file contains the interrupt handlers for Host mode */ #include -__KERNEL_RCSID(0, "$NetBSD: dwc2_hcdintr.c,v 1.13.10.1 2018/08/08 10:36:08 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwc2_hcdintr.c,v 1.13.10.2 2018/08/13 12:03:41 martin Exp $"); #include #include @@ -67,6 +67,9 @@ __KERNEL_RCSID(0, "$NetBSD: dwc2_hcdintr #define DWC2_NAKS_BEFORE_DELAY 3 int dwc2_naks_before_delay = DWC2_NAKS_BEFORE_DELAY; +#define DWC2_OUT_NAKS_BEFORE_DELAY 1 +int dwc2_out_naks_before_delay = DWC2_OUT_NAKS_BEFORE_DELAY; + /* This function is for debug only */ static void dwc2_track_missed_sofs(struct dwc2_hsotg *hsotg) { @@ -1320,8 +1323,10 @@ static void dwc2_hc_nak_intr(struct dwc2 /* * Avoid interrupt storms. */ - qtd->qh->want_wait = 1; - } else if (!chan->qh->ping_state) { + qtd->num_naks++; + qtd->qh->want_wait = qtd->num_naks >= dwc2_out_naks_before_delay; + } + if (!chan->qh->ping_state) { dwc2_update_urb_state_abn(hsotg, chan, chnum, qtd->urb, qtd, DWC2_HC_XFER_NAK); dwc2_hcd_save_data_toggle(hsotg, chan, chnum, qtd);
CVS commit: [netbsd-8] src/sys/external/bsd/dwc2/dist
Module Name:src Committed By: martin Date: Wed Aug 8 10:36:08 UTC 2018 Modified Files: src/sys/external/bsd/dwc2/dist [netbsd-8]: dwc2_core.h dwc2_hcd.c dwc2_hcd.h dwc2_hcdintr.c dwc2_hcdqueue.c Log Message: Pull up following revision(s) (requested by simonb in ticket #966): sys/external/bsd/dwc2/dist/dwc2_core.h: revision 1.9 sys/external/bsd/dwc2/dist/dwc2_hcdqueue.c: revision 1.15 sys/external/bsd/dwc2/dist/dwc2_hcd.h: revision 1.15 sys/external/bsd/dwc2/dist/dwc2_hcdintr.c: revision 1.14 sys/external/bsd/dwc2/dist/dwc2_hcd.c: revision 1.21 Merge https://github.com/torvalds/linux/commit/38d2b5fb75c15923fb89c32134516a623515bce4 to mitigate USB NAK interrupt storms, with an extra change from skrll@ to also mitigate interrupt storms on the non-split case with older DWC2 cores. Fixes woeful USB disk performance on an ERLITE. Much thanks to skrll@ for pointer to the above patch, handling the non-split case and testing. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.8.10.1 src/sys/external/bsd/dwc2/dist/dwc2_core.h cvs rdiff -u -r1.19 -r1.19.10.1 src/sys/external/bsd/dwc2/dist/dwc2_hcd.c cvs rdiff -u -r1.14 -r1.14.10.1 src/sys/external/bsd/dwc2/dist/dwc2_hcd.h \ src/sys/external/bsd/dwc2/dist/dwc2_hcdqueue.c cvs rdiff -u -r1.13 -r1.13.10.1 src/sys/external/bsd/dwc2/dist/dwc2_hcdintr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/dwc2/dist/dwc2_core.h diff -u src/sys/external/bsd/dwc2/dist/dwc2_core.h:1.8 src/sys/external/bsd/dwc2/dist/dwc2_core.h:1.8.10.1 --- src/sys/external/bsd/dwc2/dist/dwc2_core.h:1.8 Wed Feb 24 22:17:54 2016 +++ src/sys/external/bsd/dwc2/dist/dwc2_core.h Wed Aug 8 10:36:08 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: dwc2_core.h,v 1.8 2016/02/24 22:17:54 skrll Exp $ */ +/* $NetBSD: dwc2_core.h,v 1.8.10.1 2018/08/08 10:36:08 martin Exp $ */ /* * core.h - DesignWare HS OTG Controller common declarations @@ -756,6 +756,7 @@ struct dwc2_hsotg { } flags; struct list_head non_periodic_sched_inactive; + struct list_head non_periodic_sched_waiting; struct list_head non_periodic_sched_active; struct list_head *non_periodic_qh_ptr; struct list_head periodic_sched_inactive; Index: src/sys/external/bsd/dwc2/dist/dwc2_hcd.c diff -u src/sys/external/bsd/dwc2/dist/dwc2_hcd.c:1.19 src/sys/external/bsd/dwc2/dist/dwc2_hcd.c:1.19.10.1 --- src/sys/external/bsd/dwc2/dist/dwc2_hcd.c:1.19 Wed Feb 24 22:17:54 2016 +++ src/sys/external/bsd/dwc2/dist/dwc2_hcd.c Wed Aug 8 10:36:08 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: dwc2_hcd.c,v 1.19 2016/02/24 22:17:54 skrll Exp $ */ +/* $NetBSD: dwc2_hcd.c,v 1.19.10.1 2018/08/08 10:36:08 martin Exp $ */ /* * hcd.c - DesignWare HS OTG Controller host-mode routines @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dwc2_hcd.c,v 1.19 2016/02/24 22:17:54 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwc2_hcd.c,v 1.19.10.1 2018/08/08 10:36:08 martin Exp $"); #include #include @@ -117,6 +117,10 @@ static void dwc2_dump_channel_info(struc list_for_each_entry(qh, >non_periodic_sched_inactive, qh_list_entry) dev_dbg(hsotg->dev, "%p\n", qh); + dev_dbg(hsotg->dev, " NP waiting sched:\n"); + list_for_each_entry(qh, >non_periodic_sched_waiting, + qh_list_entry) + dev_dbg(hsotg->dev, "%p\n", qh); dev_dbg(hsotg->dev, " NP active sched:\n"); list_for_each_entry(qh, >non_periodic_sched_active, qh_list_entry) @@ -194,6 +198,7 @@ static void dwc2_qh_list_free(struct dwc static void dwc2_kill_all_urbs(struct dwc2_hsotg *hsotg) { dwc2_kill_urbs_in_qh_list(hsotg, >non_periodic_sched_inactive); + dwc2_kill_urbs_in_qh_list(hsotg, >non_periodic_sched_waiting); dwc2_kill_urbs_in_qh_list(hsotg, >non_periodic_sched_active); dwc2_kill_urbs_in_qh_list(hsotg, >periodic_sched_inactive); dwc2_kill_urbs_in_qh_list(hsotg, >periodic_sched_ready); @@ -2215,6 +2220,7 @@ static void dwc2_hcd_free(struct dwc2_hs /* Free memory for QH/QTD lists */ dwc2_qh_list_free(hsotg, >non_periodic_sched_inactive); + dwc2_qh_list_free(hsotg, >non_periodic_sched_waiting); dwc2_qh_list_free(hsotg, >non_periodic_sched_active); dwc2_qh_list_free(hsotg, >periodic_sched_inactive); dwc2_qh_list_free(hsotg, >periodic_sched_ready); @@ -2337,6 +2343,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hso /* Initialize the non-periodic schedule */ INIT_LIST_HEAD(>non_periodic_sched_inactive); + INIT_LIST_HEAD(>non_periodic_sched_waiting); INIT_LIST_HEAD(>non_periodic_sched_active); /* Initialize the periodic schedule */ Index: src/sys/external/bsd/dwc2/dist/dwc2_hcd.h diff -u src/sys/external/bsd/dwc2/dist/dwc2_hcd.h:1.14 src/sys/external/bsd/dwc2/dist/dwc2_hcd.h:1.14.10.1 --- src/sys/external/bsd/dwc2/dist/dwc2_hcd.h:1.14 Sat Apr 23 10:15:30 2016 +++ src/sys/external/bsd/dwc2/dist/dwc2_hcd.h Wed Aug 8 10:36:08 2018 @@ -1,4 +1,4 @@ -/*