Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1030038pxb; Thu, 4 Mar 2021 01:06:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHTeX//pI9GKa+63Mpd1JUw1h3A3/c0sMn44U8V9Xvx7JX6CmdOTfDFKrXXHCjGA2A9Kf+ X-Received: by 2002:a17:907:e8f:: with SMTP id ho15mr3165777ejc.541.1614848769131; Thu, 04 Mar 2021 01:06:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614848769; cv=none; d=google.com; s=arc-20160816; b=ZRXO7sBtzHB0kN88VqswbgdhFPY0op32vknHvVWGHITTRDJN3S8nPj+4oBRpUnmuLd XOIzvv4rfz6Dy0JTijj8AXPSjOCnKg5i8z/3stH6jSrUVBGEfLdAvsXjnsujALjx1cnF ygmJOUVQ5cC17AwFda9LLupwBbFY6lQdLxJmxKLNGt+eN4UkmDbho/xVV0xerT5NDKUZ H8+ZjqDw9UESe6gUjICzpobUqRexlPnZsXYwr2IZ+rV3+lwCz1wIoVgRLYcPINmtcF+E wg8cF0UsmnrbO0ICZCBNjWEemT8vn/f2kUecRobW7Brdcwwj9OrFojUbL/k7zKuqFV9E HeUw== 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=bfCTWDQxGsoJJN+YSMUDZDqMyYOjzCwqvQuLqpjmVfE=; b=Uv5l/ZOyYvIgCZjAJZ2wIxVuX2J0XVbh63N+dx1/sPNamZxjSgODZd2emwXIAjoMX6 QSftaVANbULhEYnHPD48UmZT0q2QpHw+icDi5SVL4Zj6dvre69J+tEPlPIWgP+jjxAKl eJYjbUtH33ZU1jvugBAO/FOb0JrAxDWeOI76FQP51sF2CBKq/umtV4fdF74t54Gfv+hu p3lX/jHVwX/lcqf8mYNoqhpIuLdr5DlxKm8xMhzcn6ua8m5CJJEIXtQFtYVxfydbznHl qCD6A8ufVLvG0rkm2x64dcCAAXkvZ2sGaCpJKPTlSq5a9K1y2NrZY3cXITRCrnQ88FEw ec6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b="rJqI5Ug/"; 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 j11si5779919edj.481.2021.03.04.01.05.47; Thu, 04 Mar 2021 01:06:09 -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="rJqI5Ug/"; 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 S1344557AbhCCNlz (ORCPT + 99 others); Wed, 3 Mar 2021 08:41:55 -0500 Received: from z11.mailgun.us ([104.130.96.11]:21938 "EHLO z11.mailgun.us" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1452383AbhCCKUb (ORCPT ); Wed, 3 Mar 2021 05:20:31 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1614766811; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=bfCTWDQxGsoJJN+YSMUDZDqMyYOjzCwqvQuLqpjmVfE=; b=rJqI5Ug/qwtePLXtRLgC4akv9RAJUwJZX/zW7bVLULXTewQn5UxtK8ilZdqbrk4T6yNEz9fC OduKTKCjZWPc7Yw8YE/IMgDfoQkv0Tob9o24F/dHuKo4WF1eUjW0wBmrOV9PGBZZhRIVNb/I Cc3ouNsXPUiGl+vZ8RNPJYol47E= X-Mailgun-Sending-Ip: 104.130.96.11 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-n03.prod.us-west-2.postgun.com with SMTP id 603f5faf7b9e2700a3d2a327 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 03 Mar 2021 10:06:39 GMT Sender: cang=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 11F7EC43463; Wed, 3 Mar 2021 10:06:38 +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 C99BBC433C6; Wed, 3 Mar 2021 10:06:37 +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:06:37 +0800 From: Can Guo To: Avri Altman Cc: asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, Alim Akhtar , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , Jaegeuk Kim , open list Subject: Re: [PATCH v2 1/3] scsi: ufs: Minor adjustments to error handling In-Reply-To: <3c6df42fef5a1e52e655753aadec4a11@codeaurora.org> References: <1614145010-36079-1-git-send-email-cang@codeaurora.org> <1614145010-36079-2-git-send-email-cang@codeaurora.org> <3c6df42fef5a1e52e655753aadec4a11@codeaurora.org> Message-ID: <43928e58a5e93fe10487d30bddbf994a@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-03 18:03, Can Guo wrote: > Hi Avri, > > On 2021-03-03 15:22, Avri Altman wrote: >>> >>> >>> 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 >> I noticed that you tagged Adrian's patch - >> https://lore.kernel.org/lkml/20210301191940.15247-1-adrian.hunter@intel.com/ >> So this patch needs to be adjusted accordingly? > > Thanks for pointing me to that one, I will rebase mine. > > Regards, > Can Guo. > Just noticed that Adrian's change comes later than mine, so I may not need to adjust mine. Thanks, Can Guo. >> >> Thanks, >> Avri >> >>> --- >>> 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.