• Xiang Chen's avatar
    scsi: hisi_sas: check host frozen before calling "done" function · cd938e53
    Xiang Chen authored
    When the host is frozen in SCSI EH state, at any point after the LLDD
    sets SAS_TASK_STATE_DONE for the sas_task task state, libsas may free
    the task; see sas_scsi_find_task().
    
    This puts the LLDD in a difficult position, in that once it sets
    SAS_TASK_STATE_DONE for the task state it should not reference the
    sas_task again. But the LLDD needs will check the sas_task indirectly in
    calling task->task_done()->sas_scsi_task_done() or sas_ata_task_done()
    (to check if the host is frozen state actually).
    
    And the LLDD cannot set SAS_TASK_STATE_DONE for the task state after
    task->task_done() is called (as the sas_task is free'd at this point).
    
    This situation would seem to be a problem made by libsas.
    
    To work around, check in the LLDD whether the host is in frozen state to
    ensure it is ok to call task->task_done() function. If in the frozen
    state, we rely on SCSI EH and libsas to free the sas_task directly.
    
    We do not do this for the following IO types:
    
     - SMP - they are managed in libsas directly, outside SCSI EH
     - Any internally originated IO, for similar reason
    Signed-off-by: default avatarXiang Chen <chenxiang66@hisilicon.com>
    Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
    Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
    cd938e53
hisi_sas_v2_hw.c 106 KB