From nobody Wed Apr 1 15:20:43 2026 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93A92213E7A for ; Tue, 22 Apr 2025 09:54:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745315650; cv=none; b=VHzanGWtdQEqWgVtLiB/wwEAMXI8/WyAZFjkMLZL1a1uJUn86N7PELUkTBNvMkdElJ4noE4ft4AKyIklAxOp6/nVzng1Xaw6bC+GIfbVJhNXFe4oLNc0F/i5dd8E4sh7O3GpA3PimJKZTto5ZpnoSJeAlLH+HTybM1HVxtZgcZo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745315650; c=relaxed/simple; bh=L2eTTuTa1eQwii4P70WWj60+AqgdSCjTwbfYuCR+exI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=WpQESr9AJBlf8iV2y/9TqPcchr2JNGexagkzIEHzWKGA9BLv844qUl+g1MIaHQgMp12Wk7OywkEH/a5x9V0yDkkdO9rAmwUh4o6fpaEp5wPGV6XHuGeuNSBsizyfLe2BDnnxFIcj4V4qZyqlfQSjN/6ZWE0QBQHtvcaRzIjl/ec= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=El46f7pB; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="El46f7pB" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-736e52948ebso5562126b3a.1 for ; Tue, 22 Apr 2025 02:54:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745315648; x=1745920448; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6gXRQ3l/ZDI7m3p/8+vMXIVMOdLVmbzl70e5WfDPUXI=; b=El46f7pBW5AY3T/pW8ccCde9pT8HEfOL4tJyCzbKl4MObmTKgcLTI3hWJDEVHyq35p IXBrshZIgp2r7zZN7anakE12qwwBa4l0yGwwYxgLdCj5xfjHjFC4bSyXF9SGexGX+34o zvtHDcnU2rFmfMccd1wW7PWWCFzD511w2Jm/+L6WFGema53B5XdoGTi6vK3al6rfrWLx fxUOOtPxpwN4byRtSq9vC8KnhYJ5lsA3jzKkDO2EOuPk7JLJp6vzRAkRuSS9hXSJZdut gLSDg3NeqkCIpAtxcFtzRADZoqNCWLR0JgMdOwmlyNQea/3zivp6nQI0Q4/RwZuuTmTU HEGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745315648; x=1745920448; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6gXRQ3l/ZDI7m3p/8+vMXIVMOdLVmbzl70e5WfDPUXI=; b=QUy8ht5CAcWE4tgEdEfxG31GUaImqPBMlRBwnpH0yG6fp1MP51vYbJzPzMU3tnXacZ ZMJ7QNHwUD13ejzSWxyV9iHhKnh+v3cISWsKPuJyLOMqJVU6DvfDsX3P9E3sKEB4rkhh SisS1I8Rvk/WE9ZFJWEH5Gwmz0UcKizjGUCemVfaC/59tBMBSMvs3/rlxEW/d8OTMz0I 10ZGc20NK3VnFV9b3Yl+y1K7XbZoNG3L7gSUCFzaqw4/IuFhncwOb9OT6bMXO+wFdOj0 c5orjCvN/EydK9JymBu5XhSEujaRUfFRptujSS49XX1lLIjonmgh8cqvx2mE2mZcpxhE WvEw== X-Forwarded-Encrypted: i=1; AJvYcCWz/XzSGNbGXpPbu2/QZfuhVQ1tCjt4x7NM32LtRfFzr+OAmorRDidLb4gSFrJBr4jrOmLMoSB3tgLcOTw=@vger.kernel.org X-Gm-Message-State: AOJu0YzjNVt0oZRCD9trxxsiuevdrOvzRqwc3A2704YQptdRMpWRhUH+ 6N05/8eUwSZjHNQ9nTCeh0rI6pXZGFaVmrfcf4d7IRdQC2UMoeKgHO27o5AODhpFHKslTZItBJw U X-Gm-Gg: ASbGncsEB50j3vCAJZXuRFrvcsjBWE2C++A2VQWDB5aAl5kRWKopT23BvVRaakD5RDi FR7Mso5I1K6q4dl2g6gna74nrPnZcoiq/Kf+bSho8Ro1XiN6FIcpMqwZC+TQyVwgwobJoqoSGD9 DPklFjYi+i/nWlm1Ofq5/+eaPT52gKLfwqHvP5dXj9BWz87RUbWKbV0lirXkTIYRf7xG1bP0G+Z pSYWxmn2O/IKJ9C+Ag9f3YB8mad2y1vFoEM9LwwPCPwsVSNbNSS0Wx9ifD6HJ2QQWG4fWYujMwP 2vz8xVPbnS2iX6tHvpS66aJ9wJqm9cFTTHv+ILqN6y03BIXUwOVP X-Google-Smtp-Source: AGHT+IE/wvqq9gqVFeBQZ9f+2ocmH5VwKgVfi/GMhqbq95+Km5GimJ+CgXmeQp3d6qdUw6qoPnp7hQ== X-Received: by 2002:a17:90b:544c:b0:2fe:6942:3710 with SMTP id 98e67ed59e1d1-3087bb3978cmr17322956a91.3.1745315647911; Tue, 22 Apr 2025 02:54:07 -0700 (PDT) Received: from localhost ([122.172.83.32]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3087df1e5bbsm8138605a91.24.2025.04.22.02.54.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Apr 2025 02:54:07 -0700 (PDT) From: Viresh Kumar To: "Rafael J. Wysocki" , Viresh Kumar , Lifeng Zheng Cc: linux-pm@vger.kernel.org, Vincent Guittot , Nicholas Chin , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org Subject: [PATCH 1/6] cpufreq: acpi: Don't enable boost on policy exit Date: Tue, 22 Apr 2025 15:23:51 +0530 Message-Id: <7ce4ffb166beef83cf1bd703a41bf91622011585.1745315548.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The boost-related code in cpufreq has undergone several changes over the years, but this particular piece remained unchanged and is now outdated. The cpufreq core currently manages boost settings during initialization, and only when necessary. As such, there's no longer a need to enable boost explicitly when entering system suspend. Previously, this wasn=E2=80=99t causing issues because boost settings were force-updated during policy initialization. However, commit 2b16c631832d ("cpufreq: ACPI: Remove set_boost in acpi_cpufreq_cpu_init()") changed that behavior=E2=80=94correctly=E2=80=94by avoiding unnecessary updates. As a result of this change, if boost was disabled prior to suspend, it remains disabled on resume as expected. But due to the current code forcibly enabling boost at suspend time, the system ends up with boost frequencies enabled after resume, even if the global boost flag was disabled. This contradicts the intended behavior. Don't enable boost on policy exit. Fixes: 2b16c631832d ("cpufreq: ACPI: Remove set_boost in acpi_cpufreq_cpu_i= nit()") Reported-by: Nicholas Chin Closes: https://bugzilla.kernel.org/show_bug.cgi?id=3D220013 Signed-off-by: Viresh Kumar Reviewed-by: Lifeng Zheng Tested-by: Nicholas Chin --- This was sent separately earlier. No changes from that. drivers/cpufreq/acpi-cpufreq.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index 924314cdeebc..7002e8de8098 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c @@ -89,8 +89,9 @@ static bool boost_state(unsigned int cpu) return false; } =20 -static int boost_set_msr(bool enable) +static void boost_set_msr_each(void *p_en) { + bool enable =3D (bool)p_en; u32 msr_addr; u64 msr_mask, val; =20 @@ -107,7 +108,7 @@ static int boost_set_msr(bool enable) msr_mask =3D MSR_K7_HWCR_CPB_DIS; break; default: - return -EINVAL; + return; } =20 rdmsrl(msr_addr, val); @@ -118,14 +119,6 @@ static int boost_set_msr(bool enable) val |=3D msr_mask; =20 wrmsrl(msr_addr, val); - return 0; -} - -static void boost_set_msr_each(void *p_en) -{ - bool enable =3D (bool) p_en; - - boost_set_msr(enable); } =20 static int set_boost(struct cpufreq_policy *policy, int val) @@ -532,15 +525,6 @@ static void free_acpi_perf_data(void) free_percpu(acpi_perf_data); } =20 -static int cpufreq_boost_down_prep(unsigned int cpu) -{ - /* - * Clear the boost-disable bit on the CPU_DOWN path so that - * this cpu cannot block the remaining ones from boosting. - */ - return boost_set_msr(1); -} - /* * acpi_cpufreq_early_init - initialize ACPI P-States library * @@ -931,7 +915,6 @@ static void acpi_cpufreq_cpu_exit(struct cpufreq_policy= *policy) =20 pr_debug("%s\n", __func__); =20 - cpufreq_boost_down_prep(policy->cpu); policy->fast_switch_possible =3D false; policy->driver_data =3D NULL; acpi_processor_unregister_performance(data->acpi_perf_cpu); --=20 2.31.1.272.g89b43f80a514 From nobody Wed Apr 1 15:20:43 2026 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1BAE2144DF for ; Tue, 22 Apr 2025 09:54:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745315653; cv=none; b=hL1axLVpsx8holklN7CK6LmoVK+S/8kHd7cG/oMVArSZkdHDogUhdKPUQgCtDFwNzSV1qvqSvva9rtikUbVq7743Qme1FbG/xt82sS/Cq/GwAgIqdbdw/lo1SqXjF7VDjeUInyQFRcvg8OHH1dJKB10iZUX9uAyZjz0Y8GnWffA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745315653; c=relaxed/simple; bh=eyplrmpjKFTUa1W5e9N6rta3lu/Fv+NYAacdGEUT+Oo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Iw/LuOY81fFUxMbiD2moWMwemIPtm4XstNwyyXovHIdEINpZUBniBU/0YlG28j0AYJOsBN9FJe7qYHK6doqXhpMBhCTRxwVL6UljS0ngMBPRFgwckmFpWMnyIWILJuwX2URt5mvHbi3N7SbDMPLNJrTqoWPuaHuSpUpc0GMnVkA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=OR7w5rkM; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OR7w5rkM" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2254e0b4b79so73527465ad.2 for ; Tue, 22 Apr 2025 02:54:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745315651; x=1745920451; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8abPOzFQPY6uZ841DkjOq7rR24N5GWsR8imwcJtx7Uk=; b=OR7w5rkM6Abf8NVSwca/9JCEU18uf3LmpX7M5NXLhCnFolnFWA8uy4ydQf+nFV8b7v Sz8ckJU1Rhf1dDiCRTI5AmaicaUBERNEJfbcxIf7/UOhCkEV2Z7FCnUA6LEojK9rEn3A izyXn/jeTx7Q9JiqyM/9N87C9hp4j05hyyz6j/0bclOdvWy280+dXypOiHltuNd3viq4 ePqm4OQgR2srZSzONmAWtnUV0rWdVEpI1gx3KjaPcv+ELvL0V/sO1DLbWH8NP7zuDfHO mDthE1oly5GYP4vBjnBB6la8GHt66oMjuhm6ldDmmYscfzYwcIAc0rLWDc5ZGALzr0u3 dCig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745315651; x=1745920451; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8abPOzFQPY6uZ841DkjOq7rR24N5GWsR8imwcJtx7Uk=; b=aRpHboZKHSrLpHP2NhYdI02sKKxV/Nah8VbNNQ64LXxWWp3zpoMmF8qHXADaNPbCPm g2hNYS2C2qXGeKfOKVJDW3qRIfERPez9l3ZnyVIi2JFQ0knaEG4CujNqelr1E39tJiju nmNadHhRs7Yz5u4HVlMqNbxzLakiHYv6Fm08zO2XZJzb7VzDLPq9Eu2rsW2WCFrx4v72 6o7+tH/Aq8Sd2cXg/pr91OTMH0MC8+bm9g2/9RZrsD7T+k+D9DVro0x6XudUbkp5sWnj t2e6EmdsBwYjg7g/ysjUwjkQU9WSWBwzFT3oppIBT1H03qTDauKT3laXOr71RyHI7BUc 7I2Q== X-Forwarded-Encrypted: i=1; AJvYcCWfFiac1mXP4xIi5thUfdR9laQyOPtDAddWyEK7ot+q8tWe6UbgAc2rjSOOLf7bRrckvrxdEbx0kHkYbDY=@vger.kernel.org X-Gm-Message-State: AOJu0YwMuQ9cZFbAww7uBOerBUbDNH++kqwAIx2tsdEh2VsRlnbqSJhI C7noZ7VT6D8lJG6cLLNfXW07dt7vfejojCvmMQsAQjj1fbGLzBqdg3fk26w/TWA= X-Gm-Gg: ASbGncuo3NLEcD6LrW124rANjUZrd598gOxoyoqh0/wNh3liH/i9KOvv2bGk1eZU+nc Okjvi1sh512rrWiocRIZWp81vLrVfl6xT/zKy6SK9HcqR8E3bGbJJJ9Lo+ZlHDhrN2q1fPDsa5A plkwv9MhQkWnL0a549qfP5/5GvFrDxxUX+TCwDZrKaY3xEwC7cCRI2vmYclBQlLmb6mi3Vb2aYY LQVQZn2Zh65Id0FJLHQHF4cK3cJO/+nnS+YGnu7FjvzvU+JoXhDEJHh0wPNsslG4+gYKY2Y8eLc /0jajHVeG8OPaqAUmfSyci0+scaRIKvoipCC0BtGRw== X-Google-Smtp-Source: AGHT+IEmg8Z6gimIDf9VigivlpBZ67Mu4d5PLElT55+RwEMc1P1qEQb5nY9a+EPjX0zXw8UepdGUvw== X-Received: by 2002:a17:902:e806:b0:229:1cef:4c83 with SMTP id d9443c01a7336-22c5356797emr251125215ad.4.1745315651107; Tue, 22 Apr 2025 02:54:11 -0700 (PDT) Received: from localhost ([122.172.83.32]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22c50bf5549sm80701565ad.94.2025.04.22.02.54.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Apr 2025 02:54:10 -0700 (PDT) From: Viresh Kumar To: "Rafael J. Wysocki" , Viresh Kumar , Lifeng Zheng Cc: linux-pm@vger.kernel.org, Vincent Guittot , Nicholas Chin , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org Subject: [PATCH 2/6] cpufreq: acpi: Re-sync CPU boost state on system resume Date: Tue, 22 Apr 2025 15:23:52 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable During suspend/resume cycles, platform firmware may alter the CPU boost state. If boost is disabled before suspend, it correctly remains off after resume. However, if firmware re-enables boost during suspend, the system may resume with boost frequencies enabled=E2=80=94even when the boost flag = was originally disabled. This violates expected behavior. Ensure the boost state is re-synchronized with the kernel policy during system resume to maintain consistency. Fixes: 2b16c631832d ("cpufreq: ACPI: Remove set_boost in acpi_cpufreq_cpu_i= nit()") Reported-by: Nicholas Chin Closes: https://bugzilla.kernel.org/show_bug.cgi?id=3D220013 Signed-off-by: Viresh Kumar Reviewed-by: Lifeng Zheng Tested-by: Nicholas Chin --- drivers/cpufreq/acpi-cpufreq.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index 7002e8de8098..0ffabf740ff5 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c @@ -893,8 +893,19 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy= *policy) if (perf->states[0].core_frequency * 1000 !=3D freq_table[0].frequency) pr_warn(FW_WARN "P-state 0 is not max freq\n"); =20 - if (acpi_cpufreq_driver.set_boost) - policy->boost_supported =3D true; + if (acpi_cpufreq_driver.set_boost) { + if (policy->boost_supported) { + /* + * The firmware may have altered boost state while the + * CPU was offline (for example during a suspend-resume + * cycle). + */ + if (policy->boost_enabled !=3D boost_state(cpu)) + set_boost(policy, policy->boost_enabled); + } else { + policy->boost_supported =3D true; + } + } =20 return result; =20 --=20 2.31.1.272.g89b43f80a514 From nobody Wed Apr 1 15:20:44 2026 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFE9C21504E for ; Tue, 22 Apr 2025 09:54:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745315656; cv=none; b=eSKOX+HRj3TZCoPtnf2uo7REBEdLp/KATXuT1frVkCmnwQUkhurYQvQpu4/Qm8La52VKg/Vz8ul1rfm5ALe88QxJtpRw9iz4IG0juAYcjTFmWfrl5XOMYlhXJUg01Jhne5rWHVTzBKn8ie8oSh9zhRNyrqjhVEEsrwsbhSp2Ad0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745315656; c=relaxed/simple; bh=Hwb5Wg8id68V2WnDvFD72dDP1oue3BffEk4N4k7Vew0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=s7pZzlIRZpRpwXZrpzxdII/Me/rF33b5LPIvh07tclqbzF9KZmOmOsAGcVQB9jFwLG4TMbCUdp3iMtEgGPzaOt6nAhqPz9GRO/XmXYbqLrWTm5pf1LuS1i8uewNILJPg3rbxKlQA8DXbwL0Q9wyTddRSefhPMlyNP5TEDEWwRww= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=YGlbdwNG; arc=none smtp.client-ip=209.85.215.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="YGlbdwNG" Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-b0b2d0b2843so3780542a12.2 for ; Tue, 22 Apr 2025 02:54:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745315654; x=1745920454; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=N5Kzn75CoyUpVkgbkAVHgMpizfueeVqLotFm0lBfgI4=; b=YGlbdwNGAPeOUUFTNkdOnb2i8AmfrcPvKDGsegtFj0tKWo1+jyL8iQQuqcqbjJ46Td lW2Q89V+VxQfYOqxMakbQx22n438HMtL34Dkat/9mH9oDuI6A8/qgUn7Sk2B9NMTLFaT Bv1Brw4dOX42c9hXunQhrHxK7FnDFTX1Ikkgo8nzT6pwsjTw6ahQTJTdQDPyDtWrbr+u P4vpQZ/lWoAPKvtHZa6fcZA02u9z0BEA/buvFjT37C+egHqDnLC4gSq8mFw7tGQQA/6S E6GKbicO/13MLlU9E02vJJSjjoGh/OQyqaI3bNqfts0EOYhDbXr0kfOcsgy2L+zs/YR1 pe+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745315654; x=1745920454; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N5Kzn75CoyUpVkgbkAVHgMpizfueeVqLotFm0lBfgI4=; b=MxQmNrBPxmp4NLx7R1wilFs89yneEBLu5Jo7Fvx1wPCSUwNhwXjMRRuTh2xnZjy0W0 az6XdBrIi/4hVYVV8nXdPCdiOX2+lgJG7qT96TZl9+2bmgTJGh51OC7P0cQMoU1wll/d VmYMIMvPxjUZSlRGV0dbHxyzj3+RIlVruYKygYKWy2kICyGsO8KzR+8rI0+YAj2EoUcX AV5qUazCvEzEinHtq+A+kXv89uDrjgjM4NXm+RUYQKONbS/GWw2W8F8A9jjTrrY5noOP qu018OH+9yVSQxAKBtM5mgg7c+kLGSwkBen64l6DHoWPex2F02HbpBicc/I7n0aobYJr 0zTg== X-Forwarded-Encrypted: i=1; AJvYcCULo85cQzbMWxQCcf5DYVn/RytjueapSU8XKWD8OozP1X6tfNmP9Jc5Fa3Z4ivxiXI2e0Vdtr6lxdb9F/c=@vger.kernel.org X-Gm-Message-State: AOJu0Yzhrk2lkFr/8jzgobLJxibD+2DQTDcJf5AtDXYIvC5k8AfJbre2 Q6sPriuQcDdRqcrDpWtkb8Z/b56JOANdSdDchC/hgAFoYeEZR/UBcNx6B1abMusE3hpHSkKHKjc I X-Gm-Gg: ASbGncuGzoUf0LO5tcRFdbHEfQlXLzp7TPAJBLTGaObsaMGuFuyYZjVOnOXSQQN1+AV hTuXVW8Vn+r/zqfkWeUW1nx1YS0xxqXbWrIcytvX5FFfdtIaBqXaEfd0eQPD7LL2yijPpLQowDe hUnTdYQ1op0YP1HqHKgT4ibqhKA25BTGzUCY7oj7dm4rVfdvtEuuvv6ze+nq6xIWpmdryhPr406 8NW2ZJXrpfBqXTWffngjWw4wg8FZlA146qNhZT5X9dNjo6zxp04U1sXP/uELHp9BlDrirbWRJVD Jq/f5a+Nv82KZcQzLJx3OXAFwE3FZNygHWl1Hqy4UA== X-Google-Smtp-Source: AGHT+IErqjm03tFu5yST3yF0F1z9Zzqt2vjP0tGj95/hMaoPb1Uko0h1jfw4cKpAm3i77EYr44591g== X-Received: by 2002:a17:90a:d64f:b0:2fe:d766:ad95 with SMTP id 98e67ed59e1d1-3087bb47646mr23455072a91.9.1745315654223; Tue, 22 Apr 2025 02:54:14 -0700 (PDT) Received: from localhost ([122.172.83.32]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3087e12a154sm8221994a91.48.2025.04.22.02.54.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Apr 2025 02:54:13 -0700 (PDT) From: Viresh Kumar To: "Rafael J. Wysocki" , Viresh Kumar Cc: linux-pm@vger.kernel.org, Vincent Guittot , Lifeng Zheng , Nicholas Chin , linux-kernel@vger.kernel.org Subject: [PATCH 3/6] cpufreq: Don't unnecessarily call set_boost() Date: Tue, 22 Apr 2025 15:23:53 +0530 Message-Id: <1ec6ec55f8413b0387a19a531dff0c3194847f24.1745315548.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The policy specific boost value may already be set correctly in cpufreq_boost_trigger_state(), don't update it again unnecessarily. Signed-off-by: Viresh Kumar Reviewed-by: Lifeng Zheng --- drivers/cpufreq/cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 3841c9da6cac..e31891c7b500 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2861,7 +2861,7 @@ static int cpufreq_boost_trigger_state(int state) =20 cpus_read_lock(); for_each_active_policy(policy) { - if (!policy->boost_supported) + if (!policy->boost_supported || policy->boost_enabled =3D=3D state) continue; =20 policy->boost_enabled =3D state; --=20 2.31.1.272.g89b43f80a514 From nobody Wed Apr 1 15:20:44 2026 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41FBD215F48 for ; Tue, 22 Apr 2025 09:54:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745315659; cv=none; b=OypTZpg8pJobDaFsgam5n4qFDSq/ZBLndt+HRJvEI2teTQBAIwtI81nnDDjM64gtQ9QtcrengEw3vHgUrnwOX3JDhRNQIpnQpRuoEufgCFNI4NX6YJGN5hOqsPLKTBLNrtAURdiJCXo7kMI+FGAwj6RX2PanHPEnLq/rgTAm0Ss= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745315659; c=relaxed/simple; bh=M+/pqwhpw1fPajfCHBDUoRbLW6qnHDooYX4AD6Hjgz8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JPaRuzGgQV4Vl9MMeeajRfZbYrJ/P+nAP+PcPKhX/HFE2oDFGx0QlRJpLT1bmfqHxTQmE5RnLbZbWEbYqDzGSm/JfXNJay0CbQ3BCqAdVo/AJAwpSMKmJKdOqZcw7evCZ0vpWvufEOlPbOJJA7dkPu2fUrOUX6rhcmBBR3f3+24= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=TQWMAAnk; arc=none smtp.client-ip=209.85.216.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="TQWMAAnk" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-30332dfc820so5864697a91.2 for ; Tue, 22 Apr 2025 02:54:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745315657; x=1745920457; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9H3WR3nBCdmpNnYy6QA+g1VB4XUB5xCxQVtKBFhosH0=; b=TQWMAAnk9ioHSH7CR85RwGzdglqimDxBC8mNm5IvkxwehRVMRn8x2n5oWU0VqWI5VG SexioYq/lwV+yRU/1+PEwf1VKkRTqH+e6KdocF0ZnmvTV4tx1tK8f6VyaS29v4kz7qz0 qkEtfzzzS1R2L+ZfHejzK8rXiaDd3znU/W3794aUYng1+UzxPTJEp92zp3xzQSneOccw edvjt0ygn7x1j1EOk6+3xWDvuL5k4pfQM2pRTukFQX73f+kWjLsa7uATtrzkQmYxMJuZ /UbYC8mswVA35W6apV8v6H1+X8aokqkT8Qj7At2fpSft/JcI+I3GJMT0tMSHSoZZzQuj epVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745315657; x=1745920457; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9H3WR3nBCdmpNnYy6QA+g1VB4XUB5xCxQVtKBFhosH0=; b=uO04Ja9GD+GLIP88ld/yaap2EPV1ly8CiCGK6p3ga65CVEO/AdR3E1H09b6dgEsakZ ezdn8qrj04VO3MC3BoMwHjg+My7Vw70O176OhlagN4wnZTSkKxVSxf/h5nvSeB8X643r 48LPogr775/vORSS5Y6b9ON2xJpYRgs2NxVjSLrTMnSg5byki9YohFJI3nwdHUoM3uGn /no5xdEmA3axeVbA+Fy43ME55UL0lrU5AVTju0eUgAdSKTqXiYQCMTUdjZKE9zoSAu8H f74D14RwN+Ar2yVu02l9dGFqOpiOTP4plC9AkE5tn8b5qZLlo1C2I7RqZFS5BQ/gyARe lIKQ== X-Forwarded-Encrypted: i=1; AJvYcCV2/sBJqfTSgL6HEcQ5nmu6cSvJU25rosjj1xfpD0f6+1pUblPB2BbLkl+zkCb9ejPD9dMaX+oSMteXvFY=@vger.kernel.org X-Gm-Message-State: AOJu0YzkBA/6Vd4KJiRyYJ/2UmYMg8LptJ4AqA2fvVhD4EGf881lbP+B RG+wYQmmxaYKXmAgNMmXKTvz67n34SBn+eEjWFhD8XPs2fZUX4qGnHWjjsWGyPJgtJ+olrhOyll j X-Gm-Gg: ASbGncu4C4b6appo33p/P/76uQRL5y0kQh7gyjQ9UA8/eh5BXwNEsm7y0lGgsMLMYZh Yf4JoJgQqwH2nKIWlfpSAaMNZJjYOVOmGffk8KHyn/o7FsoMGanu8pXNFLt+TYy38e31k/MxuL+ 8CT3wbVxxZsE2QfA63XdoXdGwEJRZ3a81GCZzXanzZnQW88BoXVp/Ss6W8pt6Weu7MHL16enZZx F76HL3Gooy5byvSeLPksL4jDf2PouTRGkadC8ChgTsXauPe+WiAr7FF2oGVHat+pg5iIe6Wg0T+ DnTkL0L9HO/D1PB2A/Lld8Udr6R6teM0A+TIrk7CHw== X-Google-Smtp-Source: AGHT+IFBp8nq5mfF9I1/dtj2dn0MaVxqa8vr08jLr5osEFoCWxugzRmsBLS0J5zZhMe46HaAwG6I1Q== X-Received: by 2002:a17:90b:37c3:b0:305:5f33:980f with SMTP id 98e67ed59e1d1-3087bcc3a75mr20408761a91.27.1745315657498; Tue, 22 Apr 2025 02:54:17 -0700 (PDT) Received: from localhost ([122.172.83.32]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22c50bda4d3sm80994595ad.47.2025.04.22.02.54.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Apr 2025 02:54:17 -0700 (PDT) From: Viresh Kumar To: "Rafael J. Wysocki" , Viresh Kumar Cc: linux-pm@vger.kernel.org, Vincent Guittot , Lifeng Zheng , Nicholas Chin , linux-kernel@vger.kernel.org Subject: [PATCH 4/6] cpufreq: Introduce policy_set_boost() Date: Tue, 22 Apr 2025 15:23:54 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce policy_set_boost() to update boost state of a cpufreq policy. No intentional function change. Signed-off-by: Viresh Kumar Reviewed-by: Lifeng Zheng --- drivers/cpufreq/cpufreq.c | 49 +++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index e31891c7b500..24745088403b 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -620,6 +620,22 @@ static ssize_t show_local_boost(struct cpufreq_policy = *policy, char *buf) return sysfs_emit(buf, "%d\n", policy->boost_enabled); } =20 +static int policy_set_boost(struct cpufreq_policy *policy, bool enable) +{ + int ret; + + if (policy->boost_enabled =3D=3D enable) + return 0; + + policy->boost_enabled =3D enable; + + ret =3D cpufreq_driver->set_boost(policy, enable); + if (ret) + policy->boost_enabled =3D !policy->boost_enabled; + + return ret; +} + static ssize_t store_local_boost(struct cpufreq_policy *policy, const char *buf, size_t count) { @@ -635,21 +651,14 @@ static ssize_t store_local_boost(struct cpufreq_polic= y *policy, if (!policy->boost_supported) return -EINVAL; =20 - if (policy->boost_enabled =3D=3D enable) - return count; - - policy->boost_enabled =3D enable; - cpus_read_lock(); - ret =3D cpufreq_driver->set_boost(policy, enable); + ret =3D policy_set_boost(policy, enable); cpus_read_unlock(); =20 - if (ret) { - policy->boost_enabled =3D !policy->boost_enabled; - return ret; - } + if (!ret) + return count; =20 - return count; + return ret; } =20 static struct freq_attr local_boost =3D __ATTR(boost, 0644, show_local_boo= st, store_local_boost); @@ -1618,15 +1627,12 @@ static int cpufreq_online(unsigned int cpu) policy->cdev =3D of_cpufreq_cooling_register(policy); =20 /* Let the per-policy boost flag mirror the cpufreq_driver boost during i= nit */ - if (cpufreq_driver->set_boost && policy->boost_supported && - policy->boost_enabled !=3D cpufreq_boost_enabled()) { - policy->boost_enabled =3D cpufreq_boost_enabled(); - ret =3D cpufreq_driver->set_boost(policy, policy->boost_enabled); + if (cpufreq_driver->set_boost && policy->boost_supported) { + ret =3D policy_set_boost(policy, cpufreq_boost_enabled()); if (ret) { /* If the set_boost fails, the online operation is not affected */ pr_info("%s: CPU%d: Cannot %s BOOST\n", __func__, policy->cpu, - str_enable_disable(policy->boost_enabled)); - policy->boost_enabled =3D !policy->boost_enabled; + str_enable_disable(cpufreq_boost_enabled())); } } =20 @@ -2861,15 +2867,12 @@ static int cpufreq_boost_trigger_state(int state) =20 cpus_read_lock(); for_each_active_policy(policy) { - if (!policy->boost_supported || policy->boost_enabled =3D=3D state) + if (!policy->boost_supported) continue; =20 - policy->boost_enabled =3D state; - ret =3D cpufreq_driver->set_boost(policy, state); - if (ret) { - policy->boost_enabled =3D !policy->boost_enabled; + ret =3D policy_set_boost(policy, state); + if (ret) goto err_reset_state; - } } cpus_read_unlock(); =20 --=20 2.31.1.272.g89b43f80a514 From nobody Wed Apr 1 15:20:44 2026 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC709215173 for ; Tue, 22 Apr 2025 09:54:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745315663; cv=none; b=SglC/NCOjAAneRHm1crfa+tVzxAOo2HwOfF0wawil0/fdfBLjMeEbdJosO5c2ak7mMZ1ecDidmjV2PKKpCbF222z+r4rFNWDqCB6aJqRjDUHaqnglPH8bZfu4XCJmm8fJiyFS/3Ta9rXwJSccbZ1hg3CoyvpW/rx6mYoL2WRmOY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745315663; c=relaxed/simple; bh=cVq4c4NXGO0/VRDBrGImjhxsKCiirGO3AQu1B/IYzYM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=joabf1ytxz5/XSppZsPytjQ3QEWS3WufsNnQW3OAz3MPkkjM+RweiSjcY7lW4h+1JVnvsMTYZdhBNk/KlG8HdtpVv5xtW7lguHW3GmEjRirq3DI97e8hfyIuWZloaO0MVxh9M6+zcwGJkwrTu1g95OxinNUtgsPLg0jqGpp18M8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=fUKu4uJY; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="fUKu4uJY" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2260c91576aso41902785ad.3 for ; Tue, 22 Apr 2025 02:54:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745315661; x=1745920461; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sL1kGrQ7pxuW+GJmcKXt495d/ijkj0h7CpDbYSylQOg=; b=fUKu4uJY24/vIz/k4INH6gCfqJeNyaN0tICWa+SEpHetPJTnUteeSFdY4HBemKdDdq MeKB9u6H5M0W4QqypC2MRtgQHszrccpmBnbHvuxGHvDOwnCTgNzcIiRInqdVt8xpeC3Q AHCsb5GG1wrvX5ds4Jukl2EoC+WH5yvccZ6o5mJH1rblYHmfGLITT9TTPglcW8jRgm39 iEl2dK7PjGk5+YDC5mE6DPRY7XvnQw5+qf8wiJuPWRB6+2YP9RIhpdusCsm5dR8SobkZ tgJ8wCpV9G7rulpbOUboFOfHwxxN7yu1Fb9gauyJkQ3jw5X93sWM2u4xYMspP1Wo3Z4e M7uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745315661; x=1745920461; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sL1kGrQ7pxuW+GJmcKXt495d/ijkj0h7CpDbYSylQOg=; b=E8AtsJ0bgtqjSrTPkqQsxA7fC01diEd+ehHyJM+0ZKT9b6nNnaK3IXC28wLGJg3vbJ BfUV4KxL4UZOFwU2Aqqz77aHv8dZfBzWSHueSkP+IQtmEGiZxP8XJm646pDA2RUA/sB5 Mx4ZmavLqp9AsLLFciqThjGwYLcjhIVft4jlSFYFmcu6MqS5+LEBP0vyfUd0GlSoi3rn ywzB2XsxC/7HMADTXCuEm0EVmQPU/c8W1Loz4S13vwQpIIayG3l4CnLOZDC4wYYZi541 78/qT+VNw4GPYjI6Ttp/3IyKbXd1nXNvLWTeldYpYEXJnTkNocXrN4XZwAsdwSAk16pB Sjpg== X-Forwarded-Encrypted: i=1; AJvYcCX7qU4tf+9IkDLn7R0V4344YojMTjCBHGr3SFQd/OnFsDA4o+a/jMJSnpwOsfxnsGbNpN2MZpwTad9Jfg8=@vger.kernel.org X-Gm-Message-State: AOJu0YwVXzpyjwJZ/EDzSKsKRYRo4Z55xyO6FVaNNuOO8klN3Ek/nfuq HFZOmLbqMLWq/nZZzFef5wzTrrADIic39LHq26RXbn0pcZB93tSw5M93ZFFYgCk= X-Gm-Gg: ASbGnctmox+fxUygW2+leLS/be6e9do85+bDohrR4Oy7zEJd0T7Rhk8TA+6sCNZqawq HFmtAJlMMfK3/M/wUME7hmSbe/AZRi7pFZ517y8Vs7LZGpeW9T/dDI9XXfEf+4jXXIeGmZIwLiH zPphGmxqNGVfrpKD9HDmvCqy0ImfyBVph5mPiZqnIAPlB1PqkbleqOPpVNGErR3CMNbtRelfL4X 3KJoKutPGxzk04i10hVQDm61Ds1qenPWSJ4NTceYtdkuFTMqmvRXrVKtI4okay/as7rxvOsH1CN 7Bv8Mfyt0MKojCYGAP60tj8eZncSSGEHwTEF+8KxGQ== X-Google-Smtp-Source: AGHT+IE/mIyh+fwUIcGlS3NjRNjJYXWPWCmv1heiExkWyxbfPD18Am5wJjrUdBt38apOdY3phcgTJw== X-Received: by 2002:a17:903:986:b0:224:e33:889b with SMTP id d9443c01a7336-22c5359a406mr246903215ad.12.1745315660864; Tue, 22 Apr 2025 02:54:20 -0700 (PDT) Received: from localhost ([122.172.83.32]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22c50bf2548sm81060525ad.64.2025.04.22.02.54.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Apr 2025 02:54:20 -0700 (PDT) From: Viresh Kumar To: "Rafael J. Wysocki" , Viresh Kumar Cc: linux-pm@vger.kernel.org, Vincent Guittot , Lifeng Zheng , Nicholas Chin , linux-kernel@vger.kernel.org Subject: [PATCH 5/6] cpufreq: Preserve policy's boost state after resume Date: Tue, 22 Apr 2025 15:23:55 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If the global boost flag was enabled and policy boost flag was disabled before a suspend resume cycle, cpufreq_online() will enable the policy boost flag on resume. While it is important for the policy boost flag to mirror the global boost flag when a policy is first created, it should be avoided when the policy is reinitialized (for example after a suspend resume cycle). Though, if the global boost flag is disabled at this point of time, we want to make sure policy boost flag is disabled too. Signed-off-by: Viresh Kumar Reviewed-by: Lifeng Zheng --- drivers/cpufreq/cpufreq.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 24745088403b..0ad459bc8f84 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1626,8 +1626,13 @@ static int cpufreq_online(unsigned int cpu) if (new_policy && cpufreq_thermal_control_enabled(cpufreq_driver)) policy->cdev =3D of_cpufreq_cooling_register(policy); =20 - /* Let the per-policy boost flag mirror the cpufreq_driver boost during i= nit */ - if (cpufreq_driver->set_boost && policy->boost_supported) { + /* + * Let the per-policy boost flag mirror the cpufreq_driver boost during + * initialization for a new policy. For an existing policy, maintain the + * previous boost value unless global boost is disabled. + */ + if (cpufreq_driver->set_boost && policy->boost_supported && + (new_policy || !cpufreq_boost_enabled())) { ret =3D policy_set_boost(policy, cpufreq_boost_enabled()); if (ret) { /* If the set_boost fails, the online operation is not affected */ --=20 2.31.1.272.g89b43f80a514 From nobody Wed Apr 1 15:20:44 2026 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46E0D1F874F for ; Tue, 22 Apr 2025 09:54:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745315666; cv=none; b=QTl60x28eLXwN3vM3I650ctrDlkSShc6UEU+OkLcSjV7AK+hlr0tzJk78lGo9PK4vG8dkvDYEDDKBSXBMh3+SOET1FToSTIfKx40IYWNFgZaOvdv6I21XzsqLfNCYozqdLNjBCLxd8CyPABLHJ9HF7rtRgiz6UWtgouEh7lN5J4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745315666; c=relaxed/simple; bh=h2PlaUDNh+Zo7Zhthf2PkPMeYtfakuR/Qz/FV6Egn6I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TxXn+lD4w1eatbHosbyCwGjauUg7ifWtLQcAWzyOYoB0OJ2iNQKMzt6SXUr+noWFFAjfIpcAgkCYfr5vBmb+JNdllyqToMYA+582QmgEuOdQ8Tb3+wUecLjWMVbnggSyoMqc7vUSO5KoQMNuJtDrFOhouIf3fDQDeCBUotb06fk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=mdi+q4IL; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mdi+q4IL" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-736c062b1f5so3826688b3a.0 for ; Tue, 22 Apr 2025 02:54:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745315664; x=1745920464; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cLlCWejYiaj9zuTPSqef+ff7x8m34iah1oXk7eNizuA=; b=mdi+q4ILLg8SGqDKvh/yRk+IZ2U2NNBQIbKgzuGhOgNT9zSnD5W1h7TE5CovFA2b9+ tX3Yx5KgpsixXFVuso51TMrGXExLC/YSc76fwm8Hfli+UyNk9DA6EyWXum1zC5U/Qerr CiliVM0gLKaea9/GB8ZlGCHGsyJiHK/jMq98uSpR1xhSIb5g3iWtCkEuOrrJ6anekPpm Quwx/lf7EfcI9JjmSQ2ycqt2n9G4M2U6deR1J4sUlZGAsifrUoMBa3NqRFcCSrW6emM6 ug3+dVGDHv2gcSFk7zoIlGK873oF41RhRUslPJ/z5ObkN/7tggDaUIxUwIVrBGvJG9ti BOKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745315664; x=1745920464; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cLlCWejYiaj9zuTPSqef+ff7x8m34iah1oXk7eNizuA=; b=RLKXu9cyNqS4qkwe4ciojreds/39NSHjsu+Ln0XpkXYR4qehGuKXme/Y2Xwv8azzww phFwA534ANm9mVJuihbi6TrFvj2qcTq5rEZIRj7wjTEydazzVlyYvkEWvNHyfRYu0KKZ HexBmvZwxaxTCELaH1rAhpopzx3qHTBPtrOfVRrYT2o54FyEAkhv7Q2niCaRIUUCRVPe mNKFUIAPMgKDZsfV4o0G3UGXUGu3apW8ye0RGhglzWxCGQI5p8WHwJ2yvCRh30pO5zlk ukfViGARHrldTqG3J0JPCDHVyf+4/nBiQvfO4MT1rhZ+/pA+1qphNp29nfq7RsQTEbPu Rp4g== X-Forwarded-Encrypted: i=1; AJvYcCVh2bWIjOrnXVgvuVIcldARd7UpYalMhoB62+H/Ha8FN9HVGEsLTtZMgWTz+3FeRYC1jl2L+hldQiJQDGY=@vger.kernel.org X-Gm-Message-State: AOJu0YytqmKmEBKHDPMdUzqkE1b5ASi5T4395mJCrUtl+/0+0cHi7g+/ Uey+/+OTLe5U+1KeinPrjP2pjNXbtIwjDUeCtJ+1QFWHATbRDgNM7zeB/HOC9kU= X-Gm-Gg: ASbGncs68xBSmmA6asq7vRfhwUSP7w0rsmkX6oYczCpihwZgwMnDd7o7ZBXyQNqrk0R 8u2kiQtFcv2Mg5IipQk6W7JLOgtHKuR9A26rpSsVmEVGqIVBandM1pAyQ3eHb6d8dIfZyWd0Um3 GVpa01iGgqs7sDCNAwCk00GbonZUIQgcMdgE9NTOktMoAv/4il3gjMnu0/deV3pIdjGNA2Tu4G8 Q1IU12kmmANDFcHF5yZZKhmI0tLgbL6gWzsMPR9NPXMYx+GIc6L20JNiDPkZef5HrONQTn5H4p9 iMNNxnBlXyWvrT5eLfgATbKWATBFwoXNmvVjhv6Cag== X-Google-Smtp-Source: AGHT+IHqQTHvvzAxnddY26qFGNYR3FXphqrDnq4k6oSYICVoVYNGfaLtcHbgiJNvmduT4S9HNBMjSQ== X-Received: by 2002:a05:6a00:3928:b0:736:a694:1a0c with SMTP id d2e1a72fcca58-73dc15cc4b4mr20840085b3a.21.1745315664414; Tue, 22 Apr 2025 02:54:24 -0700 (PDT) Received: from localhost ([122.172.83.32]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73dbf8e510bsm8463248b3a.66.2025.04.22.02.54.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Apr 2025 02:54:23 -0700 (PDT) From: Viresh Kumar To: "Rafael J. Wysocki" , Viresh Kumar Cc: linux-pm@vger.kernel.org, Vincent Guittot , Lifeng Zheng , Nicholas Chin , linux-kernel@vger.kernel.org Subject: [PATCH 6/6] cpufreq: Force sync policy boost with global boost on sysfs update Date: Tue, 22 Apr 2025 15:23:56 +0530 Message-Id: <73708a14feae46166e9bceeee5e8bf2d0802930d.1745315548.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If the global boost flag is enabled and policy boost flag is disabled, a call to `cpufreq_boost_trigger_state(true)` must enable the policy's boost state. The current code misses that because of an optimization. Fix it. Suggested-by: Lifeng Zheng Signed-off-by: Viresh Kumar Reviewed-by: Lifeng Zheng --- drivers/cpufreq/cpufreq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 0ad459bc8f84..4ac5d4fcfdd4 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2863,8 +2863,10 @@ static int cpufreq_boost_trigger_state(int state) unsigned long flags; int ret =3D 0; =20 - if (cpufreq_driver->boost_enabled =3D=3D state) - return 0; + /* + * Don't compare 'cpufreq_driver->boost_enabled' with 'state' here to + * make sure all policies are in sync with global boost flag. + */ =20 write_lock_irqsave(&cpufreq_driver_lock, flags); cpufreq_driver->boost_enabled =3D state; --=20 2.31.1.272.g89b43f80a514