usb: Factor usb_transfer_complete out of ubm_abortx method.diff -r1.303 -r1.304 src/sys/dev/usb/ehci.c
(riastradh)
--- src/sys/dev/usb/ehci.c 2022/03/03 06:04:31 1.303
+++ src/sys/dev/usb/ehci.c 2022/03/03 06:08:50 1.304
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ehci.c,v 1.303 2022/03/03 06:04:31 riastradh Exp $ */ | 1 | /* $NetBSD: ehci.c,v 1.304 2022/03/03 06:08:50 riastradh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Lennart Augustsson (lennart@augustsson.net), Charles M. Hannum, | 8 | * by Lennart Augustsson (lennart@augustsson.net), Charles M. Hannum, | |
9 | * Jeremy Morse (jeremy.morse@gmail.com), Jared D. McNeill | 9 | * Jeremy Morse (jeremy.morse@gmail.com), Jared D. McNeill | |
10 | * (jmcneill@invisible.ca). Matthew R. Green (mrg@eterna.com.au), and | 10 | * (jmcneill@invisible.ca). Matthew R. Green (mrg@eterna.com.au), and | |
11 | * Nick Hudson . | 11 | * Nick Hudson . | |
12 | * | 12 | * | |
13 | * Redistribution and use in source and binary forms, with or without | 13 | * Redistribution and use in source and binary forms, with or without | |
14 | * modification, are permitted provided that the following conditions | 14 | * modification, are permitted provided that the following conditions | |
@@ -44,27 +44,27 @@ | @@ -44,27 +44,27 @@ | |||
44 | 44 | |||
45 | /* | 45 | /* | |
46 | * TODO: | 46 | * TODO: | |
47 | * 1) hold off explorations by companion controllers until ehci has started. | 47 | * 1) hold off explorations by companion controllers until ehci has started. | |
48 | * | 48 | * | |
49 | * 2) The hub driver needs to handle and schedule the transaction translator, | 49 | * 2) The hub driver needs to handle and schedule the transaction translator, | |
50 | * to assign place in frame where different devices get to go. See chapter | 50 | * to assign place in frame where different devices get to go. See chapter | |
51 | * on hubs in USB 2.0 for details. | 51 | * on hubs in USB 2.0 for details. | |
52 | * | 52 | * | |
53 | * 3) Command failures are not recovered correctly. | 53 | * 3) Command failures are not recovered correctly. | |
54 | */ | 54 | */ | |
55 | 55 | |||
56 | #include <sys/cdefs.h> | 56 | #include <sys/cdefs.h> | |
57 | __KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.303 2022/03/03 06:04:31 riastradh Exp $"); | 57 | __KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.304 2022/03/03 06:08:50 riastradh Exp $"); | |
58 | 58 | |||
59 | #include "ohci.h" | 59 | #include "ohci.h" | |
60 | #include "uhci.h" | 60 | #include "uhci.h" | |
61 | 61 | |||
62 | #ifdef _KERNEL_OPT | 62 | #ifdef _KERNEL_OPT | |
63 | #include "opt_usb.h" | 63 | #include "opt_usb.h" | |
64 | #endif | 64 | #endif | |
65 | 65 | |||
66 | #include <sys/param.h> | 66 | #include <sys/param.h> | |
67 | 67 | |||
68 | #include <sys/bus.h> | 68 | #include <sys/bus.h> | |
69 | #include <sys/cpu.h> | 69 | #include <sys/cpu.h> | |
70 | #include <sys/device.h> | 70 | #include <sys/device.h> | |
@@ -3378,34 +3378,30 @@ ehci_abortx(struct usbd_xfer *xfer) | @@ -3378,34 +3378,30 @@ ehci_abortx(struct usbd_xfer *xfer) | |||
3378 | sqh->qh.qh_qtd.qtd_status = qhstatus; | 3378 | sqh->qh.qh_qtd.qtd_status = qhstatus; | |
3379 | usb_syncmem(&sqh->dma, | 3379 | usb_syncmem(&sqh->dma, | |
3380 | sqh->offs + offsetof(ehci_qh_t, qh_qtd.qtd_status), | 3380 | sqh->offs + offsetof(ehci_qh_t, qh_qtd.qtd_status), | |
3381 | sizeof(sqh->qh.qh_qtd.qtd_status), | 3381 | sizeof(sqh->qh.qh_qtd.qtd_status), | |
3382 | BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); | 3382 | BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); | |
3383 | } else { | 3383 | } else { | |
3384 | DPRINTF("no hit", 0, 0, 0, 0); | 3384 | DPRINTF("no hit", 0, 0, 0, 0); | |
3385 | usb_syncmem(&sqh->dma, | 3385 | usb_syncmem(&sqh->dma, | |
3386 | sqh->offs + offsetof(ehci_qh_t, qh_curqtd), | 3386 | sqh->offs + offsetof(ehci_qh_t, qh_curqtd), | |
3387 | sizeof(sqh->qh.qh_curqtd), | 3387 | sizeof(sqh->qh.qh_curqtd), | |
3388 | BUS_DMASYNC_PREREAD); | 3388 | BUS_DMASYNC_PREREAD); | |
3389 | } | 3389 | } | |
3390 | 3390 | |||
3391 | /* | |||
3392 | * Final step: Notify completion to waiting xfers. | |||
3393 | */ | |||
3394 | dying: | 3391 | dying: | |
3395 | #ifdef DIAGNOSTIC | 3392 | #ifdef DIAGNOSTIC | |
3396 | exfer->ex_isdone = true; | 3393 | exfer->ex_isdone = true; | |
3397 | #endif | 3394 | #endif | |
3398 | usb_transfer_complete(xfer); | |||
3399 | DPRINTFN(14, "end", 0, 0, 0, 0); | 3395 | DPRINTFN(14, "end", 0, 0, 0, 0); | |
3400 | 3396 | |||
3401 | KASSERT(mutex_owned(&sc->sc_lock)); | 3397 | KASSERT(mutex_owned(&sc->sc_lock)); | |
3402 | } | 3398 | } | |
3403 | 3399 | |||
3404 | Static void | 3400 | Static void | |
3405 | ehci_abort_isoc_xfer(struct usbd_xfer *xfer, usbd_status status) | 3401 | ehci_abort_isoc_xfer(struct usbd_xfer *xfer, usbd_status status) | |
3406 | { | 3402 | { | |
3407 | EHCIHIST_FUNC(); EHCIHIST_CALLED(); | 3403 | EHCIHIST_FUNC(); EHCIHIST_CALLED(); | |
3408 | ehci_isoc_trans_t trans_status; | 3404 | ehci_isoc_trans_t trans_status; | |
3409 | struct ehci_xfer *exfer; | 3405 | struct ehci_xfer *exfer; | |
3410 | ehci_softc_t *sc; | 3406 | ehci_softc_t *sc; | |
3411 | struct ehci_soft_itd *itd; | 3407 | struct ehci_soft_itd *itd; |
--- src/sys/dev/usb/motg.c 2022/03/03 06:04:31 1.38
+++ src/sys/dev/usb/motg.c 2022/03/03 06:08:50 1.39
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: motg.c,v 1.38 2022/03/03 06:04:31 riastradh Exp $ */ | 1 | /* $NetBSD: motg.c,v 1.39 2022/03/03 06:08:50 riastradh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1998, 2004, 2011, 2012, 2014 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 2004, 2011, 2012, 2014 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Lennart Augustsson (lennart@augustsson.net) at | 8 | * by Lennart Augustsson (lennart@augustsson.net) at | |
9 | * Carlstedt Research & Technology, Jared D. McNeill (jmcneill@invisible.ca), | 9 | * Carlstedt Research & Technology, Jared D. McNeill (jmcneill@invisible.ca), | |
10 | * Matthew R. Green (mrg@eterna.com.au), and Manuel Bouyer (bouyer@netbsd.org). | 10 | * Matthew R. Green (mrg@eterna.com.au), and Manuel Bouyer (bouyer@netbsd.org). | |
11 | * | 11 | * | |
12 | * Redistribution and use in source and binary forms, with or without | 12 | * Redistribution and use in source and binary forms, with or without | |
13 | * modification, are permitted provided that the following conditions | 13 | * modification, are permitted provided that the following conditions | |
14 | * are met: | 14 | * are met: | |
@@ -30,27 +30,27 @@ | @@ -30,27 +30,27 @@ | |||
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
31 | * POSSIBILITY OF SUCH DAMAGE. | 31 | * POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | 34 | |||
35 | /* | 35 | /* | |
36 | * This file contains the driver for the Mentor Graphics Inventra USB | 36 | * This file contains the driver for the Mentor Graphics Inventra USB | |
37 | * 2.0 High Speed Dual-Role controller. | 37 | * 2.0 High Speed Dual-Role controller. | |
38 | * | 38 | * | |
39 | * NOTE: The current implementation only supports Device Side Mode! | 39 | * NOTE: The current implementation only supports Device Side Mode! | |
40 | */ | 40 | */ | |
41 | 41 | |||
42 | #include <sys/cdefs.h> | 42 | #include <sys/cdefs.h> | |
43 | __KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.38 2022/03/03 06:04:31 riastradh Exp $"); | 43 | __KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.39 2022/03/03 06:08:50 riastradh Exp $"); | |
44 | 44 | |||
45 | #ifdef _KERNEL_OPT | 45 | #ifdef _KERNEL_OPT | |
46 | #include "opt_usb.h" | 46 | #include "opt_usb.h" | |
47 | #endif | 47 | #endif | |
48 | 48 | |||
49 | #include <sys/param.h> | 49 | #include <sys/param.h> | |
50 | 50 | |||
51 | #include <sys/bus.h> | 51 | #include <sys/bus.h> | |
52 | #include <sys/cpu.h> | 52 | #include <sys/cpu.h> | |
53 | #include <sys/device.h> | 53 | #include <sys/device.h> | |
54 | #include <sys/kernel.h> | 54 | #include <sys/kernel.h> | |
55 | #include <sys/kmem.h> | 55 | #include <sys/kmem.h> | |
56 | #include <sys/proc.h> | 56 | #include <sys/proc.h> | |
@@ -2212,16 +2212,15 @@ motg_abortx(struct usbd_xfer *xfer) | @@ -2212,16 +2212,15 @@ motg_abortx(struct usbd_xfer *xfer) | |||
2212 | } else if (otgpipe->hw_ep->phase == DATA_IN) { | 2212 | } else if (otgpipe->hw_ep->phase == DATA_IN) { | |
2213 | csr = UREAD1(sc, MUSB2_REG_RXCSRL); | 2213 | csr = UREAD1(sc, MUSB2_REG_RXCSRL); | |
2214 | while (csr & MUSB2_MASK_CSRL_RXPKTRDY) { | 2214 | while (csr & MUSB2_MASK_CSRL_RXPKTRDY) { | |
2215 | csr |= MUSB2_MASK_CSRL_RXFFLUSH; | 2215 | csr |= MUSB2_MASK_CSRL_RXFFLUSH; | |
2216 | UWRITE1(sc, MUSB2_REG_RXCSRL, csr); | 2216 | UWRITE1(sc, MUSB2_REG_RXCSRL, csr); | |
2217 | csr = UREAD1(sc, MUSB2_REG_RXCSRL); | 2217 | csr = UREAD1(sc, MUSB2_REG_RXCSRL); | |
2218 | } | 2218 | } | |
2219 | UWRITE1(sc, MUSB2_REG_RXCSRL, 0); | 2219 | UWRITE1(sc, MUSB2_REG_RXCSRL, 0); | |
2220 | } | 2220 | } | |
2221 | otgpipe->hw_ep->phase = IDLE; | 2221 | otgpipe->hw_ep->phase = IDLE; | |
2222 | } | 2222 | } | |
2223 | } | 2223 | } | |
2224 | dying: | 2224 | dying: | |
2225 | usb_transfer_complete(xfer); | |||
2226 | KASSERT(mutex_owned(&sc->sc_lock)); | 2225 | KASSERT(mutex_owned(&sc->sc_lock)); | |
2227 | } | 2226 | } |
--- src/sys/dev/usb/ohci.c 2022/03/03 06:04:31 1.319
+++ src/sys/dev/usb/ohci.c 2022/03/03 06:08:50 1.320
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ohci.c,v 1.319 2022/03/03 06:04:31 riastradh Exp $ */ | 1 | /* $NetBSD: ohci.c,v 1.320 2022/03/03 06:08:50 riastradh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1998, 2004, 2005, 2012, 2016, 2020 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 2004, 2005, 2012, 2016, 2020 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Lennart Augustsson (lennart@augustsson.net) at | 8 | * by Lennart Augustsson (lennart@augustsson.net) at | |
9 | * Carlstedt Research & Technology, Jared D. McNeill (jmcneill@invisible.ca), | 9 | * Carlstedt Research & Technology, Jared D. McNeill (jmcneill@invisible.ca), | |
10 | * Matthew R. Green (mrg@eterna.com.au), and Nick Hudson. | 10 | * Matthew R. Green (mrg@eterna.com.au), and Nick Hudson. | |
11 | * | 11 | * | |
12 | * This code is derived from software contributed to The NetBSD Foundation | 12 | * This code is derived from software contributed to The NetBSD Foundation | |
13 | * by Charles M. Hannum. | 13 | * by Charles M. Hannum. | |
14 | * | 14 | * | |
@@ -32,27 +32,27 @@ | @@ -32,27 +32,27 @@ | |||
32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
34 | * POSSIBILITY OF SUCH DAMAGE. | 34 | * POSSIBILITY OF SUCH DAMAGE. | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | /* | 37 | /* | |
38 | * USB Open Host Controller driver. | 38 | * USB Open Host Controller driver. | |
39 | * | 39 | * | |
40 | * OHCI spec: http://www.compaq.com/productinfo/development/openhci.html | 40 | * OHCI spec: http://www.compaq.com/productinfo/development/openhci.html | |
41 | * USB spec: http://www.usb.org/developers/docs/ | 41 | * USB spec: http://www.usb.org/developers/docs/ | |
42 | */ | 42 | */ | |
43 | 43 | |||
44 | #include <sys/cdefs.h> | 44 | #include <sys/cdefs.h> | |
45 | __KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.319 2022/03/03 06:04:31 riastradh Exp $"); | 45 | __KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.320 2022/03/03 06:08:50 riastradh Exp $"); | |
46 | 46 | |||
47 | #ifdef _KERNEL_OPT | 47 | #ifdef _KERNEL_OPT | |
48 | #include "opt_usb.h" | 48 | #include "opt_usb.h" | |
49 | #endif | 49 | #endif | |
50 | 50 | |||
51 | #include <sys/param.h> | 51 | #include <sys/param.h> | |
52 | 52 | |||
53 | #include <sys/cpu.h> | 53 | #include <sys/cpu.h> | |
54 | #include <sys/device.h> | 54 | #include <sys/device.h> | |
55 | #include <sys/kernel.h> | 55 | #include <sys/kernel.h> | |
56 | #include <sys/kmem.h> | 56 | #include <sys/kmem.h> | |
57 | #include <sys/proc.h> | 57 | #include <sys/proc.h> | |
58 | #include <sys/queue.h> | 58 | #include <sys/queue.h> | |
@@ -2399,32 +2399,27 @@ ohci_abortx(struct usbd_xfer *xfer) | @@ -2399,32 +2399,27 @@ ohci_abortx(struct usbd_xfer *xfer) | |||
2399 | DPRINTFN(1, "no hit", 0, 0, 0, 0); | 2399 | DPRINTFN(1, "no hit", 0, 0, 0, 0); | |
2400 | } | 2400 | } | |
2401 | 2401 | |||
2402 | /* | 2402 | /* | |
2403 | * HC Step 4: Turn on hardware again. | 2403 | * HC Step 4: Turn on hardware again. | |
2404 | */ | 2404 | */ | |
2405 | usb_syncmem(&sed->dma, sed->offs + offsetof(ohci_ed_t, ed_flags), | 2405 | usb_syncmem(&sed->dma, sed->offs + offsetof(ohci_ed_t, ed_flags), | |
2406 | sizeof(sed->ed.ed_flags), | 2406 | sizeof(sed->ed.ed_flags), | |
2407 | BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD); | 2407 | BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD); | |
2408 | sed->ed.ed_flags &= HTOO32(~OHCI_ED_SKIP); /* remove hardware skip */ | 2408 | sed->ed.ed_flags &= HTOO32(~OHCI_ED_SKIP); /* remove hardware skip */ | |
2409 | usb_syncmem(&sed->dma, sed->offs + offsetof(ohci_ed_t, ed_flags), | 2409 | usb_syncmem(&sed->dma, sed->offs + offsetof(ohci_ed_t, ed_flags), | |
2410 | sizeof(sed->ed.ed_flags), | 2410 | sizeof(sed->ed.ed_flags), | |
2411 | BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); | 2411 | BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); | |
2412 | ||||
2413 | /* | |||
2414 | * Final step: Notify completion to waiting xfers. | |||
2415 | */ | |||
2416 | dying: | 2412 | dying: | |
2417 | usb_transfer_complete(xfer); | |||
2418 | DPRINTFN(14, "end", 0, 0, 0, 0); | 2413 | DPRINTFN(14, "end", 0, 0, 0, 0); | |
2419 | 2414 | |||
2420 | KASSERT(mutex_owned(&sc->sc_lock)); | 2415 | KASSERT(mutex_owned(&sc->sc_lock)); | |
2421 | } | 2416 | } | |
2422 | 2417 | |||
2423 | /* | 2418 | /* | |
2424 | * Data structures and routines to emulate the root hub. | 2419 | * Data structures and routines to emulate the root hub. | |
2425 | */ | 2420 | */ | |
2426 | Static int | 2421 | Static int | |
2427 | ohci_roothub_ctrl(struct usbd_bus *bus, usb_device_request_t *req, | 2422 | ohci_roothub_ctrl(struct usbd_bus *bus, usb_device_request_t *req, | |
2428 | void *buf, int buflen) | 2423 | void *buf, int buflen) | |
2429 | { | 2424 | { | |
2430 | ohci_softc_t *sc = OHCI_BUS2SC(bus); | 2425 | ohci_softc_t *sc = OHCI_BUS2SC(bus); |
--- src/sys/dev/usb/uhci.c 2022/03/03 06:04:31 1.309
+++ src/sys/dev/usb/uhci.c 2022/03/03 06:08:50 1.310
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: uhci.c,v 1.309 2022/03/03 06:04:31 riastradh Exp $ */ | 1 | /* $NetBSD: uhci.c,v 1.310 2022/03/03 06:08:50 riastradh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1998, 2004, 2011, 2012, 2016, 2020 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 2004, 2011, 2012, 2016, 2020 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Lennart Augustsson (lennart@augustsson.net) at | 8 | * by Lennart Augustsson (lennart@augustsson.net) at | |
9 | * Carlstedt Research & Technology, Jared D. McNeill (jmcneill@invisible.ca), | 9 | * Carlstedt Research & Technology, Jared D. McNeill (jmcneill@invisible.ca), | |
10 | * Matthew R. Green (mrg@eterna.com.au) and Nick Hudson. | 10 | * Matthew R. Green (mrg@eterna.com.au) and Nick Hudson. | |
11 | * | 11 | * | |
12 | * Redistribution and use in source and binary forms, with or without | 12 | * Redistribution and use in source and binary forms, with or without | |
13 | * modification, are permitted provided that the following conditions | 13 | * modification, are permitted provided that the following conditions | |
14 | * are met: | 14 | * are met: | |
@@ -32,27 +32,27 @@ | @@ -32,27 +32,27 @@ | |||
32 | */ | 32 | */ | |
33 | 33 | |||
34 | /* | 34 | /* | |
35 | * USB Universal Host Controller driver. | 35 | * USB Universal Host Controller driver. | |
36 | * Handles e.g. PIIX3 and PIIX4. | 36 | * Handles e.g. PIIX3 and PIIX4. | |
37 | * | 37 | * | |
38 | * UHCI spec: http://www.intel.com/technology/usb/spec.htm | 38 | * UHCI spec: http://www.intel.com/technology/usb/spec.htm | |
39 | * USB spec: http://www.usb.org/developers/docs/ | 39 | * USB spec: http://www.usb.org/developers/docs/ | |
40 | * PIIXn spec: ftp://download.intel.com/design/intarch/datashts/29055002.pdf | 40 | * PIIXn spec: ftp://download.intel.com/design/intarch/datashts/29055002.pdf | |
41 | * ftp://download.intel.com/design/intarch/datashts/29056201.pdf | 41 | * ftp://download.intel.com/design/intarch/datashts/29056201.pdf | |
42 | */ | 42 | */ | |
43 | 43 | |||
44 | #include <sys/cdefs.h> | 44 | #include <sys/cdefs.h> | |
45 | __KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.309 2022/03/03 06:04:31 riastradh Exp $"); | 45 | __KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.310 2022/03/03 06:08:50 riastradh Exp $"); | |
46 | 46 | |||
47 | #ifdef _KERNEL_OPT | 47 | #ifdef _KERNEL_OPT | |
48 | #include "opt_usb.h" | 48 | #include "opt_usb.h" | |
49 | #endif | 49 | #endif | |
50 | 50 | |||
51 | #include <sys/param.h> | 51 | #include <sys/param.h> | |
52 | 52 | |||
53 | #include <sys/bus.h> | 53 | #include <sys/bus.h> | |
54 | #include <sys/cpu.h> | 54 | #include <sys/cpu.h> | |
55 | #include <sys/device.h> | 55 | #include <sys/device.h> | |
56 | #include <sys/kernel.h> | 56 | #include <sys/kernel.h> | |
57 | #include <sys/kmem.h> | 57 | #include <sys/kmem.h> | |
58 | #include <sys/mutex.h> | 58 | #include <sys/mutex.h> | |
@@ -2392,35 +2392,30 @@ uhci_abortx(struct usbd_xfer *xfer) | @@ -2392,35 +2392,30 @@ uhci_abortx(struct usbd_xfer *xfer) | |||
2392 | std->td.td_status &= htole32(~(UHCI_TD_ACTIVE | UHCI_TD_IOC)); | 2392 | std->td.td_status &= htole32(~(UHCI_TD_ACTIVE | UHCI_TD_IOC)); | |
2393 | usb_syncmem(&std->dma, | 2393 | usb_syncmem(&std->dma, | |
2394 | std->offs + offsetof(uhci_td_t, td_status), | 2394 | std->offs + offsetof(uhci_td_t, td_status), | |
2395 | sizeof(std->td.td_status), | 2395 | sizeof(std->td.td_status), | |
2396 | BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); | 2396 | BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); | |
2397 | } | 2397 | } | |
2398 | 2398 | |||
2399 | /* | 2399 | /* | |
2400 | * HC Step 2: Wait until we know hardware has finished any possible | 2400 | * HC Step 2: Wait until we know hardware has finished any possible | |
2401 | * use of the xfer. | 2401 | * use of the xfer. | |
2402 | */ | 2402 | */ | |
2403 | /* Hardware finishes in 1ms */ | 2403 | /* Hardware finishes in 1ms */ | |
2404 | usb_delay_ms_locked(upipe->pipe.up_dev->ud_bus, 2, &sc->sc_lock); | 2404 | usb_delay_ms_locked(upipe->pipe.up_dev->ud_bus, 2, &sc->sc_lock); | |
2405 | ||||
2406 | /* | |||
2407 | * HC Step 3: Notify completion to waiting xfers. | |||
2408 | */ | |||
2409 | dying: | 2405 | dying: | |
2410 | #ifdef DIAGNOSTIC | 2406 | #ifdef DIAGNOSTIC | |
2411 | ux->ux_isdone = true; | 2407 | ux->ux_isdone = true; | |
2412 | #endif | 2408 | #endif | |
2413 | usb_transfer_complete(xfer); | |||
2414 | DPRINTFN(14, "end", 0, 0, 0, 0); | 2409 | DPRINTFN(14, "end", 0, 0, 0, 0); | |
2415 | 2410 | |||
2416 | KASSERT(mutex_owned(&sc->sc_lock)); | 2411 | KASSERT(mutex_owned(&sc->sc_lock)); | |
2417 | } | 2412 | } | |
2418 | 2413 | |||
2419 | /* Close a device bulk pipe. */ | 2414 | /* Close a device bulk pipe. */ | |
2420 | void | 2415 | void | |
2421 | uhci_device_bulk_close(struct usbd_pipe *pipe) | 2416 | uhci_device_bulk_close(struct usbd_pipe *pipe) | |
2422 | { | 2417 | { | |
2423 | struct uhci_pipe *upipe = UHCI_PIPE2UPIPE(pipe); | 2418 | struct uhci_pipe *upipe = UHCI_PIPE2UPIPE(pipe); | |
2424 | uhci_softc_t *sc = UHCI_PIPE2SC(pipe); | 2419 | uhci_softc_t *sc = UHCI_PIPE2SC(pipe); | |
2425 | 2420 | |||
2426 | KASSERT(mutex_owned(&sc->sc_lock)); | 2421 | KASSERT(mutex_owned(&sc->sc_lock)); |
--- src/sys/dev/usb/usbdi.c 2022/03/03 06:07:11 1.226
+++ src/sys/dev/usb/usbdi.c 2022/03/03 06:08:50 1.227
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: usbdi.c,v 1.226 2022/03/03 06:07:11 riastradh Exp $ */ | 1 | /* $NetBSD: usbdi.c,v 1.227 2022/03/03 06:08:50 riastradh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Lennart Augustsson (lennart@augustsson.net) at | 8 | * by Lennart Augustsson (lennart@augustsson.net) at | |
9 | * Carlstedt Research & Technology, Matthew R. Green (mrg@eterna.com.au), | 9 | * Carlstedt Research & Technology, Matthew R. Green (mrg@eterna.com.au), | |
10 | * and Nick Hudson. | 10 | * and Nick Hudson. | |
11 | * | 11 | * | |
12 | * Redistribution and use in source and binary forms, with or without | 12 | * Redistribution and use in source and binary forms, with or without | |
13 | * modification, are permitted provided that the following conditions | 13 | * modification, are permitted provided that the following conditions | |
14 | * are met: | 14 | * are met: | |
@@ -22,27 +22,27 @@ | @@ -22,27 +22,27 @@ | |||
22 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 22 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
23 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 23 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
31 | * POSSIBILITY OF SUCH DAMAGE. | 31 | * POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | __KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.226 2022/03/03 06:07:11 riastradh Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.227 2022/03/03 06:08:50 riastradh Exp $"); | |
36 | 36 | |||
37 | #ifdef _KERNEL_OPT | 37 | #ifdef _KERNEL_OPT | |
38 | #include "opt_usb.h" | 38 | #include "opt_usb.h" | |
39 | #include "opt_compat_netbsd.h" | 39 | #include "opt_compat_netbsd.h" | |
40 | #include "usb_dma.h" | 40 | #include "usb_dma.h" | |
41 | #endif | 41 | #endif | |
42 | 42 | |||
43 | #include <sys/param.h> | 43 | #include <sys/param.h> | |
44 | #include <sys/systm.h> | 44 | #include <sys/systm.h> | |
45 | #include <sys/kernel.h> | 45 | #include <sys/kernel.h> | |
46 | #include <sys/device.h> | 46 | #include <sys/device.h> | |
47 | #include <sys/kmem.h> | 47 | #include <sys/kmem.h> | |
48 | #include <sys/proc.h> | 48 | #include <sys/proc.h> | |
@@ -1523,31 +1523,33 @@ usbd_xfer_abort(struct usbd_xfer *xfer) | @@ -1523,31 +1523,33 @@ usbd_xfer_abort(struct usbd_xfer *xfer) | |||
1523 | */ | 1523 | */ | |
1524 | KASSERT(xfer->ux_status != USBD_CANCELLED); | 1524 | KASSERT(xfer->ux_status != USBD_CANCELLED); | |
1525 | if (xfer->ux_status != USBD_IN_PROGRESS) | 1525 | if (xfer->ux_status != USBD_IN_PROGRESS) | |
1526 | return; | 1526 | return; | |
1527 | 1527 | |||
1528 | /* | 1528 | /* | |
1529 | * Cancel the timeout if we can, but only asynchronously; see | 1529 | * Cancel the timeout if we can, but only asynchronously; see | |
1530 | * usbd_xfer_cancel_timeout_async for why we need not wait for | 1530 | * usbd_xfer_cancel_timeout_async for why we need not wait for | |
1531 | * the callout or task here. | 1531 | * the callout or task here. | |
1532 | */ | 1532 | */ | |
1533 | usbd_xfer_cancel_timeout_async(xfer); | 1533 | usbd_xfer_cancel_timeout_async(xfer); | |
1534 | 1534 | |||
1535 | /* | 1535 | /* | |
1536 | * We beat everyone else. Claim the status as cancelled and do | 1536 | * We beat everyone else. Claim the status as cancelled, do | |
1537 | * the bus-specific dance to abort the hardware. | 1537 | * the bus-specific dance to abort the hardware, and complete | |
1538 | * the xfer. | |||
1538 | */ | 1539 | */ | |
1539 | xfer->ux_status = USBD_CANCELLED; | 1540 | xfer->ux_status = USBD_CANCELLED; | |
1540 | bus->ub_methods->ubm_abortx(xfer); | 1541 | bus->ub_methods->ubm_abortx(xfer); | |
1542 | usb_transfer_complete(xfer); | |||
1541 | } | 1543 | } | |
1542 | 1544 | |||
1543 | /* | 1545 | /* | |
1544 | * usbd_xfer_timeout(xfer) | 1546 | * usbd_xfer_timeout(xfer) | |
1545 | * | 1547 | * | |
1546 | * Called at IPL_SOFTCLOCK when too much time has elapsed waiting | 1548 | * Called at IPL_SOFTCLOCK when too much time has elapsed waiting | |
1547 | * for xfer to complete. Since we can't abort the xfer at | 1549 | * for xfer to complete. Since we can't abort the xfer at | |
1548 | * IPL_SOFTCLOCK, defer to a usb_task to run it in thread context, | 1550 | * IPL_SOFTCLOCK, defer to a usb_task to run it in thread context, | |
1549 | * unless the xfer has completed or aborted concurrently -- and if | 1551 | * unless the xfer has completed or aborted concurrently -- and if | |
1550 | * the xfer has also been resubmitted, take care of rescheduling | 1552 | * the xfer has also been resubmitted, take care of rescheduling | |
1551 | * the callout. | 1553 | * the callout. | |
1552 | */ | 1554 | */ | |
1553 | static void | 1555 | static void | |
@@ -1607,31 +1609,33 @@ usbd_xfer_timeout_task(void *cookie) | @@ -1607,31 +1609,33 @@ usbd_xfer_timeout_task(void *cookie) | |||
1607 | if (!usbd_xfer_probe_timeout(xfer)) | 1609 | if (!usbd_xfer_probe_timeout(xfer)) | |
1608 | goto out; | 1610 | goto out; | |
1609 | 1611 | |||
1610 | /* | 1612 | /* | |
1611 | * May have completed or been aborted, but we're the only one | 1613 | * May have completed or been aborted, but we're the only one | |
1612 | * who can time it out. If it has completed or been aborted, | 1614 | * who can time it out. If it has completed or been aborted, | |
1613 | * no need to timeout. | 1615 | * no need to timeout. | |
1614 | */ | 1616 | */ | |
1615 | KASSERT(xfer->ux_status != USBD_TIMEOUT); | 1617 | KASSERT(xfer->ux_status != USBD_TIMEOUT); | |
1616 | if (xfer->ux_status != USBD_IN_PROGRESS) | 1618 | if (xfer->ux_status != USBD_IN_PROGRESS) | |
1617 | goto out; | 1619 | goto out; | |
1618 | 1620 | |||
1619 | /* | 1621 | /* | |
1620 | * We beat everyone else. Claim the status as timed out and do | 1622 | * We beat everyone else. Claim the status as timed out, do | |
1621 | * the bus-specific dance to abort the hardware. | 1623 | * the bus-specific dance to abort the hardware, and complete | |
1624 | * the xfer. | |||
1622 | */ | 1625 | */ | |
1623 | xfer->ux_status = USBD_TIMEOUT; | 1626 | xfer->ux_status = USBD_TIMEOUT; | |
1624 | bus->ub_methods->ubm_abortx(xfer); | 1627 | bus->ub_methods->ubm_abortx(xfer); | |
1628 | usb_transfer_complete(xfer); | |||
1625 | 1629 | |||
1626 | out: /* All done -- release the lock. */ | 1630 | out: /* All done -- release the lock. */ | |
1627 | mutex_exit(bus->ub_lock); | 1631 | mutex_exit(bus->ub_lock); | |
1628 | } | 1632 | } | |
1629 | 1633 | |||
1630 | /* | 1634 | /* | |
1631 | * usbd_xfer_probe_timeout(xfer) | 1635 | * usbd_xfer_probe_timeout(xfer) | |
1632 | * | 1636 | * | |
1633 | * Probe the status of xfer's timeout. Acknowledge and process a | 1637 | * Probe the status of xfer's timeout. Acknowledge and process a | |
1634 | * request to reschedule. Return true if the timeout is still | 1638 | * request to reschedule. Return true if the timeout is still | |
1635 | * valid and the caller should take further action (queueing a | 1639 | * valid and the caller should take further action (queueing a | |
1636 | * task or aborting the xfer), false if it must stop here. | 1640 | * task or aborting the xfer), false if it must stop here. | |
1637 | */ | 1641 | */ |
--- src/sys/dev/usb/xhci.c 2022/03/03 06:04:31 1.156
+++ src/sys/dev/usb/xhci.c 2022/03/03 06:08:50 1.157
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: xhci.c,v 1.156 2022/03/03 06:04:31 riastradh Exp $ */ | 1 | /* $NetBSD: xhci.c,v 1.157 2022/03/03 06:08:50 riastradh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2013 Jonathan A. Kollasch | 4 | * Copyright (c) 2013 Jonathan A. Kollasch | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | |
25 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 25 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | /* | 29 | /* | |
30 | * USB rev 2.0 and rev 3.1 specification | 30 | * USB rev 2.0 and rev 3.1 specification | |
31 | * http://www.usb.org/developers/docs/ | 31 | * http://www.usb.org/developers/docs/ | |
32 | * xHCI rev 1.1 specification | 32 | * xHCI rev 1.1 specification | |
33 | * http://www.intel.com/technology/usb/spec.htm | 33 | * http://www.intel.com/technology/usb/spec.htm | |
34 | */ | 34 | */ | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | __KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.156 2022/03/03 06:04:31 riastradh Exp $"); | 37 | __KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.157 2022/03/03 06:08:50 riastradh Exp $"); | |
38 | 38 | |||
39 | #ifdef _KERNEL_OPT | 39 | #ifdef _KERNEL_OPT | |
40 | #include "opt_usb.h" | 40 | #include "opt_usb.h" | |
41 | #endif | 41 | #endif | |
42 | 42 | |||
43 | #include <sys/param.h> | 43 | #include <sys/param.h> | |
44 | #include <sys/systm.h> | 44 | #include <sys/systm.h> | |
45 | #include <sys/kernel.h> | 45 | #include <sys/kernel.h> | |
46 | #include <sys/kmem.h> | 46 | #include <sys/kmem.h> | |
47 | #include <sys/device.h> | 47 | #include <sys/device.h> | |
48 | #include <sys/select.h> | 48 | #include <sys/select.h> | |
49 | #include <sys/proc.h> | 49 | #include <sys/proc.h> | |
50 | #include <sys/queue.h> | 50 | #include <sys/queue.h> | |
@@ -2144,28 +2144,26 @@ xhci_abortx(struct usbd_xfer *xfer) | @@ -2144,28 +2144,26 @@ xhci_abortx(struct usbd_xfer *xfer) | |||
2144 | XHCIHIST_FUNC(); | 2144 | XHCIHIST_FUNC(); | |
2145 | struct xhci_softc * const sc = XHCI_XFER2SC(xfer); | 2145 | struct xhci_softc * const sc = XHCI_XFER2SC(xfer); | |
2146 | 2146 | |||
2147 | XHCIHIST_CALLARGS("xfer %#jx pipe %#jx", | 2147 | XHCIHIST_CALLARGS("xfer %#jx pipe %#jx", | |
2148 | (uintptr_t)xfer, (uintptr_t)xfer->ux_pipe, 0, 0); | 2148 | (uintptr_t)xfer, (uintptr_t)xfer->ux_pipe, 0, 0); | |
2149 | 2149 | |||
2150 | KASSERT(mutex_owned(&sc->sc_lock)); | 2150 | KASSERT(mutex_owned(&sc->sc_lock)); | |
2151 | KASSERTMSG((xfer->ux_status == USBD_CANCELLED || | 2151 | KASSERTMSG((xfer->ux_status == USBD_CANCELLED || | |
2152 | xfer->ux_status == USBD_TIMEOUT), | 2152 | xfer->ux_status == USBD_TIMEOUT), | |
2153 | "bad abort status: %d", xfer->ux_status); | 2153 | "bad abort status: %d", xfer->ux_status); | |
2154 | 2154 | |||
2155 | xhci_pipe_restart(xfer->ux_pipe); | 2155 | xhci_pipe_restart(xfer->ux_pipe); | |
2156 | 2156 | |||
2157 | usb_transfer_complete(xfer); | |||
2158 | ||||
2159 | DPRINTFN(14, "end", 0, 0, 0, 0); | 2157 | DPRINTFN(14, "end", 0, 0, 0, 0); | |
2160 | } | 2158 | } | |
2161 | 2159 | |||
2162 | static void | 2160 | static void | |
2163 | xhci_host_dequeue(struct xhci_ring * const xr) | 2161 | xhci_host_dequeue(struct xhci_ring * const xr) | |
2164 | { | 2162 | { | |
2165 | /* When dequeueing the controller, update our struct copy too */ | 2163 | /* When dequeueing the controller, update our struct copy too */ | |
2166 | memset(xr->xr_trb, 0, xr->xr_ntrb * XHCI_TRB_SIZE); | 2164 | memset(xr->xr_trb, 0, xr->xr_ntrb * XHCI_TRB_SIZE); | |
2167 | usb_syncmem(&xr->xr_dma, 0, xr->xr_ntrb * XHCI_TRB_SIZE, | 2165 | usb_syncmem(&xr->xr_dma, 0, xr->xr_ntrb * XHCI_TRB_SIZE, | |
2168 | BUS_DMASYNC_PREWRITE); | 2166 | BUS_DMASYNC_PREWRITE); | |
2169 | memset(xr->xr_cookies, 0, xr->xr_ntrb * sizeof(*xr->xr_cookies)); | 2167 | memset(xr->xr_cookies, 0, xr->xr_ntrb * sizeof(*xr->xr_cookies)); | |
2170 | 2168 | |||
2171 | xr->xr_ep = 0; | 2169 | xr->xr_ep = 0; |
--- src/sys/external/bsd/dwc2/dwc2.c 2022/03/03 06:04:31 1.78
+++ src/sys/external/bsd/dwc2/dwc2.c 2022/03/03 06:08:50 1.79
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: dwc2.c,v 1.78 2022/03/03 06:04:31 riastradh Exp $ */ | 1 | /* $NetBSD: dwc2.c,v 1.79 2022/03/03 06:08:50 riastradh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Nick Hudson | 8 | * by Nick Hudson | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -20,27 +20,27 @@ | @@ -20,27 +20,27 @@ | |||
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | __KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.78 2022/03/03 06:04:31 riastradh Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.79 2022/03/03 06:08:50 riastradh Exp $"); | |
34 | 34 | |||
35 | #include "opt_usb.h" | 35 | #include "opt_usb.h" | |
36 | 36 | |||
37 | #include <sys/param.h> | 37 | #include <sys/param.h> | |
38 | 38 | |||
39 | #include <sys/cpu.h> | 39 | #include <sys/cpu.h> | |
40 | #include <sys/device.h> | 40 | #include <sys/device.h> | |
41 | #include <sys/kernel.h> | 41 | #include <sys/kernel.h> | |
42 | #include <sys/kmem.h> | 42 | #include <sys/kmem.h> | |
43 | #include <sys/proc.h> | 43 | #include <sys/proc.h> | |
44 | #include <sys/queue.h> | 44 | #include <sys/queue.h> | |
45 | #include <sys/select.h> | 45 | #include <sys/select.h> | |
46 | #include <sys/sysctl.h> | 46 | #include <sys/sysctl.h> | |
@@ -505,40 +505,35 @@ dwc2_abortx(struct usbd_xfer *xfer) | @@ -505,40 +505,35 @@ dwc2_abortx(struct usbd_xfer *xfer) | |||
505 | } | 505 | } | |
506 | } | 506 | } | |
507 | 507 | |||
508 | /* | 508 | /* | |
509 | * If we're dying, skip the hardware action and just notify the | 509 | * If we're dying, skip the hardware action and just notify the | |
510 | * software that we're done. | 510 | * software that we're done. | |
511 | */ | 511 | */ | |
512 | if (sc->sc_dying) { | 512 | if (sc->sc_dying) { | |
513 | DPRINTFN(4, "xfer %p dying 0x%08x", xfer, xfer->ux_status); | 513 | DPRINTFN(4, "xfer %p dying 0x%08x", xfer, xfer->ux_status); | |
514 | goto dying; | 514 | goto dying; | |
515 | } | 515 | } | |
516 | 516 | |||
517 | /* | 517 | /* | |
518 | * HC Step 1: Handle the hardware. | 518 | * Handle the hardware. | |
519 | */ | 519 | */ | |
520 | err = dwc2_hcd_urb_dequeue(hsotg, dxfer->urb); | 520 | err = dwc2_hcd_urb_dequeue(hsotg, dxfer->urb); | |
521 | if (err) { | 521 | if (err) { | |
522 | DPRINTF("dwc2_hcd_urb_dequeue failed\n"); | 522 | DPRINTF("dwc2_hcd_urb_dequeue failed\n"); | |
523 | } | 523 | } | |
524 | 524 | |||
525 | dying: | 525 | dying: | |
526 | mutex_spin_exit(&hsotg->lock); | 526 | mutex_spin_exit(&hsotg->lock); | |
527 | ||||
528 | /* | |||
529 | * Final Step: Notify completion to waiting xfers. | |||
530 | */ | |||
531 | usb_transfer_complete(xfer); | |||
532 | KASSERT(mutex_owned(&sc->sc_lock)); | 527 | KASSERT(mutex_owned(&sc->sc_lock)); | |
533 | } | 528 | } | |
534 | 529 | |||
535 | Static void | 530 | Static void | |
536 | dwc2_noop(struct usbd_pipe *pipe) | 531 | dwc2_noop(struct usbd_pipe *pipe) | |
537 | { | 532 | { | |
538 | 533 | |||
539 | } | 534 | } | |
540 | 535 | |||
541 | Static void | 536 | Static void | |
542 | dwc2_device_clear_toggle(struct usbd_pipe *pipe) | 537 | dwc2_device_clear_toggle(struct usbd_pipe *pipe) | |
543 | { | 538 | { | |
544 | 539 |