summaryrefslogtreecommitdiff
path: root/sys/dev/usb/controller/usb_controller.c
Commit message (Collapse)AuthorAgeFilesLines
* Improve the realtime properties of USB transfers for embedded systemsHans Petter Selasky2015-08-141-4/+10
| | | | | | | | | | | | | | | | | | | | | | | 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
* Resolve a special case deadlock: When two or more threads areHans Petter Selasky2015-01-131-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add 64-bit DMA support in the XHCI controller driver.Hans Petter Selasky2015-01-051-1/+1
| | | | | | | | | | - Fix some comments and whitespace while at it. MFC after: 1 month Submitted by: marius@ Notes: svn path=/head/; revision=276717
* Make a bunch of USB debug SYSCTLs tunable, so that their value(s) canHans Petter Selasky2015-01-051-1/+1
| | | | | | | be set before the USB device(s) are probed. Notes: svn path=/head/; revision=276701
* Refine support for disabling USB enumeration to allow device detachHans Petter Selasky2014-10-091-10/+1
| | | | | | | | | and suspend and resume of existing devices. MFC after: 2 weeks Notes: svn path=/head/; revision=272807
* Add support for disabling USB enumeration in general or on selectedHans Petter Selasky2014-10-081-1/+10
| | | | | | | | | USB HUBs. MFC after: 2 weeks Notes: svn path=/head/; revision=272733
* Rename driver name a bit to avoid unit number confusion in dmesg.Hans Petter Selasky2014-08-051-1/+1
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=269565
* Pull in r267961 and r267973 again. Fix for issues reported will follow.Hans Petter Selasky2014-06-281-6/+3
| | | | Notes: svn path=/head/; revision=267992
* Revert r267961, r267973:Glen Barber2014-06-271-3/+6
| | | | | | | | | | | | | 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
* Extend the meaning of the CTLFLAG_TUN flag to automatically check ifHans Petter Selasky2014-06-271-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Avoid the USB device disconnected and controller shutdown clutter on systemMarius Strobl2014-06-101-2/+3
| | | | | | | | | | | | 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
* Resolve a deadlock setting the USB configuration index from userspaceHans Petter Selasky2014-06-081-1/+7
| | | | | | | | | | | | | 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
* Make WITNESS happy by giving USB mutexes different names.Hans Petter Selasky2014-06-071-2/+2
| | | | | | | | Reported by: trociny @ MFC after: 3 days Notes: svn path=/head/; revision=267212
* Hook the ISP/SAF1761 driver into MIPS kernel builds.Hans Petter Selasky2014-05-291-1/+1
| | | | | | | | | | | | - 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
* - Add softc pointer argument to FIFO functions as an optimisation.Hans Petter Selasky2014-05-181-0/+4
| | | | | | | | | | | - 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
* - Allow the SAF1761 driver to attach to the root HUB USB driver.Hans Petter Selasky2014-05-161-0/+1
| | | | | | | Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=266216
* Fix typos.Hans Petter Selasky2013-12-081-4/+4
| | | | | | | Found by: remko Notes: svn path=/head/; revision=259095
* Improve the XHCI command timeout recovery handling code.Hans Petter Selasky2013-12-061-0/+53
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=259023
* Add convenience wrapper functions to run callbacks in the context of theHans Petter Selasky2013-04-231-0/+25
| | | | | | | USB explore thread. Notes: svn path=/head/; revision=249795
* Resolve a LOR after r246616. Protect control requests using the USB deviceHans Petter Selasky2013-02-131-6/+12
| | | | | | | | | | | | 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
* Add defines to more easily allow a single threaded version of the FreeBSDHans Petter Selasky2013-02-051-28/+30
| | | | | | | USB stack. This is useful for non-kernel purposes, like the loader. Notes: svn path=/head/; revision=246363
* Use DEVMETHOD_END macro defined in sys/bus.h instead of {0, 0} sentinel on ↵Sofian Brabez2013-01-301-1/+2
| | | | | | | | | | device_method_t arrays Reviewed by: cognet Approved by: cognet Notes: svn path=/head/; revision=246128
* Modify the FreeBSD USB kernel code so that it can be compiled directlyHans Petter Selasky2013-01-301-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add missing CTLFLAG_TUN flag to tunable sysctls in USB stack.Hans Petter Selasky2012-10-261-1/+1
| | | | | | | | | | | 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
* Add support for DWC OTG.Hans Petter Selasky2012-09-091-0/+3
| | | | Notes: svn path=/head/; revision=240281
* Make sure that the USB system suspend event is executed synchronouslyHans Petter Selasky2012-03-031-2/+21
| | | | | | | | | | | | 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
* Make sure we probe and attach the root HUB afterHans Petter Selasky2012-01-021-0/+8
| | | | | | | | | resume else no devices will appear again. MFC after: 1 day Notes: svn path=/head/; revision=229317
* - Enable usbus on octusbOleksandr Tymoshenko2011-12-241-0/+1
| | | | Notes: svn path=/head/; revision=228854
* Make the recently added "no_shutdown_wait" sysctl writeable.Hans Petter Selasky2011-12-191-1/+1
| | | | | | | | Suggested by: avg @ MFC after: 3 days Notes: svn path=/head/; revision=228723
* Add code to wait for USB shutdown to be executed at system shutdown.Hans Petter Selasky2011-12-191-1/+15
| | | | | | | | | Add sysctl which can be used to skip this waiting. MFC after: 3 days Notes: svn path=/head/; revision=228711
* Add missing unlock of USB controller's lock, whenHans Petter Selasky2011-12-191-0/+12
| | | | | | | | | | doing shutdown, suspend and resume. Suggested by: avg @ MFC after: 3 days Notes: svn path=/head/; revision=228709
* Implement better support for USB controller suspend and resume.Hans Petter Selasky2011-12-141-16/+231
| | | | | | | | | | | | | 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
* Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.Ed Schouten2011-11-071-1/+1
| | | | | | | | | 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
* - Correct USB 3.0 wire-speed to 5.0GbpsHans Petter Selasky2011-02-261-1/+1
| | | | | | | | MFC after: 3 days Approved by: thompsa (mentor) Notes: svn path=/head/; revision=219048
* Minor cleanup:Hans Petter Selasky2011-02-091-4/+4
| | | | | | | | | | | - 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
* Make USB packet filtering code optional.Hans Petter Selasky2011-01-181-2/+4
| | | | | | | Approved by: thompsa (mentor) Notes: svn path=/head/; revision=217558
* Remove unneeded includes of <sys/linker_set.h>. Other headers that useJohn Baldwin2011-01-111-1/+0
| | | | | | | | | it internally contain nested includes. Reviewed by: bde Notes: svn path=/head/; revision=217265
* Removes a unused function `usb_bus_find'.Weongyo Jeong2010-11-251-26/+0
| | | | Notes: svn path=/head/; revision=215846
* Handles the unit number correctly that the previous commit had a problemWeongyo Jeong2010-11-251-4/+4
| | | | | | | | | | | (wrong unit number for a host controller) when the module is load / unloaded repeatly. Attaching the USB pf is moved to usbus device's attach. Pointed by: yongari Notes: svn path=/head/; revision=215812
* Removes all duplicated code with BPF that it's greatly simplified andWeongyo Jeong2010-11-241-1/+1
| | | | | | | | | | take all benefits whenever BPF code is improved. Pointed by: jkim Reviewed by: thompsa Notes: svn path=/head/; revision=215802
* Adds a USB packet filter feature to the stack that it could captureWeongyo Jeong2010-11-221-0/+32
| | | | | | | | | | | | packets which go through each USB host controllers. Its implementations are almost based on BPF code and very similar with it except it's little bit customized for USB packet only. The userland program usbdump(8) would be committed soon. Discussed with: hps, thompsa, yongari Notes: svn path=/head/; revision=215649
* This commit adds full support for USB 3.0 devices in host and deviceHans Petter Selasky2010-10-041-0/+6
| | | | | | | | | | | | | | | | | | | 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) Notes: svn path=/head/; revision=213435
* Add missing DRIVER_MODULE() entry for the musbotg driver.Hans Petter Selasky2010-10-041-0/+4
| | | | | | | | | Add some more comments. Approved by: thompsa (mentor) Notes: svn path=/head/; revision=213426
* The root mount hold reference was not released on USB controllerHans Petter Selasky2010-10-041-8/+14
| | | | | | | | | attach failures during boot. Fix this. Approved by: thompsa (mentor) Notes: svn path=/head/; revision=213425
* Add missing ifdefs for usb power saving support.Andrew Thompson2010-05-121-1/+4
| | | | | | | Submitted by: Hans Petter Selasky Notes: svn path=/head/; revision=208013
* Wrap the proc wakeup special case for ddb in ifdef DDB.Andrew Thompson2010-03-111-0/+6
| | | | | | | Submitted by: Giovanni Trematerra Notes: svn path=/head/; revision=205005
* Remove overuse of exclamation marks in kernel printfs, there mere fact aAndrew Thompson2009-11-261-3/+3
| | | | | | | | | 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. Notes: svn path=/head/; revision=199816
* MFp4 @ 168387Andrew Thompson2009-09-281-4/+2
| | | | | | | | | | | | | | | | | | | - 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 Notes: svn path=/head/; revision=197553
* - allow disabling "root_mount_hold()" byAlfred Perlstein2009-08-241-73/+29
| | | | | | | | | | setting a sysctl/tunable at boot - remove some redundant initial explore code Submitted by: hps Notes: svn path=/head/; revision=196488
* Temporarily revert the new-bus locking for 8.0 release. It will beJohn Baldwin2009-08-201-9/+21
| | | | | | | | | reintroduced after HEAD is reopened for commits by re@. Approved by: re (kib), attilio Notes: svn path=/head/; revision=196403