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: 12922501 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A926C43334 for ; Tue, 19 Jul 2022 13:22:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=XWwHlDfeBsIQWmDnQTsbFMeStkL+HvnCAPkSi5GnpeE=; b=mfalKl81f0M2WvpCsRQO1bAL1o s0U/dfdbdumwQ49WXdOkY3SHQEta4y+jEhtPUR2OeEegAQ6LuNXQ61f33Lb/VH41fkTSbw2/+U2IL q+ra1GpA2AHB7c3yTXa8+hjBd9fXmA70jLr1E4vubL6/WmsJivIT0jp0a0HfHAVdKkK5XIc3g1PJt VErdr1d7qQdKL54OzPUQfvt2TicP+6vis+G6prKsVny3x571I8cr10wPbenqlpFLBm7GyiAIVEDpC DQqA8LhoC+oZtD+0BN3XQxhiLqnVWP3YF3cBsQ8MgmREiCfm22ynZua8tvXGNzIooGdNRz1xEoV42 IkWSHOOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oDnBM-0098pS-2j; Tue, 19 Jul 2022 13:22:36 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oDnBI-0098jk-Jf for linux-mediatek@lists.infradead.org; Tue, 19 Jul 2022 13:22:35 +0000 X-UUID: 2e1f9cf6b81c4a748d72a81c1f128491-20220719 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.8,REQID:b5a3a9b3-6e6c-4673-9c69-a01beee80b1f,OB:0,LO B:0,IP:0,URL:5,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACTI ON:release,TS:5 X-CID-META: VersionHash:0f94e32,CLOUDID:8676b564-0b3f-4b2c-b3a6-ed5c044366a0,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:1,File:nil ,QS:nil,BEC:nil,COL:0 X-UUID: 2e1f9cf6b81c4a748d72a81c1f128491-20220719 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2056249374; Tue, 19 Jul 2022 06:22:22 -0700 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220719_062232_671974_CB83E83C X-CRM114-Status: UNSURE ( 9.78 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.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: