Commit Graph

288164 Commits

Author SHA1 Message Date
mlelstv 77c8c4e671 iic_acquire_bus can fail 2021-06-13 09:48:04 +00:00
mlelstv 65c5d463c9 Clear sc_sme pointer to avoid double free. 2021-06-13 09:47:36 +00:00
mlelstv 3944730ede iic_acquire_bus can fail. 2021-06-13 09:46:04 +00:00
mlelstv 6f4e190db8 Refactor handling of "quad utms" devices and more. 2021-06-13 09:32:01 +00:00
riastradh 55999d82b5 autoconf(9): Take kernel lock in config_detach.
config_detach is used in too many places to audit for now -- so
although I'm quite sure it is racy (e.g., with cloning devices and
drvctl: drvctl -d a newly opened fss0 before sc_state has
transitioned from FSS_IDLE), this will mitigate the immediate fallout
until we can properly fix autoconf's notions of device pointers.
2021-06-13 09:30:48 +00:00
mlelstv 0ee61f5593 Handle IXON,IXOFF individually. 2021-06-13 09:29:38 +00:00
mlelstv aa8cf322fd Fix envsys detach paths. 2021-06-13 09:28:23 +00:00
mlelstv 418cc54c2d Remove duplicate. 2021-06-13 09:27:20 +00:00
mlelstv b8a416c588 Align product name. 2021-06-13 09:26:24 +00:00
mlelstv beef52d407 Remove duplicate 2021-06-13 09:24:33 +00:00
mlelstv 99b5e62771 Regen 2021-06-13 09:24:11 +00:00
mlelstv e68c71ef7a Correct some vendor names, remove duplicates. 2021-06-13 09:23:42 +00:00
mlelstv bcbb673126 Fix last patch. 2021-06-13 09:12:24 +00:00
mlelstv dc303100ab Use correct integer lengths for properties.
Change property names vendor -> vendor-id, product -> product-id to match other users.
2021-06-13 08:50:33 +00:00
mlelstv 29f49f968e Fix non-DIAGNOSTIC build. 2021-06-13 08:48:29 +00:00
mlelstv ca3a9837ca Don't use aprint* for non-autoconf errors. Also print status value. 2021-06-13 07:51:09 +00:00
mlelstv 36b60a2939 Don't ignore detach errors from children. 2021-06-13 07:49:43 +00:00
christos 1ce5586116 need to copyin when reading the hash name from userland 2021-06-13 03:09:20 +00:00
christos d656ee6ff2 bump, something changed and the kernel does not boot with .84 modules. 2021-06-13 03:07:57 +00:00
riastradh e5b3013c11 usb(4): Tighten interface locking and pipe references.
- Just use a reference count, not a list of pipes.

- Take the reference in usbd_open_pipe*, before we even look up the
  endpoint by address; the endpoint is not stable until we hold the
  interface and prevent usbd_set_interface.

- Make opening pipes just fail if usbd_set_interface is in progress.
  => No need to block -- might block for a while, and this is
     essentially a driver error rather than a legitimate reason to
     block.
  => This should maybe be a kassert, but it's not clear that ugen(4)
     doesn't have a user-triggerable path to that kassert, so let's
     keep it as a graceful failure for now until someone can audit
     ugen(4) and make an informed decision.

- No need for a separate interface pipe lock; just use the bus lock.

This is a little bit longer than before, but makes the bracketed
nature of the references a little clearer and introduces more
kasserts to detect mistakes with internal API usage.
2021-06-13 00:13:24 +00:00
riastradh eb524e198d 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.
2021-06-13 00:11:57 +00:00
riastradh 05937cebb9 autoconf(9): Sprinkle KASSERT(dev->dv_pending == 0) in dealloc paths.
This would have made uhub's config_pending_incr leak more obvious by
crashing in KASSERT(dev->dv_pending == 0) early on, rather than
crashing in a tailq panic later on when the config_pending list gets
corrupted with use-after-free because nothing took the device off
dv_pending_list when attached.

(This is slightly academic now because config_detach blocks until
dev->dv_pending == 0, but it doesn't hurt and makes the intent
clearer.)
2021-06-13 00:11:46 +00:00
riastradh 2197f1d53f autoconf(9): Take kernel lock in a few entry points.
The arguments to config_attach_pseudo, config_init/fini_component,
and config_cfdata_attach/detach are generally statically allocated
objects in a module or the main kernel and as such are stable, and
there are no data structure invariants they assume the kernel lock
will covers from call to call.  So there should be no need for the
caller to hold the kernel lock.

Should fix panic on modload of, e.g., nvmm.
2021-06-13 00:11:17 +00:00
riastradh c641d71841 usb(4): Nix unused struct usbd_interface::ui_priv. 2021-06-12 15:49:45 +00:00
riastradh 9ee18b1c5c usb(4): Make usbd_fill_iface_data atomic.
Now either it replaces and frees the old endpoints array, or it
leaves everything in place; it never leaves a partial update nor
requires the caller to free the old array.
2021-06-12 15:41:22 +00:00
riastradh 5f20b1789e usb(4): Tweak style in usbd_close_pipe.
No functional change intended.
2021-06-12 15:40:07 +00:00
riastradh c1df5733a6 usb(4): Merge logic in usbd_kill_pipe and usbd_close_pipe.
usbd_kill_pipe is now just usbd_abort/close_pipe.

No functional change intended.
2021-06-12 15:39:57 +00:00
riastradh ce22f263a5 usb(4): Fix fix for interface change pipe fix.
If there is an interface:
- Always put the pipe on the list in usbd_setup_pipe (if successful).
- Always have the pipe on the list from _before_ upm_open.
- Always keep the pipe on the list to _after_ upm_close, and after
  the async task has completed.

This brings the logic in usbd_close_pipe and usbd_kill_pipe closer.
2021-06-12 15:39:46 +00:00
riastradh 43896fbbcf Revert "usb(4): Fix mistake in previous fix for pipe/interface-change races."
Little too fast on the commit trigger there before testing, oops.
We don't have the pipe yet until usbd_setup_pipe_flags returns!
2021-06-12 15:09:18 +00:00
riastradh aad0fb1482 usb(4): Fix mistake in previous fix for pipe/interface-change races.
Must block interface changes _before_ we enter usbd_setup_pipe_flags,
which calls the bus pipe open method.
2021-06-12 14:57:53 +00:00
riastradh 634db953cc usb(4): Fix races between usbd_open_pipe* and usbd_set_interface. 2021-06-12 14:43:27 +00:00
riastradh 76bec4db31 usb(4): Fix racy endpoint reference counting.
Rules:

1. After usbd_setup_pipe*, must usbd_kill_pipe.
2. After usbd_open_pipe*, must usbd_close_pipe.

Still haven't merged the logic in usbd_kill_pipe and usbd_close_pipe,
but getting closer.
2021-06-12 13:58:05 +00:00
riastradh 42500bf1d8 usb(4): Omit needless lock/unlock cycle in usbd_pipe_close.
pipe->up_intrxfer is stable after construction, so no need to hold
the lock to check it.
2021-06-12 13:57:51 +00:00
riastradh d14757b9b6 usb(4): Cancel and wait for async task on closing pipe.
XXX usbd_kill_pipe and usbd_close_pipe should not be copypasta; there
should be only one instance of this logic.
2021-06-12 13:57:40 +00:00
riastradh 1d83212298 ath(4): Use config_deactivate; don't abuse autoconf private dv_flags. 2021-06-12 12:15:54 +00:00
riastradh 0052d10847 ipmi(4), intelfb(4): Use config_pending_incr/decr.
Don't abuse autoconf's private (and incoherent) dv_flags.
2021-06-12 12:15:43 +00:00
riastradh 2a6fb6d606 autoconf(9): Must hold alldevs_lock to iterate dv_list on alldevs. 2021-06-12 12:14:13 +00:00
riastradh e3da9f01d0 drvctl(4): Hold a deviter while issuing config_detach.
Otherwise another concurrent detach -- e.g., from concurrent drvctl
or from USB port disconnection -- can pull the device_t out from
under us.

XXX Need to do this for _every_ operation config_* operation on a
device_t; device_find_by_xname is just fundamentally broken because a
concurrent detach can pull the device_t rug out from under you.

We really need another mechanism for holding a weak reference to a
device, and temporarily getting a strong reference to it; abusing
deviter is a bit of a kludge, and doesn't work very well because it
doesn't properly trigger garbage collection of devices detached while
other concurrent deviters are pending.
2021-06-12 12:14:03 +00:00
riastradh fffd8cfe29 autoconf(9): Prevent concurrent attach/detach and detach/detach.
- Use config_pending_incr/decr around attach.  No need for separate
  flag indicating device is still attaching.  (dv_flags locking is also
  incoherent.)

- Any config_pending now blocks config_detach.

- New dv_detaching exclusive lock for config_detach.
2021-06-12 12:13:51 +00:00
riastradh 47e570fcd6 usb(4), uhub(4): Sprinkle usbhist. 2021-06-12 12:13:23 +00:00
riastradh 53828d889d usb(4): Sprinkle kernel lock assertions. 2021-06-12 12:13:10 +00:00
riastradh d19502f578 autoconf(9), drvctl(4): Sprinkle kernel lock assertions. 2021-06-12 12:12:11 +00:00
riastradh 61e759e504 drvctl(4): Take the kernel lock around entry into autoconf(9).
Can make this finer-grained once the rest of autoconf(9) is in good
enough shape to support it.
2021-06-12 12:11:59 +00:00
riastradh 5a0c6b14f9 autoconf(9): Take kernel lock on various entries into autoconf.
Most of autoconf still tacitly assumes the kernel lock is held.
2021-06-12 12:11:49 +00:00
riastradh 777d347a77 usb(4): usb event thread is not actually MP-safe.
Still requires a lot of work in usb(4), uhub(4), and autoconf(9).
2021-06-12 12:11:38 +00:00
riastradh efe6b280f2 usb(4): Verify dev->ud_subdevs is still there before freeing it.
usbd_attachinterfaces may sleep, and if it does, it releases the
kernel lock, in which case another thread may free dev->ud_subdevs.
2021-06-12 12:11:27 +00:00
riastradh b8613a76ba usb(4): kmem_zalloc(KM_SLEEP) cannot fail; nix error branch. 2021-06-12 12:11:11 +00:00
riastradh c354e0da68 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.
2021-06-12 12:11:01 +00:00
mrg 7c8cb6a3f2 fix comment to talk about correct units (kelvin, not seconds). 2021-06-12 00:04:46 +00:00
pgoyette 86f2feafd5 Remove extraneous '\n' from debug message. 2021-06-11 23:41:47 +00:00