From mboxrd@z Thu Jan 1 00:00:00 1970 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=-14.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 BED29C433DF for ; Mon, 24 Aug 2020 16:56:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D149204EA for ; Mon, 24 Aug 2020 16:56:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598288203; bh=gM8butPAb14I94cSkihJEec7V6B/JnReAt5N+x82qVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ajKcIVZA738+stAF1o0e/xiujwhRKyx/sisUHxrpMBIY+qWwVPTyCMOMhT+MoiItV nlOWKNGpRtr6ucZyVnw3qVHH2dKq0VTvIL7yzVd5U9A628nqbruSBVvhLSW9Vp2Vpb L2Zleh6znO6yitJph9WM73lldAzYlxAfoV4SBvPQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726444AbgHXQ4m (ORCPT ); Mon, 24 Aug 2020 12:56:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:40038 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728545AbgHXQjG (ORCPT ); Mon, 24 Aug 2020 12:39:06 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4152F22D02; Mon, 24 Aug 2020 16:39:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598287146; bh=gM8butPAb14I94cSkihJEec7V6B/JnReAt5N+x82qVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VHxm5wKC5B/UlWgx7Yx1HIcSsF66uNWaUQluxKA9urKwxCUQ/meDlXoI7RNLYzXoT z6pTmi+FmURiL+2GHYoKVYngFbR1CwC+4XZ46bQ5UbxYoEqwrAVmRbN8Qvxvrluy+k NmjVaPKeEFnnxwx8i60MiqIWgREIzut9QoYMfvhI= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Stanley Chu , Can Guo , Avri Altman , Bean Huo , "Martin K . Petersen" , Sasha Levin , linux-scsi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH AUTOSEL 4.19 15/21] scsi: ufs: Clean up completed request without interrupt notification Date: Mon, 24 Aug 2020 12:38:39 -0400 Message-Id: <20200824163845.606933-15-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200824163845.606933-1-sashal@kernel.org> References: <20200824163845.606933-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 72879280df776..546bf4f960f91 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -5928,7 +5928,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", @@ -5962,6 +5962,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) goto out; } +cleanup: scsi_dma_unmap(cmd); spin_lock_irqsave(host->host_lock, flags); -- 2.25.1