History log of /freebsd-current/sys/dev/usb/usb_device.c
Revision Date Author Comments
# 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 BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 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 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


# 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 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


# 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
- 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


# c6df6f53 09-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 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


# 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 after: 1 week
Submitted by: Ma, Horse <Shichun.Ma@dell.com>
Sponsored by: Mellanox Technologies // NVIDIA Networking


# b8b3f4fd 14-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.

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


# 9dd3156e 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

usb: clean up empty lines in .c and .h files


# 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: 240545
Submitted by: Andrew Reiter <arr@watson.org> (original version)
Reviewed by: hselasky
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25706


# 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


# e2e050c8 19-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 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.


# c140287a 28-May-2018 Edward Tomasz Napierala <trasz@FreeBSD.org>

Change the default USB template from the current 0 to -1. The reason
is that current one (mass storage device) doesn't work as it is - it
needs to be set to 0 after the LUN is configured, which is what the
cfumass rc script does. In other words: the current default does not
work, and to actually make it work it had to be set to -1 in
/boot/loader.conf.

Reviewed by: hselasky@
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation


# f66c3cfc 30-Jan-2018 Edward Tomasz Napierala <trasz@FreeBSD.org>

Make the handler routine for the hw.usb.template sysctl trigger the USB
host to reprobe the bus by switching the USB pull up resistors off and
back on. In other words - when FreeBSD is configured as a USB device,
changing the sysctl will be immediately noticed by the machine it's
connected to.

Reviewed by: hselasky@
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation


# 718cf2cc 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/dev: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.


# 88f9a4ff 25-Oct-2016 Edward Tomasz Napierala <trasz@FreeBSD.org>

Make the USB attach strings in dmesg include product name.

Note to self: MFC this to 9 and 8.

Reviewed by: hselasky@, imp@
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D8259


# d3bf5efc 17-Oct-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix device delete child function.

When detaching device trees parent devices must be detached prior to
detaching its children. This is because parent devices can have
pointers to the child devices in their softcs which are not
invalidated by device_delete_child(). This can cause use after free
issues and panic().

Device drivers implementing trees, must ensure its detach function
detaches or deletes all its children before returning.

While at it remove now redundant device_detach() calls before
device_delete_child() and device_delete_children(), mostly in
the USB controller drivers.

Tested by: Jan Henrik Sylvester <me@janh.de>
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D8070
MFC after: 2 weeks


# 0eb8d462 13-Sep-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Improve USB polling mode by not locking any mutexes, asserting any
mutexes or using any callouts when active.

Trying to lock a mutex when KDB is active or the scheduler is stopped
can result in infinite wait loops. The same goes for calling callout
related functions which in turn lock mutexes.

If the USB controller at which a USB keyboard is connected is idle
when KDB is entered, polling the USB keyboard via USB will always
succeed. Else polling may fail depending on which state the USB
subsystem and USB interrupt handler is in. This is unavoidable unless
KDB can wait for USB interrupt threads to complete before stalling the
CPU(s).

Tested by: Bruce Evans <bde@freebsd.org>
MFC after: 4 weeks


# 64cb5e2a 05-Sep-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Resolve deadlock between device_detach() and usbd_do_request_flags()
by reviving the SX control request lock and refining which lock
protects the common scratch area in "struct usb_device".

The SX control request lock was removed by r246759 because it caused a
lock order reversal with the USB enumeration lock inside
usbd_transfer_setup() as a function of r246616. It was thought that
reducing the number of locks would resolve the LOR, but because some
USB device drivers use usbd_do_request_flags() inside callback
functions, like in taskqueues, a deadlock may occur when these are
drained from device_detach(). By restoring the SX control request
lock usbd_do_request_flags() is allowed to complete its execution
when a USB device driver is detaching. By using the SX control request
lock to protect the scratch area, the LOR introduced by r246616 is
also resolved.

Bump the FreeBSD version while at it to force recompilation of all USB
kernel modules.

Found by: avos@
MFC after: 1 week


# 6be75992 29-Jul-2016 Edward Tomasz Napierala <trasz@FreeBSD.org>

Improve error message.

MFC after: 1 month


# 10aab8b6 25-May-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Check for signals when locking the USB enumeration thread from
userspace, so that USB applications can be killed if an enumeration
thread should be stuck for various reasons.

MFC after: 1 week


# 869df733 04-May-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Extend the UQ_NO_STRINGS quirk to also cover the USB language string
descriptor. This fixes enumeration of some older Samsung Galaxy S3
phones.

MFC after: 1 week


# 20733245 02-May-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

dev/usb: minor spelling fixes in comments.

No functional change.

Reviewed by: hselasky


# ac3490fd 14-Jan-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Use the recently added "make_dev_s()" function to solve old race setting the
si_drv1 field in "struct cdev" when creating new character devices.


# 8d59ecb2 29-Oct-2015 Hans Petter Selasky <hselasky@FreeBSD.org>

Finish process of moving the LinuxKPI module into the default kernel build.

- Move all files related to the LinuxKPI into sys/compat/linuxkpi and
its subfolders.
- Update sys/conf/files and some Makefiles to use new file locations.
- Added description of COMPAT_LINUXKPI to sys/conf/NOTES which in turn
adds the LinuxKPI to all LINT builds.
- The LinuxKPI can be added to the kernel by setting the
COMPAT_LINUXKPI option. The OFED kernel option no longer builds the
LinuxKPI into the kernel. This was done to keep the build rules for
the LinuxKPI in sys/conf/files simple.
- Extend the LinuxKPI module to include support for USB by moving the
Linux USB compat from usb.ko to linuxkpi.ko.
- Bump the FreeBSD_version.
- A universe kernel build has been done.

Reviewed by: np @ (cxgb and cxgbe related changes only)
Sponsored by: Mellanox Technologies


# 43ea03d7 13-Aug-2015 Hans Petter Selasky <hselasky@FreeBSD.org>

Improve the realtime properties of USB transfers for embedded systems
like RPI-B and RPI-2.

Description of problem:
USB transfers can process data in their callbacks sometimes causing
unacceptable latency for other USB transfers. Separate BULK completion
callbacks from CONTROL, INTERRUPT and ISOCHRONOUS callbacks, and give
BULK completion callbacks lesser execution priority than the
others. This way USB audio won't be interfered by heavy USB ethernet
usage for example.

Further serve USB transfer completion in a round robin fashion,
instead of only serving the most CPU hungry. This has been done by
adding a third flag to USB transfer queue structure which keeps track
of looping callbacks. The "command" callback function then decides
what to do when looping.

MFC after: 2 weeks


# 415bcd89 06-May-2015 Hans Petter Selasky <hselasky@FreeBSD.org>

Add support for DYMO LabelWriter PnP.

MFC after: 2 weeks


# 07dbde67 14-Jan-2015 Hans Petter Selasky <hselasky@FreeBSD.org>

Add a kernel function to delist our kernel character devices, so that
the device name can be re-used right away in case we are destroying
the character devices in the background.

MFC after: 4 days
Reported by: dchagin@


# b78e84d1 13-Jan-2015 Hans Petter Selasky <hselasky@FreeBSD.org>

Resolve a special case deadlock: When two or more threads are
simultaneously detaching kernel drivers on the same USB device we can
get stuck in the "usb_wait_pending_ref_locked()" function because the
conditions needed for allowing detach are not met. The "destroy_dev()"
function waits for all system calls involving the given character
device to return. Character device system calls may lock the USB
enumeration lock, which is also held when "destroy_dev()" is
called. This can sometimes lead to a deadlock not noticed by
WITNESS. The current solution is to ensure the calling thread is the
only one holding the USB enumeration lock and prevent other threads
from getting refs while a USB device detach is ongoing. This turned
out not to be sufficient. To solve this deadlock we could use
"destroy_dev_sched()" to schedule the device destruction in the
background, but then we don't know when it is safe to free() the
private data of the character device. Instead a callback function is
executed by the USB explore process to kill off any leftover USB
character devices synchronously after the USB device explore code is
finished and the USB enumeration lock is no longer locked. This makes
porting easier and also ensures us that character devices must
eventually go away after a USB device detach.

While at it ensure that "flag_iserror" is only written when "priv_mtx"
is locked, which is protecting it.

MFC after: 5 days


# c3ccd2bf 05-Aug-2014 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix for deadlock in USB device side mode.

MFC after: 3 days


# af3b2549 27-Jun-2014 Hans Petter Selasky <hselasky@FreeBSD.org>

Pull in r267961 and r267973 again. Fix for issues reported will follow.


# 37a107a4 27-Jun-2014 Glen Barber <gjb@FreeBSD.org>

Revert r267961, r267973:

These changes prevent sysctl(8) from returning proper output,
such as:

1) no output from sysctl(8)
2) erroneously returning ENOMEM with tools like truss(1)
or uname(1)
truss: can not get etype: Cannot allocate memory


# 3da1cf1e 27-Jun-2014 Hans Petter Selasky <hselasky@FreeBSD.org>

Extend the meaning of the CTLFLAG_TUN flag to automatically check if
there is an environment variable which shall initialize the SYSCTL
during early boot. This works for all SYSCTL types both statically and
dynamically created ones, except for the SYSCTL NODE type and SYSCTLs
which belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added to
be used in the case a tunable sysctl has a custom initialisation
function allowing the sysctl to still be marked as a tunable. The
kernel SYSCTL API is mostly the same, with a few exceptions for some
special operations like iterating childrens of a static/extern SYSCTL
node. This operation should probably be made into a factored out
common macro, hence some device drivers use this. The reason for
changing the SYSCTL API was the need for a SYSCTL parent OID pointer
and not only the SYSCTL parent OID list pointer in order to quickly
generate the sysctl path. The motivation behind this patch is to avoid
parameter loading cludges inside the OFED driver subsystem. Instead of
adding special code to the OFED driver subsystem to post-load tunables
into dynamically created sysctls, we generalize this in the kernel.

Other changes:
- Corrected a possibly incorrect sysctl name from "hw.cbb.intr_mask"
to "hw.pcic.intr_mask".
- Removed redundant TUNABLE statements throughout the kernel.
- Some minor code rewrites in connection to removing not needed
TUNABLE statements.
- Added a missing SYSCTL_DECL().
- Wrapped two very long lines.
- Avoid malloc()/free() inside sysctl string handling, in case it is
called to initialize a sysctl from a tunable, hence malloc()/free() is
not ready when sysctls from the sysctl dataset are registered.
- Bumped FreeBSD version to indicate SYSCTL API change.

MFC after: 2 weeks
Sponsored by: Mellanox Technologies


# cabe79d9 10-Jun-2014 Marius Strobl <marius@FreeBSD.org>

Avoid the USB device disconnected and controller shutdown clutter on system
shutdown by putting the former under !rebooting and turning the latter into
debug messages.

Reviewed by: hps
MFC after: 1 week
Sponsored by: Bally Wulff Games & Entertainment GmbH


# d008478e 20-Mar-2014 Hans Petter Selasky <hselasky@FreeBSD.org>

Try to resolve a possible deadlock when detaching USB devices which
create character devices. The deadlock can happen if an application is
issuing IOCTLs which require USB refcounting, at the same time the USB
device is detaching.

There is already a counter in place in the USB device structure to
detect this situation, but it was not always checked ahead of invoking
functions that might destroy character devices, like detach, set
configuration, set alternate interface or detach active kernel driver.

Reported by: Daniel O'Connor <doconnor@gsoft.com.au>
MFC after: 1 week


# f97da128 17-Jan-2014 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix a possible memory use after free and leak situation associated
with USB device detach when using character device handles. This also
includes LibUSB. It turns out that "usb_close()" cannot always get a
reference to clean up its USB transfers and such, if called during the
kernel USB device detach.

Analysis by: hselasky @
Reported by: Juergen Lock <nox@jelal.kn-bremen.de>
MFC after: 1 week


# a0d53e0b 13-Jan-2014 Hans Petter Selasky <hselasky@FreeBSD.org>

Implement better error recovery for Transaction Translators, TTs,
found in High Speed USB HUBs which translate from High Speed USB into
FULL or LOW speed USB. In some rare cases SPLIT transactions might get
lost, which might leave the TT in an unknown state. Whenever we detect
such an error try to issue either a clear TT buffer request, or if
that is not possible reset the whole TT.

MFC after: 1 week


# e892b3fe 11-Dec-2013 Hans Petter Selasky <hselasky@FreeBSD.org>

USB method structures for USB controllers and USB pipes should be
constant and does not need to be modified. This also saves a small
amount of RAM.


# 273c749c 25-May-2013 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix some statical clang analyzer warnings.


# 6c218933 03-May-2013 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix compile warning.


# 2c79a775 03-May-2013 Hans Petter Selasky <hselasky@FreeBSD.org>

- Add more defines to limit USB memory usage and number of allocations
in reduced memory systems.

- Split allocation and freeing of the configuration descriptor into a separate
function, so that the configuration descriptor can be made fixed size
to save memory allocations. This applies for both device and host mode.


# 5b0752bb 03-May-2013 Hans Petter Selasky <hselasky@FreeBSD.org>

Add some defines to limit USB memory usage in reduced memory systems.


# fa49bce5 03-May-2013 Hans Petter Selasky <hselasky@FreeBSD.org>

Allow the default USB template to be specified at compile time.


# 15d4edd3 03-Apr-2013 Hans Petter Selasky <hselasky@FreeBSD.org>

Add missing ifdef's for reduced feature compilations.


# 23de050b 13-Mar-2013 Hans Petter Selasky <hselasky@FreeBSD.org>

- Make quirk for reading device descriptor from broken USB devices.
Else they won't enumerate at all:
hw.usb.full_ddesc=1
- Reduce the USB descriptor read timeout from 1000ms to
500ms. Typical value for LOW speed devices is 50-100ms.
- Enumerate USB device a maximum of 3 times when a port
connection change event is detected, before giving up.

MFC after: 1 month


# a18a7a41 12-Feb-2013 Hans Petter Selasky <hselasky@FreeBSD.org>

Resolve a LOR after r246616. Protect control requests using the USB device
enumeration lock. Make sure all callers of usbd_enum_lock() check the return
value. Remove the control transfer specific lock. Bump the FreeBSD version
number, hence external USB modules may need to be recompiled due to a USB
device structure change.

MFC after: 1 week


# 6950c75f 10-Feb-2013 Hans Petter Selasky <hselasky@FreeBSD.org>

- Move scratch data from the USB bus structure to the USB device structure
so that simultaneous access cannot happen. Protect scratch area using
the enumeration lock. Also reduce stack usage in usbd_transfer_setup()
by moving some big stack members to the scratch area. This saves around
200 bytes of stack.
- Fix a whitespace.

MFC after: 1 week


# 9b3a48ee 05-Feb-2013 Hans Petter Selasky <hselasky@FreeBSD.org>

Add defines to more easily allow a single threaded version of the FreeBSD
USB stack. This is useful for non-kernel purposes, like the loader.


# d2b99310 30-Jan-2013 Hans Petter Selasky <hselasky@FreeBSD.org>

Modify the FreeBSD USB kernel code so that it can be compiled directly
into the FreeBSD boot loader, typically for non-USB aware BIOSes, EFI systems
or embedded platforms. This is also useful for out of the system compilation
of the FreeBSD USB stack for various purposes. The USB kernel files can
now optionally include a global header file which should include all needed
definitions required to compile the FreeBSD USB stack. When the global USB
header file is included, no other USB header files will be included by
default.

Add new file containing the USB stack configuration for the
FreeBSD loader build.

Replace some __FBSDID()'s by /* $FreeBSD$ */ comments. Now all
USB files follow the same style.

Use cases:
- console in loader via USB
- loading kernel via USB

Discussed with: Hiroki Sato, hrs @ EuroBSDCon


# 83cadd7d 26-Oct-2012 Hans Petter Selasky <hselasky@FreeBSD.org>

Add missing CTLFLAG_TUN flag to tunable sysctls in USB stack.
Rearrange the tunables and belonging sysctl declarations, so
that they are next to eachother.

Submitted by: n_hibma @
MFC after: 1 week


# f61fc4bd 13-Aug-2012 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix for missing locks due to recent change.

PR: usb/170606
MFC after: 2 weeks


# a5cf1aaa 12-Aug-2012 Hans Petter Selasky <hselasky@FreeBSD.org>

Add support for the so-called streams feature of BULK endpoints
in SUPER-speed mode, USB 3.0.

This feature has not been tested yet, due to lack of hardware.

This feature is useful when implementing protocols like UASP,
USB attached SCSI which promises higher USB mass storage throughput.

This patch also implements support for hardware processing of endpoints
for increased performance. The switching to hardware processing
of an endpoint is done via a callback to the USB controller driver. The
stream feature is implemented like a variant of a hardware USB protocol.

USB controller drivers implementing device mode needs to be updated to
implement the new "xfer_stall" USB controller method and remove the
"xfer" argument from the "set_stall" method.

The API's toward existing USB drivers are preserved. To setup a USB transfer
in stream mode, set the "stream_id" field of the USB config structure to
the desired value.

The maximum number of BULK streams is currently hardcoded and limited to 8
via a define in usb_freebsd.h.

All USB drivers should be re-compiled after this change.

LibUSB will be updated next week to support streams mode. A new IOCTL to
setup BULK streams as already been implemented. The ugen device nodes
currently only supports stream ID zero.

The FreeBSD version has been bumped.

MFC after: 2 weeks


# 22039494 10-Aug-2012 Hans Petter Selasky <hselasky@FreeBSD.org>

Style.

MFC after: 2 weeks


# d9073c1e 01-Jun-2012 Hans Petter Selasky <hselasky@FreeBSD.org>

Improve support for detaching kernel drivers on a per interface basis.

MFC after: 1 week


# 6d917491 02-Apr-2012 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix compiler warnings, mostly signed issues,
when USB modules are compiled with WARNS=9.

MFC after: 1 weeks


# 9157ad4b 28-Oct-2011 Hans Petter Selasky <hselasky@FreeBSD.org>

Improve USB mass storage quirk auto detection.

MFC after: 3 days


# 3f37fb62 10-Sep-2011 Hans Petter Selasky <hselasky@FreeBSD.org>

Refactor auto-quirk solution so that we break as few external
drivers as possible.

PR: usb/160299
Approved by: re (kib)
Suggested by: rwatson
MFC after: 0 days


# d46dc4ad 02-Sep-2011 Hans Petter Selasky <hselasky@FreeBSD.org>

This patch adds automatic detection of USB mass storage devices
which does not support the no synchronize cache SCSI command.

The __FreeBSD_version version macro has been bumped and
external kernel modules needs to be recompiled after
this patch.

Approved by: re (kib)
MFC after: 1 week
PR: usb/160299


# 2ffd5fdc 11-Aug-2011 Hans Petter Selasky <hselasky@FreeBSD.org>

Use synchronous device destruction instead of asynchronous, so that a new
device having the same name like a previous one is not created before the old
one is gone. This fixes some panics due to asserts in the devfs code which
were added recently.

Approved by: re (kib)
MFC after: 1 week


# d43ffe94 24-Jun-2011 Hans Petter Selasky <hselasky@FreeBSD.org>

- Ensure that we get all the required nomatch devd events.

MFC after: 3 days


# a6b60150 24-Jun-2011 Hans Petter Selasky <hselasky@FreeBSD.org>

- Move execution of event handlers into the probe and attach function so that
dynamically loaded device drivers get a chance to run their event hooks.

- Decouple the USB suspend and resume lock from witness. It produces some
false warnings due to reusing the lock name among multiple devices.

MFC after: 3 days


# cd10bffa 18-May-2011 Andriy Gapon <avg@FreeBSD.org>

usb: change to one-pass probing of device drivers

This brings USB bus more in line with how newbus is supposed to be used.
Also, because of the two-pass probing the following message was produced
by devd in default configuration when almost any USB device was
connected:
Unknown USB device: vendor <> product <> bus <>
This should be fixed now.

Note that many USB device drivers pass some information from probe
method to attach method via ivars. For this to continue working we rely
on the fact that the subr_bus code calls probe method of a winning driver
again before calling its attach method in the case where multiple
drivers claim to support a device. This is done because device
description is set in successful probe methods and we want to get a correct
device description from a winning driver. So now this logic is re-used
for setting ivars too.

Reviewed by: hselasky
MFC after: 1 month


# afa524e6 08-May-2011 Hans Petter Selasky <hselasky@FreeBSD.org>

Cleanup usb_notify_addq_compat(). It should not
be needed any more.

MFC after: 7 days


# 58ccf5b4 11-Jan-2011 John Baldwin <jhb@FreeBSD.org>

Remove unneeded includes of <sys/linker_set.h>. Other headers that use
it internally contain nested includes.

Reviewed by: bde


# 02c40241 30-Nov-2010 Hans Petter Selasky <hselasky@FreeBSD.org>

We need to define a cdev variable associated with each USB device,
hence existing applications like webcamd are expecting that.
This problem was introduced by SVN change 214221 where cdev=
was replaced by ugen= by accident. Solve this problem by
redefining cdev= in devd notifications.

MFC after 3 days.

Approved by: thompsa (mentor)


# 0834ed47 05-Nov-2010 Nick Hibma <n_hibma@FreeBSD.org>

Bugfix: Move the 'at <location string' to the beginning of the attach
notification. devd would stop evaluating at 'at' (not '<k>=<v>') and
hence prevent 'port=X' (and 'bus=<"on" string>) from making it into the
environment for the devd action.

Reviewed by: hselasky
MFC after: 2 weeks


# 6df3eebb 04-Nov-2010 Nick Hibma <n_hibma@FreeBSD.org>

Don't terminate the notification with \n. This is done in
usb_device.c:devctl_notify_f().


# 8427ed84 27-Oct-2010 Hans Petter Selasky <hselasky@FreeBSD.org>

Add support for setting per-interface PnP information.

Submitted by: Nick Hibma
Approved by: thompsa (mentor)


# 8bb77249 22-Oct-2010 Hans Petter Selasky <hselasky@FreeBSD.org>

Add possibility to generate devctl notifications regardless of UGEN presence.

Submitted by: Nick Hibma
Approved by: thompsa (mentor)


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 963169b4 04-Oct-2010 Hans Petter Selasky <hselasky@FreeBSD.org>

This commit adds full support for USB 3.0 devices in host and device
mode in the USB core. The patch mostly consists of updating the USB
HUB code to support USB 3.0 HUBs. This patch also add some more USB
controller methods to support more active-alike USB controllers like
the XHCI which needs to be informed about various device state events.

USB 3.0 HUBs are not tested yet, due to lack of hardware, but are
believed to work.

After this update the initial device descriptor is only read twice
when we know that the bMaxPacketSize is too small for a single packet
transfer of this descriptor.

Approved by: thompsa (mentor)


# ae538d85 01-Sep-2010 Andrew Thompson <thompsa@FreeBSD.org>

Reduce the need to accesss struct usb_device by providing functions to access
the product, manufacturer and serial strings.

Submitted by: Hans Petter Selasky


# d2d71ce7 01-Sep-2010 Andrew Thompson <thompsa@FreeBSD.org>

Add support for power mode filtering as some USB hardware does not support
power saving.

Submitted by: Hans Petter Selasky


# 1bdfff22 11-Jun-2010 Andriy Gapon <avg@FreeBSD.org>

fix a few cases where a string is passed via format argument instead of
via %s

Most of the cases looked harmless, but this is done for the sake of
correctness. In one case it even allowed to drop an intermediate buffer.

Found by: clang
MFC after: 2 week


# 51c097f1 17-May-2010 Andrew Thompson <thompsa@FreeBSD.org>

MFC r208008

If a USB device is suspended and a USB set config request is issued when the
USB enumeration lock is locked, then the USB stack fails to resume the device
because locking the USB enumeration lock is part of the resume procedure. To
solve this issue a new lock is introduced which only protects the suspend and
resume callbacks, which can be dropped inside the usbd_do_request_flags()
function, to allow suspend and resume during so-called enumeration operations.


# 2df1e9a6 12-May-2010 Andrew Thompson <thompsa@FreeBSD.org>

If a USB device is suspended and a USB set config request is issued when the
USB enumeration lock is locked, then the USB stack fails to resume the device
because locking the USB enumeration lock is part of the resume procedure. To
solve this issue a new lock is introduced which only protects the suspend and
resume callbacks, which can be dropped inside the usbd_do_request_flags()
function, to allow suspend and resume during so-called enumeration operations.

Submitted by: Hans Petter Selasky


# 31f57dc1 29-Apr-2010 Andrew Thompson <thompsa@FreeBSD.org>

MFC r207080

Use a more obvious prefix for the USB control (endpoint 0) transfers rather
than default_*.


# c955f362 29-Apr-2010 Andrew Thompson <thompsa@FreeBSD.org>

MFC r207079

Properly name the sxlocks, mutexes and condvars.


# ccd296df 29-Apr-2010 Andrew Thompson <thompsa@FreeBSD.org>

MFC r207078

Use SX_DUPOK rather than making the string unique.


# 176b25ad 29-Apr-2010 Andrew Thompson <thompsa@FreeBSD.org>

MFC r207020, r207027, r207072.

Change usb devd events from fake attach to a notify. The ugen device is not a
proper device_t so it faked the devctl event to appear like one, this is now a
notify which allows more information to be passed.

We notify for both the device attach/detach and for each usb interface. A devd
rule can now match on the interface properties, including composite devices
which may have a uvideo interface and also usound and possibly uhid too.

An example to match a umass device with a scsi subclass and BBB protocol would be

notify 100 {
match "system" "USB";
match "subsystem" "INTERFACE";
match "type" "ATTACH";
match "intclass" "0x08";
match "intsubclass" "0x06";
match "intprotocol" "0x50";
action ...
};

The old attach devctl event has been retained for the moment to make merging to
8.1 easier. This was never compatible with 7.x or earlier due to the ugen regex
change needed.

Document the new USB notification types.


# 5b3bb704 22-Apr-2010 Andrew Thompson <thompsa@FreeBSD.org>

Use a more obvious prefix for the USB control (endpoint 0) transfers rather
than default_*.


# 91cd9240 22-Apr-2010 Andrew Thompson <thompsa@FreeBSD.org>

Properly name the sxlocks, mutexes and condvars.


# 0d92ac2a 22-Apr-2010 Andrew Thompson <thompsa@FreeBSD.org>

Use SX_DUPOK rather than making the string unique.


# 66390216 21-Apr-2010 Andrew Thompson <thompsa@FreeBSD.org>

Also add the usb mode to the devd string as the usb controller can work in both
host or device (gadget) modes.

Suggested by: HPS


# 3acd904d 21-Apr-2010 Andrew Thompson <thompsa@FreeBSD.org>

Change usb devd events from fake attach to a notify. The ugen device is not a
proper device_t so it faked the devctl event to appear like one, this is now a
notify which allows more information to be passed.

We notify for both the device attach/detach and for each usb interface. A devd
rule can now match on the interface properties, including composite devices
which may have a uvideo interface and also usound and possibly uhid too.

An example to match a umass device with a scsi subclass and BBB protocol would be

notify 100 {
match "system" "USB";
match "subsystem" "INTERFACE";
match "type" "ATTACH";
match "intclass" "0x08";
match "intsubclass" "0x06";
match "intprotocol" "0x50";
action ...
};

The old attach devctl event has been retained for the moment to make merging to
8.1 easier. This was never compatible with 7.x or earlier due to the ugen regex
change needed.

Reviewed by: warner
MFC after: 1 week


# 464b64f6 06-Apr-2010 Andrew Thompson <thompsa@FreeBSD.org>

MFC r205036

Implement USB kernel driver detach from userland.

Submitted by: Hans Petter Selasky


# a7aca4cd 11-Mar-2010 Andrew Thompson <thompsa@FreeBSD.org>

Implement USB kernel driver detach from userland.

Submitted by: Hans Petter Selasky


# 9d25e838 17-Jan-2010 Andrew Thompson <thompsa@FreeBSD.org>

MFC r201681

Improve u3g device ejecting by providing additional methods for the eject
command in the usb_msctest routines, as well as a general tidyup.


# 6b5b5822 17-Jan-2010 Andrew Thompson <thompsa@FreeBSD.org>

MFC r201680

scratch_size was incorrectly passed as language ID when retrieving the language
ID table, this broke string retrieval on some devices.

Submitted by: Hans Petter Selasky
Reported by: Renato Botelho


# d84a79e7 06-Jan-2010 Andrew Thompson <thompsa@FreeBSD.org>

Improve u3g device ejecting by providing additional methods for the eject
command in the usb_msctest routines, as well as a general tidyup.

This now properly ejects the ZTE MF636, Option Gi0322 and Novatel MC950D
devices I have on my desk.


# c10e1453 06-Jan-2010 Andrew Thompson <thompsa@FreeBSD.org>

scratch_size was incorrectly passed as language ID when retrieving the language
ID table, this broke string retrieval on some devices.

Submitted by: Hans Petter Selasky
Reported by: Renato Botelho


# ee4e4d54 30-Dec-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFC r200653

Use the EVENTHANDLER system to hook into the usb device configuration and
perform a function such as ejecting a 3G autoinstaller disk. The eventhandler
system properly tracks threads and is safe to unload, remove the
setting/clearing of a function pointer in the kernel by u3g(4) which included a
tsleep for safety.


# 2a4c6157 17-Dec-2009 Andrew Thompson <thompsa@FreeBSD.org>

Use the EVENTHANDLER system to hook into the usb device configuration and
perform a function such as ejecting a 3G autoinstaller disk. The eventhandler
system properly tracks threads and is safe to unload, remove the
setting/clearing of a function pointer in the kernel by u3g(4) which included a
tsleep for safety.


# c1b5138f 09-Dec-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFC r199816

Remove overuse of exclamation marks in kernel printfs, there mere fact a
message has been printed is enough to get someones attention. Also remove the
line number for DPRINTF/DPRINTFN, it already prints the funtion name and a
unique message.


# b7167d5d 09-Dec-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFC r199672

Improve High Speed slot allocation mechanism by moving the computation to the
endpoint rather than per xfer and provide functions around get/free of resources.

Submitted by: Hans Petter Selasky


# 767cb2e2 25-Nov-2009 Andrew Thompson <thompsa@FreeBSD.org>

Remove overuse of exclamation marks in kernel printfs, there mere fact a
message has been printed is enough to get someones attention. Also remove the
line number for DPRINTF/DPRINTFN, it already prints the funtion name and a
unique message.


# f12c6c29 22-Nov-2009 Andrew Thompson <thompsa@FreeBSD.org>

Improve High Speed slot allocation mechanism by moving the computation to the
endpoint rather than per xfer and provide functions around get/free of resources.

Submitted by: Hans Petter Selasky


# d81c7ac0 29-Oct-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFC r197561

Correct buffer sizes used so that they match. The old code could give the
impression that a overflow situation existed but was not possible.


# 88f788a6 29-Oct-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFC r197559

Add support for USB language selection.

PR: usb/138563


# 9d168176 29-Oct-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFC r197558

Fix NULL-pointer dereference in usb_endpoint_foreach().

PR: usb/138389


# 1063b450 29-Oct-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFC r197553

- clean up USB detach logic. There seems to be some problems detaching multiple
USB HUBs connected in series from the root.


# 35e0e603 28-Sep-2009 Andrew Thompson <thompsa@FreeBSD.org>

Correct buffer sizes used so that they match. The old code could give the
impression that a overflow situation existed but was not possible.

Reported by: kib
Submitted by: Hans Petter Selasky


# 7a918edf 28-Sep-2009 Andrew Thompson <thompsa@FreeBSD.org>

Add support for USB language selection.

PR: usb/138563
Reported by: Bruce Cran
Submitted by: Hans Petter Selasky


# a9e26757 28-Sep-2009 Andrew Thompson <thompsa@FreeBSD.org>

Fix NULL-pointer dereference in usb_endpoint_foreach().

PR: usb/138389
Submitted by: Patroklos Argyroudis at census, inc


# d88688c7 28-Sep-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 @ 168387

- clean up USB detach logic. There seems to be some problems detaching multiple
USB HUBs connected in series from the root.

- after this patch the rule is:
1) Always use device_detach() on the USB HUB first.
2) Never just device_delete_child() on the USB HUB, because that function
will traverse to all the device leaves and free them first, and then the USB
stack will free the devices twice which doesn't work very well.

- make sure the did DMA delay gets set after the timeout has elapsed to make
logic more clear. There is no functional difference.

Submitted by: Hans Petter Selasky


# 42a66b53 01-Sep-2009 Alfred Perlstein <alfred@FreeBSD.org>

MFC: r196489,196498
Critical USB bugfixes for 8.0

Approved by: re


# cb18f7d1 23-Aug-2009 Alfred Perlstein <alfred@FreeBSD.org>

- Patch to allow USB controller to resume operation after
being polled.

- Remove the need for Giant from the USB HUB driver.

- Leave device unconfigured instead of disabling the USB port
when Huawei Autoinstall disk detection triggers. This should
fix problems that the Huawei device is not detected after
Autoinstall eject is issued.
- Reported by: Nikolay Antsiferov

- Fix memory use after free race for USB character devices.
- Reported by: Lucius Windschuh

- Factor out the enumeration lock into three functions to make the
coming newbus lock conversion more easy.
- usbd_enum_lock
- usbd_enum_unlock
- usbd_enum_is_locked

Submitted by: hps


# bd73b187 29-Jul-2009 Alfred Perlstein <alfred@FreeBSD.org>

USB core:
- add support for defragging of written device data.
- improve handling of alternate settings in device side mode.
- correct return value from usbd_get_no_alts() function.
- reported by: HPS
- P4 ID: 166156, 166168

- report USB device release information to devd and pnpinfo.
- reported by: MIHIRA Sanpei Yoshiro
- P4 ID: 166221

Submitted by: hps
Approved by: re


# 29bd7d7e 27-Jun-2009 Andrew Thompson <thompsa@FreeBSD.org>

Sync to p4

- Add support for devices that handle set and clear stall in hardware.
- Add missing get timestamp function
- Add more xfer flags

Submitted by: Hans Petter Selasky
Approved by: re (kib)


# ed6d949a 22-Jun-2009 Andrew Thompson <thompsa@FreeBSD.org>

- Make struct usb_xfer opaque so that drivers can not access the internals
- Reduce the number of headers needed for a usb driver, the common case is just usb.h and usbdi.h


# 3c8d24f4 15-Jun-2009 Andrew Thompson <thompsa@FreeBSD.org>

Fix usb2_find_descriptor function name.


# a593f6b8 14-Jun-2009 Andrew Thompson <thompsa@FreeBSD.org>

s/usb2_/usb_|usbd_/ on all function names for the USB stack.


# 8437751d 14-Jun-2009 Andrew Thompson <thompsa@FreeBSD.org>

Remove usb2_cv_* and just use the kernel condvar implementation, it was needed
earlier since condition variables didnt work with Giant but this was fixed 10
months ago.


# ae60fdfb 07-Jun-2009 Andrew Thompson <thompsa@FreeBSD.org>

Rename usb pipes to endpoints as it better represents what they are, and struct
usb_pipe may be used for a different purpose later on.


# e0a69b51 29-May-2009 Andrew Thompson <thompsa@FreeBSD.org>

s/usb2_/usb_/ on all typedefs for the USB stack.


# 28212de2 29-May-2009 Andrew Thompson <thompsa@FreeBSD.org>

Free device strings.

Spotted by: HPS


# 760bc48e 28-May-2009 Andrew Thompson <thompsa@FreeBSD.org>

s/usb2_/usb_/ on all C structs for the USB stack.


# c86aead6 27-May-2009 Andrew Thompson <thompsa@FreeBSD.org>

Allocate the usb serial, manufacturer and product strings rather than use char
arrays in the usb_device struct. This also eliminates USB_HAVE_STRINGS.


# 9360ae40 20-May-2009 Andrew Thompson <thompsa@FreeBSD.org>

Rename the usb sysctl tree from hw.usb2.* back to hw.usb.*.

Submitted by: Hans Petter Selasky


# 8d2dd5dd 20-May-2009 Andrew Thompson <thompsa@FreeBSD.org>

Use enums for speed and rev data types.


# f29a0724 20-May-2009 Andrew Thompson <thompsa@FreeBSD.org>

- rename usb2_mode to usb_mode [1]
- change variable types to use the enum

Submitted by: Hans Petter Selasky [1]


# ec8f3127 05-May-2009 Andrew Thompson <thompsa@FreeBSD.org>

Revert part of r191494 which used the udev state to mark suspending, this needs
to be set via two variables (peer_suspended and self_suspended) and can not be
merged into one.

Submitted by: Hans Petter Selasky
Pointy hat: me


# 4d4fa6ed 25-Apr-2009 Andrew Thompson <thompsa@FreeBSD.org>

Make the state string descriptions public.


# bd216778 25-Apr-2009 Andrew Thompson <thompsa@FreeBSD.org>

Track the usb device state as its powered on, addressed and configured. This helps
to avoid touching the device when it is not going to respond and would otherwise
timeout.

Implement the suspend tracking as a udev state too.


# 459d369e 22-Apr-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb@160930

Change the roothub exec functions to take the usb request and data pointers
directly rather than placing them on the parent bus struct.

Submitted by: Hans Petter Selasky


# 9469c929 22-Apr-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb@160655

Fix possible issue with clear-stall and set-config happening at the same time.

Submitted by: Hans Petter Selasky


# 88b4e0ab 22-Apr-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb@160614

Fix errornous printout.

Submitted by: Hans Petter Selasky


# 495f25ce 22-Apr-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb@160413

Use direct reference to parent high-speed HUB instead of indirect, due to
pointer clearing race at detach of parent USB HUB.

Reported by: kientzle
Submitted by: Hans Petter Selasky
PR: usb/133545


# fde87526 05-Apr-2009 Andrew Thompson <thompsa@FreeBSD.org>

Provide a better commit log for r190735, forced by making a whitespace change.

Refactor how we interface with the root HUB. This is achieved by making a
direct call from usb2_do_request to the host controller for root hub requests,
this call will perform the controller specific register read/writes and return
the error code.

This cuts out a lot of code in the host controller files and saves one thread
per USB bus.

Submitted by: Hans Petter Selasky


# 9f2b42e5 05-Apr-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb@160056

Remove code for unused and unlikely quirk, "uq_power_claim"

Submitted by: Hans Petter Selasky


# 03797f33 05-Apr-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb@159948

Add more debugging output on enumeration failures.

Submitted by: Hans Petter Selasky


# 39307315 05-Apr-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb@159922

Refactor how we interface with the root HUB. This cuts around 1200 lines of
code totally and saves one thread per USB bus.

Submitted by: Hans Petter Selasky


# 4eae601e 05-Apr-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb@159909

- make usb2_power_mask_t 16-bit
- remove "usb2_config_sub" structure from "usb2_config". To compensate for this
"usb2_config" has a new field called "usb_mode" which select for which mode
the current xfer entry is active. Options are: a) Device mode only b) Host
mode only (default-by-zero) c) Both modes. This change was scripted using
the following sed script: "s/\.mh\././g".
- the standard packet size table in "usb_transfer.c" is now a function, hence
the code for the function uses less memory than the table itself.

Submitted by: Hans Petter Selasky


# 51ec1603 05-Apr-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb@159897

Add new endpoint direction values for use with usb2_config

Submitted by: Hans Petter Selasky


# 63521bbc 05-Apr-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb@159871

- bugfixes after the memory usage reduction patch
- Use "udev->pipes_max" instead of USB_EP_MAX
- Use correct "bmRequestType" for getting the config descriptor.

Submitted by: Hans Petter Selasky


# bdd41206 05-Apr-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb@159866

- memory usage reduction by only allocating the required USB pipes and USB
interfaces.
- cleanup some USB parsing functions to be more flexible.

Submitted by: Hans Petter Selasky


# 7efaaa9a 05-Apr-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb@159811

First patch in a series of memory save patches.

Submitted by: Hans Petter Selasky


# 72b532e5 05-Apr-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb@159677

Remove redundant locking.

Submitted by: Hans Petter Selasky


# 91f72ced 23-Mar-2009 Andrew Thompson <thompsa@FreeBSD.org>

Fix order of debug printf items, addr and config# were swapped.


# 62a5f394 22-Mar-2009 Alexander Kabaev <kan@FreeBSD.org>

Do not pass uninitialized data buffer to devctl_queue_data function.
This was botched in revision 190191.


# 8755859a 20-Mar-2009 Andrew Thompson <thompsa@FreeBSD.org>

Fix compile with USB_HAVE_BUSDMA/USB_HAVE_UGEN/USB_HAVE_STRINGS.

Submitted by: Hans Petter Selasky


# 578d0eff 20-Mar-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb @159431,159437,159438

- start using the new USB typedefs in the USB core
- Remove usage of USB_ADD_BYTES()

Submitted by: Hans Petter Selasky


# bdc081c6 20-Mar-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb@159392

Add ifdefs for making parts of usb conditional.

Submitted by: Hans Petter Selasky


# ab42e8b2 20-Mar-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb @159430

- Move tunable defines into usb_core.h and dependancy towards usb_defs.h
- Leave hardcoded defines in "usb_defs.h".
- Allow overriding all tunable defines.
- Add more customisable typedefs.
- Correct maximum device number.

Submitted by: Hans Petter Selasky


# 0f6e8f93 09-Mar-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb 158942,158948

Allow USB to be compiled without ugen support.

Submitted by: Hans Petter Selasky


# f35aaff0 28-Feb-2009 Andrew Thompson <thompsa@FreeBSD.org>

A couple of style nits in the last commit
- unwrap short lines
- move variable initialisation out of the declaration.


# f5f145ba 28-Feb-2009 Andrew Thompson <thompsa@FreeBSD.org>

- Remove the usb interface number from the device nodes as it is not needed.
- Do not recreate the device nodes in set_alt_interface as the endpoints do not
change.

Submitted by: Hans Petter Selasky


# ee3e3ff5 27-Feb-2009 Andrew Thompson <thompsa@FreeBSD.org>

Change USB over to make_dev() for all device nodes, previously it hooked into
the devfs clone handler to open the (invisible) devices on the fly.

The /dev entries are layed out as follows,

/dev/usbctl = master device
/dev/usb/0.1.0.5 = usb device, (<bus>.<dev>.<iface>.<endpoint>)
/dev/ugen0.1 -> usb/0.1.0.0 = ugen link to ctrl endpoint

This also removes the custom permissions model from USB. Bump
__FreeBSD_version to 800066.

Submitted by: rink (earlier version)


# e2805033 23-Feb-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb@157958

- We don't need to exit the Giant mutex when sleeping. This is done
automatically. Replace Giant by NULL mutex for all control requests in the
enumeration path.
- Optimise away duplicate alternate interface selection requests in USB Host
mode.

Submitted by: Hans Petter Selasky


# 16589bea 23-Feb-2009 Andrew Thompson <thompsa@FreeBSD.org>

MFp4 //depot/projects/usb@157909

Changes to make implementing USB NDIS easier.

Submitted by: Hans Petter Selasky


# 02ac6454 23-Feb-2009 Andrew Thompson <thompsa@FreeBSD.org>

Move the new USB stack into its new home.