mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: lirongqing <lirongqing@baidu.com>
Cc: Hans de Goede <hansg@kernel.org>,
	 Kristen Carlson Accardi <kristen.c.accardi@intel.com>,
	 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	 Tero Kristo <tero.kristo@linux.intel.com>,
	 Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	 platform-driver-x86@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] platform/x86/intel/tpmi: Clean up CPU mappings on offline
Date: Mon, 16 Nov 2026 13:02:18 +0200 (EET)	[thread overview]
Message-ID: <d5f8b43f-5d42-62bc-b233-9645a3708472@linux.intel.com> (raw)
In-Reply-To: <20261114142914.2595-1-lirongqing@baidu.com>

On Sat, 14 Nov 2026, lirongqing wrote:

> From: Li RongQing <lirongqing@baidu.com>
> 
> The driver adds each online CPU to tpmi_cpu_hash and to its power domain
> mask. Neither entry is removed when the CPU goes offline, so the next
> online transition calls hash_add() on an hlist node that is still
> linked, corrupting the hash list.
> 
> Register an offline callback that removes the hash entry and clears the
> CPU from its power domain mask.
> 
> The TPMI feature does not depend on CPU online/offline and can update the
> MMIO area while a CPU is offline. There is currently no consumer that
> reads the mapping data of an offlined CPU; if such a use case appears,
> retaining the offline mapping can be added on top.
> 
> Fixes: 17ca2780458c ("platform/x86/intel: TPMI domain id and CPU mapping")
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
> Changes in v2:
> 
> - Add Acked-by from Srinivas Pandruvada
> - Rename the title
> - Add a new line after guard()
> 
>  drivers/platform/x86/intel/tpmi_power_domains.c | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/intel/tpmi_power_domains.c b/drivers/platform/x86/intel/tpmi_power_domains.c
> index ebe052c..457abac 100644
> --- a/drivers/platform/x86/intel/tpmi_power_domains.c
> +++ b/drivers/platform/x86/intel/tpmi_power_domains.c
> @@ -220,6 +220,24 @@ 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;

Hi,

I've taken this patch into the review-ilpo-next branch.

...But could you make another patch on top of it which adds a helper for 
this index calculation (from the tpmi_cpu_info struct, the one in 
tpmi_get_linux_die_id() seems to not have it so it can be left as is).
It seems to be repeated a few times and is quite long, online func even 
calculates it twice.

-- 
 i.

> +
> +	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 +267,7 @@ static int __init tpmi_init(void)
>  
>  	ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
>  				"platform/x86/tpmi_power_domains:online",
> -				tpmi_cpu_online, NULL);
> +				tpmi_cpu_online, tpmi_cpu_offline);
>  	if (ret < 0)
>  		goto free_domain_map;
>  
> 

-- 
 i.


      reply	other threads:[~2026-11-16 11:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14 14:29 lirongqing
2026-11-16 11:02 ` Ilpo Järvinen [this message]

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=d5f8b43f-5d42-62bc-b233-9645a3708472@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=hansg@kernel.org \
    --cc=kristen.c.accardi@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lirongqing@baidu.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=srinivas.pandruvada@linux.intel.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®