Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3354426rwa; Tue, 23 Aug 2022 03:26:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR6wecK1O0lQ4C2r4J/vjVfP4BeaqgMYt4ZsKzgcWtR4+QHDNh1S5pVU8scHLLawcp8Str2L X-Received: by 2002:a17:907:d0b:b0:73d:6bee:1456 with SMTP id gn11-20020a1709070d0b00b0073d6bee1456mr8753020ejc.89.1661250306767; Tue, 23 Aug 2022 03:25:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661250306; cv=none; d=google.com; s=arc-20160816; b=brD+AG7vdgr/EB7DbDJ2Va85UewR4Wmx/sIcxh3MWqFdaTf9wZq8UqaTI2pF0UN1c/ QCdWM0r8ErtVjDTBrPO6jbEeY5/i3uN9e9dhNbbk5THy4VHKIKUgzj0KpUnJbqIClIrH K+vkSbJs9LJtDhg9qrc74HHdSs+V3xETFeD2KYOjYZSfwhlAgiq+uBrNA+bZgSSPjAgk pMLjj5OtTZZMT6NXHZl0KxNr2efmILEa9UeBbAPkgAogTYc5sgcD1b9qA0JwmIeLInct KOR2i9JEwHC9b6vqc1G6owBRE8ygv/ExpykIwaw6NthmOVY2esWaOvFTJZH9oK5dYGEX WnGQ== 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=OGfhEEZj1fG5i+oCLpJfgPrzYa0QKISERU+b1htcWM8=; b=fy8oRm0FlMa83AuqvDd2XMrWFTlNjIh4hlHGN7HrVT40uz+MT+bK0wvtpvaWAufA8e kwwKt2NqLxssx5U/M6chLKTaLBcsvdRGxZB/7K3tOca8j6PCkQPC4jIGPx7W7wkyqimt SGMqLPG6qdDZpyeH+F6WFrWS7OL6joLNIgB3wBJZEQB96DXMXiRs/uJB6sohPA4tunES AJI1JSKhnhRHSA7RFNn2NFnU71DJP8vxBqyBsxse8AM0SdO5dqGHRbP46RFjPBTl95Zy vC36GcPrFpMaAcmxoIsdRyb9E+uWPeuxmLF3ddFpcNK1IwPj+zuLFL7gaWShPlJYDWOa mkIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="PHgwiq/q"; 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 js3-20020a17090797c300b0073046c15d8csi12732374ejc.610.2022.08.23.03.24.40; Tue, 23 Aug 2022 03:25:06 -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="PHgwiq/q"; 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 S1354310AbiHWKVN (ORCPT + 99 others); Tue, 23 Aug 2022 06:21:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352911AbiHWKJd (ORCPT ); Tue, 23 Aug 2022 06:09:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0BE270E7C; Tue, 23 Aug 2022 01:55:28 -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 4DDC061561; Tue, 23 Aug 2022 08:55:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D0B6C433D6; Tue, 23 Aug 2022 08:55:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244927; bh=ItqQFXDDWb3IjtNXUtXeNW31x5hR5NXcdcX8U4BxumU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PHgwiq/qW2taCTcvf94myMNk/RRMSzqNdaZ2d9bN+CggEchecQPpYA9/byL1ULmxG L+5dxxuuVGvjNNpWv1LG27pZqmIf+E4Cw6icSUqsCUE+om1Q2nUlTEU89iTn7WENaE gBnPEmHq6/pwrhJ4/9U0KKwOqqP1fXxMkDJzcZyY= 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.15 173/244] scsi: ufs: ufs-mediatek: Fix the timing of configuring device regulators Date: Tue, 23 Aug 2022 10:25:32 +0200 Message-Id: <20220823080105.047904117@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@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/scsi/ufs/ufs-mediatek.c | 58 ++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c index 4e53857605de..9f1d69d33149 100644 --- a/drivers/scsi/ufs/ufs-mediatek.c +++ b/drivers/scsi/ufs/ufs-mediatek.c @@ -949,7 +949,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; @@ -973,12 +972,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) @@ -1139,9 +1139,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