From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 5C544328B62 for ; Fri, 21 Aug 2026 08:34:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787301287; cv=none; b=X9R0Zaq2c91uORtSpN5k/foJzt+knHAuUDqewsAu4/oHJgFYAOuBW5HMvdvwSIxuOuFwBr6r149vGV9LFpBrgKKxR3kAZcnTlbcm2f7aExz2G9SqsneWNWNEnqmfO1XQNJiZoEYoWdBayPjptL/hjMuv1LGexzfXP5FdIymfEEY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787301287; c=relaxed/simple; bh=DZgjw3xXltTcaSFcPUclcnFO3sSrn3L3nD5iXwkHSjg=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=SJ0ItomiJSS3qnUUpl/nRF3tKMYRn1+ioJuSCJy117m2JwqFqi0kg95wh9exdzT0ieUEBJ/NxKafdVynLvSAI25F43DrlnSWC8rVTwXPz2VoNXXWePWxkCIt2uIY+kWkmvzeU7Mds2rBjirvZ+jQobyo2OKMlsYN0f8WjAeWNzg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=mPpYrNOl; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=KQ6xGp4J; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="mPpYrNOl"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="KQ6xGp4J" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67L8WNR31688509 for ; Fri, 21 Aug 2026 08:34:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 9PjhwOraLF4jwKhPLpSZiMqtcMCNemKIlbmfB/PjLmA=; b=mPpYrNOlTYxkxiPl 16K9SyQedHYjRBMCfkeBTt687fH7UMJurE6Uc7yTiOKmkYe9KpUBCD9kbWUHojrD rcZybT6Q1tstEpCv4JSOpQeKSPMJuUS8/XqQI76SAV9s+auh4Qz+2rvV8GyIbtXQ BVO+HcjW5GaNeFrah9YVkKjak6I90FfWe5JhB2EXTPQZBBGVjXiOyt69cdgUVyMr HybLJUbBuzTFtGWVlCGnItni36/2ibj/DQtvOiCyzBwHJqiMvPhv64r+vDzuj5iD aEmt8iAbzXQfNOhhAdRXyjbcx653oMRVMzRPGnIZQ8oCnAzD6uyLbqtKDdgVFkI6 kgAFWA== Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g6ecb92x3-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 21 Aug 2026 08:34:43 +0000 (GMT) Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-cbedfa3898aso738056a12.3 for ; Fri, 21 Aug 2026 01:34:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1787301283; x=1787906083; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to:content-type; bh=9PjhwOraLF4jwKhPLpSZiMqtcMCNemKIlbmfB/PjLmA=; b=KQ6xGp4JgEruIIyXWNuinnyWCrZRfB+wK7cCYn6V6Xom27q6YI4h5HPS4tY7Ln8fGl AyokqfYetVET0Z+Vd9+KouwebOYNWuSvjvrPrY76hy7iGOEl/tUfU2ddzv9w9kSvgfNr zzwVD3goEDWd7XDOinhYbKswwL56+0+YI9zPezmX1xyggTmoKfIPNsK4oRXmAQrfCpHs beD2JUd9VoNi7oFLAbq4NRlHcYT3M6c2agZk9y6LsQbKEY6930vf2U9Ys0icLmfMkjpb Ne3g9IOxIxMRzVNBzpmlVgaqOzLsl3jJnUkjD4M543zvxJHRARUQ4WYI/xskKby0y4NS IJjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787301283; x=1787906083; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=9PjhwOraLF4jwKhPLpSZiMqtcMCNemKIlbmfB/PjLmA=; b=opeiK5F7mRQhC61dr/l1GHTxSjWYj2jYltO/VOcIV6tQKK4XVw/HTDv7YGlbLoPlJu 24GjhTIgzWmt2jPuyMgvDf8o9zqwZqdngx28u1VgC6nIyqWQmrv81kKHyCMGqixX/fL0 0i/Yf+rwZRqmFJUc1C/jtdE6p6LqL9pwYnV6fEhR1zqH2JAN+JSBojr1xX4aTyoqtAgv etcxahWzgpCtne2U49bpSh1naw4PYZ2ge99WoTz0o6uXG4RlmtJ+OniUe29+/55/Izq3 lSOGXlM7mULSjYqYB+iG6NVgb4Yw27Rp+szzQtMvPkQPdkYpnPkbocv+M5gHBDiSBrsR wi3w== X-Forwarded-Encrypted: i=1; AHgh+Rr+7Diy9Iu+4HWbXuH9hepjLfsDOPJ3z7mxSk+jpPrjjU//XgPUFTnsGD2h67hmId8eteIyG4bjQ3dA4ds=@vger.kernel.org X-Gm-Message-State: AFuF++kZPXb5UUZ3mBgwuSKleWHtqhylIlAtUQs5ilc2MQEskhDgFdpU 9ujL/wk0CalMekJpIWBigg3Wal0D56iHfpY5v7oNEuYSEQOl50ELSFf1l5XkAngz2bm+1voZQV/ 8doEI6PErjXd7O9oIL2zFf0cqgzxnSrcThmlueumKwRdUR9UjVCah2h/wL2hxJKOnWI0wD3kNbI K+mA== X-Gm-Gg: AR+sD13pfWO52YNyTSs3fKXdN4AEfSIMAppGK8EUm4yKZ7671VoRXcMpj3iMV6R6qTa e48ExkXotgRH4al6Uhy+KWt+BQukFu6t79NQUy8fRJ8q/4flGbsaViPkdkT+QftnSEmlo/aOsBR pLdhExC8ijDE1PL9tdZpxsJW4Z4Qb0A6uSa1XHC9wcp6qH+PPlyaq44FMiOddhY/S9hQESWIfDi Wa8LvVcrjDfuTOpSJECNpPST8W7H/KdNn6rFNA5TRP1GSYfPJ5a/JzZIdk410n6iSs79g1c/wCH DWYt6zf3nDPv+UqcBhj8aqvT/M4vC1oggOPKRLGclj4nfu4UoFcsZsEL2G1zjVhWjJd3qGBHaQY 7JAU/DTJj32oHCsQQaq7kf/YuwbNi71dovxRlKDLqYGJaqkNL0UVsOpTtdh9YxSItSDcwU6g= X-Received: by 2002:a05:6a00:174b:b0:851:c1d2:c48d with SMTP id d2e1a72fcca58-851f9884ce7mr6941116b3a.8.1787301282999; Fri, 21 Aug 2026 01:34:42 -0700 (PDT) X-Received: by 2002:a05:6a00:174b:b0:851:c1d2:c48d with SMTP id d2e1a72fcca58-851f9884ce7mr6941059b3a.8.1787301282551; Fri, 21 Aug 2026 01:34:42 -0700 (PDT) Received: from [10.133.33.51] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-851d36185c8sm2610296b3a.38.2026.08.21.01.34.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Aug 2026 01:34:41 -0700 (PDT) Message-ID: <3d3f8a94-7184-459a-b6b8-3f9afc43ebc8@oss.qualcomm.com> Date: Fri, 21 Aug 2026 16:34:38 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/2] cpufreq: acpi-cpufreq: fix P-state index mismatch in extract_io() To: lirongqing , "Rafael J . Wysocki" , Viresh Kumar , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, zhongqiu.han@oss.qualcomm.com References: <20260820020715.2344-1-lirongqing@baidu.com> <20260820020715.2344-2-lirongqing@baidu.com> Content-Language: en-US From: Zhongqiu Han In-Reply-To: <20260820020715.2344-2-lirongqing@baidu.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODIxMDA2MSBTYWx0ZWRfX8jKaxl/b118m wUJlWGZWg3m5lzITfI9uJRBbfQoCdrTkMGOnXcSjyUyZ6gOpselMq0V7aoxMiMJ/0Bb933z2lto ULqRgVtF/SISR6/CPBoLuy2VUNUqlrwCzZu7zQ1mZdF6NUm6S2jbv+uFYwTn5b+rfFtSanfXhoX zYAjUpz2ctIxc1lg8A0j/NgYTidBBlYUrKXvlfOjARJmpsSxfp4I/YAp1ySJMZ94J/IrTZ+crCt isSxooBxdExKgAA6J30OvniOwLMaLt2DYyqF5Teci5s/c8aeHTD37RCVfYXgNo8eg6tjuV5F7ac +CKqDbxK13vOAvLgp485VpdWOymsOlcmqXEF9qE4VPaBiNNfBG+lhIPeZ1CCm0bV881SyO9SLg3 mrNOdpRrV5lhUaRpAbSkjZEWyFHbiDXvOs3SI3eN8HlJQ11yWlHLu/CFiu72VH+0/yAsDIDr0vq 3s20RwGzJrFfkZ8dWuw== X-Authority-Analysis: v=2.4 cv=e/s2j6p/ c=1 sm=1 tr=0 ts=6a880da4 cx=c_pps a=oF/VQ+ItUULfLr/lQ2/icg==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=zuLzuavZAAAA:8 a=EUspDBNiAAAA:8 a=859UagAclvumeDjhmZYA:9 a=QEXdDO2ut3YA:10 a=3WC7DwWrALyhR5TkjVHa:22 X-Proofpoint-GUID: eC9y5Gmv-yoeaqZdkhYNJPrcGywynly8 X-Proofpoint-Spam-Info: AW1haW4tMjYwODIxMDA2MSBTYWx0ZWRfX/h5mOWprZdJB TCvoc0RotWPTMldV/G9Y8QC2mJbduGeX+FOcuJLdNmxXNCB0efxdoC1buo/9YSMxUrgPLLRUzpG nP2p4/vshxtKVxvHqM/Lu6RdtcRA94Y= X-Proofpoint-ORIG-GUID: eC9y5Gmv-yoeaqZdkhYNJPrcGywynly8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-21_02,2026-08-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 impostorscore=0 suspectscore=0 spamscore=0 phishscore=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608210061 On 8/20/2026 10:07 AM, lirongqing wrote: > From: Li RongQing > > When policy->freq_table is built in acpi_cpufreq_cpu_init(), entries > with duplicate frequencies are skipped. For each remaining entry, To be precise for applying if needed. "entries with duplicate frequencies are skipped. --> entries that are not lower in frequency than the previous one are skipped." > 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 retries the check for all > iterations before returning -EAGAIN, Small nit, just for applying if needed. "It then retries the check for all iterations before returning -EAGAIN," --> "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 > --- > drivers/cpufreq/acpi-cpufreq.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c > index 10ea603..a797bb2 100644 > --- a/drivers/cpufreq/acpi-cpufreq.c > +++ b/drivers/cpufreq/acpi-cpufreq.c > @@ -197,14 +197,13 @@ static unsigned extract_io(struct cpufreq_policy *policy, u32 value) > { > 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; > } > -- Thx and BRs, Zhongqiu Han