History log of /freebsd-10-stable/sys/dev/usb/usb_device.c
Revision Date Author Comments
# 361908 08-Jun-2020 hselasky

MFC r361577:
Don't allow USB device drivers to parent own interface.
It will prevent proper USB device detach.

Sponsored by: Mellanox Technologies


# 310281 19-Dec-2016 trasz

MFC r307902:

Make the USB attach strings in dmesg include product name.

MFC after: 1 month


# 308402 07-Nov-2016 hselasky

MFC r307518:
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


# 305734 12-Sep-2016 hselasky

MFC r305421:
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@


# 301253 03-Jun-2016 hselasky

MFC r300667:
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.


# 301250 03-Jun-2016 hselasky

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


# 287274 29-Aug-2015 hselasky

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


# 283173 21-May-2015 hselasky

MFC r282577:
Add support for DYMO LabelWriter PnP.


# 278289 05-Feb-2015 hselasky

MFC r277136:
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.

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


# 269917 13-Aug-2014 hselasky

MFC r269566:
Fix for deadlock in USB device side mode.


# 267775 23-Jun-2014 marius

MFC: r267321

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
Sponsored by: Bally Wulff Games & Entertainment GmbH


# 263799 27-Mar-2014 hselasky

MFC r263423:
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.


# 261110 24-Jan-2014 hselasky

MFC r260808 and r260814:
- Close a minor deadlock.
- 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.


# 261105 24-Jan-2014 hselasky

MFC r260588 and r260589:
- Separate I/O errors from reception of STALL PID.
- 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.


# 287274 29-Aug-2015 hselasky

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


# 283173 21-May-2015 hselasky

MFC r282577:
Add support for DYMO LabelWriter PnP.


# 278289 05-Feb-2015 hselasky

MFC r277136:
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.

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


# 269917 13-Aug-2014 hselasky

MFC r269566:
Fix for deadlock in USB device side mode.


# 267775 23-Jun-2014 marius

MFC: r267321

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
Sponsored by: Bally Wulff Games & Entertainment GmbH


# 263799 27-Mar-2014 hselasky

MFC r263423:
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.


# 261110 24-Jan-2014 hselasky

MFC r260808 and r260814:
- Close a minor deadlock.
- 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.


# 261105 24-Jan-2014 hselasky

MFC r260588 and r260589:
- Separate I/O errors from reception of STALL PID.
- 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.