Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4764336pxu; Wed, 21 Oct 2020 05:00:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxh+nr9p1pC9SPG4x62LNYiYOzbDEUphhhm+P4zOmnysN3bBvsFXqhQG7/Q2X/ksQ3WZJZW X-Received: by 2002:a17:906:b010:: with SMTP id v16mr3226484ejy.163.1603281609810; Wed, 21 Oct 2020 05:00:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603281609; cv=none; d=google.com; s=arc-20160816; b=ZJWYTro7XeKzDOeq/cdThCikC20OvD6PtLDtiy7nxura1mEfsWFwbphUhUD9VdbzsS mJqS4x3mYIfkr2h3L3rHR5tFenbGAkXCcLLY0nKX4IMtYcUaDdvKshMq+ImAyoU6mOaI 0jtXHJeHxsa3NU/HaaqZCZlYNvPWfgzuhp/k3NCWKFDd86ygI0HgKSP2OnBgFoTYheqU fnSl/iNoqSe77tguw7dB3Bk+kcSZR8+eUs95BbbE04ewgjegkdnFbHmFOgK05oLFM2bo BXG8nYbCF/5UMen/WC9JQmwczBl9dmSiSxW8DlBiXb98JBqw1HieZUERlbIPyG+1GxUn m7Uw== 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=Q99/rOnCLxfHaES0uHhwhzsm5Qm580CmW3mR5keYfYY=; b=UlIvgWZ9JjQCZuy3KQ3SqBa/jOSwmpX9Lt63DhPXV5FnCDVromQLjl/+jhFWxhIym0 2ZaG20vcrz7SlUZL7ft4/4mzb8lkg+4v7D0ilNYWVU/nDn+zJ3g3OVjx1/g1Uo97yS+S qHL6HBVtDxkFShqDqcHQbnLWSPubiw9m6qQDiq5IP81nxCr4W+ZdkaBwMgRGPnYzlnmD aj9+nyBiWCcmVwJzfc9Bf1ciuhWdKsimiRIeE9LWTxtRrLPCqkC7sPn2VwnmQnu/VIry db2JXx1Va7G4EFfEtTtyeeYZwfcD/ZJ0/npZPMLDErixTFW+tIB9kE+j3sXk7pLQgVmF t1Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=YEgDmNvF; 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 gu7si1238316ejb.146.2020.10.21.04.59.46; Wed, 21 Oct 2020 05:00:09 -0700 (PDT) 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=YEgDmNvF; 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 S2404943AbgJUBTB (ORCPT + 99 others); Tue, 20 Oct 2020 21:19:01 -0400 Received: from z5.mailgun.us ([104.130.96.5]:64222 "EHLO z5.mailgun.us" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393920AbgJUBTA (ORCPT ); Tue, 20 Oct 2020 21:19:00 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1603243140; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=Q99/rOnCLxfHaES0uHhwhzsm5Qm580CmW3mR5keYfYY=; b=YEgDmNvFk2zHnPq5NsuJO+87l/UhD06n0y1MT/v94nODqYr4LoPVTRNtFuzmmeXP6H+AWuyy kDCRwnQIEH1Lk/0SRFsO/OpNJn4rfwj7+X4JuG5oMtGeNqFv0eIsC58igi9L0UEEgflAQa9w goYGCtuG+2a3JxSrMtQvZyZxLTc= X-Mailgun-Sending-Ip: 104.130.96.5 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-n04.prod.us-west-2.postgun.com with SMTP id 5f8f8c83319d4e9cb56160d1 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 21 Oct 2020 01:18:59 GMT Sender: cang=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 81A20C433FE; Wed, 21 Oct 2020 01:18:59 +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 6BCC4C433C9; Wed, 21 Oct 2020 01:18:58 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 21 Oct 2020 09:18:58 +0800 From: Can Guo To: Bean Huo Cc: asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@codeaurora.org, rnayak@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com, Alim Akhtar , Avri Altman , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , Bart Van Assche , Satya Tangirala , open list Subject: Re: [PATCH v1 1/2] scsi: ufs: Serialize eh_work with system PM events and async scan In-Reply-To: References: <1600752747-31881-1-git-send-email-cang@codeaurora.org> <1600752747-31881-2-git-send-email-cang@codeaurora.org> Message-ID: <877678c6b188fc6a85d4d9c6cb7b89c1@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 2020-10-20 22:19, Bean Huo wrote: > On Mon, 2020-09-21 at 22:32 -0700, Can Guo wrote: >> Serialize eh_work with system PM events and async scan to make sure >> eh_work >> does not run in parallel with them. >> >> Change-Id: I33012c68e2ea443950313c59a4a46ad88cf3c82d >> Signed-off-by: Can Guo >> --- >> drivers/scsi/ufs/ufshcd.c | 64 +++++++++++++++++++++++++++++------ >> ------------ >> drivers/scsi/ufs/ufshcd.h | 1 + >> 2 files changed, 41 insertions(+), 24 deletions(-) >> >> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c >> index 1d8134e..7e764e8 100644 >> --- a/drivers/scsi/ufs/ufshcd.c >> +++ b/drivers/scsi/ufs/ufshcd.c >> @@ -5597,7 +5597,9 @@ static inline void >> ufshcd_schedule_eh_work(struct ufs_hba *hba) >> static void ufshcd_err_handling_prepare(struct ufs_hba *hba) >> { >> pm_runtime_get_sync(hba->dev); >> - if (pm_runtime_suspended(hba->dev)) { >> + if (pm_runtime_status_suspended(hba->dev) || hba- >> >is_sys_suspended) { > > Hi Can > > I curiously want to know how this can be produced in real system. > > IMO, The system has been in system PM suspeded mode, how can trigger > error handler? because the tasks have been freezed, the device > interrupts disabled, before entering system PM suspended mode, the > tasks in the queue should be completed, otherwises, there is bug in the > whole flow. > > > thanks, > Bean Hi Bean, You might misunderstand here - the hba->is_sys_suspended check is not for the case that system has entered suspend, but for the case a resume failure happens. If system resume fails, hba->is_sys_suspended is set and powers/clks/IRQs are OFF, so we need to prepare the environments for err_handler to run. To reproduce this scenario, you can fake a hibern8 exit failure during system resume. If the whole system has entered suspend, of course err_handler won't run. I guess your real concern is that if UFS has entered system suspend (not the whole system), but err_handling was somehow scheduled (most likely due to an non-fatal error). This definitely is a problem and it is also why I make this change. With this change, if UFS has entered system suspend, the eh_sem lock is held, err_handler won't even get a chance to run, the err_handler will run only after UFS is resumed. Thanks, Can Guo.