Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp944534pxb; Wed, 3 Mar 2021 22:02:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyOXDzFygLlWY1F+JcWkK/r3JLPY2w+FJyhskg8zqTSHd1F6i6lKFieFhh6Bq4/a/Q+cXm2 X-Received: by 2002:a17:906:2ad8:: with SMTP id m24mr2487772eje.512.1614837727906; Wed, 03 Mar 2021 22:02:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614837727; cv=none; d=google.com; s=arc-20160816; b=wFwulAtJNVzBkMuVLxIVcn96k1AsMbe9SohW4A+zaYihiO+zj8+j8znb9i9xOG9QPQ qCEXxqTNkrLqsXwMWZLGWPknPEisDR+VU4+WSSZr5ytpw7Zyj7X6mIU4+cFXTBmEI+QU 092jNy+CL8LK+sPzxRx/ljXB5QB2GLNgmthO1AaZZwF/BxiRCMCfnwRtXeMf23HTkRiq u3ATOPnpSvM4R3iWwBBv3sZ+sw68gvx8vdAUgktGZSMj9UkqrL7O2Jx5R/pWjvoepnlU yO1wDihLDzke+rvU8b5WURSc8dBRB6kiGS4hKD7DtbAPbjZBsl74FAw5YVtP/qSvFDFp MkNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=8Tn2kzJ7FAI003TdNc30jO6HV4HcC/ct/qIWhIwhGIc=; b=XkmfyzyQH0ePCPOhboNsIuEzDyCJ6VW1oV6UEe4Uo+IDqqVhHCP7Snly9vM7gkq8V/ DHDnnNt47UH4ptBDxe8PSgG1BokSmqBZipDMr/0+/N2wTZ8r92LRtfQG33w2jHv51gaa BtNliE9fSnbQLkUEt1WRNgGiOz93Ezpz3BsCQPWFgTH7EOToYvV9Y6+b93BCbTGYtQZZ /9E3n7Frzv5L5yiWb0ZgniVvTDaKaRh7ijWe6KSD2P0CcdJrefwDeHD/V7Q06N6ydv6O fXLrC7Ck+wy41kLDdSdiuILeRW+v/Uv20ZhxJMX7Yp569yxqthy/FpnQgLv4RLkpLbUA Fkzw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r14si16027843edb.408.2021.03.03.22.01.45; Wed, 03 Mar 2021 22:02:07 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381704AbhCBIbr (ORCPT + 99 others); Tue, 2 Mar 2021 03:31:47 -0500 Received: from mga02.intel.com ([134.134.136.20]:56672 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376850AbhCBIPk (ORCPT ); Tue, 2 Mar 2021 03:15:40 -0500 IronPort-SDR: 5w1DZeJlsOW4YQb8Xmwz9ydz0LtQsmy4nsvooLC9e2M8jef5Pmt2km0u3o3HP+vjXUnn4HjKut WgrTaRT0Wp+w== X-IronPort-AV: E=McAfee;i="6000,8403,9910"; a="173868697" X-IronPort-AV: E=Sophos;i="5.81,216,1610438400"; d="scan'208";a="173868697" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2021 00:14:32 -0800 IronPort-SDR: 2GxtmNGV3uMj/YVMpE11TbS3n2Qx84HRH7u3pRZAvxX6XDZ78+pJ/srDjbaB5GO/NzPUgL49WD wrBQ7v3YzCgg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,216,1610438400"; d="scan'208";a="585812058" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.76]) ([10.237.72.76]) by orsmga005.jf.intel.com with ESMTP; 02 Mar 2021 00:14:29 -0800 Subject: Re: [PATCH] scsi: ufs: Fix incorrect ufshcd_state after ufshcd_reset_and_restore() To: Avri Altman , "Martin K . Petersen" , "James E . J . Bottomley" Cc: "linux-scsi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Alim Akhtar , Bean Huo , Can Guo , Asutosh Das , Stanley Chu References: <20210301191940.15247-1-adrian.hunter@intel.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <5fe97f16-406c-c279-b108-d27bb2769ed6@intel.com> Date: Tue, 2 Mar 2021 10:14:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > > >> --- >> 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 >