usb: Factor usb_insert_transfer out of upm_transfer and make private. Almost every upm_transfer function starts with: mutex_enter(&sc->sc_lock); err = usb_insert_transfer(xfer); mutex_exit(&sc->sc_lock); if (err) return err; Some of them have debug messages sprinkled in here too, or assert that err == USBD_NORMAL_COMPLETION (alternative is USBD_IN_PROGRESS, only for pipes with up_running or up_serialise, presumably not applicable for these types of pipes). Some of them also assert xfer->ux_status == USBD_NOT_STARTED, which is guaranteed on entry and preserved by usb_insert_transer. Exceptions: - arch/mips/adm5120/dev/ahci.c ahci_device_isoc_transfer just returns USBD_NORMAL_COMPLETION, but I'm pretty sure this is and always has been broken anyway, so won't make anything worse (if anything, might make it better...) - external/bsd/dwc2/dwc2.c dwc2_device_bulk_transfer and dwc2_device_isoc_transfer _also_ issue dwc2_device_start(xfer) under the lock. This is probably a better way to do it, but let's do it uniformly across all HCIs at once. - rump/dev/lib/libugenhc/ugenhc.c rumpusb_device_bulk_transfer sometimes returns USBD_IN_PROGRESS _without_ queueing the transfer, in the !rump_threads case. Not really sure how this is supposed to work... If it actually breaks anything, we can figure it out.diff -r1.28 -r1.29 src/sys/arch/mips/adm5120/dev/ahci.c
(riastradh)
--- src/sys/arch/mips/adm5120/dev/ahci.c 2021/12/21 09:51:22 1.28
+++ src/sys/arch/mips/adm5120/dev/ahci.c 2022/03/03 06:04:31 1.29
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ahci.c,v 1.28 2021/12/21 09:51:22 skrll Exp $ */ | 1 | /* $NetBSD: ahci.c,v 1.29 2022/03/03 06:04:31 riastradh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko. | 4 | * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or | 7 | * Redistribution and use in source and binary forms, with or | |
8 | * without modification, are permitted provided that the following | 8 | * without modification, are permitted provided that the following | |
9 | * conditions are met: | 9 | * conditions 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 | 12 | * 2. Redistributions in binary form must reproduce the above | |
13 | * copyright notice, this list of conditions and the following | 13 | * copyright notice, this list of conditions and the following | |
14 | * disclaimer in the documentation and/or other materials provided | 14 | * disclaimer in the documentation and/or other materials provided | |
@@ -54,27 +54,27 @@ | @@ -54,27 +54,27 @@ | |||
54 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 54 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
55 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 55 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
56 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 56 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
57 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 57 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
58 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 58 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
59 | * POSSIBILITY OF SUCH DAMAGE. | 59 | * POSSIBILITY OF SUCH DAMAGE. | |
60 | */ | 60 | */ | |
61 | 61 | |||
62 | /* | 62 | /* | |
63 | * !! HIGHLY EXPERIMENTAL CODE !! | 63 | * !! HIGHLY EXPERIMENTAL CODE !! | |
64 | */ | 64 | */ | |
65 | 65 | |||
66 | #include <sys/cdefs.h> | 66 | #include <sys/cdefs.h> | |
67 | __KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.28 2021/12/21 09:51:22 skrll Exp $"); | 67 | __KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.29 2022/03/03 06:04:31 riastradh Exp $"); | |
68 | 68 | |||
69 | #include <sys/param.h> | 69 | #include <sys/param.h> | |
70 | #include <sys/systm.h> | 70 | #include <sys/systm.h> | |
71 | #include <sys/kernel.h> | 71 | #include <sys/kernel.h> | |
72 | #include <sys/proc.h> | 72 | #include <sys/proc.h> | |
73 | #include <sys/device.h> | 73 | #include <sys/device.h> | |
74 | #include <sys/kmem.h> | 74 | #include <sys/kmem.h> | |
75 | 75 | |||
76 | #include <sys/bus.h> | 76 | #include <sys/bus.h> | |
77 | #include <machine/cpu.h> | 77 | #include <machine/cpu.h> | |
78 | 78 | |||
79 | #include <dev/usb/usb.h> | 79 | #include <dev/usb/usb.h> | |
80 | #include <dev/usb/usbdi.h> | 80 | #include <dev/usb/usbdi.h> | |
@@ -719,42 +719,30 @@ ahci_roothub_ctrl(struct usbd_bus *bus, | @@ -719,42 +719,30 @@ ahci_roothub_ctrl(struct usbd_bus *bus, | |||
719 | default: | 719 | default: | |
720 | DPRINTF(D_MSG, ("ioerr(UR=%02x,UT=%02x) ", | 720 | DPRINTF(D_MSG, ("ioerr(UR=%02x,UT=%02x) ", | |
721 | req->bRequest, req->bmRequestType)); | 721 | req->bRequest, req->bmRequestType)); | |
722 | /* default from usbroothub */ | 722 | /* default from usbroothub */ | |
723 | return buflen; | 723 | return buflen; | |
724 | } | 724 | } | |
725 | 725 | |||
726 | return totlen; | 726 | return totlen; | |
727 | } | 727 | } | |
728 | 728 | |||
729 | static usbd_status | 729 | static usbd_status | |
730 | ahci_root_intr_transfer(struct usbd_xfer *xfer) | 730 | ahci_root_intr_transfer(struct usbd_xfer *xfer) | |
731 | { | 731 | { | |
732 | struct ahci_softc *sc = AHCI_XFER2SC(xfer); | |||
733 | usbd_status error; | |||
734 | 732 | |||
735 | DPRINTF(D_TRACE, ("SLRItransfer ")); | 733 | DPRINTF(D_TRACE, ("SLRItransfer ")); | |
736 | 734 | |||
737 | /* Insert last in queue */ | 735 | /* Pipe isn't running, start first. */ | |
738 | mutex_enter(&sc->sc_lock); | |||
739 | error = usb_insert_transfer(xfer); | |||
740 | mutex_exit(&sc->sc_lock); | |||
741 | if (error) | |||
742 | return error; | |||
743 | ||||
744 | /* | |||
745 | * Pipe isn't running (otherwise error would be USBD_INPROG), | |||
746 | * start first. | |||
747 | */ | |||
748 | return ahci_root_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 736 | return ahci_root_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
749 | } | 737 | } | |
750 | 738 | |||
751 | static usbd_status | 739 | static usbd_status | |
752 | ahci_root_intr_start(struct usbd_xfer *xfer) | 740 | ahci_root_intr_start(struct usbd_xfer *xfer) | |
753 | { | 741 | { | |
754 | struct ahci_softc *sc = AHCI_XFER2SC(xfer); | 742 | struct ahci_softc *sc = AHCI_XFER2SC(xfer); | |
755 | 743 | |||
756 | DPRINTF(D_TRACE, ("SLRIstart ")); | 744 | DPRINTF(D_TRACE, ("SLRIstart ")); | |
757 | 745 | |||
758 | mutex_enter(&sc->sc_lock); | 746 | mutex_enter(&sc->sc_lock); | |
759 | KASSERT(sc->sc_intr_xfer == NULL); | 747 | KASSERT(sc->sc_intr_xfer == NULL); | |
760 | sc->sc_interval = MS_TO_TICKS(xfer->ux_pipe->up_endpoint->ue_edesc->bInterval); | 748 | sc->sc_interval = MS_TO_TICKS(xfer->ux_pipe->up_endpoint->ue_edesc->bInterval); | |
@@ -817,37 +805,29 @@ ahci_root_intr_done(struct usbd_xfer *xf | @@ -817,37 +805,29 @@ ahci_root_intr_done(struct usbd_xfer *xf | |||
817 | //DPRINTF(D_XFER, ("RIdn ")); | 805 | //DPRINTF(D_XFER, ("RIdn ")); | |
818 | 806 | |||
819 | KASSERT(mutex_owned(&sc->sc_lock)); | 807 | KASSERT(mutex_owned(&sc->sc_lock)); | |
820 | 808 | |||
821 | /* Claim the xfer so it doesn't get completed again. */ | 809 | /* Claim the xfer so it doesn't get completed again. */ | |
822 | KASSERT(sc->sc_intr_xfer == xfer); | 810 | KASSERT(sc->sc_intr_xfer == xfer); | |
823 | KASSERT(xfer->ux_status != USBD_IN_PROGRESS); | 811 | KASSERT(xfer->ux_status != USBD_IN_PROGRESS); | |
824 | sc->sc_intr_xfer = NULL; | 812 | sc->sc_intr_xfer = NULL; | |
825 | } | 813 | } | |
826 | 814 | |||
827 | static usbd_status | 815 | static usbd_status | |
828 | ahci_device_ctrl_transfer(struct usbd_xfer *xfer) | 816 | ahci_device_ctrl_transfer(struct usbd_xfer *xfer) | |
829 | { | 817 | { | |
830 | struct ahci_softc *sc = AHCI_XFER2SC(xfer); | |||
831 | usbd_status error; | |||
832 | 818 | |||
833 | DPRINTF(D_TRACE, ("C")); | 819 | DPRINTF(D_TRACE, ("C")); | |
834 | 820 | |||
835 | mutex_enter(&sc->sc_lock); | |||
836 | error = usb_insert_transfer(xfer); | |||
837 | mutex_exit(&sc->sc_lock); | |||
838 | if (error) | |||
839 | return error; | |||
840 | ||||
841 | return ahci_device_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 821 | return ahci_device_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
842 | } | 822 | } | |
843 | 823 | |||
844 | static usbd_status | 824 | static usbd_status | |
845 | ahci_device_ctrl_start(struct usbd_xfer *xfer) | 825 | ahci_device_ctrl_start(struct usbd_xfer *xfer) | |
846 | { | 826 | { | |
847 | usbd_status status = USBD_NORMAL_COMPLETION; | 827 | usbd_status status = USBD_NORMAL_COMPLETION; | |
848 | int s, err; | 828 | int s, err; | |
849 | static struct admhcd_ed ep_v __attribute__((aligned(16))), *ep; | 829 | static struct admhcd_ed ep_v __attribute__((aligned(16))), *ep; | |
850 | static struct admhcd_td td_v[4] __attribute__((aligned(16))), *td, *td1, *td2, *td3; | 830 | static struct admhcd_td td_v[4] __attribute__((aligned(16))), *td, *td1, *td2, *td3; | |
851 | static usb_dma_t reqdma; | 831 | static usb_dma_t reqdma; | |
852 | struct usbd_pipe *pipe = xfer->ux_pipe; | 832 | struct usbd_pipe *pipe = xfer->ux_pipe; | |
853 | usb_device_request_t *req = &xfer->ux_request; | 833 | usb_device_request_t *req = &xfer->ux_request; | |
@@ -1007,37 +987,29 @@ ahci_device_ctrl_close(struct usbd_pipe | @@ -1007,37 +987,29 @@ ahci_device_ctrl_close(struct usbd_pipe | |||
1007 | { | 987 | { | |
1008 | DPRINTF(D_TRACE, ("Ccl ")); | 988 | DPRINTF(D_TRACE, ("Ccl ")); | |
1009 | } | 989 | } | |
1010 | 990 | |||
1011 | static void | 991 | static void | |
1012 | ahci_device_ctrl_done(struct usbd_xfer *xfer) | 992 | ahci_device_ctrl_done(struct usbd_xfer *xfer) | |
1013 | { | 993 | { | |
1014 | DPRINTF(D_TRACE, ("Cdn ")); | 994 | DPRINTF(D_TRACE, ("Cdn ")); | |
1015 | } | 995 | } | |
1016 | 996 | |||
1017 | static usbd_status | 997 | static usbd_status | |
1018 | ahci_device_intr_transfer(struct usbd_xfer *xfer) | 998 | ahci_device_intr_transfer(struct usbd_xfer *xfer) | |
1019 | { | 999 | { | |
1020 | struct ahci_softc *sc = AHCI_XFER2SC(xfer); | |||
1021 | usbd_status error; | |||
1022 | 1000 | |||
1023 | DPRINTF(D_TRACE, ("INTRtrans ")); | 1001 | DPRINTF(D_TRACE, ("INTRtrans ")); | |
1024 | 1002 | |||
1025 | mutex_enter(&sc->sc_lock); | |||
1026 | error = usb_insert_transfer(xfer); | |||
1027 | mutex_exit(&sc->sc_lock); | |||
1028 | if (error) | |||
1029 | return error; | |||
1030 | ||||
1031 | return ahci_device_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 1003 | return ahci_device_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
1032 | } | 1004 | } | |
1033 | 1005 | |||
1034 | static usbd_status | 1006 | static usbd_status | |
1035 | ahci_device_intr_start(struct usbd_xfer *xfer) | 1007 | ahci_device_intr_start(struct usbd_xfer *xfer) | |
1036 | { | 1008 | { | |
1037 | struct usbd_pipe *pipe = xfer->ux_pipe; | 1009 | struct usbd_pipe *pipe = xfer->ux_pipe; | |
1038 | struct ahci_xfer *sx; | 1010 | struct ahci_xfer *sx; | |
1039 | 1011 | |||
1040 | DPRINTF(D_TRACE, ("INTRstart ")); | 1012 | DPRINTF(D_TRACE, ("INTRstart ")); | |
1041 | 1013 | |||
1042 | sx = kmem_intr_alloc(sizeof(*sx), KM_NOSLEEP); | 1014 | sx = kmem_intr_alloc(sizeof(*sx), KM_NOSLEEP); | |
1043 | if (sx == NULL) | 1015 | if (sx == NULL) | |
@@ -1151,37 +1123,29 @@ ahci_device_isoc_close(struct usbd_pipe | @@ -1151,37 +1123,29 @@ ahci_device_isoc_close(struct usbd_pipe | |||
1151 | { | 1123 | { | |
1152 | DPRINTF(D_TRACE, ("Scl ")); | 1124 | DPRINTF(D_TRACE, ("Scl ")); | |
1153 | } | 1125 | } | |
1154 | 1126 | |||
1155 | static void | 1127 | static void | |
1156 | ahci_device_isoc_done(struct usbd_xfer *xfer) | 1128 | ahci_device_isoc_done(struct usbd_xfer *xfer) | |
1157 | { | 1129 | { | |
1158 | DPRINTF(D_TRACE, ("Sdn ")); | 1130 | DPRINTF(D_TRACE, ("Sdn ")); | |
1159 | } | 1131 | } | |
1160 | 1132 | |||
1161 | static usbd_status | 1133 | static usbd_status | |
1162 | ahci_device_bulk_transfer(struct usbd_xfer *xfer) | 1134 | ahci_device_bulk_transfer(struct usbd_xfer *xfer) | |
1163 | { | 1135 | { | |
1164 | struct ahci_softc *sc = AHCI_XFER2SC(xfer); | |||
1165 | usbd_status error; | |||
1166 | 1136 | |||
1167 | DPRINTF(D_TRACE, ("B")); | 1137 | DPRINTF(D_TRACE, ("B")); | |
1168 | 1138 | |||
1169 | mutex_enter(&sc->sc_lock); | |||
1170 | error = usb_insert_transfer(xfer); | |||
1171 | mutex_exit(&sc->sc_lock); | |||
1172 | if (error) | |||
1173 | return error; | |||
1174 | ||||
1175 | return ahci_device_bulk_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 1139 | return ahci_device_bulk_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
1176 | } | 1140 | } | |
1177 | 1141 | |||
1178 | static usbd_status | 1142 | static usbd_status | |
1179 | ahci_device_bulk_start(struct usbd_xfer *xfer) | 1143 | ahci_device_bulk_start(struct usbd_xfer *xfer) | |
1180 | { | 1144 | { | |
1181 | #define NBULK_TDS 32 | 1145 | #define NBULK_TDS 32 | |
1182 | static volatile int level = 0; | 1146 | static volatile int level = 0; | |
1183 | usbd_status status = USBD_NORMAL_COMPLETION; | 1147 | usbd_status status = USBD_NORMAL_COMPLETION; | |
1184 | int s, err; | 1148 | int s, err; | |
1185 | static struct admhcd_ed ep_v __attribute__((aligned(16))), *ep; | 1149 | static struct admhcd_ed ep_v __attribute__((aligned(16))), *ep; | |
1186 | static struct admhcd_td td_v[NBULK_TDS] __attribute__((aligned(16))), *td[NBULK_TDS]; | 1150 | static struct admhcd_td td_v[NBULK_TDS] __attribute__((aligned(16))), *td[NBULK_TDS]; | |
1187 | struct usbd_pipe *pipe = xfer->ux_pipe; | 1151 | struct usbd_pipe *pipe = xfer->ux_pipe; |
--- src/sys/dev/ic/sl811hs.c 2021/12/10 20:36:03 1.108
+++ src/sys/dev/ic/sl811hs.c 2022/03/03 06:04:31 1.109
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: sl811hs.c,v 1.108 2021/12/10 20:36:03 andvar Exp $ */ | 1 | /* $NetBSD: sl811hs.c,v 1.109 2022/03/03 06:04:31 riastradh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Not (c) 2007 Matthew Orgass | 4 | * Not (c) 2007 Matthew Orgass | |
5 | * This file is public domain, meaning anyone can make any use of part or all | 5 | * This file is public domain, meaning anyone can make any use of part or all | |
6 | * of this file including copying into other works without credit. Any use, | 6 | * of this file including copying into other works without credit. Any use, | |
7 | * modified or not, is solely the responsibility of the user. If this file is | 7 | * modified or not, is solely the responsibility of the user. If this file is | |
8 | * part of a collection then use in the collection is governed by the terms of | 8 | * part of a collection then use in the collection is governed by the terms of | |
9 | * the collection. | 9 | * the collection. | |
10 | */ | 10 | */ | |
11 | 11 | |||
12 | /* | 12 | /* | |
13 | * Cypress/ScanLogic SL811HS/T USB Host Controller | 13 | * Cypress/ScanLogic SL811HS/T USB Host Controller | |
14 | * Datasheet, Errata, and App Note available at www.cypress.com | 14 | * Datasheet, Errata, and App Note available at www.cypress.com | |
@@ -58,27 +58,27 @@ | @@ -58,27 +58,27 @@ | |||
58 | */ | 58 | */ | |
59 | 59 | |||
60 | /* | 60 | /* | |
61 | * XXX TODO: | 61 | * XXX TODO: | |
62 | * copy next output packet while transfering | 62 | * copy next output packet while transfering | |
63 | * usb suspend | 63 | * usb suspend | |
64 | * could keep track of known values of all buffer space? | 64 | * could keep track of known values of all buffer space? | |
65 | * combined print/log function for errors | 65 | * combined print/log function for errors | |
66 | * | 66 | * | |
67 | * ub_usepolling support is untested and may not work | 67 | * ub_usepolling support is untested and may not work | |
68 | */ | 68 | */ | |
69 | 69 | |||
70 | #include <sys/cdefs.h> | 70 | #include <sys/cdefs.h> | |
71 | __KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.108 2021/12/10 20:36:03 andvar Exp $"); | 71 | __KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.109 2022/03/03 06:04:31 riastradh Exp $"); | |
72 | 72 | |||
73 | #ifdef _KERNEL_OPT | 73 | #ifdef _KERNEL_OPT | |
74 | #include "opt_slhci.h" | 74 | #include "opt_slhci.h" | |
75 | #include "opt_usb.h" | 75 | #include "opt_usb.h" | |
76 | #endif | 76 | #endif | |
77 | 77 | |||
78 | #include <sys/param.h> | 78 | #include <sys/param.h> | |
79 | 79 | |||
80 | #include <sys/bus.h> | 80 | #include <sys/bus.h> | |
81 | #include <sys/cpu.h> | 81 | #include <sys/cpu.h> | |
82 | #include <sys/device.h> | 82 | #include <sys/device.h> | |
83 | #include <sys/gcq.h> | 83 | #include <sys/gcq.h> | |
84 | #include <sys/intr.h> | 84 | #include <sys/intr.h> | |
@@ -829,48 +829,33 @@ slhci_freex(struct usbd_bus *bus, struct | @@ -829,48 +829,33 @@ slhci_freex(struct usbd_bus *bus, struct | |||
829 | 829 | |||
830 | static void | 830 | static void | |
831 | slhci_get_lock(struct usbd_bus *bus, kmutex_t **lock) | 831 | slhci_get_lock(struct usbd_bus *bus, kmutex_t **lock) | |
832 | { | 832 | { | |
833 | struct slhci_softc *sc = SLHCI_BUS2SC(bus); | 833 | struct slhci_softc *sc = SLHCI_BUS2SC(bus); | |
834 | 834 | |||
835 | *lock = &sc->sc_lock; | 835 | *lock = &sc->sc_lock; | |
836 | } | 836 | } | |
837 | 837 | |||
838 | usbd_status | 838 | usbd_status | |
839 | slhci_transfer(struct usbd_xfer *xfer) | 839 | slhci_transfer(struct usbd_xfer *xfer) | |
840 | { | 840 | { | |
841 | SLHCIHIST_FUNC(); SLHCIHIST_CALLED(); | 841 | SLHCIHIST_FUNC(); SLHCIHIST_CALLED(); | |
842 | struct slhci_softc *sc = SLHCI_XFER2SC(xfer); | |||
843 | usbd_status error; | 842 | usbd_status error; | |
844 | 843 | |||
845 | DLOG(D_TRACE, "transfer type %jd xfer %#jx spipe %#jx ", | 844 | DLOG(D_TRACE, "transfer type %jd xfer %#jx spipe %#jx ", | |
846 | SLHCI_XFER_TYPE(xfer), (uintptr_t)xfer, (uintptr_t)xfer->ux_pipe, | 845 | SLHCI_XFER_TYPE(xfer), (uintptr_t)xfer, (uintptr_t)xfer->ux_pipe, | |
847 | 0); | 846 | 0); | |
848 | 847 | |||
849 | /* Insert last in queue */ | 848 | /* Pipe isn't running, so start it first. */ | |
850 | mutex_enter(&sc->sc_lock); | |||
851 | error = usb_insert_transfer(xfer); | |||
852 | mutex_exit(&sc->sc_lock); | |||
853 | if (error) { | |||
854 | if (error != USBD_IN_PROGRESS) | |||
855 | DLOG(D_ERR, "usb_insert_transfer returns %jd!", error, | |||
856 | 0,0,0); | |||
857 | return error; | |||
858 | } | |||
859 | ||||
860 | /* | |||
861 | * Pipe isn't running (otherwise error would be USBD_INPROG), | |||
862 | * so start it first. | |||
863 | */ | |||
864 | 849 | |||
865 | /* | 850 | /* | |
866 | * Start will take the lock. | 851 | * Start will take the lock. | |
867 | */ | 852 | */ | |
868 | error = xfer->ux_pipe->up_methods->upm_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 853 | error = xfer->ux_pipe->up_methods->upm_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
869 | 854 | |||
870 | return error; | 855 | return error; | |
871 | } | 856 | } | |
872 | 857 | |||
873 | /* It is not safe for start to return anything other than USBD_INPROG. */ | 858 | /* It is not safe for start to return anything other than USBD_INPROG. */ | |
874 | usbd_status | 859 | usbd_status | |
875 | slhci_start(struct usbd_xfer *xfer) | 860 | slhci_start(struct usbd_xfer *xfer) | |
876 | { | 861 | { |
--- src/sys/dev/usb/ehci.c 2022/02/12 15:55:04 1.302
+++ src/sys/dev/usb/ehci.c 2022/03/03 06:04:31 1.303
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ehci.c,v 1.302 2022/02/12 15:55:04 macallan Exp $ */ | 1 | /* $NetBSD: ehci.c,v 1.303 2022/03/03 06:04:31 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.302 2022/02/12 15:55:04 macallan Exp $"); | 57 | __KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.303 2022/03/03 06:04:31 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> | |
@@ -2738,35 +2738,26 @@ ehci_disown(ehci_softc_t *sc, int index, | @@ -2738,35 +2738,26 @@ ehci_disown(ehci_softc_t *sc, int index, | |||
2738 | } else { | 2738 | } else { | |
2739 | #ifdef DIAGNOSTIC | 2739 | #ifdef DIAGNOSTIC | |
2740 | printf("%s: npcomp == 0\n", device_xname(sc->sc_dev)); | 2740 | printf("%s: npcomp == 0\n", device_xname(sc->sc_dev)); | |
2741 | #endif | 2741 | #endif | |
2742 | } | 2742 | } | |
2743 | port = EHCI_PORTSC(index); | 2743 | port = EHCI_PORTSC(index); | |
2744 | v = EOREAD4(sc, port) &~ EHCI_PS_CLEAR; | 2744 | v = EOREAD4(sc, port) &~ EHCI_PS_CLEAR; | |
2745 | EOWRITE4(sc, port, v | EHCI_PS_PO); | 2745 | EOWRITE4(sc, port, v | EHCI_PS_PO); | |
2746 | } | 2746 | } | |
2747 | 2747 | |||
2748 | Static usbd_status | 2748 | Static usbd_status | |
2749 | ehci_root_intr_transfer(struct usbd_xfer *xfer) | 2749 | ehci_root_intr_transfer(struct usbd_xfer *xfer) | |
2750 | { | 2750 | { | |
2751 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | |||
2752 | usbd_status err; | |||
2753 | ||||
2754 | /* Insert last in queue. */ | |||
2755 | mutex_enter(&sc->sc_lock); | |||
2756 | err = usb_insert_transfer(xfer); | |||
2757 | mutex_exit(&sc->sc_lock); | |||
2758 | if (err) | |||
2759 | return err; | |||
2760 | 2751 | |||
2761 | /* Pipe isn't running, start first */ | 2752 | /* Pipe isn't running, start first */ | |
2762 | return ehci_root_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 2753 | return ehci_root_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
2763 | } | 2754 | } | |
2764 | 2755 | |||
2765 | Static usbd_status | 2756 | Static usbd_status | |
2766 | ehci_root_intr_start(struct usbd_xfer *xfer) | 2757 | ehci_root_intr_start(struct usbd_xfer *xfer) | |
2767 | { | 2758 | { | |
2768 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | 2759 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | |
2769 | const bool polling = sc->sc_bus.ub_usepolling; | 2760 | const bool polling = sc->sc_bus.ub_usepolling; | |
2770 | 2761 | |||
2771 | if (sc->sc_dying) | 2762 | if (sc->sc_dying) | |
2772 | return USBD_IOERROR; | 2763 | return USBD_IOERROR; | |
@@ -3596,35 +3587,26 @@ ehci_device_ctrl_fini(struct usbd_xfer * | @@ -3596,35 +3587,26 @@ ehci_device_ctrl_fini(struct usbd_xfer * | |||
3596 | KASSERT(ex->ex_type == EX_CTRL); | 3587 | KASSERT(ex->ex_type == EX_CTRL); | |
3597 | 3588 | |||
3598 | ehci_free_sqtd(sc, ex->ex_setup); | 3589 | ehci_free_sqtd(sc, ex->ex_setup); | |
3599 | ehci_free_sqtd(sc, ex->ex_status); | 3590 | ehci_free_sqtd(sc, ex->ex_status); | |
3600 | ehci_free_sqtds(sc, ex); | 3591 | ehci_free_sqtds(sc, ex); | |
3601 | if (ex->ex_nsqtd) | 3592 | if (ex->ex_nsqtd) | |
3602 | kmem_free(ex->ex_sqtds, | 3593 | kmem_free(ex->ex_sqtds, | |
3603 | sizeof(ehci_soft_qtd_t *) * ex->ex_nsqtd); | 3594 | sizeof(ehci_soft_qtd_t *) * ex->ex_nsqtd); | |
3604 | } | 3595 | } | |
3605 | 3596 | |||
3606 | Static usbd_status | 3597 | Static usbd_status | |
3607 | ehci_device_ctrl_transfer(struct usbd_xfer *xfer) | 3598 | ehci_device_ctrl_transfer(struct usbd_xfer *xfer) | |
3608 | { | 3599 | { | |
3609 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | |||
3610 | usbd_status err; | |||
3611 | ||||
3612 | /* Insert last in queue. */ | |||
3613 | mutex_enter(&sc->sc_lock); | |||
3614 | err = usb_insert_transfer(xfer); | |||
3615 | mutex_exit(&sc->sc_lock); | |||
3616 | if (err) | |||
3617 | return err; | |||
3618 | 3600 | |||
3619 | /* Pipe isn't running, start first */ | 3601 | /* Pipe isn't running, start first */ | |
3620 | return ehci_device_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 3602 | return ehci_device_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
3621 | } | 3603 | } | |
3622 | 3604 | |||
3623 | Static usbd_status | 3605 | Static usbd_status | |
3624 | ehci_device_ctrl_start(struct usbd_xfer *xfer) | 3606 | ehci_device_ctrl_start(struct usbd_xfer *xfer) | |
3625 | { | 3607 | { | |
3626 | struct ehci_pipe *epipe = EHCI_XFER2EPIPE(xfer); | 3608 | struct ehci_pipe *epipe = EHCI_XFER2EPIPE(xfer); | |
3627 | struct ehci_xfer *exfer = EHCI_XFER2EXFER(xfer); | 3609 | struct ehci_xfer *exfer = EHCI_XFER2EXFER(xfer); | |
3628 | usb_device_request_t *req = &xfer->ux_request; | 3610 | usb_device_request_t *req = &xfer->ux_request; | |
3629 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | 3611 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | |
3630 | ehci_soft_qtd_t *setup, *status, *next; | 3612 | ehci_soft_qtd_t *setup, *status, *next; | |
@@ -3876,35 +3858,26 @@ ehci_device_bulk_fini(struct usbd_xfer * | @@ -3876,35 +3858,26 @@ ehci_device_bulk_fini(struct usbd_xfer * | |||
3876 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | 3858 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | |
3877 | struct ehci_xfer *ex = EHCI_XFER2EXFER(xfer); | 3859 | struct ehci_xfer *ex = EHCI_XFER2EXFER(xfer); | |
3878 | 3860 | |||
3879 | KASSERT(ex->ex_type == EX_BULK); | 3861 | KASSERT(ex->ex_type == EX_BULK); | |
3880 | 3862 | |||
3881 | ehci_free_sqtds(sc, ex); | 3863 | ehci_free_sqtds(sc, ex); | |
3882 | if (ex->ex_nsqtd) | 3864 | if (ex->ex_nsqtd) | |
3883 | kmem_free(ex->ex_sqtds, sizeof(ehci_soft_qtd_t *) * ex->ex_nsqtd); | 3865 | kmem_free(ex->ex_sqtds, sizeof(ehci_soft_qtd_t *) * ex->ex_nsqtd); | |
3884 | } | 3866 | } | |
3885 | 3867 | |||
3886 | Static usbd_status | 3868 | Static usbd_status | |
3887 | ehci_device_bulk_transfer(struct usbd_xfer *xfer) | 3869 | ehci_device_bulk_transfer(struct usbd_xfer *xfer) | |
3888 | { | 3870 | { | |
3889 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | |||
3890 | usbd_status err; | |||
3891 | ||||
3892 | /* Insert last in queue. */ | |||
3893 | mutex_enter(&sc->sc_lock); | |||
3894 | err = usb_insert_transfer(xfer); | |||
3895 | mutex_exit(&sc->sc_lock); | |||
3896 | if (err) | |||
3897 | return err; | |||
3898 | 3871 | |||
3899 | /* Pipe isn't running, start first */ | 3872 | /* Pipe isn't running, start first */ | |
3900 | return ehci_device_bulk_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 3873 | return ehci_device_bulk_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
3901 | } | 3874 | } | |
3902 | 3875 | |||
3903 | Static usbd_status | 3876 | Static usbd_status | |
3904 | ehci_device_bulk_start(struct usbd_xfer *xfer) | 3877 | ehci_device_bulk_start(struct usbd_xfer *xfer) | |
3905 | { | 3878 | { | |
3906 | struct ehci_pipe *epipe = EHCI_XFER2EPIPE(xfer); | 3879 | struct ehci_pipe *epipe = EHCI_XFER2EPIPE(xfer); | |
3907 | struct ehci_xfer *exfer = EHCI_XFER2EXFER(xfer); | 3880 | struct ehci_xfer *exfer = EHCI_XFER2EXFER(xfer); | |
3908 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | 3881 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | |
3909 | ehci_soft_qh_t *sqh; | 3882 | ehci_soft_qh_t *sqh; | |
3910 | ehci_soft_qtd_t *end; | 3883 | ehci_soft_qtd_t *end; | |
@@ -4089,40 +4062,28 @@ ehci_device_intr_fini(struct usbd_xfer * | @@ -4089,40 +4062,28 @@ ehci_device_intr_fini(struct usbd_xfer * | |||
4089 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | 4062 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | |
4090 | struct ehci_xfer *ex = EHCI_XFER2EXFER(xfer); | 4063 | struct ehci_xfer *ex = EHCI_XFER2EXFER(xfer); | |
4091 | 4064 | |||
4092 | KASSERT(ex->ex_type == EX_INTR); | 4065 | KASSERT(ex->ex_type == EX_INTR); | |
4093 | 4066 | |||
4094 | ehci_free_sqtds(sc, ex); | 4067 | ehci_free_sqtds(sc, ex); | |
4095 | if (ex->ex_nsqtd) | 4068 | if (ex->ex_nsqtd) | |
4096 | kmem_free(ex->ex_sqtds, sizeof(ehci_soft_qtd_t *) * ex->ex_nsqtd); | 4069 | kmem_free(ex->ex_sqtds, sizeof(ehci_soft_qtd_t *) * ex->ex_nsqtd); | |
4097 | } | 4070 | } | |
4098 | 4071 | |||
4099 | Static usbd_status | 4072 | Static usbd_status | |
4100 | ehci_device_intr_transfer(struct usbd_xfer *xfer) | 4073 | ehci_device_intr_transfer(struct usbd_xfer *xfer) | |
4101 | { | 4074 | { | |
4102 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | |||
4103 | usbd_status err; | |||
4104 | 4075 | |||
4105 | /* Insert last in queue. */ | 4076 | /* Pipe isn't running, so start it first. */ | |
4106 | mutex_enter(&sc->sc_lock); | |||
4107 | err = usb_insert_transfer(xfer); | |||
4108 | mutex_exit(&sc->sc_lock); | |||
4109 | if (err) | |||
4110 | return err; | |||
4111 | ||||
4112 | /* | |||
4113 | * Pipe isn't running (otherwise err would be USBD_INPROG), | |||
4114 | * so start it first. | |||
4115 | */ | |||
4116 | return ehci_device_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 4077 | return ehci_device_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
4117 | } | 4078 | } | |
4118 | 4079 | |||
4119 | Static usbd_status | 4080 | Static usbd_status | |
4120 | ehci_device_intr_start(struct usbd_xfer *xfer) | 4081 | ehci_device_intr_start(struct usbd_xfer *xfer) | |
4121 | { | 4082 | { | |
4122 | struct ehci_pipe *epipe = EHCI_XFER2EPIPE(xfer); | 4083 | struct ehci_pipe *epipe = EHCI_XFER2EPIPE(xfer); | |
4123 | struct ehci_xfer *exfer = EHCI_XFER2EXFER(xfer); | 4084 | struct ehci_xfer *exfer = EHCI_XFER2EXFER(xfer); | |
4124 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | 4085 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | |
4125 | ehci_soft_qtd_t *end; | 4086 | ehci_soft_qtd_t *end; | |
4126 | ehci_soft_qh_t *sqh; | 4087 | ehci_soft_qh_t *sqh; | |
4127 | int len, isread, endpt; | 4088 | int len, isread, endpt; | |
4128 | const bool polling = sc->sc_bus.ub_usepolling; | 4089 | const bool polling = sc->sc_bus.ub_usepolling; | |
@@ -4341,34 +4302,26 @@ ehci_device_fs_isoc_fini(struct usbd_xfe | @@ -4341,34 +4302,26 @@ ehci_device_fs_isoc_fini(struct usbd_xfe | |||
4341 | { | 4302 | { | |
4342 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | 4303 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | |
4343 | struct ehci_xfer *ex = EHCI_XFER2EXFER(xfer); | 4304 | struct ehci_xfer *ex = EHCI_XFER2EXFER(xfer); | |
4344 | 4305 | |||
4345 | KASSERT(ex->ex_type == EX_FS_ISOC); | 4306 | KASSERT(ex->ex_type == EX_FS_ISOC); | |
4346 | 4307 | |||
4347 | ehci_free_sitd_chain(sc, ex->ex_sitdstart); | 4308 | ehci_free_sitd_chain(sc, ex->ex_sitdstart); | |
4348 | } | 4309 | } | |
4349 | 4310 | |||
4350 | Static usbd_status | 4311 | Static usbd_status | |
4351 | ehci_device_fs_isoc_transfer(struct usbd_xfer *xfer) | 4312 | ehci_device_fs_isoc_transfer(struct usbd_xfer *xfer) | |
4352 | { | 4313 | { | |
4353 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | 4314 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | |
4354 | usbd_status __diagused err; | |||
4355 | ||||
4356 | mutex_enter(&sc->sc_lock); | |||
4357 | err = usb_insert_transfer(xfer); | |||
4358 | mutex_exit(&sc->sc_lock); | |||
4359 | ||||
4360 | KASSERT(err == USBD_NORMAL_COMPLETION); | |||
4361 | ||||
4362 | struct ehci_pipe *epipe = EHCI_XFER2EPIPE(xfer); | 4315 | struct ehci_pipe *epipe = EHCI_XFER2EPIPE(xfer); | |
4363 | struct usbd_device *dev = xfer->ux_pipe->up_dev; | 4316 | struct usbd_device *dev = xfer->ux_pipe->up_dev; | |
4364 | struct ehci_xfer *exfer = EHCI_XFER2EXFER(xfer); | 4317 | struct ehci_xfer *exfer = EHCI_XFER2EXFER(xfer); | |
4365 | ehci_soft_sitd_t *sitd; | 4318 | ehci_soft_sitd_t *sitd; | |
4366 | usb_dma_t *dma_buf; | 4319 | usb_dma_t *dma_buf; | |
4367 | int i, j, k, frames; | 4320 | int i, j, k, frames; | |
4368 | int offs; | 4321 | int offs; | |
4369 | int frindex; | 4322 | int frindex; | |
4370 | u_int dir; | 4323 | u_int dir; | |
4371 | 4324 | |||
4372 | EHCIHIST_FUNC(); EHCIHIST_CALLED(); | 4325 | EHCIHIST_FUNC(); EHCIHIST_CALLED(); | |
4373 | 4326 | |||
4374 | sitd = NULL; | 4327 | sitd = NULL; | |
@@ -4714,34 +4667,26 @@ ehci_device_isoc_fini(struct usbd_xfer * | @@ -4714,34 +4667,26 @@ ehci_device_isoc_fini(struct usbd_xfer * | |||
4714 | { | 4667 | { | |
4715 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | 4668 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | |
4716 | struct ehci_xfer *ex = EHCI_XFER2EXFER(xfer); | 4669 | struct ehci_xfer *ex = EHCI_XFER2EXFER(xfer); | |
4717 | 4670 | |||
4718 | KASSERT(ex->ex_type == EX_ISOC); | 4671 | KASSERT(ex->ex_type == EX_ISOC); | |
4719 | 4672 | |||
4720 | ehci_free_itd_chain(sc, ex->ex_itdstart); | 4673 | ehci_free_itd_chain(sc, ex->ex_itdstart); | |
4721 | } | 4674 | } | |
4722 | 4675 | |||
4723 | Static usbd_status | 4676 | Static usbd_status | |
4724 | ehci_device_isoc_transfer(struct usbd_xfer *xfer) | 4677 | ehci_device_isoc_transfer(struct usbd_xfer *xfer) | |
4725 | { | 4678 | { | |
4726 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | 4679 | ehci_softc_t *sc = EHCI_XFER2SC(xfer); | |
4727 | usbd_status __diagused err; | |||
4728 | ||||
4729 | mutex_enter(&sc->sc_lock); | |||
4730 | err = usb_insert_transfer(xfer); | |||
4731 | mutex_exit(&sc->sc_lock); | |||
4732 | ||||
4733 | KASSERT(err == USBD_NORMAL_COMPLETION); | |||
4734 | ||||
4735 | struct ehci_pipe *epipe = EHCI_XFER2EPIPE(xfer); | 4680 | struct ehci_pipe *epipe = EHCI_XFER2EPIPE(xfer); | |
4736 | struct ehci_xfer *exfer = EHCI_XFER2EXFER(xfer); | 4681 | struct ehci_xfer *exfer = EHCI_XFER2EXFER(xfer); | |
4737 | ehci_soft_itd_t *itd, *prev; | 4682 | ehci_soft_itd_t *itd, *prev; | |
4738 | usb_dma_t *dma_buf; | 4683 | usb_dma_t *dma_buf; | |
4739 | int i, j; | 4684 | int i, j; | |
4740 | int frames, uframes, ufrperframe; | 4685 | int frames, uframes, ufrperframe; | |
4741 | int trans_count, offs; | 4686 | int trans_count, offs; | |
4742 | int frindex; | 4687 | int frindex; | |
4743 | 4688 | |||
4744 | EHCIHIST_FUNC(); EHCIHIST_CALLED(); | 4689 | EHCIHIST_FUNC(); EHCIHIST_CALLED(); | |
4745 | 4690 | |||
4746 | prev = NULL; | 4691 | prev = NULL; | |
4747 | itd = NULL; | 4692 | itd = NULL; |
--- src/sys/dev/usb/motg.c 2021/08/07 16:19:16 1.37
+++ src/sys/dev/usb/motg.c 2022/03/03 06:04:31 1.38
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: motg.c,v 1.37 2021/08/07 16:19:16 thorpej Exp $ */ | 1 | /* $NetBSD: motg.c,v 1.38 2022/03/03 06:04:31 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.37 2021/08/07 16:19:16 thorpej Exp $"); | 43 | __KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.38 2022/03/03 06:04:31 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> | |
@@ -999,40 +999,28 @@ motg_root_intr_abort(struct usbd_xfer *x | @@ -999,40 +999,28 @@ motg_root_intr_abort(struct usbd_xfer *x | |||
999 | /* | 999 | /* | |
1000 | * Otherwise, sc->sc_intr_xfer had better be this transfer. | 1000 | * Otherwise, sc->sc_intr_xfer had better be this transfer. | |
1001 | * Cancel it. | 1001 | * Cancel it. | |
1002 | */ | 1002 | */ | |
1003 | KASSERT(sc->sc_intr_xfer == xfer); | 1003 | KASSERT(sc->sc_intr_xfer == xfer); | |
1004 | KASSERT(xfer->ux_status == USBD_IN_PROGRESS); | 1004 | KASSERT(xfer->ux_status == USBD_IN_PROGRESS); | |
1005 | xfer->ux_status = USBD_CANCELLED; | 1005 | xfer->ux_status = USBD_CANCELLED; | |
1006 | usb_transfer_complete(xfer); | 1006 | usb_transfer_complete(xfer); | |
1007 | } | 1007 | } | |
1008 | 1008 | |||
1009 | usbd_status | 1009 | usbd_status | |
1010 | motg_root_intr_transfer(struct usbd_xfer *xfer) | 1010 | motg_root_intr_transfer(struct usbd_xfer *xfer) | |
1011 | { | 1011 | { | |
1012 | struct motg_softc *sc = MOTG_XFER2SC(xfer); | |||
1013 | usbd_status err; | |||
1014 | ||||
1015 | /* Insert last in queue. */ | |||
1016 | mutex_enter(&sc->sc_lock); | |||
1017 | err = usb_insert_transfer(xfer); | |||
1018 | mutex_exit(&sc->sc_lock); | |||
1019 | if (err) | |||
1020 | return err; | |||
1021 | 1012 | |||
1022 | /* | 1013 | /* Pipe isn't running, start first */ | |
1023 | * Pipe isn't running (otherwise err would be USBD_INPROG), | |||
1024 | * start first | |||
1025 | */ | |||
1026 | return motg_root_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 1014 | return motg_root_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
1027 | } | 1015 | } | |
1028 | 1016 | |||
1029 | /* Start a transfer on the root interrupt pipe */ | 1017 | /* Start a transfer on the root interrupt pipe */ | |
1030 | usbd_status | 1018 | usbd_status | |
1031 | motg_root_intr_start(struct usbd_xfer *xfer) | 1019 | motg_root_intr_start(struct usbd_xfer *xfer) | |
1032 | { | 1020 | { | |
1033 | struct usbd_pipe *pipe = xfer->ux_pipe; | 1021 | struct usbd_pipe *pipe = xfer->ux_pipe; | |
1034 | struct motg_softc *sc = MOTG_PIPE2SC(pipe); | 1022 | struct motg_softc *sc = MOTG_PIPE2SC(pipe); | |
1035 | const bool polling = sc->sc_bus.ub_usepolling; | 1023 | const bool polling = sc->sc_bus.ub_usepolling; | |
1036 | 1024 | |||
1037 | MOTGHIST_FUNC(); MOTGHIST_CALLED(); | 1025 | MOTGHIST_FUNC(); MOTGHIST_CALLED(); | |
1038 | 1026 | |||
@@ -1269,41 +1257,28 @@ motg_setup_endpoint_rx(struct usbd_xfer | @@ -1269,41 +1257,28 @@ motg_setup_endpoint_rx(struct usbd_xfer | |||
1269 | } else { | 1257 | } else { | |
1270 | if (sc->sc_high_speed) { | 1258 | if (sc->sc_high_speed) { | |
1271 | UWRITE1(sc, MUSB2_REG_RXNAKLIMIT, POLL_TO_HIGH); | 1259 | UWRITE1(sc, MUSB2_REG_RXNAKLIMIT, POLL_TO_HIGH); | |
1272 | } else { | 1260 | } else { | |
1273 | UWRITE1(sc, MUSB2_REG_RXNAKLIMIT, POLL_TO); | 1261 | UWRITE1(sc, MUSB2_REG_RXNAKLIMIT, POLL_TO); | |
1274 | } | 1262 | } | |
1275 | } | 1263 | } | |
1276 | } | 1264 | } | |
1277 | } | 1265 | } | |
1278 | 1266 | |||
1279 | static usbd_status | 1267 | static usbd_status | |
1280 | motg_device_ctrl_transfer(struct usbd_xfer *xfer) | 1268 | motg_device_ctrl_transfer(struct usbd_xfer *xfer) | |
1281 | { | 1269 | { | |
1282 | struct motg_softc *sc = MOTG_XFER2SC(xfer); | |||
1283 | usbd_status err; | |||
1284 | 1270 | |||
1285 | /* Insert last in queue. */ | 1271 | /* Pipe isn't running, so start it first. */ | |
1286 | mutex_enter(&sc->sc_lock); | |||
1287 | err = usb_insert_transfer(xfer); | |||
1288 | KASSERT(xfer->ux_status == USBD_NOT_STARTED); | |||
1289 | mutex_exit(&sc->sc_lock); | |||
1290 | if (err) | |||
1291 | return err; | |||
1292 | ||||
1293 | /* | |||
1294 | * Pipe isn't running (otherwise err would be USBD_INPROG), | |||
1295 | * so start it first. | |||
1296 | */ | |||
1297 | return motg_device_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 1272 | return motg_device_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
1298 | } | 1273 | } | |
1299 | 1274 | |||
1300 | static usbd_status | 1275 | static usbd_status | |
1301 | motg_device_ctrl_start(struct usbd_xfer *xfer) | 1276 | motg_device_ctrl_start(struct usbd_xfer *xfer) | |
1302 | { | 1277 | { | |
1303 | struct motg_softc *sc = MOTG_XFER2SC(xfer); | 1278 | struct motg_softc *sc = MOTG_XFER2SC(xfer); | |
1304 | usbd_status err; | 1279 | usbd_status err; | |
1305 | mutex_enter(&sc->sc_lock); | 1280 | mutex_enter(&sc->sc_lock); | |
1306 | err = motg_device_ctrl_start1(sc); | 1281 | err = motg_device_ctrl_start1(sc); | |
1307 | mutex_exit(&sc->sc_lock); | 1282 | mutex_exit(&sc->sc_lock); | |
1308 | return err; | 1283 | return err; | |
1309 | } | 1284 | } | |
@@ -1721,44 +1696,29 @@ motg_device_ctrl_close(struct usbd_pipe | @@ -1721,44 +1696,29 @@ motg_device_ctrl_close(struct usbd_pipe | |||
1721 | 1696 | |||
1722 | void | 1697 | void | |
1723 | motg_device_ctrl_done(struct usbd_xfer *xfer) | 1698 | motg_device_ctrl_done(struct usbd_xfer *xfer) | |
1724 | { | 1699 | { | |
1725 | struct motg_pipe *otgpipe __diagused = MOTG_PIPE2MPIPE(xfer->ux_pipe); | 1700 | struct motg_pipe *otgpipe __diagused = MOTG_PIPE2MPIPE(xfer->ux_pipe); | |
1726 | MOTGHIST_FUNC(); MOTGHIST_CALLED(); | 1701 | MOTGHIST_FUNC(); MOTGHIST_CALLED(); | |
1727 | 1702 | |||
1728 | KASSERT(otgpipe->hw_ep->xfer != xfer); | 1703 | KASSERT(otgpipe->hw_ep->xfer != xfer); | |
1729 | } | 1704 | } | |
1730 | 1705 | |||
1731 | static usbd_status | 1706 | static usbd_status | |
1732 | motg_device_data_transfer(struct usbd_xfer *xfer) | 1707 | motg_device_data_transfer(struct usbd_xfer *xfer) | |
1733 | { | 1708 | { | |
1734 | struct motg_softc *sc = MOTG_XFER2SC(xfer); | |||
1735 | usbd_status err; | |||
1736 | ||||
1737 | MOTGHIST_FUNC(); MOTGHIST_CALLED(); | 1709 | MOTGHIST_FUNC(); MOTGHIST_CALLED(); | |
1738 | 1710 | |||
1739 | /* Insert last in queue. */ | 1711 | /* Pipe isn't running, so start it first. */ | |
1740 | mutex_enter(&sc->sc_lock); | |||
1741 | DPRINTF("xfer %#jx status %jd", (uintptr_t)xfer, xfer->ux_status, 0, 0); | |||
1742 | err = usb_insert_transfer(xfer); | |||
1743 | KASSERT(xfer->ux_status == USBD_NOT_STARTED); | |||
1744 | mutex_exit(&sc->sc_lock); | |||
1745 | if (err) | |||
1746 | return err; | |||
1747 | ||||
1748 | /* | |||
1749 | * Pipe isn't running (otherwise err would be USBD_INPROG), | |||
1750 | * so start it first. | |||
1751 | */ | |||
1752 | return motg_device_data_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 1712 | return motg_device_data_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
1753 | } | 1713 | } | |
1754 | 1714 | |||
1755 | static usbd_status | 1715 | static usbd_status | |
1756 | motg_device_data_start(struct usbd_xfer *xfer) | 1716 | motg_device_data_start(struct usbd_xfer *xfer) | |
1757 | { | 1717 | { | |
1758 | struct motg_softc *sc = MOTG_XFER2SC(xfer); | 1718 | struct motg_softc *sc = MOTG_XFER2SC(xfer); | |
1759 | struct motg_pipe *otgpipe = MOTG_PIPE2MPIPE(xfer->ux_pipe); | 1719 | struct motg_pipe *otgpipe = MOTG_PIPE2MPIPE(xfer->ux_pipe); | |
1760 | usbd_status err; | 1720 | usbd_status err; | |
1761 | 1721 | |||
1762 | MOTGHIST_FUNC(); MOTGHIST_CALLED(); | 1722 | MOTGHIST_FUNC(); MOTGHIST_CALLED(); | |
1763 | 1723 | |||
1764 | mutex_enter(&sc->sc_lock); | 1724 | mutex_enter(&sc->sc_lock); |
--- src/sys/dev/usb/ohci.c 2021/12/21 09:51:22 1.318
+++ src/sys/dev/usb/ohci.c 2022/03/03 06:04:31 1.319
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ohci.c,v 1.318 2021/12/21 09:51:22 skrll Exp $ */ | 1 | /* $NetBSD: ohci.c,v 1.319 2022/03/03 06:04:31 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.318 2021/12/21 09:51:22 skrll Exp $"); | 45 | __KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.319 2022/03/03 06:04:31 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> | |
@@ -2606,35 +2606,26 @@ ohci_roothub_ctrl(struct usbd_bus *bus, | @@ -2606,35 +2606,26 @@ ohci_roothub_ctrl(struct usbd_bus *bus, | |||
2606 | } | 2606 | } | |
2607 | break; | 2607 | break; | |
2608 | default: | 2608 | default: | |
2609 | /* default from usbroothub */ | 2609 | /* default from usbroothub */ | |
2610 | return buflen; | 2610 | return buflen; | |
2611 | } | 2611 | } | |
2612 | 2612 | |||
2613 | return totlen; | 2613 | return totlen; | |
2614 | } | 2614 | } | |
2615 | 2615 | |||
2616 | Static usbd_status | 2616 | Static usbd_status | |
2617 | ohci_root_intr_transfer(struct usbd_xfer *xfer) | 2617 | ohci_root_intr_transfer(struct usbd_xfer *xfer) | |
2618 | { | 2618 | { | |
2619 | ohci_softc_t *sc = OHCI_XFER2SC(xfer); | |||
2620 | usbd_status err; | |||
2621 | ||||
2622 | /* Insert last in queue. */ | |||
2623 | mutex_enter(&sc->sc_lock); | |||
2624 | err = usb_insert_transfer(xfer); | |||
2625 | mutex_exit(&sc->sc_lock); | |||
2626 | if (err) | |||
2627 | return err; | |||
2628 | 2619 | |||
2629 | /* Pipe isn't running, start first */ | 2620 | /* Pipe isn't running, start first */ | |
2630 | return ohci_root_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 2621 | return ohci_root_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
2631 | } | 2622 | } | |
2632 | 2623 | |||
2633 | Static usbd_status | 2624 | Static usbd_status | |
2634 | ohci_root_intr_start(struct usbd_xfer *xfer) | 2625 | ohci_root_intr_start(struct usbd_xfer *xfer) | |
2635 | { | 2626 | { | |
2636 | ohci_softc_t *sc = OHCI_XFER2SC(xfer); | 2627 | ohci_softc_t *sc = OHCI_XFER2SC(xfer); | |
2637 | const bool polling = sc->sc_bus.ub_usepolling; | 2628 | const bool polling = sc->sc_bus.ub_usepolling; | |
2638 | 2629 | |||
2639 | if (sc->sc_dying) | 2630 | if (sc->sc_dying) | |
2640 | return USBD_IOERROR; | 2631 | return USBD_IOERROR; | |
@@ -2764,35 +2755,26 @@ ohci_device_ctrl_fini(struct usbd_xfer * | @@ -2764,35 +2755,26 @@ ohci_device_ctrl_fini(struct usbd_xfer * | |||
2764 | } | 2755 | } | |
2765 | ohci_free_std_locked(sc, ox->ox_stat); | 2756 | ohci_free_std_locked(sc, ox->ox_stat); | |
2766 | mutex_exit(&sc->sc_lock); | 2757 | mutex_exit(&sc->sc_lock); | |
2767 | 2758 | |||
2768 | if (ox->ox_nstd) { | 2759 | if (ox->ox_nstd) { | |
2769 | const size_t sz = sizeof(ohci_soft_td_t *) * ox->ox_nstd; | 2760 | const size_t sz = sizeof(ohci_soft_td_t *) * ox->ox_nstd; | |
2770 | kmem_free(ox->ox_stds, sz); | 2761 | kmem_free(ox->ox_stds, sz); | |
2771 | } | 2762 | } | |
2772 | } | 2763 | } | |
2773 | 2764 | |||
2774 | Static usbd_status | 2765 | Static usbd_status | |
2775 | ohci_device_ctrl_transfer(struct usbd_xfer *xfer) | 2766 | ohci_device_ctrl_transfer(struct usbd_xfer *xfer) | |
2776 | { | 2767 | { | |
2777 | ohci_softc_t *sc = OHCI_XFER2SC(xfer); | |||
2778 | usbd_status err; | |||
2779 | ||||
2780 | /* Insert last in queue. */ | |||
2781 | mutex_enter(&sc->sc_lock); | |||
2782 | err = usb_insert_transfer(xfer); | |||
2783 | mutex_exit(&sc->sc_lock); | |||
2784 | if (err) | |||
2785 | return err; | |||
2786 | 2768 | |||
2787 | /* Pipe isn't running, start first */ | 2769 | /* Pipe isn't running, start first */ | |
2788 | return ohci_device_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 2770 | return ohci_device_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
2789 | } | 2771 | } | |
2790 | 2772 | |||
2791 | Static usbd_status | 2773 | Static usbd_status | |
2792 | ohci_device_ctrl_start(struct usbd_xfer *xfer) | 2774 | ohci_device_ctrl_start(struct usbd_xfer *xfer) | |
2793 | { | 2775 | { | |
2794 | ohci_softc_t *sc = OHCI_XFER2SC(xfer); | 2776 | ohci_softc_t *sc = OHCI_XFER2SC(xfer); | |
2795 | struct ohci_xfer *ox = OHCI_XFER2OXFER(xfer); | 2777 | struct ohci_xfer *ox = OHCI_XFER2OXFER(xfer); | |
2796 | struct ohci_pipe *opipe = OHCI_PIPE2OPIPE(xfer->ux_pipe); | 2778 | struct ohci_pipe *opipe = OHCI_PIPE2OPIPE(xfer->ux_pipe); | |
2797 | usb_device_request_t *req = &xfer->ux_request; | 2779 | usb_device_request_t *req = &xfer->ux_request; | |
2798 | struct usbd_device *dev __diagused = opipe->pipe.up_dev; | 2780 | struct usbd_device *dev __diagused = opipe->pipe.up_dev; | |
@@ -3052,35 +3034,26 @@ ohci_device_bulk_fini(struct usbd_xfer * | @@ -3052,35 +3034,26 @@ ohci_device_bulk_fini(struct usbd_xfer * | |||
3052 | ohci_free_std_locked(sc, std); | 3034 | ohci_free_std_locked(sc, std); | |
3053 | } | 3035 | } | |
3054 | mutex_exit(&sc->sc_lock); | 3036 | mutex_exit(&sc->sc_lock); | |
3055 | 3037 | |||
3056 | if (ox->ox_nstd) { | 3038 | if (ox->ox_nstd) { | |
3057 | const size_t sz = sizeof(ohci_soft_td_t *) * ox->ox_nstd; | 3039 | const size_t sz = sizeof(ohci_soft_td_t *) * ox->ox_nstd; | |
3058 | kmem_free(ox->ox_stds, sz); | 3040 | kmem_free(ox->ox_stds, sz); | |
3059 | } | 3041 | } | |
3060 | } | 3042 | } | |
3061 | 3043 | |||
3062 | Static usbd_status | 3044 | Static usbd_status | |
3063 | ohci_device_bulk_transfer(struct usbd_xfer *xfer) | 3045 | ohci_device_bulk_transfer(struct usbd_xfer *xfer) | |
3064 | { | 3046 | { | |
3065 | ohci_softc_t *sc = OHCI_XFER2SC(xfer); | |||
3066 | usbd_status err; | |||
3067 | ||||
3068 | /* Insert last in queue. */ | |||
3069 | mutex_enter(&sc->sc_lock); | |||
3070 | err = usb_insert_transfer(xfer); | |||
3071 | mutex_exit(&sc->sc_lock); | |||
3072 | if (err) | |||
3073 | return err; | |||
3074 | 3047 | |||
3075 | /* Pipe isn't running, start first */ | 3048 | /* Pipe isn't running, start first */ | |
3076 | return ohci_device_bulk_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 3049 | return ohci_device_bulk_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
3077 | } | 3050 | } | |
3078 | 3051 | |||
3079 | Static usbd_status | 3052 | Static usbd_status | |
3080 | ohci_device_bulk_start(struct usbd_xfer *xfer) | 3053 | ohci_device_bulk_start(struct usbd_xfer *xfer) | |
3081 | { | 3054 | { | |
3082 | struct ohci_xfer *ox = OHCI_XFER2OXFER(xfer); | 3055 | struct ohci_xfer *ox = OHCI_XFER2OXFER(xfer); | |
3083 | struct ohci_pipe *opipe = OHCI_PIPE2OPIPE(xfer->ux_pipe); | 3056 | struct ohci_pipe *opipe = OHCI_PIPE2OPIPE(xfer->ux_pipe); | |
3084 | ohci_softc_t *sc = OHCI_XFER2SC(xfer); | 3057 | ohci_softc_t *sc = OHCI_XFER2SC(xfer); | |
3085 | ohci_soft_td_t *last; | 3058 | ohci_soft_td_t *last; | |
3086 | ohci_soft_td_t *data, *tail, *tdp; | 3059 | ohci_soft_td_t *data, *tail, *tdp; | |
@@ -3260,35 +3233,26 @@ ohci_device_intr_fini(struct usbd_xfer * | @@ -3260,35 +3233,26 @@ ohci_device_intr_fini(struct usbd_xfer * | |||
3260 | ohci_free_std_locked(sc, std); | 3233 | ohci_free_std_locked(sc, std); | |
3261 | } | 3234 | } | |
3262 | mutex_exit(&sc->sc_lock); | 3235 | mutex_exit(&sc->sc_lock); | |
3263 | 3236 | |||
3264 | if (ox->ox_nstd) { | 3237 | if (ox->ox_nstd) { | |
3265 | const size_t sz = sizeof(ohci_soft_td_t *) * ox->ox_nstd; | 3238 | const size_t sz = sizeof(ohci_soft_td_t *) * ox->ox_nstd; | |
3266 | kmem_free(ox->ox_stds, sz); | 3239 | kmem_free(ox->ox_stds, sz); | |
3267 | } | 3240 | } | |
3268 | } | 3241 | } | |
3269 | 3242 | |||
3270 | Static usbd_status | 3243 | Static usbd_status | |
3271 | ohci_device_intr_transfer(struct usbd_xfer *xfer) | 3244 | ohci_device_intr_transfer(struct usbd_xfer *xfer) | |
3272 | { | 3245 | { | |
3273 | ohci_softc_t *sc = OHCI_XFER2SC(xfer); | |||
3274 | usbd_status err; | |||
3275 | ||||
3276 | /* Insert last in queue. */ | |||
3277 | mutex_enter(&sc->sc_lock); | |||
3278 | err = usb_insert_transfer(xfer); | |||
3279 | mutex_exit(&sc->sc_lock); | |||
3280 | if (err) | |||
3281 | return err; | |||
3282 | 3246 | |||
3283 | /* Pipe isn't running, start first */ | 3247 | /* Pipe isn't running, start first */ | |
3284 | return ohci_device_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 3248 | return ohci_device_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
3285 | } | 3249 | } | |
3286 | 3250 | |||
3287 | Static usbd_status | 3251 | Static usbd_status | |
3288 | ohci_device_intr_start(struct usbd_xfer *xfer) | 3252 | ohci_device_intr_start(struct usbd_xfer *xfer) | |
3289 | { | 3253 | { | |
3290 | struct ohci_xfer *ox = OHCI_XFER2OXFER(xfer); | 3254 | struct ohci_xfer *ox = OHCI_XFER2OXFER(xfer); | |
3291 | struct ohci_pipe *opipe = OHCI_PIPE2OPIPE(xfer->ux_pipe); | 3255 | struct ohci_pipe *opipe = OHCI_PIPE2OPIPE(xfer->ux_pipe); | |
3292 | ohci_softc_t *sc = OHCI_XFER2SC(xfer); | 3256 | ohci_softc_t *sc = OHCI_XFER2SC(xfer); | |
3293 | ohci_soft_ed_t *sed = opipe->sed; | 3257 | ohci_soft_ed_t *sed = opipe->sed; | |
3294 | ohci_soft_td_t *data, *last, *tail; | 3258 | ohci_soft_td_t *data, *last, *tail; | |
@@ -3564,40 +3528,30 @@ ohci_device_isoc_fini(struct usbd_xfer * | @@ -3564,40 +3528,30 @@ ohci_device_isoc_fini(struct usbd_xfer * | |||
3564 | } | 3528 | } | |
3565 | mutex_exit(&sc->sc_lock); | 3529 | mutex_exit(&sc->sc_lock); | |
3566 | 3530 | |||
3567 | if (ox->ox_nsitd) { | 3531 | if (ox->ox_nsitd) { | |
3568 | const size_t sz = sizeof(ohci_soft_itd_t *) * ox->ox_nsitd; | 3532 | const size_t sz = sizeof(ohci_soft_itd_t *) * ox->ox_nsitd; | |
3569 | kmem_free(ox->ox_sitds, sz); | 3533 | kmem_free(ox->ox_sitds, sz); | |
3570 | } | 3534 | } | |
3571 | } | 3535 | } | |
3572 | 3536 | |||
3573 | 3537 | |||
3574 | usbd_status | 3538 | usbd_status | |
3575 | ohci_device_isoc_transfer(struct usbd_xfer *xfer) | 3539 | ohci_device_isoc_transfer(struct usbd_xfer *xfer) | |
3576 | { | 3540 | { | |
3577 | ohci_softc_t *sc = OHCI_XFER2SC(xfer); | |||
3578 | usbd_status __diagused err; | |||
3579 | ||||
3580 | OHCIHIST_FUNC(); OHCIHIST_CALLED(); | 3541 | OHCIHIST_FUNC(); OHCIHIST_CALLED(); | |
3581 | 3542 | |||
3582 | DPRINTFN(5, "xfer=%#jx", (uintptr_t)xfer, 0, 0, 0); | 3543 | DPRINTFN(5, "xfer=%#jx", (uintptr_t)xfer, 0, 0, 0); | |
3583 | 3544 | |||
3584 | /* Put it on our queue, */ | |||
3585 | mutex_enter(&sc->sc_lock); | |||
3586 | err = usb_insert_transfer(xfer); | |||
3587 | mutex_exit(&sc->sc_lock); | |||
3588 | ||||
3589 | KASSERT(err == USBD_NORMAL_COMPLETION); | |||
3590 | ||||
3591 | /* insert into schedule, */ | 3545 | /* insert into schedule, */ | |
3592 | ohci_device_isoc_enter(xfer); | 3546 | ohci_device_isoc_enter(xfer); | |
3593 | 3547 | |||
3594 | /* and start if the pipe wasn't running */ | 3548 | /* and start if the pipe wasn't running */ | |
3595 | return USBD_IN_PROGRESS; | 3549 | return USBD_IN_PROGRESS; | |
3596 | } | 3550 | } | |
3597 | 3551 | |||
3598 | void | 3552 | void | |
3599 | ohci_device_isoc_enter(struct usbd_xfer *xfer) | 3553 | ohci_device_isoc_enter(struct usbd_xfer *xfer) | |
3600 | { | 3554 | { | |
3601 | struct ohci_xfer *ox = OHCI_XFER2OXFER(xfer); | 3555 | struct ohci_xfer *ox = OHCI_XFER2OXFER(xfer); | |
3602 | struct ohci_pipe *opipe = OHCI_PIPE2OPIPE(xfer->ux_pipe); | 3556 | struct ohci_pipe *opipe = OHCI_PIPE2OPIPE(xfer->ux_pipe); | |
3603 | ohci_softc_t *sc = OHCI_XFER2SC(xfer); | 3557 | ohci_softc_t *sc = OHCI_XFER2SC(xfer); |
--- src/sys/dev/usb/uhci.c 2021/12/21 09:51:22 1.308
+++ src/sys/dev/usb/uhci.c 2022/03/03 06:04:31 1.309
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: uhci.c,v 1.308 2021/12/21 09:51:22 skrll Exp $ */ | 1 | /* $NetBSD: uhci.c,v 1.309 2022/03/03 06:04:31 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.308 2021/12/21 09:51:22 skrll Exp $"); | 45 | __KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.309 2022/03/03 06:04:31 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> | |
@@ -2248,40 +2248,28 @@ uhci_device_bulk_fini(struct usbd_xfer * | @@ -2248,40 +2248,28 @@ uhci_device_bulk_fini(struct usbd_xfer * | |||
2248 | struct uhci_xfer *ux = UHCI_XFER2UXFER(xfer); | 2248 | struct uhci_xfer *ux = UHCI_XFER2UXFER(xfer); | |
2249 | 2249 | |||
2250 | KASSERT(ux->ux_type == UX_BULK); | 2250 | KASSERT(ux->ux_type == UX_BULK); | |
2251 | 2251 | |||
2252 | if (ux->ux_nstd) { | 2252 | if (ux->ux_nstd) { | |
2253 | uhci_free_stds(sc, ux); | 2253 | uhci_free_stds(sc, ux); | |
2254 | kmem_free(ux->ux_stds, sizeof(uhci_soft_td_t *) * ux->ux_nstd); | 2254 | kmem_free(ux->ux_stds, sizeof(uhci_soft_td_t *) * ux->ux_nstd); | |
2255 | } | 2255 | } | |
2256 | } | 2256 | } | |
2257 | 2257 | |||
2258 | usbd_status | 2258 | usbd_status | |
2259 | uhci_device_bulk_transfer(struct usbd_xfer *xfer) | 2259 | uhci_device_bulk_transfer(struct usbd_xfer *xfer) | |
2260 | { | 2260 | { | |
2261 | uhci_softc_t *sc = UHCI_XFER2SC(xfer); | |||
2262 | usbd_status err; | |||
2263 | ||||
2264 | /* Insert last in queue. */ | |||
2265 | mutex_enter(&sc->sc_lock); | |||
2266 | err = usb_insert_transfer(xfer); | |||
2267 | mutex_exit(&sc->sc_lock); | |||
2268 | if (err) | |||
2269 | return err; | |||
2270 | 2261 | |||
2271 | /* | 2262 | /* Pipe isn't running, so start it first. */ | |
2272 | * Pipe isn't running (otherwise err would be USBD_INPROG), | |||
2273 | * so start it first. | |||
2274 | */ | |||
2275 | return uhci_device_bulk_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 2263 | return uhci_device_bulk_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
2276 | } | 2264 | } | |
2277 | 2265 | |||
2278 | usbd_status | 2266 | usbd_status | |
2279 | uhci_device_bulk_start(struct usbd_xfer *xfer) | 2267 | uhci_device_bulk_start(struct usbd_xfer *xfer) | |
2280 | { | 2268 | { | |
2281 | struct uhci_pipe *upipe = UHCI_PIPE2UPIPE(xfer->ux_pipe); | 2269 | struct uhci_pipe *upipe = UHCI_PIPE2UPIPE(xfer->ux_pipe); | |
2282 | struct uhci_xfer *ux = UHCI_XFER2UXFER(xfer); | 2270 | struct uhci_xfer *ux = UHCI_XFER2UXFER(xfer); | |
2283 | uhci_softc_t *sc = UHCI_XFER2SC(xfer); | 2271 | uhci_softc_t *sc = UHCI_XFER2SC(xfer); | |
2284 | uhci_soft_td_t *data, *dataend; | 2272 | uhci_soft_td_t *data, *dataend; | |
2285 | uhci_soft_qh_t *sqh; | 2273 | uhci_soft_qh_t *sqh; | |
2286 | const bool polling = sc->sc_bus.ub_usepolling; | 2274 | const bool polling = sc->sc_bus.ub_usepolling; | |
2287 | int len; | 2275 | int len; | |
@@ -2485,40 +2473,28 @@ uhci_device_ctrl_fini(struct usbd_xfer * | @@ -2485,40 +2473,28 @@ uhci_device_ctrl_fini(struct usbd_xfer * | |||
2485 | struct uhci_xfer *ux = UHCI_XFER2UXFER(xfer); | 2473 | struct uhci_xfer *ux = UHCI_XFER2UXFER(xfer); | |
2486 | 2474 | |||
2487 | KASSERT(ux->ux_type == UX_CTRL); | 2475 | KASSERT(ux->ux_type == UX_CTRL); | |
2488 | 2476 | |||
2489 | if (ux->ux_nstd) { | 2477 | if (ux->ux_nstd) { | |
2490 | uhci_free_stds(sc, ux); | 2478 | uhci_free_stds(sc, ux); | |
2491 | kmem_free(ux->ux_stds, sizeof(uhci_soft_td_t *) * ux->ux_nstd); | 2479 | kmem_free(ux->ux_stds, sizeof(uhci_soft_td_t *) * ux->ux_nstd); | |
2492 | } | 2480 | } | |
2493 | } | 2481 | } | |
2494 | 2482 | |||
2495 | usbd_status | 2483 | usbd_status | |
2496 | uhci_device_ctrl_transfer(struct usbd_xfer *xfer) | 2484 | uhci_device_ctrl_transfer(struct usbd_xfer *xfer) | |
2497 | { | 2485 | { | |
2498 | uhci_softc_t *sc = UHCI_XFER2SC(xfer); | |||
2499 | usbd_status err; | |||
2500 | ||||
2501 | /* Insert last in queue. */ | |||
2502 | mutex_enter(&sc->sc_lock); | |||
2503 | err = usb_insert_transfer(xfer); | |||
2504 | mutex_exit(&sc->sc_lock); | |||
2505 | if (err) | |||
2506 | return err; | |||
2507 | 2486 | |||
2508 | /* | 2487 | /* Pipe isn't running, so start it first. */ | |
2509 | * Pipe isn't running (otherwise err would be USBD_INPROG), | |||
2510 | * so start it first. | |||
2511 | */ | |||
2512 | return uhci_device_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 2488 | return uhci_device_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
2513 | } | 2489 | } | |
2514 | 2490 | |||
2515 | usbd_status | 2491 | usbd_status | |
2516 | uhci_device_ctrl_start(struct usbd_xfer *xfer) | 2492 | uhci_device_ctrl_start(struct usbd_xfer *xfer) | |
2517 | { | 2493 | { | |
2518 | uhci_softc_t *sc = UHCI_XFER2SC(xfer); | 2494 | uhci_softc_t *sc = UHCI_XFER2SC(xfer); | |
2519 | struct uhci_xfer *uxfer = UHCI_XFER2UXFER(xfer); | 2495 | struct uhci_xfer *uxfer = UHCI_XFER2UXFER(xfer); | |
2520 | struct uhci_pipe *upipe = UHCI_PIPE2UPIPE(xfer->ux_pipe); | 2496 | struct uhci_pipe *upipe = UHCI_PIPE2UPIPE(xfer->ux_pipe); | |
2521 | usb_device_request_t *req = &xfer->ux_request; | 2497 | usb_device_request_t *req = &xfer->ux_request; | |
2522 | struct usbd_device *dev = upipe->pipe.up_dev; | 2498 | struct usbd_device *dev = upipe->pipe.up_dev; | |
2523 | int addr = dev->ud_addr; | 2499 | int addr = dev->ud_addr; | |
2524 | int endpt = upipe->pipe.up_endpoint->ue_edesc->bEndpointAddress; | 2500 | int endpt = upipe->pipe.up_endpoint->ue_edesc->bEndpointAddress; | |
@@ -2691,40 +2667,28 @@ uhci_device_intr_fini(struct usbd_xfer * | @@ -2691,40 +2667,28 @@ uhci_device_intr_fini(struct usbd_xfer * | |||
2691 | struct uhci_xfer *ux = UHCI_XFER2UXFER(xfer); | 2667 | struct uhci_xfer *ux = UHCI_XFER2UXFER(xfer); | |
2692 | 2668 | |||
2693 | KASSERT(ux->ux_type == UX_INTR); | 2669 | KASSERT(ux->ux_type == UX_INTR); | |
2694 | 2670 | |||
2695 | if (ux->ux_nstd) { | 2671 | if (ux->ux_nstd) { | |
2696 | uhci_free_stds(sc, ux); | 2672 | uhci_free_stds(sc, ux); | |
2697 | kmem_free(ux->ux_stds, sizeof(uhci_soft_td_t *) * ux->ux_nstd); | 2673 | kmem_free(ux->ux_stds, sizeof(uhci_soft_td_t *) * ux->ux_nstd); | |
2698 | } | 2674 | } | |
2699 | } | 2675 | } | |
2700 | 2676 | |||
2701 | usbd_status | 2677 | usbd_status | |
2702 | uhci_device_intr_transfer(struct usbd_xfer *xfer) | 2678 | uhci_device_intr_transfer(struct usbd_xfer *xfer) | |
2703 | { | 2679 | { | |
2704 | uhci_softc_t *sc = UHCI_XFER2SC(xfer); | |||
2705 | usbd_status err; | |||
2706 | 2680 | |||
2707 | /* Insert last in queue. */ | 2681 | /* Pipe isn't running, so start it first. */ | |
2708 | mutex_enter(&sc->sc_lock); | |||
2709 | err = usb_insert_transfer(xfer); | |||
2710 | mutex_exit(&sc->sc_lock); | |||
2711 | if (err) | |||
2712 | return err; | |||
2713 | ||||
2714 | /* | |||
2715 | * Pipe isn't running (otherwise err would be USBD_INPROG), | |||
2716 | * so start it first. | |||
2717 | */ | |||
2718 | return uhci_device_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 2682 | return uhci_device_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
2719 | } | 2683 | } | |
2720 | 2684 | |||
2721 | usbd_status | 2685 | usbd_status | |
2722 | uhci_device_intr_start(struct usbd_xfer *xfer) | 2686 | uhci_device_intr_start(struct usbd_xfer *xfer) | |
2723 | { | 2687 | { | |
2724 | struct uhci_xfer *ux = UHCI_XFER2UXFER(xfer); | 2688 | struct uhci_xfer *ux = UHCI_XFER2UXFER(xfer); | |
2725 | struct uhci_pipe *upipe = UHCI_PIPE2UPIPE(xfer->ux_pipe); | 2689 | struct uhci_pipe *upipe = UHCI_PIPE2UPIPE(xfer->ux_pipe); | |
2726 | uhci_softc_t *sc = UHCI_XFER2SC(xfer); | 2690 | uhci_softc_t *sc = UHCI_XFER2SC(xfer); | |
2727 | uhci_soft_td_t *data, *dataend; | 2691 | uhci_soft_td_t *data, *dataend; | |
2728 | uhci_soft_qh_t *sqh; | 2692 | uhci_soft_qh_t *sqh; | |
2729 | const bool polling = sc->sc_bus.ub_usepolling; | 2693 | const bool polling = sc->sc_bus.ub_usepolling; | |
2730 | int isread, endpt; | 2694 | int isread, endpt; | |
@@ -2881,38 +2845,30 @@ uhci_device_isoc_init(struct usbd_xfer * | @@ -2881,38 +2845,30 @@ uhci_device_isoc_init(struct usbd_xfer * | |||
2881 | 2845 | |||
2882 | Static void | 2846 | Static void | |
2883 | uhci_device_isoc_fini(struct usbd_xfer *xfer) | 2847 | uhci_device_isoc_fini(struct usbd_xfer *xfer) | |
2884 | { | 2848 | { | |
2885 | struct uhci_xfer *ux __diagused = UHCI_XFER2UXFER(xfer); | 2849 | struct uhci_xfer *ux __diagused = UHCI_XFER2UXFER(xfer); | |
2886 | 2850 | |||
2887 | KASSERT(ux->ux_type == UX_ISOC); | 2851 | KASSERT(ux->ux_type == UX_ISOC); | |
2888 | } | 2852 | } | |
2889 | 2853 | |||
2890 | usbd_status | 2854 | usbd_status | |
2891 | uhci_device_isoc_transfer(struct usbd_xfer *xfer) | 2855 | uhci_device_isoc_transfer(struct usbd_xfer *xfer) | |
2892 | { | 2856 | { | |
2893 | uhci_softc_t *sc = UHCI_XFER2SC(xfer); | 2857 | uhci_softc_t *sc = UHCI_XFER2SC(xfer); | |
2894 | usbd_status err __diagused; | |||
2895 | 2858 | |||
2896 | UHCIHIST_FUNC(); UHCIHIST_CALLED(); | 2859 | UHCIHIST_FUNC(); UHCIHIST_CALLED(); | |
2897 | DPRINTFN(5, "xfer=%#jx", (uintptr_t)xfer, 0, 0, 0); | 2860 | DPRINTFN(5, "xfer=%#jx", (uintptr_t)xfer, 0, 0, 0); | |
2898 | 2861 | |||
2899 | /* Put it on our queue, */ | |||
2900 | mutex_enter(&sc->sc_lock); | |||
2901 | err = usb_insert_transfer(xfer); | |||
2902 | mutex_exit(&sc->sc_lock); | |||
2903 | ||||
2904 | KASSERT(err == USBD_NORMAL_COMPLETION); | |||
2905 | ||||
2906 | /* insert into schedule, */ | 2862 | /* insert into schedule, */ | |
2907 | 2863 | |||
2908 | struct uhci_pipe *upipe = UHCI_PIPE2UPIPE(xfer->ux_pipe); | 2864 | struct uhci_pipe *upipe = UHCI_PIPE2UPIPE(xfer->ux_pipe); | |
2909 | struct uhci_xfer *ux = UHCI_XFER2UXFER(xfer); | 2865 | struct uhci_xfer *ux = UHCI_XFER2UXFER(xfer); | |
2910 | struct isoc *isoc = &upipe->isoc; | 2866 | struct isoc *isoc = &upipe->isoc; | |
2911 | uhci_soft_td_t *std = NULL; | 2867 | uhci_soft_td_t *std = NULL; | |
2912 | uint32_t buf, len, status, offs; | 2868 | uint32_t buf, len, status, offs; | |
2913 | int i, next, nframes; | 2869 | int i, next, nframes; | |
2914 | int rd = UE_GET_DIR(upipe->pipe.up_endpoint->ue_edesc->bEndpointAddress) == UE_DIR_IN; | 2870 | int rd = UE_GET_DIR(upipe->pipe.up_endpoint->ue_edesc->bEndpointAddress) == UE_DIR_IN; | |
2915 | 2871 | |||
2916 | DPRINTFN(5, "used=%jd next=%jd xfer=%#jx nframes=%jd", | 2872 | DPRINTFN(5, "used=%jd next=%jd xfer=%#jx nframes=%jd", | |
2917 | isoc->inuse, isoc->next, (uintptr_t)xfer, xfer->ux_nframes); | 2873 | isoc->inuse, isoc->next, (uintptr_t)xfer, xfer->ux_nframes); | |
2918 | 2874 | |||
@@ -3880,40 +3836,28 @@ uhci_root_intr_abort(struct usbd_xfer *x | @@ -3880,40 +3836,28 @@ uhci_root_intr_abort(struct usbd_xfer *x | |||
3880 | 3836 | |||
3881 | KASSERT(sc->sc_intr_xfer == xfer); | 3837 | KASSERT(sc->sc_intr_xfer == xfer); | |
3882 | KASSERT(xfer->ux_status == USBD_IN_PROGRESS); | 3838 | KASSERT(xfer->ux_status == USBD_IN_PROGRESS); | |
3883 | xfer->ux_status = USBD_CANCELLED; | 3839 | xfer->ux_status = USBD_CANCELLED; | |
3884 | #ifdef DIAGNOSTIC | 3840 | #ifdef DIAGNOSTIC | |
3885 | UHCI_XFER2UXFER(xfer)->ux_isdone = true; | 3841 | UHCI_XFER2UXFER(xfer)->ux_isdone = true; | |
3886 | #endif | 3842 | #endif | |
3887 | usb_transfer_complete(xfer); | 3843 | usb_transfer_complete(xfer); | |
3888 | } | 3844 | } | |
3889 | 3845 | |||
3890 | usbd_status | 3846 | usbd_status | |
3891 | uhci_root_intr_transfer(struct usbd_xfer *xfer) | 3847 | uhci_root_intr_transfer(struct usbd_xfer *xfer) | |
3892 | { | 3848 | { | |
3893 | uhci_softc_t *sc = UHCI_XFER2SC(xfer); | |||
3894 | usbd_status err; | |||
3895 | ||||
3896 | /* Insert last in queue. */ | |||
3897 | mutex_enter(&sc->sc_lock); | |||
3898 | err = usb_insert_transfer(xfer); | |||
3899 | mutex_exit(&sc->sc_lock); | |||
3900 | if (err) | |||
3901 | return err; | |||
3902 | 3849 | |||
3903 | /* | 3850 | /* Pipe isn't running, start first */ | |
3904 | * Pipe isn't running (otherwise err would be USBD_INPROG), | |||
3905 | * start first | |||
3906 | */ | |||
3907 | return uhci_root_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 3851 | return uhci_root_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
3908 | } | 3852 | } | |
3909 | 3853 | |||
3910 | /* Start a transfer on the root interrupt pipe */ | 3854 | /* Start a transfer on the root interrupt pipe */ | |
3911 | usbd_status | 3855 | usbd_status | |
3912 | uhci_root_intr_start(struct usbd_xfer *xfer) | 3856 | uhci_root_intr_start(struct usbd_xfer *xfer) | |
3913 | { | 3857 | { | |
3914 | struct usbd_pipe *pipe = xfer->ux_pipe; | 3858 | struct usbd_pipe *pipe = xfer->ux_pipe; | |
3915 | uhci_softc_t *sc = UHCI_PIPE2SC(pipe); | 3859 | uhci_softc_t *sc = UHCI_PIPE2SC(pipe); | |
3916 | unsigned int ival; | 3860 | unsigned int ival; | |
3917 | const bool polling = sc->sc_bus.ub_usepolling; | 3861 | const bool polling = sc->sc_bus.ub_usepolling; | |
3918 | 3862 | |||
3919 | UHCIHIST_FUNC(); UHCIHIST_CALLED(); | 3863 | UHCIHIST_FUNC(); UHCIHIST_CALLED(); |
--- src/sys/dev/usb/usbdi.c 2022/01/20 03:14:03 1.222
+++ src/sys/dev/usb/usbdi.c 2022/03/03 06:04:31 1.223
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: usbdi.c,v 1.222 2022/01/20 03:14:03 mrg Exp $ */ | 1 | /* $NetBSD: usbdi.c,v 1.223 2022/03/03 06:04:31 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.222 2022/01/20 03:14:03 mrg Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.223 2022/03/03 06:04:31 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> | |
@@ -104,26 +104,27 @@ SDT_PROBE_DEFINE5(usb, device, xfer, cre | @@ -104,26 +104,27 @@ SDT_PROBE_DEFINE5(usb, device, xfer, cre | |||
104 | "size_t"/*len*/, | 104 | "size_t"/*len*/, | |
105 | "unsigned int"/*flags*/, | 105 | "unsigned int"/*flags*/, | |
106 | "unsigned int"/*nframes*/); | 106 | "unsigned int"/*nframes*/); | |
107 | SDT_PROBE_DEFINE1(usb, device, xfer, start, "struct usbd_xfer *"/*xfer*/); | 107 | SDT_PROBE_DEFINE1(usb, device, xfer, start, "struct usbd_xfer *"/*xfer*/); | |
108 | SDT_PROBE_DEFINE1(usb, device, xfer, preabort, "struct usbd_xfer *"/*xfer*/); | 108 | SDT_PROBE_DEFINE1(usb, device, xfer, preabort, "struct usbd_xfer *"/*xfer*/); | |
109 | SDT_PROBE_DEFINE1(usb, device, xfer, abort, "struct usbd_xfer *"/*xfer*/); | 109 | SDT_PROBE_DEFINE1(usb, device, xfer, abort, "struct usbd_xfer *"/*xfer*/); | |
110 | SDT_PROBE_DEFINE1(usb, device, xfer, timeout, "struct usbd_xfer *"/*xfer*/); | 110 | SDT_PROBE_DEFINE1(usb, device, xfer, timeout, "struct usbd_xfer *"/*xfer*/); | |
111 | SDT_PROBE_DEFINE2(usb, device, xfer, done, | 111 | SDT_PROBE_DEFINE2(usb, device, xfer, done, | |
112 | "struct usbd_xfer *"/*xfer*/, | 112 | "struct usbd_xfer *"/*xfer*/, | |
113 | "usbd_status"/*status*/); | 113 | "usbd_status"/*status*/); | |
114 | SDT_PROBE_DEFINE1(usb, device, xfer, destroy, "struct usbd_xfer *"/*xfer*/); | 114 | SDT_PROBE_DEFINE1(usb, device, xfer, destroy, "struct usbd_xfer *"/*xfer*/); | |
115 | 115 | |||
116 | Static usbd_status usbd_ar_pipe(struct usbd_pipe *); | 116 | Static usbd_status usbd_ar_pipe(struct usbd_pipe *); | |
117 | static usbd_status usb_insert_transfer(struct usbd_xfer *); | |||
117 | Static void usbd_start_next(struct usbd_pipe *); | 118 | Static void usbd_start_next(struct usbd_pipe *); | |
118 | Static usbd_status usbd_open_pipe_ival | 119 | Static usbd_status usbd_open_pipe_ival | |
119 | (struct usbd_interface *, uint8_t, uint8_t, struct usbd_pipe **, int); | 120 | (struct usbd_interface *, uint8_t, uint8_t, struct usbd_pipe **, int); | |
120 | static void *usbd_alloc_buffer(struct usbd_xfer *, uint32_t); | 121 | static void *usbd_alloc_buffer(struct usbd_xfer *, uint32_t); | |
121 | static void usbd_free_buffer(struct usbd_xfer *); | 122 | static void usbd_free_buffer(struct usbd_xfer *); | |
122 | static struct usbd_xfer *usbd_alloc_xfer(struct usbd_device *, unsigned int); | 123 | static struct usbd_xfer *usbd_alloc_xfer(struct usbd_device *, unsigned int); | |
123 | static usbd_status usbd_free_xfer(struct usbd_xfer *); | 124 | static usbd_status usbd_free_xfer(struct usbd_xfer *); | |
124 | static void usbd_request_async_cb(struct usbd_xfer *, void *, usbd_status); | 125 | static void usbd_request_async_cb(struct usbd_xfer *, void *, usbd_status); | |
125 | static void usbd_xfer_timeout(void *); | 126 | static void usbd_xfer_timeout(void *); | |
126 | static void usbd_xfer_timeout_task(void *); | 127 | static void usbd_xfer_timeout_task(void *); | |
127 | static bool usbd_xfer_probe_timeout(struct usbd_xfer *); | 128 | static bool usbd_xfer_probe_timeout(struct usbd_xfer *); | |
128 | static void usbd_xfer_cancel_timeout_async(struct usbd_xfer *); | 129 | static void usbd_xfer_cancel_timeout_async(struct usbd_xfer *); | |
129 | 130 | |||
@@ -396,27 +397,34 @@ usbd_transfer(struct usbd_xfer *xfer) | @@ -396,27 +397,34 @@ usbd_transfer(struct usbd_xfer *xfer) | |||
396 | * If not using the xfer buffer copy data to the | 397 | * If not using the xfer buffer copy data to the | |
397 | * xfer buffer for OUT transfers of >0 length | 398 | * xfer buffer for OUT transfers of >0 length | |
398 | */ | 399 | */ | |
399 | if (xfer->ux_buffer != xfer->ux_buf) { | 400 | if (xfer->ux_buffer != xfer->ux_buf) { | |
400 | KASSERT(xfer->ux_buf); | 401 | KASSERT(xfer->ux_buf); | |
401 | if (!usbd_xfer_isread(xfer)) { | 402 | if (!usbd_xfer_isread(xfer)) { | |
402 | memcpy(xfer->ux_buf, xfer->ux_buffer, size); | 403 | memcpy(xfer->ux_buf, xfer->ux_buffer, size); | |
403 | } | 404 | } | |
404 | } | 405 | } | |
405 | } | 406 | } | |
406 | 407 | |||
407 | /* xfer is not valid after the transfer method unless synchronous */ | 408 | /* xfer is not valid after the transfer method unless synchronous */ | |
408 | SDT_PROBE2(usb, device, pipe, transfer__start, pipe, xfer); | 409 | SDT_PROBE2(usb, device, pipe, transfer__start, pipe, xfer); | |
409 | err = pipe->up_methods->upm_transfer(xfer); | 410 | do { | |
411 | usbd_lock_pipe(pipe); | |||
412 | err = usb_insert_transfer(xfer); | |||
413 | usbd_unlock_pipe(pipe); | |||
414 | if (err) | |||
415 | break; | |||
416 | err = pipe->up_methods->upm_transfer(xfer); | |||
417 | } while (0); | |||
410 | SDT_PROBE3(usb, device, pipe, transfer__done, pipe, xfer, err); | 418 | SDT_PROBE3(usb, device, pipe, transfer__done, pipe, xfer, err); | |
411 | 419 | |||
412 | if (err != USBD_IN_PROGRESS && err) { | 420 | if (err != USBD_IN_PROGRESS && err) { | |
413 | /* | 421 | /* | |
414 | * The transfer made it onto the pipe queue, but didn't get | 422 | * The transfer made it onto the pipe queue, but didn't get | |
415 | * accepted by the HCD for some reason. It needs removing | 423 | * accepted by the HCD for some reason. It needs removing | |
416 | * from the pipe queue. | 424 | * from the pipe queue. | |
417 | */ | 425 | */ | |
418 | USBHIST_LOG(usbdebug, "xfer failed: %jd, reinserting", | 426 | USBHIST_LOG(usbdebug, "xfer failed: %jd, reinserting", | |
419 | err, 0, 0, 0); | 427 | err, 0, 0, 0); | |
420 | usbd_lock_pipe(pipe); | 428 | usbd_lock_pipe(pipe); | |
421 | SDT_PROBE1(usb, device, xfer, preabort, xfer); | 429 | SDT_PROBE1(usb, device, xfer, preabort, xfer); | |
422 | #ifdef DIAGNOSTIC | 430 | #ifdef DIAGNOSTIC | |
@@ -1126,27 +1134,27 @@ usb_transfer_complete(struct usbd_xfer * | @@ -1126,27 +1134,27 @@ usb_transfer_complete(struct usbd_xfer * | |||
1126 | if (repeat) { | 1134 | if (repeat) { | |
1127 | xfer->ux_actlen = 0; | 1135 | xfer->ux_actlen = 0; | |
1128 | xfer->ux_status = USBD_NOT_STARTED; | 1136 | xfer->ux_status = USBD_NOT_STARTED; | |
1129 | } else { | 1137 | } else { | |
1130 | /* XXX should we stop the queue on all errors? */ | 1138 | /* XXX should we stop the queue on all errors? */ | |
1131 | if (erred && pipe->up_iface != NULL) /* not control pipe */ | 1139 | if (erred && pipe->up_iface != NULL) /* not control pipe */ | |
1132 | pipe->up_running = 0; | 1140 | pipe->up_running = 0; | |
1133 | } | 1141 | } | |
1134 | if (pipe->up_running && pipe->up_serialise) | 1142 | if (pipe->up_running && pipe->up_serialise) | |
1135 | usbd_start_next(pipe); | 1143 | usbd_start_next(pipe); | |
1136 | } | 1144 | } | |
1137 | 1145 | |||
1138 | /* Called with USB lock held. */ | 1146 | /* Called with USB lock held. */ | |
1139 | usbd_status | 1147 | static usbd_status | |
1140 | usb_insert_transfer(struct usbd_xfer *xfer) | 1148 | usb_insert_transfer(struct usbd_xfer *xfer) | |
1141 | { | 1149 | { | |
1142 | struct usbd_pipe *pipe = xfer->ux_pipe; | 1150 | struct usbd_pipe *pipe = xfer->ux_pipe; | |
1143 | usbd_status err; | 1151 | usbd_status err; | |
1144 | 1152 | |||
1145 | USBHIST_FUNC(); USBHIST_CALLARGS(usbdebug, | 1153 | USBHIST_FUNC(); USBHIST_CALLARGS(usbdebug, | |
1146 | "xfer = %#jx pipe = %#jx running = %jd timeout = %jd", | 1154 | "xfer = %#jx pipe = %#jx running = %jd timeout = %jd", | |
1147 | (uintptr_t)xfer, (uintptr_t)pipe, | 1155 | (uintptr_t)xfer, (uintptr_t)pipe, | |
1148 | pipe->up_running, xfer->ux_timeout); | 1156 | pipe->up_running, xfer->ux_timeout); | |
1149 | 1157 | |||
1150 | KASSERT(mutex_owned(pipe->up_dev->ud_bus->ub_lock)); | 1158 | KASSERT(mutex_owned(pipe->up_dev->ud_bus->ub_lock)); | |
1151 | KASSERTMSG(xfer->ux_state == XFER_BUSY, "xfer %p state is %x", xfer, | 1159 | KASSERTMSG(xfer->ux_state == XFER_BUSY, "xfer %p state is %x", xfer, | |
1152 | xfer->ux_state); | 1160 | xfer->ux_state); |
--- src/sys/dev/usb/usbdivar.h 2022/02/14 09:23:32 1.131
+++ src/sys/dev/usb/usbdivar.h 2022/03/03 06:04:31 1.132
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: usbdivar.h,v 1.131 2022/02/14 09:23:32 riastradh Exp $ */ | 1 | /* $NetBSD: usbdivar.h,v 1.132 2022/03/03 06:04:31 riastradh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 2012 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 and Matthew R. Green (mrg@eterna.com.au). | 9 | * Carlstedt Research & Technology and Matthew R. Green (mrg@eterna.com.au). | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -57,27 +57,26 @@ | @@ -57,27 +57,26 @@ | |||
57 | * upm_transfer - | 57 | * upm_transfer - | |
58 | * upm_start - might want to take lock? | 58 | * upm_start - might want to take lock? | |
59 | * upm_abort x | 59 | * upm_abort x | |
60 | * upm_close x | 60 | * upm_close x | |
61 | * upm_cleartoggle - | 61 | * upm_cleartoggle - | |
62 | * upm_done x | 62 | * upm_done x | |
63 | * | 63 | * | |
64 | * The above semantics are likely to change. Little performance | 64 | * The above semantics are likely to change. Little performance | |
65 | * evaluation has been done on this code and the locking strategy. | 65 | * evaluation has been done on this code and the locking strategy. | |
66 | * | 66 | * | |
67 | * USB functions known to expect the lock taken include (this list is | 67 | * USB functions known to expect the lock taken include (this list is | |
68 | * probably not exhaustive): | 68 | * probably not exhaustive): | |
69 | * usb_transfer_complete() | 69 | * usb_transfer_complete() | |
70 | * usb_insert_transfer() | |||
71 | * usb_start_next() | 70 | * usb_start_next() | |
72 | * | 71 | * | |
73 | */ | 72 | */ | |
74 | 73 | |||
75 | #include <sys/callout.h> | 74 | #include <sys/callout.h> | |
76 | #include <sys/mutex.h> | 75 | #include <sys/mutex.h> | |
77 | #include <sys/bus.h> | 76 | #include <sys/bus.h> | |
78 | 77 | |||
79 | /* From usb_mem.h */ | 78 | /* From usb_mem.h */ | |
80 | struct usb_dma_block; | 79 | struct usb_dma_block; | |
81 | typedef struct { | 80 | typedef struct { | |
82 | struct usb_dma_block *udma_block; | 81 | struct usb_dma_block *udma_block; | |
83 | u_int udma_offs; | 82 | u_int udma_offs; | |
@@ -349,27 +348,26 @@ usbd_status usbd_new_device(device_t, st | @@ -349,27 +348,26 @@ usbd_status usbd_new_device(device_t, st | |||
349 | struct usbd_port *); | 348 | struct usbd_port *); | |
350 | usbd_status usbd_reattach_device(device_t, struct usbd_device *, | 349 | usbd_status usbd_reattach_device(device_t, struct usbd_device *, | |
351 | int, const int *); | 350 | int, const int *); | |
352 | 351 | |||
353 | void usbd_remove_device(struct usbd_device *, struct usbd_port *); | 352 | void usbd_remove_device(struct usbd_device *, struct usbd_port *); | |
354 | bool usbd_iface_locked(struct usbd_interface *); | 353 | bool usbd_iface_locked(struct usbd_interface *); | |
355 | usbd_status usbd_iface_lock(struct usbd_interface *); | 354 | usbd_status usbd_iface_lock(struct usbd_interface *); | |
356 | void usbd_iface_unlock(struct usbd_interface *); | 355 | void usbd_iface_unlock(struct usbd_interface *); | |
357 | usbd_status usbd_iface_piperef(struct usbd_interface *); | 356 | usbd_status usbd_iface_piperef(struct usbd_interface *); | |
358 | void usbd_iface_pipeunref(struct usbd_interface *); | 357 | void usbd_iface_pipeunref(struct usbd_interface *); | |
359 | usbd_status usbd_fill_iface_data(struct usbd_device *, int, int); | 358 | usbd_status usbd_fill_iface_data(struct usbd_device *, int, int); | |
360 | void usb_free_device(struct usbd_device *); | 359 | void usb_free_device(struct usbd_device *); | |
361 | 360 | |||
362 | usbd_status usb_insert_transfer(struct usbd_xfer *); | |||
363 | void usb_transfer_complete(struct usbd_xfer *); | 361 | void usb_transfer_complete(struct usbd_xfer *); | |
364 | int usb_disconnect_port(struct usbd_port *, device_t, int); | 362 | int usb_disconnect_port(struct usbd_port *, device_t, int); | |
365 | 363 | |||
366 | usbd_status usbd_endpoint_acquire(struct usbd_device *, | 364 | usbd_status usbd_endpoint_acquire(struct usbd_device *, | |
367 | struct usbd_endpoint *, int); | 365 | struct usbd_endpoint *, int); | |
368 | void usbd_endpoint_release(struct usbd_device *, | 366 | void usbd_endpoint_release(struct usbd_device *, | |
369 | struct usbd_endpoint *); | 367 | struct usbd_endpoint *); | |
370 | 368 | |||
371 | void usbd_kill_pipe(struct usbd_pipe *); | 369 | void usbd_kill_pipe(struct usbd_pipe *); | |
372 | usbd_status usbd_attach_roothub(device_t, struct usbd_device *); | 370 | usbd_status usbd_attach_roothub(device_t, struct usbd_device *); | |
373 | usbd_status usbd_probe_and_attach(device_t, struct usbd_device *, int, int); | 371 | usbd_status usbd_probe_and_attach(device_t, struct usbd_device *, int, int); | |
374 | 372 | |||
375 | /* Routines from usb.c */ | 373 | /* Routines from usb.c */ |
--- src/sys/dev/usb/usbroothub.c 2022/01/20 03:14:03 1.11
+++ src/sys/dev/usb/usbroothub.c 2022/03/03 06:04:31 1.12
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: usbroothub.c,v 1.11 2022/01/20 03:14:03 mrg Exp $ */ | 1 | /* $NetBSD: usbroothub.c,v 1.12 2022/03/03 06:04:31 riastradh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 2004, 2011, 2012 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 2004, 2011, 2012 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: | |
@@ -48,27 +48,27 @@ | @@ -48,27 +48,27 @@ | |||
48 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 48 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
49 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 49 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
50 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 50 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
51 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 51 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
52 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 52 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
53 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 53 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
54 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 54 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
55 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 55 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
56 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 56 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
57 | * | 57 | * | |
58 | */ | 58 | */ | |
59 | 59 | |||
60 | #include <sys/cdefs.h> | 60 | #include <sys/cdefs.h> | |
61 | __KERNEL_RCSID(0, "$NetBSD: usbroothub.c,v 1.11 2022/01/20 03:14:03 mrg Exp $"); | 61 | __KERNEL_RCSID(0, "$NetBSD: usbroothub.c,v 1.12 2022/03/03 06:04:31 riastradh Exp $"); | |
62 | 62 | |||
63 | #include <sys/param.h> | 63 | #include <sys/param.h> | |
64 | #include <sys/systm.h> /* for ostype */ | 64 | #include <sys/systm.h> /* for ostype */ | |
65 | 65 | |||
66 | #include <dev/usb/usb.h> | 66 | #include <dev/usb/usb.h> | |
67 | #include <dev/usb/usbdi.h> | 67 | #include <dev/usb/usbdi.h> | |
68 | #include <dev/usb/usbdivar.h> | 68 | #include <dev/usb/usbdivar.h> | |
69 | #include <dev/usb/usbroothub.h> | 69 | #include <dev/usb/usbroothub.h> | |
70 | #include <dev/usb/usbhist.h> | 70 | #include <dev/usb/usbhist.h> | |
71 | 71 | |||
72 | /* helper functions for USB root hub emulation */ | 72 | /* helper functions for USB root hub emulation */ | |
73 | 73 | |||
74 | static usbd_status roothub_ctrl_transfer(struct usbd_xfer *); | 74 | static usbd_status roothub_ctrl_transfer(struct usbd_xfer *); | |
@@ -333,36 +333,26 @@ static const usb_hub_descriptor_t usbroo | @@ -333,36 +333,26 @@ static const usb_hub_descriptor_t usbroo | |||
333 | .bNbrPorts = 1, | 333 | .bNbrPorts = 1, | |
334 | .wHubCharacteristics = USETWD(UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL), | 334 | .wHubCharacteristics = USETWD(UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL), | |
335 | .bPwrOn2PwrGood = 50, | 335 | .bPwrOn2PwrGood = 50, | |
336 | .bHubContrCurrent = 0, | 336 | .bHubContrCurrent = 0, | |
337 | .DeviceRemovable = {0}, /* port is removable */ | 337 | .DeviceRemovable = {0}, /* port is removable */ | |
338 | }; | 338 | }; | |
339 | 339 | |||
340 | /* | 340 | /* | |
341 | * Simulate a hardware hub by handling all the necessary requests. | 341 | * Simulate a hardware hub by handling all the necessary requests. | |
342 | */ | 342 | */ | |
343 | usbd_status | 343 | usbd_status | |
344 | roothub_ctrl_transfer(struct usbd_xfer *xfer) | 344 | roothub_ctrl_transfer(struct usbd_xfer *xfer) | |
345 | { | 345 | { | |
346 | struct usbd_pipe *pipe = xfer->ux_pipe; | |||
347 | struct usbd_bus *bus = pipe->up_dev->ud_bus; | |||
348 | usbd_status err; | |||
349 | ||||
350 | /* Insert last in queue. */ | |||
351 | mutex_enter(bus->ub_lock); | |||
352 | err = usb_insert_transfer(xfer); | |||
353 | mutex_exit(bus->ub_lock); | |||
354 | if (err) | |||
355 | return err; | |||
356 | 346 | |||
357 | /* Pipe isn't running, start first */ | 347 | /* Pipe isn't running, start first */ | |
358 | return roothub_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 348 | return roothub_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
359 | } | 349 | } | |
360 | 350 | |||
361 | static usbd_status | 351 | static usbd_status | |
362 | roothub_ctrl_start(struct usbd_xfer *xfer) | 352 | roothub_ctrl_start(struct usbd_xfer *xfer) | |
363 | { | 353 | { | |
364 | struct usbd_pipe *pipe = xfer->ux_pipe; | 354 | struct usbd_pipe *pipe = xfer->ux_pipe; | |
365 | struct usbd_bus *bus = pipe->up_dev->ud_bus; | 355 | struct usbd_bus *bus = pipe->up_dev->ud_bus; | |
366 | usb_device_request_t *req; | 356 | usb_device_request_t *req; | |
367 | usbd_status err = USBD_IOERROR; /* XXX STALL? */ | 357 | usbd_status err = USBD_IOERROR; /* XXX STALL? */ | |
368 | uint16_t len, value; | 358 | uint16_t len, value; |
--- src/sys/dev/usb/vhci.c 2022/02/12 03:24:36 1.23
+++ src/sys/dev/usb/vhci.c 2022/03/03 06:04:31 1.24
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: vhci.c,v 1.23 2022/02/12 03:24:36 riastradh Exp $ */ | 1 | /* $NetBSD: vhci.c,v 1.24 2022/03/03 06:04:31 riastradh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2019-2020 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2019-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 Maxime Villard. | 8 | * by Maxime Villard. | |
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: vhci.c,v 1.23 2022/02/12 03:24:36 riastradh Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: vhci.c,v 1.24 2022/03/03 06:04:31 riastradh Exp $"); | |
34 | 34 | |||
35 | #ifdef _KERNEL_OPT | 35 | #ifdef _KERNEL_OPT | |
36 | #include "opt_usb.h" | 36 | #include "opt_usb.h" | |
37 | #endif | 37 | #endif | |
38 | 38 | |||
39 | #include <sys/param.h> | 39 | #include <sys/param.h> | |
40 | 40 | |||
41 | #include <sys/bus.h> | 41 | #include <sys/bus.h> | |
42 | #include <sys/cpu.h> | 42 | #include <sys/cpu.h> | |
43 | #include <sys/conf.h> | 43 | #include <sys/conf.h> | |
44 | #include <sys/device.h> | 44 | #include <sys/device.h> | |
45 | #include <sys/kernel.h> | 45 | #include <sys/kernel.h> | |
46 | #include <sys/kmem.h> | 46 | #include <sys/kmem.h> | |
@@ -580,38 +580,29 @@ vhci_roothub_ctrl(struct usbd_bus *bus, | @@ -580,38 +580,29 @@ vhci_roothub_ctrl(struct usbd_bus *bus, | |||
580 | default: | 580 | default: | |
581 | /* default from usbroothub */ | 581 | /* default from usbroothub */ | |
582 | return buflen; | 582 | return buflen; | |
583 | } | 583 | } | |
584 | 584 | |||
585 | return totlen; | 585 | return totlen; | |
586 | } | 586 | } | |
587 | 587 | |||
588 | /* -------------------------------------------------------------------------- */ | 588 | /* -------------------------------------------------------------------------- */ | |
589 | 589 | |||
590 | static usbd_status | 590 | static usbd_status | |
591 | vhci_device_ctrl_transfer(struct usbd_xfer *xfer) | 591 | vhci_device_ctrl_transfer(struct usbd_xfer *xfer) | |
592 | { | 592 | { | |
593 | vhci_softc_t *sc = xfer->ux_bus->ub_hcpriv; | |||
594 | usbd_status err; | |||
595 | 593 | |||
596 | DPRINTF("%s: called\n", __func__); | 594 | DPRINTF("%s: called\n", __func__); | |
597 | 595 | |||
598 | /* Insert last in queue. */ | |||
599 | mutex_enter(&sc->sc_lock); | |||
600 | err = usb_insert_transfer(xfer); | |||
601 | mutex_exit(&sc->sc_lock); | |||
602 | if (err) | |||
603 | return err; | |||
604 | ||||
605 | /* Pipe isn't running, start first */ | 596 | /* Pipe isn't running, start first */ | |
606 | return vhci_device_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 597 | return vhci_device_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
607 | } | 598 | } | |
608 | 599 | |||
609 | static usbd_status | 600 | static usbd_status | |
610 | vhci_device_ctrl_start(struct usbd_xfer *xfer) | 601 | vhci_device_ctrl_start(struct usbd_xfer *xfer) | |
611 | { | 602 | { | |
612 | usb_endpoint_descriptor_t *ed = xfer->ux_pipe->up_endpoint->ue_edesc; | 603 | usb_endpoint_descriptor_t *ed = xfer->ux_pipe->up_endpoint->ue_edesc; | |
613 | usb_device_request_t *req = &xfer->ux_request; | 604 | usb_device_request_t *req = &xfer->ux_request; | |
614 | struct usbd_device *dev = xfer->ux_pipe->up_dev; | 605 | struct usbd_device *dev = xfer->ux_pipe->up_dev; | |
615 | vhci_softc_t *sc = xfer->ux_bus->ub_hcpriv; | 606 | vhci_softc_t *sc = xfer->ux_bus->ub_hcpriv; | |
616 | vhci_port_t *port; | 607 | vhci_port_t *port; | |
617 | bool polling = sc->sc_bus.ub_usepolling; | 608 | bool polling = sc->sc_bus.ub_usepolling; | |
@@ -697,38 +688,29 @@ vhci_device_ctrl_cleartoggle(struct usbd | @@ -697,38 +688,29 @@ vhci_device_ctrl_cleartoggle(struct usbd | |||
697 | } | 688 | } | |
698 | 689 | |||
699 | static void | 690 | static void | |
700 | vhci_device_ctrl_done(struct usbd_xfer *xfer) | 691 | vhci_device_ctrl_done(struct usbd_xfer *xfer) | |
701 | { | 692 | { | |
702 | DPRINTF("%s: called\n", __func__); | 693 | DPRINTF("%s: called\n", __func__); | |
703 | } | 694 | } | |
704 | 695 | |||
705 | /* -------------------------------------------------------------------------- */ | 696 | /* -------------------------------------------------------------------------- */ | |
706 | 697 | |||
707 | static usbd_status | 698 | static usbd_status | |
708 | vhci_root_intr_transfer(struct usbd_xfer *xfer) | 699 | vhci_root_intr_transfer(struct usbd_xfer *xfer) | |
709 | { | 700 | { | |
710 | vhci_softc_t *sc = xfer->ux_bus->ub_hcpriv; | |||
711 | usbd_status err; | |||
712 | 701 | |||
713 | DPRINTF("%s: called\n", __func__); | 702 | DPRINTF("%s: called\n", __func__); | |
714 | 703 | |||
715 | /* Insert last in queue. */ | |||
716 | mutex_enter(&sc->sc_lock); | |||
717 | err = usb_insert_transfer(xfer); | |||
718 | mutex_exit(&sc->sc_lock); | |||
719 | if (err) | |||
720 | return err; | |||
721 | ||||
722 | /* Pipe isn't running, start first */ | 704 | /* Pipe isn't running, start first */ | |
723 | return vhci_root_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 705 | return vhci_root_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
724 | } | 706 | } | |
725 | 707 | |||
726 | static usbd_status | 708 | static usbd_status | |
727 | vhci_root_intr_start(struct usbd_xfer *xfer) | 709 | vhci_root_intr_start(struct usbd_xfer *xfer) | |
728 | { | 710 | { | |
729 | vhci_softc_t *sc = xfer->ux_bus->ub_hcpriv; | 711 | vhci_softc_t *sc = xfer->ux_bus->ub_hcpriv; | |
730 | const bool polling = sc->sc_bus.ub_usepolling; | 712 | const bool polling = sc->sc_bus.ub_usepolling; | |
731 | 713 | |||
732 | DPRINTF("%s: called, len=%zu\n", __func__, (size_t)xfer->ux_length); | 714 | DPRINTF("%s: called, len=%zu\n", __func__, (size_t)xfer->ux_length); | |
733 | 715 | |||
734 | if (sc->sc_dying) | 716 | if (sc->sc_dying) |
--- src/sys/dev/usb/xhci.c 2022/01/29 21:36:12 1.155
+++ src/sys/dev/usb/xhci.c 2022/03/03 06:04:31 1.156
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: xhci.c,v 1.155 2022/01/29 21:36:12 riastradh Exp $ */ | 1 | /* $NetBSD: xhci.c,v 1.156 2022/03/03 06:04:31 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.155 2022/01/29 21:36:12 riastradh Exp $"); | 37 | __KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.156 2022/03/03 06:04:31 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> | |
@@ -4119,38 +4119,28 @@ xhci_roothub_ctrl(struct usbd_bus *bus, | @@ -4119,38 +4119,28 @@ xhci_roothub_ctrl(struct usbd_bus *bus, | |||
4119 | default: | 4119 | default: | |
4120 | /* default from usbroothub */ | 4120 | /* default from usbroothub */ | |
4121 | return buflen; | 4121 | return buflen; | |
4122 | } | 4122 | } | |
4123 | 4123 | |||
4124 | return totlen; | 4124 | return totlen; | |
4125 | } | 4125 | } | |
4126 | 4126 | |||
4127 | /* root hub interrupt */ | 4127 | /* root hub interrupt */ | |
4128 | 4128 | |||
4129 | static usbd_status | 4129 | static usbd_status | |
4130 | xhci_root_intr_transfer(struct usbd_xfer *xfer) | 4130 | xhci_root_intr_transfer(struct usbd_xfer *xfer) | |
4131 | { | 4131 | { | |
4132 | struct xhci_softc * const sc = XHCI_XFER2SC(xfer); | |||
4133 | usbd_status err; | |||
4134 | ||||
4135 | XHCIHIST_FUNC(); XHCIHIST_CALLED(); | 4132 | XHCIHIST_FUNC(); XHCIHIST_CALLED(); | |
4136 | 4133 | |||
4137 | /* Insert last in queue. */ | |||
4138 | mutex_enter(&sc->sc_lock); | |||
4139 | err = usb_insert_transfer(xfer); | |||
4140 | mutex_exit(&sc->sc_lock); | |||
4141 | if (err) | |||
4142 | return err; | |||
4143 | ||||
4144 | /* Pipe isn't running, start first */ | 4134 | /* Pipe isn't running, start first */ | |
4145 | return xhci_root_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 4135 | return xhci_root_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
4146 | } | 4136 | } | |
4147 | 4137 | |||
4148 | /* Wait for roothub port status/change */ | 4138 | /* Wait for roothub port status/change */ | |
4149 | static usbd_status | 4139 | static usbd_status | |
4150 | xhci_root_intr_start(struct usbd_xfer *xfer) | 4140 | xhci_root_intr_start(struct usbd_xfer *xfer) | |
4151 | { | 4141 | { | |
4152 | struct xhci_softc * const sc = XHCI_XFER2SC(xfer); | 4142 | struct xhci_softc * const sc = XHCI_XFER2SC(xfer); | |
4153 | const size_t bn = XHCI_XFER2BUS(xfer) == &sc->sc_bus ? 0 : 1; | 4143 | const size_t bn = XHCI_XFER2BUS(xfer) == &sc->sc_bus ? 0 : 1; | |
4154 | const bool polling = xhci_polling_p(sc); | 4144 | const bool polling = xhci_polling_p(sc); | |
4155 | 4145 | |||
4156 | XHCIHIST_FUNC(); XHCIHIST_CALLED(); | 4146 | XHCIHIST_FUNC(); XHCIHIST_CALLED(); | |
@@ -4223,38 +4213,28 @@ xhci_root_intr_done(struct usbd_xfer *xf | @@ -4223,38 +4213,28 @@ xhci_root_intr_done(struct usbd_xfer *xf | |||
4223 | 4213 | |||
4224 | /* Claim the xfer so it doesn't get completed again. */ | 4214 | /* Claim the xfer so it doesn't get completed again. */ | |
4225 | KASSERT(sc->sc_intrxfer[bn] == xfer); | 4215 | KASSERT(sc->sc_intrxfer[bn] == xfer); | |
4226 | KASSERT(xfer->ux_status != USBD_IN_PROGRESS); | 4216 | KASSERT(xfer->ux_status != USBD_IN_PROGRESS); | |
4227 | sc->sc_intrxfer[bn] = NULL; | 4217 | sc->sc_intrxfer[bn] = NULL; | |
4228 | } | 4218 | } | |
4229 | 4219 | |||
4230 | /* -------------- */ | 4220 | /* -------------- */ | |
4231 | /* device control */ | 4221 | /* device control */ | |
4232 | 4222 | |||
4233 | static usbd_status | 4223 | static usbd_status | |
4234 | xhci_device_ctrl_transfer(struct usbd_xfer *xfer) | 4224 | xhci_device_ctrl_transfer(struct usbd_xfer *xfer) | |
4235 | { | 4225 | { | |
4236 | struct xhci_softc * const sc = XHCI_XFER2SC(xfer); | |||
4237 | usbd_status err; | |||
4238 | ||||
4239 | XHCIHIST_FUNC(); XHCIHIST_CALLED(); | 4226 | XHCIHIST_FUNC(); XHCIHIST_CALLED(); | |
4240 | 4227 | |||
4241 | /* Insert last in queue. */ | |||
4242 | mutex_enter(&sc->sc_lock); | |||
4243 | err = usb_insert_transfer(xfer); | |||
4244 | mutex_exit(&sc->sc_lock); | |||
4245 | if (err) | |||
4246 | return err; | |||
4247 | ||||
4248 | /* Pipe isn't running, start first */ | 4228 | /* Pipe isn't running, start first */ | |
4249 | return xhci_device_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 4229 | return xhci_device_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
4250 | } | 4230 | } | |
4251 | 4231 | |||
4252 | static usbd_status | 4232 | static usbd_status | |
4253 | xhci_device_ctrl_start(struct usbd_xfer *xfer) | 4233 | xhci_device_ctrl_start(struct usbd_xfer *xfer) | |
4254 | { | 4234 | { | |
4255 | struct xhci_softc * const sc = XHCI_XFER2SC(xfer); | 4235 | struct xhci_softc * const sc = XHCI_XFER2SC(xfer); | |
4256 | struct xhci_slot * const xs = xfer->ux_pipe->up_dev->ud_hcpriv; | 4236 | struct xhci_slot * const xs = xfer->ux_pipe->up_dev->ud_hcpriv; | |
4257 | const u_int dci = xhci_ep_get_dci(xfer->ux_pipe->up_endpoint->ue_edesc); | 4237 | const u_int dci = xhci_ep_get_dci(xfer->ux_pipe->up_endpoint->ue_edesc); | |
4258 | struct xhci_ring * const tr = xs->xs_xr[dci]; | 4238 | struct xhci_ring * const tr = xs->xs_xr[dci]; | |
4259 | struct xhci_xfer * const xx = XHCI_XFER2XXFER(xfer); | 4239 | struct xhci_xfer * const xx = XHCI_XFER2XXFER(xfer); | |
4260 | usb_device_request_t * const req = &xfer->ux_request; | 4240 | usb_device_request_t * const req = &xfer->ux_request; | |
@@ -4368,38 +4348,28 @@ static void | @@ -4368,38 +4348,28 @@ static void | |||
4368 | xhci_device_ctrl_close(struct usbd_pipe *pipe) | 4348 | xhci_device_ctrl_close(struct usbd_pipe *pipe) | |
4369 | { | 4349 | { | |
4370 | XHCIHIST_FUNC(); XHCIHIST_CALLED(); | 4350 | XHCIHIST_FUNC(); XHCIHIST_CALLED(); | |
4371 | 4351 | |||
4372 | xhci_close_pipe(pipe); | 4352 | xhci_close_pipe(pipe); | |
4373 | } | 4353 | } | |
4374 | 4354 | |||
4375 | /* ------------------ */ | 4355 | /* ------------------ */ | |
4376 | /* device isochronous */ | 4356 | /* device isochronous */ | |
4377 | 4357 | |||
4378 | static usbd_status | 4358 | static usbd_status | |
4379 | xhci_device_isoc_transfer(struct usbd_xfer *xfer) | 4359 | xhci_device_isoc_transfer(struct usbd_xfer *xfer) | |
4380 | { | 4360 | { | |
4381 | struct xhci_softc * const sc = XHCI_XFER2SC(xfer); | |||
4382 | usbd_status err; | |||
4383 | ||||
4384 | XHCIHIST_FUNC(); XHCIHIST_CALLED(); | 4361 | XHCIHIST_FUNC(); XHCIHIST_CALLED(); | |
4385 | 4362 | |||
4386 | /* Insert last in queue. */ | |||
4387 | mutex_enter(&sc->sc_lock); | |||
4388 | err = usb_insert_transfer(xfer); | |||
4389 | mutex_exit(&sc->sc_lock); | |||
4390 | if (err) | |||
4391 | return err; | |||
4392 | ||||
4393 | return xhci_device_isoc_enter(xfer); | 4363 | return xhci_device_isoc_enter(xfer); | |
4394 | } | 4364 | } | |
4395 | 4365 | |||
4396 | static usbd_status | 4366 | static usbd_status | |
4397 | xhci_device_isoc_enter(struct usbd_xfer *xfer) | 4367 | xhci_device_isoc_enter(struct usbd_xfer *xfer) | |
4398 | { | 4368 | { | |
4399 | struct xhci_softc * const sc = XHCI_XFER2SC(xfer); | 4369 | struct xhci_softc * const sc = XHCI_XFER2SC(xfer); | |
4400 | struct xhci_slot * const xs = xfer->ux_pipe->up_dev->ud_hcpriv; | 4370 | struct xhci_slot * const xs = xfer->ux_pipe->up_dev->ud_hcpriv; | |
4401 | const u_int dci = xhci_ep_get_dci(xfer->ux_pipe->up_endpoint->ue_edesc); | 4371 | const u_int dci = xhci_ep_get_dci(xfer->ux_pipe->up_endpoint->ue_edesc); | |
4402 | struct xhci_ring * const tr = xs->xs_xr[dci]; | 4372 | struct xhci_ring * const tr = xs->xs_xr[dci]; | |
4403 | struct xhci_xfer * const xx = XHCI_XFER2XXFER(xfer); | 4373 | struct xhci_xfer * const xx = XHCI_XFER2XXFER(xfer); | |
4404 | struct xhci_pipe * const xpipe = (struct xhci_pipe *)xfer->ux_pipe; | 4374 | struct xhci_pipe * const xpipe = (struct xhci_pipe *)xfer->ux_pipe; | |
4405 | uint32_t len = xfer->ux_length; | 4375 | uint32_t len = xfer->ux_length; | |
@@ -4532,42 +4502,29 @@ xhci_device_isoc_done(struct usbd_xfer * | @@ -4532,42 +4502,29 @@ xhci_device_isoc_done(struct usbd_xfer * | |||
4532 | XHCIHIST_CALLARGS("%#jx slot %ju dci %ju", | 4502 | XHCIHIST_CALLARGS("%#jx slot %ju dci %ju", | |
4533 | (uintptr_t)xfer, xs->xs_idx, dci, 0); | 4503 | (uintptr_t)xfer, xs->xs_idx, dci, 0); | |
4534 | 4504 | |||
4535 | usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length, | 4505 | usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length, | |
4536 | isread ? BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE); | 4506 | isread ? BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE); | |
4537 | } | 4507 | } | |
4538 | 4508 | |||
4539 | /* ----------- */ | 4509 | /* ----------- */ | |
4540 | /* device bulk */ | 4510 | /* device bulk */ | |
4541 | 4511 | |||
4542 | static usbd_status | 4512 | static usbd_status | |
4543 | xhci_device_bulk_transfer(struct usbd_xfer *xfer) | 4513 | xhci_device_bulk_transfer(struct usbd_xfer *xfer) | |
4544 | { | 4514 | { | |
4545 | struct xhci_softc * const sc = XHCI_XFER2SC(xfer); | |||
4546 | usbd_status err; | |||
4547 | ||||
4548 | XHCIHIST_FUNC(); XHCIHIST_CALLED(); | 4515 | XHCIHIST_FUNC(); XHCIHIST_CALLED(); | |
4549 | 4516 | |||
4550 | /* Insert last in queue. */ | 4517 | /* Pipe isn't running, so start it first. */ | |
4551 | mutex_enter(&sc->sc_lock); | |||
4552 | err = usb_insert_transfer(xfer); | |||
4553 | mutex_exit(&sc->sc_lock); | |||
4554 | if (err) | |||
4555 | return err; | |||
4556 | ||||
4557 | /* | |||
4558 | * Pipe isn't running (otherwise err would be USBD_INPROG), | |||
4559 | * so start it first. | |||
4560 | */ | |||
4561 | return xhci_device_bulk_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 4518 | return xhci_device_bulk_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
4562 | } | 4519 | } | |
4563 | 4520 | |||
4564 | static usbd_status | 4521 | static usbd_status | |
4565 | xhci_device_bulk_start(struct usbd_xfer *xfer) | 4522 | xhci_device_bulk_start(struct usbd_xfer *xfer) | |
4566 | { | 4523 | { | |
4567 | struct xhci_softc * const sc = XHCI_XFER2SC(xfer); | 4524 | struct xhci_softc * const sc = XHCI_XFER2SC(xfer); | |
4568 | struct xhci_slot * const xs = xfer->ux_pipe->up_dev->ud_hcpriv; | 4525 | struct xhci_slot * const xs = xfer->ux_pipe->up_dev->ud_hcpriv; | |
4569 | const u_int dci = xhci_ep_get_dci(xfer->ux_pipe->up_endpoint->ue_edesc); | 4526 | const u_int dci = xhci_ep_get_dci(xfer->ux_pipe->up_endpoint->ue_edesc); | |
4570 | struct xhci_ring * const tr = xs->xs_xr[dci]; | 4527 | struct xhci_ring * const tr = xs->xs_xr[dci]; | |
4571 | struct xhci_xfer * const xx = XHCI_XFER2XXFER(xfer); | 4528 | struct xhci_xfer * const xx = XHCI_XFER2XXFER(xfer); | |
4572 | const uint32_t len = xfer->ux_length; | 4529 | const uint32_t len = xfer->ux_length; | |
4573 | usb_dma_t * const dma = &xfer->ux_dmabuf; | 4530 | usb_dma_t * const dma = &xfer->ux_dmabuf; | |
@@ -4670,42 +4627,29 @@ static void | @@ -4670,42 +4627,29 @@ static void | |||
4670 | xhci_device_bulk_close(struct usbd_pipe *pipe) | 4627 | xhci_device_bulk_close(struct usbd_pipe *pipe) | |
4671 | { | 4628 | { | |
4672 | XHCIHIST_FUNC(); XHCIHIST_CALLED(); | 4629 | XHCIHIST_FUNC(); XHCIHIST_CALLED(); | |
4673 | 4630 | |||
4674 | xhci_close_pipe(pipe); | 4631 | xhci_close_pipe(pipe); | |
4675 | } | 4632 | } | |
4676 | 4633 | |||
4677 | /* ---------------- */ | 4634 | /* ---------------- */ | |
4678 | /* device interrupt */ | 4635 | /* device interrupt */ | |
4679 | 4636 | |||
4680 | static usbd_status | 4637 | static usbd_status | |
4681 | xhci_device_intr_transfer(struct usbd_xfer *xfer) | 4638 | xhci_device_intr_transfer(struct usbd_xfer *xfer) | |
4682 | { | 4639 | { | |
4683 | struct xhci_softc * const sc = XHCI_XFER2SC(xfer); | |||
4684 | usbd_status err; | |||
4685 | ||||
4686 | XHCIHIST_FUNC(); XHCIHIST_CALLED(); | 4640 | XHCIHIST_FUNC(); XHCIHIST_CALLED(); | |
4687 | 4641 | |||
4688 | /* Insert last in queue. */ | 4642 | /* Pipe isn't running, so start it first. */ | |
4689 | mutex_enter(&sc->sc_lock); | |||
4690 | err = usb_insert_transfer(xfer); | |||
4691 | mutex_exit(&sc->sc_lock); | |||
4692 | if (err) | |||
4693 | return err; | |||
4694 | ||||
4695 | /* | |||
4696 | * Pipe isn't running (otherwise err would be USBD_INPROG), | |||
4697 | * so start it first. | |||
4698 | */ | |||
4699 | return xhci_device_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 4643 | return xhci_device_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
4700 | } | 4644 | } | |
4701 | 4645 | |||
4702 | static usbd_status | 4646 | static usbd_status | |
4703 | xhci_device_intr_start(struct usbd_xfer *xfer) | 4647 | xhci_device_intr_start(struct usbd_xfer *xfer) | |
4704 | { | 4648 | { | |
4705 | struct xhci_softc * const sc = XHCI_XFER2SC(xfer); | 4649 | struct xhci_softc * const sc = XHCI_XFER2SC(xfer); | |
4706 | struct xhci_slot * const xs = xfer->ux_pipe->up_dev->ud_hcpriv; | 4650 | struct xhci_slot * const xs = xfer->ux_pipe->up_dev->ud_hcpriv; | |
4707 | const u_int dci = xhci_ep_get_dci(xfer->ux_pipe->up_endpoint->ue_edesc); | 4651 | const u_int dci = xhci_ep_get_dci(xfer->ux_pipe->up_endpoint->ue_edesc); | |
4708 | struct xhci_ring * const tr = xs->xs_xr[dci]; | 4652 | struct xhci_ring * const tr = xs->xs_xr[dci]; | |
4709 | struct xhci_xfer * const xx = XHCI_XFER2XXFER(xfer); | 4653 | struct xhci_xfer * const xx = XHCI_XFER2XXFER(xfer); | |
4710 | const uint32_t len = xfer->ux_length; | 4654 | const uint32_t len = xfer->ux_length; | |
4711 | const bool polling = xhci_polling_p(sc); | 4655 | const bool polling = xhci_polling_p(sc); |
--- src/sys/external/bsd/dwc2/dwc2.c 2021/12/21 09:51:22 1.77
+++ src/sys/external/bsd/dwc2/dwc2.c 2022/03/03 06:04:31 1.78
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: dwc2.c,v 1.77 2021/12/21 09:51:22 skrll Exp $ */ | 1 | /* $NetBSD: dwc2.c,v 1.78 2022/03/03 06:04:31 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.77 2021/12/21 09:51:22 skrll Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.78 2022/03/03 06:04:31 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> | |
@@ -604,38 +604,29 @@ dwc2_roothub_ctrl(struct usbd_bus *bus, | @@ -604,38 +604,29 @@ dwc2_roothub_ctrl(struct usbd_bus *bus, | |||
604 | buf, len); | 604 | buf, len); | |
605 | if (err) { | 605 | if (err) { | |
606 | return -1; | 606 | return -1; | |
607 | } | 607 | } | |
608 | totlen = len; | 608 | totlen = len; | |
609 | } | 609 | } | |
610 | 610 | |||
611 | return totlen; | 611 | return totlen; | |
612 | } | 612 | } | |
613 | 613 | |||
614 | Static usbd_status | 614 | Static usbd_status | |
615 | dwc2_root_intr_transfer(struct usbd_xfer *xfer) | 615 | dwc2_root_intr_transfer(struct usbd_xfer *xfer) | |
616 | { | 616 | { | |
617 | struct dwc2_softc *sc = DWC2_XFER2SC(xfer); | |||
618 | usbd_status err; | |||
619 | 617 | |||
620 | DPRINTF("\n"); | 618 | DPRINTF("\n"); | |
621 | 619 | |||
622 | /* Insert last in queue. */ | |||
623 | mutex_enter(&sc->sc_lock); | |||
624 | err = usb_insert_transfer(xfer); | |||
625 | mutex_exit(&sc->sc_lock); | |||
626 | if (err) | |||
627 | return err; | |||
628 | ||||
629 | /* Pipe isn't running, start first */ | 620 | /* Pipe isn't running, start first */ | |
630 | return dwc2_root_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 621 | return dwc2_root_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
631 | } | 622 | } | |
632 | 623 | |||
633 | Static usbd_status | 624 | Static usbd_status | |
634 | dwc2_root_intr_start(struct usbd_xfer *xfer) | 625 | dwc2_root_intr_start(struct usbd_xfer *xfer) | |
635 | { | 626 | { | |
636 | struct dwc2_softc *sc = DWC2_XFER2SC(xfer); | 627 | struct dwc2_softc *sc = DWC2_XFER2SC(xfer); | |
637 | const bool polling = sc->sc_bus.ub_usepolling; | 628 | const bool polling = sc->sc_bus.ub_usepolling; | |
638 | 629 | |||
639 | DPRINTF("\n"); | 630 | DPRINTF("\n"); | |
640 | 631 | |||
641 | if (sc->sc_dying) | 632 | if (sc->sc_dying) | |
@@ -701,38 +692,29 @@ dwc2_root_intr_done(struct usbd_xfer *xf | @@ -701,38 +692,29 @@ dwc2_root_intr_done(struct usbd_xfer *xf | |||
701 | DPRINTF("\n"); | 692 | DPRINTF("\n"); | |
702 | 693 | |||
703 | /* Claim the xfer so it doesn't get completed again. */ | 694 | /* Claim the xfer so it doesn't get completed again. */ | |
704 | KASSERT(sc->sc_intrxfer == xfer); | 695 | KASSERT(sc->sc_intrxfer == xfer); | |
705 | KASSERT(xfer->ux_status != USBD_IN_PROGRESS); | 696 | KASSERT(xfer->ux_status != USBD_IN_PROGRESS); | |
706 | sc->sc_intrxfer = NULL; | 697 | sc->sc_intrxfer = NULL; | |
707 | } | 698 | } | |
708 | 699 | |||
709 | /***********************************************************************/ | 700 | /***********************************************************************/ | |
710 | 701 | |||
711 | Static usbd_status | 702 | Static usbd_status | |
712 | dwc2_device_ctrl_transfer(struct usbd_xfer *xfer) | 703 | dwc2_device_ctrl_transfer(struct usbd_xfer *xfer) | |
713 | { | 704 | { | |
714 | struct dwc2_softc *sc = DWC2_XFER2SC(xfer); | |||
715 | usbd_status err; | |||
716 | 705 | |||
717 | DPRINTF("\n"); | 706 | DPRINTF("\n"); | |
718 | 707 | |||
719 | /* Insert last in queue. */ | |||
720 | mutex_enter(&sc->sc_lock); | |||
721 | err = usb_insert_transfer(xfer); | |||
722 | mutex_exit(&sc->sc_lock); | |||
723 | if (err) | |||
724 | return err; | |||
725 | ||||
726 | /* Pipe isn't running, start first */ | 708 | /* Pipe isn't running, start first */ | |
727 | return dwc2_device_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 709 | return dwc2_device_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
728 | } | 710 | } | |
729 | 711 | |||
730 | Static usbd_status | 712 | Static usbd_status | |
731 | dwc2_device_ctrl_start(struct usbd_xfer *xfer) | 713 | dwc2_device_ctrl_start(struct usbd_xfer *xfer) | |
732 | { | 714 | { | |
733 | struct dwc2_softc *sc = DWC2_XFER2SC(xfer); | 715 | struct dwc2_softc *sc = DWC2_XFER2SC(xfer); | |
734 | usbd_status err; | 716 | usbd_status err; | |
735 | const bool polling = sc->sc_bus.ub_usepolling; | 717 | const bool polling = sc->sc_bus.ub_usepolling; | |
736 | 718 | |||
737 | DPRINTF("\n"); | 719 | DPRINTF("\n"); | |
738 | 720 | |||
@@ -778,32 +760,28 @@ dwc2_device_ctrl_done(struct usbd_xfer * | @@ -778,32 +760,28 @@ dwc2_device_ctrl_done(struct usbd_xfer * | |||
778 | DPRINTF("xfer=%p\n", xfer); | 760 | DPRINTF("xfer=%p\n", xfer); | |
779 | } | 761 | } | |
780 | 762 | |||
781 | /***********************************************************************/ | 763 | /***********************************************************************/ | |
782 | 764 | |||
783 | Static usbd_status | 765 | Static usbd_status | |
784 | dwc2_device_bulk_transfer(struct usbd_xfer *xfer) | 766 | dwc2_device_bulk_transfer(struct usbd_xfer *xfer) | |
785 | { | 767 | { | |
786 | struct dwc2_softc *sc = DWC2_XFER2SC(xfer); | 768 | struct dwc2_softc *sc = DWC2_XFER2SC(xfer); | |
787 | usbd_status err; | 769 | usbd_status err; | |
788 | 770 | |||
789 | DPRINTF("xfer=%p\n", xfer); | 771 | DPRINTF("xfer=%p\n", xfer); | |
790 | 772 | |||
791 | /* Insert last in queue. */ | |||
792 | mutex_enter(&sc->sc_lock); | 773 | mutex_enter(&sc->sc_lock); | |
793 | err = usb_insert_transfer(xfer); | 774 | KASSERT(xfer->ux_status == USBD_NOT_STARTED); | |
794 | ||||
795 | KASSERT(err == USBD_NORMAL_COMPLETION); | |||
796 | ||||
797 | xfer->ux_status = USBD_IN_PROGRESS; | 775 | xfer->ux_status = USBD_IN_PROGRESS; | |
798 | err = dwc2_device_start(xfer); | 776 | err = dwc2_device_start(xfer); | |
799 | mutex_exit(&sc->sc_lock); | 777 | mutex_exit(&sc->sc_lock); | |
800 | 778 | |||
801 | return err; | 779 | return err; | |
802 | } | 780 | } | |
803 | 781 | |||
804 | Static void | 782 | Static void | |
805 | dwc2_device_bulk_abort(struct usbd_xfer *xfer) | 783 | dwc2_device_bulk_abort(struct usbd_xfer *xfer) | |
806 | { | 784 | { | |
807 | struct dwc2_softc *sc __diagused = DWC2_XFER2SC(xfer); | 785 | struct dwc2_softc *sc __diagused = DWC2_XFER2SC(xfer); | |
808 | 786 | |||
809 | KASSERT(mutex_owned(&sc->sc_lock)); | 787 | KASSERT(mutex_owned(&sc->sc_lock)); | |
@@ -823,38 +801,29 @@ dwc2_device_bulk_close(struct usbd_pipe | @@ -823,38 +801,29 @@ dwc2_device_bulk_close(struct usbd_pipe | |||
823 | 801 | |||
824 | Static void | 802 | Static void | |
825 | dwc2_device_bulk_done(struct usbd_xfer *xfer) | 803 | dwc2_device_bulk_done(struct usbd_xfer *xfer) | |
826 | { | 804 | { | |
827 | 805 | |||
828 | DPRINTF("xfer=%p\n", xfer); | 806 | DPRINTF("xfer=%p\n", xfer); | |
829 | } | 807 | } | |
830 | 808 | |||
831 | /***********************************************************************/ | 809 | /***********************************************************************/ | |
832 | 810 | |||
833 | Static usbd_status | 811 | Static usbd_status | |
834 | dwc2_device_intr_transfer(struct usbd_xfer *xfer) | 812 | dwc2_device_intr_transfer(struct usbd_xfer *xfer) | |
835 | { | 813 | { | |
836 | struct dwc2_softc *sc = DWC2_XFER2SC(xfer); | |||
837 | usbd_status err; | |||
838 | 814 | |||
839 | DPRINTF("xfer=%p\n", xfer); | 815 | DPRINTF("xfer=%p\n", xfer); | |
840 | 816 | |||
841 | /* Insert last in queue. */ | |||
842 | mutex_enter(&sc->sc_lock); | |||
843 | err = usb_insert_transfer(xfer); | |||
844 | mutex_exit(&sc->sc_lock); | |||
845 | if (err) | |||
846 | return err; | |||
847 | ||||
848 | /* Pipe isn't running, start first */ | 817 | /* Pipe isn't running, start first */ | |
849 | return dwc2_device_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 818 | return dwc2_device_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
850 | } | 819 | } | |
851 | 820 | |||
852 | Static usbd_status | 821 | Static usbd_status | |
853 | dwc2_device_intr_start(struct usbd_xfer *xfer) | 822 | dwc2_device_intr_start(struct usbd_xfer *xfer) | |
854 | { | 823 | { | |
855 | struct dwc2_pipe *dpipe = DWC2_XFER2DPIPE(xfer) | 824 | struct dwc2_pipe *dpipe = DWC2_XFER2DPIPE(xfer) | |
856 | struct usbd_device *dev = dpipe->pipe.up_dev; | 825 | struct usbd_device *dev = dpipe->pipe.up_dev; | |
857 | struct dwc2_softc *sc = dev->ud_bus->ub_hcpriv; | 826 | struct dwc2_softc *sc = dev->ud_bus->ub_hcpriv; | |
858 | usbd_status err; | 827 | usbd_status err; | |
859 | const bool polling = sc->sc_bus.ub_usepolling; | 828 | const bool polling = sc->sc_bus.ub_usepolling; | |
860 | 829 | |||
@@ -899,32 +868,28 @@ dwc2_device_intr_done(struct usbd_xfer * | @@ -899,32 +868,28 @@ dwc2_device_intr_done(struct usbd_xfer * | |||
899 | DPRINTF("\n"); | 868 | DPRINTF("\n"); | |
900 | } | 869 | } | |
901 | 870 | |||
902 | /***********************************************************************/ | 871 | /***********************************************************************/ | |
903 | 872 | |||
904 | usbd_status | 873 | usbd_status | |
905 | dwc2_device_isoc_transfer(struct usbd_xfer *xfer) | 874 | dwc2_device_isoc_transfer(struct usbd_xfer *xfer) | |
906 | { | 875 | { | |
907 | struct dwc2_softc *sc = DWC2_XFER2SC(xfer); | 876 | struct dwc2_softc *sc = DWC2_XFER2SC(xfer); | |
908 | usbd_status err; | 877 | usbd_status err; | |
909 | 878 | |||
910 | DPRINTF("xfer=%p\n", xfer); | 879 | DPRINTF("xfer=%p\n", xfer); | |
911 | 880 | |||
912 | /* Insert last in queue. */ | |||
913 | mutex_enter(&sc->sc_lock); | 881 | mutex_enter(&sc->sc_lock); | |
914 | err = usb_insert_transfer(xfer); | 882 | KASSERT(xfer->ux_status == USBD_NOT_STARTED); | |
915 | ||||
916 | KASSERT(err == USBD_NORMAL_COMPLETION); | |||
917 | ||||
918 | xfer->ux_status = USBD_IN_PROGRESS; | 883 | xfer->ux_status = USBD_IN_PROGRESS; | |
919 | err = dwc2_device_start(xfer); | 884 | err = dwc2_device_start(xfer); | |
920 | mutex_exit(&sc->sc_lock); | 885 | mutex_exit(&sc->sc_lock); | |
921 | 886 | |||
922 | return err; | 887 | return err; | |
923 | } | 888 | } | |
924 | 889 | |||
925 | void | 890 | void | |
926 | dwc2_device_isoc_abort(struct usbd_xfer *xfer) | 891 | dwc2_device_isoc_abort(struct usbd_xfer *xfer) | |
927 | { | 892 | { | |
928 | struct dwc2_softc *sc __diagused = DWC2_XFER2SC(xfer); | 893 | struct dwc2_softc *sc __diagused = DWC2_XFER2SC(xfer); | |
929 | KASSERT(mutex_owned(&sc->sc_lock)); | 894 | KASSERT(mutex_owned(&sc->sc_lock)); | |
930 | 895 |
--- src/sys/rump/dev/lib/libugenhc/ugenhc.c 2021/08/07 16:19:18 1.29
+++ src/sys/rump/dev/lib/libugenhc/ugenhc.c 2022/03/03 06:04:31 1.30
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ugenhc.c,v 1.29 2021/08/07 16:19:18 thorpej Exp $ */ | 1 | /* $NetBSD: ugenhc.c,v 1.30 2022/03/03 06:04:31 riastradh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. | 4 | * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
@@ -51,27 +51,27 @@ | @@ -51,27 +51,27 @@ | |||
51 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 51 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
52 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 52 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
53 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 53 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
54 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 54 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
55 | * POSSIBILITY OF SUCH DAMAGE. | 55 | * POSSIBILITY OF SUCH DAMAGE. | |
56 | */ | 56 | */ | |
57 | 57 | |||
58 | /* | 58 | /* | |
59 | * This rump driver attaches ugen as a kernel usb host controller. | 59 | * This rump driver attaches ugen as a kernel usb host controller. | |
60 | * It's still somewhat under the hammer .... | 60 | * It's still somewhat under the hammer .... | |
61 | */ | 61 | */ | |
62 | 62 | |||
63 | #include <sys/cdefs.h> | 63 | #include <sys/cdefs.h> | |
64 | __KERNEL_RCSID(0, "$NetBSD: ugenhc.c,v 1.29 2021/08/07 16:19:18 thorpej Exp $"); | 64 | __KERNEL_RCSID(0, "$NetBSD: ugenhc.c,v 1.30 2022/03/03 06:04:31 riastradh Exp $"); | |
65 | 65 | |||
66 | #include <sys/param.h> | 66 | #include <sys/param.h> | |
67 | #include <sys/bus.h> | 67 | #include <sys/bus.h> | |
68 | #include <sys/conf.h> | 68 | #include <sys/conf.h> | |
69 | #include <sys/device.h> | 69 | #include <sys/device.h> | |
70 | #include <sys/fcntl.h> | 70 | #include <sys/fcntl.h> | |
71 | #include <sys/kmem.h> | 71 | #include <sys/kmem.h> | |
72 | #include <sys/kernel.h> | 72 | #include <sys/kernel.h> | |
73 | #include <sys/kthread.h> | 73 | #include <sys/kthread.h> | |
74 | #include <sys/mutex.h> | 74 | #include <sys/mutex.h> | |
75 | 75 | |||
76 | #include <dev/usb/usb.h> | 76 | #include <dev/usb/usb.h> | |
77 | #include <dev/usb/usbdi.h> | 77 | #include <dev/usb/usbdi.h> | |
@@ -391,34 +391,26 @@ rumpusb_device_ctrl_start(struct usbd_xf | @@ -391,34 +391,26 @@ rumpusb_device_ctrl_start(struct usbd_xf | |||
391 | 391 | |||
392 | ret: | 392 | ret: | |
393 | xfer->ux_status = err; | 393 | xfer->ux_status = err; | |
394 | mutex_enter(&sc->sc_lock); | 394 | mutex_enter(&sc->sc_lock); | |
395 | usb_transfer_complete(xfer); | 395 | usb_transfer_complete(xfer); | |
396 | mutex_exit(&sc->sc_lock); | 396 | mutex_exit(&sc->sc_lock); | |
397 | 397 | |||
398 | return USBD_IN_PROGRESS; | 398 | return USBD_IN_PROGRESS; | |
399 | } | 399 | } | |
400 | 400 | |||
401 | static usbd_status | 401 | static usbd_status | |
402 | rumpusb_device_ctrl_transfer(struct usbd_xfer *xfer) | 402 | rumpusb_device_ctrl_transfer(struct usbd_xfer *xfer) | |
403 | { | 403 | { | |
404 | struct ugenhc_softc *sc = UGENHC_XFER2SC(xfer); | |||
405 | usbd_status err; | |||
406 | ||||
407 | mutex_enter(&sc->sc_lock); | |||
408 | err = usb_insert_transfer(xfer); | |||
409 | mutex_exit(&sc->sc_lock); | |||
410 | if (err) | |||
411 | return err; | |||
412 | 404 | |||
413 | return rumpusb_device_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 405 | return rumpusb_device_ctrl_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
414 | } | 406 | } | |
415 | 407 | |||
416 | static void | 408 | static void | |
417 | rumpusb_device_ctrl_abort(struct usbd_xfer *xfer) | 409 | rumpusb_device_ctrl_abort(struct usbd_xfer *xfer) | |
418 | { | 410 | { | |
419 | 411 | |||
420 | } | 412 | } | |
421 | 413 | |||
422 | static void | 414 | static void | |
423 | rumpusb_device_ctrl_close(struct usbd_pipe *pipe) | 415 | rumpusb_device_ctrl_close(struct usbd_pipe *pipe) | |
424 | { | 416 | { | |
@@ -530,34 +522,26 @@ rumpusb_root_intr_start(struct usbd_xfer | @@ -530,34 +522,26 @@ rumpusb_root_intr_start(struct usbd_xfer | |||
530 | error = kthread_create(PRI_NONE, 0, NULL, | 522 | error = kthread_create(PRI_NONE, 0, NULL, | |
531 | rhscintr, sc, &sc->sc_rhintr, "ugenrhi"); | 523 | rhscintr, sc, &sc->sc_rhintr, "ugenrhi"); | |
532 | if (error) | 524 | if (error) | |
533 | xfer->ux_status = USBD_IOERROR; | 525 | xfer->ux_status = USBD_IOERROR; | |
534 | } | 526 | } | |
535 | mutex_exit(&sc->sc_lock); | 527 | mutex_exit(&sc->sc_lock); | |
536 | 528 | |||
537 | return USBD_IN_PROGRESS; | 529 | return USBD_IN_PROGRESS; | |
538 | } | 530 | } | |
539 | 531 | |||
540 | static usbd_status | 532 | static usbd_status | |
541 | rumpusb_root_intr_transfer(struct usbd_xfer *xfer) | 533 | rumpusb_root_intr_transfer(struct usbd_xfer *xfer) | |
542 | { | 534 | { | |
543 | struct ugenhc_softc *sc = UGENHC_XFER2SC(xfer); | |||
544 | usbd_status err; | |||
545 | ||||
546 | mutex_enter(&sc->sc_lock); | |||
547 | err = usb_insert_transfer(xfer); | |||
548 | mutex_exit(&sc->sc_lock); | |||
549 | if (err) | |||
550 | return err; | |||
551 | 535 | |||
552 | return rumpusb_root_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 536 | return rumpusb_root_intr_start(SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
553 | } | 537 | } | |
554 | 538 | |||
555 | static void | 539 | static void | |
556 | rumpusb_root_intr_abort(struct usbd_xfer *xfer) | 540 | rumpusb_root_intr_abort(struct usbd_xfer *xfer) | |
557 | { | 541 | { | |
558 | 542 | |||
559 | } | 543 | } | |
560 | 544 | |||
561 | static void | 545 | static void | |
562 | rumpusb_root_intr_close(struct usbd_pipe *pipe) | 546 | rumpusb_root_intr_close(struct usbd_pipe *pipe) | |
563 | { | 547 | { | |
@@ -699,51 +683,38 @@ doxfer_kth(void *arg) | @@ -699,51 +683,38 @@ doxfer_kth(void *arg) | |||
699 | do { | 683 | do { | |
700 | struct usbd_xfer *xfer = SIMPLEQ_FIRST(&pipe->up_queue); | 684 | struct usbd_xfer *xfer = SIMPLEQ_FIRST(&pipe->up_queue); | |
701 | mutex_exit(&sc->sc_lock); | 685 | mutex_exit(&sc->sc_lock); | |
702 | rumpusb_device_bulk_start(xfer); | 686 | rumpusb_device_bulk_start(xfer); | |
703 | mutex_enter(&sc->sc_lock); | 687 | mutex_enter(&sc->sc_lock); | |
704 | } while (!SIMPLEQ_EMPTY(&pipe->up_queue)); | 688 | } while (!SIMPLEQ_EMPTY(&pipe->up_queue)); | |
705 | mutex_exit(&sc->sc_lock); | 689 | mutex_exit(&sc->sc_lock); | |
706 | kthread_exit(0); | 690 | kthread_exit(0); | |
707 | } | 691 | } | |
708 | 692 | |||
709 | static usbd_status | 693 | static usbd_status | |
710 | rumpusb_device_bulk_transfer(struct usbd_xfer *xfer) | 694 | rumpusb_device_bulk_transfer(struct usbd_xfer *xfer) | |
711 | { | 695 | { | |
712 | struct ugenhc_softc *sc = UGENHC_XFER2SC(xfer); | |||
713 | usbd_status err; | |||
714 | 696 | |||
715 | if (!rump_threads) { | 697 | if (!rump_threads) { | |
716 | /* XXX: lie about supporting async transfers */ | 698 | /* XXX: lie about supporting async transfers */ | |
717 | if ((xfer->ux_flags & USBD_SYNCHRONOUS) == 0) { | 699 | if ((xfer->ux_flags & USBD_SYNCHRONOUS) == 0) { | |
718 | printf("non-threaded rump does not support " | 700 | printf("non-threaded rump does not support " | |
719 | "async transfers.\n"); | 701 | "async transfers.\n"); | |
720 | return USBD_IN_PROGRESS; | 702 | return USBD_IN_PROGRESS; | |
721 | } | 703 | } | |
722 | 704 | |||
723 | mutex_enter(&sc->sc_lock); | |||
724 | err = usb_insert_transfer(xfer); | |||
725 | mutex_exit(&sc->sc_lock); | |||
726 | if (err) | |||
727 | return err; | |||
728 | ||||
729 | return rumpusb_device_bulk_start( | 705 | return rumpusb_device_bulk_start( | |
730 | SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | 706 | SIMPLEQ_FIRST(&xfer->ux_pipe->up_queue)); | |
731 | } else { | 707 | } else { | |
732 | mutex_enter(&sc->sc_lock); | |||
733 | err = usb_insert_transfer(xfer); | |||
734 | mutex_exit(&sc->sc_lock); | |||
735 | if (err) | |||
736 | return err; | |||
737 | kthread_create(PRI_NONE, 0, NULL, doxfer_kth, xfer->ux_pipe, NULL, | 708 | kthread_create(PRI_NONE, 0, NULL, doxfer_kth, xfer->ux_pipe, NULL, | |
738 | "rusbhcxf"); | 709 | "rusbhcxf"); | |
739 | 710 | |||
740 | return USBD_IN_PROGRESS; | 711 | return USBD_IN_PROGRESS; | |
741 | } | 712 | } | |
742 | } | 713 | } | |
743 | 714 | |||
744 | /* wait for transfer to abort. yea, this is cheesy (from a spray can) */ | 715 | /* wait for transfer to abort. yea, this is cheesy (from a spray can) */ | |
745 | static void | 716 | static void | |
746 | rumpusb_device_bulk_abort(struct usbd_xfer *xfer) | 717 | rumpusb_device_bulk_abort(struct usbd_xfer *xfer) | |
747 | { | 718 | { | |
748 | struct rusb_xfer *rx = RUSB(xfer); | 719 | struct rusb_xfer *rx = RUSB(xfer); | |
749 | 720 |