Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp618929pxh; Tue, 9 Nov 2021 16:16:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyAS7o5Pj2i8WVgCl6Kqa/H1yJsNJUSqa60z+nVOjCHxOhE1yDcri1s6+zUAfloVKNQN8iz X-Received: by 2002:a5d:9442:: with SMTP id x2mr8063222ior.108.1636503414761; Tue, 09 Nov 2021 16:16:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636503414; cv=none; d=google.com; s=arc-20160816; b=ATCI+fWDDfD82TJM/AUHkoRqvGaprRa/oxael0Jo0pyFPyXHHeSdr4t0Z22P7ZKdtl 0MBOEKlt3QRlTvc90lmOJwfdEGNB/mtWFNXNzOaG+BHSE0Ji/9iFPxQjTEORx5eCetcy DC7wCa1kbmXa+f73+16cU2ewrFlddkZmQIhlDISJ9CMKum6dAVJX47Qr5i1H6IQyUeDE /Us18IeCcDbo3MzDamC4/X7dY2wzRVzii8tgNbyqtT7zMhfSA9comFK8+ofNmwd8pGcI lCCL+AJVzfnsXx1SsY9ReIXOptDO9pbX6Lky/BKPyCj9IQe1nosZoMpG6E2q9asch6rN cjLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=zD8n5Mm87ltHKWpK9uNYN5IBiKelhzoM6qNICXLfs1w=; b=go/eTpp0IzncZjFJuAniajHe7PrmEwx3KNRMAVWFbo7XyTozUAiLjctE1hI+Q2E4/b nqSgnpgColslu7xjNhr96Do4pXUMjZHlxsxVP7Rem6ux+Zg4yBRsuyL7loAs0oNmmiwc /U6dqeUEQ1a3KkHOkHqP2JiF+ud0UQaPnHwMqD05f3PKAYXFaHIzW18sRBZjdojylbnk eGTycAIVOddWlqQRGiPwjtTSbEIbGF8puZCmAJS8EwBAEpsjScEjUU+OB4yHziKPfXjF YnKg927+Z7nv0+nhxRpliQpYRFnuX+35E2jntzHWcvTgPKBiqC4gBnyeEVMgtJr59ZO/ ntsA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n8si39384325jat.113.2021.11.09.16.16.42; Tue, 09 Nov 2021 16:16:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244055AbhKIUAl (ORCPT + 97 others); Tue, 9 Nov 2021 15:00:41 -0500 Received: from foss.arm.com ([217.140.110.172]:37980 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244023AbhKIUAi (ORCPT ); Tue, 9 Nov 2021 15:00:38 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6C08C2B; Tue, 9 Nov 2021 11:57:52 -0800 (PST) Received: from e123648.arm.com (unknown [10.57.26.224]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 25D4E3F7F5; Tue, 9 Nov 2021 11:57:47 -0800 (PST) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, steev@kali.org, lukasz.luba@arm.com, sudeep.holla@arm.com, will@kernel.org, catalin.marinas@arm.com, linux@armlinux.org.uk, gregkh@linuxfoundation.org, rafael@kernel.org, viresh.kumar@linaro.org, amitk@kernel.org, daniel.lezcano@linaro.org, amit.kachhap@gmail.com, thara.gopinath@linaro.org, bjorn.andersson@linaro.org, agross@kernel.org Subject: [PATCH v4 4/5] cpufreq: qcom-cpufreq-hw: Use new thermal pressure update function Date: Tue, 9 Nov 2021 19:57:13 +0000 Message-Id: <20211109195714.7750-5-lukasz.luba@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211109195714.7750-1-lukasz.luba@arm.com> References: <20211109195714.7750-1-lukasz.luba@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thermal pressure provides a new API, which allows to use CPU frequency as an argument. That removes the need of local conversion to capacity. Use this new API and remove old local conversion code. The new arch_update_thermal_pressure() also accepts boost frequencies, which solves issue in the driver code with wrong reduced capacity calculation. The reduced capacity was calculated wrongly due to 'policy->cpuinfo.max_freq' used as a divider. The value present there was actually the boost frequency. Thus, even a normal maximum frequency value which corresponds to max CPU capacity (arch_scale_cpu_capacity(cpu_id)) is not able to remove the capping. The second side effect which is solved is that the reduced frequency wasn't properly translated into the right reduced capacity, e.g. boost frequency = 3000MHz (stored in policy->cpuinfo.max_freq) max normal frequency = 2500MHz (which is 1024 capacity) 2nd highest frequency = 2000MHz (which translates to 819 capacity) Then in a scenario when the 'throttled_freq' max allowed frequency was 2000MHz the driver translated it into 682 capacity: capacity = 1024 * 2000 / 3000 = 682 Then set the pressure value bigger than actually applied by the HW: max_capacity - capacity => 1024 - 682 = 342 (<- thermal pressure) Which was causing higher throttling and misleading task scheduler about available CPU capacity. A proper calculation in such case should be: capacity = 1024 * 2000 / 2500 = 819 1024 - 819 = 205 (<- thermal pressure) This patch relies on the new arch_update_thermal_pressure() handling correctly such use case (with boost frequencies). Signed-off-by: Lukasz Luba --- drivers/cpufreq/qcom-cpufreq-hw.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 0138b2ec406d..248135e5087e 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -275,10 +275,10 @@ static unsigned int qcom_lmh_get_throttle_freq(struct qcom_cpufreq_data *data) static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data) { - unsigned long max_capacity, capacity, freq_hz, throttled_freq; struct cpufreq_policy *policy = data->policy; int cpu = cpumask_first(policy->cpus); struct device *dev = get_cpu_device(cpu); + unsigned long freq_hz, throttled_freq; struct dev_pm_opp *opp; unsigned int freq; @@ -295,17 +295,8 @@ static void qcom_lmh_dcvs_notify(struct qcom_cpufreq_data *data) throttled_freq = freq_hz / HZ_PER_KHZ; - /* Update thermal pressure */ - - max_capacity = arch_scale_cpu_capacity(cpu); - capacity = mult_frac(max_capacity, throttled_freq, policy->cpuinfo.max_freq); - - /* Don't pass boost capacity to scheduler */ - if (capacity > max_capacity) - capacity = max_capacity; - - arch_set_thermal_pressure(policy->related_cpus, - max_capacity - capacity); + /* Update thermal pressure (the boost frequencies are accepted) */ + arch_update_thermal_pressure(policy->related_cpus, throttled_freq); /* * In the unlikely case policy is unregistered do not enable -- 2.17.1