diff options
Diffstat (limited to 'sys/dev/cxgbe/tom/t4_tom.c')
-rw-r--r-- | sys/dev/cxgbe/tom/t4_tom.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/sys/dev/cxgbe/tom/t4_tom.c b/sys/dev/cxgbe/tom/t4_tom.c index d5b6b6ee2ce0..97cb380d0e71 100644 --- a/sys/dev/cxgbe/tom/t4_tom.c +++ b/sys/dev/cxgbe/tom/t4_tom.c @@ -1946,20 +1946,29 @@ done: static int t4_tom_deactivate(struct adapter *sc) { - int rc = 0; + int rc = 0, i, v; struct tom_data *td = sc->tom_softc; + struct vi_info *vi; ASSERT_SYNCHRONIZED_OP(sc); if (td == NULL) return (0); /* XXX. KASSERT? */ - if (sc->offload_map != 0) - return (EBUSY); /* at least one port has IFCAP_TOE enabled */ - if (uld_active(sc, ULD_IWARP) || uld_active(sc, ULD_ISCSI)) return (EBUSY); /* both iWARP and iSCSI rely on the TOE. */ + if (sc->offload_map != 0) { + for_each_port(sc, i) { + for_each_vi(sc->port[i], v, vi) { + toe_capability(vi, false); + if_setcapenablebit(vi->ifp, 0, IFCAP_TOE); + SETTOEDEV(vi->ifp, NULL); + } + } + MPASS(sc->offload_map == 0); + } + mtx_lock(&td->toep_list_lock); if (!TAILQ_EMPTY(&td->toep_list)) rc = EBUSY; @@ -2243,14 +2252,16 @@ t4_tom_mod_load(void) } static void -tom_uninit(struct adapter *sc, void *arg __unused) +tom_uninit(struct adapter *sc, void *arg) { + bool *ok_to_unload = arg; + if (begin_synchronized_op(sc, NULL, SLEEP_OK | INTR_OK, "t4tomun")) return; /* Try to free resources (works only if no port has IFCAP_TOE) */ - if (uld_active(sc, ULD_TOM)) - t4_deactivate_uld(sc, ULD_TOM); + if (uld_active(sc, ULD_TOM) && t4_deactivate_uld(sc, ULD_TOM) != 0) + *ok_to_unload = false; end_synchronized_op(sc, 0); } @@ -2258,7 +2269,11 @@ tom_uninit(struct adapter *sc, void *arg __unused) static int t4_tom_mod_unload(void) { - t4_iterate(tom_uninit, NULL); + bool ok_to_unload = true; + + t4_iterate(tom_uninit, &ok_to_unload); + if (!ok_to_unload) + return (EBUSY); if (t4_unregister_uld(&tom_uld_info, ULD_TOM) == EBUSY) return (EBUSY); |