diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 0b44e5bf9bea..97ca00d6b462 100755 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -7494,15 +7494,12 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba, #endif cmd->result = result; - clear_bit_unlock(index, &hba->lrb_in_use); lrbp->complete_time_stamp = ktime_get(); update_req_stats(hba, lrbp); ufshcd_complete_lrbp_crypto(hba, cmd, lrbp); /* Mark completed command as NULL in LRB */ lrbp->cmd = NULL; hba->ufs_stats.clk_rel.ctx = XFR_REQ_COMPL; - __ufshcd_release(hba, false); - __ufshcd_hibern8_release(hba, false); if (cmd->request) { /* * As we are accessing the "request" structure, @@ -7530,6 +7527,10 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba, } } + clear_bit_unlock(index, &hba->lrb_in_use); + __ufshcd_release(hba, false); + __ufshcd_hibern8_release(hba, false); + /* Do not touch lrbp after scsi done */ cmd->scsi_done(cmd); } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE || @@ -7579,12 +7580,10 @@ void ufshcd_abort_outstanding_transfer_requests(struct ufs_hba *hba, int result) /* Clear pending transfer requests */ ufshcd_clear_cmd(hba, index); ufshcd_outstanding_req_clear(hba, index); - clear_bit_unlock(index, &hba->lrb_in_use); lrbp->complete_time_stamp = ktime_get(); update_req_stats(hba, lrbp); /* Mark completed command as NULL in LRB */ lrbp->cmd = NULL; - ufshcd_release_all(hba); if (cmd->request) { /* * As we are accessing the "request" structure, @@ -7594,6 +7593,9 @@ void ufshcd_abort_outstanding_transfer_requests(struct ufs_hba *hba, int result) ufshcd_vops_pm_qos_req_end(hba, cmd->request, true); } + clear_bit_unlock(index, &hba->lrb_in_use); + ufshcd_release_all(hba); + /* Do not touch lrbp after scsi done */ cmd->scsi_done(cmd); } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE) {