summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/usb.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* update some usb.org URLs following reorganisation, add a new one for updsthen2021-01-291-3/+2
| | | | partly from Alessandro Ricci
* Don't rely on wTotalLength for usbd_get_cdesc() malloc/free but on themglocker2020-09-021-4/+4
| | | | | | | | actual length which has been allocated. We saw cases where the wTotalLength value is changing on a second read, e.g. when a USB device was waked up from sleep mode. ok mpi@
* Fix a potential panic during free(9) which can be caused by an USBmglocker2020-08-271-4/+4
| | | | | | | | | | | device which returns a spurious value for wTotalLength on a configuration descriptor request. Therefore don't relay on wTotalLength for free(9) but on the length variable which was used for the malloc(9) before. The issue was reported by Mikolaj Kucharski <mikolaj (at) kucharski (dot) name> on bugs@. Discussed and ok deraadt@
* tsleep(9) to tsleep_nsec(9) conversions.mpi2019-10-061-4/+5
| | | | ok visa@, kn@, cheloha@
* No need to call usbd_fill_deviceinfo() from a task, it doesn't generate I/O.mpi2019-01-091-38/+2
| | | | ok visa@
* Use "%s", __func__ in DPRINTF() to reduce grep noise.mpi2018-11-181-3/+3
|
* free(9) sizes for configuration descriptors, missed in previous.mpi2018-11-141-3/+3
|
* remove shadow variables for 'error' in usbioctl(); ok mpi@ ratchov@miko2018-08-311-3/+1
|
* Simplify/refactor the way vendor/product/serial informations arelandry2018-05-011-2/+2
| | | | | | | | | | | | | | | | | | gathered from usb devices. Cache them early in usbd_new_device() instead of querying the device several times (the content wont change anyway) and uselessly generating usb traffic (which could conflict with other access..) The heuristic stays the same, first look in the device descriptor, then try to match against usb_known_vendors/usb_known_products, then fallback to use the idVendor/idProduct codes. Remove the now useless 'usedev' parameter from usbd_fill_deviceinfo(). Tested from bsd & bsd.rd. suggested by and ok mpi@
* Support dumping isochronous frames via bpf(4) using the USBPcap protocol.mpi2018-02-261-13/+44
| | | | ok deraadt@, ratchov@
* Add a default case to a usb_tap() switch statement which mpi@ says willjsg2018-02-191-1/+3
| | | | | | | never be called to convince compilers and static analysis tools a path that uses uninitialised memory does not exist. ok krw@ mpi@
* Remove almost unused `flags' argument of suser().mpi2018-02-191-2/+2
| | | | | | | The account flag `ASU' will no longer be set but that makes suser() mpsafe since it no longer mess with a per-process field. No objection from millert@, ok tedu@, bluhm@
* Add support for dumping USB transfers via bpf(4) using USBPcap headers.mpi2018-02-031-1/+101
| | | | ok deraadt@, dlg@
* Remove useless conditional before free().ians2017-07-291-3/+2
| | | | ok mpi@
* Do not permit USB ioctl handler malloc(9)'s to block as this interferesians2017-07-211-2/+5
| | | | | | with expected behavior. OK mpi@ patrick@
* A pile of sizes to free(9). In test for a few days in snapshots.deraadt2017-04-081-8/+9
| | | | | Errors will result in nice clean panic messages so we know what's wrong. Reviewed by dhill visa natano jsg.
* Cache vendor, product and serial info for each usb device. This allowspatrick2016-05-181-2/+2
| | | | | | | | | | | ioctl(USB_DEVICEINFO) not to issue any further requests to gather information. Thus reducing stress on connected usb devices. This fixes an issue where usbdevs called in a loop causes a USB mass storage device to halt operation. Adapted from a similar commit in NetBSD. ok mpi@
* Convert uiomovei to uiomove. Fixes a few integer truncations along thestefan2016-03-031-8/+9
| | | | | | way. ok natano@
* If usb_fill_udf_task() failed to fill the struct, udf_data stillbluhm2016-01-221-1/+2
| | | | | | contained the pointer it received from user land. usbioctl() has to reset it, otherwise user supplied data is passed to free(). OK mpi@
* 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@