Module Name: src
Committed By: martin
Date: Wed May 9 14:52:40 UTC 2018
Modified Files:
src/sys/dev/pci [netbsd-8]: if_bnx.c if_bnxvar.h
Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #814):
sys/dev/pci/if_bnxvar.h: revision 1.7
sys/dev/pci/if_bnx.c: revision 1.64
- Fix a bug that bnx(4) panics on shutdown. Stop callout before restroy.
Reported by Andreas Gustafsson in PR#53265.
- Make sure not to re-arm the callout when we are about to detach. Same as
if_bge.c rev. 1.292.
- Use pci_intr_establish_xname().
To generate a diff of this commit:
cvs rdiff -u -r1.61.8.1 -r1.61.8.2 src/sys/dev/pci/if_bnx.c
cvs rdiff -u -r1.6 -r1.6.22.1 src/sys/dev/pci/if_bnxvar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/pci/if_bnx.c
diff -u src/sys/dev/pci/if_bnx.c:1.61.8.1 src/sys/dev/pci/if_bnx.c:1.61.8.2
--- src/sys/dev/pci/if_bnx.c:1.61.8.1 Tue Oct 24 08:38:59 2017
+++ src/sys/dev/pci/if_bnx.c Wed May 9 14:52:40 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bnx.c,v 1.61.8.1 2017/10/24 08:38:59 snj Exp $ */
+/* $NetBSD: if_bnx.c,v 1.61.8.2 2018/05/09 14:52:40 martin Exp $ */
/* $OpenBSD: if_bnx.c,v 1.85 2009/11/09 14:32:41 dlg Exp $ */
/*-
@@ -35,7 +35,7 @@
#if 0
__FBSDID("$FreeBSD: src/sys/dev/bce/if_bce.c,v 1.3 2006/04/13 14:12:26 ru Exp $");
#endif
-__KERNEL_RCSID(0, "$NetBSD: if_bnx.c,v 1.61.8.1 2017/10/24 08:38:59 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bnx.c,v 1.61.8.2 2018/05/09 14:52:40 martin Exp $");
/*
* The following controllers are supported by this driver:
@@ -792,7 +792,8 @@ bnx_attach(device_t parent, device_t sel
IFCAP_CSUM_UDPv4_Tx | IFCAP_CSUM_UDPv4_Rx;
/* Hookup IRQ last. */
- sc->bnx_intrhand = pci_intr_establish(pc, ih, IPL_NET, bnx_intr, sc);
+ sc->bnx_intrhand = pci_intr_establish_xname(pc, ih, IPL_NET, bnx_intr,
+ sc, device_xname(self));
if (sc->bnx_intrhand == NULL) {
aprint_error_dev(self, "couldn't establish interrupt");
if (intrstr != NULL)
@@ -890,17 +891,7 @@ bnx_detach(device_t dev, int flags)
/* Stop and reset the controller. */
s = splnet();
- if (ifp->if_flags & IFF_RUNNING)
- bnx_stop(ifp, 1);
- else {
- /* Disable the transmit/receive blocks. */
- REG_WR(sc, BNX_MISC_ENABLE_CLR_BITS, 0x5ffffff);
- REG_RD(sc, BNX_MISC_ENABLE_CLR_BITS);
- DELAY(20);
- bnx_disable_intr(sc);
- bnx_reset(sc, BNX_DRV_MSG_CODE_RESET);
- }
-
+ bnx_stop(ifp, 1);
splx(s);
pmf_device_deregister(dev);
@@ -3371,10 +3362,11 @@ bnx_stop(struct ifnet *ifp, int disable)
DBPRINT(sc, BNX_VERBOSE_RESET, "Entering %s()\n", __func__);
- if ((ifp->if_flags & IFF_RUNNING) == 0)
- return;
-
- callout_stop(&sc->bnx_timeout);
+ if (disable) {
+ sc->bnx_detaching = 1;
+ callout_halt(&sc->bnx_timeout, NULL);
+ } else
+ callout_stop(&sc->bnx_timeout);
mii_down(&sc->bnx_mii);
@@ -5694,9 +5686,6 @@ bnx_tick(void *xsc)
/* Update the statistics from the hardware statistics block. */
bnx_stats_update(sc);
- /* Schedule the next tick. */
- callout_reset(&sc->bnx_timeout, hz, bnx_tick, sc);
-
mii = &sc->bnx_mii;
mii_tick(mii);
@@ -5707,6 +5696,11 @@ bnx_tick(void *xsc)
bnx_get_buf(sc, &prod, &chain_prod, &prod_bseq);
sc->rx_prod = prod;
sc->rx_prod_bseq = prod_bseq;
+
+ /* Schedule the next tick. */
+ if (!sc->bnx_detaching)
+ callout_reset(&sc->bnx_timeout, hz, bnx_tick, sc);
+
splx(s);
return;
}
Index: src/sys/dev/pci/if_bnxvar.h
diff -u src/sys/dev/pci/if_bnxvar.h:1.6 src/sys/dev/pci/if_bnxvar.h:1.6.22.1
--- src/sys/dev/pci/if_bnxvar.h:1.6 Tue Jul 1 17:11:35 2014
+++ src/sys/dev/pci/if_bnxvar.h Wed May 9 14:52:40 2018
@@ -210,6 +210,7 @@ struct bnx_softc
uint32_t tx_prod_bseq; /* Counts the bytes used. */
struct callout bnx_timeout;
+ int bnx_detaching;
/* Frame size and mbuf allocation size for RX frames. */
uint32_t max_frame_size;