Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1525479pxb; Thu, 4 Mar 2021 13:44:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxKHh79P7kanQaP1R3JWpJ2hjQ+I3/Ebv7PNOUJO8NRvfmYjYomD83hsy2Uut2EYxKRsKyF X-Received: by 2002:aa7:dd97:: with SMTP id g23mr2259966edv.154.1614894291524; Thu, 04 Mar 2021 13:44:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614894291; cv=none; d=google.com; s=arc-20160816; b=03fD9yRmKs/2nBRtA4NpciImFTNXZecY1RfrnR3qYnJFN0YpNxD4D7tcZ8MIXxP1yP I7Td0Bnh/qmrC/oS+AEJAYOZ4u6dqj0rKmAIP6Mw16shpJa5RWEq+/T53tssVlDFBN/Q 8T3C7JvYTIE7ggOF4v90EOMYL3alxdPFeU+7d1pPA02g4igMKzvDrnX1oIQ0T/HMKOlD 8kpGxGWN9fxOmZ1JAruUk3ES9lHwIMMgzMCrOrorW8zDNZktTpYTHayNXBlR3H4ISrbb Wo9BIrmMmr/C8vXCox4BXiregEmcT+iVBgnkJucRzZmRZH2lC+LJa+1fNPzkfcJmaIpf WJXQ== 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=NgawUiqwXp+6LkGutn5iBvxqzt510G1PCZ3d25uDEa4=; b=fwBwnvJ8yzMn9W7UIZc5VXdKRYZIOikBMCEH6Kg87qngxRfKPyWTO0viI9J0tvFRn5 MV3Scp+t6gJOCTm6Bq51lK8x1/vHCaaJ6PGSlq0gRdYQAPCCk89oXz2SnvLJ0Xr9YHIx HZiG6AwM16mgg/Pd2OFCAftoz8xhxwpt+YORp8B169AjSLBbBMpUDRs6FiKZj9PFLs/h w9JrTNc7LVxsXSZqHbzNq6m0S0yjOENVp4wJep4K2D6/m9mr7frtifp+UuA+0nCwgZB3 nE0c1kP+YA8KBIwbMmkiqJVg5wG7fJMZCFmL+H6x+/kVtllFwUTT+DwkRrvNuVB70cac L0Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=Yl2o+oO3; 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 a20si245441ejg.492.2021.03.04.13.44.28; Thu, 04 Mar 2021 13:44:51 -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=Yl2o+oO3; 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 S1444412AbhCCNlX (ORCPT + 99 others); Wed, 3 Mar 2021 08:41:23 -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 S1449361AbhCCKU1 (ORCPT ); Wed, 3 Mar 2021 05:20:27 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1614766808; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=NgawUiqwXp+6LkGutn5iBvxqzt510G1PCZ3d25uDEa4=; b=Yl2o+oO3yd1GLxmMloKbhyYbcEi85wezsPV6e71pkEcqqx6EDGgNeJlHX4dxPv0r4KY6z4Ze FeV+TkaJ99HiFSxsDXQW5TT7fDBjGwwrfAVawDtIWzPZmYvT7/u+7y075u2aDmKPtCrLEUtG TIhZ8dbM5SKrWifkhHSyPuJsnh0= 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-n04.prod.us-west-2.postgun.com with SMTP id 603f62a639ef3721149d633a (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 03 Mar 2021 10:19:18 GMT Sender: cang=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 88C67C43463; Wed, 3 Mar 2021 10:19:18 +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, URIBL_BLOCKED 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 B2974C433C6; Wed, 3 Mar 2021 10:19:17 +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:19:17 +0800 From: Can Guo To: Adrian Hunter Cc: Avri Altman , "Martin K . Petersen" , "James E . J . Bottomley" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Alim Akhtar , Bean Huo , Asutosh Das , Stanley Chu Subject: Re: [PATCH] scsi: ufs: Fix incorrect ufshcd_state after ufshcd_reset_and_restore() In-Reply-To: <5fe97f16-406c-c279-b108-d27bb2769ed6@intel.com> References: <20210301191940.15247-1-adrian.hunter@intel.com> <5fe97f16-406c-c279-b108-d27bb2769ed6@intel.com> Message-ID: <80301bea84b7349ca9dbdcc4f2c9a744@codeaurora.org> 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 16:14, Adrian Hunter wrote: > On 2/03/21 9:01 am, Avri Altman 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 >> I think that CanG recent series addressed that issue as well, can you >> take a look? >> https://lore.kernel.org/lkml/1614145010-36079-2-git-send-email-cang@codeaurora.org/ > > Yes, there it is mixed in with other changes. However it is probably > better > as a separate patch. Can Guo, what do you think? Oh, I missed this one... Sure, I will split it out as a seperate change in next version. Thanks, Can Guo. > >> >> >>> --- >>> 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); >>> >>> -- >>> 2.17.1 >>