Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3406919rwa; Tue, 23 Aug 2022 04:22:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR68venC8zYTEJEeOs6sebAuZMMqL5npwNS7WrM+c8guSoLlDI1LMw7crR1f6ssbvd6oZ3rH X-Received: by 2002:a17:902:edc3:b0:172:8ae3:9778 with SMTP id q3-20020a170902edc300b001728ae39778mr23813989plk.72.1661253759937; Tue, 23 Aug 2022 04:22:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253759; cv=none; d=google.com; s=arc-20160816; b=uYgrcz6ZZ6ZTIrkrMfxzi/4JmGNQLKdcATAfMH7dEfOVDlmCdOlYNVdUQvyl4LMuin kkFhayq5vXM1yXyHuPmC3Bu3qebrfU3dP4Vd7zB7ovaOYF3PoGI32IMv7qwrPlg24xRV ez6uAo6Sfo/Cf9E+su6SbHwO6z+vvFZ1sBPT20VhpcSMBudGhRDyHn+eW56uLy4QK3vo 5+C7Wa2UmJWACoetPrBVQ9sN7ze0Oqd7ORknQAByRSdHioSsG6/KorJpsJwvmq/nym3J ssT4y/vAz+9KB4sc0oTcImwdtIQeTMfg+A3VAYEly1LQMBYxfRwjEh+Xx+DQ5tvdFmdM a18g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1tVad2UoWC41F9roF1C4ewEYGfOEOaDIS2stJ+8HrJI=; b=Rs4S9SZ4QEojHkTosD4B1NpXh/i3JY9RD9FmNbvAy9/gxYKtS+ZGKyhdky8dyRnJUB AfNjOiXN3lUoxc57KkLzHcfZLMNtpznBhDlENpt0tOVcco6rHfv05djYN7Ufdk1nkSd8 U88xZCrl56aT7JcMen9uMQgbTlCe64J5drrMHBoRvtKy1ozvs57+ci+dbsNFoN378lW7 bNd38kMfCqpmlZpsRij3F8aZsCFKuu9CpR8CDUdhkYQUg7zD4rPcopsIeG9UVGx+J/zH VHTGna9F29o3idWrJg/bFrBkt5kSP1blumujlArBvsAjPZ57zZXGJpTydXFGqms2F2zG yMnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uvGfXknM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h123-20020a636c81000000b0041c86b0597dsi15307869pgc.594.2022.08.23.04.22.28; Tue, 23 Aug 2022 04:22:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uvGfXknM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349048AbiHWJR3 (ORCPT + 99 others); Tue, 23 Aug 2022 05:17:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349194AbiHWJOx (ORCPT ); Tue, 23 Aug 2022 05:14:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2AC88708F; Tue, 23 Aug 2022 01:32:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2428D6123D; Tue, 23 Aug 2022 08:32:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C612C433C1; Tue, 23 Aug 2022 08:31:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243520; bh=a4/LmbqCcfw4a/dBf+i02Qljn4gGGMGLZNQ7He7NoVg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uvGfXknMSeNPKQqNPdUGSU+uLd/UHLQOTK6oYdilTZpepxCSb49b4D5gdiL3ogct/ soKtnzli9+Jt+dtZyKo1p0mzFMI/SWgIKXTL++wMnV0t+27mYvObsRw/oz2tiHZO72 tXBdC/sc5StGDGPWf0fzIAHK/rIa88bmicShJ6r4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stanley Chu , Po-Wen Kao , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.19 273/365] scsi: ufs: ufs-mediatek: Fix the timing of configuring device regulators Date: Tue, 23 Aug 2022 10:02:54 +0200 Message-Id: <20220823080129.592036136@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Po-Wen Kao [ Upstream commit 3fd23b8dfb54d9b74eba6dfdd3225db3ac116785 ] Currently the LPM configurations of device regulators may not work since VCC is not disabled yet while ufs_mtk_vreg_set_lpm() is executed. Fix this by changing the timing of invoking ufs_mtk_vreg_set_lpm(). Link: https://lore.kernel.org/r/20220616053725.5681-5-stanley.chu@mediatek.com Reviewed-by: Stanley Chu Signed-off-by: Po-Wen Kao Signed-off-by: Stanley Chu Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/ufs/host/ufs-mediatek.c | 58 ++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c index beabc3ccd30b..8b9daa281cc4 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -1026,7 +1026,6 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op, * ufshcd_suspend() re-enabling regulators while vreg is still * in low-power mode. */ - ufs_mtk_vreg_set_lpm(hba, true); err = ufs_mtk_mphy_power_on(hba, false); if (err) goto fail; @@ -1050,12 +1049,13 @@ static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) { int err; + if (hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL) + ufs_mtk_vreg_set_lpm(hba, false); + err = ufs_mtk_mphy_power_on(hba, true); if (err) goto fail; - ufs_mtk_vreg_set_lpm(hba, false); - if (ufshcd_is_link_hibern8(hba)) { err = ufs_mtk_link_set_hpm(hba); if (err) @@ -1220,9 +1220,57 @@ static int ufs_mtk_remove(struct platform_device *pdev) return 0; } +int ufs_mtk_system_suspend(struct device *dev) +{ + struct ufs_hba *hba = dev_get_drvdata(dev); + int ret; + + ret = ufshcd_system_suspend(dev); + if (ret) + return ret; + + ufs_mtk_vreg_set_lpm(hba, true); + + return 0; +} + +int ufs_mtk_system_resume(struct device *dev) +{ + struct ufs_hba *hba = dev_get_drvdata(dev); + + ufs_mtk_vreg_set_lpm(hba, false); + + return ufshcd_system_resume(dev); +} + +int ufs_mtk_runtime_suspend(struct device *dev) +{ + struct ufs_hba *hba = dev_get_drvdata(dev); + int ret = 0; + + ret = ufshcd_runtime_suspend(dev); + if (ret) + return ret; + + ufs_mtk_vreg_set_lpm(hba, true); + + return 0; +} + +int ufs_mtk_runtime_resume(struct device *dev) +{ + struct ufs_hba *hba = dev_get_drvdata(dev); + + ufs_mtk_vreg_set_lpm(hba, false); + + return ufshcd_runtime_resume(dev); +} + static const struct dev_pm_ops ufs_mtk_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(ufshcd_system_suspend, ufshcd_system_resume) - SET_RUNTIME_PM_OPS(ufshcd_runtime_suspend, ufshcd_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(ufs_mtk_system_suspend, + ufs_mtk_system_resume) + SET_RUNTIME_PM_OPS(ufs_mtk_runtime_suspend, + ufs_mtk_runtime_resume, NULL) .prepare = ufshcd_suspend_prepare, .complete = ufshcd_resume_complete, }; -- 2.35.1