From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388186; b=l40KXmyddzeov0DWF6f/kWnDdh1n0S7o83qOhdTYLjVg9pxHnEg+LqluYgEAtqI0UL91 B7XIcSvdWwD3L6Chg3p8WiFHbb7LIhGh+/ydJthdJHIIqKeFiA/v5Y5pN+AKg5D7CWBxj PYPN8pJpXedKru6h2zECz+/so8F4xG/DQBLYptkzX+eAe36Ml1spH8m7sthLf6ZT7TClc II5/oW9lLQxw4cVF/Zj5OlzldKrVjo7AkgishzYOliW20y0c4u7L3vbfmJyFxjZJD5qY1 GnDYu/8QLyg5UH1cofTdXuNQ6DVypsJc0B3G+s1lsq+8aD3F88n+k5M09TQ2i0rEDiQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388186; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=dv+xlvPZGKAPIIZTK/SpCHGX9hqnZKKo4th788wXz+M=; b=1AL8kqD5XYrFCVLP3wR1QbO45a4OXqnxi5I49mqLfbWhMKPDvt33s0jkkTx0vmhHMwWq 3iamqQgGQVKOSJXWKT9TnkOUcYdfpVWcluWvrpbOxRRL50Jd4lFxugJA/EbikSvJM+bKy 1RFBIkN1KzkO9XcHGAw4RvXWOkbwJUI7QT2X6RqVP0YbbTY+f+5fdspDQkuStiRp/9y/t q9qapQTveYmeEGgJBs6C/pzI+WWXF7KpnWuEsrDzi2wCnNDPRENKzrs+dccWvs95Go7UQ aHDxe7agS4W2tIsSk2sZG6CCWUtMGYiBb4pBsExT7DwyRyB2X02MuLkmKe99lI2X7EA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=2NppmK6G; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A60B606A322; Fri, 4 Dec 2026 12:43:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=2NppmK6G Received: by smtp.kernel.org (Postfix) with ESMTPSA id 087A21F000C2; Fri, 4 Dec 2026 12:43:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388186; bh=dv+xlvPZGKAPIIZTK/SpCHGX9hqnZKKo4th788wXz+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2NppmK6GM2aEHn4Xn6n1k6Za20U2+nBjD7oQtgbgc3nVFBPKoFKLBdWdzoPJuDYw3 e9zb5PTzRdQjx5l3WPwINLiIKKxFyXRRXsqn6Dve4pURf2keDGDJJRTgVofl3VMWum /LkpVSAz1GBT5EMJ5Aq+GHaa2n7K0uCT2jw4sUBk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Li RongQing , Zhongqiu Han , "Rafael J. Wysocki" Subject: [PATCH 6.1 0517/1059] cpufreq: acpi-cpufreq: fix P-state index mismatch in extract_io() Date: Fri, 4 Dec 2026 19:00:48 +0900 Message-ID: <20261204100657.628541927@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Li RongQing commit 6bc092a0fc4d331a4adbbb664078af149c580834 upstream. When policy->freq_table is built in acpi_cpufreq_cpu_init(), entries that are not lower in frequency than the previous one are skipped. For each remaining entry, freq_table[].driver_data stores the original ACPI P-state index, so the index space of freq_table no longer matches perf->states[]. extract_io() currently walks perf->states[] with index i and uses the same i to index policy->freq_table[i]. When duplicate frequencies exist, this can associate a P-state status with the frequency of a different P-state. It can also access an invalid or sentinel entry in freq_table when the number of entries in perf->states[] is greater than the number of entries remaining in the frequency table. extract_io() is used on ACPI_ADR_SPACE_SYSTEM_IO platforms by the frequency verification path, which is enabled by the acpi_pstate_strict module parameter. With the mismatched lookup, check_freqs() can fail to match the frequency of the P-state that drv_write() has already programmed. It then sleeps through all 100 iterations - at least ~1 ms of usleep_range() plus 100 cross-CPU calls and I/O port reads, all with policy->rwsem held, and .target_index() returns -EAGAIN, leaving perf->state at its previous value while the hardware is running at the newly requested P-state. The cpufreq core consequently keeps policy->cur at the old frequency. Since __cpufreq_driver_target() returns early when the requested frequency equals policy->cur, the driver is not called again for that frequency and the control register is not rewritten. The hardware can therefore remain at a frequency that differs from the frequency known to the cpufreq core. Fix this by iterating over policy->freq_table and using pos->driver_data as the original ACPI P-state index when accessing perf->states[], as extract_msr() already does. Fixes: fe27cb358835 ("[CPUFREQ][2/8] acpi: reorganize code to make MSR support addition easier") Signed-off-by: Li RongQing Reviewed-by: Zhongqiu Han Cc: All applicable Link: https://patch.msgid.link/20260910111329.2220-2-lirongqing@baidu.com Signed-off-by: Rafael J. Wysocki Signed-off-by: Greg Kroah-Hartman --- drivers/cpufreq/acpi-cpufreq.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c @@ -200,14 +200,13 @@ static unsigned extract_io(struct cpufre { struct acpi_cpufreq_data *data = policy->driver_data; struct acpi_processor_performance *perf; - int i; + struct cpufreq_frequency_table *pos; perf = to_perf_data(data); - for (i = 0; i < perf->state_count; i++) { - if (value == perf->states[i].status) - return policy->freq_table[i].frequency; - } + cpufreq_for_each_entry(pos, policy->freq_table) + if (value == perf->states[pos->driver_data].status) + return pos->frequency; return 0; }