From patchwork Tue Jul 19 13:02:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UGV0ZXIgV2FuZyAo546L5L+h5Y+LKQ==?= X-Patchwork-Id: 12922546 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2881EC433EF for ; Tue, 19 Jul 2022 13:49:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238099AbiGSNtf (ORCPT ); Tue, 19 Jul 2022 09:49:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239334AbiGSNtN (ORCPT ); Tue, 19 Jul 2022 09:49:13 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D09C10AD8F for ; Tue, 19 Jul 2022 06:02:21 -0700 (PDT) X-UUID: f5c2f19f784f412b873b245918ed6fc3-20220719 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.8,REQID:f29795bf-64a0-4699-9ce3-ae2a09e823ef,OB:0,LO B:0,IP:0,URL:5,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,RULE:Release_Ham,ACT ION:release,TS:100 X-CID-INFO: VERSION:1.1.8,REQID:f29795bf-64a0-4699-9ce3-ae2a09e823ef,OB:0,LOB: 0,IP:0,URL:5,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,RULE:Spam_GS981B3D,ACT ION:quarantine,TS:100 X-CID-META: VersionHash:0f94e32,CLOUDID:607ee7d7-5d6d-4eaf-a635-828a3ee48b7c,C OID:92ce10ef286f,Recheck:0,SF:28|17|19|48,TC:nil,Content:0,EDM:-3,IP:nil,U RL:1,File:nil,QS:nil,BEC:nil,COL:0 X-UUID: f5c2f19f784f412b873b245918ed6fc3-20220719 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1818527939; Tue, 19 Jul 2022 21:02:11 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Tue, 19 Jul 2022 21:02:10 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.3 via Frontend Transport; Tue, 19 Jul 2022 21:02:10 +0800 From: To: , , , , , CC: , , , , , , , , , , Subject: [PATCH v1] scsi: ufs: correct ufshcd_shutdown flow Date: Tue, 19 Jul 2022 21:02:08 +0800 Message-ID: <20220719130208.29032-1-peter.wang@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Peter Wang After ufshcd_wl_shutdown set device poweroff and link off, ufshcd_shutdown not turn off regulators/clocks. Correct the flow to wait ufshcd_wl_shutdown done and turn off regulators/clocks by polling ufs device/link state 500ms. Also remove pm_runtime_get_sync because it is unnecessary. Signed-off-by: Peter Wang --- drivers/ufs/core/ufshcd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index c7b337480e3e..1c11af48b584 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -9461,10 +9461,14 @@ EXPORT_SYMBOL(ufshcd_runtime_resume); */ int ufshcd_shutdown(struct ufs_hba *hba) { - if (ufshcd_is_ufs_dev_poweroff(hba) && ufshcd_is_link_off(hba)) - goto out; + ktime_t timeout = ktime_add_ms(ktime_get(), 500); - pm_runtime_get_sync(hba->dev); + /* Wait ufshcd_wl_shutdown clear ufs state, timeout 500 ms */ + while (!ufshcd_is_ufs_dev_poweroff(hba) || !ufshcd_is_link_off(hba)) { + if (ktime_after(ktime_get(), timeout)) + goto out; + msleep(1); + } ufshcd_suspend(hba); out: