* [PATCH] platform/x86/intel/tpmi/plr: Fix CPU selection on partitioned systems
@ 2026-11-25 9:22 Qinyun Tan
2026-11-25 17:49 ` Srinivas Pandruvada
0 siblings, 1 reply; 2+ messages in thread
From: Qinyun Tan @ 2026-11-25 9:22 UTC (permalink / raw)
To: Ilpo Järvinen, Hans de Goede
Cc: Srinivas Pandruvada, Tero Kristo, platform-driver-x86,
linux-kernel, xlpang, Qinyun Tan
When a package has multiple TPMI partitions, PLR can report the same
CPUs in more than one partition. For example, on a single-package
system with 72 logical CPUs and two TPMI partitions, both partitions
list CPUs 0-35 in their PLR status files. CPUs 36-71 are missing.
Each partition numbers its PLR resources from zero. The driver compares
that index with the CPU's power domain ID from MSR_PM_LOGICAL_ID, which
is unique within the package. As a result, both partitions select the
same CPUs. A mailbox read or clear on the second partition then uses a
module ID taken from a CPU in the first partition.
Use the partition's cdie_mask to map each PLR resource to its package
power domain. For compatibility with older platforms, keep using the
resource index for partition 0 when no mask is available. Skip per-CPU
mailbox accesses if the resource has no valid CPU mapping.
Fixes: 9e9397a41b7b ("platform/x86/intel/tpmi/plr: Add support for the plr mailbox")
Signed-off-by: Qinyun Tan <qinyuntan@linux.alibaba.com>
---
Notes:
Tested on a single-package system with 72 logical CPUs and two TPMI
partitions. The PLR status files now list the CPUs belonging to each
partition.
drivers/platform/x86/intel/plr_tpmi.c | 31 ++++++++++++++++---
.../platform/x86/intel/tpmi_power_domains.c | 2 --
.../platform/x86/intel/tpmi_power_domains.h | 2 ++
3 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/drivers/platform/x86/intel/plr_tpmi.c b/drivers/platform/x86/intel/plr_tpmi.c
index 785c279b4540..33066f4763ef 100644
--- a/drivers/platform/x86/intel/plr_tpmi.c
+++ b/drivers/platform/x86/intel/plr_tpmi.c
@@ -51,7 +51,7 @@ struct tpmi_plr_die {
void __iomem *base;
struct mutex lock; /* Protect access to PLR mailbox */
int package_id;
- int die_id;
+ int power_domain_id;
struct tpmi_plr *plr;
};
@@ -201,10 +201,13 @@ static int plr_status_show(struct seq_file *s, void *unused)
seq_puts(s, "cpus");
plr_print_bits(s, val, 32);
+ if (plr_die->power_domain_id < 0)
+ return 0;
+
guard(mutex)(&plr_die->lock);
for (int cpu = 0; cpu < nr_cpu_ids; cpu++) {
- if (plr_die->die_id != tpmi_get_power_domain_id(cpu))
+ if (plr_die->power_domain_id != tpmi_get_power_domain_id(cpu))
continue;
if (plr_die->package_id != topology_physical_package_id(cpu))
@@ -241,10 +244,13 @@ static ssize_t plr_status_write(struct file *filp, const char __user *ubuf,
plr_write(0, plr_die, PLR_DIE_LEVEL);
+ if (plr_die->power_domain_id < 0)
+ return count;
+
guard(mutex)(&plr_die->lock);
for (int cpu = 0; cpu < nr_cpu_ids; cpu++) {
- if (plr_die->die_id != tpmi_get_power_domain_id(cpu))
+ if (plr_die->power_domain_id != tpmi_get_power_domain_id(cpu))
continue;
if (plr_die->package_id != topology_physical_package_id(cpu))
@@ -281,6 +287,23 @@ static void intel_plr_unregister_notifier(struct notifier_block *nb)
tpmi_unregister_notifier(nb);
}
+static int plr_power_domain_id(const struct oobmsm_plat_info *plat_info, int index)
+{
+ u16 mask = plat_info->cdie_mask;
+ int id = index;
+
+ /* Resource indices are relative to the partition's first compute die. */
+ if (mask)
+ id += __ffs(mask);
+ else if (plat_info->partition)
+ return -ENODEV;
+
+ if (id >= MAX_POWER_DOMAINS || (mask && !(mask & BIT(id))))
+ return -ENODEV;
+
+ return id;
+}
+
static int intel_plr_probe(struct auxiliary_device *auxdev, const struct auxiliary_device_id *id)
{
struct oobmsm_plat_info *plat_info;
@@ -340,7 +363,7 @@ static int intel_plr_probe(struct auxiliary_device *auxdev, const struct auxilia
plr->die_info[i].base = base;
plr->die_info[i].package_id = plat_info->package_id;
- plr->die_info[i].die_id = i;
+ plr->die_info[i].power_domain_id = plr_power_domain_id(plat_info, i);
plr->die_info[i].plr = plr;
mutex_init(&plr->die_info[i].lock);
diff --git a/drivers/platform/x86/intel/tpmi_power_domains.c b/drivers/platform/x86/intel/tpmi_power_domains.c
index ebe052c3bbe4..f6a46b4571ec 100644
--- a/drivers/platform/x86/intel/tpmi_power_domains.c
+++ b/drivers/platform/x86/intel/tpmi_power_domains.c
@@ -70,8 +70,6 @@ static DEFINE_PER_CPU(struct tpmi_cpu_info, tpmi_cpu_info);
/* The dynamically assigned cpu hotplug state to free later */
static enum cpuhp_state tpmi_hp_state __read_mostly;
-#define MAX_POWER_DOMAINS 8
-
static cpumask_t *tpmi_power_domain_mask;
static u16 *domain_die_map;
diff --git a/drivers/platform/x86/intel/tpmi_power_domains.h b/drivers/platform/x86/intel/tpmi_power_domains.h
index 2fd0dd7afbd2..43a80b526133 100644
--- a/drivers/platform/x86/intel/tpmi_power_domains.h
+++ b/drivers/platform/x86/intel/tpmi_power_domains.h
@@ -10,6 +10,8 @@
#include <linux/cpumask.h>
+#define MAX_POWER_DOMAINS 8
+
int tpmi_get_linux_cpu_number(int package_id, int die_id, int punit_core_id);
int tpmi_get_punit_core_number(int cpu_no);
int tpmi_get_power_domain_id(int cpu_no);
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
--
2.55.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] platform/x86/intel/tpmi/plr: Fix CPU selection on partitioned systems
2026-11-25 9:22 [PATCH] platform/x86/intel/tpmi/plr: Fix CPU selection on partitioned systems Qinyun Tan
@ 2026-11-25 17:49 ` Srinivas Pandruvada
0 siblings, 0 replies; 2+ messages in thread
From: Srinivas Pandruvada @ 2026-11-25 17:49 UTC (permalink / raw)
To: Qinyun Tan, Ilpo Järvinen, Hans de Goede
Cc: platform-driver-x86, linux-kernel, xlpang
On Wed, 2026-11-25 at 17:22 +0800, Qinyun Tan wrote:
> When a package has multiple TPMI partitions, PLR can report the same
> CPUs in more than one partition. For example, on a single-package
> system with 72 logical CPUs and two TPMI partitions, both partitions
> list CPUs 0-35 in their PLR status files. CPUs 36-71 are missing.
>
> Each partition numbers its PLR resources from zero. The driver
> compares
> that index with the CPU's power domain ID from MSR_PM_LOGICAL_ID,
> which
> is unique within the package. As a result, both partitions select the
> same CPUs. A mailbox read or clear on the second partition then uses
> a
> module ID taken from a CPU in the first partition.
>
> Use the partition's cdie_mask to map each PLR resource to its package
> power domain. For compatibility with older platforms, keep using the
> resource index for partition 0 when no mask is available. Skip per-
> CPU
> mailbox accesses if the resource has no valid CPU mapping.
>
> Fixes: 9e9397a41b7b ("platform/x86/intel/tpmi/plr: Add support for
> the plr mailbox")
> Signed-off-by: Qinyun Tan <qinyuntan@linux.alibaba.com>
Hi Tan,
Thank you for submitting this change, similar change was in our queue
waiting to test.
You have moved definition of MAX_POWER_DOMAINS to header file, but this
there is no description of that in the commit description.
If you happen to post update, add that.
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
>
> Notes:
> Tested on a single-package system with 72 logical CPUs and two
> TPMI
> partitions. The PLR status files now list the CPUs belonging to
> each
> partition.
>
> drivers/platform/x86/intel/plr_tpmi.c | 31 ++++++++++++++++-
> --
> .../platform/x86/intel/tpmi_power_domains.c | 2 --
> .../platform/x86/intel/tpmi_power_domains.h | 2 ++
> 3 files changed, 29 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/platform/x86/intel/plr_tpmi.c
> b/drivers/platform/x86/intel/plr_tpmi.c
> index 785c279b4540..33066f4763ef 100644
> --- a/drivers/platform/x86/intel/plr_tpmi.c
> +++ b/drivers/platform/x86/intel/plr_tpmi.c
> @@ -51,7 +51,7 @@ struct tpmi_plr_die {
> void __iomem *base;
> struct mutex lock; /* Protect access to PLR mailbox */
> int package_id;
> - int die_id;
> + int power_domain_id;
> struct tpmi_plr *plr;
> };
>
> @@ -201,10 +201,13 @@ static int plr_status_show(struct seq_file *s,
> void *unused)
> seq_puts(s, "cpus");
> plr_print_bits(s, val, 32);
>
> + if (plr_die->power_domain_id < 0)
> + return 0;
> +
> guard(mutex)(&plr_die->lock);
>
> for (int cpu = 0; cpu < nr_cpu_ids; cpu++) {
> - if (plr_die->die_id !=
> tpmi_get_power_domain_id(cpu))
> + if (plr_die->power_domain_id !=
> tpmi_get_power_domain_id(cpu))
> continue;
>
> if (plr_die->package_id !=
> topology_physical_package_id(cpu))
> @@ -241,10 +244,13 @@ static ssize_t plr_status_write(struct file
> *filp, const char __user *ubuf,
>
> plr_write(0, plr_die, PLR_DIE_LEVEL);
>
> + if (plr_die->power_domain_id < 0)
> + return count;
> +
> guard(mutex)(&plr_die->lock);
>
> for (int cpu = 0; cpu < nr_cpu_ids; cpu++) {
> - if (plr_die->die_id !=
> tpmi_get_power_domain_id(cpu))
> + if (plr_die->power_domain_id !=
> tpmi_get_power_domain_id(cpu))
> continue;
>
> if (plr_die->package_id !=
> topology_physical_package_id(cpu))
> @@ -281,6 +287,23 @@ static void intel_plr_unregister_notifier(struct
> notifier_block *nb)
> tpmi_unregister_notifier(nb);
> }
>
> +static int plr_power_domain_id(const struct oobmsm_plat_info
> *plat_info, int index)
> +{
> + u16 mask = plat_info->cdie_mask;
> + int id = index;
> +
> + /* Resource indices are relative to the partition's first
> compute die. */
> + if (mask)
> + id += __ffs(mask);
> + else if (plat_info->partition)
> + return -ENODEV;
> +
> + if (id >= MAX_POWER_DOMAINS || (mask && !(mask & BIT(id))))
> + return -ENODEV;
> +
> + return id;
> +}
> +
> static int intel_plr_probe(struct auxiliary_device *auxdev, const
> struct auxiliary_device_id *id)
> {
> struct oobmsm_plat_info *plat_info;
> @@ -340,7 +363,7 @@ static int intel_plr_probe(struct
> auxiliary_device *auxdev, const struct auxilia
>
> plr->die_info[i].base = base;
> plr->die_info[i].package_id = plat_info->package_id;
> - plr->die_info[i].die_id = i;
> + plr->die_info[i].power_domain_id =
> plr_power_domain_id(plat_info, i);
> plr->die_info[i].plr = plr;
> mutex_init(&plr->die_info[i].lock);
>
> diff --git a/drivers/platform/x86/intel/tpmi_power_domains.c
> b/drivers/platform/x86/intel/tpmi_power_domains.c
> index ebe052c3bbe4..f6a46b4571ec 100644
> --- a/drivers/platform/x86/intel/tpmi_power_domains.c
> +++ b/drivers/platform/x86/intel/tpmi_power_domains.c
> @@ -70,8 +70,6 @@ static DEFINE_PER_CPU(struct tpmi_cpu_info,
> tpmi_cpu_info);
> /* The dynamically assigned cpu hotplug state to free later */
> static enum cpuhp_state tpmi_hp_state __read_mostly;
>
> -#define MAX_POWER_DOMAINS 8
> -
> static cpumask_t *tpmi_power_domain_mask;
>
> static u16 *domain_die_map;
> diff --git a/drivers/platform/x86/intel/tpmi_power_domains.h
> b/drivers/platform/x86/intel/tpmi_power_domains.h
> index 2fd0dd7afbd2..43a80b526133 100644
> --- a/drivers/platform/x86/intel/tpmi_power_domains.h
> +++ b/drivers/platform/x86/intel/tpmi_power_domains.h
> @@ -10,6 +10,8 @@
>
> #include <linux/cpumask.h>
>
> +#define MAX_POWER_DOMAINS 8
> +
> int tpmi_get_linux_cpu_number(int package_id, int die_id, int
> punit_core_id);
> int tpmi_get_punit_core_number(int cpu_no);
> int tpmi_get_power_domain_id(int cpu_no);
>
> base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-25 17:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 9:22 [PATCH] platform/x86/intel/tpmi/plr: Fix CPU selection on partitioned systems Qinyun Tan
2026-11-25 17:49 ` Srinivas Pandruvada
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®