Received: by mail.netbsd.org (Postfix, from userid 605) id 0D7F184D75; Sat, 25 Aug 2018 11:29:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id D73CD84D4D for ; Sat, 25 Aug 2018 11:29:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([IPv6:::1]) by localhost (mail.netbsd.org [IPv6:::1]) (amavisd-new, port 10025) with ESMTP id L3fcbshcok-C for ; Sat, 25 Aug 2018 11:29:52 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.NetBSD.org [IPv6:2001:470:a085:999:28c:faff:fe03:5984]) by mail.netbsd.org (Postfix) with ESMTP id D3F8284C78 for ; Sat, 25 Aug 2018 11:29:52 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id CC269FBEC; Sat, 25 Aug 2018 11:29:52 +0000 (UTC) Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" MIME-Version: 1.0 Date: Sat, 25 Aug 2018 11:29:52 +0000 From: "Martin Husemann" Subject: CVS commit: [netbsd-8] src/sys To: source-changes@NetBSD.org X-Mailer: log_accum Message-Id: <20180825112952.CC269FBEC@cvs.NetBSD.org> Sender: source-changes-owner@NetBSD.org List-Id: source-changes.NetBSD.org Precedence: bulk Reply-To: source-changes-d@NetBSD.org Mail-Reply-To: "Martin Husemann" Mail-Followup-To: source-changes-d@NetBSD.org List-Unsubscribe: Module Name: src Committed By: martin Date: Sat Aug 25 11:29:52 UTC 2018 Modified Files: src/sys/dev/usb [netbsd-8]: ehci.c ehcivar.h motg.c ohci.c ohcivar.h uhci.c uhcivar.h usbdi.c usbdivar.h xhci.c xhcivar.h src/sys/external/bsd/dwc2 [netbsd-8]: dwc2.c Log Message: Pull up following revision(s) (requested by mrg in ticket #980): sys/dev/usb/usbdivar.h: revision 1.117 sys/external/bsd/dwc2/dwc2.c: revision 1.52 sys/dev/usb/xhcivar.h: revision 1.10 sys/dev/usb/motg.c: revision 1.22 sys/dev/usb/ehci.c: revision 1.260 sys/dev/usb/ehci.c: revision 1.261 sys/dev/usb/xhci.c: revision 1.96 sys/dev/usb/ohci.c: revision 1.282 sys/dev/usb/ohci.c: revision 1.283 sys/dev/usb/ehcivar.h: revision 1.45 sys/dev/usb/uhci.c: revision 1.281 sys/dev/usb/uhci.c: revision 1.282 sys/dev/usb/usbdi.c: revision 1.177 sys/dev/usb/ohcivar.h: revision 1.60 sys/dev/usb/uhcivar.h: revision 1.55 (all via patch) pull across abort fixes from nick-nhusb. add more abort fixes, using ideas from Taylor and Nick, and myself. special thanks to both who inspired much of the code here, if not wrote it directly. among other problems, this assert should no longer trigger: panic: kernel diagnostic assertion "xfer->ux_state == XFER_ONQU" failed: file "/current/src/sys/dev/usb/usbdi.c", line 914 using usbhist i was able to track down my instance of it being related to userland close() beginning, dropping the sc_lock, and then the usb softintr completes the transfer normally, and when it is done, the abort path attempts to re-complete the transfer, and the above assert is tripped. changes from nhusb were commited with these logs: -- Move the struct usb_task to struct usbd_xfer for everyone to use. -- Set device transfer status to USBD_IN_PROGRESS if start methods succeeds -- Actually set the transfer status on transfers in ohci_abort_xfer and the controller is dying -- Don't supply the lock to callout_halt when polling as it won't be held -- Improve transfer abort -- Mark device transfers as USBD_IN_PROGRESS appropriately and improve abort handling -- -- Mark device transfers as USBD_IN_PROGRESS appropriately and improve abort handling -- additional changes include: - initialise the usb abort task in the HCI allocx routine, so that it can be safely usb_rem_task()'d. - rework the handling of softintr vs cancellation vs timeout abort based upon a scheme from Taylor: when completing a transfer normally: - if the status is not in progress, it must be cancelled or timed out, and we should not process this xfer. - set the status as normal. - unconditionallly callout_stop() and usb_rem_task(). they're safe and either aren't running, or will run and do nothing. - finally call usb_transfer_complete(). when aborting a transfer: - status should be cancelled or timed out. - if cancelling, callout_halt and usb_rem_task_wait() to make sure the timer is either done or cancelled. - at this point, the ux_status must not be cancelled or timed out, and if it is not in progress we're done. - set the status. - if the controller is dying, just return. - perform HCI-specific tasks to abort this xfer. - finally call usb_transfer_complete(). for the timeout and timeout task: - if the HCI is not dying, and the ux_status is in progress, then trigger the usb abort task. - remove UXFER_ABORTWAIT and UXFER_ABORTING. tested on: - multiple PC systems with several types of devices: ugen/UPS, ucom, umass with disk, ssd and cdrom backends, kbd, ms, using uhci, ehci and xhci. - erlite3: sd@umass on dwc2. - sunblade2000: kbd/ms and umass disk on ohci. untested: - motg, slhci and ahci. motg has some portion of the new scheme applied, but slhci and ahci require more study. future work includes pushing a lot of the common abort handling into usbdi.c and leaving upm_abort() for HC specific tasks, but this change is pullup-able to netbsd-7 and netbsd-8 as it does not change any external API, as well as removing over 100 lines of code while adding over 30 new asserts. XXX: pullup-7, pullup-8. fix DIAGNOSTIC build by not copying ub_usepolling to stack before use Sprinkle __diagused To generate a diff of this commit: cvs rdiff -u -r1.254.8.3 -r1.254.8.4 src/sys/dev/usb/ehci.c cvs rdiff -u -r1.43 -r1.43.10.1 src/sys/dev/usb/ehcivar.h cvs rdiff -u -r1.17.10.2 -r1.17.10.3 src/sys/dev/usb/motg.c cvs rdiff -u -r1.273.6.2 -r1.273.6.3 src/sys/dev/usb/ohci.c cvs rdiff -u -r1.58 -r1.58.10.1 src/sys/dev/usb/ohcivar.h cvs rdiff -u -r1.275.2.3 -r1.275.2.4 src/sys/dev/usb/uhci.c cvs rdiff -u -r1.53 -r1.53.10.1 src/sys/dev/usb/uhcivar.h cvs rdiff -u -r1.173.2.1 -r1.173.2.2 src/sys/dev/usb/usbdi.c cvs rdiff -u -r1.114 -r1.114.6.1 src/sys/dev/usb/usbdivar.h cvs rdiff -u -r1.72.2.6 -r1.72.2.7 src/sys/dev/usb/xhci.c cvs rdiff -u -r1.7 -r1.7.6.1 src/sys/dev/usb/xhcivar.h cvs rdiff -u -r1.46.2.1 -r1.46.2.2 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.