summaryrefslogtreecommitdiff
path: root/sys/dev/usb/controller/usb_controller.c
AgeCommit message (Collapse)Author
2025-03-12usb: Use bus_detach_children instead of bus_generic_detachJohn Baldwin
The USB bus performs additional teardown steps in between detaching child devices and deleting child devices. Reported by: phk, thj Tested by: phk Fixes: e9d3857040a1 ("Use bus_detach_children instead of bus_generic_detach")
2024-09-24usb: change LIST to SLIST to avoid LinuxKPI conflictsBjoern A. Zeeb
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
2024-06-03kern: Remove leftover saf1761otg bitsJoshua Kinard
Almost all code related to the saf1761 driver was removed in commit 44796b7e822e, except for two small bits related to saf1761otg support. This patch completes the removal. PR: 279302 Signed-off-by: Joshua Kinard <freebsd@kumba.dev> Reviewed by: mhorne MFC after: 3 days Fixes: 44796b7e822e ("mips: remove saf1761")
2023-08-16sys: Remove $FreeBSD$: one-line .c comment patternWarner Losh
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
2023-05-12spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh
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
2022-10-07usb(4): Make the enumeration thread nice time a variable.Hans Petter Selasky
Depends on "options USB_DEBUG". Suggested by: koobs@ MFC after: 1 week Sponsored by: NVIDIA Networking
2022-10-05usb(4): Make sure the enumeration thread doesn't loop too fast.Hans Petter Selasky
MFC after: 1 week Sponsored by: NVIDIA Networking
2022-05-06usb: Remove unused devclass arguments to DRIVER_MODULE.John Baldwin
2021-12-09Create wrapper for Giant taken for newbusWarner Losh
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
2020-09-01usb: clean up empty lines in .c and .h filesMateusz Guzik
Notes: svn path=/head/; revision=365084
2020-02-15Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (2 of many)Pawel Biernacki
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Reviewed by: hselasky, kib Approved by: kib (mentor) Differential Revision: https://reviews.freebsd.org/D23632 Notes: svn path=/head/; revision=357972
2018-07-27Remove Atmel AT91RM9200 and AT91SAM9 support.Warner Losh
The last known robust version of this code base was FreeBSD 8.2. There are no users of this on current, and all users of it have abandoned this platform or are in legacy mode with a prior version of FreeBSD. All known users on arm@ approved this removal, and there were no objections. Differential Revision: https://reviews.freebsd.org/D16312 Notes: svn path=/head/; revision=336770
2017-11-27sys/dev: further adoption of SPDX licensing ID tags.Pedro F. Giffuni
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. Notes: svn path=/head/; revision=326255
2015-08-14Improve the realtime properties of USB transfers for embedded systemsHans Petter Selasky
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 Notes: svn path=/head/; revision=286773
2015-01-13Resolve a special case deadlock: When two or more threads areHans Petter Selasky
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 Notes: svn path=/head/; revision=277136
2015-01-05Add 64-bit DMA support in the XHCI controller driver.Hans Petter Selasky
- Fix some comments and whitespace while at it. MFC after: 1 month Submitted by: marius@ Notes: svn path=/head/; revision=276717
2015-01-05Make a bunch of USB debug SYSCTLs tunable, so that their value(s) canHans Petter Selasky
be set before the USB device(s) are probed. Notes: svn path=/head/; revision=276701
2014-10-09Refine support for disabling USB enumeration to allow device detachHans Petter Selasky
and suspend and resume of existing devices. MFC after: 2 weeks Notes: svn path=/head/; revision=272807
2014-10-08Add support for disabling USB enumeration in general or on selectedHans Petter Selasky
USB HUBs. MFC after: 2 weeks Notes: svn path=/head/; revision=272733
2014-08-05Rename driver name a bit to avoid unit number confusion in dmesg.Hans Petter Selasky
MFC after: 3 days Notes: svn path=/head/; revision=269565
2014-06-28Pull in r267961 and r267973 again. Fix for issues reported will follow.Hans Petter Selasky
Notes: svn path=/head/; revision=267992
2014-06-27Revert r267961, r267973:Glen Barber
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 Notes: svn path=/head/; revision=267985
2014-06-27Extend the meaning of the CTLFLAG_TUN flag to automatically check ifHans Petter Selasky
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 Notes: svn path=/head/; revision=267961
2014-06-10Avoid the USB device disconnected and controller shutdown clutter on systemMarius Strobl
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 Notes: svn path=/head/; revision=267321
2014-06-08Resolve a deadlock setting the USB configuration index from userspaceHans Petter Selasky
on USB HUBs by moving the code into the USB explore threads. The deadlock happens because child devices of the USB HUB don't have the expected reference count when called from outside the explore thread. Only the HUB device itself, which the IOCTL interface locks, gets the correct reference count. MFC after: 3 days Notes: svn path=/head/; revision=267240
2014-06-07Make WITNESS happy by giving USB mutexes different names.Hans Petter Selasky
Reported by: trociny @ MFC after: 3 days Notes: svn path=/head/; revision=267212
2014-05-29Hook the ISP/SAF1761 driver into MIPS kernel builds.Hans Petter Selasky
- Update FDT file for BERI DE4 boards. - Add needed kernel configuration keywords. - Rename module to saf1761otg so that the device unit number does not interfere with the hardware ID in dmesg. Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=266832
2014-05-18- Add softc pointer argument to FIFO functions as an optimisation.Hans Petter Selasky
- Implement support for interrupt filters in the DWC OTG driver, to reduce the amount of CPU task switching when only feeding the FIFOs. - Add common spinlock to the USB bus structure. MFC after: 2 weeks Notes: svn path=/head/; revision=266394
2014-05-16- Allow the SAF1761 driver to attach to the root HUB USB driver.Hans Petter Selasky
Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=266216
2013-12-08Fix typos.Hans Petter Selasky
Found by: remko Notes: svn path=/head/; revision=259095
2013-12-06Improve the XHCI command timeout recovery handling code.Hans Petter Selasky
MFC after: 1 week Notes: svn path=/head/; revision=259023
2013-04-23Add convenience wrapper functions to run callbacks in the context of theHans Petter Selasky
USB explore thread. Notes: svn path=/head/; revision=249795
2013-02-13Resolve a LOR after r246616. Protect control requests using the USB deviceHans Petter Selasky
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 Notes: svn path=/head/; revision=246759
2013-02-05Add defines to more easily allow a single threaded version of the FreeBSDHans Petter Selasky
USB stack. This is useful for non-kernel purposes, like the loader. Notes: svn path=/head/; revision=246363
2013-01-30Use DEVMETHOD_END macro defined in sys/bus.h instead of {0, 0} sentinel on ↵Sofian Brabez
device_method_t arrays Reviewed by: cognet Approved by: cognet Notes: svn path=/head/; revision=246128
2013-01-30Modify the FreeBSD USB kernel code so that it can be compiled directlyHans Petter Selasky
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 Notes: svn path=/head/; revision=246122
2012-10-26Add missing CTLFLAG_TUN flag to tunable sysctls in USB stack.Hans Petter Selasky
Rearrange the tunables and belonging sysctl declarations, so that they are next to eachother. Submitted by: n_hibma @ MFC after: 1 week Notes: svn path=/head/; revision=242126
2012-09-09Add support for DWC OTG.Hans Petter Selasky
Notes: svn path=/head/; revision=240281
2012-03-03Make sure that the USB system suspend event is executed synchronouslyHans Petter Selasky
and not asynchronously. This fixes problems related to USB system suspend and resume. It is assumed that we are always allowed to sleep from the device_suspend() method. MFC after: 1 week Submitted by: jkim Notes: svn path=/head/; revision=232448
2012-01-02Make sure we probe and attach the root HUB afterHans Petter Selasky
resume else no devices will appear again. MFC after: 1 day Notes: svn path=/head/; revision=229317
2011-12-24- Enable usbus on octusbOleksandr Tymoshenko
Notes: svn path=/head/; revision=228854
2011-12-19Make the recently added "no_shutdown_wait" sysctl writeable.Hans Petter Selasky
Suggested by: avg @ MFC after: 3 days Notes: svn path=/head/; revision=228723
2011-12-19Add code to wait for USB shutdown to be executed at system shutdown.Hans Petter Selasky
Add sysctl which can be used to skip this waiting. MFC after: 3 days Notes: svn path=/head/; revision=228711
2011-12-19Add missing unlock of USB controller's lock, whenHans Petter Selasky
doing shutdown, suspend and resume. Suggested by: avg @ MFC after: 3 days Notes: svn path=/head/; revision=228709
2011-12-14Implement better support for USB controller suspend and resume.Hans Petter Selasky
This patch should remove the need for kldunload of USB controller drivers at suspend and kldload of USB controller drivers at resume. This patch also fixes some build issues in avr32dci.c MFC after: 2 weeks Notes: svn path=/head/; revision=228483
2011-11-07Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.Ed Schouten
The SYSCTL_NODE macro defines a list that stores all child-elements of that node. If there's no SYSCTL_DECL macro anywhere else, there's no reason why it shouldn't be static. Notes: svn path=/head/; revision=227309
2011-02-26- Correct USB 3.0 wire-speed to 5.0GbpsHans Petter Selasky
MFC after: 3 days Approved by: thompsa (mentor) Notes: svn path=/head/; revision=219048
2011-02-09Minor cleanup:Hans Petter Selasky
- use device_printf() instead of printf() to give more accurate warnings. - use memcpy() instead of bcopy(). - add missing #if's for non-FreeBSD compilation. Approved by: thompsa (mentor) Notes: svn path=/head/; revision=218475
2011-01-18Make USB packet filtering code optional.Hans Petter Selasky
Approved by: thompsa (mentor) Notes: svn path=/head/; revision=217558
2011-01-11Remove unneeded includes of <sys/linker_set.h>. Other headers that useJohn Baldwin
it internally contain nested includes. Reviewed by: bde Notes: svn path=/head/; revision=217265