Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci wm(4): Remove the non-MP-safe scaffolding.
details: https://anonhg.NetBSD.org/src/rev/92d561c6fcdc
branches: trunk
changeset: 368900:92d561c6fcdc
user: riastradh <riastradh%NetBSD.org@localhost>
date: Fri Aug 12 10:59:42 2022 +0000
description:
wm(4): Remove the non-MP-safe scaffolding.
- Where we had #ifndef WM_MPSAFE splnet(), we also had WM_CORE_LOCK,
which implies splnet, so just remove the conditional splnet.
- Make the core lock unconditional and remove macro indirections.
- Pass CALLOUT_MPSAFE, SOFTINT_MPSAFE, and WQ_MPSAFE directly without
macro indirections.
diffstat:
sys/dev/pci/if_wm.c | 149 ++++++++++++++++-----------------------------------
1 files changed, 48 insertions(+), 101 deletions(-)
diffs (truncated from 482 to 300 lines):
diff -r 8e7afd651719 -r 92d561c6fcdc sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c Fri Aug 12 10:58:45 2022 +0000
+++ b/sys/dev/pci/if_wm.c Fri Aug 12 10:59:42 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wm.c,v 1.762 2022/08/12 10:58:45 riastradh Exp $ */
+/* $NetBSD: if_wm.c,v 1.763 2022/08/12 10:59:42 riastradh Exp $ */
/*
* Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,10 +82,9 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.762 2022/08/12 10:58:45 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.763 2022/08/12 10:59:42 riastradh Exp $");
#ifdef _KERNEL_OPT
-#include "opt_net_mpsafe.h"
#include "opt_if_wm.h"
#endif
@@ -173,17 +172,6 @@
#define DPRINTF(sc, x, y) __nothing
#endif /* WM_DEBUG */
-#ifdef NET_MPSAFE
-#define WM_MPSAFE 1
-#define WM_CALLOUT_FLAGS CALLOUT_MPSAFE
-#define WM_SOFTINT_FLAGS SOFTINT_MPSAFE
-#define WM_WORKQUEUE_FLAGS WQ_PERCPU | WQ_MPSAFE
-#else
-#define WM_CALLOUT_FLAGS 0
-#define WM_SOFTINT_FLAGS 0
-#define WM_WORKQUEUE_FLAGS WQ_PERCPU
-#endif
-
#define WM_WORKQUEUE_PRI PRI_SOFTNET
/*
@@ -718,13 +706,6 @@
#endif
};
-#define WM_CORE_LOCK(_sc) \
- if ((_sc)->sc_core_lock) mutex_enter((_sc)->sc_core_lock)
-#define WM_CORE_UNLOCK(_sc) \
- if ((_sc)->sc_core_lock) mutex_exit((_sc)->sc_core_lock)
-#define WM_CORE_LOCKED(_sc) \
- (!(_sc)->sc_core_lock || mutex_owned((_sc)->sc_core_lock))
-
#define WM_RXCHAIN_RESET(rxq) \
do { \
(rxq)->rxq_tailp = &(rxq)->rxq_head; \
@@ -1986,7 +1967,7 @@
sc->sc_debug = WM_DEBUG_DEFAULT;
#endif
sc->sc_dev = self;
- callout_init(&sc->sc_tick_ch, WM_CALLOUT_FLAGS);
+ callout_init(&sc->sc_tick_ch, CALLOUT_MPSAFE);
callout_setfunc(&sc->sc_tick_ch, wm_tick, sc);
sc->sc_core_stopping = false;
@@ -2225,7 +2206,7 @@
snprintf(wqname, sizeof(wqname), "%sTxRx", device_xname(sc->sc_dev));
error = workqueue_create(&sc->sc_queue_wq, wqname,
wm_handle_queue_work, sc, WM_WORKQUEUE_PRI, IPL_NET,
- WM_WORKQUEUE_FLAGS);
+ WQ_PERCPU | WQ_MPSAFE);
if (error) {
aprint_error_dev(sc->sc_dev,
"unable to create TxRx workqueue\n");
@@ -2272,7 +2253,7 @@
aprint_verbose_dev(sc->sc_dev,
"Communication Streaming Architecture\n");
if (sc->sc_type == WM_T_82547) {
- callout_init(&sc->sc_txfifo_ch, WM_CALLOUT_FLAGS);
+ callout_init(&sc->sc_txfifo_ch, CALLOUT_MPSAFE);
callout_setfunc(&sc->sc_txfifo_ch,
wm_82547_txfifo_stall, sc);
aprint_verbose_dev(sc->sc_dev,
@@ -3068,11 +3049,7 @@
aprint_verbose_dev(sc->sc_dev, "%s\n", buf);
}
-#ifdef WM_MPSAFE
sc->sc_core_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET);
-#else
- sc->sc_core_lock = NULL;
-#endif
/* Initialize the media structures accordingly. */
if (sc->sc_mediatype == WM_MEDIATYPE_COPPER)
@@ -3085,9 +3062,7 @@
strlcpy(ifp->if_xname, xname, IFNAMSIZ);
ifp->if_softc = sc;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
-#ifdef WM_MPSAFE
ifp->if_extflags = IFEF_MPSAFE;
-#endif
ifp->if_ioctl = wm_ioctl;
if ((sc->sc_flags & WM_F_NEWQUEUE) != 0) {
ifp->if_start = wm_nq_start;
@@ -3501,11 +3476,11 @@
rnd_detach_source(&sc->rnd_source);
/* Tell the firmware about the release */
- WM_CORE_LOCK(sc);
+ mutex_enter(sc->sc_core_lock);
wm_release_manageability(sc);
wm_release_hw_control(sc);
wm_enable_wakeup(sc);
- WM_CORE_UNLOCK(sc);
+ mutex_exit(sc->sc_core_lock);
mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);
@@ -3770,17 +3745,11 @@
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
uint64_t crcerrs, algnerrc, symerrc, mpc, colc, sec, rlec, rxerrc,
cexterr;
-#ifndef WM_MPSAFE
- int s = splnet();
-#endif
-
- WM_CORE_LOCK(sc);
+
+ mutex_enter(sc->sc_core_lock);
if (sc->sc_core_stopping) {
- WM_CORE_UNLOCK(sc);
-#ifndef WM_MPSAFE
- splx(s);
-#endif
+ mutex_exit(sc->sc_core_lock);
return;
}
@@ -3907,10 +3876,7 @@
else
wm_tbi_tick(sc);
- WM_CORE_UNLOCK(sc);
-#ifndef WM_MPSAFE
- splx(s);
-#endif
+ mutex_exit(sc->sc_core_lock);
if (wm_watchdog(ifp))
callout_schedule(&sc->sc_tick_ch, hz);
@@ -3930,7 +3896,8 @@
device_xname(sc->sc_dev), __func__));
KASSERT(IFNET_LOCKED(ifp));
- WM_CORE_LOCK(sc);
+
+ mutex_enter(sc->sc_core_lock);
/*
* Check for if_flags.
@@ -3964,7 +3931,7 @@
out:
if (needreset)
rc = ENETRESET;
- WM_CORE_UNLOCK(sc);
+ mutex_exit(sc->sc_core_lock);
return rc;
}
@@ -4037,12 +4004,9 @@
KASSERT(IFNET_LOCKED(ifp));
}
-#ifndef WM_MPSAFE
- const int s = splnet();
-#endif
switch (cmd) {
case SIOCSIFMEDIA:
- WM_CORE_LOCK(sc);
+ mutex_enter(sc->sc_core_lock);
/* Flow control requires full-duplex mode. */
if (IFM_SUBTYPE(ifr->ifr_media) == IFM_AUTO ||
(ifr->ifr_media & IFM_FDX) == 0)
@@ -4055,7 +4019,7 @@
}
sc->sc_flowflags = ifr->ifr_media & IFM_ETH_FMASK;
}
- WM_CORE_UNLOCK(sc);
+ mutex_exit(sc->sc_core_lock);
error = ifmedia_ioctl(ifp, ifr, &sc->sc_mii.mii_media, cmd);
if (error == 0 && wm_phy_need_linkdown_discard(sc)) {
if (IFM_SUBTYPE(ifr->ifr_media) == IFM_NONE) {
@@ -4067,7 +4031,7 @@
}
break;
case SIOCINITIFADDR:
- WM_CORE_LOCK(sc);
+ mutex_enter(sc->sc_core_lock);
if (ifa->ifa_addr->sa_family == AF_LINK) {
sdl = satosdl(ifp->if_dl->ifa_addr);
(void)sockaddr_dl_setaddr(sdl, sdl->sdl_len,
@@ -4075,10 +4039,10 @@
/* Unicast address is the first multicast entry */
wm_set_filter(sc);
error = 0;
- WM_CORE_UNLOCK(sc);
- break;
- }
- WM_CORE_UNLOCK(sc);
+ mutex_exit(sc->sc_core_lock);
+ break;
+ }
+ mutex_exit(sc->sc_core_lock);
/*FALLTHROUGH*/
default:
if (cmd == SIOCSIFFLAGS && wm_phy_need_linkdown_discard(sc)) {
@@ -4090,14 +4054,10 @@
wm_set_linkdown_discard(sc);
}
}
-#ifdef WM_MPSAFE
const int s = splnet();
-#endif
/* It may call wm_start, so unlock here */
error = ether_ioctl(ifp, cmd, data);
-#ifdef WM_MPSAFE
splx(s);
-#endif
if (error != ENETRESET)
break;
@@ -4106,7 +4066,7 @@
if (cmd == SIOCSIFCAP)
error = if_init(ifp);
else if (cmd == SIOCADDMULTI || cmd == SIOCDELMULTI) {
- WM_CORE_LOCK(sc);
+ mutex_enter(sc->sc_core_lock);
if (sc->sc_if_flags & IFF_RUNNING) {
/*
* Multicast list has changed; set the hardware filter
@@ -4114,14 +4074,11 @@
*/
wm_set_filter(sc);
}
- WM_CORE_UNLOCK(sc);
- }
- break;
- }
-
-#ifndef WM_MPSAFE
- splx(s);
-#endif
+ mutex_exit(sc->sc_core_lock);
+ }
+ break;
+ }
+
return error;
}
@@ -4382,7 +4339,7 @@
DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n",
device_xname(sc->sc_dev), __func__));
- KASSERT(WM_CORE_LOCKED(sc));
+ KASSERT(mutex_owned(sc->sc_core_lock));
if (sc->sc_type >= WM_T_82544)
mta_reg = WMREG_CORDOVA_MTA;
@@ -6083,7 +6040,7 @@
wmq->wmq_id = qidx;
wmq->wmq_intr_idx = intr_idx;
- wmq->wmq_si = softint_establish(SOFTINT_NET | WM_SOFTINT_FLAGS,
+ wmq->wmq_si = softint_establish(SOFTINT_NET | SOFTINT_MPSAFE,
wm_handle_queue, wmq);
if (wmq->wmq_si != NULL)
return 0;
@@ -6114,9 +6071,7 @@
}
intrstr = pci_intr_string(pc, sc->sc_intrs[0], intrbuf,
sizeof(intrbuf));
-#ifdef WM_MPSAFE
pci_intr_setattr(pc, &sc->sc_intrs[0], PCI_INTR_MPSAFE, true);
-#endif
sc->sc_ihs[0] = pci_intr_establish_xname(pc, sc->sc_intrs[0],
IPL_NET, wm_intr_legacy, sc, device_xname(sc->sc_dev));
if (sc->sc_ihs[0] == NULL) {
@@ -6177,10 +6132,8 @@
intrstr = pci_intr_string(pc, sc->sc_intrs[intr_idx], intrbuf,
sizeof(intrbuf));
-#ifdef WM_MPSAFE
pci_intr_setattr(pc, &sc->sc_intrs[intr_idx],
PCI_INTR_MPSAFE, true);
-#endif
memset(intr_xname, 0, sizeof(intr_xname));
snprintf(intr_xname, sizeof(intr_xname), "%sTXRX%d",
device_xname(sc->sc_dev), qidx);
@@ -6216,9 +6169,7 @@
/* LINK */
Home |
Main Index |
Thread Index |
Old Index