summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/usb.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Reject USB requests that could damage the bus integrity, just like itmpi2015-09-011-2/+11
| | | | | | is done in ugen(4). Found by Grant Czajkowski during the GSoC 2015.
* Remove some includes include-what-you-use claims don'tjsg2015-03-141-2/+1
| | | | | | | have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
* First step towards making uiomove() take a size_t size argument:miod2015-02-101-4/+4
| | | | | | | - rename uiomove() to uiomovei() and update all its users. - introduce uiomove(), which is similar to uiomovei() but with a size_t. - rewrite uiomovei() as an uiomove() wrapper. ok kettenis@
* Trim blank lines.uebayasi2015-02-091-3/+1
|
* Always allow abort tasks to be scheduled, even if the device is beeingmpi2015-01-131-9/+11
| | | | | | | | | | | | | | detached, in order to prevent a deadlock situation. This situation can occur if the thread detaching a device is sleeping, waiting for all submitted transfers to finish, and the device's pipes have not yet been aborted. This can happen when a USB Ethernet device is being detached while a userland program is doing an ioctl(2). Abort tasks need to be able to run in such case since timed out transfers rely on them to be properly completed. ok deraadt@
* If a host controller has been detached or reported a halt condition itmpi2014-12-181-1/+8
| | | | | | | | | | | | | | | should be considered as dead. In such condition the stack no longer submits I/O or schedules any USB task for its bus. However we need an explore task to detach the root hub since only the task thread is supposed to discover buses and attach/detach devices in order to avoid races. So reset the bus' dying flag when marking it as disconnecting in order to let the task be scheduled. This should be safe because a detached or halted HC should not trigger any new interrupt. Fix a panic when detaching USB PCMCIA cards reported by Tilo Stritzky.
* Since USB xfer pools are accessed in interrupt context, initialize themmpi2014-08-101-3/+2
| | | | with the correct ipl to prevent your CPU from locking against itself.
* Do not store the whole USB hub descriptor in the "struct usbd_hub"mpi2014-08-091-3/+3
| | | | to help integrating super speed hubs that use a different descriptor.
* add a size argument to free. will be used soon, but for now default to 0.tedu2014-07-121-4/+4
| | | | after discussions with beck deraadt kettenis.
* Be less verbose with task debug messages and kill some trailingmpi2014-07-111-20/+17
| | | | whitespaces while here.
* autoconf(9) is your friend and it knows you more than you think. Itmpi2014-07-091-3/+5
| | | | | | | | | even knows your children! So let him handle the seperation correctly. Do not rewrite your own custom config_detach_children(9) and as a bonus start removing the usbd_port tentacles from the stack. ok pirofti@, yuo@, miod@, deraadt@
* Apart from the early exploration done to find a console keyboard duringmpi2014-05-281-15/+21
| | | | | | | | | | | the boot process, USB devices must be attached or detached from the usb task thread in order to avoid races with periodical explorations issued by uhub(4) interrupts. Respect this rule when detaching root hubs during a suspend/resume cycle and avoid some hangs due to the aforementioned race. Tested by Mattieu Baptiste, thanks!
* The relation between uhci(4), ohci(4) and their root hub device ismpi2014-05-111-2/+11
| | | | | | | | | | | | | | | | delicate. HC drivers do not always accept to be left alone. I don't know if it is a love crisis, but apparently receiving a root hub status change interrupt before having an uhub(4) attached breaks resume. So make sure the root hub is re-attached before interrupt get enabled. It is safe to do it during DVACT_RESUME since attaching root hubs do not require any USB transfer. Based on a diff from yasuoka@, fix a regression introduced in last commit an reported by Abel Abraham Camarillo Ojeda on tech@ and Nils R on bugs@.
* Force the detach of all USB devices by disconnecting the root hubsmpi2014-03-311-40/+61
| | | | | | | | | | before suspending the machine. Prior to this commit, devices were logically disconnected after resuming the machine leading to funny races since the controller was reset in between. ok deraadt@
* Attach to host controller drivers advertising USB 3.0 support and assignmpi2014-03-081-5/+5
| | | | | the correct speed. This has no effect for the moment since there is no such driver in our tree, but something tells me it might change soon.
* Add a DVACT_WAKEUP op to the *_activate() API. This is called after thederaadt2013-12-061-8/+4
| | | | | | | | kernel resumes normal (non-cold, able to run processes, etc) operation. Previously we were relying on specific DVACT_RESUME op's in drivers creating callback/threads themselves, but that has become too common, indicating the need for a built-in mechanism. ok dlg kettenis, tested by a sufficient amount of people
* Enforce ca_activate tree-walks over the entire heirarchy for all events,deraadt2013-05-301-1/+8
| | | | | | cleaning up some shutdown-hook related code on the way. (A few drivers related to sparc are still skipped at kettenis' request) ok kettenis mlarkin, tested by many others too
* Don't leak information to userland in case the actual transfer length ismpi2013-05-171-1/+4
| | | | | | | | | | smaller than the requested one. From ws@NetBSD via miod@. This problem can only occur when the USBD_SHORT_XFER_OK flag is set, otherwise completed transfers with a length smaller than the one submitted are treated as errors. ok miod@
* Give back to usb(4) what is usb(4)'s. In other words use the usb_* prefixmpi2013-04-261-28/+21
| | | | | | | for functions related to the usb(4) driver and keep usbd_* for generic USB layer functions. ok mglocker@
* Rename usbd_fill_*_task() to usb_fill_*_task().mglocker2013-04-191-10/+10
|
* Move over function prototypes from ubsdi.h to usb.c which just get usedmglocker2013-04-181-13/+16
| | | | | | there. Some spacing while here. Suggested and ok mpi@
* Add new ioctl command USB_DEVICE_GET_DDESC to usb(4) to retrieve themglocker2013-04-171-1/+20
| | | | | | device descriptor. Help and ok mpi@
* Get rid of various 'typedef struct' definitions and use plain structuremglocker2013-04-151-15/+15
| | | | | | | | | definitions instead. We don't change usb.h for now to stay compatible with userland. Tested by mpi@ on macppc and myself on i386. ok mpi@
* Add new ioctl's USB_DEVICE_GET_CDESC and USB_DEVICE_GET_FDESC to usb(4).mglocker2013-04-081-1/+119
| | | | | | | Those are the equivalents for ugen(4)'s USB_GET_CONFIG_DESC and USB_GET_FULL_DESC. Help and OK mpi@, jmc@
* proc.h is way too much header for usb to handle.tedu2013-03-281-2/+1
|
* you probably don't need to include vnode.h or reboot.h. you most definitelytedu2013-03-281-2/+1
| | | | | absolutely do not need to include vnode.h because it includes uvm_extern.h and you want the idiotic TRUE FALSE defines from uvm.
* Remove the 4.8 version of the USB device info ioctl.mpi2013-03-161-21/+1
| | | | ok deraadt@
* Don't use a pointer to an opaque softc, we'll need to access its unitmpi2012-05-151-7/+8
| | | | | | number. No functional change. ok miod@
* Returns different errors for USB_REQUEST if the address specifiedmpi2012-05-121-3/+4
| | | | | | is invalid or valid but with no device found. ok miod@
* Force usb_needs_explore() at DVACT_RESUME time; from Alexander Polakovderaadt2012-01-281-1/+4
| | | | Might help a few laptops resume their usb devices better.
* usbdivar.h needs struct timeout. But don't get it indirectly viakrw2011-09-181-1/+2
| | | | | | | sys/kthread.h, use sys/timeout.h explicitly. Noted by Michael Knudsen. ok deraadt@ kettenis@ guenther@
* Remove config_activate() and DVACT_ACTIVATE. PCMCIA's the only thingmatthew2011-07-031-3/+1
| | | | | | | | that's ever used it, and it's long since been changed to use DVACT_{QUIESCE,SUSPEND,RESUME} instead. ok deraadt@, dlg@; miod@ also agreed with this idea when I brought it up a few weeks ago
* remove horrible abuse of kthread_create_deferred(9). this was beingjakemsr2011-04-281-46/+36
| | | | | | | | | | | | used to "do things later" and was potentially sleeping in swapper context. the latter is really bad, because it might never wake up. instead, move the things that usb_first_explore() was doing to the first run of the explore task. since tasks are run in a kthread, they are in process context and ok to sleep. fixes boot hang noticed by jsg@, which mikeb@ debugged and found usb_first_explore() to be sleeping swapper context
* bring back changes in usb.c revision 1.73jakemsr2011-02-091-46/+111
| | | | | | | | | | | | | | | | date: 2011/02/04 08:21:39; author: jakemsr; state: Exp; lines: +85 -34 * merge 'onqueue' and 'running' members of struct usb_task into a new member, 'state'. * add new function 'usb_wait_task()', which waits for queued or running usb_tasks to complete. * in the USB_DEVICEINFO ioctl, fill struct usb_device_info in a usb_task, thereby avoiding races against driver attach/detach. but this time make the state a bitmask, since it is valid to be added to the task queue while the task is running. also be more careful about waking up the task when state changes. ok miod@
* revert usb.c to r1.72, and all subsequent changes that depend on it.jakemsr2011-02-091-85/+34
| | | | this is causing problems with suspend/resume for some people.
* * merge 'onqueue' and 'running' members of struct usb_task intojakemsr2011-02-041-34/+85
| | | | | | | | | | a new member, 'state'. * add new function 'usb_wait_task()', which waits for queued or running usb_tasks to complete. * in the USB_DEVICEINFO ioctl, fill struct usb_device_info in a usb_task, thereby avoiding races against driver attach/detach. ok miod@
* garbage collect "usb events". without /dev/usb there is no way to accessjakemsr2011-01-251-241/+1
| | | | | | them from userland, and nothing in the kernel uses them. ok krw@, miod@
* * add 'udi_serial' to struct usb_device_info.jakemsr2011-01-151-1/+21
| | | | | | | * fill 'udi_serial' with the serial number in usbd_fill_deviceinfo(). * add compatability ioctl/struct so old binaries continue to work. discussed with deraadt and miod
* * check that the root hub has been configured before trying tojakemsr2010-12-061-9/+11
| | | | | | free it's resources * use usbd_is_dying() instead of directly checking the device's bus dying flag
* create another kthread to run xfer abort tasks. xfer abort tasks cannotjakemsr2010-10-231-22/+89
| | | | | | | | | | | be run from the generic task kthread, because xfers that need to be aborted block newly queued tasks from running (i.e. the xfer to be aborted blocks the abort of that task). as there are now three types of usb tasks, add an argument to usb_init_task() and another member to struct usb_task to specify the task type. fixes boot hangs that are showing up because we now use usb tasks to attach/detach usb devices.
* add two members to struct usb_taskjakemsr2010-09-231-2/+25
| | | | | | | | | | | | | | | * usbd_device_handle dev - the device responsible for the task. use this to not run the task if the device's hub is dying. * int running - a flag to be set when the task is running. add usb_rem_wait_task(), a wrapper for usb_rem_task() that waits for the task to complete if the task is already running. s/usb_rem_task/usb_rem_wait_task/ in usb_detach(). probably most drivers using usb_tasks should do this as well. although device attach/detach is serialized in normal cases, in the special case where the usb bus is hotpluggable (like cardbus/pcmcia), devices are not detached in the task thread.
* add a 'dying' flag to struct usbd_bus. use this to signify the busjakemsr2010-09-231-12/+15
| | | | | | | | | is dying, instead of setting a flag in struct usb_softc. as usbd_device_handle has a pointer to the usbd_bus it's attached to, usb devices, and functions they run or functions run on their behalf, can now easily check if their bus is dying. use this to stop usbd_do_request* from running and the usb task thread from adding new tasks when a device's bus is dying.
* instead of waiting the full power-up-to-power-steady time for rootjakemsr2010-09-231-3/+12
| | | | | | | hubs before their first port explore, check how long it's actually been since power up and only wait as necessary. saves a little time on boot, especially now that explore tasks are serialized. ok yuo@
* instead of running usb_explore() from individual kthreads for eachjakemsr2010-09-231-107/+123
| | | | | | | USB bus, make usb_explore() a usb_task. reduces races during normal USB device detach, since now usb_tasks and detach happen in the same process. ok yuo@, matthew@ helped with the task thread loop
* rename usb_discover to usb_explore for consistency.jakemsr2010-09-231-7/+7
| | | | OK krw
* In xxactivate() DVACT_DEACTIVATE, when calling a series of config_deactivate()deraadt2010-08-311-5/+7
| | | | | | for sub-devices, return the last error return value instead of |'ing the failures together and creating some value that is non-0 (bravo!) but potentially loses the specific error value...
* Every selwakeup() should have a matching KNOTE() (even if kqueue isn'tnicm2009-11-091-2/+1
| | | | | | | | | | supported it doesn't do any harm), so put the KNOTE() in selwakeup() itself and remove it from any occurences where both are used, except one for kqueue itself and one in sys_pipe.c (where the selwakeup is under a PIPE_SEL flag). Based on a diff from tedu. ok deraadt
* Get rid of __HAVE_GENERIC_SOFT_INTERRUPTS now that all our platforms support it.kettenis2009-11-041-9/+2
| | | | ok jsing@, miod@
* Add missing KNOTE() calls after selwakeup(), until we decide if the KNOTE()deraadt2009-10-311-1/+2
| | | | | | | calls can go directly into selwakeup() safely long discussion with nicm, murmers of consent from tedu and miod, noone else seems to care of kqueue is busted as long as it makes their sockets move data fast... pretty sad.
* Get rid of devact enum, substitute it with an int and coresponding defines.pirofti2009-10-131-3/+3
| | | | | | This is needed for the addition of further suspend/resume actions. Okay deraadt@, marco@.