Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci avoid illegal sleeps in the softint routine.
details: https://anonhg.NetBSD.org/src/rev/69470f7b503e
branches: trunk
changeset: 783165:69470f7b503e
user: mrg <mrg%NetBSD.org@localhost>
date: Sun Dec 09 03:30:00 2012 +0000
description:
avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.
diffstat:
sys/dev/pci/if_alc.c | 30 +++++++++++++++++++-----------
1 files changed, 19 insertions(+), 11 deletions(-)
diffs (122 lines):
diff -r 4c1099056cca -r 69470f7b503e sys/dev/pci/if_alc.c
--- a/sys/dev/pci/if_alc.c Sun Dec 09 02:59:16 2012 +0000
+++ b/sys/dev/pci/if_alc.c Sun Dec 09 03:30:00 2012 +0000
@@ -103,6 +103,7 @@
static int alc_detach(device_t, int);
static int alc_init(struct ifnet *);
+static int alc_init_backend(struct ifnet *, bool);
static void alc_start(struct ifnet *);
static int alc_ioctl(struct ifnet *, u_long, void *);
static void alc_watchdog(struct ifnet *);
@@ -119,7 +120,7 @@
static void alc_get_macaddr(struct alc_softc *);
static void alc_init_cmb(struct alc_softc *);
static void alc_init_rr_ring(struct alc_softc *);
-static int alc_init_rx_ring(struct alc_softc *);
+static int alc_init_rx_ring(struct alc_softc *, bool);
static void alc_init_smb(struct alc_softc *);
static void alc_init_tx_ring(struct alc_softc *);
static int alc_intr(void *);
@@ -127,7 +128,7 @@
static int alc_miibus_readreg(device_t, int, int);
static void alc_miibus_statchg(struct ifnet *);
static void alc_miibus_writereg(device_t, int, int, int);
-static int alc_newbuf(struct alc_softc *, struct alc_rxdesc *, int);
+static int alc_newbuf(struct alc_softc *, struct alc_rxdesc *, bool);
static void alc_phy_down(struct alc_softc *);
static void alc_phy_reset(struct alc_softc *);
static void alc_reset(struct alc_softc *);
@@ -1442,13 +1443,13 @@
printf("%s: watchdog timeout (missed link)\n",
device_xname(sc->sc_dev));
ifp->if_oerrors++;
- alc_init(ifp);
+ alc_init_backend(ifp, false);
return;
}
printf("%s: watchdog timeout\n", device_xname(sc->sc_dev));
ifp->if_oerrors++;
- alc_init(ifp);
+ alc_init_backend(ifp, false);
if (!IFQ_IS_EMPTY(&ifp->if_snd))
alc_start(ifp);
@@ -1678,7 +1679,7 @@
error = alc_rxintr(sc);
if (error) {
- alc_init(ifp);
+ alc_init_backend(ifp, false);
return (0);
}
}
@@ -1694,7 +1695,7 @@
if (status & INTR_TXQ_TO_RST)
printf("%s: TxQ reset! -- resetting\n",
device_xname(sc->sc_dev));
- alc_init(ifp);
+ alc_init_backend(ifp, false);
return (0);
}
@@ -1765,7 +1766,7 @@
}
static int
-alc_newbuf(struct alc_softc *sc, struct alc_rxdesc *rxd, int init)
+alc_newbuf(struct alc_softc *sc, struct alc_rxdesc *rxd, bool init)
{
struct mbuf *m;
bus_dmamap_t map;
@@ -1920,7 +1921,7 @@
rxd = &sc->alc_cdata.alc_rxdesc[rx_cons];
mp = rxd->rx_m;
/* Add a new receive buffer to the ring. */
- if (alc_newbuf(sc, rxd, 0) != 0) {
+ if (alc_newbuf(sc, rxd, false) != 0) {
ifp->if_iqdrops++;
/* Reuse Rx buffers. */
if (sc->alc_cdata.alc_rxhead != NULL)
@@ -2044,6 +2045,13 @@
static int
alc_init(struct ifnet *ifp)
{
+
+ return alc_init_backend(ifp, true);
+}
+
+static int
+alc_init_backend(struct ifnet *ifp, bool init)
+{
struct alc_softc *sc = ifp->if_softc;
struct mii_data *mii;
uint8_t eaddr[ETHER_ADDR_LEN];
@@ -2061,7 +2069,7 @@
alc_reset(sc);
/* Initialize Rx descriptors. */
- error = alc_init_rx_ring(sc);
+ error = alc_init_rx_ring(sc, init);
if (error != 0) {
printf("%s: no memory for Rx buffers.\n", device_xname(sc->sc_dev));
alc_stop(ifp, 0);
@@ -2514,7 +2522,7 @@
}
static int
-alc_init_rx_ring(struct alc_softc *sc)
+alc_init_rx_ring(struct alc_softc *sc, bool init)
{
struct alc_ring_data *rd;
struct alc_rxdesc *rxd;
@@ -2527,7 +2535,7 @@
rxd = &sc->alc_cdata.alc_rxdesc[i];
rxd->rx_m = NULL;
rxd->rx_desc = &rd->alc_rx_ring[i];
- if (alc_newbuf(sc, rxd, 1) != 0)
+ if (alc_newbuf(sc, rxd, init) != 0)
return (ENOBUFS);
}
Home |
Main Index |
Thread Index |
Old Index