From nobody Tue Dec 2 00:03:45 2025 Received: from canpmsgout01.his.huawei.com (canpmsgout01.his.huawei.com [113.46.200.216]) (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 69ED52D23BC; Tue, 25 Nov 2025 07:29:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.216 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764055799; cv=none; b=sc997A7CDtHlwe9d9hgTNwHRsEYQ/p1cB2R2ktoCzX/aDQq8ykPMom/VuhIjyr5tFDpq3VIfBYJK6Yd1RfeEc9nOERQV5fXKiGIJESTluo3eeII1okbc3ZYXQpXQ6F+ZyElSlDJLR02gB+JdJrsQ/lbLxw5F7RlaRFxm1Yqq8sA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764055799; c=relaxed/simple; bh=X5/3gdJkRcceYG/DfbiK9+cgdMpYw8zbaZBPlRdOy9Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eGZUcPChtCFCpGm8rZhxhU01JmKtiTUsIspz9zXbbTpdsMw9ThpdE/qmrfXCkwVn2aHgiu/O3MMVk9ejUZ99a3DVGMHwuLbE4Bi+wLOaZM3CAzt0InkluabbG4DrU9CWW0GZA2c2lb4zs7K0+YLKuD9d6+zfIRDVuCswchoSKnI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=h-partners.com; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b=qkqy9a8a; arc=none smtp.client-ip=113.46.200.216 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=h-partners.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b="qkqy9a8a" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=WiROCxrBtPQla3s66UVcRJVDrGmGEpn6T44vNOJN7to=; b=qkqy9a8au8DOLsrCNVO1RkMKqzHos3hl0X0VU+elZpG9y7qQ2omg2z3hkQcgj2jfbcfSUo+Xg LVmeni04hO6xHlwmfeA8Kuq1CbyU9MWEvikxGEND15vcuMF2c042PFcEsB8wsjLyVcpLX2+eaBp 01NNktda3jKAZ4Ixi6UaMf4= Received: from mail.maildlp.com (unknown [172.19.163.252]) by canpmsgout01.his.huawei.com (SkyGuard) with ESMTPS id 4dFvRq11Crz1T4J7; Tue, 25 Nov 2025 15:28:07 +0800 (CST) Received: from dggemv712-chm.china.huawei.com (unknown [10.1.198.32]) by mail.maildlp.com (Postfix) with ESMTPS id 69E49180B3F; Tue, 25 Nov 2025 15:29:48 +0800 (CST) Received: from kwepemn100009.china.huawei.com (7.202.194.112) by dggemv712-chm.china.huawei.com (10.1.198.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 25 Nov 2025 15:29:35 +0800 Received: from localhost.localdomain (10.50.163.32) by kwepemn100009.china.huawei.com (7.202.194.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Tue, 25 Nov 2025 15:29:34 +0800 From: Huisong Li To: , CC: , , , , , , , , Subject: [PATCH 1/3] cpuidle: Add enable_cpuidle() interface Date: Tue, 25 Nov 2025 15:29:31 +0800 Message-ID: <20251125072933.3706006-2-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20251125072933.3706006-1-lihuisong@huawei.com> References: <20251125072933.3706006-1-lihuisong@huawei.com> 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 X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To kwepemn100009.china.huawei.com (7.202.194.112) Content-Type: text/plain; charset="utf-8" The global switch of cpuidle can be turned back on in some case. So add enable_cpuidle(). Signed-off-by: Huisong Li --- drivers/cpuidle/cpuidle.c | 5 ++++- include/linux/cpuidle.h | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 56132e843c99..980ddfd3d930 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -48,7 +48,10 @@ void disable_cpuidle(void) { off =3D 1; } - +void enable_cpuidle(void) +{ + off =3D 0; +} bool cpuidle_not_available(struct cpuidle_driver *drv, struct cpuidle_device *dev) { diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index a9ee4fe55dcf..94c030748af3 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -168,6 +168,7 @@ struct cpuidle_driver { }; =20 #ifdef CONFIG_CPU_IDLE +extern void enable_cpuidle(void); extern void disable_cpuidle(void); extern bool cpuidle_not_available(struct cpuidle_driver *drv, struct cpuidle_device *dev); @@ -203,6 +204,7 @@ extern struct cpuidle_driver *cpuidle_get_cpu_driver(st= ruct cpuidle_device *dev) static inline struct cpuidle_device *cpuidle_get_device(void) {return __this_cpu_read(cpuidle_devices); } #else +static inline void enable_cpuidle(void) { } static inline void disable_cpuidle(void) { } static inline bool cpuidle_not_available(struct cpuidle_driver *drv, struct cpuidle_device *dev) --=20 2.33.0 From nobody Tue Dec 2 00:03:45 2025 Received: from canpmsgout11.his.huawei.com (canpmsgout11.his.huawei.com [113.46.200.226]) (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 B00A7277C9D; Tue, 25 Nov 2025 07:29:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.226 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764055782; cv=none; b=B/uA0jdrVuDGiSroAOfRD2tRWk6mJcjchhY+/UUVpiZE0rHdFvqtS8K/8rOYwQMxteSA6FEuTMIjdZ6SOqVzUNMTsV7MSVyeJshqIC2FKNp4W4N8T7Nn6mAqKpvsehGRPlzjHbCePUyqqNY7uoZMWkNVvyKM76kIvHSJMJOrfik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764055782; c=relaxed/simple; bh=DtIRHZYQlefCOCKKA1gI9C2LJXsiG17trnRZFBgYGNI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OQJopDaiEKDK5ptllNpATxxBCzaPa7hsHciH4FdNfeN7TYVKcSTfCG+XmQvwB/o/YGEXpE+Sy79mVtcFA/uhb6tLB8dvoZisXO1fNzZYaznlQPoXYz5PfxFVQEFHdgfJw63zRiW6P8EPLvx6eiEmbyVnuJFvdqNYI/IbCNIxqVw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=h-partners.com; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b=o+6dKQ+k; arc=none smtp.client-ip=113.46.200.226 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=h-partners.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b="o+6dKQ+k" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=zlMmNKdqNyikz+CDppi5yO3MNdJ8QEte/0cAyLq9xNo=; b=o+6dKQ+kkHtp1xYwh/l4ggKyGH6s2WjcDvOefr/YKQWeXgRN6lq12szPJR82Z7zQn6p+do2E/ OODVeHR3rrtk6F1RSdN4qKvJc3YrSsMLZ+HLgi8WLaZh45Md3bu/i1FRGc3hh9OnCdFeoaBRuwk 2tihbSz1PZJkTyRD37o91aQ= Received: from mail.maildlp.com (unknown [172.19.162.112]) by canpmsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4dFvRS233KzKm4X; Tue, 25 Nov 2025 15:27:48 +0800 (CST) Received: from dggemv705-chm.china.huawei.com (unknown [10.3.19.32]) by mail.maildlp.com (Postfix) with ESMTPS id 393E2140230; Tue, 25 Nov 2025 15:29:36 +0800 (CST) Received: from kwepemn100009.china.huawei.com (7.202.194.112) by dggemv705-chm.china.huawei.com (10.3.19.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 25 Nov 2025 15:29:36 +0800 Received: from localhost.localdomain (10.50.163.32) by kwepemn100009.china.huawei.com (7.202.194.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Tue, 25 Nov 2025 15:29:35 +0800 From: Huisong Li To: , CC: , , , , , , , , Subject: [PATCH 2/3] ACPI: processor: idle: Disable ACPI idle if get power information failed in power notify Date: Tue, 25 Nov 2025 15:29:32 +0800 Message-ID: <20251125072933.3706006-3-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20251125072933.3706006-1-lihuisong@huawei.com> References: <20251125072933.3706006-1-lihuisong@huawei.com> 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 X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To kwepemn100009.china.huawei.com (7.202.194.112) Content-Type: text/plain; charset="utf-8" The old states may not be usable any more if get power information failed in power notify. The ACPI idle should be disabled entirely. Fixes: f427e5f1cf75 ("ACPI / processor: Get power info before updating the = C-states") Signed-off-by: Huisong Li --- drivers/acpi/processor_idle.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 5f86297c8b23..cd4d1d8d70b0 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -1298,6 +1298,7 @@ int acpi_processor_power_state_has_changed(struct acp= i_processor *pr) int cpu; struct acpi_processor *_pr; struct cpuidle_device *dev; + int ret =3D 0; =20 if (disabled_by_idle_boot_param()) return 0; @@ -1326,27 +1327,44 @@ int acpi_processor_power_state_has_changed(struct a= cpi_processor *pr) cpuidle_disable_device(dev); } =20 - /* Populate Updated C-state information */ - acpi_processor_get_power_info(pr); + /* + * Update C-state information based on new power information. + * + * The same idle state is used for all CPUs. + * The old idle state may not be usable anymore if fail to get + * ACPI power information of CPU0. + * The cpuidle of all CPUs should be disabled. + */ + ret =3D acpi_processor_get_power_info(pr); + if (ret) { + /* Ensure cpuidle of offline CPUs are inavaliable. */ + disable_cpuidle(); + pr_err("Get processor-%u power information failed, disable cpuidle of a= ll CPUs\n", + pr->id); + goto release_lock; + } + acpi_processor_setup_cpuidle_states(pr); + enable_cpuidle(); =20 /* Enable all cpuidle devices */ for_each_online_cpu(cpu) { _pr =3D per_cpu(processors, cpu); if (!_pr || !_pr->flags.power_setup_done) continue; - acpi_processor_get_power_info(_pr); - if (_pr->flags.power) { + ret =3D acpi_processor_get_power_info(_pr); + if (!ret && _pr->flags.power) { dev =3D per_cpu(acpi_cpuidle_device, cpu); acpi_processor_setup_cpuidle_dev(_pr, dev); cpuidle_enable_device(dev); } } +release_lock: cpuidle_resume_and_unlock(); cpus_read_unlock(); } =20 - return 0; + return ret; } =20 void acpi_processor_register_idle_driver(void) --=20 2.33.0 From nobody Tue Dec 2 00:03:45 2025 Received: from canpmsgout02.his.huawei.com (canpmsgout02.his.huawei.com [113.46.200.217]) (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 5AD6B2D73A9; Tue, 25 Nov 2025 07:29:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.217 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764055781; cv=none; b=YJOCK7BoOG3u7qOu6hm8aR4m6x2hw39k3UBvfvVsbIZmQvZe6wa5um1x3pevi2p5nf+fPcT3FNgyaw9tgiV9sS1bKoGmM6kN3sA4V6EFeRUUsFqehg4cjsGpTCC9orK5WyzWxA15uYOinZadA42ZHBiqXCLaEs9yDE6KI5JWfAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764055781; c=relaxed/simple; bh=teSNBsRwcRRwniPEDYSxcu3kWy7IPtFhJxEjSGZwADo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oas5F7LF+uX+XHEruSekO+a2XttMo6XhH8BKodURiweg+ckvuAKMnGk3lrxy49VJIdMP9HMBuSolePXeORuYUU91sJhi5DcWdjgS5FpE8fQBT96tc3rNyM7zK2jxickvTYriRBL5KJa44beXtN8LSN8zLoTYjqXEtGqTWPVTRZs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=h-partners.com; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b=JjwnHsMd; arc=none smtp.client-ip=113.46.200.217 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=h-partners.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b="JjwnHsMd" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=F4LQMeD2kHahQ+1nrC+W98OH/wc9EAR9nP6PI06pBgQ=; b=JjwnHsMd/YQmZmbQAerSzyVF7La1XUJTn3RjVH/oo2ECvqBGnyz/5vNmT4mhLn5nrEKMi3bwK xSnosaN+KYmTQ55sZbCZAvo3C5nBF1hb1hAnvSwft4J64W+njuFlYM7TB5kYmfHjccvASFEBXn2 tWp2o/RQ8iwZ0Z6ZpYTm1zg= Received: from mail.maildlp.com (unknown [172.19.88.105]) by canpmsgout02.his.huawei.com (SkyGuard) with ESMTPS id 4dFvQz4lBRzcZxk; Tue, 25 Nov 2025 15:27:23 +0800 (CST) Received: from dggemv706-chm.china.huawei.com (unknown [10.3.19.33]) by mail.maildlp.com (Postfix) with ESMTPS id BD8241402C1; Tue, 25 Nov 2025 15:29:36 +0800 (CST) Received: from kwepemn100009.china.huawei.com (7.202.194.112) by dggemv706-chm.china.huawei.com (10.3.19.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 25 Nov 2025 15:29:36 +0800 Received: from localhost.localdomain (10.50.163.32) by kwepemn100009.china.huawei.com (7.202.194.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Tue, 25 Nov 2025 15:29:35 +0800 From: Huisong Li To: , CC: , , , , , , , , Subject: [PATCH 3/3] ACPI: processor: idle: Update idle states from avaiable power information Date: Tue, 25 Nov 2025 15:29:33 +0800 Message-ID: <20251125072933.3706006-4-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20251125072933.3706006-1-lihuisong@huawei.com> References: <20251125072933.3706006-1-lihuisong@huawei.com> 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 X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To kwepemn100009.china.huawei.com (7.202.194.112) Content-Type: text/plain; charset="utf-8" Currently, the ACPI power notify makes it once per system instead of once p= er-cpu. And driver selects the notify on CPU0 to update idle states. The same idle state is used for all CPUs. An avaiable power information is obtained successfully from any CPUs can be used to populate the ACPI idle states as acpi_processor_register_idle_driver() did. So keep the same logical to get avaiable power information from online CPUs instead of CPU0 to update idle states in power notify. Signed-off-by: Huisong Li --- drivers/acpi/processor_idle.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index cd4d1d8d70b0..8d3122a4e6d0 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -1332,19 +1332,26 @@ int acpi_processor_power_state_has_changed(struct a= cpi_processor *pr) * * The same idle state is used for all CPUs. * The old idle state may not be usable anymore if fail to get - * ACPI power information of CPU0. + * available ACPI power information from any online CPU. * The cpuidle of all CPUs should be disabled. */ - ret =3D acpi_processor_get_power_info(pr); + ret =3D -ENODEV; + for_each_online_cpu(cpu) { + _pr =3D per_cpu(processors, cpu); + if (!_pr && !_pr->flags.power_setup_done) + continue; + ret =3D acpi_processor_get_power_info(_pr); + if (!ret) { + acpi_processor_setup_cpuidle_states(_pr); + break; + } + } if (ret) { /* Ensure cpuidle of offline CPUs are inavaliable. */ disable_cpuidle(); - pr_err("Get processor-%u power information failed, disable cpuidle of a= ll CPUs\n", - pr->id); + pr_err("No available ACPI power information, disable cpuidle of all CPU= s.\n"); goto release_lock; } - - acpi_processor_setup_cpuidle_states(pr); enable_cpuidle(); =20 /* Enable all cpuidle devices */ --=20 2.33.0