Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1029842pxb; Thu, 4 Mar 2021 01:05:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJylGGVBUBPHz9cJNjFgFJ74IWWDXtD+JDtggD2m/89JPcznryhBswx8SMyrvRtStU8ZrLmo X-Received: by 2002:a05:6402:312b:: with SMTP id dd11mr3196783edb.149.1614848749891; Thu, 04 Mar 2021 01:05:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614848749; cv=none; d=google.com; s=arc-20160816; b=wr6QzezzzLcm0rVR3390FLjAZa/pBfpXWKS8h00J8E9GnYXp6eGQghGuvs/KWpWohm Z1cDxSisgkgT/fX0cS8A4UgrKBd4kqXfAqZNkyzlwPHuZMxhP27DjePfEe9RUcFJzakz 5SAZ3oJ+ZZfXPnMOpbLiL9OkhMoz0rOIRMrV4YzxJewLfXeYJBsOqxu6Hn1Ru2rXUOPH Zz77cclgRTQhobqejnXOKtqOR9zX72RiJSlGWurqDELsyeaof8lex67L30dJd66qEYIm FjW6q8eoqHXNyKvP3pREdi6aEbunvXCIbXZSdyCJKJ/2KD9I91pCxrA0DGwUZJRl6k/7 WPuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :sender:dkim-signature; bh=wj9yRsgWncKIVARUwCuj7pr3e/bua+APomfcTLjUaCM=; b=cr5fVNGbemwXb2BqgpSpjiBXEvsY11b5F9fyKkrs5yma3vzWWWtPvRgjxeKaCV7GxB /sLzczDuDYmjA+A/A85Kv/chn4LPEA7AEZyiHJwhFczL5E4dwvvgzulajU2+O8D/6dHg zeJKXTDvoBRwFP5gEaJFqWvUlpgJR+Nwox6FIdUyUem1pcj9pzPzlqKC75dXIXAY3YBh +XEee/3fbiVzR8VH6qCIrfNEbYQJ18JeEnbq0YNQrszsm0ymkPBx9QeNEIlH6eWkHaNe qKl7ASJ9all1+EQbnkyCerV5rgqHkFEFpY47kmCuLj1jUHkKKW/uYWAf4j5c6xa/rAYQ Osmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=DPPD3TRT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s16si16554154ejf.641.2021.03.04.01.05.27; Thu, 04 Mar 2021 01:05:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=DPPD3TRT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1445828AbhCCNrs (ORCPT + 99 others); Wed, 3 Mar 2021 08:47:48 -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) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.0 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.