Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb mark this driver MPSAFE for usb tasks and pipes,...
details: https://anonhg.NetBSD.org/src/rev/1e0ce4b7c30d
branches: trunk
changeset: 999880:1e0ce4b7c30d
user: mrg <mrg%NetBSD.org@localhost>
date: Sat Jun 22 09:53:56 2019 +0000
description:
mark this driver MPSAFE for usb tasks and pipes, if(4), and callouts.
remove remaining redundant spl calls.
diffstat:
sys/dev/usb/if_axen.c | 68 ++++++++++----------------------------------------
1 files changed, 14 insertions(+), 54 deletions(-)
diffs (truncated from 303 to 300 lines):
diff -r 4f7df76955b7 -r 1e0ce4b7c30d sys/dev/usb/if_axen.c
--- a/sys/dev/usb/if_axen.c Sat Jun 22 09:48:39 2019 +0000
+++ b/sys/dev/usb/if_axen.c Sat Jun 22 09:53:56 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_axen.c,v 1.46 2019/06/22 08:09:08 mrg Exp $ */
+/* $NetBSD: if_axen.c,v 1.47 2019/06/22 09:53:56 mrg Exp $ */
/* $OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $ */
/*
@@ -23,7 +23,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.46 2019/06/22 08:09:08 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.47 2019/06/22 09:53:56 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -784,7 +784,7 @@
char *devinfop;
const char *devname = device_xname(self);
struct ifnet *ifp;
- int i, s;
+ int i;
aprint_naive("\n");
aprint_normal("\n");
@@ -805,7 +805,7 @@
sc->axen_flags = axen_lookup(uaa->uaa_vendor, uaa->uaa_product)->axen_flags;
- usb_init_task(&sc->axen_tick_task, axen_tick_task, sc, 0);
+ usb_init_task(&sc->axen_tick_task, axen_tick_task, sc, USB_TASKQ_MPSAFE);
err = usbd_device2interface_handle(dev, AXEN_IFACE_IDX,&sc->axen_iface);
if (err) {
@@ -861,8 +861,6 @@
mutex_init(&sc->axen_lock, MUTEX_DEFAULT, IPL_NONE);
cv_init(&sc->axen_detachcv, "axendet");
- s = splnet();
-
sc->axen_phyno = AXEN_PHY_ID;
DPRINTF(("%s: phyno %d\n", device_xname(self), sc->axen_phyno));
@@ -897,6 +895,7 @@
ifp->if_softc = sc;
strlcpy(ifp->if_xname, devname, IFNAMSIZ);
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+ ifp->if_extflags = IFEF_MPSAFE;
ifp->if_ioctl = axen_ioctl;
ifp->if_start = axen_start;
ifp->if_init = axen_init;
@@ -938,11 +937,10 @@
rnd_attach_source(&sc->rnd_source, device_xname(sc->axen_dev),
RND_TYPE_NET, RND_FLAG_DEFAULT);
- callout_init(&sc->axen_stat_ch, 0);
+ callout_init(&sc->axen_stat_ch, CALLOUT_MPSAFE);
callout_setfunc(&sc->axen_stat_ch, axen_tick, sc);
sc->axen_attached = true;
- splx(s);
usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->axen_udev,sc->axen_dev);
@@ -955,7 +953,6 @@
{
struct axen_softc * const sc = device_private(self);
struct ifnet *ifp = GET_IFP(sc);
- int s;
mutex_enter(&sc->axen_lock);
sc->axen_dying = true;
@@ -973,8 +970,6 @@
usb_rem_task_wait(sc->axen_udev, &sc->axen_tick_task,
USB_TASKQ_DRIVER, NULL);
- s = splusb();
-
if (ifp->if_flags & IFF_RUNNING)
axen_stop(ifp, 1);
@@ -1003,8 +998,6 @@
sc->axen_attached = false;
- splx(s);
-
usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->axen_udev,sc->axen_dev);
cv_destroy(&sc->axen_detachcv);
@@ -1136,7 +1129,6 @@
uint16_t hdr_offset, pkt_count;
size_t pkt_len;
size_t temp;
- int s;
DPRINTFN(10,("%s: %s: enter\n", device_xname(sc->axen_dev), __func__));
@@ -1252,9 +1244,7 @@
mutex_exit(&sc->axen_rxlock);
/* push the packet up */
- s = splnet();
if_percpuq_enqueue((ifp)->if_percpuq, (m));
- splx(s);
mutex_enter(&sc->axen_rxlock);
if (sc->axen_stopping) {
@@ -1341,7 +1331,6 @@
struct axen_softc * const sc = c->axen_sc;
struct axen_cdata *cd = &sc->axen_cdata;
struct ifnet *ifp = GET_IFP(sc);
- int s;
mutex_enter(&sc->axen_txlock);
if (sc->axen_stopping || sc->axen_dying) {
@@ -1349,8 +1338,6 @@
return;
}
- s = splnet();
-
KASSERT(cd->axen_tx_cnt > 0);
cd->axen_tx_cnt--;
@@ -1363,12 +1350,12 @@
break;
case USBD_NORMAL_COMPLETION:
+ ifp->if_opackets++;
if (!IFQ_IS_EMPTY(&ifp->if_snd))
axen_start_locked(ifp);
break;
default:
- ifp->if_opackets++;
ifp->if_oerrors++;
if (usbd_ratecheck(&sc->axen_tx_notice))
@@ -1379,7 +1366,6 @@
break;
}
- splx(s);
mutex_exit(&sc->axen_txlock);
}
@@ -1391,18 +1377,13 @@
if (sc == NULL)
return;
- mutex_enter(&sc->axen_lock);
-
DPRINTFN(0xff,("%s: %s: enter\n", device_xname(sc->axen_dev),__func__));
- if (sc->axen_stopping || sc->axen_dying) {
- mutex_exit(&sc->axen_lock);
- return;
+ mutex_enter(&sc->axen_lock);
+ if (!sc->axen_stopping && !sc->axen_dying) {
+ /* Perform periodic stuff in process context */
+ usb_add_task(sc->axen_udev, &sc->axen_tick_task, USB_TASKQ_DRIVER);
}
-
- /* Perform periodic stuff in process context */
- usb_add_task(sc->axen_udev, &sc->axen_tick_task, USB_TASKQ_DRIVER);
-
mutex_exit(&sc->axen_lock);
}
@@ -1412,7 +1393,6 @@
struct axen_softc * const sc = xsc;
struct ifnet *ifp;
struct mii_data *mii;
- int s;
if (sc == NULL)
return;
@@ -1431,8 +1411,6 @@
sc->axen_refcnt++;
mutex_exit(&sc->axen_lock);
- s = splnet();
-
if (sc->axen_timer != 0 && --sc->axen_timer == 0)
axen_watchdog(ifp);
@@ -1447,8 +1425,6 @@
if (!sc->axen_stopping && !sc->axen_dying)
callout_schedule(&sc->axen_stat_ch, hz);
mutex_exit(&sc->axen_lock);
-
- splx(s);
}
static int
@@ -1576,7 +1552,7 @@
struct axen_softc * const sc = ifp->if_softc;
struct axen_chain *c;
usbd_status err;
- int i, s;
+ int i;
uint16_t rxmode;
uint16_t wval;
uint8_t bval;
@@ -1586,8 +1562,6 @@
if (sc->axen_dying)
return EIO;
- s = splnet();
-
/* Cancel pending I/O */
axen_stop_locked(ifp, 1);
@@ -1617,34 +1591,30 @@
/* Open RX and TX pipes. */
err = usbd_open_pipe(sc->axen_iface, sc->axen_ed[AXEN_ENDPT_RX],
- USBD_EXCLUSIVE_USE, &sc->axen_ep[AXEN_ENDPT_RX]);
+ USBD_EXCLUSIVE_USE | USBD_MPSAFE, &sc->axen_ep[AXEN_ENDPT_RX]);
if (err) {
aprint_error_dev(sc->axen_dev, "open rx pipe failed: %s\n",
usbd_errstr(err));
- splx(s);
return EIO;
}
err = usbd_open_pipe(sc->axen_iface, sc->axen_ed[AXEN_ENDPT_TX],
- USBD_EXCLUSIVE_USE, &sc->axen_ep[AXEN_ENDPT_TX]);
+ USBD_EXCLUSIVE_USE | USBD_MPSAFE, &sc->axen_ep[AXEN_ENDPT_TX]);
if (err) {
aprint_error_dev(sc->axen_dev, "open tx pipe failed: %s\n",
usbd_errstr(err));
- splx(s);
return EIO;
}
/* Init RX ring. */
if (axen_rx_list_init(sc)) {
aprint_error_dev(sc->axen_dev, "rx list init failed\n");
- splx(s);
return ENOBUFS;
}
/* Init TX ring. */
if (axen_tx_list_init(sc)) {
aprint_error_dev(sc->axen_dev, "tx list init failed\n");
- splx(s);
return ENOBUFS;
}
@@ -1668,8 +1638,6 @@
ifp->if_flags |= IFF_RUNNING;
ifp->if_flags &= ~IFF_OACTIVE;
- splx(s);
-
callout_schedule(&sc->axen_stat_ch, hz);
return 0;
}
@@ -1690,11 +1658,8 @@
axen_ioctl(struct ifnet *ifp, u_long cmd, void *data)
{
struct axen_softc * const sc = ifp->if_softc;
- int s;
int error = 0;
- s = splnet();
-
switch (cmd) {
case SIOCSIFFLAGS:
if ((error = ifioctl_common(ifp, cmd, data)) != 0)
@@ -1746,7 +1711,6 @@
}
break;
}
- splx(s);
return error;
}
@@ -1757,20 +1721,16 @@
struct axen_softc * const sc = ifp->if_softc;
struct axen_chain *c;
usbd_status stat;
- int s;
ifp->if_oerrors++;
aprint_error_dev(sc->axen_dev, "watchdog timeout\n");
- s = splusb();
-
c = &sc->axen_cdata.axen_tx_chain[0];
usbd_get_xfer_status(c->axen_xfer, NULL, NULL, NULL, &stat);
axen_txeof(c->axen_xfer, c, stat);
if (!IFQ_IS_EMPTY(&ifp->if_snd))
axen_start(ifp);
- splx(s);
Home |
Main Index |
Thread Index |
Old Index