summaryrefslogtreecommitdiff
path: root/sys/dev/usb
AgeCommit message (Collapse)Author
2022-08-03Pull up following revision(s) (requested by riastradh in ticket #1493):martin
sys/dev/usb/ucom.c: revision 1.129 ucom(4): Fix earlier mistake causing pipes not to be closed. In revision 1.123, mrg@ changed what he thought was a double-close, but was actually abort&close (as is appropriate) to just abort (which is not enough -- leaks the pipe). This restores the abort&close. The original `bug' was found by code inspection, whereas this bug was found by asserting in usb_subr.c that no pipes are open on device disconnection after detach; the asserts actually triggered with several ucom(4) devices, and no longer trigger with this change. XXX pullup-9
2022-08-03Pull up following revision(s) (requested by riastradh in ticket #1492):martin
sys/dev/usb/ukbd.c: revision 1.154 ukbd(4): Wait for callouts and blinking to complete in detach. This detach routine (and whole driver) has got a lotta other problems, but let's fix 'em one at a time...
2022-08-01Pull up following revision(s) (requested by rin in ticket #1483):martin
sys/dev/usb/uslsa.c: revision 1.32 PR kern/56946 Baud rate must be in little endian for SLSA_R_SET_BAUDRATE request.
2022-02-16Pull up following revision(s) (requested by jakllsch in ticket #1428):martin
sys/dev/usb/uhidev.c: revision 1.82 Do not explicitly set the HID Report Protocol upon attach, some devices don't like it and should be in Report Protocol after enumeration/reset anyway. May address PR kern/55019.
2022-01-31Pull up following revision(s) (requested by riastradh in ticket #1415):martin
sys/dev/usb/usbnet.c: revision 1.44 (via patch) usbnet: Defer hardware multicast filter updates to USB task. Breaks deadlock: - usbnet_detach holds usbnet lock, awaits kpause in ure_reset - callout holds softclock `lock' (sequential softints, blocks kpause wakeup), awaits softnet_lock in tcp_timer_keep, frag6_fasttimo, &c. - soclose holds softnet_lock, awaits usbnet lock in SIOCDELMULTI This change breaks the deadlock by not passing the SIOCADDMULTI or SIOCDELMULTI ioctl synchronously to the driver, which typically takes the usbnet lock. With this change, the ethernet layer still maintains the list of multicast addresses synchronously, but we defer the driver logic that updates the hardware multicast filter to an asynchronous USB task without softnet_lock held. This doesn't cause exactly the same ioctl to be sent to the driver -- usbnet just sends SIOCDELMULTI with an all-zero struct ifreq, and might drop some ioctls if issued in quick succession. This is OK because none of the drivers actually distinguish between SIOCADDMULTI and SIOCDELMULTI, or examine the argument; the drivers just commit whatever multicast addresses are listed in the ethercom. Other than the different ioctl submitted, there is no change to the ABI or locking scheme of usbnet, so this is safe to pull up to netbsd-9. This means we unfortunately can't guarantee that if a process issues SIOCADDMULTI and then sendto, the multicast filter update will be done by the time of the sendto -- and, more importantly, the packets received in reply to it. But failing to guarantee that is better than deadlocking! Later changes on HEAD will restore the synchronous multicast filter updates with much more extensive ABI changes and API simplifications in usbnet(9). Proposed on tech-net: https://mail-index.netbsd.org/tech-net/2021/12/30/msg008164.html XXX pullup-9
2022-01-18Pull up following revision(s) (requested by martin in ticket #1405):snj
sys/dev/usb/usb_quirks.c: revision 1.102 Ignore new APC UPS devices when matching uhid devices.
2022-01-18regen for ticket 1404snj
2022-01-18Pull up following revision(s) (requested by martin in ticket #1404):snj
sys/dev/usb/usbdevs: revision 1.800 Add a new APC UPS device id.
2022-01-18Pull up following revision(s) (requested by bouyer in ticket #1403):martin
sys/dev/usb/usb_quirks.c: revision 1.103 Add UQ_HID_IGNORE for the Microchip PICkit2 and 3 programmers.
2022-01-18Regen for ticket #1402 (add Microchip PICkit3 programmer)martin
2022-01-18Pull up following revision(s) (requested by bouyer in ticket #1402):martin
sys/dev/usb/usbdevs: revision 1.801 Add the Microchip PICkit3 programmer
2021-12-19Pull up following revision(s) (requested by mrg in ticket #1395):martin
sys/dev/usb/usb_quirks.c: revision 1.101 add two additional cyperpower ups ids for ignore hid.
2021-12-19regen for ticket #1395 (add two more models of cyperpower UPS)martin
2021-12-19Pull up following revision(s) (requested by mrg in ticket #1395):martin
sys/dev/usb/usbdevs: revision 1.799 add two more models of cyperpower UPS.
2021-12-06Pull up following revision(s) (requested by riastradh in ticket #1386):martin
sys/dev/usb/ehci.c: revision 1.287 ehci: Replace bogus polling during suspend by taking bus lock. The system is not at high IPL or limited to a single CPU at this point; it is running essentially normally, just with some devices suspended. Other threads might be trying to touch EHCI registers, which might have bad outcomes while we're suspending stuff. Enabling polling only makes sense if there is a single thread and single CPU running, such as when we enter ddb on crash.
2021-10-23Pull up following revision(s) (requested by jnemeth in ticket #1364):martin
sys/dev/usb/if_urtwn.c: revision 1.101 add Edimax N150 adapter; tested on my PBP
2021-10-23Regen (ticket #1364, urtwn Edimax N150 addition)martin
2021-10-23Pull up following revision(s) (requested by jnemeth in ticket #1364):martin
sys/dev/usb/usbdevs: revision 1.798 add Edimax N150 adapter; tested on my PBP
2021-09-03Pull up following revision(s) (requested by mrg in ticket #1340):martin
sys/dev/usb/ehci.c: revision 1.286 add missing newline and fix conditional for askroot/single user hand over delay message. PR#56366.
2021-06-22Fix pullup #1302 by adapting the changes to this branchmartin
(there was a misunderstanding in the ticket handling)
2021-06-21Pull up following revision(s) (requested by riastradh in ticket #1306):martin
sys/dev/usb/umass.c: revision 1.185 sys/dev/usb/umass_scsipi.c: revision 1.68 umass(4): Use an empty function callback, not null pointer. This stupid bug, with an `XXX Broken!' comment right above, has been preventing NetBSD from suspend/resume with a USB drive plugged in for longer than I want to even think about admitting. *sigh* umass(4): Assert that we got a cb up front. Avoids jump to zero waaaaaaay down the line where we've forgotten why we wanted to jump into oblivion.
2021-06-21Pull up following revision(s) (requested by riastradh in ticket #1302):martin
sys/dev/usb/ualea.c: revision 1.13 ualea(4): Null suspend/resume handler.
2021-06-21Pull up following revision(s) (requested by riastradh in ticket #1301):martin
sys/dev/usb/xhci.c: revision 1.140 sys/dev/usb/xhci.c: revision 1.141 sys/dev/usb/xhci.c: revision 1.143 sys/dev/usb/xhcivar.h: revision 1.18 sys/dev/usb/xhcivar.h: revision 1.19 sys/dev/usb/xhcireg.h: revision 1.19 sys/dev/usb/xhci.c: revision 1.139 xhci(4): Draft suspend/resume. Work almost entirely done and tested by maya@ based on xhci 1.2 spec; tidied up and tweaked by me. Not sure about issuing Stop Endpoint commands or ensuring the Command Ring is in the Stopped or Idle state, but this seems to work as is, so it's already an improvement over what we had before which was no xhci suspend/resume at all. In particular, it's not clear to us: - if we don't have any pending USB activity whether we need to issue the Stop Endpoints or quiesce the command ring; but - if we do have any pending USB activity whether issuing Stop Endpoint is enough or whether we also need to do anything to synchronize with other software logic to quiesce it too. xhci(4): Block commands and issue Stop Endpoint on suspend. xhci: Fix logic in waiting for command queue access. _Either_ an existing command in progress, _or_ an existing suspend in progress that is not done by us, should block us; the logic I wrote previously erroneously blocked only if both conditions happened at the same time. Should fix issue reported by Andrius V in the PR kern/56050 followup discussion. xhci(4): Wait USB_RESUME_WAIT ms, not 20 ms. Better to use the named constant, and although the spec says 20 ms is enough, apparently for some devices it's not.
2021-03-27regen for ticket #1236 (BELKIN F5D7050E fix)martin
2021-03-27Pull up following revision(s) (requested by nia in ticket #1236):martin
sys/dev/usb/usbdevs: revision 1.793 correct usb device id for BELKIN F5D7050E matches freebsd / openbsd (sources of urtw driver), various online sources PR kern/56056
2021-03-22Pull up following revision(s) (requested by nat in ticket #1234),martin
all via patch: sys/dev/usb/if_urtwn.c: revision 1.93 sys/dev/usb/if_urtwn.c: revision 1.95 sys/dev/usb/if_urtwn.c: revision 1.96 if_urtwn.c: Plug a few leaks Can be a cause of PR/55968 Also free assocated mbufs. Opps....Remove irrelavent debug code and don't free_m before IFQ_DEQUEUE(). Identified and reported by Patrick Welche and remedy found by Martin Husemann.
2021-03-07Pull up following revision(s) (requested by isaki in ticket #1225):martin
sys/dev/usb/uaudio.c: revision 1.169 Fix my copy-and-paste bug in rev1.160. This fixes recording sample dropout.
2021-02-04regen (for ticket #1197)martin
2021-02-04Pull up following revision(s) (requested by nia in ticket #1197):martin
sys/dev/usb/if_urtwn.c: revision 1.89,1.90 sys/dev/usb/usbdevs: revision 1.788,1.789 urtwn(4): add TPLINK WN821N to the list of USB device ids reported by kfmut on the unitedbsd forums. add another TPLINK RTL8192EU variant to avoid confusion use TP-Link's names for these variants, matching FreeBSD
2021-02-04Pull up following revision(s) (requested by riastradh in ticket #1196):martin
sys/dev/usb/uhid.c: revision 1.115 sys/dev/usb/uhidev.h: revision 1.21 sys/dev/usb/uhidev.c: revision 1.79 (all via patch) usb: Overhaul uhid(4) and uhidev(4) locking. - uhidev API rules: 1. Call uhidev_open when you want exclusive use of a report id. After it succeeds, you will get interrupts. 2. Call uhidev_close when done with exclusive use of a report id. After it returns, you will no longer get interrupts. => uhidev_open/close do not nest. 3. uhidev_write no longer requires the caller to have exclusive access -- if there is a write in progress, it will block interruptibly until done. This way drivers for individual report ids need not work separately to coordinate their writes. 4. You must uhidev_stop to abort any pending writes on the same report id. (uhidev_stop no longer does anything else -- to ensure no more interrupts, just use uhidev_close.) - Fix uhidev_open/close locking -- uhidev now has an interruptible config lock held only on first open and last close by any report id in the device, to serialize the transition between zero and nonzero numbers of references which requires opening/closing pipes and allocating/freeing buffers. - Make /dev/uhidN selnotify(POLLHUP) when the device is yanked. - Factor uhid device lookup and reference counting and dying detection and so on into uhid_enter/exit. - Nix struct uhid_softc::sc_access_lock. This served no purpose but to confuse me when trying to understand the logic of this beast (and to ensure uhidev_write exclusion, but it was uninterruptible, which is wrong for something that implements userland operations, and didn't actually work because uhidev_write did nothing to coordinate between different report ids). - Fix locking in select/poll. - Use atomics to manage UHID_IMMED to keep it simple. (sc_lock would be fine too but it makes the code more verbose.) - Omit needless UHID_ASLP -- cv_broadcast already has this micro-optimization. With these changes, my Pinebook survives for i in `jot 100`; do echo '###' $i for j in `jot 16`; do usbhidctl -rf /dev/uhid$j >/dev/null & done wait done while plugging and unplugging uhid(4) devices (U2F keys), and the U2F keys still work as U2F keys. ok nick, mrg XXX pullup-9 XXX pullup-8? Note on ABI and pullups: This changes the layout of struct uhidev_softc, but with the sole exception of ucycom(4) -- which at the moment is completely broken and unusable -- the only members that USB HID drivers use are sc_udev and sc_iface, which haven't changed. The layout of struct uhidev, which is allocated by each USB HID driver in its own softc structure, is unchanged.
2020-12-23Pull up following revision(s) (requested by riastradh in ticket #1159):martin
sys/dev/usb/ohci.c: revision 1.314 sys/external/bsd/dwc2/dwc2.c: revision 1.75 sys/dev/usb/ehci.c: revision 1.284 sys/dev/usb/uhci.c: revision 1.305 sys/dev/usb/xhci.c: revision 1.136 usb: Omit bogus assertions about struct usbd_pipe::up_intrxfer. These assertions were only valid for pipes at UE_IN_DIR, UE_INTERRUPT endpoints created with usbd_open_pipe_intr, which uses up_intrxfer to pass the struct usbd_xfer object to usbd_close_pipe to free later. In contrast, for pipes at UE_OUT_DIR, UE_INTERRUPT endpoints, up_intrxfer is never initialized, so the assertion cannot be right. In principle we might even have more than one outstanding interrupt transfer at a time, rendering the point of the assertion moot anyway. Found by interrupting a uhidev write to a u2f device. ok nick
2020-12-12Pull up following revision(s) (requested by skrll in ticket #1150):martin
sys/dev/usb/ohci.c: revision 1.311 sys/dev/usb/ohci.c: revision 1.312 sys/dev/usb/ohcivar.h: revision 1.62 Restructure the abort code for TD based transfers (ctrl, bulk, intr). In PR kern/22646 some TDs can be on the done queue when the abort start and, if this is the case, they need to processed after the WDH interrupt. Instead of waiting for WDH we release TDs that have been touched by the HC and replace them with new ones. Once WDH happens the floating TDs will be returned to the free list. Also addresses the issue seen in PR kern/55835 Thanks to both Andreas Gustafsson and Edgar Fu=C3=9F for testing. Apologi= es to Andreas Gustafsson for not committing this to HEAD for 4y6m.w Remove leading space that crept in in the last change
2020-12-12Pull up following revision(s) (requested by mrg in ticket #1147):martin
sys/dev/usb/ucom.c: revision 1.128 properly wait for refcounts to drain. fixes panic at detach that jmnceill saw. XXX: pullup-[89].
2020-10-15Pull up following revision(s) (requested by jmcneill in ticket #1112):martin
sys/dev/usb/ums.c: revision 1.94 sys/dev/usb/ums.c: revision 1.99 Initialize tcpalib for ums devices. In r1.3 of src/sys/dev/hid/hidms.c, tpcalib is used for any hidms device reporting absolute coordinates. So ums devices reporting absolute coordinates also need to initialize tcpalib - do it for all ums devices. An uninitialized tcpalib stops a mouse with absolute coordinates from "moving". For absolute pointers, report min/max X and Y values using WSMOUSEIO_[SG]CALIBCOORDS ioctl.
2020-08-28Pull up following revision(s) (requested by riastradh in ticket #1067):martin
sys/dev/usb/usbnet.c: revision 1.39 sys/dev/usb/if_atu.c: revision 1.73 usbnet: Reject buflen>MCLBYTES in usbnet_newbuf. atu(4): Reject packets larger than MCLBYTES.
2020-08-27Pull up following revision(s) (requested by riastradh in ticket #1065):martin
sys/dev/usb/usbdevices.config: revision 1.41 (patch) sys/dev/usb/ugen.c: revision 1.152 sys/dev/usb/ugen.c: revision 1.153 sys/dev/usb/ugen.c: revision 1.154 sys/dev/usb/ugen.c: revision 1.155 (patch) sys/dev/usb/ugen.c: revision 1.156 sys/dev/usb/ugen.c: revision 1.157 Remove UGEN_ASLP microoptimization. cv_signal already has this microoptimization. While here, make the lock cover the relevant things we're issuing cv_signal about -- progress toward real MP-safety. Hold the lock over access to the data structures it covers. Still not MPSAFE, but progress. Convert DIAGNOSTIC prints to KASSERTs. Share unit numbering for ugen and ugenif. This way putting ugenif in kernel config actually works to wire it to the /dev/ugenN.MM device nodes in userland. Not a fully fleshed out solution to the ugen problem -- there's no way for a userland driver to kick out a kernel driver and take over, but this will let us, e.g., use uhidev(4) for Yubikey OTP/U2F/FIDO2 but ugen(4), with pcscd(8), for Yubikey CCID. Fix various MP-safety issues while here (still not MPSAFE, but more progress). Expose Yubikey CCID interface to userland via ugenif. Fix sloppy mistakes in previous. 1. Give the offset of the rbnode, not some other random members to overwrite with garbage. 2. Don't try to unlock a mutex at NULL. 3. Make sure all paths out after ugenif_acquire go via ugenif_release. Fix ugen detach after partial attach. While here, register null pmf handler even for partially attached devices so they don't needlessly interfere with suspend.
2020-07-18Pull up following revision(s) (requested by mrg in ticket #1020):martin
sys/dev/usb/usbdi.c: revision 1.203 for both usbd_transfer() and usbd_ar_pipe() be sure to reset the xfer ux_state to XFER_BUSY when removing from the queue. seems to fix an occasional panic i was seeing on pinebook and pinebookpro lately with axen(4). from riastradh@. XXX: pullup-9.
2020-07-15Pull up following revision(s) (requested by riastradh in ticket #1010):martin
sys/dev/usb/uhid.c: revision 1.112 sys/dev/usb/uhid.c: revision 1.113 sys/dev/hid/hid.h: revision 1.4 sys/dev/hid/hid.h: revision 1.5 sys/dev/usb/usbhid.h: revision 1.19 Add fido constants, and turn hid "raw" mode for fido devices. Add ioctls to get and set raw mode. Use unsigned to avoid undefined behavior. Found by kUBSan.
2020-07-15Pull up following revision(s) (requested by riastradh in ticket #1008):martin
sys/dev/usb/ualea.c: revision 1.10 Turn XXX comment into KASSERT.
2020-07-13Pull up following revision(s) (requested by simonb in ticket #1003):martin
sys/dev/usb/ualea.c: revision 1.12 Set up the USB xfer for every transfer, not just once in the attach function. Caught by DIAGNOSTIC on a similar driver. Thanks to mrg@ for USB xfer clue and martin@ for testing.
2020-06-11Pull up following revision (requested by martin in ticket #958):jdc
src/sys/dev/usb/if_run.c: revision 1.41 Better bounds checking for oversized packets, to avoid kernel memory corruption. Pointed out by Ilja Van Sprundel.
2020-06-11Pull up following revision (requested by martin in ticket #957):jdc
src/sys/dev/usb/if_otus.c: revision 1.45 (via patch) Stricter bounds check for some packet length we get from the usb chip, to make sure we do not corrupt kernel memory. Pointed out by Ilja Van Sprundel.
2020-06-07Pull up following revision(s) (requested by skrll in ticket #948):martin
sys/dev/usb/ugensa.c: revision 1.42 sys/dev/usb/u3g.c: revision 1.41 Remove duplicated USB_VENDOR_SIERRA USB_PRODUCT_SIERRA_USB305 entry PR kern/55329 Replace calls to usbd_device2interface_handle in u3g_match() and u3g_attach() with the interface already passed in uiaa->uiaa_iface and store the interface in sc->sc_iface for later use by u3g_open()/ Also skip Direct IP interfaces in u3g_match() to avoid potential side effects. PR kern/55330
2020-05-31Pull up following revision(s) (requested by skrll in ticket #934):martin
sys/dev/usb/usb.c: revision 1.187 Don't allow open of /dev/usb if there are no attached busses. PR kern/55303 mutex_vector_enter,512: uninitialized lock
2020-05-25Pull up following revision(s) (requested by jakllsch in ticket #921):martin
sys/dev/usb/xhci.c: revision 1.129 xhci(4): only usbd_xfer_trycomplete() if certain to usb_transfer_complete() Previously we'd cancel the timeout after the data stage of control xfers, and then hope that the status stage would eventually interrupt.
2020-05-09Pull up following revision(s) (requested by skrll in ticket #896):martin
sys/dev/usb/if_cdce.c: revision 1.71 Search the descriptors of the appropriate interface to ensure correct match. PR kern/55240 cdce(4) error "no data interface" when ECM USB IF are preceded by ACM USB IF
2020-04-29Regen for ticket #873martin
2020-04-29Pull up following revision(s) (requested by nia in ticket #873):martin
sys/dev/usb/usbdevs: revision 1.782 usbdevs: more Intel Integrated Rate Matching Hub IDs
2020-04-24Regen for ticket #848 (DWA-121 in urtwn)martin
2020-04-24Pull up following revision(s) (requested by maya in ticket #848):martin
sys/dev/usb/usbdevs: revision 1.778 sys/dev/usb/if_urtwn.c: revision 1.85 Add D-Link DWA-121 rev B1 to list of supported devices From Miguel Landaeta in kern/55140