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 B982A43A80E for ; Mon, 17 Aug 2026 13:34:09 +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=1786973656; cv=none; b=VBXqXmkD877gmmQG+grc+B0/EgIYIM0iqmoJqzn0EYasL143PDuXkARVXnWC24OjrFtj8fADz7oi4C7H857q/KGVTpEb/pjzHO1HiStUQZo17LhXdg29lEP2ounlaiMgB9GpGmBQ1UzX3pzhFNv0PrUOWQYb+rBMr5bPVzdmDpM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786973656; c=relaxed/simple; bh=FGuszqknZFozF7pKzpAoA04EqrXSP2JnLU572u497H0=; h=Message-ID:Date:MIME-Version:Subject:To:References:From:Cc: In-Reply-To:Content-Type; b=LIjSFg3f44fAPuJVemPyNri9Nxvdnh2fCXJMDCG2sAggEY488VRh0CYlJ52YkHe5sQnBcjl4hWq9cDNiXQS9OiEgAqJpmVhsh6BsZShuEhHcoD+SdvAvRqia1jq1kDYnuFRo6dwprgtbMxUciUx10h4OcDPOYaVn7NHMb4X1+p4= 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=ATMbm9u+; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=J1vo5uAA; 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="ATMbm9u+"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="J1vo5uAA" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67HD69ux2330012 for ; Mon, 17 Aug 2026 13:34:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= iWD3BGVe7Jxn1EGjVKUV/jvwmRStEg8cJXdcbwX3Hvs=; b=ATMbm9u+4AcFkAJx MYzc3VNuFi7GZdikG+AkyOI8Ndw0fu1pqVPltKtmuZztI4kBCHn7EqdgFdtdQqMU SqOuE6U5JkiPsawIeAK+/Hu45Mc26wwP35XSvWOT0mCczVGlTqfaBIByNq3m2QzN Vqe1qRJ/rlxMcoIU0RpRCUHdi9ZSsrnT4mkZZzgdQgNUOSuYEeHQBudZVbtTOc6M beGGu0GeDwOP9bN459TGQlSBYiqZp/T7OIt0KLREd92fM6bpw9BYdBv9iCg164Fz DULWcfx/XRHweSEzzYUai9Mo5Y6rZkrXGBMOHJwJPtamyt2b8i01VgVAA06U9mmb Xy4Lwg== Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g3vghsuj6-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 17 Aug 2026 13:34:05 +0000 (GMT) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-381250979d5so3450618a91.0 for ; Mon, 17 Aug 2026 06:34:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1786973645; x=1787578445; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:cc: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=iWD3BGVe7Jxn1EGjVKUV/jvwmRStEg8cJXdcbwX3Hvs=; b=J1vo5uAAIK66ZZDJ76+jdFIzT+hvFGWRsTO8WgYEjEdYEq9CB32xZQRDqptn/NjFXb iTzl/KpexjpVTcFpX/3Sew4B89ulBIbgr/6WIGjmwfAgbzi25wkU79j43JcD4Fh9KK4f jTEJmJjxcbnFzHKlKGXw45AZ+yMB2QSrBrgeou1sQegIxgUDje16DMn3hs/06/zFX38h wifeY2WYNBQAHEYBJC/3/AoQRA771D5XP5SdXX2ZRx3uSji0ycBt7S9xbi2XiDfPd4mD 8DCqt+FEE0IuiYlE0Tfpxe0+6CTKJhpEkrkSkbWZD4ZWGP0wY6z1iTNmN+tjcqcOX/uQ SalA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786973645; x=1787578445; h=content-transfer-encoding:content-type:in-reply-to:cc: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=iWD3BGVe7Jxn1EGjVKUV/jvwmRStEg8cJXdcbwX3Hvs=; b=aU2TJf1tGRtQL0gZNxtSKGR3fwW9tZv6a0lnauUs6ybfdDR8491rgBR4qsDEVgoUIG 8BdKpR5JU9LJyi6wjloqACnrZ1fFgZbIvesZyMTOMI09zO7kepqdsEv610pIOpC4oFb3 tG3w8xmcOCZZvGx/6LGgvD/YFphaiOH6hK88okM/zEdjY6BLX6hK2hiiF7zEKYouFqDO 7wnG3XkU0zrKFImi4/x4KyujjXHTIR6tkG4zLPkACUvSap9s6i1z67BjcO1pYk9XXHAz OFUUGeZEYAsjdXUZG5AV/JlvCv10+ctPgYsEc4ivvu3cR49IR5vgAT/qJL+STKxpMHYf PE/Q== X-Forwarded-Encrypted: i=1; AHgh+RqaqWLh5Akzf/hvkeXSXBbgADqvTqhPXqu4XKUmk7yRy8CZXROdhQDYkxdx1Tld5cGNHgx7YwOBfn3VdPI=@vger.kernel.org X-Gm-Message-State: AOJu0YyuIiPn73nJSdYROlthQyah4Ed7PU+e5KL66/8K7wq6Umc2Mba9 +Y80OyR7Q4iRXY/dEsUHLTHY4Rl8Ha53SoDKOA+5VjqE0mcysQT0BJz8KxZIfie8snN4xDlUpZO wRSaEobeW5a/o060oO9N2TKEQuhxp+epsttvAWxmdKhygEZOcPnXbGgojvjK5feiAScE= X-Gm-Gg: AR+sD13kEivA0N580NTEF+NcwCtrckfKOg7OQHHxOYsxIwDA0UCZ2w51a4xKPLj1N8t sE/WTDWWaHZ/tfJQZYSUUp/pd2LniEh5Z7bn9BMMesp9kUhjslk/Vwbybj+/Li9H727IRzxOvAR SIh+HCg3RiUPD38F8nujgXDfpTiugK3oOQgV2UOknYFbURjAnijSxnI4GYFmrb/G+gYejcPj+H0 EyeG5QhOjzZ9i7mLaeM6Mm5jQzMot3HxCoyjNuyY+tCubCOHgiGiV+EvjDQ7DC9bqhTZtVCYi+D Q4E4Yib35Bc85d5FGOZvJSCk74bE+Q8bTxqp+9EcEPD15iQfSBDqcXb6hvzkKHAUxumFq3ow38R Rs+GceSAnPjTkcCQrRh3Skrv7YFHvMJxHh9zT3Jzdl0KOfL5DCdFgTesZVgN9rjB7b/uLNjM= X-Received: by 2002:a17:90b:2d92:b0:36b:77b9:5c8c with SMTP id 98e67ed59e1d1-3933babae61mr26190136a91.17.1786973644576; Mon, 17 Aug 2026 06:34:04 -0700 (PDT) X-Received: by 2002:a17:90b:2d92:b0:36b:77b9:5c8c with SMTP id 98e67ed59e1d1-3933babae61mr26190069a91.17.1786973643937; Mon, 17 Aug 2026 06:34:03 -0700 (PDT) Received: from [10.133.33.95] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39339b1edb2sm5424828a91.0.2026.08.17.06.34.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Aug 2026 06:34:03 -0700 (PDT) Message-ID: Date: Mon, 17 Aug 2026 21:33:59 +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 v2 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 References: <20260813090145.2450-1-lirongqing@baidu.com> <20260813090145.2450-2-lirongqing@baidu.com> Content-Language: en-US From: Zhongqiu Han Cc: zhongqiu.han@oss.qualcomm.com In-Reply-To: <20260813090145.2450-2-lirongqing@baidu.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Authority-Analysis: v=2.4 cv=P9gKQCAu c=1 sm=1 tr=0 ts=6a830dcd cx=c_pps a=vVfyC5vLCtgYJKYeQD43oA==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=zuLzuavZAAAA:8 a=B83gT7kL6Ddqc7TX8wIA:9 a=QEXdDO2ut3YA:10 a=rl5im9kqc5Lf4LNbBjHf:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwODE3MDEwMyBTYWx0ZWRfX5gQCEmZHhHco vsabsangdMC1m6QRfxpKErd/Y1tXsKBgSaoA4/ZxMZpA22WP/902trWolYBnt3vH8qqg8g3nqhN ZkpbJquYeqOr5XF+nhxgjbJqM5QZYDo= X-Proofpoint-ORIG-GUID: Bue-ufMlw7fdEbK6oQCyIHeMyM9TfPSE X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODE3MDEwMyBTYWx0ZWRfX+RxPfS55I3Tk LfcT8CAyoc2hqyAc9PGtYGA6+XnHKYooSR+ChG05JTOa0ysXRqYRTST1RGXH+yI6lpuaek1yirb MWW7Mary6JwubzoDoQOk+NUEYO0M583/Ipn5NKsS4st1vaeuAMJ8CXwDbGXP4PcJur8Ua/iWhzi gQXwHQ93EWkcX2MD76uorcCGLwtDQGoK1MdtkhXkKOhy849LIGFO5FrURuFKSJRHn8FmTzvjrdz g3zj81sPCCA9hZfHE+CLMlk+6DPJqZNF0fWG7s+R46K73sS1jcAzACWkNS4WV3/cqrksJQche3H 6ZbkGBBueUv8bdujob/Y2QxaWW/4pZvN7sTO4OAVV4y7N0mdg3IZ6ahuPPBb2ohN64IH11uCkKI Vy1+XJl0X/AHoxrRKRDNTQXO6cIF5AjZ+KEusrzWLlYo7u/MErWLsCfXRK6bFLU0iTX8Q66Bhqn ShmHfPloa0r52990gfQ== X-Proofpoint-GUID: Bue-ufMlw7fdEbK6oQCyIHeMyM9TfPSE 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-17_01,2026-08-12_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608170103 On 8/13/2026 5:01 PM, lirongqing wrote: > From: Li RongQing > > When policy->freq_table is built in acpi_cpufreq_cpu_init(), entries > with duplicate frequencies are skipped. The original P-state index for > each remaining entry is stored in freq_table[].driver_data, so the index > space of freq_table no longer matches perf->states[]. > > extract_io() walks perf->states[] with index i and uses the same i to > index policy->freq_table[i]. This causes two problems when duplicate > frequencies exist: > > - Returning the frequency of the wrong P-state > - Returning 0 from a zeroed tail entry, or even CPUFREQ_TABLE_END > (~1u) reported as 0xfffffffe kHz AFAICT, It may be worth expanding the changelog to cover the consequences described below , particularly the resulting divergence between the hardware state and the cpufreq core's view of the current frequency: Furthermore, extract_io() is only reachable on ACPI_ADR_SPACE_SYSTEM_IO platforms, where cpufreq_driver->get is not installed, so its only caller in practice is check_freqs(), i.e. only when the acpi_pstate_strict module parameter is set. There, the mismatched lookup makes the frequency comparison fail even though drv_write() has already switched the hardware to the requested P-state. So check_freqs() 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. perf ->state is therefore left at its previous value while the hardware sits at the new one. The core then restores policy->cur to the old frequency, and because __cpufreq_driver_target() returns early when the requested frequency equals policy->cur, the driver is not called again for it - so the control register is not rewritten and the CPU is left running at a frequency the core does not know about. > > Fix it by walking policy->freq_table with cpufreq_for_each_entry() and > using perf->states[pos->driver_data].status, aligning with extract_msr(). > > Fixes: 8cee1eed8e78 ("cpufreq: ACPI: Remove freq_table from acpi_cpufreq_data") The real tag should be fe27cb358835 ("[CPUFREQ][2/8] acpi: reorganize code to make MSR support addition easier") That commit added both the entry-skipping loop with the freq_table[].index (now .driver_data) back-pointer, which is what makes the two indices diverge, and the faulty lookup itself -- back then in a function called extract_freq(). dde9f7ba60ad ("[CPUFREQ][3/8] acpi cpufreq: Pull in MSR based transition support") merely renamed it to extract_io(). > Signed-off-by: Li RongQing > --- > 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 21639d9..1abe9ab 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