• Mike Christie's avatar
    scsi: qedi: Complete TMF works before disconnect · b40f3894
    Mike Christie authored
    We need to make sure that abort and reset completion work has completed
    before ep_disconnect returns. After ep_disconnect we can't manipulate
    cmds because libiscsi will call conn_stop and take onwership.
    
    We are trying to make sure abort work and reset completion work has
    completed before we do the cmd clean up in ep_disconnect. The problem is
    that:
    
     1. the work function sets the QEDI_CONN_FW_CLEANUP bit, so if the work was
        still pending we would not see the bit set. We need to do this before
        the work is queued.
    
     2. If we had multiple works queued then we could break from the loop in
        qedi_ep_disconnect early because when abort work 1 completes it could
        clear QEDI_CONN_FW_CLEANUP. qedi_ep_disconnect could then see that
        before work 2 has run.
    
     3. A TMF reset completion work could run after ep_disconnect starts
        cleaning up cmds via qedi_clearsq. ep_disconnect's call to qedi_clearsq
        -> qedi_cleanup_all_io would might think it's done cleaning up cmds,
        but the reset completion work could still be running. We then return
        from ep_disconnect while still doing cleanup.
    
    This replaces the bit with a counter to track the number of queued TMF
    works, and adds a bool to prevent new works from starting from the
    completion path once a ep_disconnect starts.
    
    Link: https://lore.kernel.org/r/20210525181821.7617-28-michael.christie@oracle.comReviewed-by: default avatarManish Rangankar <mrangankar@marvell.com>
    Signed-off-by: default avatarMike Christie <michael.christie@oracle.com>
    Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
    b40f3894
qedi_fw.c 66.2 KB