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 panic when failing during attach or deta...
details: https://anonhg.NetBSD.org/src/rev/e39b6ea8f02a
branches: trunk
changeset: 373039:e39b6ea8f02a
user: ryo <ryo%NetBSD.org@localhost>
date: Sat Jan 14 13:17:20 2023 +0000
description:
- avoid panic when failing during attach or detach with modload/drvctl.
- free workqueue resources when detaching.
- remove debug message.
diffstat:
sys/dev/pci/if_aq.c | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
diffs (82 lines):
diff -r 5d36d55c8a3d -r e39b6ea8f02a sys/dev/pci/if_aq.c
--- a/sys/dev/pci/if_aq.c Sat Jan 14 13:16:27 2023 +0000
+++ b/sys/dev/pci/if_aq.c Sat Jan 14 13:17:20 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_aq.c,v 1.40 2023/01/14 13:16:27 ryo Exp $ */
+/* $NetBSD: if_aq.c,v 1.41 2023/01/14 13:17:20 ryo Exp $ */
/**
* aQuantia Corporation Network Driver
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.40 2023/01/14 13:16:27 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.41 2023/01/14 13:17:20 ryo Exp $");
#ifdef _KERNEL_OPT
#include "opt_if_aq.h"
@@ -931,7 +931,8 @@
#define AQ_EVCNT_ATTACH_MISC(sc, name, desc) \
AQ_EVCNT_ATTACH(sc, name, desc, EVCNT_TYPE_MISC)
#define AQ_EVCNT_DETACH(sc, name) \
- evcnt_detach(&(sc)->sc_evcount_##name##_ev)
+ if ((sc)->sc_evcount_##name##_name[0] != '\0') \
+ evcnt_detach(&(sc)->sc_evcount_##name##_ev)
#define AQ_EVCNT_ADD(sc, name, val) \
((sc)->sc_evcount_##name##_ev.ev_count += (val))
#endif /* AQ_EVENT_COUNTERS */
@@ -1587,6 +1588,9 @@
struct ifnet * const ifp = &sc->sc_ethercom.ec_if;
int i;
+ if (sc->sc_dev == NULL)
+ return 0;
+
if (sc->sc_iosize != 0) {
if (ifp->if_softc != NULL) {
IFNET_LOCK(ifp);
@@ -1601,12 +1605,19 @@
}
}
if (sc->sc_nintrs > 0) {
+ callout_stop(&sc->sc_tick_ch);
+
pci_intr_release(sc->sc_pc, sc->sc_intrs,
sc->sc_nintrs);
sc->sc_intrs = NULL;
sc->sc_nintrs = 0;
}
+ if (sc->sc_reset_wq != NULL) {
+ workqueue_destroy(sc->sc_reset_wq);
+ sc->sc_reset_wq = NULL;
+ }
+
aq_txrx_rings_free(sc);
if (ifp->if_softc != NULL) {
@@ -1614,7 +1625,6 @@
if_detach(ifp);
}
- aprint_debug_dev(sc->sc_dev, "%s: bus_space_unmap\n", __func__);
bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_iosize);
sc->sc_iosize = 0;
}
@@ -1647,10 +1657,14 @@
AQ_EVCNT_DETACH(sc, cprc);
#endif
- ifmedia_fini(&sc->sc_media);
+ if (sc->sc_ethercom.ec_ifmedia != NULL) {
+ ifmedia_fini(&sc->sc_media);
+ sc->sc_ethercom.ec_ifmedia = NULL;
+ }
mutex_destroy(&sc->sc_mpi_mutex);
mutex_destroy(&sc->sc_mutex);
+ sc->sc_dev = NULL;
return 0;
}
Home |
Main Index |
Thread Index |
Old Index