From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: lirongqing <lirongqing@baidu.com>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Kristen Carlson Accardi" <kristen.c.accardi@intel.com>,
"Tero Kristo" <tero.kristo@linux.intel.com>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH] platform/x86: TPMI: clean up CPU mappings on offline
Date: Wed, 04 Nov 2026 07:30:13 -0800 [thread overview]
Message-ID: <245eea039c692d03736fcf2ca2448a271fa135ce.camel@linux.intel.com> (raw)
In-Reply-To: <20261104032724.1824-1-lirongqing@baidu.com>
On Wed, 2026-11-04 at 11:27 +0800, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
>
> The TPMI power domain driver adds each online CPU to a hash table and
> its power domain mask, but does not remove either entry when the CPU
> goes offline. Bringing a CPU back online can therefore insert the
> same
> hlist node again and leave stale CPU mask state.
>
> Register an offline callback that removes the hash entry and clears
> the
> CPU from its power domain mask.
>
Hi RonQing,
Thanks for the patch.
TPMI feature doesn't depend on CPU online/offline and can update MMIO
while CPU is offline.
Instead of adding a offline callback, can we just do the below if the
cost of search is not high?
diff --git a/drivers/platform/x86/intel/tpmi_power_domains.c
b/drivers/platform/x86/intel/tpmi_power_domains.c
index d89b9894c42a..dadd5fc5719f 100644
--- a/drivers/platform/x86/intel/tpmi_power_domains.c
+++ b/drivers/platform/x86/intel/tpmi_power_domains.c
@@ -201,6 +201,8 @@ static int tpmi_get_logical_id(unsigned int cpu,
struct tpmi_cpu_info *info)
static int tpmi_cpu_online(unsigned int cpu)
{
struct tpmi_cpu_info *info = &per_cpu(tpmi_cpu_info, cpu);
+ struct tpmi_cpu_info *entry;
+ bool found = false;
int ret, index;
/* Don't fail CPU online for some bad mapping of CPUs */
@@ -212,7 +214,14 @@ static int tpmi_cpu_online(unsigned int cpu)
guard(mutex)(&tpmi_lock);
cpumask_set_cpu(cpu, &tpmi_power_domain_mask[index]);
- hash_add(tpmi_cpu_hash, &info->hnode, info->punit_core_id);
+ hash_for_each_possible(tpmi_cpu_hash, entry, hnode, info-
>punit_core_id) {
+ if (entry == info) {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ hash_add(tpmi_cpu_hash, &info->hnode, info-
>punit_core_id);
domain_die_map[info->pkg_id * MAX_POWER_DOMAINS + info-
>punit_domain_id] =
topology_die_id(cpu);
Thanks,
Srinivas
> Fixes: 17ca2780458c ("platform/x86/intel: TPMI domain id and CPU
> mapping")
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> ---
> drivers/platform/x86/intel/tpmi_power_domains.c | 19
> ++++++++++++++++++-
> 1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/intel/tpmi_power_domains.c
> b/drivers/platform/x86/intel/tpmi_power_domains.c
> index d89b989..c3fd1bd 100644
> --- a/drivers/platform/x86/intel/tpmi_power_domains.c
> +++ b/drivers/platform/x86/intel/tpmi_power_domains.c
> @@ -220,6 +220,23 @@ static int tpmi_cpu_online(unsigned int cpu)
> return 0;
> }
>
> +static int tpmi_cpu_offline(unsigned int cpu)
> +{
> + struct tpmi_cpu_info *info = &per_cpu(tpmi_cpu_info, cpu);
> + int index;
> +
> + if (hlist_unhashed(&info->hnode) ||
> !tpmi_domain_is_valid(info))
> + return 0;
> +
> + index = info->pkg_id * MAX_POWER_DOMAINS + info-
> >punit_domain_id;
> +
> + guard(mutex)(&tpmi_lock);
> + cpumask_clear_cpu(cpu, &tpmi_power_domain_mask[index]);
> + hash_del(&info->hnode);
> +
> + return 0;
> +}
> +
> static int __init tpmi_init(void)
> {
> const struct x86_cpu_id *id;
> @@ -249,7 +266,7 @@ static int __init tpmi_init(void)
>
> ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
> "platform/x86/tpmi_power_domains:onl
> ine",
> - tpmi_cpu_online, NULL);
> + tpmi_cpu_online, tpmi_cpu_offline);
> if (ret < 0)
> goto free_domain_map;
>
next prev parent reply other threads:[~2026-11-04 15:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 3:27 [PATCH] platform/x86: TPMI: clean up CPU mappings on offline lirongqing
2026-11-04 15:30 ` Srinivas Pandruvada [this message]
2026-11-05 3:09 ` 答复: [外部邮件] " Li,Rongqing
2026-11-05 16:00 ` srinivas pandruvada
2026-11-04 15:39 ` Andy Shevchenko
2026-11-12 23:49 ` srinivas pandruvada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=245eea039c692d03736fcf2ca2448a271fa135ce.camel@linux.intel.com \
--to=srinivas.pandruvada@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=kristen.c.accardi@intel.com \
--cc=lirongqing@baidu.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=tero.kristo@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.