Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp226381pxb; Tue, 23 Feb 2021 23:54:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcO43VOxR3fnApXHvkAsIiuiaiioYEZbBrA3kPZxBTiWItfk0/c7sXmaZSrgNYKMmazP0Z X-Received: by 2002:a17:906:f18a:: with SMTP id gs10mr1456020ejb.341.1614153257783; Tue, 23 Feb 2021 23:54:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614153257; cv=none; d=google.com; s=arc-20160816; b=MMkKCPQvdgn0iI5U+u46YQOqku+o/6fc/p8sHdL/eVzH+zE+OVTq0Z1WmhlAgyHwla wDKbI2qcC5RwLLUNTGYup2kERUmQ4GXXSnlcDuwCVEY9OAAPhyIDKO0VMU2YtQWXnAXk 3uU1DKQxjhSPpRwSHUpfn3ZbC/8DeDXESH2YYe7pVpVs6hr37SCgiPmoNh96bt8Kv+W3 NZtjMNprM+EO4dvMUlNTMVD3cUtBxhfAk/LSNnQCdbQfu3v8S7fnj+uhBcIaEnODg9qK ZpJG9Cd285+TmN7HhYS2soo3xV8uvv0IPt4vYcX6pdMItCmkt81Sn39Bo25QEqbJqixJ W7dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr; bh=/x2Se2bsdsKHgvOxOpDKrJk1EEtTnW+KTSnoKMRD0XM=; b=KE37kGP4a/k0zV4Vh/WZ7ionN1pU0phOCibFx3C1bYljiY1HWmBfg5SlLT05o0HJ6N E8zYJ4KKlu55v4FUx5pf26bWp3ekudBhHCM1JfcBed0SvKnMT9EsoSsddtof3+cwgH8j s7IAWwLl7hzSyBlgUbSvgMu1OzyvlrsnxU9P3+ZBANtO/Q313B5ahL3lMK9PRar0IFc4 pCDTwcHigpBpv7YgHH8WAI2sOMPTaE+l/7fJYH3BbiAvCK3oG1kLZMylPei9/LtQcqIy SFHMrHg2/bg8TbJnI65qKTO3VpTGh6keoBMXNRD8BY2mQZVisyaXykLunCwIK3kDeH7o Rhiw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si888351ejd.83.2021.02.23.23.53.54; Tue, 23 Feb 2021 23:54:17 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233978AbhBXFhn (ORCPT + 99 others); Wed, 24 Feb 2021 00:37:43 -0500 Received: from labrats.qualcomm.com ([199.106.110.90]:3383 "EHLO labrats.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231445AbhBXFhm (ORCPT ); Wed, 24 Feb 2021 00:37:42 -0500 IronPort-SDR: VFUJjWc2DPJGzoAUvU0BCP2avjDIqsx4Ox2hduoRvJTZJq9AnZI8BKT4zzvr5tlFczBuB+VjQf vXahwRMUy6ADeVbFQ9m548+nzVl4Ap2PLsOJ1GYp9w0rkmw0w8mBkb2i741eoDpCFWJRRaYyOM DhWreb/mut+z5DTwhtJTawPDgDsyLra5L6KbIq2aHxj0wIMdKHoRoYUXcd/ySYuR6ofLQnl+RR vqsQtY+smGab91iFVhFjdV7y8Uu3lxr5KikdenQSZFz4aOTTR0F55MxnSXTMKXnYmn36Fu+8kc 8yo= X-IronPort-AV: E=Sophos;i="5.81,201,1610438400"; d="scan'208";a="47788277" Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by labrats.qualcomm.com with ESMTP; 23 Feb 2021 21:37:01 -0800 X-QCInternal: smtphost Received: from wsp769891wss.qualcomm.com (HELO stor-presley.qualcomm.com) ([192.168.140.85]) by ironmsg03-sd.qualcomm.com with ESMTP; 23 Feb 2021 21:37:00 -0800 Received: by stor-presley.qualcomm.com (Postfix, from userid 359480) id 0D1F921A10; Tue, 23 Feb 2021 21:37:00 -0800 (PST) From: Can Guo To: asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, cang@codeaurora.org Cc: Alim Akhtar , Avri Altman , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , Jaegeuk Kim , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 1/3] scsi: ufs: Minor adjustments to error handling Date: Tue, 23 Feb 2021 21:36:47 -0800 Message-Id: <1614145010-36079-2-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1614145010-36079-1-git-send-email-cang@codeaurora.org> References: <1614145010-36079-1-git-send-email-cang@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In error handling prepare stage, after SCSI requests are blocked, do a down/up_write(clk_scaling_lock) to clean up the queuecommand() path. Meanwhile, stop eeh_work in case it disturbs error recovery. Moreover, reset ufshcd_state at the entrance of ufshcd_probe_hba(), since it may be called multiple times during error recovery. Signed-off-by: Can Guo --- drivers/scsi/ufs/ufshcd.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 80620c8..013eb73 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4987,6 +4987,7 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) * UFS device needs urgent BKOPs. */ if (!hba->pm_op_in_progress && + !ufshcd_eh_in_progress(hba) && ufshcd_is_exception_event(lrbp->ucd_rsp_ptr) && schedule_work(&hba->eeh_work)) { /* @@ -5784,13 +5785,20 @@ static void ufshcd_err_handling_prepare(struct ufs_hba *hba) ufshcd_suspend_clkscaling(hba); ufshcd_clk_scaling_allow(hba, false); } + ufshcd_scsi_block_requests(hba); + /* Drain ufshcd_queuecommand() */ + down_write(&hba->clk_scaling_lock); + up_write(&hba->clk_scaling_lock); + cancel_work_sync(&hba->eeh_work); } static void ufshcd_err_handling_unprepare(struct ufs_hba *hba) { + ufshcd_scsi_unblock_requests(hba); ufshcd_release(hba); if (ufshcd_is_clkscaling_supported(hba)) ufshcd_clk_scaling_suspend(hba, false); + ufshcd_clear_ua_wluns(hba); pm_runtime_put(hba->dev); } @@ -5882,8 +5890,8 @@ static void ufshcd_err_handler(struct work_struct *work) spin_unlock_irqrestore(hba->host->host_lock, flags); ufshcd_err_handling_prepare(hba); spin_lock_irqsave(hba->host->host_lock, flags); - ufshcd_scsi_block_requests(hba); - hba->ufshcd_state = UFSHCD_STATE_RESET; + if (hba->ufshcd_state != UFSHCD_STATE_ERROR) + hba->ufshcd_state = UFSHCD_STATE_RESET; /* Complete requests that have door-bell cleared by h/w */ ufshcd_complete_requests(hba); @@ -6042,12 +6050,8 @@ static void ufshcd_err_handler(struct work_struct *work) } ufshcd_clear_eh_in_progress(hba); spin_unlock_irqrestore(hba->host->host_lock, flags); - ufshcd_scsi_unblock_requests(hba); ufshcd_err_handling_unprepare(hba); up(&hba->host_sem); - - if (!err && needs_reset) - ufshcd_clear_ua_wluns(hba); } /** @@ -7858,6 +7862,8 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool async) unsigned long flags; ktime_t start = ktime_get(); + hba->ufshcd_state = UFSHCD_STATE_RESET; + ret = ufshcd_link_startup(hba); if (ret) goto out; -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.