From 1fe12906e3980018bc1514ac1b9f21c5fd2c3a19 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Mon, 13 Jun 2005 21:38:12 +0000 Subject: [PATCH] Convert to critical sections. --- sys/dev/netif/cm/if_cm_isa.c | 9 +++--- sys/dev/netif/cm/smc90cx6.c | 62 +++++++++++++++++------------------- 2 files changed, 35 insertions(+), 36 deletions(-) diff --git a/sys/dev/netif/cm/if_cm_isa.c b/sys/dev/netif/cm/if_cm_isa.c index f3d3a11490..5cad5e4029 100644 --- a/sys/dev/netif/cm/if_cm_isa.c +++ b/sys/dev/netif/cm/if_cm_isa.c @@ -1,6 +1,6 @@ /* $NetBSD: if_bah_zbus.c,v 1.6 2000/01/23 21:06:12 aymeric Exp $ */ /* $FreeBSD: src/sys/dev/cm/if_cm_isa.c,v 1.1.2.1 2002/02/13 22:33:41 fjoe Exp $ */ -/* $DragonFly: src/sys/dev/netif/cm/Attic/if_cm_isa.c,v 1.6 2005/05/24 20:59:01 dillon Exp $ */ +/* $DragonFly: src/sys/dev/netif/cm/Attic/if_cm_isa.c,v 1.7 2005/06/13 21:38:12 joerg Exp $ */ /*- * Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc. @@ -108,11 +108,12 @@ cm_isa_detach(device_t dev) cm_stop(sc); ifp->if_flags &= ~IFF_RUNNING; - s = splimp(); + crit_enter(); arc_ifdetach(&sc->sc_arccom.ac_if); - splx(s); - bus_teardown_intr(dev, sc->irq_res, sc->irq_handle); + + crit_exit(); + cm_release_resources(dev); return (0); diff --git a/sys/dev/netif/cm/smc90cx6.c b/sys/dev/netif/cm/smc90cx6.c index 2d3aaa4a0c..e419d5c470 100644 --- a/sys/dev/netif/cm/smc90cx6.c +++ b/sys/dev/netif/cm/smc90cx6.c @@ -1,6 +1,6 @@ /* $NetBSD: smc90cx6.c,v 1.38 2001/07/07 15:57:53 thorpej Exp $ */ /* $FreeBSD: src/sys/dev/cm/smc90cx6.c,v 1.1.2.3 2003/02/05 18:42:14 fjoe Exp $ */ -/* $DragonFly: src/sys/dev/netif/cm/Attic/smc90cx6.c,v 1.14 2005/06/12 15:39:33 hsu Exp $ */ +/* $DragonFly: src/sys/dev/netif/cm/Attic/smc90cx6.c,v 1.15 2005/06/13 21:38:12 joerg Exp $ */ /*- * Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc. @@ -55,6 +55,7 @@ #include #include #include +#include #include #include @@ -278,10 +279,9 @@ cm_attach(dev) { struct cm_softc *sc = device_get_softc(dev); struct ifnet *ifp = &sc->sc_arccom.ac_if; - int s; u_int8_t linkaddress; - s = splhigh(); + crit_enter(); /* * read the arcnet address from the board @@ -304,7 +304,7 @@ cm_attach(dev) sc->sc_recontime = sc->sc_reconcount = 0; /* and reenable kernel int level */ - splx(s); + crit_exit(); /* * set interface to stopped condition (reset) @@ -349,17 +349,14 @@ cm_init(xsc) void *xsc; { struct cm_softc *sc = (struct cm_softc *)xsc; - struct ifnet *ifp; - int s; - - ifp = &sc->sc_arccom.ac_if; + struct ifnet *ifp = &sc->sc_arccom.ac_if; if ((ifp->if_flags & IFF_RUNNING) == 0) { - s = splimp(); + crit_enter(); ifp->if_flags |= IFF_RUNNING; cm_reset(sc); cm_start(ifp); - splx(s); + crit_exit(); } } @@ -474,8 +471,7 @@ cm_start(ifp) struct cm_softc *sc = ifp->if_softc; struct mbuf *m,*mp; - int cm_ram_ptr; - int len, tlen, offset, s, buffer; + int cm_ram_ptr, len, tlen, offset, buffer; #ifdef CMTIMINGS u_long copystart, lencopy, perbyte; #endif @@ -484,20 +480,22 @@ cm_start(ifp) printf("%s: start(%p)\n", ifp->if_xname, ifp); #endif - if ((ifp->if_flags & IFF_RUNNING) == 0) - return; + crit_enter(); - s = splimp(); + if ((ifp->if_flags & IFF_RUNNING) == 0) { + crit_exit(); + return; + } if (sc->sc_tx_fillcount >= 2) { - splx(s); + crit_exit(); return; } m = arc_frag_next(ifp); buffer = sc->sc_tx_act ^ 1; - splx(s); + crit_exit(); if (m == 0) return; @@ -564,7 +562,7 @@ cm_start(ifp) sc->sc_retransmits[buffer] = (m->m_flags & M_BCAST) ? 1 : 5; /* actually transmit the packet */ - s = splimp(); + crit_enter(); if (++sc->sc_tx_fillcount > 1) { /* @@ -590,7 +588,9 @@ cm_start(ifp) sc->sc_arccom.ac_if.if_timer = ARCTIMEOUT; } - splx(s); + + crit_exit(); + m_freem(m); /* @@ -612,17 +612,15 @@ cm_srint(vsc) void *vsc; { struct cm_softc *sc = (struct cm_softc *)vsc; - int buffer, len, offset, s, type; + int buffer, len, offset, type; int cm_ram_ptr; struct mbuf *m; struct arc_header *ah; - struct ifnet *ifp; - - ifp = &sc->sc_arccom.ac_if; + struct ifnet *ifp = &sc->sc_arccom.ac_if; - s = splimp(); + crit_enter(); buffer = sc->sc_rx_act ^ 1; - splx(s); + crit_exit(); /* * Align so that IP packet will be longword aligned. Here we @@ -684,7 +682,8 @@ cleanup: /* mark buffer as invalid by source id 0 */ PUTMEM(buffer << 9, 0); - s = splimp(); + + crit_enter(); if (--sc->sc_rx_fillcount == 2 - 1) { @@ -701,7 +700,7 @@ cleanup: ifp->if_xname, buffer); #endif } - splx(s); + crit_exit(); } __inline static void @@ -956,13 +955,14 @@ cm_ioctl(struct ifnet *ifp, u_long command, caddr_t data, struct ucred *cr) struct cm_softc *sc; struct ifaddr *ifa; struct ifreq *ifr; - int s, error; + int error; error = 0; sc = ifp->if_softc; ifa = (struct ifaddr *)data; ifr = (struct ifreq *)data; - s = splimp(); + + crit_enter(); #if defined(CM_DEBUG) && (CM_DEBUG > 2) printf("%s: ioctl() called, cmd = 0x%lx\n", @@ -994,7 +994,7 @@ cm_ioctl(struct ifnet *ifp, u_long command, caddr_t data, struct ucred *cr) break; } - splx(s); + crit_exit(); return (error); } @@ -1008,8 +1008,6 @@ cm_ioctl(struct ifnet *ifp, u_long command, caddr_t data, struct ucred *cr) * Only thing we do is disable transmitter. We'll get an transmit timeout, * and the int handler will have to decide not to retransmit (in case * retransmission is implemented). - * - * This one assumes being called inside splimp() */ void -- 2.41.0