Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3946217pxb; Tue, 2 Mar 2021 02:41:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqiYJd1K+39YEO8cJ0mhk3ooh47L1NqS3QhDVyXK7T0jJqLETmN0rgjAp2fWuS1vkMhwxG X-Received: by 2002:a17:906:ae88:: with SMTP id md8mr19709123ejb.264.1614681660178; Tue, 02 Mar 2021 02:41:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614681660; cv=none; d=google.com; s=arc-20160816; b=f97nqid/M+Ysm8/iDazJ3zvAyyiUErxKwP/mjBpr/IwR8Nt25m5c3wshz5igjE5vPg SEm+Q24SqR3C54EXqYYUkuoXCFXBc3Vjqcnxv8BxVtcS7ZKU+x8LUXPBOlbszQjyiOjo hlZOKT2itK8CupOKT4ih3ZXSSY7qYySSmQQg7YgKN5t2K6dAqQLIjFUdRSDTqj38giK/ 1N+3IL09cjOD7cqneDJ/3vnnSQp5thZn452Xq+2ZFrVS7hwmLEWjU44MAfOqESLXho5x +q9VEh5Smyev5QiCRjlIbNx0JaP1AZBl8s8ZWViMQ1B4VB3CF8yEnWn1e7XxQYBKHY9F UY0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=EJucTMsMG3eGTMQJxEoqc1y+5jbVdCuS6lFG5U3a9Ok=; b=TB4eo+Af/OvfmZpe92bf0Bo4kFS0C0CCu9a2+/ibg4AjKDreLAdnj09ooU4pwGpoie FNn55op6hOk5tPEPlS79Oox9BjC4Xg/ob00He8j00YvDBSCuvNNjjV5QGO73PEMZGNHZ 7NI9GqeGm9FkIg7MUjYwnBH34JxqBBACtHMamsI5jiK6lL/m25oasW3gQ9rjo0r0X1KJ 29B2Fd7TK6mXYjms/qUMxengR7QbyfjP/AHGiv0iGjWrnGS0apEgDh+/LlvR9Wyj2TdI svVPD/Qeu2jBEWfjOQHNYbUH0WLX/+ljVM0BPhaPBJ8g2+MC0UGehdQlv5368VpJRaxl i3mg== 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 pw23si12506113ejb.18.2021.03.02.02.40.37; Tue, 02 Mar 2021 02:41:00 -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 S1345831AbhCBBql (ORCPT + 99 others); Mon, 1 Mar 2021 20:46:41 -0500 Received: from mga04.intel.com ([192.55.52.120]:41210 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236332AbhCATWd (ORCPT ); Mon, 1 Mar 2021 14:22:33 -0500 IronPort-SDR: 7R0A/rd9L2LsHIfJEcAuf/cBCNtEpe0Db0HAeVS1q1ixvQKD/ICvrzSGma17WUkZFhQM+ReA0f npnAsxiyY6DQ== X-IronPort-AV: E=McAfee;i="6000,8403,9910"; a="184133972" X-IronPort-AV: E=Sophos;i="5.81,215,1610438400"; d="scan'208";a="184133972" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2021 11:19:29 -0800 IronPort-SDR: arpXN5RRLSPAWd7Ewkk+EhwhjGceiKoQQv9gwC8a/X5MwhfJoyKI9NwYxVPOue0QH+fpzyROyC a3AGBNWtfjMA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,215,1610438400"; d="scan'208";a="427031988" Received: from ahunter-desktop.fi.intel.com ([10.237.72.76]) by fmsmga004.fm.intel.com with ESMTP; 01 Mar 2021 11:19:27 -0800 From: Adrian Hunter To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Alim Akhtar , Avri Altman , Bean Huo , Can Guo , Asutosh Das , Stanley Chu Subject: [PATCH] scsi: ufs: Fix incorrect ufshcd_state after ufshcd_reset_and_restore() Date: Mon, 1 Mar 2021 21:19:40 +0200 Message-Id: <20210301191940.15247-1-adrian.hunter@intel.com> X-Mailer: git-send-email 2.17.1 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.17.1