| #
b258282e
|
| 02-Jan-2026 |
Warner Losh <imp@FreeBSD.org> |
kshim/usb: Prefer memset to bzero
Replace bzero with the equivalent memset(x,0,x) since the latter is available in the kshim environment and we have a soft goal of migrating to standard interfaces w
kshim/usb: Prefer memset to bzero
Replace bzero with the equivalent memset(x,0,x) since the latter is available in the kshim environment and we have a soft goal of migrating to standard interfaces when there's a reason...
Sponsored by: Netflix
show more ...
|
| #
37e3b664
|
| 17-Aug-2025 |
Vladimir Kondratyev <wulf@FreeBSD.org> |
usbhid(4): Implement USB_GET_DEVICEINFO ioctl
With factoring out of supporting code from ugen(4) driver. The ioctl is used in FIDO/U2F security key drivers to get USB product and manufacturer string
usbhid(4): Implement USB_GET_DEVICEINFO ioctl
With factoring out of supporting code from ugen(4) driver. The ioctl is used in FIDO/U2F security key drivers to get USB product and manufacturer strings.
PR: 264843 Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D51609
show more ...
|
| #
c2794499
|
| 06-Jun-2025 |
Jan Biedermann <jan@isomorfeus.com> |
usb: Don't call usb_msc_auto_quirk for UQ_MSC_IGNORE devices
usb_msc_auto_quirk() potentially crashes usb devices with a hidden storage (see bug 287333). These devices may still operate normally if
usb: Don't call usb_msc_auto_quirk for UQ_MSC_IGNORE devices
usb_msc_auto_quirk() potentially crashes usb devices with a hidden storage (see bug 287333). These devices may still operate normally if usb_msc_auto_quirk() would not be called all and the hidden storage is ignored. This patch makes sure, that usb_msc_auto_quirk() is not called when the UQ_MSC_IGNORE quirk is set for a device. It shouldn't be called anyway if the hidden storage supposed to be ignored. This gives users a chance to get their devices working by using
'usbconfig add_dev_quirk_vplh <vid> <pid> <lo_rev> <hi_rev> UQ_MSC_IGNORE'.
Reviewed by: imp MFC After: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/1716 Closes: https://github.com/freebsd/freebsd-src/pull/1716
show more ...
|
| #
d41600e5
|
| 07-May-2025 |
Warner Losh <imp@FreeBSD.org> |
usb: Make autoquirk code optional and opt out
There are significant problems with the current autoquirk code. This results in quite a bit of bogus over-quirking.
Most commands don't do the proper "
usb: Make autoquirk code optional and opt out
There are significant problems with the current autoquirk code. This results in quite a bit of bogus over-quirking.
Most commands don't do the proper "sense" dance to get the scsi sense codes to see if the failures are interesting or not. A number of 'sleeps' are used to try to get around this, but they are racy. Rather than fix these, use better hueristics just introduced to catch SYNCHRONIZE CACHE problems, etc.
The test for getting max lun number was bogus. It would set this quirk both on errors and when 0 was returned. It appears to be an attempt to filter our REPORT LUNS error messages that are actually benign (we ignore the errors properly). These errors are also only filtered sometimes, so the test is unreliable. In addition, it's doing exactly the same test that the umass driver is doing and recovering in the same way. There's no value add here.
The TEST UNIT READY almost always fails because the drive is becoming ready. The SENSE is usually UNIT ATTENTION 28/0 "Drive went from not ready to ready" which is a normal condition.
The crazy looping to get INQUIRY data is odd. It shouldn't be needed and rarely actually fails (I've not seen any, despite using this code on some really sketchy drives). It should set a NO_INQUIRY quirk if it fails, but instead sets a whole bunch of other, mostly unrelated quirks if it fails.
The INQUIRY code also doesn't recognie RBC devices as well as DIRECT devices. This means it fails on some older generations of cameras that could actually benefit from this code.
The SYNCHRONIZE CACHE test is flawed. It will do the same failed test over and over again in the event the command succeeds. There are better ways to detect probelms.
The START STOP test is useless. It doesn't really help on any of the devices I've tested on. It appears to be another result of the failure to properly obtain the SENSE code and do appropriate things with it.
The PREVENT ALLOW test is useless. It is overwhelmingly used to prevent an error message later. However, after it was added the error message was changed to be informative and not scary. We properly probe this at runtime on all the devices I tested on.
At the end of the tests, we try to clear the SENSE errors, but do so imperfectly. Only one is cleared and we use INQUIRY rather than the better TEST UNIT READY.
Attempted re-write to fix this caused additional problems as the reset code was not at all robust (the same sequnce in umass / CAM worked when we disabled this code).
In addition, the over-quirking and hair-triggered declaration that SYNCHRONIE CACHE is bad would mean that some working drives that have cache wouldn't flush the cache when WCE=1, leading to corruption. Thankfully, nearly all (but not all) the USB sticks I have default to WCE=0. One, however, did default to WCE=1 and some allow setting it (despite the fact this is a bad idea on removeable devices). However, for real disks attached via USB could be tripped up over this.
When we do reset, some small subset of drives are now failing to probe. There are reports on the FreeBSD forums that at least one ebook reader no longer works. A different ebook reads is affected as well (one of my long-time friends has htis). in my collection, one USB memory stick, one SD card reader and one USB to generic PATA adapter no longer work. All of them are pretty obscure (you could literally say they were found in my junk drawer), but are troubling. These problems appear to disappear if we stop doing the auto-quirk code.
For all these reasons, I'm turning this off and will likely remove it entirely in the future once the alternative SYNC CACHE code has provent itself.
Differential Revision: https://reviews.freebsd.org/D49477 Sponsored by: Netflix
show more ...
|
| #
114080d1
|
| 04-Oct-2024 |
Ed Maste <emaste@FreeBSD.org> |
usb: fix loop in usb_config_parse
By inspection, index increment was missing.
PR: 281843 Reported by: Matt Jacobson Reviewed by: bz, markj Fixes: e4611d26265f ("usb(4): Call optional endpoint_unin
usb: fix loop in usb_config_parse
By inspection, index increment was missing.
PR: 281843 Reported by: Matt Jacobson Reviewed by: bz, markj Fixes: e4611d26265f ("usb(4): Call optional endpoint_uninit() when changing configuration or alternate setting.") Sponsored by: The FreeBSD Foundation
show more ...
|
| #
5b8f97d8
|
| 04-Sep-2024 |
Bjoern A. Zeeb <bz@FreeBSD.org> |
usb: change LIST to SLIST to avoid LinuxKPI conflicts
In order to better integrate modern LinuxKPI USB this tries to reduce a contention point of "LIST". Given there is no need to use a LIST here c
usb: change LIST to SLIST to avoid LinuxKPI conflicts
In order to better integrate modern LinuxKPI USB this tries to reduce a contention point of "LIST". Given there is no need to use a LIST here change it to SLIST to avoid conflicts. It is a workaround which does not solve the actual problem (overlapping namespaces) but it helps us a lot for now.
Sponsored by: The FreeBSD Foundation X-MFC? unclear Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D46534
show more ...
|
| #
5b56413d
|
| 25-Jul-2024 |
Warner Losh <imp@FreeBSD.org> |
newbus: globally replace device_add_child(..., -1) with DEVICE_UNIT_ANY
Sponsored by: Netflix
|
| #
604511f8
|
| 20-Apr-2024 |
Gordon Bergling <gbe@FreeBSD.org> |
usb(4): Remove a double word in a source code comment
- s/of of/of/
MFC after: 3 days
|
| #
71625ec9
|
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
|
| #
4d846d26
|
| 10-May-2023 |
Warner Losh <imp@FreeBSD.org> |
spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of
spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause.
Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
show more ...
|
| #
9b077d72
|
| 31-Mar-2023 |
Hans Petter Selasky <hselasky@FreeBSD.org> |
usb(4): Separate the fast path and the slow path to avoid races and use-after-free for the USB FS interface.
Bad behaving user-space USB applicatoins may crash the kernel by issuing USB FS related i
usb(4): Separate the fast path and the slow path to avoid races and use-after-free for the USB FS interface.
Bad behaving user-space USB applicatoins may crash the kernel by issuing USB FS related ioctl(2)'s out of their expected order. By default the USB FS ioctl(2) interface is only available to the administrator, root, and driver applications like webcamd(8) needs to be hijacked in order for this to happen.
The issue is the fast-path code does not always see updates made by the slow-path code, and may then work on freed memory.
This is easily fixed by using an EPOCH(9) type of synchronization mechanism. A SX(9) lock will be used as a substitute for EPOCH(9), due to the need for sleepability. In addition most calls going into the fast-path originate from a single user-space process and the need for multi-thread performance is not present.
Differential Revision: https://reviews.freebsd.org/D39373 Reviewed by: markj@ Reported by: C Turt <ecturt@gmail.com> admbugs: 994 MFC after: 1 week Sponsored by: NVIDIA Networking
show more ...
|
| #
e4611d26
|
| 15-Dec-2022 |
Hans Petter Selasky <hselasky@FreeBSD.org> |
usb(4): Call optional endpoint_uninit() when changing configuration or alternate setting.
MFC after: 1 week Sponsored by: NVIDIA Networking
|
| #
3ee94386
|
| 26-Apr-2022 |
Kornel Duleba <mindal@semihalf.com> |
usb: Respect NO_INQUIRY quirk during device enumeration
Both usb_iface_is_cdrom and usb_msc_auto_quirk functions use SCSI INQUIRY command to probe various properties of usb mass storage devices. The
usb: Respect NO_INQUIRY quirk during device enumeration
Both usb_iface_is_cdrom and usb_msc_auto_quirk functions use SCSI INQUIRY command to probe various properties of usb mass storage devices. The problem here is that some very broken devices don't like this command. Check if UQ_MSC_NO_INQUIRY quirk is set and skip cdrom and quirk autodetection in that case.
Sponsored by: Stormshield Obtained from: Semihalf Reviewed by: hps, wma Differential Revision: https://reviews.freebsd.org/D35075
show more ...
|
| #
7520b888
|
| 21-Feb-2022 |
Hans Petter Selasky <hselasky@FreeBSD.org> |
usb(4): Automagically apply all quirks for USB mass storage devices.
Currently there are five quirks the USB stack tries to automagically detect: - UQ_MSC_NO_PREVENT_ALLOW - UQ_MSC_NO_SYNC_CACHE - U
usb(4): Automagically apply all quirks for USB mass storage devices.
Currently there are five quirks the USB stack tries to automagically detect: - UQ_MSC_NO_PREVENT_ALLOW - UQ_MSC_NO_SYNC_CACHE - UQ_MSC_NO_TEST_UNIT_READY - UQ_MSC_NO_GETMAXLUN - UQ_MSC_NO_START_STOP
If any of the quirks above are set, no further quirks will be probed.
If any of the USB mass storage tests fail, the USB device is re-enumerated as a last resort to clear any error states from the device. Then the USB stack will try to probe and attach the umass<N> device passing the detected quirks.
While at it give more details in dmesg about what is going on.
Tested by: several Submitted by: Idwer Vollering <vidwer_fbsdbugs@gmail.com> Differential Revision: https://reviews.freebsd.org/D30919 MFC after: 1 week Sponsored by: NVIDIA Networking
show more ...
|
| #
c6df6f53
|
| 10-Dec-2021 |
Warner Losh <imp@FreeBSD.org> |
Create wrapper for Giant taken for newbus
Create a wrapper for newbus to take giant and for busses to take it too. bus_topo_lock() should be called before interacting with newbus routines and unlock
Create wrapper for Giant taken for newbus
Create a wrapper for newbus to take giant and for busses to take it too. bus_topo_lock() should be called before interacting with newbus routines and unlocked with bus_topo_unlock(). If you need the topology lock for some reason, bus_topo_mtx() will provide that.
Sponsored by: Netflix Reviewed by: mav Differential Revision: https://reviews.freebsd.org/D31831
show more ...
|
| #
b1f99f9c
|
| 15-Dec-2020 |
Hans Petter Selasky <hselasky@FreeBSD.org> |
Improve handling of alternate settings in the USB stack.
Move initialization of num_altsetting under USB_CFG_INIT, else there will be a page fault when enumerating USB devices.
PR: 251856 MFC afte
Improve handling of alternate settings in the USB stack.
Move initialization of num_altsetting under USB_CFG_INIT, else there will be a page fault when enumerating USB devices.
PR: 251856 MFC after: 1 week Submitted by: Ma, Horse <Shichun.Ma@dell.com> Sponsored by: Mellanox Technologies // NVIDIA Networking
show more ...
|
| #
b8b3f4fd
|
| 15-Dec-2020 |
Hans Petter Selasky <hselasky@FreeBSD.org> |
Improve handling of alternate settings in the USB stack.
Allow setting the alternate interface number to fail when there is only one alternate setting present, to comply with the USB specification.
Improve handling of alternate settings in the USB stack.
Allow setting the alternate interface number to fail when there is only one alternate setting present, to comply with the USB specification.
Refactor how iface->num_altsetting is computed.
Bump the __FreeBSD_version due to change of core USB structure.
PR: 251856 MFC after: 1 week Submitted by: Ma, Horse <Shichun.Ma@dell.com> Sponsored by: Mellanox Technologies // NVIDIA Networking
show more ...
|
| #
9dd3156e
|
| 01-Sep-2020 |
Mateusz Guzik <mjg@FreeBSD.org> |
usb: clean up empty lines in .c and .h files
|
| #
c7aa572c
|
| 31-Jul-2020 |
Glen Barber <gjb@FreeBSD.org> |
MFH
Sponsored by: Rubicon Communications, LLC (netgate.com)
|
| #
94140f47
|
| 22-Jul-2020 |
Mark Johnston <markj@FreeBSD.org> |
usb(4): Stop checking for failures from malloc(M_WAITOK).
Handle the fact that parts of usb(4) can be compiled into the boot loader, where M_WAITOK does not guarantee a successful allocation.
PR:
usb(4): Stop checking for failures from malloc(M_WAITOK).
Handle the fact that parts of usb(4) can be compiled into the boot loader, where M_WAITOK does not guarantee a successful allocation.
PR: 240545 Submitted by: Andrew Reiter <arr@watson.org> (original version) Reviewed by: hselasky MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25706
show more ...
|
| #
5e055201
|
| 28-May-2020 |
Hans Petter Selasky <hselasky@FreeBSD.org> |
Don't allow USB device drivers to parent own interface. It will prevent proper USB device detach.
MFC after: 3 days Sponsored by: Mellanox Technologies
|
| #
f54ab96d
|
| 11-May-2020 |
Hans Petter Selasky <hselasky@FreeBSD.org> |
Refresh the USB device strings when a USB device is re-enumerated.
Submitted by: Horse Ma <Shichun.Ma@dell.com> MFC after: 1 week Sponsored by: Mellanox Technologies
|
| #
0269ae4c
|
| 06-Jun-2019 |
Alan Somers <asomers@FreeBSD.org> |
MFHead @348740
Sponsored by: The FreeBSD Foundation
|
| #
e2e050c8
|
| 20-May-2019 |
Conrad Meyer <cem@FreeBSD.org> |
Extract eventfilter declarations to sys/_eventfilter.h
This allows replacing "sys/eventfilter.h" includes with "sys/_eventfilter.h" in other header files (e.g., sys/{bus,conf,cpu}.h) and reduces hea
Extract eventfilter declarations to sys/_eventfilter.h
This allows replacing "sys/eventfilter.h" includes with "sys/_eventfilter.h" in other header files (e.g., sys/{bus,conf,cpu}.h) and reduces header pollution substantially.
EVENTHANDLER_DECLARE and EVENTHANDLER_LIST_DECLAREs were moved out of .c files into appropriate headers (e.g., sys/proc.h, powernv/opal.h).
As a side effect of reduced header pollution, many .c files and headers no longer contain needed definitions. The remainder of the patch addresses adding appropriate includes to fix those files.
LOCK_DEBUG and LOCK_FILE_LINE_ARG are moved to sys/_lock.h, as required by sys/mutex.h since r326106 (but silently protected by header pollution prior to this change).
No functional change (intended). Of course, any out of tree modules that relied on header pollution for sys/eventhandler.h, sys/lock.h, or sys/mutex.h inclusion need to be fixed. __FreeBSD_version has been bumped.
show more ...
|
| #
b258282e
|
| 02-Jan-2026 |
Warner Losh <imp@FreeBSD.org> |
kshim/usb: Prefer memset to bzero
Replace bzero with the equivalent memset(x,0,x) since the latter is available in the kshim environment and we have a soft goal of migrating to standard interfaces w
kshim/usb: Prefer memset to bzero
Replace bzero with the equivalent memset(x,0,x) since the latter is available in the kshim environment and we have a soft goal of migrating to standard interfaces when there's a reason...
Sponsored by: Netflix
show more ...
|