From 820e10e82012b85177e0df251193a3f3edd73d23 Mon Sep 17 00:00:00 2001 From: Can Guo Date: Fri, 17 Jul 2020 09:03:49 +0800 Subject: [PATCH] scsi: ufs: Clear uic_cmd->cmd_active before calling complete() Previously, uic_cmd->cmd_active is cleared after completion has been raised so that we can tell completion timeout happened due to kernel scheduling, which is for debugging purposes. It is more important, however, to increase the chance that UIC cmd survives from a completion timeout. So, this change clears uic_cmd->cmd_active before calling complete(). Change-Id: I99254ac4e3b16dc6b905b5ed5248d53f9c9fc3af Signed-off-by: Can Guo --- drivers/scsi/ufs/ufshcd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index c1713bbfcde4..74521494c165 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -5079,15 +5079,16 @@ static irqreturn_t ufshcd_uic_cmd_compl(struct ufs_hba *hba, u32 intr_status) ufshcd_get_uic_cmd_result(hba); hba->active_uic_cmd->argument3 = ufshcd_get_dme_attr_val(hba); - complete(&hba->active_uic_cmd->done); if (!hba->uic_async_done) hba->active_uic_cmd->cmd_active = 0; + complete(&hba->active_uic_cmd->done); retval = IRQ_HANDLED; } if ((intr_status & UFSHCD_UIC_PWR_MASK) && hba->uic_async_done) { + if (hba->active_uic_cmd) + hba->active_uic_cmd->cmd_active = 0; complete(hba->uic_async_done); - hba->active_uic_cmd->cmd_active = 0; retval = IRQ_HANDLED; } return retval;