From patchwork Tue Apr 22 09:53:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 883440 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (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 B9653213E81 for ; Tue, 22 Apr 2025 09:54:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745315650; cv=none; b=Ss3qO7OeWTAvJKrQ8QpL5SLUvTEWiW7+HLkzPIjtvRuxm3JPhmrtxeRYiXBq1n8UVFA24bV5tpuzxk6qisNTP7+pStrNn3NwLWhDUyeEA68XUJpsIhCVfwEbP2qRmC/jtgmDtngHe+EC540WGDKvArFAbmR7AjVmNuDjGslwxCU= 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.216.44 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-pj1-f44.google.com with SMTP id 98e67ed59e1d1-301302a328bso5203004a91.2 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=m56lRleWn6PxwWvEweOCXTLURDkvsLhOImgCkEICKOxAU8wM1w+/rLO7EfTXAjGrmT paNNbNe/ydoJgDanFv9AfZdQ/RFDntRD2YCP/x5FMGFaUs6vl2smv0FBAqX6YYejmwm/ gAPYw/wERZ9LRzdc1AFQ8SeeJZb2a2zsI5QRDxYcrrtBWzViDkFWAnwGtCXedXT65WFy Ch9df/jE4kfixvsghlzRLS0LhIRtPzMzY4h9NmkDPkWieXdGBDeb8VxuJjd3GUFVCdqw HorqZLblt61n+wZ6zBJL45nO/XabOe/3gpUoJBtEq6h1Wss9qwq2/bEypn+EHd02bF26 UnOQ== X-Gm-Message-State: AOJu0YyXENsWBr4sVIVuxW6ZTLtqqdh+4k3ZZlS48DFVd+GqeZuYQdiM RmmlV0uZhYu+i/vw5EG2NZUuLHXLB8g7oUmczWZf8/eX2ncpqCfPP1V78wd4CgY= X-Gm-Gg: ASbGncuDwSKqxDOF1i0qj83wHtFtOYYJ/WulIhvIZiqVUwu+5wgNpI6oSqnIquRL7Vv 343HHIY03jNM54ZiqcHuTJm6wkv2Y4lfDWpASNO1QhNjtCyI1/N085qn9LEQ8qS3/m8M/zDGlC/ WYg/PzlMRg7uxIVXbwKPH5ySMTgbrS/1IiXYD7RS9Upq1ecRNg3/RuO2mXNM41MfChfEPUfczKN GO3Fxer1GRVzMdtSIpA4vt2ngYslRoIkFxQDvR8b77374PzojmHGX1xnxn09/w4IIgm/ru/3QTm YD8CjxJjLKDFtxWbC02MieAoRFqvliTdrdR5NTnSrLoE0hkRoOI2 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-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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’t 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—correctly—by 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_init()") Reported-by: Nicholas Chin Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220013 Signed-off-by: Viresh Kumar --- 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; } -static int boost_set_msr(bool enable) +static void boost_set_msr_each(void *p_en) { + bool enable = (bool)p_en; u32 msr_addr; u64 msr_mask, val; @@ -107,7 +108,7 @@ static int boost_set_msr(bool enable) msr_mask = MSR_K7_HWCR_CPB_DIS; break; default: - return -EINVAL; + return; } rdmsrl(msr_addr, val); @@ -118,14 +119,6 @@ static int boost_set_msr(bool enable) val |= msr_mask; wrmsrl(msr_addr, val); - return 0; -} - -static void boost_set_msr_each(void *p_en) -{ - bool enable = (bool) p_en; - - boost_set_msr(enable); } 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); } -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) pr_debug("%s\n", __func__); - cpufreq_boost_down_prep(policy->cpu); policy->fast_switch_possible = false; policy->driver_data = NULL; acpi_processor_unregister_performance(data->acpi_perf_cpu); From patchwork Tue Apr 22 09:53:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 884213 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 D22142147E6 for ; Tue, 22 Apr 2025 09:54:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745315654; cv=none; b=WmSOCRnhqS3XPp5soHH1O847hISyPVasbUu2UPbkRNQ6cg2XIKp3qV+U0mrC1E99jmrCdzNoGskNMCIGNMlq/I4NlbVaSORZ+02JdXeSll4k93fl96rSh6rhW+lB0J67KLFiK7XCMNIv6nNbq9E8haN9sqTHtbZJkHblGqYirPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745315654; 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=cxpwNSZ8LoRzmO2O1ao7cJdIH30dMyeO62BSPgiXUr4WI9poURXibuxdBde1xfjA0p80d/9aI/aZm4BVqc3lAX5lJhOCaERRChzkHfgnZxeDcokzN0bNFDRjW4/FeakZVDPjY4HjvwZkMLGPxDbOC8siO3szGmOvHr7llPUZQDk= 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.179 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-f179.google.com with SMTP id d9443c01a7336-22c3407a87aso73012935ad.3 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=FKtti3+yuR3AaFFVL4m+7N1TzrbkbvIi7CFJ520I+UMURgp5R+KXvnk+h0Y465GGFz 2r3TSC1y2jlikjKrRTuXX7Hai7Gj051fNV2tCjjAkhuExe638gRX9guLRZ4FNvumH6JF CEY6HeVf7dG1lm7V5uHWMlP5dalYsTOpS6nozHclQE8ILcMdS5P058Hb9vF2Rgc9mFmS nYDF3R7/56wK9R7FSIj7cVCWMKvQt5v1icN9xV3inBfuAvvUx+KUIHOOCsJbJzVkFW5d lB4BtJygA+Kkv8+cYAQ6TZ89qve6piLxNfuygACelw020AoNF4Vx6Ao98+PvnVZqGF43 he9w== X-Gm-Message-State: AOJu0YyZCLc8eeMVSPthKM9N5sO76Y0ebqp3SUpDfBM1fN1XA0+rkpEA Oe0u5tEsdkH+VgWYRHm/3c7Smei6y8w5DrqVfQvVLTt5mEPoFf7b1vWnvgIj5Js= X-Gm-Gg: ASbGnct9Elh5BaT5TK91E9he8rONNJBhCDB9MTbJV3/O0uyzUEGwL3iBN0o3y4JXRpc ARDc6k77pGFelQJBNIb1A9DB/tNxOVqUsKmoORTJeSlLqnWwoT1bBzNWop8rr78+bb5/XuGzJbz vRe/Bb3er3HW8UlJfCmeBCp+D4zoQEcWMcI9U718UJdJyvmBJHcHxS+UcdRqcbhxkTr4D0rrcli Nvu56rLLay2mOOezOuJzElCMv/SX3n/81mGjNAwKwYCnvkNBMHlNnp0+9t2vZwcjvBWjrUbv78s f/NSEdxH8jOn8RLRcAzzDUE33uVtxDNiYrTxiHuGCA== 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-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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—even 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_init()") Reported-by: Nicholas Chin Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220013 Signed-off-by: Viresh Kumar --- 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 != freq_table[0].frequency) pr_warn(FW_WARN "P-state 0 is not max freq\n"); - if (acpi_cpufreq_driver.set_boost) - policy->boost_supported = 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 != boost_state(cpu)) + set_boost(policy, policy->boost_enabled); + } else { + policy->boost_supported = true; + } + } return result; From patchwork Tue Apr 22 09:53:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 883439 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (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 CE9BD215046 for ; Tue, 22 Apr 2025 09:54:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745315656; cv=none; b=jQFzgvBdJzoIGx3zAfm0Z0MQanDWiqgpujIAuDRTFVPv5sur1DfmDWIzZoPYZpTfQeoPZojte0o7Cwrhg8GQoicncfg77lrsavSx0D49Sa1QMB79zHrgaI8V39mK6mJHuh/w1FvWOJeIR7+J95f3wf3fNfzMmXKpZEr9C9JUkzQ= 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.181 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-f181.google.com with SMTP id 41be03b00d2f7-b0b2d1f2845so3334142a12.3 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=CJnSxRnMmPF+CzbToiAtqIb+rQdXa8NMkqKXiviZC8t7UFEtDs403ClTUm/1FZeih3 KH3DN/kJ9FuAvD3n76EA7DZLjGZ2W/wJhTFQycRVbeYARM1Vvwo+9aj2DFB8QuANk9Nz QA4rjM6WpEJqc9Bw72Ym2ij9phKUsz+Fh3sAqnkmY4DKL2AU0Od77lpa+etvFNF+ak6T L9qP3NFZRAjots7QXCSGbQmwxX21yoca90mjYYucS9TS+iKmapjnhkwVfO+fqXi847ue yEynrRQXTctF0WbN4g29YSeRT9KHGylqUXLfEm41x12tEQkV8iQJCzTRvMOBgEgUK3SK AaVA== X-Gm-Message-State: AOJu0YyEjGJpzuWZfWmy2UY1WwsK78UXIvMpWtJPKBB5nAmahFWfNL60 mbKCslBeNIGB2HxiY8YRCjdHLk+nnN+00nzaa79/6nyBfvReHlqbdELyaqMQ2dA= X-Gm-Gg: ASbGncs+kPw2qXCj7Y30Uou584P9NFlm+CW8JUeHAkHLjf8eSNQm7fgGgZva/ibublv eMrAENvNEb5io6HK2Lrofi8BOTAun/NobfesiRVv4KnK5kN5lISV1eJFz2E2N+00Vd+/lN7FJ4m GQ5sFQ/FOvVPh7wMlfwIrjnkmGHIL8M9Af2qZPxOD71kpSqRCE7ihLUvsNmvjwM656hi16S/Pk1 eJK1P+etm4dn64Lazn92R30lewNeKEFJBeLCIV4NGEOdEAmS7alOC5fudapfXlMNIFkIfZrTXPx Z5agNT/4oXI8Wz555zRFBKuN75I2KnVadehOoBESxQ== 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-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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) cpus_read_lock(); for_each_active_policy(policy) { - if (!policy->boost_supported) + if (!policy->boost_supported || policy->boost_enabled == state) continue; policy->boost_enabled = state; From patchwork Tue Apr 22 09:53:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 884212 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (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 6670A215F56 for ; Tue, 22 Apr 2025 09:54:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745315660; cv=none; b=NZ9duFOEK05hfhFfKP998vwWKrViI6ygVlWkfzTGamUJHXxmDDSWcrlyT8J8/XTWNNHaWo1OeWBZ7vSJzGpEKUvDxRyRAGxWxMznaOUxHkUnQrS6vDs81LoZI/CyAwuzgX2aTZEMOEvYjqPUEhSFFyxCVgfM5y2GRzHlLR5NQ3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745315660; c=relaxed/simple; bh=M+/pqwhpw1fPajfCHBDUoRbLW6qnHDooYX4AD6Hjgz8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sRKh/fCsUHh61z4PyaNH/DXh3PXK+WuofRGbHBPZpTXVRCHMgaWv1loOXzpPBLc3BKP9SrLfXAMlvByFbvisvB04loEyxmcIF9s05jOXPvuSyKKRHHuwDQ1Lt+5VbShXXoTJfMGY7iqupag1lzeiATsD0mWcjvO4L+0Ik8EK9e0= 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.50 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-f50.google.com with SMTP id 98e67ed59e1d1-301a4d5156aso5176749a91.1 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=oALEzh6JUF1RrGh3vxLRvsreLdK77NfIu/n+MONlxcqJSkvwY2az22N9jqPelIBAXs aFnafMpYiTr/4wVfFuuvfF81fdu579xHnSWexdmCYWyy7TW/4buzwM8cY7Q6AQdlZV2v 05xA4xU4Vp3xQMkm3V2DEgNaQyQUxPg6p449KSBgsnBLdkBbhPomjscQa6UsoEyTyEoO ZDqF9i+zoeJzt8rfKVvgD9cmrxIITxGsQOW5YQ/yqTS9EXQZ6HCT48gv9fVRYllHnZgo 2OzfkIXbt+hDtRPn2Md/XylpG4b8fM5mgNzykvsEwSTjymfYZ52XhRhI0lMRgtYl7xb+ sXfw== X-Gm-Message-State: AOJu0Yy+zVMKW6I1TQBkhg4ABykNpuFnaR29qXp96HaXoq+ONBMVkSiX I7y4eIhq1/Ewy91bsaDhKulASIKdUBVUZgkAGkzidi+qLvuVkLRwawo+XwiUYaE= X-Gm-Gg: ASbGncvxuxSA8Xye4m06gXjM94EbmqAV55umUuVEkF9EXYOs/S4QVsInuFTN+r/vjZK JjqXizWGPgTQd27bnaNHrVvlWixHDTYKyyBMT0ev8nQJ9l2xwmx75GTR4eRXWJG2MI/Iaq8nn4F xvNxP+NXnIHr6WB5VL4Fvm5POBSoWyehtkWC8qFQYS5+mJb+9jwiCrYa2w+3uuQN92RhJuVQvRv aTJOFzeRNnuFodc7vVLkaKJHGOEJ6toiVp2DC+10A8xtB6fUPZl3hKYf61HVWlMVFu81KNdPUhL /fOJtTAvdpBcehHubjxFNZrWcE7fZSPW5XWOPKR+7g== 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-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Introduce policy_set_boost() to update boost state of a cpufreq policy. No intentional function change. Signed-off-by: Viresh Kumar --- 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); } +static int policy_set_boost(struct cpufreq_policy *policy, bool enable) +{ + int ret; + + if (policy->boost_enabled == enable) + return 0; + + policy->boost_enabled = enable; + + ret = cpufreq_driver->set_boost(policy, enable); + if (ret) + policy->boost_enabled = !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_policy *policy, if (!policy->boost_supported) return -EINVAL; - if (policy->boost_enabled == enable) - return count; - - policy->boost_enabled = enable; - cpus_read_lock(); - ret = cpufreq_driver->set_boost(policy, enable); + ret = policy_set_boost(policy, enable); cpus_read_unlock(); - if (ret) { - policy->boost_enabled = !policy->boost_enabled; - return ret; - } + if (!ret) + return count; - return count; + return ret; } static struct freq_attr local_boost = __ATTR(boost, 0644, show_local_boost, store_local_boost); @@ -1618,15 +1627,12 @@ static int cpufreq_online(unsigned int cpu) policy->cdev = of_cpufreq_cooling_register(policy); /* Let the per-policy boost flag mirror the cpufreq_driver boost during init */ - if (cpufreq_driver->set_boost && policy->boost_supported && - policy->boost_enabled != cpufreq_boost_enabled()) { - policy->boost_enabled = cpufreq_boost_enabled(); - ret = cpufreq_driver->set_boost(policy, policy->boost_enabled); + if (cpufreq_driver->set_boost && policy->boost_supported) { + ret = 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 = !policy->boost_enabled; + str_enable_disable(cpufreq_boost_enabled())); } } @@ -2861,15 +2867,12 @@ static int cpufreq_boost_trigger_state(int state) cpus_read_lock(); for_each_active_policy(policy) { - if (!policy->boost_supported || policy->boost_enabled == state) + if (!policy->boost_supported) continue; - policy->boost_enabled = state; - ret = cpufreq_driver->set_boost(policy, state); - if (ret) { - policy->boost_enabled = !policy->boost_enabled; + ret = policy_set_boost(policy, state); + if (ret) goto err_reset_state; - } } cpus_read_unlock(); From patchwork Tue Apr 22 09:53:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 883438 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 8B67D217701 for ; Tue, 22 Apr 2025 09:54:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745315663; cv=none; b=MR1JOs2CmLHa6q1Cn4xlOmKkAisBScTqtTGJtnmrH44lFQeTQ5riIp2Pk9IHzaolpAS7kRmL5vTaxDf1bFlgDn6rXKnQgEdZ+LzdEWsoPDLLMyQP4FJ9BNrhnvrsfNlxRqoeUMLy3ImGovDxJN3LsDzjLwIwUZpF5BeayiLjSMo= 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.177 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-f177.google.com with SMTP id d9443c01a7336-22c33e5013aso55314565ad.0 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=SVuyJ58OFez2xLgh1gb8MnqVZe7XEY9RQISwr0koVCx3gROgcHYnrTNh/kBiQApKTm yg9kYv1P0YYmUPHitQ2GTkIhVw27RcXN19ak5T4/nCWQ2n5xPQRl7twC/dZT0sv9u7/S 3sJVvP9WJQMwSUD9/fEocnk4mvuCPAjVgEChpbqm/bLklj/BB/1JgQQD9qFaLcHi5M7a E/AvhsvOwkxuvJ3BaphiKgPdlF1lPiC/KTSu21xobZfFoo7+2lnsBABxQfDOEgChK8t4 jN+e3DV6xG1Wj4FpI10qgp3NI9MxHTbY7GrAYNewY2PkKQMM/sybTOUUe4nlHA66IbRt OA2A== X-Gm-Message-State: AOJu0Yw/dJFD8BHlKXIO+djjDskgMDgOLmyvXHYrdQuqKDB0TH4vS6gF okJuW19qw/AETSxxKFTkJEvhkAr1PenW5A/OoUPdhoNtk1sVpzwBUJhsY2Lp7io= X-Gm-Gg: ASbGncv2YVwGhzPHtVT9OLmAI8YWtyB/N7ZmXMzinj0jyc+P+RU+HlgVytooiI+M6se q39Gwv8CgQs2PzaVlmcbgBQjAyJ2V8lbw0VvexEUc1L3mjaCbN2KsnCUMYZ2HjYfbdtRGEMGSS8 xJAO43zwC2D2CAlPhqo656UJTU0DaXqNT0rz+8rJw+y7N1LbulZHYhg6uIC0tw7azUHBjRySFne 8kZ6oawnMWhGlX7PKL8pY3XuaKLdJYZz+Yyehj0srIGQP5MWGVMS9CwyPQplV/QmcTDQ+XTGd5s qng6O7TKHJkH6ryiLMz8cmgZ87Syz16JGU183PQN8A== 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-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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 = of_cpufreq_cooling_register(policy); - /* Let the per-policy boost flag mirror the cpufreq_driver boost during init */ - 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 = policy_set_boost(policy, cpufreq_boost_enabled()); if (ret) { /* If the set_boost fails, the online operation is not affected */ From patchwork Tue Apr 22 09:53:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 884211 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 30F55216E24 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-7376dd56f60so3483630b3a.3 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=pnqsZNNf22ahH9OwKu4U4yYzVToKQSTS46wqOrORHnRkHSArAGRDBOax4jg6ZWcxJZ KFFeZejdiuR5jtj0dS884U/Vgo9WG4jAGjSplt5ZeBUGRbyFegGRWqOGFmw0pcwLwzyy 8YPCTgHEgCx6O/5AOb/b6Sz5X0Sj4ay8Xv6FWXqLil/W/40OCB0SCpltbVIgZOAeoNSW XVEz0sxIdnFLkDv+Ua0OECXq4fK6y/KuZt8qO66vm/uR15jXXpzitbOuIagMrYcVUpYY Wr9QrAUOxireuuDJaBuLFfVJ9GwDHvbCYTiOX1EgF6f9F+t9fnuTs4HQvJ8gobXOfIky tDJA== X-Gm-Message-State: AOJu0YyShchf46brBuRUXzpBpgHKykhkN4ToJyNo2wdWWE17p++LFp3p tAgjV0Upg5c8EF2x5iUF5sf+/B+z0bQKdO37UIG0uBYcsN1OBB6xhLpibxN8Bsk= X-Gm-Gg: ASbGncuNTwi3wBgi2dm39GDplb88/0kt09IW2aN7Z1S6HtDiaFHagNOc+SqU5fZfukj AzlyyiF9uxilrYsaXm94mktFZtEfcaJ4aH+Y601KFsgwgCjMNBieA30LrXga3AiX9AgYtMUiob2 g6ZbsYrLnOPCnNKcsT/5T9CTFOb/xnqpcAt2rGy+VqZkyd+HM/zpil/pDakO5hkNeGCuPwfz41L /QNwaivZgUiwvkiaDuRdp3IFzLD2zdevAjzaROnUJ+R8Eogox5aYUYUJuIs2gadQ/kR3m2eHJgm vHK/C/Vvtkg0MFkV1nsqD3pfu1WaK8spcp0RIHMmjQ== 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-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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 = 0; - if (cpufreq_driver->boost_enabled == 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. + */ write_lock_irqsave(&cpufreq_driver_lock, flags); cpufreq_driver->boost_enabled = state;