cvs commit: src/sys/dev/fxp if_fxp.c if_fxpvar.h
M. Warner Losh
imp at bsdimp.com
Tue Apr 29 12:52:08 PDT 2003
Here's the diff that I plan on committing. It fixes the following
issues:
1) gone duplicates the suspend functionality. Roll the two
together to reduce the overhead.
2) Move test for suspend under the lock. Otherwise we have a
race.
3) Move suspend test to before DEVICE_POLLING, since it is
supposed to keep things from happening at all.
4) Rather than using 'gone' use mtx_owned instead to protect
recursive lock in ioctl.
Comments?
Index: if_fxp.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/fxp/if_fxp.c,v
retrieving revision 1.176
diff -u -r1.176 if_fxp.c
--- if_fxp.c 29 Apr 2003 05:47:14 -0000 1.176
+++ if_fxp.c 29 Apr 2003 19:47:30 -0000
@@ -881,7 +881,7 @@
FXP_LOCK(sc);
s = splimp();
- sc->gone = 1;
+ sc->suspend = 1; /* Do same thing as we do for suspend */
/*
* Close down routes etc.
*/
@@ -1499,10 +1499,12 @@
struct ifnet *ifp = &sc->sc_if;
u_int8_t statack;
- if (sc->gone)
+ FXP_LOCK(sc);
+ if (sc->suspended) {
+ FXP_UNLOCK(sc);
return;
+ }
- FXP_LOCK(sc);
#ifdef DEVICE_POLLING
if (ifp->if_flags & IFF_POLLING) {
FXP_UNLOCK(sc);
@@ -1516,12 +1518,6 @@
return;
}
#endif
-
- if (sc->suspended) {
- FXP_UNLOCK(sc);
- return;
- }
-
while ((statack = CSR_READ_1(sc, FXP_CSR_SCB_STATACK)) != 0) {
/*
* It should not be possible to have all bits set; the
@@ -2362,8 +2358,10 @@
struct mii_data *mii;
int s, error = 0;
- if (sc->gone)
- return (ENODEV);
+ // Detaching causes us to call ioctl with the mutex owned. Preclude
+ // that by saying we're busy.
+ if (mtx_owned(&sc->sc_mtx))
+ return (EBUSY);
FXP_LOCK(sc);
s = splimp();
Index: if_fxpvar.h
===================================================================
RCS file: /home/ncvs/src/sys/dev/fxp/if_fxpvar.h,v
retrieving revision 1.26
diff -u -r1.26 if_fxpvar.h
--- if_fxpvar.h 29 Apr 2003 05:45:09 -0000 1.26
+++ if_fxpvar.h 29 Apr 2003 19:47:30 -0000
@@ -185,11 +185,10 @@
int tunable_int_delay; /* interrupt delay value for ucode */
int tunable_bundle_max; /* max # frames per interrupt (ucode) */
int eeprom_size; /* size of serial EEPROM */
- int suspended; /* 0 = normal 1 = suspended (APM) */
+ int suspended; /* 0 = normal 1 = suspended or dead */
int cu_resume_bug;
int revision;
int flags;
- int gone;
u_int32_t saved_maps[5]; /* pci data */
u_int32_t saved_biosaddr;
u_int8_t saved_intline;
More information about the cvs-src
mailing list