Module Name: src Committed By: skrll Date: Wed Sep 3 10:00:08 UTC 2014
Modified Files: src/sys/external/bsd/dwc2/dist: dwc2_hcd.c dwc2_hcd.h dwc2_hcdintr.c dwc2_hcdqueue.c Log Message: Adapt the NAK holdoff scheme for FS/LS devices from the Raspberry Pi Foundation driver. Should fix PR/49019 - RPI: interrupt storm when url0 is up To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/dwc2/dist/dwc2_hcd.c cvs rdiff -u -r1.8 -r1.9 src/sys/external/bsd/dwc2/dist/dwc2_hcd.h cvs rdiff -u -r1.9 -r1.10 src/sys/external/bsd/dwc2/dist/dwc2_hcdintr.c cvs rdiff -u -r1.10 -r1.11 src/sys/external/bsd/dwc2/dist/dwc2_hcdqueue.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_hcd.c diff -u src/sys/external/bsd/dwc2/dist/dwc2_hcd.c:1.13 src/sys/external/bsd/dwc2/dist/dwc2_hcd.c:1.14 --- src/sys/external/bsd/dwc2/dist/dwc2_hcd.c:1.13 Thu Jul 3 07:18:42 2014 +++ src/sys/external/bsd/dwc2/dist/dwc2_hcd.c Wed Sep 3 10:00:08 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: dwc2_hcd.c,v 1.13 2014/07/03 07:18:42 skrll Exp $ */ +/* $NetBSD: dwc2_hcd.c,v 1.14 2014/09/03 10:00:08 skrll Exp $ */ /* * hcd.c - DesignWare HS OTG Controller host-mode routines @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dwc2_hcd.c,v 1.13 2014/07/03 07:18:42 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwc2_hcd.c,v 1.14 2014/09/03 10:00:08 skrll Exp $"); #include <sys/types.h> #include <sys/kmem.h> @@ -887,6 +887,23 @@ enum dwc2_transaction_type dwc2_hcd_sele if (list_empty(&hsotg->free_hc_list)) break; qh = list_entry(qh_ptr, struct dwc2_qh, qh_list_entry); + + /* + * Check to see if this is a NAK'd retransmit, in which case + * ignore for retransmission. We hold off on bulk/control + * retransmissions to reduce NAK interrupt overhead for + * cheeky devices that just hold off using NAKs. + */ + if (qh->do_split && + qh->nak_frame != 0xffff && + dwc2_full_frame_num(qh->nak_frame) == + dwc2_full_frame_num(dwc2_hcd_get_frame_number(hsotg))) { + qh_ptr = qh_ptr->next; + continue; + } else { + qh->nak_frame = 0xffff; + } + if (hsotg->core_params->uframe_sched > 0) { if (hsotg->available_host_channels < 1) break; Index: src/sys/external/bsd/dwc2/dist/dwc2_hcd.h diff -u src/sys/external/bsd/dwc2/dist/dwc2_hcd.h:1.8 src/sys/external/bsd/dwc2/dist/dwc2_hcd.h:1.9 --- src/sys/external/bsd/dwc2/dist/dwc2_hcd.h:1.8 Thu Apr 3 06:34:58 2014 +++ src/sys/external/bsd/dwc2/dist/dwc2_hcd.h Wed Sep 3 10:00:08 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: dwc2_hcd.h,v 1.8 2014/04/03 06:34:58 skrll Exp $ */ +/* $NetBSD: dwc2_hcd.h,v 1.9 2014/09/03 10:00:08 skrll Exp $ */ /* * hcd.h - DesignWare HS OTG Controller host-mode declarations @@ -243,6 +243,7 @@ enum dwc2_transaction_type { * @interval: Interval between transfers in (micro)frames * @sched_frame: (Micro)frame to initialize a periodic transfer. * The transfer executes in the following (micro)frame. + * @nak_frame: Internal variable used by the NAK holdoff code * @frame_usecs: Internal variable used by the microframe scheduler * @start_split_frame: (Micro)frame at which last start split was initialized * @ntd: Actual number of transfer descriptors in a list @@ -277,6 +278,7 @@ struct dwc2_qh { u16 usecs; u16 interval; u16 sched_frame; + u16 nak_frame; u16 frame_usecs[8]; u16 start_split_frame; u16 ntd; Index: src/sys/external/bsd/dwc2/dist/dwc2_hcdintr.c diff -u src/sys/external/bsd/dwc2/dist/dwc2_hcdintr.c:1.9 src/sys/external/bsd/dwc2/dist/dwc2_hcdintr.c:1.10 --- src/sys/external/bsd/dwc2/dist/dwc2_hcdintr.c:1.9 Sat Jul 26 09:18:53 2014 +++ src/sys/external/bsd/dwc2/dist/dwc2_hcdintr.c Wed Sep 3 10:00:08 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: dwc2_hcdintr.c,v 1.9 2014/07/26 09:18:53 skrll Exp $ */ +/* $NetBSD: dwc2_hcdintr.c,v 1.10 2014/09/03 10:00:08 skrll 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 <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dwc2_hcdintr.c,v 1.9 2014/07/26 09:18:53 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwc2_hcdintr.c,v 1.10 2014/09/03 10:00:08 skrll Exp $"); #include <sys/types.h> #include <sys/pool.h> @@ -1211,6 +1211,17 @@ static void dwc2_hc_nak_intr(struct dwc2 chnum); /* + * When we get control/bulk NAKs then remember this so we holdoff on + * this qh until the beginning of the next frame + */ + switch (dwc2_hcd_get_pipe_type(&qtd->urb->pipe_info)) { + case USB_ENDPOINT_XFER_CONTROL: + case USB_ENDPOINT_XFER_BULK: + chan->qh->nak_frame = dwc2_hcd_get_frame_number(hsotg); + break; + } + + /* * Handle NAK for IN/OUT SSPLIT/CSPLIT transfers, bulk, control, and * interrupt. Re-start the SSPLIT transfer. */ Index: src/sys/external/bsd/dwc2/dist/dwc2_hcdqueue.c diff -u src/sys/external/bsd/dwc2/dist/dwc2_hcdqueue.c:1.10 src/sys/external/bsd/dwc2/dist/dwc2_hcdqueue.c:1.11 --- src/sys/external/bsd/dwc2/dist/dwc2_hcdqueue.c:1.10 Thu Jul 3 07:18:42 2014 +++ src/sys/external/bsd/dwc2/dist/dwc2_hcdqueue.c Wed Sep 3 10:00:08 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: dwc2_hcdqueue.c,v 1.10 2014/07/03 07:18:42 skrll Exp $ */ +/* $NetBSD: dwc2_hcdqueue.c,v 1.11 2014/09/03 10:00:08 skrll Exp $ */ /* * hcd_queue.c - DesignWare HS OTG Controller host queuing routines @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dwc2_hcdqueue.c,v 1.10 2014/07/03 07:18:42 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dwc2_hcdqueue.c,v 1.11 2014/09/03 10:00:08 skrll Exp $"); #include <sys/types.h> #include <sys/kmem.h> @@ -94,6 +94,7 @@ static void dwc2_qh_init(struct dwc2_hso dev_speed = dwc2_host_get_speed(hsotg, urb->priv); dwc2_host_hub_info(hsotg, urb->priv, &hub_addr, &hub_port); + qh->nak_frame = 0xffff; if ((dev_speed == USB_SPEED_LOW || dev_speed == USB_SPEED_FULL) && hub_addr != 0 && hub_addr != 1) {