Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2606290lqp; Mon, 25 Mar 2024 04:20:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUwUyYihECBRRnRivuTzuNIV8fb3v/Az11rLQ3gqlTxlkLGXj/NU8Dw1FxRoOEGQ9f0Erx5J01IspRGt6u8/po76Qtv9YEJM2ZD4Vwxow== X-Google-Smtp-Source: AGHT+IFogLt79z9ccNyzs4GIFdc3WIKRQZtPeYOu5OQtCtX/5K7KjP8/6lVaFSaOUKR7Dsxybpwn X-Received: by 2002:a50:cd9c:0:b0:56b:ebda:a615 with SMTP id p28-20020a50cd9c000000b0056bebdaa615mr4762578edi.6.1711365619878; Mon, 25 Mar 2024 04:20:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711365619; cv=pass; d=google.com; s=arc-20160816; b=0L10lsS2EBFqY16dWyi+IByUK8IzzMvEIVOqSOXNwdxB0ruOWXnyUFnWqgodFLPeCs 4yaZ82WcLTir4pzbKzWTmhwDeCRWbk39825+Loua/M87MZxOuer5qPztj7nqzDbq9XMu sJocTz84zMB5zWRi3JVUBsms9JNb0M9mdNyf8h3PTjpN/TNIVjGZRANEGOOwPreAww7R p5y3X1/dClcbCd26sG0TSOyDIAKs/u6Odzpx+tVvvyoNyLPX9sAKFu8RNXv99wV1M+DZ f18rV0n/tFh42FObkMPPbYOHAjHhHHXz3auL9bwR2ZH5SluvSaYHkVnDuGBnhxZi9VcD 1Ilg== 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=yQl5LxfscCGBch5bPebN1YpcekkDDZG5kOyjM/kruQ0=; fh=cMIQOS53PpLZxxK5uQ9Ppt37wZGdL1m7p2QRZIy49b0=; b=RW8zgrSEwR6r2rEvyQnHe3TxskdNgBntN9sa6zMhfMmmRVLrqh9mvERQnWDqbR/WW8 /IZpMGYS5279d3Qm154+Cb3kdMKuHVP8gqgZEvRQM72vytNAq3T/jRzO3gchJMnScCQY uL9lpi1KUtJtzVBmdyo9Vo93Gc5oU842V7S6N2isZraQgvYv1NOzqlAGGRUaTmuLwioz IBHMm35KqoM1FW0Jvor8TwHOQGQt7BQEdIDh4b1jVinRwcIy6BfrLGofXqa99Be1cKB0 vdpK0pswe5xD8S790UxNpp95IVmHBpTJNJO0YiELl8gv5wXYXrgj8LrVlTONVcZHCtAE AhXQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jm7lNIKf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115564-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115564-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m10-20020a056402510a00b0056bf2f44977si2492071edd.9.2024.03.25.04.20.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 04:20:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115564-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jm7lNIKf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115564-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115564-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9A6E11F31B32 for ; Mon, 25 Mar 2024 11:20:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58D9E2BD556; Mon, 25 Mar 2024 02:43:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jm7lNIKf" 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 DAE8512D1FA; Sun, 24 Mar 2024 22:58:15 +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=1711321095; cv=none; b=XeHH2aGZAMFtzAtBKkPs3iC3zOWnhBHJrfg8p4vc5cyKTY7Lm8VecaPX+WLqVImdOaKWeGY3rYV92vpkcyj8N/NQzLhSrVzFR46+KsuMXtGY00PE0waJtsrhNkkFkUlfvaUsEWUAwkkKEdI7QSZXFpiYwZpHOe2Eh4ySd2Ec/qs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711321095; c=relaxed/simple; bh=p65xs8vC9CJdrFtATSUTKtFfuO2Na/xsx+WT/DECHWM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aAptNlXJE7xmczuzL1gXbhYCm2gAXNJ41c8IpWYGHRYvKj7ufKbaz8vBtDkNX9vkYuS4Uryro9vqXu9dYbO5T4fo3vzdEKW3eBSZZiTWqJLShhQcxTRtUSWH5jGXRfCN732aUU/FUxKWHPJpc3zg5HCdOI82BJL6VLsfcVo5Qe0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jm7lNIKf; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D018C433F1; Sun, 24 Mar 2024 22:58:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711321095; bh=p65xs8vC9CJdrFtATSUTKtFfuO2Na/xsx+WT/DECHWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jm7lNIKf9zakiaVdEtlMgakXJddYJ3/jiEzW3fj/kyg41Ehe3gBfRE7FEoWYIVY8j O4cIjKCBoir6h80cJC3I5v6p+g+Tn319usLQ8yUMLNrrWQCjZ7qQ8XBJd51VadhOL0 h6ty1eENvoPNh6dO+x/7112MkvFs4mEltp0PJA5hethEA6Wp3+l+5Dp+3pJlgygNmT A10JEfGBBfg8wHS8MxOh1vWH1e86V2Fn9HMK2KBZ7HOEiZqKAgvc0ShFeeOv8I27TY pZS6n/mL3aUQ8DUv0uJAzUpgEmUmqtm/+Mpja7mTX3qk+GFkCYwE7LAWdVR61umCye W9CcZIemHAzqg== 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.7 658/713] cpufreq: Fix per-policy boost behavior on SoCs using cpufreq_boost_set_sw() Date: Sun, 24 Mar 2024 18:46:24 -0400 Message-ID: <20240324224720.1345309-659-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324224720.1345309-1-sashal@kernel.org> References: <20240324224720.1345309-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 934d35f570b7a..5104f853a923e 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