From patchwork Tue Jun 23 09:05:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanley Chu X-Patchwork-Id: 11620115 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 62A06161F for ; Tue, 23 Jun 2020 09:05:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 488132078A for ; Tue, 23 Jun 2020 09:05:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="eUntoQE4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731971AbgFWJFT (ORCPT ); Tue, 23 Jun 2020 05:05:19 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:12525 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1731894AbgFWJFS (ORCPT ); Tue, 23 Jun 2020 05:05:18 -0400 X-UUID: 476d30af18d14cd08b988024d5536bd0-20200623 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=KrSrGuuWaYdD1xn1WyvfP2hN+0NoJYvJhqKj27QkdiE=; b=eUntoQE4VjF28P8VH9xdZRub0VHzYTYEd5Huq8Mm34YtPmJTH5JE0H015DJnqJQr9/nKeqlCmhmdA9VZXZU0W6BBMogD+QAQRNZX+OtxPDdH8SJ72AnLRJaQ+J984rzcfBSjqRk/7HSv3sUHn0owh6rhmA7S/guFGZ+LM1sSPAA=; X-UUID: 476d30af18d14cd08b988024d5536bd0-20200623 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1576730067; Tue, 23 Jun 2020 17:05:14 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs02n1.mediatek.inc (172.21.101.77) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 23 Jun 2020 17:05:06 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 23 Jun 2020 17:05:06 +0800 From: Stanley Chu To: , , , , CC: , , , , , , , , , , , , , , Stanley Chu Subject: [PATCH v1] scsi: ufs: Cleanup completed request without interrupt notification Date: Tue, 23 Jun 2020 17:05:11 +0800 Message-ID: <20200623090511.20085-1-stanley.chu@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If somehow no interrupt notification is raised for a completed request and its doorbell bit is cleared by host, UFS driver needs to cleanup its outstanding bit in ufshcd_abort(). Otherwise, system may crash by below abnormal flow: After this request is requeued by SCSI layer with its outstanding bit set, the next completed request will trigger ufshcd_transfer_req_compl() to handle all "completed outstanding bits". In this time, the "abnormal outstanding bit" will be detected and the "requeued request" will be chosen to execute request post-processing flow. This is wrong and blk_finish_request() will BUG_ON because this request is still in the request queue. Signed-off-by: Stanley Chu --- drivers/scsi/ufs/ufshcd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 52abe82a1166..f173ad1bd79f 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6462,7 +6462,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) /* command completed already */ dev_err(hba->dev, "%s: cmd at tag %d successfully cleared from DB.\n", __func__, tag); - goto out; + goto cleanup; } else { dev_err(hba->dev, "%s: no response from device. tag = %d, err %d\n", @@ -6496,6 +6496,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) goto out; } +cleanup: scsi_dma_unmap(cmd); spin_lock_irqsave(host->host_lock, flags);