Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2402591lqp; Sun, 24 Mar 2024 18:02:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXbU8LCktVPSyG34hUf048uy2woJp0aA6Jq7HedfoUqlgGWQqDLe4g9bB0iooPVzguOVupdilCR/ioHGAohMagF3gZ/LSPH1nKBo96RDg== X-Google-Smtp-Source: AGHT+IG0MTe/4ub9H+k6chkyQT3hOv6OTY4h7/6AvcAICOYd7DVUnrsYTPpjcqGXRhBTNjoM6tbI X-Received: by 2002:a92:c0d1:0:b0:365:70c5:7e66 with SMTP id t17-20020a92c0d1000000b0036570c57e66mr5594748ilf.8.1711328526520; Sun, 24 Mar 2024 18:02:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711328526; cv=pass; d=google.com; s=arc-20160816; b=qiDZ3wMlgNxBd/yn1TLGuUoWSwYuUEj0+U7a1Imrhevs56Z8b906kgWvpIGBfu+uQp VCdqyigogKvzSKquLeqY8gqkhBG/7n9uxLmrAPA3fomqyHOzK3FAhduSy6+XqEPmGtDC APwPckqMSKWnIvtP6jsiw1ubpOkzJcqSpTfsOkER7sDh21ed8xWsKHKmIAA/ZOdsOfWP n6jFeJSYySfLgHT0wkrs4q6UpHHldCfkVSQgQKDaeGaqAolJ7mvz96rlmyC5M0ieYH4X NJuBwPk8pu6Ab7seEgUXB96GLgcrFUHpiuiPx4a/ofR4LyFSbVMBPXrOdnL/6GbhmnnI cYEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=tsW1dbDSAm1+SG6mjVbZVO9wvltw9pZMIYSE6BxHCW0=; fh=cMIQOS53PpLZxxK5uQ9Ppt37wZGdL1m7p2QRZIy49b0=; b=H05Ycay+16oKkcarmHPWGnET7HP5pUjPBsOANE6KndZN4TzoXsewIdalvaHNZYzNzH WRN0Cxlwdf/C9G8BgVvM3hwkNzdVBFXeCvv3+vb1d4LG2e1aOI2kOW0gvdaif1nL2tDx +kHrbN9zk3UrdZ/jSqVqaq4Rt4doUOGpMHWT/R5ejRnLtzP7f5PURJ5DyjQ8UBiwLbDp kub0mh8r9wZwkK6pIhvsZVblcnrnKP3RdOx9mUoNGhf6DSx04ii1nBslL3pkQY1izv8G /Nz0vcBKy6EUdpFI9FvhC1k0j07ZokZp6f7cLw+n0e+nCZta1j3XrMkhc1EIK9qJj5LL K41A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="X+0FmSk/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113543-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113543-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i33-20020a631321000000b005dcb4f1acc6si6661958pgl.176.2024.03.24.18.02.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 18:02:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113543-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="X+0FmSk/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113543-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113543-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3052D284345 for ; Mon, 25 Mar 2024 01:00:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 234241C2329; Sun, 24 Mar 2024 22:45:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="X+0FmSk/" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3293E1C230D; Sun, 24 Mar 2024 22:45:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320345; cv=none; b=S7DsZZ7LFX5K0kr96cOfRx+L5g5yj4nOsg+EkeHjhmPZaz6lFrN9A+FgfgywvgBpFeJDGDiseLPYbu/qwokRfqSF5U+3D/1MIKs1YcbMYLTOjTYK6pGvOvEQ0rS27a5KE5NhnWb1xNKNCX5MkgrkrtFPhPwwJf538Zj8tU+JWiA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320345; c=relaxed/simple; bh=5owybSETCYpp/UVbihl69EMPTb3L1SV374MwjH88fko=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pdokLhIPiuYpBGLMcBeV3d1BlSyDmIpUq+YR6WRiqJE81XtmcwuxxeV80lf0eryEbrGq3/yzcW8RXPWI0dzUROAvQ1IifPQ2D4Q8Ed21686b9BAyFMLtEIQ/Ye1RNvBhzuRvuVBsrVgLluyZAQ3Tif0MF4sifBW5UlPSiZ/jRU8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X+0FmSk/; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13E56C433F1; Sun, 24 Mar 2024 22:45:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320345; bh=5owybSETCYpp/UVbihl69EMPTb3L1SV374MwjH88fko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X+0FmSk/WxMrNY89fwtJ94E1v8m/mqROOLlttugudbRMzkXRAWpAtLYNPDL+9eQji WxKjH7Q2MrjCblJYym3wAtp4vp/5iOU0yXuGgCXfDCGu/y3UMM+66D7eWD+MVH0qL4 3yVTY4uVdtGueR2v+V/UO7/vJWFklfYUYphBg3CRReawyy0U83Q2g7Ebrxn8Xz6McS rkR3O1ob2kDfYNM0tJ28cgHwp+Bn5iS0frpLK5GWlq6ikVn3yF5EqKZzob5a7ehXLS Vnzmssuw6o3+S8FDUVo4fhA6EtWV6ElQ7bfMSw+2/geUDnAn3XiIENsKdp8eHL3VQC A35H7MxsOc9cQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sibi Sankar , Dietmar Eggemann , Viresh Kumar , Dhruva Gole , Yipeng Zou , "Rafael J . Wysocki" , Sasha Levin Subject: [PATCH 6.8 652/715] cpufreq: Fix per-policy boost behavior on SoCs using cpufreq_boost_set_sw() Date: Sun, 24 Mar 2024 18:33:51 -0400 Message-ID: <20240324223455.1342824-653-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Sibi Sankar [ Upstream commit f37a4d6b4a2c77414e8b9d25dd5ee31537ce9b00 ] In the existing code, per-policy flags don't have any impact i.e. if cpufreq_driver boost is enabled and boost is disabled for one or more of the policies, the cpufreq driver will behave as if boost is enabled. Fix this by incorporating per-policy boost flag in the policy->max computation used in cpufreq_frequency_table_cpuinfo and setting the default per-policy boost to mirror the cpufreq_driver boost flag. Fixes: 218a06a79d9a ("cpufreq: Support per-policy performance boost") Reported-by: Dietmar Eggemann Reviewed-by: Viresh Kumar Reviewed-by: Dhruva Gole Signed-off-by: Sibi Sankar Tested-by:Yipeng Zou Reviewed-by: Yipeng Zou Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/cpufreq/cpufreq.c | 18 ++++++++++++------ drivers/cpufreq/freq_table.c | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 44db4f59c4cc6..7d570b44777ac 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -644,14 +644,16 @@ static ssize_t store_local_boost(struct cpufreq_policy *policy, if (policy->boost_enabled == enable) return count; + policy->boost_enabled = enable; + cpus_read_lock(); ret = cpufreq_driver->set_boost(policy, enable); cpus_read_unlock(); - if (ret) + if (ret) { + policy->boost_enabled = !policy->boost_enabled; return ret; - - policy->boost_enabled = enable; + } return count; } @@ -1419,6 +1421,9 @@ static int cpufreq_online(unsigned int cpu) goto out_free_policy; } + /* Let the per-policy boost flag mirror the cpufreq_driver boost during init */ + policy->boost_enabled = cpufreq_boost_enabled() && policy_has_boost_freq(policy); + /* * The initialization has succeeded and the policy is online. * If there is a problem with its frequency table, take it @@ -2755,11 +2760,12 @@ int cpufreq_boost_trigger_state(int state) cpus_read_lock(); for_each_active_policy(policy) { + policy->boost_enabled = state; ret = cpufreq_driver->set_boost(policy, state); - if (ret) + if (ret) { + policy->boost_enabled = !policy->boost_enabled; goto err_reset_state; - - policy->boost_enabled = state; + } } cpus_read_unlock(); diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index c4d4643b6ca65..c17dc51a5a022 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c @@ -40,7 +40,7 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, cpufreq_for_each_valid_entry(pos, table) { freq = pos->frequency; - if (!cpufreq_boost_enabled() + if ((!cpufreq_boost_enabled() || !policy->boost_enabled) && (pos->flags & CPUFREQ_BOOST_FREQ)) continue; -- 2.43.0