Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp160022pxb; Thu, 14 Jan 2021 23:01:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJz6BZhWFj1prag9M9K6ngzs4sdl1jJRNMPvNS4DYExAVFnymXyOM1RJp2BQKAswPERdrzAn X-Received: by 2002:a05:6402:5246:: with SMTP id t6mr8475380edd.62.1610694115542; Thu, 14 Jan 2021 23:01:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610694115; cv=none; d=google.com; s=arc-20160816; b=B8Pn1NgbLPVaN9yHo8EH0H9/M3C+rA9B6rD9RGUd+3qar2f/U41w8KD2Cg9SX45SMP 8R4ckIVdDNsGXxOSFS4scR7MYKVHXsGM31CZIP6f+Ffe7nshQ6YwlGYqt2eOOpVt3wdp oo84gsFs+IELT5Ky8KGt4HrRlzRywzvjuz6FZsiO+u+/K8WKafRelOCjeW3EMftt1AQN gKcmPYBNCSL2ISQ7BB7QwCL0zxG6g1BoVQT6V6OErwLR/xWo07AR/WKnBuILHeYrF7Dh vHLaGY3QqwMMjYxbbiDN0gto/GZ4Nh+NIqg5SzUTOJh9SI/BQij9v+4W9deifpVH6H3Y v8WA== 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=VF7B3AAlfgOWvaW/r39W85wfMo4EzUscUd7nkIBnDss=; b=yShMei58zh82TRbs5o3dOsUNdpNneGmpjUQKEaCDZtFlIOLhx4xc2Jwl0xsKi2GaxZ yuYdkFCMKoJEGuUo/c/g7Q+5w0kU9k52tiZPb6r3qYf3LVibthkUULclqkSuKU7m2GM3 wrg/lVqjF/KB/cKNQEQB9yZQraD84DAxMd/6GB+WrhkcpevoHIpB5zxH+bOE832qDJcf IwQy5oHVxOIQmFguFzNIJPLG1VC/TIlPhYRXdbGASSH+hZT8mBlo3oqx9rVa34ehWDh5 Et9XZCSPnfT85lQ2LSwOkYtmVvhcP9D8Mm7W41O+8VocoPVp05h26jiOHfP79tfGhQNa VcvQ== 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 o18si3243393eje.528.2021.01.14.23.01.31; Thu, 14 Jan 2021 23:01:55 -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 S1731340AbhAOBhN (ORCPT + 99 others); Thu, 14 Jan 2021 20:37:13 -0500 Received: from labrats.qualcomm.com ([199.106.110.90]:13949 "EHLO labrats.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725815AbhAOBhM (ORCPT ); Thu, 14 Jan 2021 20:37:12 -0500 IronPort-SDR: lRgqXgWEIvhFu/KcUySbJRnLYYPldxkEii9NaZ9a6uNF+arWDIa3McN3Hq9QZUE6pGJCtw7Jlh pDq94ktMD9rsO3EMhYoRwyKQIvZUiS+Q3fHrPWVrzHA5+Uq+TvAqZEmRtQbiwdmFkahVwLAArp 4eFkDV31AtVV/J8AKZ9hVTnCD1FOT81o7We9Wf1GHYyu2tBHuPOFKt+JMvumgmE4K04F7J1ZEV I0Pzf0KZqsJX8q117LBqv+3Krm15uwjjTR2HFKw5s3hKlPOTdQ33eVgWaRkCCy4/TwrNLIRoPl 5ds= X-IronPort-AV: E=Sophos;i="5.79,347,1602572400"; d="scan'208";a="29542002" Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by labrats.qualcomm.com with ESMTP; 14 Jan 2021 17:36:32 -0800 X-QCInternal: smtphost Received: from stor-presley.qualcomm.com ([192.168.140.85]) by ironmsg04-sd.qualcomm.com with ESMTP; 14 Jan 2021 17:36:31 -0800 Received: by stor-presley.qualcomm.com (Postfix, from userid 359480) id 5A430218C5; Thu, 14 Jan 2021 17:36:31 -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 , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/2] scsi: ufs: Minor adjustments to error handling Date: Thu, 14 Jan 2021 17:36:18 -0800 Message-Id: <1610674580-20811-2-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1610674580-20811-1-git-send-email-cang@codeaurora.org> References: <1610674580-20811-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 diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 53fd59c..bb0ef70 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4964,6 +4964,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)) { /* @@ -5765,10 +5766,16 @@ static void ufshcd_err_handling_prepare(struct ufs_hba *hba) ufshcd_suspend_clkscaling(hba); } } + ufshcd_scsi_block_requests(hba); + /* Clean up ufshcd_queuecommand path */ + 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 (hba->clk_scaling.is_allowed) ufshcd_resume_clkscaling(hba); @@ -5862,8 +5869,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); @@ -6022,7 +6029,6 @@ 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->eh_sem); } @@ -7836,6 +7842,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.