History log of /freebsd-12.1/sys/dev/usb/usb_transfer.c (Results 1 – 25 of 88)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: release/12.2.0, release/11.4.0, release/12.1.0
# 8835f272 07-Oct-2019 Hans Petter Selasky <[email protected]>

MFS r353177:
Add quirk for XHCI(4) controllers to support USB control transfers
above 1Kbyte. It might look like some XHCI(4) controllers do not
support when the USB control transfer is split using

MFS r353177:
Add quirk for XHCI(4) controllers to support USB control transfers
above 1Kbyte. It might look like some XHCI(4) controllers do not
support when the USB control transfer is split using a link TRB. The
next NORMAL TRB after the link TRB is simply failing with XHCI error
code 4. The quirk ensures we allocate a 64Kbyte buffer so that the
data stage TRB is not broken with a link TRB.

Found at: EuroBSDcon 2019
Sponsored by: Mellanox Technologies
Approved by: re (gjb)

show more ...


Revision tags: release/11.3.0, release/12.0.0, release/11.2.0
# 718cf2cc 27-Nov-2017 Pedro F. Giffuni <[email protected]>

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

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.

show more ...


Revision tags: release/10.4.0, release/11.1.0, release/11.0.1, release/11.0.0
# 0eb8d462 14-Sep-2016 Hans Petter Selasky <[email protected]>

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 infi

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 <[email protected]>
MFC after: 4 weeks

show more ...


# 64cb5e2a 05-Sep-2016 Hans Petter Selasky <[email protected]>

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 c

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

show more ...


# 20733245 02-May-2016 Pedro F. Giffuni <[email protected]>

dev/usb: minor spelling fixes in comments.

No functional change.

Reviewed by: hselasky


# 057b4402 26-Apr-2016 Pedro F. Giffuni <[email protected]>

sys/dev: extend use of the howmany() macro when available.

We have a howmany() macro in the <sys/param.h> header that is
convenient to re-use as it makes things easier to read.


# 2bf49386 09-Apr-2016 Pedro F. Giffuni <[email protected]>

USB: replace 0 with NULL for pointers.

Found with devel/coccinelle.

Reviewed by: hselasky


Revision tags: release/10.3.0
# 22ef3de7 15-Aug-2015 Hans Petter Selasky <[email protected]>

Fix race in USB PF which can happen if we stop tracing exactly when
the kernel is tapping an USB transfer. This leads to a NULL pointer
access. The solution is to only trace while the USB bus lock is

Fix race in USB PF which can happen if we stop tracing exactly when
the kernel is tapping an USB transfer. This leads to a NULL pointer
access. The solution is to only trace while the USB bus lock is
locked.

MFC after: 2 weeks

show more ...


# 43ea03d7 14-Aug-2015 Hans Petter Selasky <[email protected]>

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 l

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

show more ...


Revision tags: release/10.2.0
# 8b1ce329 02-Feb-2015 Hans Petter Selasky <[email protected]>

Optimise allocation of USB DMA structures. By default don't double map
allocations if only one element should be allocated per page
cache. Make one allocation per element compile time configurable. F

Optimise allocation of USB DMA structures. By default don't double map
allocations if only one element should be allocated per page
cache. Make one allocation per element compile time configurable. Fix
a comment while at it.

Suggested by: ian @
MFC after: 1 week

show more ...


# add9e3e5 02-Feb-2015 Hans Petter Selasky <[email protected]>

Section 3.2.9 in the XHCI specification about control transfers says
that we should use a normal-TRB if there are more TRBs extending the
data-stage TRB. Add a dedicated state bit to the internal USB

Section 3.2.9 in the XHCI specification about control transfers says
that we should use a normal-TRB if there are more TRBs extending the
data-stage TRB. Add a dedicated state bit to the internal USB transfer
flags to handle this case.

Reported by: Kohji Okuno <[email protected]>
MFC after: 1 week

show more ...


# b217d184 05-Jan-2015 Hans Petter Selasky <[email protected]>

Add 64-bit DMA support in the XHCI controller driver.
- Fix some comments and whitespace while at it.

MFC after: 1 month
Submitted by: marius@


Revision tags: release/10.1.0, release/9.3.0
# e91fe3a9 14-Mar-2014 Hans Petter Selasky <[email protected]>

Workaround for USB MIDI adapters which use non-supported values of
wMaxPacketSize for BULK endpoints.

MFC after: 1 week


# 924b1f5d 22-Jan-2014 Hans Petter Selasky <[email protected]>

Ensure that the DMA delay does not get rounded down to zero ticks when
a timeout value of a single tick is given. With FreeBSD-10 and newer
the current system time is used as a starting point, and th

Ensure that the DMA delay does not get rounded down to zero ticks when
a timeout value of a single tick is given. With FreeBSD-10 and newer
the current system time is used as a starting point, and the minimum
callout time of a single tick will be guaranteed. This patch mostly
affect the DMA delay timeouts, which are typically in the range from
0.125 to 2ms.

MFC after: 1 week

show more ...


Revision tags: release/10.0.0
# a0d53e0b 13-Jan-2014 Hans Petter Selasky <[email protected]>

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 mi

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

show more ...


# e892b3fe 11-Dec-2013 Hans Petter Selasky <[email protected]>

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.


Revision tags: release/9.2.0, release/8.4.0
# 6950c75f 10-Feb-2013 Hans Petter Selasky <[email protected]>

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

- 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

show more ...


# 9b3a48ee 05-Feb-2013 Hans Petter Selasky <[email protected]>

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 <[email protected]>

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

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

show more ...


# a6d2f40e 20-Dec-2012 Hans Petter Selasky <[email protected]>

Allocate separate USB buffers for DMA'ed data, so that
DMA data does not reside next to non DMA data. This
might cause more memory to be allocated, but solves
problems on platforms using manual cache

Allocate separate USB buffers for DMA'ed data, so that
DMA data does not reside next to non DMA data. This
might cause more memory to be allocated, but solves
problems on platforms using manual cache
synchronization.

Add a convenience function to get the buffer only
from a USB transfer's page cache structure.

MFC after: 1 week
Suggested by: imp

show more ...


Revision tags: release/9.1.0
# a5cf1aaa 12-Aug-2012 Hans Petter Selasky <[email protected]>

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

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

show more ...


Revision tags: release/8.3.0, release/7.4.0, release/8.2.0, release/8.1.0
# 31f57dc1 29-Apr-2010 Andrew Thompson <[email protected]>

MFC r207080

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


# c955f362 29-Apr-2010 Andrew Thompson <[email protected]>

MFC r207079

Properly name the sxlocks, mutexes and condvars.


# ad658060 29-Apr-2010 Andrew Thompson <[email protected]>

MFC r207077

Change USB_DEBUG to #ifdef and allow it to be turned off. Previously this had
the illusion of a tunable setting but was always turned on regardless.


# 33f167cc 06-Apr-2010 Andrew Thompson <[email protected]>

MFC r205035

Make sure there is a way to reset the endpoint FIFO on transfer errors for
ISOCHRONOUS transfers

Submitted by: Hans Petter Selasky


1234