]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
NTB: MFV fca4d518: Fix ntb_transport link down race
authorcem <cem@FreeBSD.org>
Tue, 13 Oct 2015 23:42:13 +0000 (23:42 +0000)
committercem <cem@FreeBSD.org>
Tue, 13 Oct 2015 23:42:13 +0000 (23:42 +0000)
A WARN_ON is being hit in ntb_qp_link_work due to the NTB transport link
being down while the ntb qp link is still active.  This is caused by the
transport link being brought down prior to the qp link worker thread
being terminated.  To correct this, shutdown the qp's prior to bringing
the transport link down.  Also, only call the qp worker thread if it is
in interrupt context, otherwise call the function directly.

Authored by: Jon Mason
Obtained from: Linux (Dual BSD/GPL driver)
Sponsored by: EMC / Isilon Storage Division

sys/dev/ntb/if_ntb/if_ntb.c

index 81ebe73a42088144e25b23a608caf4e988cb7759..02bab46f8b6a1ce0bd4e09940bc38880522e7f84 100644 (file)
@@ -519,7 +519,7 @@ ntb_transport_free(void *transport)
        struct ntb_softc *ntb = nt->ntb;
        int i;
 
-       nt->transport_link = NTB_LINK_DOWN;
+       ntb_transport_link_cleanup(nt);
 
        callout_drain(&nt->link_work);
 
@@ -1257,16 +1257,16 @@ ntb_transport_link_cleanup(struct ntb_netdev *nt)
 {
        int i;
 
-       if (nt->transport_link == NTB_LINK_DOWN)
-               callout_drain(&nt->link_work);
-       else
-               nt->transport_link = NTB_LINK_DOWN;
-
        /* Pass along the info to any clients */
        for (i = 0; i < nt->max_qps; i++)
                if (!test_bit(i, &nt->qp_bitmap))
                        ntb_qp_link_down(&nt->qps[i]);
 
+       if (nt->transport_link == NTB_LINK_DOWN)
+               callout_drain(&nt->link_work);
+       else
+               nt->transport_link = NTB_LINK_DOWN;
+
        /* 
         * The scratchpad registers keep the values if the remote side
         * goes down, blast them now to give them a sane value the next