Commit Graph

140 Commits

Author SHA1 Message Date
manu
064e02ee42 Make USB port numbers display consistent
Make sure USB ports numbers are displayed with the first one as number one
and not number zero when rescanning bus. The change makes the display
consistent with the display at boot time USB discovery.

While we are there, make port iteration consistent everywhere in the code,
always starting at one instead of zero.
2018-10-19 00:33:27 +00:00
mrg
275f5ff63e add config_pending usage to uhub and general USB device attachment.
- call config_pending_incr() and config_pending_decr() around attaching
  devices against "usbdevif" attribute.

uhub:
- convert sc_explorepending and sc_running to bool.  add new sc_first_explore.
- call config_pending_incr() at the start of uhub_attach().  dropped in
  uhub_explore(), if this is the first explore.
2018-09-18 01:36:44 +00:00
msaitoh
a4f7562156 Mark DVF_DETACH_SHUTDOWN to USB root HUB. This change makes USB host
controller drivers detachable. OK'd by Nick.
2018-02-01 09:50:48 +00:00
pgoyette
cb32a134a5 Update the kernhist(9) kernel history code to address issues identified
in PR kern/52639, as well as some general cleaning-up...

(As proposed on tech-kern@ with additional changes and enhancements.)

Details of changes:

* All history arguments are now stored as uintmax_t values[1], both in
  the kernel and in the structures used for exporting the history data
  to userland via sysctl(9).  This avoids problems on some architectures
  where passing a 64-bit (or larger) value to printf(3) can cause it to
  process the value as multiple arguments.  (This can be particularly
  problematic when printf()'s format string is not a literal, since in
  that case the compiler cannot know how large each argument should be.)

* Update the data structures used for exporting kernel history data to
  include a version number as well as the length of history arguments.

* All [2] existing users of kernhist(9) have had their format strings
  updated.  Each format specifier now includes an explicit length
  modifier 'j' to refer to numeric values of the size of uintmax_t.

* All [2] existing users of kernhist(9) have had their format strings
  updated to replace uses of "%p" with "%#jx", and the pointer
  arguments are now cast to (uintptr_t) before being subsequently cast
  to (uintmax_t).  This is needed to avoid compiler warnings about
  casting "pointer to integer of a different size."

* All [2] existing users of kernhist(9) have had instances of "%s" or
  "%c" format strings replaced with numeric formats; several instances
  of mis-match between format string and argument list have been fixed.

* vmstat(1) has been modified to handle the new size of arguments in the
  history data as exported by sysctl(9).

* vmstat(1) now provides a warning message if the history requested with
  the -u option does not exist (previously, this condition was silently
  ignored, with only a single blank line being printed).

* vmstat(1) now checks the version and argument length included in the
  data exported via sysctl(9) and exits if they do not match the values
  with which vmstat was built.

* The kernhist(9) man-page has been updated to note the additional
  requirements imposed on the format strings, along with several other
  minor changes and enhancements.

[1] It would have been possible to use an explicit length (for example,
    uint64_t) for the history arguments.  But that would require another
    "rototill" of all the users in the future when we add support for an
    architecture that supports a larger size.  Also, the printf(3) format
    specifiers for explicitly-sized values, such as "%"PRIu64, are much
    more verbose (and less aesthetically appealing, IMHO) than simply
    using "%ju".

[2] I've tried very hard to find "all [the] existing users of kernhist(9)"
    but it is possible that I've missed some of them.  I would be glad to
    update any stragglers that anyone identifies.
2017-10-28 00:37:11 +00:00
chs
fd34ea77eb remove checks for failure after memory allocation calls that cannot fail:
kmem_alloc() with KM_SLEEP
  kmem_zalloc() with KM_SLEEP
  percpu_alloc()
  pserialize_create()
  psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
2017-06-01 02:45:05 +00:00
skrll
a7c71d30d6 +#include "opt_usb.h" 2016-11-25 12:56:29 +00:00
skrll
990b8eeb89 tiny KNF 2016-09-13 07:30:32 +00:00
skrll
4e8e66439e Merge nick-nhusb
- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
    - kern/48308
    - uhub status notification improvements
    - umass(4) probe fix (applied to HEAD already)
    - ohci(4) short transfer fix
2016-04-23 10:15:27 +00:00
skrll
349519764b KNF 2016-03-13 07:01:43 +00:00
skrll
970a1b8e99 Re-enable the TT support that existed previously. 2016-02-16 07:51:13 +00:00
skrll
178de58605 Use the port status straight after the reset and not after the
usbd_clear_port_feature(dev, port, UHF_C_PORT_RESET)

The Gadget USB HUB in the IBM x3250 sborrill sent me returns the wrong
status and this would appear to leave the attached cdce(4) in the default
state.  The next device probed fails as a result.
2016-02-05 15:41:49 +00:00
skrll
fc18aa93ff Improve DPRINTFs - partially from Takahiro HAYASHI 2015-03-28 07:58:00 +00:00
skrll
8e89cd3c39 Note the uhub the DPRINTF is about in many cases 2015-03-26 16:19:26 +00:00
skrll
9602c03fb6 Convert to USBHIST. Inspired by patch from Takahiro HAYASHI 2015-03-26 15:53:58 +00:00
skrll
1673781687 SS device detection needs more work. #if 0 previous attempt for now.
PR/49106: panic: ehci_open: bad device speed 4
2014-08-13 06:26:32 +00:00
skrll
be08e709ea Some USB3 / SS support - baby steps. From Takahiro HAYASHI. 2014-08-12 13:36:40 +00:00
martin
e318f27f06 Remove unused variable 2013-09-15 15:33:47 +00:00
jakllsch
777d27f690 Spell "Windows 98" not-incorrectly in comment. 2013-06-25 15:37:17 +00:00
jmcneill
6f856c0ad6 uhub is mpsafe 2013-01-22 21:12:32 +00:00
christos
38f4ff5bf5 fix debug variables.
- include opt_usb.h in usb.h so that USB_DEBUG gets set properly in it.
- normalize and sort debugging variables
2013-01-05 23:34:16 +00:00
christos
3039e3a5a7 - need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID
2013-01-05 01:30:15 +00:00
skrll
0228517d04 Fix function name in DPRINTF 2012-11-14 13:53:23 +00:00
gsutre
b942a7ea7e In uhub_childdet, do not free the array of sub-devices if there is none.
This prevents a kernel panic at shutdown on my laptop.
2012-09-09 20:23:38 +00:00
mrg
c59438a785 take the kernel lock a few more places when doing detach, to avoid
triggering KERNEL_LOCK_P() asserts in both scsi and usb code.

with this and other recent fixes i can now "drvctl -d ehci0".
2012-03-12 02:44:16 +00:00
jakllsch
7ced092c93 Restore parts of uhub_explore() needed to make usb_needs_reattach() work. 2012-03-09 00:12:10 +00:00
sborrill
1d982e3397 not enable -> not enabled 2012-03-05 16:14:03 +00:00
matt
39d427883c Move EHCI_DEBUG, OHCI_DEBUG, UHCI_DEBUG, USB_DEBUG, UHUB_DEBUG to opt_usb.h
(ya dependencies).
Cleanup usb_mem.c a little more and add block tracking code.  Help find
corruption problems.
Comment out the SPEED check for ETTF.  XXX why doesn't that work right?
2011-06-09 19:08:31 +00:00
jmcneill
006e5dde1f When a child device is detached and no interfaces are claimed by drivers,
free the port's subdevice list. This allows for detaching a driver from
a USB device and loading a different one without disconnecting the device.
2011-05-29 12:37:09 +00:00
dyoung
95e20b0de7 Change a stray USBDEVNAME to device_xname(). Only affects DIAGNOSTIC
kernels.
2010-11-03 22:59:40 +00:00
dyoung
49337c8880 Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera.  These files produce the same assembly
(according to objdump -d) before and after the change
2010-11-03 22:34:23 +00:00
kiyohara
a449bab930 Ensure that it is UPS_PORT_ENABLED before checking the speed of the device. 2010-09-08 14:01:58 +00:00
pooka
068898b44d Introduce the uhub_ubermatch variable. Setting it to 1 makes sure
than a uhub attaches even at higher priority than ugen when
ugen_override is set to 1.  This allows to probe the whole USB bus
and attach its functions with ugen.

A better infrastructure to control this would be nice ....
2010-02-02 23:18:49 +00:00
dyoung
af7d639aad Re-order operations in usb_detach() so that if a usb(4) instance's
children will not detach, the instance is not left in an inconsistent
state.

If uhub(4) port is disconnected, forcefully detach the children on
that port.

Simplify detachment hooks.  (sc_dying must die!)

Pass along and respect detachment flags, esp. DETACH_FORCE,
throughout.
2009-11-12 20:11:35 +00:00
dyoung
ac13fdbe53 Expand some definitions from <dev/usb/usb_port.h>. 2009-09-04 18:14:41 +00:00
dyoung
5cebfe910a KNF: compare a pointer with NULL instead of evaluating its "truth." 2009-09-04 16:42:38 +00:00
dyoung
628c492598 Expand some of the portability macros from sys/dev/usb/usb_port.h.
There is no change in the generated assembly.
2009-09-03 20:54:03 +00:00
dyoung
227c03169a Detach uhub(4) and usb(4) at shutdown. 2009-04-07 18:15:45 +00:00
kent
fb5a41ad3a Implement uhub_rescan(). After this change, "modload uaudio.kmod"
configures an audio device correctly for a device which is already
plugged.

* usb_subr.c
 Add locators parameter to usbd_attachinterfaces()
 Add usbd_reatach_device()

* usbdivar.h
 Export usbd_reatach_device()
2008-08-18 18:03:21 +00:00
drochner
6a47db887e -in usbd_probe_and_attach(), split out the code for per-device and
per-interface attachment into individual functions, to ease
 maintainance and allow easier plugin of new attachment functions
-keep a counter of USB interfaces in use on a device, and try to
 keep track of interfaces claimed by drivers behind the framework's
 back
2008-07-28 15:22:01 +00:00
drochner
dd989679ec -plug a minimal memory leak on attach/detach
-avoid unnecessary tree walks and port status requests:
 -acknowledge hub status change notifications (but do nothing)
 -clear cached port status change bits earlier (but not on ehci, due
  to an ehci driver bug)
-do the ehci check on attach rather than a string comparision at runtime
2008-06-16 10:37:54 +00:00
drochner
1f3341612f minor unifdef and cleanup, no functional change 2008-05-27 20:44:28 +00:00
drochner
f8b26260d9 -make the list of USB child devices a (possibly sparse) array rather
than a zero-terminated list; this makes the code simpler and also
 hopefully fixes the recent "childdet" botch, see PR kern/38528
-handle the root hub specially a bit earlier, this allows to kick out
 the "submatch" functions completely which needed to second-guess
 from the port number (where "0" meant root hub")
 (we could handle the root hub specially even earlier, but as done
 now big parts of the hub emulation code are exercised regularely,
 this would bitrot otherwise)
2008-05-25 21:41:35 +00:00
cube
3624455eba Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral.  I tested umass myself.
2008-05-24 16:40:58 +00:00
martin
ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
jmcneill
de45d1c96b Cleanup uhub autoconfiguration messages. 2008-04-21 23:31:18 +00:00
dyoung
0b1dce29ae Use device_t and its accessor functions.
Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().
2008-02-18 05:24:24 +00:00
jmcneill
a06bac7d44 Speed up uhub attachment considerably. Rather than powering up each port
individually then waiting for it to become stable, power them up all
at once and then delay. Don't even bother delaying if we are a root hub,
as this is handled separately in the event thread. From OpenBSD.
2008-01-25 00:29:12 +00:00
smb
0cb6d977ab Add calls to pmf_deregister on detach. 2008-01-04 03:56:47 +00:00
jmcneill
4c1d81b2b5 Merge jmcneill-pm branch. 2007-12-09 20:27:42 +00:00
jmcneill
4fbe23fdd0 aprintify 2007-12-01 04:50:50 +00:00