Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3278515rwd; Mon, 22 May 2023 11:08:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6UnxwrHBnk1NzvOU6Og+/g+9dJLOz/13L+eo8UnPKsLdPWqR2KLKXU6QtvgKO6u/XIIbdZ X-Received: by 2002:a05:6a20:549d:b0:10b:bf0e:3bda with SMTP id i29-20020a056a20549d00b0010bbf0e3bdamr3666510pzk.2.1684778917836; Mon, 22 May 2023 11:08:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684778917; cv=none; d=google.com; s=arc-20160816; b=aNMGByJ1EpAwoihuhnM0XQ3DJF1fH9V991WAdjJWJLW9r9UnnDNTWFRmmBmkzWS8gW 9yOKvjk1AuR8A6m3UQbQ9aeQEcXPP1IujStHyCmAuzn+1WJN5ya0pR11TGF9icOe/Nd9 VwBX2LIE+il7u99AGDEDTZ+gD6Kb3G5CRQA7sasnsOArkUiNRahKmzj5q02jBwUIr+lM UYbLzvA8k9yvhegfNJpwnVMYwjxm3I0dGNL7K3+eDnCkkMl9pq2MAz+NNcRSYjZMOYjT 5VTArqnSaydwm2yX1cOddwo/8aMGXn7aqbx4nAPbWh1JDH5wynu55cnRbgBTvMt4pZ/9 mRZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=lywUkrrpPvwsCTrXQ5X4uWZOLZyH8yEs2rcz6K44gI4=; b=URn/jAmDHPhYqreFyNX9JCmAuz9dUx8cbX1cDoFecH61EOKAWwWRcKFdnsViviVdV1 kh95bKM/pG02m21+MQyOQwu0MWHrs6ihfYJZJXrjqo/4amqaIihOYeLyRXt7C84PYOi/ uykru2W/1RloK2jlfq6WBgQ0d1XjYGnkynlOgBpPABqF66cym7c4SsectnTsylf5HnbN G9ImmAfZYOrzkYpvhn7cg1dD2PFv7padWUAub019ddOLLV1AG+4zoybGJh8rzKX2YYyn IEhJmEHK3vsOmVGFkFXI/2Z6NH2086j9+ij6x4wEDZFT6iTsvr+o81wazp22i+/f9fNn pOXA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i4-20020a17090a974400b002472a818166si2724702pjw.96.2023.05.22.11.08.20; Mon, 22 May 2023 11:08:37 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231495AbjEVSDl (ORCPT + 99 others); Mon, 22 May 2023 14:03:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231635AbjEVSDf (ORCPT ); Mon, 22 May 2023 14:03:35 -0400 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1790D11A for ; Mon, 22 May 2023 11:03:22 -0700 (PDT) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1q19sC-00046b-1s; Mon, 22 May 2023 18:03:08 +0000 Date: Mon, 22 May 2023 19:03:00 +0100 From: Daniel Golle To: "jia-wei.chang" Cc: "Rafael J . Wysocki" , Viresh Kumar , Matthias Brugger , AngeloGioacchino Del Regno , Kevin Hilman , Rex-BC Chen , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Project_Global_Chrome_Upstream_Group@mediatek.com, hsinyi@google.com, Nick Hainke , Dan Carpenter Subject: Re: [PATCH v2 4/4] cpufreq: mediatek: Raise proc and sram max voltage for MT7622/7623 Message-ID: References: <20230324101130.14053-1-jia-wei.chang@mediatek.com> <20230324101130.14053-5-jia-wei.chang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230324101130.14053-5-jia-wei.chang@mediatek.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 Hi Jia-Wei, Hi AngeloGioacchino, On Fri, Mar 24, 2023 at 06:11:30PM +0800, jia-wei.chang wrote: > From: AngeloGioacchino Del Regno > > During the addition of SRAM voltage tracking for CCI scaling, this > driver got some voltage limits set for the vtrack algorithm: these > were moved to platform data first, then enforced in a later commit > 6a17b3876bc8 ("cpufreq: mediatek: Refine mtk_cpufreq_voltage_tracking()") > using these as max values for the regulator_set_voltage() calls. > > In this case, the vsram/vproc constraints for MT7622 and MT7623 > were supposed to be the same as MT2701 (and a number of other SoCs), > but that turned out to be a mistake because the aforementioned two > SoCs' maximum voltage for both VPROC and VPROC_SRAM is 1.36V. > > Fix that by adding new platform data for MT7622/7623 declaring the > right {proc,sram}_max_volt parameter. > > Fixes: ead858bd128d ("cpufreq: mediatek: Move voltage limits to platform data") > Fixes: 6a17b3876bc8 ("cpufreq: mediatek: Refine mtk_cpufreq_voltage_tracking()") > Signed-off-by: AngeloGioacchino Del Regno > Signed-off-by: Jia-Wei Chang > --- > drivers/cpufreq/mediatek-cpufreq.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/drivers/cpufreq/mediatek-cpufreq.c b/drivers/cpufreq/mediatek-cpufreq.c > index 764e4fbdd536..9a39a7ccfae9 100644 > --- a/drivers/cpufreq/mediatek-cpufreq.c > +++ b/drivers/cpufreq/mediatek-cpufreq.c > @@ -693,6 +693,15 @@ static const struct mtk_cpufreq_platform_data mt2701_platform_data = { > .ccifreq_supported = false, > }; > > +static const struct mtk_cpufreq_platform_data mt7622_platform_data = { > + .min_volt_shift = 100000, > + .max_volt_shift = 200000, > + .proc_max_volt = 1360000, > + .sram_min_volt = 0, > + .sram_max_volt = 1360000, This change breaks cpufreq (with ondemand scheduler) on my BPi R64 board (having MT7622AV SoC with MT6380N PMIC). ... [ 2.540091] cpufreq: __target_index: Failed to change cpu frequency: -22 [ 2.556985] cpu cpu0: cpu0: failed to scale up voltage! ... (repeating a lot, every time the highest operating point is selected by the cpufreq governor) The reason is that the MT6380N doesn't support 1360000uV on the supply outputs used for SRAM and processor. As for some reason cpufreq-mediatek tries to rise the SRAM supply voltage to the maximum for a short moment (probably a side-effect of the voltage tracking algorithm), this fails because the PMIC only supports up to 1350000uV. As the highest operating point is anyway using only 1310000uV the simple fix is setting 1350000uV as the maximum instead for both proc_max_volt and sram_max_volt. A similar situation applies also for BPi R2 (MT7623NI with MT6323L PMIC), here the maximum supported voltage of the PMIC which also only supports up to 1350000uV, and the SoC having its highest operating voltage defined at 1300000uV. If all agree with the simple fix I will post a patch for that. However, to me it feels fishy to begin with that the tracking algorithm tries to rise the voltage above the highest operating point defined in device tree, see here: 6a17b3876bc830 drivers/cpufreq/mediatek-cpufreq.c (Jia-Wei Chang 2022-05-05 19:52:20 +0800 100) new_vsram = clamp(new_vproc + soc_data->min_volt_shift, 6a17b3876bc830 drivers/cpufreq/mediatek-cpufreq.c (Jia-Wei Chang 2022-05-05 19:52:20 +0800 101) soc_data->sram_min_volt, soc_data->sram_max_volt); However, I did not investigate in depth the purpose of this initial rise and can impossibly test my modifications to the tracking algorithm on all supported SoCs. Cheers Daniel > + .ccifreq_supported = false, > +}; > + > static const struct mtk_cpufreq_platform_data mt8183_platform_data = { > .min_volt_shift = 100000, > .max_volt_shift = 200000, > @@ -724,8 +733,8 @@ static const struct mtk_cpufreq_platform_data mt8516_platform_data = { > static const struct of_device_id mtk_cpufreq_machines[] __initconst = { > { .compatible = "mediatek,mt2701", .data = &mt2701_platform_data }, > { .compatible = "mediatek,mt2712", .data = &mt2701_platform_data }, > - { .compatible = "mediatek,mt7622", .data = &mt2701_platform_data }, > - { .compatible = "mediatek,mt7623", .data = &mt2701_platform_data }, > + { .compatible = "mediatek,mt7622", .data = &mt7622_platform_data }, > + { .compatible = "mediatek,mt7623", .data = &mt7622_platform_data }, > { .compatible = "mediatek,mt8167", .data = &mt8516_platform_data }, > { .compatible = "mediatek,mt817x", .data = &mt2701_platform_data }, > { .compatible = "mediatek,mt8173", .data = &mt2701_platform_data }, > -- > 2.18.0 > >