Home | History | Annotate | Download | only in usb
History log of /src/sys/dev/usb/uhub.c
RevisionDateAuthorComments
 1.162  04-May-2024  mlelstv Use device_printf instead of autoconf messages for errors.
 1.161  06-Apr-2022  mlelstv revert accidental last commit (except ukbd.c)
 1.160  06-Apr-2022  mlelstv remove debug printf
 1.159  04-Feb-2022  riastradh uhub(4): Sprinkle dtrace probes.
 1.158  15-Oct-2021  jmcneill Revert "usb: uhub: remove unnecessary delays when powering on ports"

syzbot says that the change exposes UB in usb_free_device and I can't
see how, so revert until I have a better understanding of what's going on.

Reported-by: syzbot+c445f7149cce07d4c252@syzkaller.appspotmail.com
Reported-by: syzbot+a2ae42f37de765a54b20@syzkaller.appspotmail.com
 1.157  11-Oct-2021  msaitoh Add missing inclusion of sys/bitops.h.
 1.156  11-Oct-2021  jmcneill uhub: Skip USB_POWER_DOWN_TIME delay for root hubs
 1.155  11-Oct-2021  jmcneill Fix previous; restore 'up' pointer in second uhub_explore loop.
 1.154  10-Oct-2021  jmcneill usb: uhub: remove unnecessary delays when powering on ports

In uhub_explore instead of waiting 300ms after powering up each
connected port, power up all of the connected ports and then wait for
300ms total.
 1.153  13-Jun-2021  riastradh usb(4): Bus exploration is single-threaded -- assert it so.

New usb_in_event_thread(dev) returns true if dev is a USB device --
that is, a device with a usbN ancestor -- and the current thread is
the USB event thread.

(Kinda kludgey to pass around the device_t instead of, say, struct
usbd_bus, but I don't see a good way to get to the usbN device_t or
struct usb_softc from there.)
 1.152  13-Jun-2021  riastradh uhub(4): Defer rescan to USB event thread.

Keep all of the USB bus exploration in a single thread -- this
appears to have been the original assumption, violated back in 2008
when uhub_rescan was added, and will make everything simpler.
 1.151  13-Jun-2021  riastradh uhub(4): Trigger bus exploration after rescanning children.

Otherwise, if uhub4 is attached at uhub1, then when we do

# drvctl -d uhub4
# drvctl -r -a usbdevif uhub1

the rescan never discovers devices attached recursively at uhub4, and
uhub4 leaks a config_pending_incr count so it can't be detached.
 1.150  12-Jun-2021  riastradh usb(4), uhub(4): Sprinkle usbhist.
 1.149  12-Jun-2021  riastradh usb(4): Sprinkle kernel lock assertions.
 1.148  12-Jun-2021  riastradh uhub(4): Allow only one explore/rescan at a time.

Otherwise we might simultaneously attach two autoconf instances of
the same device, which leads to no good.
 1.147  05-Jun-2020  maxv branches: 1.147.6;
Register eight vHCI buses, and use separate KCOV mailboxes for them.
 1.146  31-May-2020  maxv sc_statuspend is allocated with kmem_zalloc, so no need to memset it.
 1.145  15-May-2020  maxv Introduce KCOV remote support. This allows to collect KCOV coverage on
threads other than curlwp, which is useful when fuzzing components that
defer processing, such as the network stack (partially runs in softints)
and the USB stack (partially runs in uhub kthreads).

A subsystem that whishes to provide coverage for its threads creates a
"mailbox" via kcov_remote_register() and gives it a (subsystem, id)
identifier. There is one mailbox per "target lwp". The target lwp(s)
must then call kcov_remote_enter() and kcov_remote_leave() with the
identifier, to respectively enable and disable coverage within the
thread.

On the userland side, the fuzzer has access to the mailboxes on the
system with the KCOV_IOC_REMOTE_ATTACH and KCOV_IOC_REMOTE_DETACH ioctls.
When attached to a mailbox with a given identifier, the KCOV_IOC_ENABLE,
KCOV_IOC_DISABLE and mmap() operations will affect the mailbox.

As a demonstrator, the vHCI subsystem is changed to use KCOV mailboxes.
When the vHCI bus attaches it creates as many mailboxes as it has USB
ports, each mailbox being associated with a distinct port. Uhub is changed
to enable KCOV coverage in usbd_new_device(). With that in place, all of
the USB enumeration procedure can be traced with KCOV.
 1.144  07-Jan-2020  maxv Localify, constify.
 1.143  21-Aug-2019  mrg convert pairs of USBHIST_CALLED()+USBHIST_LOG*() into
USBHIST_CALLARGS() calls. this reduces the number of
kernel history lines consumed by these callers, and
for the +LOGN versions, add useful log info to a
message that just says "called!".

reduces the line spam which means the total info in a
full log is significantly increased.
 1.142  05-May-2019  mrg branches: 1.142.2;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h
 1.141  23-Oct-2018  manu Make USB port iteration code consistent, always startint at port #1

This complements change in revision 1.140
 1.140  19-Oct-2018  manu 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.
 1.139  18-Sep-2018  mrg 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.
 1.138  01-Feb-2018  msaitoh branches: 1.138.2; 1.138.4;
Mark DVF_DETACH_SHUTDOWN to USB root HUB. This change makes USB host
controller drivers detachable. OK'd by Nick.
 1.137  28-Oct-2017  pgoyette 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.
 1.136  01-Jun-2017  chs branches: 1.136.2;
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.
 1.135  25-Nov-2016  skrll +#include "opt_usb.h"
 1.134  13-Sep-2016  skrll tiny KNF
 1.133  23-Apr-2016  skrll branches: 1.133.2;
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
 1.132  13-Mar-2016  skrll KNF
 1.131  16-Feb-2016  skrll Re-enable the TT support that existed previously.
 1.130  05-Feb-2016  skrll 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.
 1.129  28-Mar-2015  skrll Improve DPRINTFs - partially from Takahiro HAYASHI
 1.128  26-Mar-2015  skrll Note the uhub the DPRINTF is about in many cases
 1.127  26-Mar-2015  skrll Convert to USBHIST. Inspired by patch from Takahiro HAYASHI
 1.126  13-Aug-2014  skrll branches: 1.126.2;
SS device detection needs more work. #if 0 previous attempt for now.

PR/49106: panic: ehci_open: bad device speed 4
 1.125  12-Aug-2014  skrll Some USB3 / SS support - baby steps. From Takahiro HAYASHI.
 1.124  15-Sep-2013  martin branches: 1.124.4;
Remove unused variable
 1.123  25-Jun-2013  jakllsch branches: 1.123.2;
Spell "Windows 98" not-incorrectly in comment.
 1.122  22-Jan-2013  jmcneill uhub is mpsafe
 1.121  05-Jan-2013  christos fix debug variables.
- include opt_usb.h in usb.h so that USB_DEBUG gets set properly in it.
- normalize and sort debugging variables
 1.120  05-Jan-2013  christos - need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID
 1.119  14-Nov-2012  skrll Fix function name in DPRINTF
 1.118  09-Sep-2012  gsutre branches: 1.118.2;
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.
 1.117  12-Mar-2012  mrg 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".
 1.116  09-Mar-2012  jakllsch Restore parts of uhub_explore() needed to make usb_needs_reattach() work.
 1.115  05-Mar-2012  sborrill not enable -> not enabled
 1.114  09-Jun-2011  matt branches: 1.114.2; 1.114.6; 1.114.10;
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?
 1.113  29-May-2011  jmcneill branches: 1.113.2;
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.
 1.112  03-Nov-2010  dyoung branches: 1.112.2;
Change a stray USBDEVNAME to device_xname(). Only affects DIAGNOSTIC
kernels.
 1.111  03-Nov-2010  dyoung 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
 1.110  08-Sep-2010  kiyohara Ensure that it is UPS_PORT_ENABLED before checking the speed of the device.
 1.109  02-Feb-2010  pooka branches: 1.109.2; 1.109.4;
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 ....
 1.108  12-Nov-2009  dyoung 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.
 1.107  04-Sep-2009  dyoung Expand some definitions from <dev/usb/usb_port.h>.
 1.106  04-Sep-2009  dyoung KNF: compare a pointer with NULL instead of evaluating its "truth."
 1.105  03-Sep-2009  dyoung Expand some of the portability macros from sys/dev/usb/usb_port.h.
There is no change in the generated assembly.
 1.104  07-Apr-2009  dyoung Detach uhub(4) and usb(4) at shutdown.
 1.103  18-Aug-2008  kent branches: 1.103.2; 1.103.8;
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()
 1.102  28-Jul-2008  drochner -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
 1.101  16-Jun-2008  drochner branches: 1.101.2;
-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
 1.100  27-May-2008  drochner branches: 1.100.2;
minor unifdef and cleanup, no functional change
 1.99  25-May-2008  drochner -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)
 1.98  24-May-2008  cube 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.
 1.97  28-Apr-2008  martin branches: 1.97.2;
Remove clause 3 and 4 from TNF licenses
 1.96  21-Apr-2008  jmcneill branches: 1.96.2;
Cleanup uhub autoconfiguration messages.
 1.95  18-Feb-2008  dyoung branches: 1.95.6; 1.95.8;
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().
 1.94  25-Jan-2008  jmcneill 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.
 1.93  04-Jan-2008  smb Add calls to pmf_deregister on detach.
 1.92  09-Dec-2007  jmcneill branches: 1.92.2;
Merge jmcneill-pm branch.
 1.91  01-Dec-2007  jmcneill branches: 1.91.2; 1.91.4;
aprintify
 1.90  19-Oct-2007  ad branches: 1.90.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.89  23-Mar-2007  drochner branches: 1.89.8; 1.89.10; 1.89.14;
Work around imperfect hub emulation in the ehci root hub (ohci is affected
too, but that's not critical): real hubs send port status change
notifications until acknowledged, ehci/ohci send only once so there is
a chance that this gets lost if notifications are disabled during a scan.
The temporary fix is to force a rescan; the real fix will involve a
change in interrupt handling in ehci/ohci which needs more work and
testing.
ehci is critical because a port status change during scan regularely
happens if a full/lowspeed device is connected, due to the handover
process.
Fixes a problem where full/lowspeed devices were not reattached after
a disconnect, reported by Kouichirou Hiratsuka and Juan RP
on current-users.
 1.88  19-Mar-2007  drochner fix variable in DEBUG code, from Lubomir Kundrak per PR kern/36036
 1.87  15-Mar-2007  drochner Keep track of the per-port status change notifications coming in
through the interrupt pipe; during exploration check only the ports
where we got such a notification. This speeds up things.
(I believe we should go a step further and use a thread per hub
instead of per bus. If power management gets implemented, we should
be able to react quickly on a resume event.)
Try to simplify the logics in the explore function a bit. (The reattach
thing was hacked in badly, not sure whether I broke it. Only used
by if_atu.)
Clean up some dead code.
 1.86  13-Mar-2007  drochner branches: 1.86.2;
Introduce different autoconf interface attributes for USB drivers
matching (and handling) a whole device and those which match an
interface only. This will allow to enforce some rules, eg that
the former don't use interface information for matching or that the
latter don't modify global device state.
The previous way left too much freedom do the drivers which led to
inconsistencies and abuse.
For now, I've not changed locators and submatch rules, this will
happen later.
There should not be any change in behaviour, except in the case of
some drivers which did behave inconsistently:
if_atu, if_axe, uep: matched the configured device in the interface
stage, but did configuration again. I've converted them to match
in the device stage.
ustir, utoppy: matched in the interface stage, but only against
vendor/device information, and used any configuration/interface
without checking. Changed to match in device stage, and added
some simple code to configure and use the first interface.
If you have one of those devices, please test!
 1.85  26-Feb-2007  drochner branches: 1.85.4; 1.85.6; 1.85.8;
Remove the check which disallows to connect a bus powered hub to another
bus powered hub. While one can interpret the spec that way, it is not
stated clearly, and is at most a side effect of power budgeting.
Also, there are devices which don't report correctly whether they
are self powered, so the check was unreliable.
 1.84  07-Jan-2007  drochner branches: 1.84.2;
Allocate storage for status change notifications dynamically, depending
on the number of ports. One byte wasn't even sufficient for 8 ports.
The code doesn't make use of the status bits yet, but it might be used
to speed up the exploration loop later.
 1.83  01-Dec-2006  drochner branches: 1.83.2; 1.83.4;
-comment out transaction translator support for now, it doesn't do more
than allocating memory, and it does wrongly use the hub's capabilities
but not the actual setting
-switch a high-speed hub to "multiple TTs" but ignore errors; since
we don't care whether there is one or multiple this is a "best effort"
thing
 1.82  30-Nov-2006  drochner don't specify a polling interval for the interrupt pipe -- that's
what the descriptor is good for
 1.81  16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.80  24-Oct-2006  drochner clean up the USB attachment stuff a bit: use a dedicated interface
attribute ("usbdevif") to attach USB devices, be it a plain device or
a hub, and remove some strangeness caused by the former usb/uhub mess
 1.79  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.78  14-Apr-2006  christos branches: 1.78.8; 1.78.10;
Coverity CID 2330: Spell out that we are going to use the memory we allocated.
 1.77  11-Dec-2005  christos branches: 1.77.4; 1.77.6; 1.77.8; 1.77.10; 1.77.12;
merge ktrace-lwp.
 1.76  11-May-2005  augustss branches: 1.76.2;
Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows.
 1.75  30-Apr-2005  augustss Root hubs don't have transaction translators, so don't print anything
about them for depth 0. From FreeBSD.
 1.74  02-Mar-2005  mycroft Copyright maintenance.
 1.73  27-Feb-2005  perry nuke trailing whitespace
 1.72  24-Jan-2005  joff branches: 1.72.2;
Implementation requirements of usb_needs_reattach(), from OpenBSD and required
for atu(4) to do a USB reconnect after firmware upload.
 1.71  26-Oct-2004  augustss branches: 1.71.4;
Free memory in the correct order. Pointed out by Jeff Rizzo.
 1.70  23-Oct-2004  augustss Keep track of what high speed port (if any) a device belongs to so we can
set the transaction translator fields for the transfer.
Add a gross hack for split transaction completion in the ehci driver that
allows control transfers to be translated. Interrupt transfers do not work.
Warn when any low/full speed device is opened.
 1.69  22-Oct-2004  augustss Print information for high speed hubs about the number of TTs.
Print a message when low/full speed devices are ignored on high speed hubs.
 1.68  29-Jun-2004  mycroft Ignore a port error that happens to come in at the same time as a connect
status change. Some root hubs seem to report both.
 1.67  11-Jun-2004  petrov Initialize restartcnt. from FreeBSD.
 1.66  23-Apr-2004  itojun use bounded string ops (snprintf, strl*)
 1.65  29-Dec-2003  toshii branches: 1.65.2;
Use the correct wValue to get hub desriptors.
Also, make wValue checks of root hub codes less strict.
 1.64  08-Feb-2003  ichiro branches: 1.64.2;
change URL pointers of USB[1,2] specification
 1.63  02-Jan-2003  dsainty Initialise uhubdebug so that it's patchable in a kernel image
 1.62  02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.61  01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.60  27-Sep-2002  thorpej Declare all cfattach structures const.
 1.59  23-Sep-2002  simonb Remove breaks after returns, unreachable returns and returns after
returns(!).
 1.58  11-Jul-2002  augustss Get rid of trailing white space.
 1.57  20-Nov-2001  augustss branches: 1.57.8; 1.57.10;
Add a comment.
 1.56  20-Nov-2001  augustss Keep track of device speed for USB 2.0.
 1.55  16-Nov-2001  augustss Better error message.
 1.54  16-Nov-2001  augustss Handle devices that disappear during reset gracefully.
 1.53  13-Nov-2001  lukem add RCSIDs
 1.52  26-Oct-2001  augustss Compare pointer with NULL instead of using them as a condition.
 1.51  24-Oct-2001  augustss Better debug message.
 1.50  28-Sep-2001  augustss branches: 1.50.2;
Only clear the endpoint on stall (from FreeBSD).
 1.49  21-Jan-2001  augustss branches: 1.49.2; 1.49.4; 1.49.6;
Change the operation of the USB event thread. Before it only performed
USB device discovery, now it can also perform (short) tasks for device
drivers that need a process context, but don't have one.
This is not pretty, but better than using busy-wait in an interrupt context.
 1.48  29-Dec-2000  augustss Update many URLs.
 1.47  24-Sep-2000  augustss Don't give up so easily if the device does not respond properly.
Mostly from Nick Hibma (FreeBSD).
 1.46  22-Sep-2000  augustss Fix a device diconnect bug found by Christian Groessler <cpg@aladdin.de>.
 1.45  01-Jun-2000  augustss Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.
 1.44  27-Apr-2000  augustss branches: 1.44.2;
Change my email address.
 1.43  21-Apr-2000  augustss Use a 255 ms interrupt interval even if the descriptor in the hub asks
for something else, because the spec says that it should be 255.
 1.42  21-Apr-2000  augustss Change the exact sequence of commands when a hub is attached to follow
Windoze more closely. This makes more devices work.

After two years of doing USB work I've finally access to a USB protocol
analyzer. Which means I should be able to mimic what Windoze does in
certain cases instead of just following the specs. Following the specs
is not enough since the devices often don't.
 1.41  27-Mar-2000  augustss Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.
 1.40  29-Feb-2000  augustss Distinguish between device and interface classes.
(I finally found a document that said that they were different.)
 1.39  12-Feb-2000  augustss Avoid panic when a non-working hub is detached.
 1.38  02-Feb-2000  augustss Generate usb events on attach and detach.
 1.37  02-Feb-2000  augustss Change the USB event mechanism to include more information about devices
and drivers. Partly from FreeBSD.
 1.36  19-Jan-2000  augustss Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.
 1.35  24-Nov-1999  augustss Add some more debug printing.
 1.34  18-Nov-1999  augustss Cosmetic changes and some small improvements. From FreeBSD and Nick Hibma.
 1.33  12-Nov-1999  augustss A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF
 1.32  13-Oct-1999  augustss branches: 1.32.2; 1.32.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.
 1.31  12-Oct-1999  augustss Fix some bugs in USB controller detach code.
 1.30  11-Oct-1999  augustss Remove an obsolete comment.
 1.29  15-Sep-1999  augustss branches: 1.29.2;
Add preliminary (untested) code for detaching the USB host controller
(needed for CardBus based controllers).
 1.28  13-Sep-1999  augustss Rearrange the code a little so we can decide if we are in process
or interrupt context in a reliable way. Mainly used for DIAGNOSTIC.
 1.27  12-Sep-1999  augustss Add a flag in the request to determine if the data copying is done by the
driver or the usbdi layer.
 1.26  05-Sep-1999  augustss Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.
 1.25  02-Sep-1999  augustss Avoid null reference, from Nick Hibma, FreeBSD.
 1.24  28-Aug-1999  augustss Change some 'struct device' to 'bdevice'. From FreeBSD.
 1.23  23-Aug-1999  augustss Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.
 1.22  22-Aug-1999  augustss Move more of the transfer completion processing to HC independent code.
Fix some problems with transfer abort & timeout.
 1.21  19-Aug-1999  augustss Add a utility function, usbd_errstr(), to print error strings. From FreeBSD.
 1.20  17-Aug-1999  augustss Make some small changes to make it compile on OpenBSD.
 1.19  14-Aug-1999  augustss Some changes from FreeBSD (no functional differences).
 1.18  30-Jun-1999  augustss Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.
 1.17  14-Jun-1999  augustss Check that the hub ports actually power up.
 1.16  10-Jan-1999  augustss branches: 1.16.4;
Some minor updates from FreeBSD.
 1.15  10-Jan-1999  augustss Update/add URLs to relevant USB specs.
 1.14  08-Jan-1999  augustss Various little fixes from the FreeBSD version.
 1.13  30-Dec-1998  augustss Split usbd_delay_ms() into two functions, one can be used in
device drivers.
 1.12  28-Dec-1998  augustss Add another power up wait so that some devices (that do not follow
the spec) start up more reliably.
 1.11  26-Dec-1998  augustss Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.
 1.10  09-Dec-1998  drochner make compile without USB_DEBUG, wrap lines to 80 cols
 1.9  09-Dec-1998  augustss Clear stall condition on interrupt pipe.
 1.8  08-Dec-1998  augustss Use plaintest error messages for debugging.
 1.7  02-Dec-1998  augustss Avoid wrapping lines in attach printfs.
 1.6  25-Nov-1998  augustss Make the copyright header conform to the NetBSD template.
 1.5  02-Aug-1998  augustss Improve some error messages.
Make some preparations for isochronous transfers.
 1.4  01-Aug-1998  augustss Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.
 1.3  01-Aug-1998  augustss Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.
 1.2  22-Jul-1998  augustss Loop over all configurations when trying to probe for interface drivers.
 1.1  12-Jul-1998  augustss Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers
 1.16.4.2  01-Jul-1999  thorpej Sync w/ -current.
 1.16.4.1  21-Jun-1999  thorpej Sync w/ -current.
 1.29.2.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.32.4.1  15-Nov-1999  fvdl Sync with -current
 1.32.2.3  11-Feb-2001  bouyer Sync with HEAD.
 1.32.2.2  05-Jan-2001  bouyer Sync with HEAD
 1.32.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.44.2.1  22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.49.6.1  01-Oct-2001  fvdl Catch up with -current.
 1.49.4.3  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.49.4.2  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.49.4.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.49.2.6  03-Jan-2003  thorpej Sync with HEAD.
 1.49.2.5  18-Oct-2002  nathanw Catch up to -current.
 1.49.2.4  01-Aug-2002  nathanw Catch up to -current.
 1.49.2.3  08-Jan-2002  nathanw Catch up to -current.
 1.49.2.2  14-Nov-2001  nathanw Catch up to -current.
 1.49.2.1  08-Oct-2001  nathanw Catch up to -current.
 1.50.2.1  12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.57.10.1  15-Mar-2004  jmc Pullup rev 1.65 (requested by toshii in ticket #1599)

Use the correct wValue to get hub desriptors.
Also, make wValue checks of root hub codes less strict.
 1.57.8.1  15-Jul-2002  gehenna catch up with -current.
 1.64.2.7  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.64.2.6  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.64.2.5  24-Jan-2005  skrll Sync with HEAD.
 1.64.2.4  02-Nov-2004  skrll Sync with HEAD.
 1.64.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.64.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.64.2.1  03-Aug-2004  skrll Sync with HEAD
 1.65.2.2  02-Jul-2004  he Pull up revision 1.68 (requested by mycroft in ticket #572):
Several fixes mostly related to USB:
o Ignore a port error that happens to come in at the same
time as a connect status change. Some root hubs appear
to report both.
 1.65.2.1  14-Jun-2004  jmc Pullup rev 1.67 (requested by petrov in ticket #470)

Initialize restartcnt.
 1.71.4.1  29-Apr-2005  kent sync with -current
 1.72.2.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.76.2.9  27-Feb-2008  yamt sync with head.
 1.76.2.8  04-Feb-2008  yamt sync with head.
 1.76.2.7  21-Jan-2008  yamt sync with head
 1.76.2.6  07-Dec-2007  yamt sync with head
 1.76.2.5  27-Oct-2007  yamt sync with head.
 1.76.2.4  03-Sep-2007  yamt sync with head.
 1.76.2.3  26-Feb-2007  yamt sync with head.
 1.76.2.2  30-Dec-2006  yamt sync with head.
 1.76.2.1  21-Jun-2006  yamt sync with head.
 1.77.12.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.77.10.1  19-Apr-2006  elad sync with head.
 1.77.8.1  24-May-2006  yamt sync with head.
 1.77.6.1  22-Apr-2006  simonb Sync with head.
 1.77.4.1  09-Sep-2006  rpaulo sync with head
 1.78.10.2  10-Dec-2006  yamt sync with head.
 1.78.10.1  22-Oct-2006  yamt sync with head
 1.78.8.2  12-Jan-2007  ad Sync with head.
 1.78.8.1  18-Nov-2006  ad Sync with head.
 1.83.4.1  03-Jun-2008  skrll Sync with netbsd-4.
 1.83.2.1  03-Feb-2008  riz Pull up following revision(s) (requested by jmcneill in ticket #1056):
sys/dev/usb/uhub.c: revision 1.94
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.
 1.84.2.2  24-Mar-2007  yamt sync with head.
 1.84.2.1  27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.85.8.3  21-Jun-2007  itohy Pullup 1.87-1.88
I'm not sure we should use 1.89....
 1.85.8.2  18-Jun-2007  itohy - Pullup 1.86 (attach driver per interface) with #ifdef USB_USE_IFATTACH.
- Introduce sc_proto to simplify code (this is part of 1.86 and included
without conditional compilation)
 1.85.8.1  22-May-2007  itohy Overhaul of USB stack, mostly DMA related

This applies to NetBSD 4.99.13 (March 1, 2007)

usbdi(9) interface is based on FreeBSD version, excluding
- removal of portability code

Patch most NetBSD changes, excluding
- DMA memory "reserve", since we don't need contiguous buffers any longer
- volatiles in DMA structure, since it should not be needed
with proper bus_dmamap_sync(9)s

DMA/non-DMA memory management overhaul
- Move all DMA related code to usb_mem.[ch]
(add usb_alloc_buffer_dma(), usb_free_buffer_dma(), etc.).
XXX Should usb_mem.[ch] be renamed as usb_mem_dma.[ch] ?
- Add corresponding non-DMA code to usb_mem_nodma.[ch] .
Currently just use malloc(9).
- Above files are conditionally used by config framework (added
attributes to conf/files and dev/usb/files.usb).
- Add diagnostic panics when resource allocation is requested
on interrupt context.
- Change memory allocations (that require context) from NOWAIT to WAITOK.

Allocate DMA/non-DMA buffer per host interface, not globally.
advantage: Buffers can be freed on detaching host interface.
Activity of a host interface does not affect others.
disadvantages: It possibly consumes more memory.

API changes
- usbd_alloc_xfer() is changed:
old: usbd_xfer_handle usbd_alloc_xfer(usbd_device_handle dev);
new: usbd_xfer_handle usbd_alloc_xfer(usbd_device_handle dev,
usbd_pipe_handle pipe);
- pipe argument of usbd_setup_*xfer() are now unused
XXX the pipe argument should be removed?
- add mapping APIs
- async request will be processed as a task (kernel thread context),
and delayed to some extent
- usbdivar.h: struct usbd_xfer: renamed a member "allocbuf" to "hcbuffer"
(mapped/allocated/refered buffer for HCI driver)
- usb_port.h: change usb_proc_ptr from struct ptoc * to struct lwp *
- usb_port.h: add usb_sigproc_ptr for psignal(9) (struct proc *)
- usb.h: add UE_MAXPKTSZ(ep) and UE_MAXPKTSZ_MASK macros for USB 2.0

changes to USB device drivers
- atu, aue, axe, cdce, cue, kue, rum, udav, upl, ural, url,
uaudio, ubt, ucom, ugen, uhidev, uirda, ulpt, umidi, urio,
uscanner, ustir, utoppy:
* catch up API change of usbd_alloc_xfer()
- umass, usscanner:
* catch up API change of usbd_alloc_xfer()
* eliminate memory copy for large transfer

ohci
- free resources on detach
- add lots of bus_dmamap_sync() operations
- simplify the code of loading std chain
- rewrite code of looking up TD/ITD from DMA addr by using allocation chunk
- add workaround for CMD Tech 670 and 673 chipsets
- make sure resources are not allocated in interrupt context
- add support for mapping buffer and mbuf

slhci
- allocate xfer and slhci_xfer at once, and simplify relevant code
- add slhci_detach()
- remove second arg of slhci_attach() since it is the same as the first arg.
- add support for "mapping" (no, it doesn't map since it doesn't do DMA)
buffer and mbuf
- add pcmcia frontend
- NOT TESTED, missing hardware

ehci
- add lots of bus_dmamap_sync() operations, possibly too many
- make sure resources are not allocated in interrupt context
- add support for mapping buffer and mbuf
- done only simple test

uhci
- add lots of bus_dmamap_sync() operations, possibly too many
- make sure resources are not allocated in interrupt context
- add support for mapping buffer and mbuf

To do
- review, test, debug
- rewrite network drivers to utilize usbd_map_buffer_mbuf()
- rewrite uaudio(4) to eliminate memcpy
- "pipe" argument of usbd_setup_*xfer() should eventually be removed
 1.85.6.1  11-Jul-2007  mjf Sync with head.
 1.85.4.3  23-Oct-2007  ad Sync with head.
 1.85.4.2  10-Apr-2007  ad Sync with head.
 1.85.4.1  13-Mar-2007  ad Sync with head.
 1.86.2.2  29-Mar-2007  reinoud Pullup to -current
 1.86.2.1  18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.89.14.1  25-Oct-2007  bouyer Sync with HEAD.
 1.89.10.3  23-Mar-2008  matt sync with HEAD
 1.89.10.2  09-Jan-2008  matt sync with HEAD
 1.89.10.1  06-Nov-2007  matt sync with HEAD
 1.89.8.7  08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.89.8.6  01-Dec-2007  jmcneill Sync with HEAD.
 1.89.8.5  06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.89.8.4  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.89.8.3  07-Aug-2007  jmcneill uhub power handler is not necessary; use pnp_generic_power
 1.89.8.2  07-Aug-2007  jmcneill Remove debug printf.
 1.89.8.1  07-Aug-2007  jmcneill Add uhub power handler.
 1.90.2.3  18-Feb-2008  mjf Sync with HEAD.
 1.90.2.2  27-Dec-2007  mjf Sync with HEAD.
 1.90.2.1  08-Dec-2007  mjf Sync with HEAD.
 1.91.4.1  11-Dec-2007  yamt sync with head.
 1.91.2.1  26-Dec-2007  ad Sync with head.
 1.92.2.1  08-Jan-2008  bouyer Sync with HEAD
 1.95.8.3  17-Jun-2008  yamt sync with head.
 1.95.8.2  04-Jun-2008  yamt sync with head
 1.95.8.1  18-May-2008  yamt sync with head.
 1.95.6.3  28-Sep-2008  mjf Sync with HEAD.
 1.95.6.2  29-Jun-2008  mjf Sync with HEAD.
 1.95.6.1  02-Jun-2008  mjf Sync with HEAD.
 1.96.2.5  09-Oct-2010  yamt sync with head
 1.96.2.4  11-Mar-2010  yamt sync with head
 1.96.2.3  16-Sep-2009  yamt sync with head
 1.96.2.2  04-May-2009  yamt sync with head.
 1.96.2.1  16-May-2008  yamt sync with head.
 1.97.2.2  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.97.2.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.100.2.2  31-Jul-2008  simonb Sync with head.
 1.100.2.1  18-Jun-2008  simonb Sync with head.
 1.101.2.1  19-Oct-2008  haad Sync with HEAD.
 1.103.8.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.103.2.1  28-Apr-2009  skrll Sync with HEAD.
 1.109.4.3  12-Jun-2011  rmind sync with head
 1.109.4.2  31-May-2011  rmind sync with head
 1.109.4.1  05-Mar-2011  rmind sync with head
 1.109.2.2  06-Nov-2010  uebayasi Sync with HEAD.
 1.109.2.1  22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.112.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.113.2.1  23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.114.10.1  19-Mar-2012  riz Pull up following revision(s) (requested by mrg in ticket #125):
sys/dev/scsipi/scsiconf.c: revision 1.263
sys/dev/scsipi/scsiconf.c: revision 1.264
sys/dev/ic/ncr53c9x.c: revision 1.144
sys/dev/ic/ninjascsi32.c: revision 1.22
sys/dev/usb/uhub.c: revision 1.117
take the kernel lock in functions called from attach*().
scsidevdetached ioctl path enters scsipi code without kernel lock
and this upsets the newer kasserts. take kernel lock here.
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".
 1.114.6.3  05-Apr-2012  mrg sync to latest -current.
 1.114.6.2  11-Mar-2012  mrg sync to latest -current
 1.114.6.1  06-Mar-2012  mrg sync to -current
 1.114.2.5  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.114.2.4  23-Jan-2013  yamt sync with head
 1.114.2.3  16-Jan-2013  yamt sync with (a bit old) head
 1.114.2.2  30-Oct-2012  yamt sync with head
 1.114.2.1  17-Apr-2012  yamt sync with head
 1.118.2.4  03-Dec-2017  jdolecek update from HEAD
 1.118.2.3  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.118.2.2  25-Feb-2013  tls resync with head
 1.118.2.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.123.2.1  18-May-2014  rmind sync with head
 1.124.4.2  05-Apr-2017  snj Pull up following revision(s) (requested by skrll in ticket #1395):
share/man/man4/axe.4: netbsd-7-nhusb
share/man/man4/axen.4: netbsd-7-nhusb
share/man/man4/cdce.4: netbsd-7-nhusb
share/man/man4/uaudio.4: netbsd-7-nhusb
share/man/man4/ucom.4: netbsd-7-nhusb
share/man/man4/uep.4: netbsd-7-nhusb
share/man/man4/urtw.4: netbsd-7-nhusb
share/man/man4/usb.4: netbsd-7-nhusb
share/man/man4/uyap.4: netbsd-7-nhusb
share/man/man4/xhci.4: netbsd-7-nhusb
share/man/man9/usbdi.9: netbsd-7-nhusb
sys/arch/amd64/conf/ALL: netbsd-7-nhusb
sys/arch/amd64/conf/GENERIC: netbsd-7-nhusb
sys/arch/amiga/dev/slhci_zbus.c: netbsd-7-nhusb
sys/arch/arm/allwinner/awin_otg.c: netbsd-7-nhusb
sys/arch/arm/allwinner/awin_usb.c: netbsd-7-nhusb
sys/arch/arm/amlogic/amlogic_dwctwo.c: netbsd-7-nhusb
sys/arch/arm/at91/at91ohci.c: netbsd-7-nhusb
sys/arch/arm/broadcom/bcm2835_dwctwo.c: netbsd-7-nhusb
sys/arch/arm/broadcom/bcm53xx_usb.c: netbsd-7-nhusb
sys/arch/arm/ep93xx/epohci.c: netbsd-7-nhusb
sys/arch/arm/gemini/obio_ehci.c: netbsd-7-nhusb
sys/arch/arm/imx/files.imx23: netbsd-7-nhusb
sys/arch/arm/imx/imxusb.c: netbsd-7-nhusb
sys/arch/arm/imx/imxusbreg.h: netbsd-7-nhusb
sys/arch/arm/omap/obio_ohci.c: netbsd-7-nhusb
sys/arch/arm/omap/omap3_ehci.c: netbsd-7-nhusb
sys/arch/arm/omap/omapl1x_ohci.c: netbsd-7-nhusb
sys/arch/arm/omap/tiotg.c: netbsd-7-nhusb
sys/arch/arm/s3c2xx0/ohci_s3c24x0.c: netbsd-7-nhusb
sys/arch/arm/samsung/exynos_usb.c: netbsd-7-nhusb
sys/arch/arm/xscale/pxa2x0_ohci.c: netbsd-7-nhusb
sys/arch/arm/zynq/zynq_usb.c: netbsd-7-nhusb
sys/arch/hpcarm/dev/nbp_slhci.c: netbsd-7-nhusb
sys/arch/hpcmips/dev/plumohci.c: netbsd-7-nhusb
sys/arch/i386/conf/ALL: netbsd-7-nhusb
sys/arch/i386/conf/GENERIC: netbsd-7-nhusb
sys/arch/i386/pci/gcscehci.c: netbsd-7-nhusb
sys/arch/luna68k/conf/GENERIC: netbsd-7-nhusb
sys/arch/mips/adm5120/dev/ahci.c: netbsd-7-nhusb
sys/arch/mips/adm5120/dev/ahcivar.h: netbsd-7-nhusb
sys/arch/mips/alchemy/dev/ohci_aubus.c: netbsd-7-nhusb
sys/arch/mips/atheros/dev/ehci_arbus.c: netbsd-7-nhusb
sys/arch/mips/atheros/dev/ohci_arbus.c: netbsd-7-nhusb
sys/arch/mips/conf/files.adm5120: netbsd-7-nhusb
sys/arch/mips/ralink/ralink_ehci.c: netbsd-7-nhusb
sys/arch/mips/ralink/ralink_ohci.c: netbsd-7-nhusb
sys/arch/mips/rmi/rmixl_ehci.c: netbsd-7-nhusb
sys/arch/mips/rmi/rmixl_ohci.c: netbsd-7-nhusb
sys/arch/playstation2/dev/ohci_sbus.c: netbsd-7-nhusb
sys/arch/powerpc/booke/dev/pq3ehci.c: netbsd-7-nhusb
sys/arch/powerpc/ibm4xx/dev/dwctwo_plb.c: netbsd-7-nhusb
sys/arch/x68k/dev/slhci_intio.c: netbsd-7-nhusb
sys/conf/files: netbsd-7-nhusb
sys/dev/cardbus/ehci_cardbus.c: netbsd-7-nhusb
sys/dev/cardbus/ohci_cardbus.c: netbsd-7-nhusb
sys/dev/cardbus/uhci_cardbus.c: netbsd-7-nhusb
sys/dev/ic/sl811hs.c: netbsd-7-nhusb
sys/dev/ic/sl811hsvar.h: netbsd-7-nhusb
sys/dev/isa/slhci_isa.c: netbsd-7-nhusb
sys/dev/marvell/ehci_mv.c: netbsd-7-nhusb
sys/dev/pci/ehci_pci.c: netbsd-7-nhusb
sys/dev/pci/ohci_pci.c: netbsd-7-nhusb
sys/dev/pci/uhci_pci.c: netbsd-7-nhusb
sys/dev/pci/xhci_pci.c: netbsd-7-nhusb
sys/dev/pcmcia/slhci_pcmcia.c: netbsd-7-nhusb
sys/dev/usb/Makefile.usbdevs: netbsd-7-nhusb
sys/dev/usb/TODO: netbsd-7-nhusb
sys/dev/usb/TODO.usbmp: netbsd-7-nhusb
sys/dev/usb/aubtfwl.c: netbsd-7-nhusb
sys/dev/usb/auvitek.c: netbsd-7-nhusb
sys/dev/usb/auvitek_audio.c: netbsd-7-nhusb
sys/dev/usb/auvitek_dtv.c: netbsd-7-nhusb
sys/dev/usb/auvitek_i2c.c: netbsd-7-nhusb
sys/dev/usb/auvitek_video.c: netbsd-7-nhusb
sys/dev/usb/auvitekvar.h: netbsd-7-nhusb
sys/dev/usb/ehci.c: netbsd-7-nhusb
sys/dev/usb/ehcireg.h: netbsd-7-nhusb
sys/dev/usb/ehcivar.h: netbsd-7-nhusb
sys/dev/usb/emdtv.c: netbsd-7-nhusb
sys/dev/usb/emdtv_dtv.c: netbsd-7-nhusb
sys/dev/usb/emdtv_ir.c: netbsd-7-nhusb
sys/dev/usb/emdtvvar.h: netbsd-7-nhusb
sys/dev/usb/ezload.c: netbsd-7-nhusb
sys/dev/usb/ezload.h: netbsd-7-nhusb
sys/dev/usb/files.usb: netbsd-7-nhusb
sys/dev/usb/hid.c: netbsd-7-nhusb
sys/dev/usb/hid.h: netbsd-7-nhusb
sys/dev/usb/if_athn_usb.c: netbsd-7-nhusb
sys/dev/usb/if_athn_usb.h: netbsd-7-nhusb
sys/dev/usb/if_atu.c: netbsd-7-nhusb
sys/dev/usb/if_atureg.h: netbsd-7-nhusb
sys/dev/usb/if_aue.c: netbsd-7-nhusb
sys/dev/usb/if_auereg.h: netbsd-7-nhusb
sys/dev/usb/if_axe.c: netbsd-7-nhusb
sys/dev/usb/if_axen.c: netbsd-7-nhusb
sys/dev/usb/if_axenreg.h: netbsd-7-nhusb
sys/dev/usb/if_axereg.h: netbsd-7-nhusb
sys/dev/usb/if_cdce.c: netbsd-7-nhusb
sys/dev/usb/if_cdcereg.h: netbsd-7-nhusb
sys/dev/usb/if_cue.c: netbsd-7-nhusb
sys/dev/usb/if_cuereg.h: netbsd-7-nhusb
sys/dev/usb/if_kue.c: netbsd-7-nhusb
sys/dev/usb/if_kuereg.h: netbsd-7-nhusb
sys/dev/usb/if_otus.c: netbsd-7-nhusb
sys/dev/usb/if_otusvar.h: netbsd-7-nhusb
sys/dev/usb/if_rum.c: netbsd-7-nhusb
sys/dev/usb/if_rumreg.h: netbsd-7-nhusb
sys/dev/usb/if_rumvar.h: netbsd-7-nhusb
sys/dev/usb/if_run.c: netbsd-7-nhusb
sys/dev/usb/if_runvar.h: netbsd-7-nhusb
sys/dev/usb/if_smsc.c: netbsd-7-nhusb
sys/dev/usb/if_smscreg.h: netbsd-7-nhusb
sys/dev/usb/if_smscvar.h: netbsd-7-nhusb
sys/dev/usb/if_udav.c: netbsd-7-nhusb
sys/dev/usb/if_udavreg.h: netbsd-7-nhusb
sys/dev/usb/if_upgt.c: netbsd-7-nhusb
sys/dev/usb/if_upgtvar.h: netbsd-7-nhusb
sys/dev/usb/if_upl.c: netbsd-7-nhusb
sys/dev/usb/if_ural.c: netbsd-7-nhusb
sys/dev/usb/if_uralreg.h: netbsd-7-nhusb
sys/dev/usb/if_uralvar.h: netbsd-7-nhusb
sys/dev/usb/if_url.c: netbsd-7-nhusb
sys/dev/usb/if_urlreg.h: netbsd-7-nhusb
sys/dev/usb/if_urndis.c: netbsd-7-nhusb
sys/dev/usb/if_urndisreg.h: netbsd-7-nhusb
sys/dev/usb/if_urtw.c: netbsd-7-nhusb
sys/dev/usb/if_urtwn.c: netbsd-7-nhusb
sys/dev/usb/if_urtwn_data.h: netbsd-7-nhusb
sys/dev/usb/if_urtwnreg.h: netbsd-7-nhusb
sys/dev/usb/if_urtwnvar.h: netbsd-7-nhusb
sys/dev/usb/if_urtwreg.h: netbsd-7-nhusb
sys/dev/usb/if_zyd.c: netbsd-7-nhusb
sys/dev/usb/if_zydreg.h: netbsd-7-nhusb
sys/dev/usb/irmce.c: netbsd-7-nhusb
sys/dev/usb/moscom.c: netbsd-7-nhusb
sys/dev/usb/motg.c: netbsd-7-nhusb
sys/dev/usb/motgvar.h: netbsd-7-nhusb
sys/dev/usb/ohci.c: netbsd-7-nhusb
sys/dev/usb/ohcireg.h: netbsd-7-nhusb
sys/dev/usb/ohcivar.h: netbsd-7-nhusb
sys/dev/usb/pseye.c: netbsd-7-nhusb
sys/dev/usb/slurm.c: netbsd-7-nhusb
sys/dev/usb/stuirda.c: netbsd-7-nhusb
sys/dev/usb/u3g.c: netbsd-7-nhusb
sys/dev/usb/uark.c: netbsd-7-nhusb
sys/dev/usb/uatp.c: netbsd-7-nhusb
sys/dev/usb/uaudio.c: netbsd-7-nhusb
sys/dev/usb/uberry.c: netbsd-7-nhusb
sys/dev/usb/ubsa.c: netbsd-7-nhusb
sys/dev/usb/ubsa_common.c: netbsd-7-nhusb
sys/dev/usb/ubsavar.h: netbsd-7-nhusb
sys/dev/usb/ubt.c: netbsd-7-nhusb
sys/dev/usb/uchcom.c: netbsd-7-nhusb
sys/dev/usb/ucom.c: netbsd-7-nhusb
sys/dev/usb/ucomvar.h: netbsd-7-nhusb
sys/dev/usb/ucycom.c: netbsd-7-nhusb
sys/dev/usb/udl.c: netbsd-7-nhusb
sys/dev/usb/udl.h: netbsd-7-nhusb
sys/dev/usb/udsbr.c: netbsd-7-nhusb
sys/dev/usb/udsir.c: netbsd-7-nhusb
sys/dev/usb/uep.c: netbsd-7-nhusb
sys/dev/usb/uftdi.c: netbsd-7-nhusb
sys/dev/usb/uftdireg.h: netbsd-7-nhusb
sys/dev/usb/ugen.c: netbsd-7-nhusb
sys/dev/usb/ugensa.c: netbsd-7-nhusb
sys/dev/usb/uhci.c: netbsd-7-nhusb
sys/dev/usb/uhcireg.h: netbsd-7-nhusb
sys/dev/usb/uhcivar.h: netbsd-7-nhusb
sys/dev/usb/uhid.c: netbsd-7-nhusb
sys/dev/usb/uhidev.c: netbsd-7-nhusb
sys/dev/usb/uhidev.h: netbsd-7-nhusb
sys/dev/usb/uhmodem.c: netbsd-7-nhusb
sys/dev/usb/uhso.c: netbsd-7-nhusb
sys/dev/usb/uhub.c: netbsd-7-nhusb
sys/dev/usb/uipad.c: netbsd-7-nhusb
sys/dev/usb/uipaq.c: netbsd-7-nhusb
sys/dev/usb/uirda.c: netbsd-7-nhusb
sys/dev/usb/uirdavar.h: netbsd-7-nhusb
sys/dev/usb/ukbd.c: netbsd-7-nhusb
sys/dev/usb/ukbdmap.c: netbsd-7-nhusb
sys/dev/usb/ukyopon.c: netbsd-7-nhusb
sys/dev/usb/ukyopon.h: netbsd-7-nhusb
sys/dev/usb/ulpt.c: netbsd-7-nhusb
sys/dev/usb/umass.c: netbsd-7-nhusb
sys/dev/usb/umass_isdata.c: netbsd-7-nhusb
sys/dev/usb/umass_isdata.h: netbsd-7-nhusb
sys/dev/usb/umass_quirks.c: netbsd-7-nhusb
sys/dev/usb/umass_quirks.h: netbsd-7-nhusb
sys/dev/usb/umass_scsipi.c: netbsd-7-nhusb
sys/dev/usb/umass_scsipi.h: netbsd-7-nhusb
sys/dev/usb/umassvar.h: netbsd-7-nhusb
sys/dev/usb/umcs.c: netbsd-7-nhusb
sys/dev/usb/umct.c: netbsd-7-nhusb
sys/dev/usb/umidi.c: netbsd-7-nhusb
sys/dev/usb/umidi_quirks.c: netbsd-7-nhusb
sys/dev/usb/umidi_quirks.h: netbsd-7-nhusb
sys/dev/usb/umodem.c: netbsd-7-nhusb
sys/dev/usb/umodem_common.c: netbsd-7-nhusb
sys/dev/usb/umodemvar.h: netbsd-7-nhusb
sys/dev/usb/ums.c: netbsd-7-nhusb
sys/dev/usb/uplcom.c: netbsd-7-nhusb
sys/dev/usb/urio.c: netbsd-7-nhusb
sys/dev/usb/urio.h: netbsd-7-nhusb
sys/dev/usb/usb.c: netbsd-7-nhusb
sys/dev/usb/usb.h: netbsd-7-nhusb
sys/dev/usb/usb_mem.c: netbsd-7-nhusb
sys/dev/usb/usb_mem.h: netbsd-7-nhusb
sys/dev/usb/usb_quirks.c: netbsd-7-nhusb
sys/dev/usb/usb_quirks.h: netbsd-7-nhusb
sys/dev/usb/usb_subr.c: netbsd-7-nhusb
sys/dev/usb/usbdevices.config: netbsd-7-nhusb
sys/dev/usb/usbdevs: netbsd-7-nhusb
sys/dev/usb/usbdevs.h: netbsd-7-nhusb
sys/dev/usb/usbdevs_data.h: netbsd-7-nhusb
sys/dev/usb/usbdi.c: netbsd-7-nhusb
sys/dev/usb/usbdi.h: netbsd-7-nhusb
sys/dev/usb/usbdi_util.c: netbsd-7-nhusb
sys/dev/usb/usbdi_util.h: netbsd-7-nhusb
sys/dev/usb/usbdivar.h: netbsd-7-nhusb
sys/dev/usb/usbhid.h: netbsd-7-nhusb
sys/dev/usb/usbhist.h: netbsd-7-nhusb
sys/dev/usb/usbroothub.c: netbsd-7-nhusb
sys/dev/usb/usbroothub.h: netbsd-7-nhusb
sys/dev/usb/usbroothub_subr.c: delete
sys/dev/usb/usbroothub_subr.h: delete
sys/dev/usb/uscanner.c: netbsd-7-nhusb
sys/dev/usb/uslsa.c: netbsd-7-nhusb
sys/dev/usb/usscanner.c: netbsd-7-nhusb
sys/dev/usb/ustir.c: netbsd-7-nhusb
sys/dev/usb/uthum.c: netbsd-7-nhusb
sys/dev/usb/utoppy.c: netbsd-7-nhusb
sys/dev/usb/uts.c: netbsd-7-nhusb
sys/dev/usb/uvideo.c: netbsd-7-nhusb
sys/dev/usb/uvisor.c: netbsd-7-nhusb
sys/dev/usb/uvscom.c: netbsd-7-nhusb
sys/dev/usb/uyap.c: netbsd-7-nhusb
sys/dev/usb/uyap_firmware.h: netbsd-7-nhusb
sys/dev/usb/uyurex.c: netbsd-7-nhusb
sys/dev/usb/x1input_rdesc.h: netbsd-7-nhusb
sys/dev/usb/xhci.c: netbsd-7-nhusb
sys/dev/usb/xhcireg.h: netbsd-7-nhusb
sys/dev/usb/xhcivar.h: netbsd-7-nhusb
sys/dev/usb/xinput_rdesc.h: netbsd-7-nhusb
sys/external/bsd/common/conf/files.linux: netbsd-7-nhusb
sys/external/bsd/common/include/linux/err.h: netbsd-7-nhusb
sys/external/bsd/common/include/linux/kernel.h: netbsd-7-nhusb
sys/external/bsd/common/include/linux/workqueue.h: netbsd-7-nhusb
sys/external/bsd/common/linux/linux_work.c: netbsd-7-nhusb
sys/external/bsd/drm2/dist/drm/radeon/atombios_encoders.c: netbsd-7-nhusb
sys/external/bsd/drm2/dist/drm/radeon/radeon_legacy_encoders.c: netbsd-7-nhusb
sys/external/bsd/drm2/drm/files.drmkms: netbsd-7-nhusb
sys/external/bsd/drm2/i915drm/files.i915drmkms: netbsd-7-nhusb
sys/external/bsd/drm2/include/linux/err.h: delete
sys/external/bsd/drm2/include/linux/workqueue.h: delete
sys/external/bsd/drm2/linux/files.drmkms_linux: netbsd-7-nhusb
sys/external/bsd/drm2/linux/linux_work.c: delete
sys/external/bsd/dwc2/dwc2.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dwc2.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dwc2var.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dwctwo2netbsd: netbsd-7-nhusb
sys/external/bsd/dwc2/conf/files.dwc2: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_core.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_core.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_coreintr.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcd.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcd.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcdddma.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcdintr.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcdqueue.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hw.h: netbsd-7-nhusb
sys/modules/drmkms_linux/Makefile: netbsd-7-nhusb
sys/modules/i915drmkms/Makefile: netbsd-7-nhusb
sys/rump/dev/lib/libugenhc/ugenhc.c: netbsd-7-nhusb
sys/rump/dev/lib/libusb/Makefile: netbsd-7-nhusb
sys/rump/dev/lib/libusb/USB.ioconf: netbsd-7-nhusb
sys/rump/dev/lib/libusb/usb_at_ugenhc.c: delete
sys/rump/dev/lib/libusb/opt/opt_usb.h: delete
sys/rump/dev/lib/libusb/opt/opt_usbverbose.h: delete
sys/sys/mbuf.h: netbsd-7-nhusb
usr.sbin/usbdevs/usbdevs.8: netbsd-7-nhusb
usr.sbin/usbdevs/usbdevs.c: netbsd-7-nhusb
Merge netbsd-7-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
- Change the SOFTINT level from NET to SERIAL for the USB softint handler.
This gives the callback a chance of running when another softint handler
at SOFTINT_NET has blocked holding a lock, e.g. softnet_lock and most of
the network stack.
- kern/49065 - ifconfig tun0 ... sequence locks up system / lockup:
softnet_lock held across usb xfr
- kern/50491 - unkillable wait in usbd_transfer while using usmsc0
on raspberry pi 2
- kern/51395 - USB Ethernet makes xhci hang
- Various improvements to slhci(4)
- Various improvements to dwc2(4)
 1.124.4.1  08-Mar-2016  snj branches: 1.124.4.1.2;
Pull up following revision(s) (requested by skrll in ticket #1134):
sys/dev/usb/uhub.c: revision 1.130
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.
 1.124.4.1.2.2  26-Jan-2017  skrll Sync with HEAD/nhusb
 1.124.4.1.2.1  06-Sep-2016  skrll First pass at netbsd-7 updated with USB code from HEAD
 1.126.2.31  28-Aug-2017  skrll Sync with HEAD
 1.126.2.30  05-Dec-2016  skrll Sync with HEAD
 1.126.2.29  05-Oct-2016  skrll Sync with HEAD
 1.126.2.28  10-Apr-2016  skrll Revert 1.126.2.12 partially: fix some devices ware not recognized.
uhub would give up enumeration too quickly.

From Takahiro HAYASHI
 1.126.2.27  10-Apr-2016  skrll default uhubdebug to 0 again
 1.126.2.26  10-Apr-2016  skrll Fix a debug message: sync with other device name expressions.

From Takahiro HAYASHI
 1.126.2.25  10-Apr-2016  skrll Add a comment
 1.126.2.24  29-Mar-2016  skrll Whitespace
 1.126.2.23  16-Feb-2016  skrll Re-enable the TT support that existed previously here as well
 1.126.2.22  06-Feb-2016  skrll Pull across fix from HEAD

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.
 1.126.2.21  28-Jan-2016  skrll Whitespace
 1.126.2.20  02-Jan-2016  skrll Destroy the mutex on detach
 1.126.2.19  02-Jan-2016  skrll Add a missing curly from previous
 1.126.2.18  02-Jan-2016  skrll Generalise the hub status change notification and registering of
pending changes while exploring.

Notifications could be lost before
 1.126.2.17  02-Jan-2016  skrll Make debug output consistent
 1.126.2.16  03-Oct-2015  skrll From t-hash
+ Import port speed detection code from OpenBSD.
Check port power bit instead of speed bits. It's a cool idea.
 1.126.2.15  29-Sep-2015  skrll sizeof KNF
 1.126.2.14  23-Sep-2015  skrll From t-hash
+ Fix devices were not recognized at boot on some xhci
(AFAIK Intel PCHs).
 1.126.2.13  06-Jun-2015  skrll Simplify treatment of WRC condition and add comments.

From t-hash.
 1.126.2.12  28-May-2015  skrll More changes from Takahiro HAYASHI

+ Add sc_statuspend that stores ports bitmap of pending interrupts
instead of sc_isxhciroothub hack til someone implements suspend pipe.
While sc_explorepending == 1, uhub_intr shall merge sc_status into
sc_statuspend.
+ Eliminate confusing UPS_SUPER_SPEED flag and introduce
UPS_OTHER_SPEED flag that indicates ud_speed of device is
super speed (or more).
uhub shall set this flag if ud_speed is super speed (or more).
+ Add the macro that checks ud_speed is super speed.
The codes shall use this macro to check ud_speed is super speed.
+ Add speed type conversion functions.
+ Include port link status in port_status if port is super speed.

Various other changes to support SS hubs and devices
 1.126.2.11  07-Apr-2015  skrll Another DPRINTF. From Takahiro HAYASHI.
 1.126.2.10  07-Apr-2015  skrll KNF
 1.126.2.9  06-Apr-2015  skrll Sync with HEAD
 1.126.2.8  21-Mar-2015  skrll Add prefixes to attach_arg structure member names. No functional change.
 1.126.2.7  19-Mar-2015  skrll Do the same as OpenBSD and get rid of the *_handle typedefs and use
plain structures insteads
 1.126.2.6  06-Dec-2014  skrll Fix pasto that meant kmem_free was called twice against sc_statusbuf. Free
sc_status instead.
 1.126.2.5  06-Dec-2014  skrll KNF. Remove argument name from function declarations.

No functional change.
 1.126.2.4  05-Dec-2014  skrll KNF. Remove ( ) from return statements.
 1.126.2.3  03-Dec-2014  skrll Replace malloc(9) with kmem(9)
 1.126.2.2  03-Dec-2014  skrll The grand renaming of structure members.

No functional change.
 1.126.2.1  30-Nov-2014  skrll Use C99 types. u_int{8,16,32,64}_t to uint{8,16,32,64}_t.

No functional change.
 1.133.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.136.2.3  04-Nov-2018  martin Pull up following revision(s) (requested by manu in ticket #1078):

sys/dev/usb/uhub.c: revision 1.140
sys/dev/usb/uhub.c: revision 1.141
sys/dev/usb/usb_subr.c: revision 1.228

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.

-

Make USB port iteration code consistent, always startint at port #1
This complements change in revision 1.140
 1.136.2.2  27-Sep-2018  martin Pull up following revision(s) (requested by mrg in ticket #1037):

sys/dev/usb/uhub.c: revision 1.139
sys/external/bsd/dwc2/dwc2.c: revision 1.55
sys/ddb/db_output.c: revision 1.34
sys/ddb/db_command.c: revision 1.160
sys/dev/usb/ehci.c: revision 1.264
sys/dev/usb/xhci.c: revision 1.99
sys/dev/usb/ehci.c: revision 1.265
sys/kern/subr_userconf.c: revision 1.27
sys/dev/usb/ehcivar.h: revision 1.46
sys/dev/usb/ohci.c: revision 1.287
sys/dev/usb/uhci.c: revision 1.284
sys/dev/usb/usbdi.c: revision 1.178
sys/dev/usb/usb.c: revision 1.172
sys/dev/pci/xhci_pci.c: revision 1.14
sys/dev/usb/usb.c: revision 1.173
sys/dev/usb/usb.c: revision 1.174
share/man/man4/usb.4: revision 1.110
sys/ddb/db_command.c: revision 1.159
sys/dev/usb/usb_subr.c: revision 1.227
sys/dev/usb/uhcivar.h: revision 1.56
(all via patch)

consolidate the handling of polling across HC drivers, and generic USB:
- don't take mutexes if polling
- normalise the code across all drivers
- add some not yet code to block discovery to/from polling
- minor CSE
- adjust comment for usbd_set_polling() to reality now i properly
understand what it is used for and why.

this, with a hack to make RB_ASKNAME to wait 5 seconds allows boot -a
work with USB keyboards. there are still multiple issues remaining:
- discovery and polling need to be mutually exclusive
- attachment of ukbd and wskbd is not handled by config_pending, and
the 5 second delay isn't going to always be enough.

call cnpollc(1) and cnpollc(0) around cngetc().
(christos has a good idea to add a function that does all 3,
and we should switch all the callers in this sequence to use
it (and fix the MD ones missing it still). not all can, as
eg, line-grabbing functions can use cngetsn(), which only
calls cnpollc() twice.)


When this file is used when not building the kernel (eg: /usr/sbin/crash)
make cnpollc() go away.


reorder some struct members to remove holes.


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.


implement a gross hack to fix "boot -a" on systems with usb keyboards on
systems with ehci handover to uhci (and maybe ohci), and fix a similar
problem for "boot -s".

there is effort to ensure that all devices attached via USB are probed
before RB_ASKNAME or RB_SINGLE attempts to ask any questions on the console,
and largely this works, often by chance, today, for USB disks and root.
i've recently pushed this more into uhub and general USB device attachment
as well, and kept a config_pending reference across the first explore of
a bus. these fix many issues with directly attached hubs.

however, on systems where devices connected to ehci ports are handed over
to a companion uhci or ohci port, it may not be the first, or even second,
bus explore that finds the device finally before attachment, and at this
point all config_pending references are dropped.

there is no direct communication between drivers, the potentials are
looked up but their device_t is only used for generic things like the name,
so informing the correct companion to expect a device and deal with the
config_pending references is not possible without some fairly ugly layer
violations or multi-level callbacks (eg, we have "ehci0", and usually an
the relevant companion, eg, "uhci2", but it is the uhub that uhci2 has
attached that will deal with the device attachment.)

with the above fixes to generic USB code, the disown happens during the
first explore. the hack works by, at this point, checking if (a) root
is not mounted, (b) single user or ask name are set, and (c) if the hack
as not been triggered already. if all 3 conditions are true, then a
config_pending_incr() is called and a callback is triggered for (default)
5 seconds to call config_pending_decr(). ehci detach pauses waiting for
this callback if scheduled.

this allows enough time for the uhub and the ukbd/wskbd to attach before
the RK_ASKROOT prompts appear. testing shows it takes between 1.5 and
2 seconds for the keyboard to appear after the disown occurs.

Index: dev/usb/ehcivar.c
- new sc_compcallout, sc_compcallout, sc_complock, and a state for th
handover hack.

Index: dev/usb/ehci.c
ehci_init():
- use aprint_normal_dev() instead of manual device_xname().
- initialise sc_compcallout, sc_compcallout, sc_complock, and sc_comp_state.
ehci_detach():
- if there are companion controllers, tear own the above, including waiting
if there is a callback scheduled.
ehci_disown_callback():
- new callout to call config_pending_decr() in the the future.
schedule this ca
ehci_disown_sched_callback():
- if booting to single user or asking names, call config_pending_incr() and
schedule the callout above, default 5 second delay.
ehci_disown():
- if disowning a port call ehci_disown_sched_callback().
deal with partial attach failures in usb_attach vs usb_detach aka PR 53598.
- make sure xhci's sc->sc_ios is NULL if failure happens.
- rearrange usb_attach() / usb_doattach() to make it simpler to clean up.
- move usb_async_intr softint into usb_once_init(). previously, each USB
controller would start a new one, and leave the old one leaked.
- handle controller interrupts without a bus attached


remove usb(4)'s "flags 1" code. it has been dead for a while,
as it runs during the interrupts part of configuration now,
and all the devices try attach as early as possible, including
any root or boot required disk or keyboard device, which is
what this flag was for.
 1.136.2.1  02-Nov-2017  snj Pull up following revision(s) (requested by pgoyette in ticket #335):
share/man/man9/kernhist.9: 1.5-1.8
sys/arch/acorn26/acorn26/pmap.c: 1.39
sys/arch/arm/arm32/fault.c: 1.105 via patch
sys/arch/arm/arm32/pmap.c: 1.350, 1.359
sys/arch/arm/broadcom/bcm2835_bsc.c: 1.7
sys/arch/arm/omap/if_cpsw.c: 1.20
sys/arch/arm/omap/tiotg.c: 1.7
sys/arch/evbarm/conf/RPI2_INSTALL: 1.3
sys/dev/ic/sl811hs.c: 1.98
sys/dev/usb/ehci.c: 1.256
sys/dev/usb/if_axe.c: 1.83
sys/dev/usb/motg.c: 1.18
sys/dev/usb/ohci.c: 1.274
sys/dev/usb/ucom.c: 1.119
sys/dev/usb/uhci.c: 1.277
sys/dev/usb/uhub.c: 1.137
sys/dev/usb/umass.c: 1.160-1.162
sys/dev/usb/umass_quirks.c: 1.100
sys/dev/usb/umass_scsipi.c: 1.55
sys/dev/usb/usb.c: 1.168
sys/dev/usb/usb_mem.c: 1.70
sys/dev/usb/usb_subr.c: 1.221
sys/dev/usb/usbdi.c: 1.175
sys/dev/usb/usbdi_util.c: 1.67-1.70
sys/dev/usb/usbroothub.c: 1.3
sys/dev/usb/xhci.c: 1.75
sys/external/bsd/drm2/dist/drm/i915/i915_gem.c: 1.34
sys/kern/kern_history.c: 1.15
sys/kern/kern_xxx.c: 1.74
sys/kern/vfs_bio.c: 1.275-1.276
sys/miscfs/genfs/genfs_io.c: 1.71
sys/sys/kernhist.h: 1.21
sys/ufs/ffs/ffs_balloc.c: 1.63
sys/ufs/lfs/lfs_vfsops.c: 1.361
sys/ufs/lfs/ulfs_inode.c: 1.21
sys/ufs/lfs/ulfs_vnops.c: 1.52
sys/ufs/ufs/ufs_inode.c: 1.102
sys/ufs/ufs/ufs_vnops.c: 1.239
sys/uvm/pmap/pmap.c: 1.37-1.39
sys/uvm/pmap/pmap_tlb.c: 1.22
sys/uvm/uvm_amap.c: 1.108
sys/uvm/uvm_anon.c: 1.64
sys/uvm/uvm_aobj.c: 1.126
sys/uvm/uvm_bio.c: 1.91
sys/uvm/uvm_device.c: 1.66
sys/uvm/uvm_fault.c: 1.201
sys/uvm/uvm_km.c: 1.144
sys/uvm/uvm_loan.c: 1.85
sys/uvm/uvm_map.c: 1.353
sys/uvm/uvm_page.c: 1.194
sys/uvm/uvm_pager.c: 1.111
sys/uvm/uvm_pdaemon.c: 1.109
sys/uvm/uvm_swap.c: 1.175
sys/uvm/uvm_vnode.c: 1.103
usr.bin/vmstat/vmstat.c: 1.219
Reorder to test for null before null deref in debug code
--
Reorder to test for null before null deref in debug code
--
KNF
--
No need for '\n' in UVMHIST_LOG
--
normalise a BIOHIST log message
--
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.
--
For some reason this single kernel seems to have outgrown its declared
size as a result of the kernhist(9) changes. Bump the size.
XXX The amount of increase may be excessive - anyone with more detailed
XXX knowledge please feel free to further adjust the value
appropriately.
--
Misssed one cast of pointer --> uintptr_t in previous kernhist(9) commit
--
And yet another one. :(
--
Use correct mark-up for NetBSD version.
--
More improvements in grammar and readability.
--
Remove a stray '"' (obvious typo) and add a couple of casts that are
probably needed.
--
And replace an instance of "%p" conversion with "%#jx"
--
Whitespace fix. Give Bl tag table a width. Fix Xr.
 1.138.4.3  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.138.4.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.138.4.1  10-Jun-2019  christos Sync with HEAD
 1.138.2.3  26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.138.2.2  20-Oct-2018  pgoyette Sync with head
 1.138.2.1  30-Sep-2018  pgoyette Ssync with HEAD
 1.142.2.1  01-Sep-2019  martin Pull up following revision(s) (requested by mrg in ticket #135):

distrib/sets/lists/comp/mi 1.2279
distrib/sets/lists/modules/mi 1.123
share/man/man9/Makefile 1.438
share/man/man9/usbnet.9 1.1-1.9
sys/dev/ic/rndisreg.h 1.3
sys/dev/usb/TODO 1.47-1.52
sys/dev/usb/TODO.usbmp 1.15,1.16
sys/dev/usb/files.usb 1.157-1.167
sys/dev/usb/if_aue.c 1.155-1.161
sys/dev/usb/if_auereg.h 1.30-1.32
sys/dev/usb/if_axe.c 1.103-1.119
sys/dev/usb/if_axen.c 1.51-1.53,1.55-1.67
sys/dev/usb/if_axenreg.h 1.15
sys/dev/usb/if_cdce.c 1.54-1.67
sys/dev/usb/if_cue.c 1.85,1.86
sys/dev/usb/if_cuereg.h 1.23
sys/dev/usb/if_kue.c 1.97-1.100
sys/dev/usb/if_kuereg.h 1.23,1.24
sys/dev/usb/if_mue.c 1.51-1.55
sys/dev/usb/if_muereg.h 1.6
sys/dev/usb/if_muevar.h 1.9
sys/dev/usb/if_smsc.c 1.46-1.61
sys/dev/usb/if_smscreg.h 1.6
sys/dev/usb/if_smscvar.h delete
sys/dev/usb/if_udav.c 1.60-1.71
sys/dev/usb/if_udavreg.h 1.14,1.15
sys/dev/usb/if_upl.c 1.65,1.66
sys/dev/usb/if_ure.c 1.15-1.31
sys/dev/usb/if_urevar.h 1.4,1.5
sys/dev/usb/if_url.c 1.67-1.70
sys/dev/usb/if_urlreg.h 1.14
sys/dev/usb/if_urndis.c 1.22-1.33
sys/dev/usb/if_urtwn.c 1.72
sys/dev/usb/ohci.c 1.290
sys/dev/usb/uhub.c 1.143
sys/dev/usb/usb.c 1.180
sys/dev/usb/usb.h 1.118
sys/dev/usb/usb_mem.c 1.71
sys/dev/usb/usb_subr.c 1.238,1.239
sys/dev/usb/usbdevs 1.772
sys/dev/usb/usbdi.c 1.183,1.186
sys/dev/usb/usbdi.h 1.97
sys/dev/usb/usbdi_util.c 1.75
sys/dev/usb/usbhist.h 1.5,1.6
sys/dev/usb/usbnet.c 1.1-1.24
sys/dev/usb/usbnet.h 1.1-1.14
sys/dev/usb/usbroothub.c 1.9
sys/dev/usb/xhci.c 1.109,1.110
sys/modules/Makefile 1.223
sys/modules/usbnet/Makefile 1.1

usbnet(9): Add common framework for USB network devices.
This bring various safety fixes to all updated drivers,
and includes locking clean up, detach safety when being
used or not, separate rx/tx locks to improve performance,
porting to NET_MPSAFE, many edge/error case bugs in
drivers fixed, as well as resovling PRs 54303 and 54308.
These drivers are converted: axe(4), axen(4), aue(4),
cdce(4), cue(4), kue(4), mue(4), smsc(4), udav(4),
upl(4), ure(4), url(4), and urndis(4).
 1.147.6.1  17-Jun-2021  thorpej Sync w/ HEAD.

RSS XML Feed