Commit Graph

55 Commits

Author SHA1 Message Date
Andrew Thompson
a7aca4cd92 Implement USB kernel driver detach from userland.
Submitted by:	Hans Petter Selasky
2010-03-11 21:50:36 +00:00
Andrew Thompson
d84a79e731 Improve u3g device ejecting by providing additional methods for the eject
command in the usb_msctest routines, as well as a general tidyup.

This now properly ejects the ZTE MF636, Option Gi0322 and Novatel MC950D
devices I have on my desk.
2010-01-06 22:14:05 +00:00
Andrew Thompson
c10e1453e7 scratch_size was incorrectly passed as language ID when retrieving the language
ID table, this broke string retrieval on some devices.

Submitted by:	Hans Petter Selasky
Reported by:	Renato Botelho
2010-01-06 21:46:08 +00:00
Andrew Thompson
2a4c6157ca Use the EVENTHANDLER system to hook into the usb device configuration and
perform a function such as ejecting a 3G autoinstaller disk. The eventhandler
system properly tracks threads and is safe to unload, remove the
setting/clearing of a function pointer in the kernel by u3g(4) which included a
tsleep for safety.
2009-12-17 21:42:10 +00:00
Andrew Thompson
767cb2e29d Remove overuse of exclamation marks in kernel printfs, there mere fact a
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.
2009-11-26 00:43:17 +00:00
Andrew Thompson
f12c6c2913 Improve High Speed slot allocation mechanism by moving the computation to the
endpoint rather than per xfer and provide functions around get/free of resources.

Submitted by:	Hans Petter Selasky
2009-11-22 21:16:43 +00:00
Andrew Thompson
35e0e60378 Correct buffer sizes used so that they match. The old code could give the
impression that a overflow situation existed but was not possible.

Reported by:	kib
Submitted by:	Hans Petter Selasky
2009-09-28 07:42:59 +00:00
Andrew Thompson
7a918edff2 Add support for USB language selection.
PR:		usb/138563
Reported by:	Bruce Cran
Submitted by:	Hans Petter Selasky
2009-09-28 07:41:17 +00:00
Andrew Thompson
a9e267575b Fix NULL-pointer dereference in usb_endpoint_foreach().
PR:		usb/138389
Submitted by:	Patroklos Argyroudis at census, inc
2009-09-28 07:39:51 +00:00
Andrew Thompson
d88688c7da MFp4 @ 168387
- 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
2009-09-28 07:01:54 +00:00
Alfred Perlstein
cb18f7d12b - Patch to allow USB controller to resume operation after
being polled.

         - Remove the need for Giant from the USB HUB driver.

         - Leave device unconfigured instead of disabling the USB port
           when Huawei Autoinstall disk detection triggers. This should
           fix problems that the Huawei device is not detected after
           Autoinstall eject is issued.
         - Reported by: Nikolay Antsiferov

         - Fix memory use after free race for USB character devices.
         - Reported by: Lucius Windschuh

         - Factor out the enumeration lock into three functions to make the
         coming newbus lock conversion more easy.
          - usbd_enum_lock
          - usbd_enum_unlock
          - usbd_enum_is_locked

Submitted by:	hps
2009-08-24 05:05:38 +00:00
Alfred Perlstein
bd73b18714 USB core:
- add support for defragging of written device data.
- improve handling of alternate settings in device side mode.
- correct return value from usbd_get_no_alts() function.
- reported by: HPS
- P4 ID: 166156, 166168

- report USB device release information to devd and pnpinfo.
- reported by: MIHIRA Sanpei Yoshiro
- P4 ID: 166221

Submitted by:	hps
Approved by:	re
2009-07-30 00:15:50 +00:00
Andrew Thompson
29bd7d7e9a Sync to p4
- Add support for devices that handle set and clear stall in hardware.
 - Add missing get timestamp function
 - Add more xfer flags

Submitted by:	Hans Petter Selasky
Approved by:	re (kib)
2009-06-27 21:23:30 +00:00
Andrew Thompson
ed6d949afd - Make struct usb_xfer opaque so that drivers can not access the internals
- Reduce the number of headers needed for a usb driver, the common case is just   usb.h and usbdi.h
2009-06-23 02:19:59 +00:00
Andrew Thompson
3c8d24f43b Fix usb2_find_descriptor function name. 2009-06-15 22:38:05 +00:00
Andrew Thompson
a593f6b8de s/usb2_/usb_|usbd_/ on all function names for the USB stack. 2009-06-15 01:02:43 +00:00
Andrew Thompson
8437751d86 Remove usb2_cv_* and just use the kernel condvar implementation, it was needed
earlier since condition variables didnt work with Giant but this was fixed 10
months ago.
2009-06-15 00:33:18 +00:00
Andrew Thompson
ae60fdfba2 Rename usb pipes to endpoints as it better represents what they are, and struct
usb_pipe may be used for a different purpose later on.
2009-06-07 19:41:11 +00:00
Andrew Thompson
e0a69b51ac s/usb2_/usb_/ on all typedefs for the USB stack. 2009-05-29 18:46:57 +00:00
Andrew Thompson
28212de200 Free device strings.
Spotted by:	HPS
2009-05-29 16:15:56 +00:00
Andrew Thompson
760bc48e7e s/usb2_/usb_/ on all C structs for the USB stack. 2009-05-28 17:36:36 +00:00
Andrew Thompson
c86aead66c Allocate the usb serial, manufacturer and product strings rather than use char
arrays in the usb_device struct. This also eliminates USB_HAVE_STRINGS.
2009-05-27 23:12:02 +00:00
Andrew Thompson
9360ae4073 Rename the usb sysctl tree from hw.usb2.* back to hw.usb.*.
Submitted by:	Hans Petter Selasky
2009-05-21 01:48:42 +00:00
Andrew Thompson
8d2dd5dd85 Use enums for speed and rev data types. 2009-05-21 01:05:21 +00:00
Andrew Thompson
f29a072444 - rename usb2_mode to usb_mode [1]
- change variable types to use the enum

Submitted by:	Hans Petter Selasky [1]
2009-05-21 00:04:17 +00:00
Andrew Thompson
ec8f31275d Revert part of r191494 which used the udev state to mark suspending, this needs
to be set via two variables (peer_suspended and self_suspended) and can not be
merged into one.

Submitted by:	Hans Petter Selasky
Pointy hat:	me
2009-05-05 15:36:23 +00:00
Andrew Thompson
4d4fa6edd4 Make the state string descriptions public. 2009-04-25 21:25:52 +00:00
Andrew Thompson
bd21677868 Track the usb device state as its powered on, addressed and configured. This helps
to avoid touching the device when it is not going to respond and would otherwise
timeout.

Implement the suspend tracking as a udev state too.
2009-04-25 21:10:06 +00:00
Andrew Thompson
459d369ee2 MFp4 //depot/projects/usb@160930
Change the roothub exec functions to take the usb request and data pointers
directly rather than placing them on the parent bus struct.

Submitted by:	Hans Petter Selasky
2009-04-22 17:08:16 +00:00
Andrew Thompson
9469c92974 MFp4 //depot/projects/usb@160655
Fix possible issue with clear-stall and set-config happening at the same time.

Submitted by:	Hans Petter Selasky
2009-04-22 17:08:04 +00:00
Andrew Thompson
88b4e0abcf MFp4 //depot/projects/usb@160614
Fix errornous printout.

Submitted by:	Hans Petter Selasky
2009-04-22 17:07:59 +00:00
Andrew Thompson
495f25cedc MFp4 //depot/projects/usb@160413
Use direct reference to parent high-speed HUB instead of indirect, due to
pointer clearing race at detach of parent USB HUB.

Reported by:	kientzle
Submitted by:	Hans Petter Selasky
PR:		usb/133545
2009-04-22 17:07:53 +00:00
Andrew Thompson
fde875265f Provide a better commit log for r190735, forced by making a whitespace change.
Refactor how we interface with the root HUB. This is achieved by making a
direct call from usb2_do_request to the host controller for root hub requests,
this call will perform the controller specific register read/writes and return
the error code.

This cuts out a lot of code in the host controller files and saves one thread
per USB bus.

Submitted by:	Hans Petter Selasky
2009-04-06 00:22:49 +00:00
Andrew Thompson
9f2b42e596 MFp4 //depot/projects/usb@160056
Remove code for unused and unlikely quirk, "uq_power_claim"

Submitted by:	Hans Petter Selasky
2009-04-05 18:22:13 +00:00
Andrew Thompson
03797f3300 MFp4 //depot/projects/usb@159948
Add more debugging output on enumeration failures.

Submitted by:	Hans Petter Selasky
2009-04-05 18:21:31 +00:00
Andrew Thompson
3930731567 MFp4 //depot/projects/usb@159922
Refactor how we interface with the root HUB. This cuts around 1200 lines of
code totally and saves one thread per USB bus.

Submitted by:	Hans Petter Selasky
2009-04-05 18:20:49 +00:00
Andrew Thompson
4eae601ebd MFp4 //depot/projects/usb@159909
- make usb2_power_mask_t 16-bit
- remove "usb2_config_sub" structure from "usb2_config". To compensate for this
  "usb2_config" has a new field called "usb_mode" which select for which mode
  the current xfer entry is active. Options are: a) Device mode only b) Host
  mode only (default-by-zero) c) Both modes.  This change was scripted using
  the following sed script: "s/\.mh\././g".
- the standard packet size table in "usb_transfer.c" is now a function, hence
  the code for the function uses less memory than the table itself.

Submitted by:	Hans Petter Selasky
2009-04-05 18:20:38 +00:00
Andrew Thompson
51ec16035f MFp4 //depot/projects/usb@159897
Add new endpoint direction values for use with usb2_config

Submitted by:	Hans Petter Selasky
2009-04-05 18:20:13 +00:00
Andrew Thompson
63521bbc5a MFp4 //depot/projects/usb@159871
- bugfixes after the memory usage reduction patch
- Use "udev->pipes_max" instead of USB_EP_MAX
- Use correct "bmRequestType" for getting the config descriptor.

Submitted by:	Hans Petter Selasky
2009-04-05 18:20:03 +00:00
Andrew Thompson
bdd4120608 MFp4 //depot/projects/usb@159866
- memory usage reduction by only allocating the required USB pipes and USB
  interfaces.
- cleanup some USB parsing functions to be more flexible.

Submitted by:	Hans Petter Selasky
2009-04-05 18:19:52 +00:00
Andrew Thompson
7efaaa9a91 MFp4 //depot/projects/usb@159811
First patch in a series of memory save patches.

Submitted by:	Hans Petter Selasky
2009-04-05 18:19:19 +00:00
Andrew Thompson
72b532e501 MFp4 //depot/projects/usb@159677
Remove redundant locking.

Submitted by:	Hans Petter Selasky
2009-04-05 18:18:36 +00:00
Andrew Thompson
91f72cedda Fix order of debug printf items, addr and config# were swapped. 2009-03-23 19:10:38 +00:00
Alexander Kabaev
62a5f39429 Do not pass uninitialized data buffer to devctl_queue_data function.
This was botched in revision 190191.
2009-03-23 01:24:17 +00:00
Andrew Thompson
8755859a43 Fix compile with USB_HAVE_BUSDMA/USB_HAVE_UGEN/USB_HAVE_STRINGS.
Submitted by:	Hans Petter Selasky
2009-03-20 23:12:14 +00:00
Andrew Thompson
578d0eff90 MFp4 //depot/projects/usb @159431,159437,159438
- start using the new USB typedefs in the USB core
- Remove usage of USB_ADD_BYTES()

Submitted by:	Hans Petter Selasky
2009-03-20 21:50:54 +00:00
Andrew Thompson
bdc081c60f MFp4 //depot/projects/usb@159392
Add ifdefs for making parts of usb conditional.

Submitted by:	Hans Petter Selasky
2009-03-20 21:48:11 +00:00
Andrew Thompson
ab42e8b2df MFp4 //depot/projects/usb @159430
- Move tunable defines into usb_core.h and dependancy towards usb_defs.h
- Leave hardcoded defines in "usb_defs.h".
- Allow overriding all tunable defines.
- Add more customisable typedefs.
- Correct maximum device number.

Submitted by:	Hans Petter Selasky
2009-03-20 19:04:31 +00:00
Andrew Thompson
0f6e8f934f MFp4 //depot/projects/usb 158942,158948
Allow USB to be compiled without ugen support.

Submitted by:	Hans Petter Selasky
2009-03-09 20:08:08 +00:00
Andrew Thompson
f35aaff035 A couple of style nits in the last commit
- unwrap short lines
 - move variable initialisation out of the declaration.
2009-02-28 17:20:00 +00:00