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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 F09C2C433DB for ; Wed, 3 Mar 2021 13:50:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8AD964EE9 for ; Wed, 3 Mar 2021 13:50:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1447199AbhCCNsG (ORCPT ); Wed, 3 Mar 2021 08:48:06 -0500 Received: from m42-2.mailgun.net ([69.72.42.2]:42311 "EHLO m42-2.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1582432AbhCCKVZ (ORCPT ); Wed, 3 Mar 2021 05:21:25 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1614766865; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=wj9yRsgWncKIVARUwCuj7pr3e/bua+APomfcTLjUaCM=; b=DPPD3TRTGvyVVsgUnzyfEGHBI9rteSwpo7Zc9F2sCJZ09Ueu+HCSp+SEZrtzb8w4nmm9y5za DNK1ETqSu2qarY6g7xdltQwu/zoQ9u+B/B+8U9Kfdx4/M9UUd9g7bJbaGREIskS5rhubg8Oh wY6qb+APknOTWgx0drGWgq2Gli4= X-Mailgun-Sending-Ip: 69.72.42.2 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n07.prod.us-west-2.postgun.com with SMTP id 603f5f5639ef37211490cf5a (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 03 Mar 2021 10:05:10 GMT Sender: cang=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id D6EC5C43462; Wed, 3 Mar 2021 10:05:10 +0000 (UTC) Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: cang) by smtp.codeaurora.org (Postfix) with ESMTPSA id E4384C433CA; Wed, 3 Mar 2021 10:05:07 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 03 Mar 2021 18:05:07 +0800 From: Can Guo To: Adrian Hunter Cc: "Martin K . Petersen" , "James E . J . Bottomley" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Alim Akhtar , Avri Altman , Bean Huo , Asutosh Das , Stanley Chu Subject: Re: [PATCH] scsi: ufs: Fix incorrect ufshcd_state after ufshcd_reset_and_restore() In-Reply-To: <20210301191940.15247-1-adrian.hunter@intel.com> References: <20210301191940.15247-1-adrian.hunter@intel.com> Message-ID: X-Sender: cang@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-03-02 03:19, Adrian Hunter wrote: > If ufshcd_probe_hba() fails it sets ufshcd_state to UFSHCD_STATE_ERROR, > however, if it is called again, as it is within a loop in > ufshcd_reset_and_restore(), and succeeds, then it will not set the > state > back to UFSHCD_STATE_OPERATIONAL unless the state was > UFSHCD_STATE_RESET. > > That can result in the state being UFSHCD_STATE_ERROR even though > ufshcd_reset_and_restore() is successful and returns zero. > > Fix by initializing the state to UFSHCD_STATE_RESET in the start of > each > loop in ufshcd_reset_and_restore(). If there is an error, > ufshcd_reset_and_restore() will change the state to UFSHCD_STATE_ERROR, > otherwise ufshcd_probe_hba() will have set the state appropriately. > > Fixes: 4db7a2360597 ("scsi: ufs: Fix concurrency of error handler and > other error recovery paths") > Signed-off-by: Adrian Hunter > --- > drivers/scsi/ufs/ufshcd.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index 77161750c9fb..91a403afe038 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -7031,6 +7031,8 @@ static int ufshcd_reset_and_restore(struct > ufs_hba *hba) > spin_unlock_irqrestore(hba->host->host_lock, flags); > > do { > + hba->ufshcd_state = UFSHCD_STATE_RESET; > + > /* Reset the attached device */ > ufshcd_device_reset(hba); Hi Adrian, I've proposed a fix to get it addressed - https://lore.kernel.org/patchwork/patch/1383817/ Thanks, Can Guo.