| Age | Commit message (Collapse) | Author |
|
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.
|
|
uno_init is now called with the core lock already held so there is no
need for a separate locked subroutine.
|
|
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!
|
|
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.
|
|
|
|
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.
|
|
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.
|
|
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.
|
|
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.)
|
|
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.
|
|
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.)
|
|
|
|
|
|
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.
|
|
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).
|
|
I don't think there can be any, but this message, if printed, would
falsify my hypothesis!
|
|
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.
|
|
|
|
|
|
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.
|
|
|
|
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
|
|
No functional change intended.
|
|
All outstanding software activity under usbnet's control -- which is
all that participates in the refcnting -- should be quiesced by
stopping and detaching everything.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
Not necessary for the one caller that did it (url(4)): usbnet_detach
handles failed attach just fine without it.
|
|
SIOCSIFFLAGS and SIOCSETHERCAP always end up in ether_ioctl_reinit,
which triggers the same logic to reprogram the multicast filters
anyway.
|
|
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.
|
|
The one user of this interface in tree, aue(4), doesn't care --
if_statinc is safe whether IFF_RUNNING or not.
|
|
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.
|
|
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.
|
|
- if_init
- if_stop
- ethersubr(9) ifflags_cb
|
|
|
|
Otherwise other parts of the system might start using ifp the moment
we if_register it, and trip over null if_softc.
|
|
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.
|
|
- Set IFF_RUNNING before any calls to usbnet_rxeof are possible.
- Don't clear IFF_RUNNING until all transfers have been aborted.
|
|
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.
|
|
|
|
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.
|
|
New MI default of 0 serves.
|
|
pci_machdep.h can define __HAVE_PCI_GET_SEGMENT to provide a nonzero
definition.
|
|
|