summaryrefslogtreecommitdiff
path: root/sys/dev
AgeCommit message (Collapse)Author
2022-03-03usbnet: Take the core lock around uno_mcast.riastradh
Every driver does this already. This will enable us to change the lock that serializes access to the registers so we can go back to doing this synchronously in SIOCADDMULTI/SIOCDELMULTI.
2022-03-03usbnet drivers: Omit needless uno_init locked subroutines.riastradh
uno_init is now called with the core lock already held so there is no need for a separate locked subroutine.
2022-03-03usbnet: No need for the core lock in usbnet_ifflags_cb.riastradh
The only state this touches is unp_if_flags, and all paths touching it also hold IFNET_LOCK -- not to mention this is the only path that touches unp_if_flags in the first place!
2022-03-03usbnet: Make the tx/rx locks private to usbnet.c.riastradh
Suffice it for the drivers to know that uno_tx_prepare and uno_rx_loop have exclusive access to the chain, and, for tx, exclusive access to the mbuf.
2022-03-03usbnet: usbnet_busy is no longer referenced; release it!riastradh
2022-03-03usbnet: No need for usbnet_busy in mii callbacks.riastradh
After mii_detach, these have all completed and no new ones can be made, and detach doesn't start destroying anything until after mii_detach has returned, so there is no need to hang onto a reference count here.
2022-03-03usbnet: No need for usbnet_busy in usbnet_init_rx_tx or usbnet_stop.riastradh
These run with IFNET_LOCK held, and the interface cannot be detached until the IFNET_LOCK is released, so there is no need to hang onto a reference count here.
2022-03-03usbnet drivers: No need for usbnet_busy during attach.riastradh
usbnet_detach cannot run until the attach routine has finished (unless a driver goes out of its way to tie its shoelaces together and explicitly call it during the attach routine, which none of them do), so there is no need to hang onto a reference count that we release before attach returns.
2022-03-03usbnet drivers: No need for usbnet_busy in uno_ioctl.riastradh
This callback always runs with the IFNET_LOCK held, and the interface cannot be detached until the IFNET_LOCK is released, so there is no need to hang onto a reference count here. (None of the subnet drivers touch the IFNET_LOCK except to verify it is held sometimes.)
2022-03-03usbnet drivers: No need for usbnet_busy in uno_mcast.riastradh
This callback always runs with IFNET_LOCK held, and during a task that usbnet_detach prevents scheduling anew and waits for finishing before completing the detach, so there is no need to hang onto a reference count here.
2022-03-03usbnet drivers: No need for usbnet_busy in uno_init.riastradh
This callback always runs with the IFNET_LOCK held, and the interface cannot be detached until the IFNET_LOCK is released, so there is no need to hang onto a reference count here. (None of the usbnet drivers touch the IFNET_LOCK except to verify it is held sometimes.)
2022-03-03usbnet: Split multicast filter reprogramming into separate operation.riastradh
2022-03-03usbnet drivers: Stop timeout loops early if device is detaching.riastradh
2022-03-03usbnet: Omit needless locking around usbnet_isdying.riastradh
Now that is tested and set with atomic_load/store, there is no need to hold the lock -- which means we can set it while the core lock is held during, e.g., a reset sequence, and use that to interrupt the sequence so it doesn't get stuck waiting to time out when the device is physically removed.
2022-03-03usbnet: Use atomic_load/store_relaxed for unp_dying.riastradh
This way we don't need to hold the core lock to avoid upsetting sanitizers (which probably find the current code upsetting), and we can use it to exit early from timeout loops that run under the core lock (which is probably not necessary for them to do anyway, but let's worry about that later).
2022-03-03usbnet: Print diagnostic about refcnt stragglers.riastradh
I don't think there can be any, but this message, if printed, would falsify my hypothesis!
2022-03-03usbnet: Enter uno_init with the core lock held.riastradh
This reduces code in all drivers except urndis(4) and aue(4). However, it's still safe for urndis to drop the core lock because the ifnet is locked, and the ifnet lock covers the DOWN->UP (uno_init) and UP->DOWN (uno_stop) transitions.
2022-03-03usbnet: Assert ioctl locking.riastradh
2022-03-03usbnet: Impart blame on whose ifnet is unlocked in uno_init.riastradh
2022-03-03usbnet: Don't waste time calling uno_stop if device is detaching.riastradh
The hardware is most likely gone, so trying to write to its registers (and, in some cases, wait until a timeout for a device to reset) is a waste of time. Even if it was detached only in software with drvctl, reattaching it will reset the device anyway.
2022-03-03cue(4): Return real error code, not -1, on init when detaching.riastradh
2022-03-03usbnet: Avoid IFNET_LOCK on detach if we never attached the ifp.riastradh
2022-03-03usbnet: Clear watchdog timer before stopping hardware.riastradh
No need to take the lock again -- which might not be necessary because the callout and task have completed, but let's obviate the need to think about that.
2022-03-03usbnet: Omit needless locking/busying/testing in usbnet_tick_task.riastradh
usbnet_stop waits for the task to complete before resetting the hardware, and usbnet_detach waits for usbnet_stop to complete before destroying anything, so there's no need for any of this.
2022-03-03usbnet: Omit needless tests in usbnet_tick.riastradh
It's harmless for us to schedule the tick task even if unp_dying or unp_stopping is set by now, because usbnet_stop will just wait for it to finish anyway, and the callout can't be scheduled again until the interface is done stopping and is brought back up again. No need for unp == NULL test -- un->un_pri is initialized well before this callout can be scheduled, and is nulled out only at the end of usbnet_detach, at which point we have already halted this callout.
2022-03-03usbnet: Uncomment and fix assertion for ifp->if_flags |= IFF_RUNNING.riastradh
We always hold IFNET_LOCK for ioctls that end up here -- the ones that don't hold it are only SIOCADDMULTI/SIOCDELMULTI, which don't end up here. However, urndis(4) throws a spanner in the works by doing weird device initialization.
2022-03-03usbnet: Don't issue a detach event if we never issued an attach one.riastradh
2022-03-03usbnet: Make detach order reverse attach order, for unp_stat_ch.riastradh
No functional change intended.
2022-03-03usbnet: Detach interface and mii before waiting for refcnt to drain.riastradh
All outstanding software activity under usbnet's control -- which is all that participates in the refcnting -- should be quiesced by stopping and detaching everything.
2022-03-03usbnet: Omit needless callout_halt and usb_rem_task_wait.riastradh
The callout and tasks cannot be pending at this point -- it is a bug if usbnet_if_stop failed to quiesce everything, so turn these into KASSERTs.
2022-03-03usbnet: Refuse to bring interfaces back up once dying.riastradh
Make this happen uniformly across all usbnet drivers, not on a per-driver basis. This ensures new activity on the interface can't happen by the time we have stopped existing activity and waited for it to complete.
2022-03-03usbnet: Assert IFNET_LOCKED in usbnet_media_upd.riastradh
This ensures, if the device is being initialized or stopped, usbnet_media_upd will not run until it's done, so the reset sequence has exclusive access to the device registers used by mii.
2022-03-03usbnet: Fix ordering of actions in usbnet_stop.riastradh
Make sure all software activity is quiescent (callouts and tasks, including ifmedia and mii callbacks -- anything that might trigger register access) before asking the driver to stop the hardware. This way, the driver uno_stop routine is guaranteed exclusive access to the registers. This will also enable us to simplify the callouts and tasks so they don't have to check the software state -- to be done in a separate commit.
2022-03-03usbnet: Remove usbnet_set_dying.riastradh
Not necessary for the one caller that did it (url(4)): usbnet_detach handles failed attach just fine without it.
2022-03-03axen(4), mue(4), smsc(4): Omit irrelevant cases in ioctl.riastradh
SIOCSIFFLAGS and SIOCSETHERCAP always end up in ether_ioctl_reinit, which triggers the same logic to reprogram the multicast filters anyway.
2022-03-03usbnet: Omit needless unp == NULL test in usbnet_tick_task.riastradh
The task is never scheduled until after un->un_pri is initialized, and un->un_pri isn't nulled until after the callout and task are quiescent.
2022-03-03usbnet: Don't check if_flags for IFF_RUNNING in usbnet_pipe_intr.riastradh
The one user of this interface in tree, aue(4), doesn't care -- if_statinc is safe whether IFF_RUNNING or not.
2022-03-03usbnet: Don't check if_flags for IFF_RUNNING in usbnet_rxeof.riastradh
This can only run after we start the pipes in usbnet_init_rx_tx, and before we abort the pipes in usbnet_stop, during which time if_flags & IFF_RUNNING is stably set.
2022-03-03usbnet: Assert IFNET_LOCKED in usbnet_init_rx_tx, usbnet_stop.riastradh
Exception: urndis(4) abuses this API to start this logic before the ifp is actually initialized. So for the sake of urndis(4), until sense can be beaten into it, allow the !unp_ifp_attached case to run without IFNET_LOCK.
2022-03-03usbnet: Assert IFNET_LOCKED on if_flags change callbacks.riastradh
- if_init - if_stop - ethersubr(9) ifflags_cb
2022-03-03usbnet: Ensure access to unp_timer is protected by unp_txlock.riastradh
2022-03-03usbnet: Ensure ifp->if_softc is initialized _before_ publishing ifp.riastradh
Otherwise other parts of the system might start using ifp the moment we if_register it, and trip over null if_softc.
2022-03-03usbnet: Take IFNET_LOCK around access to if_flags in usbnet_detach.riastradh
This is not stable without IFNET_LOCK. Extraneous calls to usbnet_stop arising from this race might be harmless, but let's render it unnecessary to even think about that.
2022-03-03usbnet: Set and clear IFF_RUNNING slightly earlier and later.riastradh
- Set IFF_RUNNING before any calls to usbnet_rxeof are possible. - Don't clear IFF_RUNNING until all transfers have been aborted.
2022-03-03usbnet: Simplify usbnet_isdying.riastradh
usbnet_detach (or its caller) stops all users before it returns. If un->un_pri is null at this point, there's a bug -- something didn't wait for everything to finish before calling usbnet_detach.
2022-02-27acpi: Assert acpi_register_notify is not called twice.riastradh
2022-02-27acpivga(4): Provide hooks for ACPI display notifications.riastradh
The Intel i915 graphics driver needs to receive ACPI VGA 0x80 notifications, but with NetBSD's ACPI API, each ACPI node -- such as the VGA node -- can only have one notifier attached, and acpivga(4) already uses it.
2022-02-27acpi: Nix conditional pci_get_segment use.riastradh
New MI default of 0 serves.
2022-02-27pci(9): Provide default definition of pci_get_segment, always zero.riastradh
pci_machdep.h can define __HAVE_PCI_GET_SEGMENT to provide a nonzero definition.
2022-02-27lockstat(4): KNF. No functional change intended.riastradh