Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1156329iog; Wed, 15 Jun 2022 23:28:56 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u7xI9xRpPu8AhlUPwk1aZZ4uSBOAcbHCU1WyZCllXNoz9NTwElvk6zIe/jhCPmtjf8MzBn X-Received: by 2002:a65:6459:0:b0:3fc:700a:ce88 with SMTP id s25-20020a656459000000b003fc700ace88mr3158180pgv.143.1655360936160; Wed, 15 Jun 2022 23:28:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655360936; cv=none; d=google.com; s=arc-20160816; b=rV0g5cH6egKvkwyVmvmTlPsjRJs31wFlde89FnDaQlDWJLw3Z1G50oYXiIgwNOskkT HkFyLznsOZXDovalYI9ttS/nJ1Hw2vK3TLMDsK5LUKB/cPxZPM3p4HAmPKGbR68WDb4a ZhM5PCrDAvGmpbzqbect6dMcd7q5buQEO6opprVhmxQZiAo1ZBf2x1AWPwFq1EUPedKP LVUkiYQ50Dsg7ncYCjRIAGFfnL7mMsyD9jW+ldVoiR8Qbt6O3S5paS8+afWc0crI1lWn LtT1lIFMiyTP/wPcdfTalBqlX/QLGcSOlAF016Rgp7F0PQxteeHTi2NQLj0yesH+y17I 8oeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Euo7j+7qn9k51jTeZ/43pgwauaIThdOIuUd3a/rFH4M=; b=ORJOh18Qzm+cNBXk4mrPHXs04Tg7pW9cT5VdVQXB22RaH2A+vbC1PPi1NJEbKUCf4h yjuhjZcKCMHGqN71KI0+coTuszwOxJXtC8NSak8YRyBE9tSIBkNKDVCDPA7AlWjX5zf5 cxmQnPZQLGfdvZuoNTIRUMurc3y+dlQAl4X/EKizVOyOilHty68R9oFSYeZpqII3wJNS tBIPBHkJL2HYX51aXBLVy6XteBAxgvXPOGa9PASeEEAVITnJ4bP5g95X4Fx17vBvbiVz 7rhlcUYkkn5dE+Jsj43KPJGHVaIIL01fkAKgu4JC0HAXr5HxOn0c6JxzkTQxyngjjxO0 1aNw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g1-20020a635201000000b003fc52ba77desi1430682pgb.408.2022.06.15.23.28.44; Wed, 15 Jun 2022 23:28:56 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358827AbiFPFiD (ORCPT + 99 others); Thu, 16 Jun 2022 01:38:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242913AbiFPFhm (ORCPT ); Thu, 16 Jun 2022 01:37:42 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C37922287; Wed, 15 Jun 2022 22:37:37 -0700 (PDT) X-UUID: c6ef22e2381f41ddaf22038fcac92818-20220616 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.6,REQID:f03ffe46-879d-4c7d-bda3-a2028210b6d5,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:b14ad71,CLOUDID:bf5b6ff6-e099-41ba-a32c-13b8bfe63214,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:nil,BEC:nil,COL:0 X-UUID: c6ef22e2381f41ddaf22038fcac92818-20220616 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2095308324; Thu, 16 Jun 2022 13:37:27 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.15; Thu, 16 Jun 2022 13:37:26 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 16 Jun 2022 13:37:26 +0800 From: Stanley Chu To: , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v5 05/11] scsi: ufs-mediatek: Prevent device regulators setting as LPM incorrectly Date: Thu, 16 Jun 2022 13:37:19 +0800 Message-ID: <20220616053725.5681-6-stanley.chu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220616053725.5681-1-stanley.chu@mediatek.com> References: <20220616053725.5681-1-stanley.chu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no 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 Device regulatrs are allowed to enter low-power mode if neither device is not in active mode, nor VCC does not keep on. Simply fix this by adding conditions before LPM decision. Reviewed-by: Stanley Chu Signed-off-by: Po-Wen Kao Signed-off-by: Stanley Chu --- drivers/ufs/host/ufs-mediatek.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c index 817d957512a3..03762ecaaaf8 100755 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -1034,10 +1034,18 @@ static void ufs_mtk_vreg_set_lpm(struct ufs_hba *hba, bool lpm) if (!hba->vreg_info.vccq2 || !hba->vreg_info.vcc) return; - if (lpm && !hba->vreg_info.vcc->enabled) + /* Bypass LPM when device is still active */ + if (lpm && ufshcd_is_ufs_dev_active(hba)) + return; + + /* Bypass LPM if VCC is enabled */ + if (lpm && hba->vreg_info.vcc->enabled) + return; + + if (lpm) regulator_set_mode(hba->vreg_info.vccq2->reg, REGULATOR_MODE_IDLE); - else if (!lpm) + else regulator_set_mode(hba->vreg_info.vccq2->reg, REGULATOR_MODE_NORMAL); } -- 2.18.0