From patchwork Tue Sep 1 15:10:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 264589 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBB1BC433E7 for ; Tue, 1 Sep 2020 16:22:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 98C30206FA for ; Tue, 1 Sep 2020 16:22:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598977365; bh=p+uNYajHCNM3JrW5tTlFYkZ3P8VMd+9AAH5nA2e4Gv8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=luAlk5WTHJliHwnBHkGynuBao7k+RCNi+JuFxa+CFzCDPMnfivaqFv/Bx8jdvrEsd G5XLqUvPCB5tkNughHsP+aPq5PtKWgvPDc9AdkyeB9SKgPR7BpSQJV4bg6xj03AP1/ QaN8B1QAxJdggH0jm1tfdcfcUFCp/N6vmxH1NwCM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728381AbgIAQWj (ORCPT ); Tue, 1 Sep 2020 12:22:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:35852 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731010AbgIAPcV (ORCPT ); Tue, 1 Sep 2020 11:32:21 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B647A20866; Tue, 1 Sep 2020 15:32:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598974341; bh=p+uNYajHCNM3JrW5tTlFYkZ3P8VMd+9AAH5nA2e4Gv8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1Z7MWXpQ0EDBZj3Qf/LSIjIo4fPDmS2pr4bxna4jLcNem778pZEX3fXYLMBwn54Tl lX0Nbf+uJAcAQY6K69dCdOdI47A+LRWO8wg6JSoOvC12OxCKWAXNT69mbFx2jSVHNp yb/lxeW2S48Fsqwdd4i3RyKmr7a9lspkX4qrzsGE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Can Guo , Avri Altman , Stanley Chu , Bean Huo , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.4 139/214] scsi: ufs: Clean up completed request without interrupt notification Date: Tue, 1 Sep 2020 17:10:19 +0200 Message-Id: <20200901150959.642820073@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150952.963606936@linuxfoundation.org> References: <20200901150952.963606936@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Stanley Chu [ Upstream commit b10178ee7fa88b68a9e8adc06534d2605cb0ec23 ] 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 behave abnormally in the following scenario: After ufshcd_abort() returns, this request will be requeued by SCSI layer with its outstanding bit set. Any future completed request will trigger ufshcd_transfer_req_compl() to handle all "completed outstanding bits". At 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 because this request is still "alive". Link: https://lore.kernel.org/r/20200811141859.27399-2-huobean@gmail.com Reviewed-by: Can Guo Acked-by: Avri Altman Signed-off-by: Stanley Chu Signed-off-by: Bean Huo Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- 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 b51ccbf6cc59c..5e502e1605549 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6140,7 +6140,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", @@ -6174,6 +6174,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) goto out; } +cleanup: scsi_dma_unmap(cmd); spin_lock_irqsave(host->host_lock, flags);