* [PATCH v2 0/5] intel-uncore-freq: Add agent_types and die_id attributes
@ 2025-04-28 17:03 Srinivas Pandruvada
2025-04-28 17:03 ` [PATCH v2 1/5] platform/x86/intel-uncore-freq: Add attributes to show agent types Srinivas Pandruvada
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Srinivas Pandruvada @ 2025-04-28 17:03 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, linux-kernel, Srinivas Pandruvada
Add two new attributes, so that orchestration software like Kubernetes can
target specific dies and agents for uncore frequency control.
v2:
In patch 5/5 fix grammar as reported by Alok Tiwari
Srinivas Pandruvada (5):
platform/x86/intel-uncore-freq: Add attributes to show agent types
Documentation: admin-guide: pm: Add documentation for agent_types
platform/x86/intel: power-domains: Add interface to get Linux die ID
platform/x86/intel-uncore-freq: Add attributes to show die_id
Documentation: admin-guide: pm: Add documentation for die_id
.../pm/intel_uncore_frequency_scaling.rst | 10 ++++
.../platform/x86/intel/tpmi_power_domains.c | 34 +++++++++--
.../platform/x86/intel/tpmi_power_domains.h | 1 +
.../uncore-frequency-common.c | 31 ++++++++++
.../uncore-frequency-common.h | 19 ++++++-
.../uncore-frequency/uncore-frequency-tpmi.c | 56 +++++++++++++++++++
6 files changed, 146 insertions(+), 5 deletions(-)
--
2.48.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/5] platform/x86/intel-uncore-freq: Add attributes to show agent types
2025-04-28 17:03 [PATCH v2 0/5] intel-uncore-freq: Add agent_types and die_id attributes Srinivas Pandruvada
@ 2025-04-28 17:03 ` Srinivas Pandruvada
2025-05-07 13:02 ` Ilpo Järvinen
2025-04-28 17:03 ` [PATCH v2 2/5] Documentation: admin-guide: pm: Add documentation for agent_types Srinivas Pandruvada
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Srinivas Pandruvada @ 2025-04-28 17:03 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, linux-kernel, Srinivas Pandruvada
Currently, users need detailed hardware information to understand the
scope of controls within each uncore domain. Uncore frequency controls
manage subsystems such as core, cache, memory, and I/O. The UFS TPMI
provides this information, which can be used to present the scope more
clearly.
Each uncore domain consists of one or more agent types, with each agent
type controlling one or more uncore hardware subsystems. For example, a
single agent might control both the core and cache.
Introduce a new attribute called "agent_types." This attribute displays
a list of agents, separated by space character.
The string representations for agent types are as follows:
For core agent: core
For cache agent: cache
For memory agent: memory
For I/O agent: io
These agent types are read during probe time for each cluster and stored
as part of the struct uncore_data.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
v2:
No change
.../uncore-frequency-common.c | 24 ++++++++++++++++
.../uncore-frequency-common.h | 17 ++++++++++-
.../uncore-frequency/uncore-frequency-tpmi.c | 28 +++++++++++++++++++
3 files changed, 68 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
index 4e2c6a2d7e6e..cfa3039a0e39 100644
--- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
+++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
@@ -43,6 +43,28 @@ static ssize_t show_package_id(struct kobject *kobj, struct kobj_attribute *attr
return sprintf(buf, "%u\n", data->package_id);
}
+static ssize_t show_agent_types(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
+{
+ struct uncore_data *data = container_of(attr, struct uncore_data, agent_types_kobj_attr);
+ int length = 0;
+
+ if (data->agent_type_mask & AGENT_TYPE_CORE)
+ length += sysfs_emit_at(buf, length, "core ");
+
+ if (data->agent_type_mask & AGENT_TYPE_CACHE)
+ length += sysfs_emit_at(buf, length, "cache ");
+
+ if (data->agent_type_mask & AGENT_TYPE_MEMORY)
+ length += sysfs_emit_at(buf, length, "memory ");
+
+ if (data->agent_type_mask & AGENT_TYPE_IO)
+ length += sysfs_emit_at(buf, length, "io ");
+
+ length += sysfs_emit_at(buf, length, "\n");
+
+ return length;
+}
+
static ssize_t show_attr(struct uncore_data *data, char *buf, enum uncore_index index)
{
unsigned int value;
@@ -179,6 +201,8 @@ static int create_attr_group(struct uncore_data *data, char *name)
data->uncore_attrs[index++] = &data->fabric_cluster_id_kobj_attr.attr;
init_attribute_root_ro(package_id);
data->uncore_attrs[index++] = &data->package_id_kobj_attr.attr;
+ init_attribute_ro(agent_types);
+ data->uncore_attrs[index++] = &data->agent_types_kobj_attr.attr;
}
data->uncore_attrs[index++] = &data->max_freq_khz_kobj_attr.attr;
diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.h b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.h
index 26c854cd5d97..197ca2ad327f 100644
--- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.h
+++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.h
@@ -11,6 +11,17 @@
#include <linux/device.h>
+/*
+ * Define uncore agents, which are under uncore frequency control.
+ * It is possible that there are common uncore frequency control to more than
+ * one agents. So these defines are used as a bit mask.
+ */
+#define AGENT_TYPE_NONE 0
+#define AGENT_TYPE_CORE 0x01
+#define AGENT_TYPE_CACHE 0x02
+#define AGENT_TYPE_MEMORY 0x04
+#define AGENT_TYPE_IO 0x08
+
/**
* struct uncore_data - Encapsulate all uncore data
* @stored_uncore_data: Last user changed MSR 620 value, which will be restored
@@ -25,6 +36,7 @@
* @cluster_id: cluster id in a domain
* @instance_id: Unique instance id to append to directory name
* @name: Sysfs entry name for this instance
+ * @agent_type_mask: Bit mask of all hardware agents for this domain
* @uncore_attr_group: Attribute group storage
* @max_freq_khz_kobj_attr: Storage for kobject attribute max_freq_khz
* @mix_freq_khz_kobj_attr: Storage for kobject attribute min_freq_khz
@@ -41,6 +53,7 @@
* @elc_high_threshold_enable_kobj_attr:
Storage for kobject attribute elc_high_threshold_enable
* @elc_floor_freq_khz_kobj_attr: Storage for kobject attribute elc_floor_freq_khz
+ * @agent_types_kobj_attr: Storage for kobject attribute agent_type
* @uncore_attrs: Attribute storage for group creation
*
* This structure is used to encapsulate all data related to uncore sysfs
@@ -58,6 +71,7 @@ struct uncore_data {
int cluster_id;
int instance_id;
char name[32];
+ u16 agent_type_mask;
struct attribute_group uncore_attr_group;
struct kobj_attribute max_freq_khz_kobj_attr;
@@ -72,7 +86,8 @@ struct uncore_data {
struct kobj_attribute elc_high_threshold_percent_kobj_attr;
struct kobj_attribute elc_high_threshold_enable_kobj_attr;
struct kobj_attribute elc_floor_freq_khz_kobj_attr;
- struct attribute *uncore_attrs[13];
+ struct kobj_attribute agent_types_kobj_attr;
+ struct attribute *uncore_attrs[14];
};
#define UNCORE_DOMAIN_ID_INVALID -1
diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c
index 4aa6c227ec82..70415d80773c 100644
--- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c
+++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c
@@ -74,6 +74,12 @@ struct tpmi_uncore_struct {
/* Bit definitions for STATUS register */
#define UNCORE_CURRENT_RATIO_MASK GENMASK_ULL(6, 0)
+/* Uncore agent type bits */
+#define UNCORE_CORE_PRESENT BIT(23)
+#define UNCORE_CACHE_PRESENT BIT(24)
+#define UNCORE_MEMORY_PRESENT BIT(25)
+#define UNCORE_IO_PRESENT BIT(26)
+
/* Bit definitions for CONTROL register */
#define UNCORE_MAX_RATIO_MASK GENMASK_ULL(14, 8)
#define UNCORE_MIN_RATIO_MASK GENMASK_ULL(21, 15)
@@ -347,6 +353,26 @@ static int uncore_read_freq(struct uncore_data *data, unsigned int *freq)
return 0;
}
+/* Helper function to read agent type over MMIO and set the agent type */
+static void uncore_set_agent_type(struct tpmi_uncore_cluster_info *cluster_info)
+{
+ u64 status;
+
+ status = readq((u8 __iomem *)cluster_info->cluster_base + UNCORE_STATUS_INDEX);
+
+ if (status & UNCORE_CORE_PRESENT)
+ cluster_info->uncore_data.agent_type_mask |= AGENT_TYPE_CORE;
+
+ if (status & UNCORE_CACHE_PRESENT)
+ cluster_info->uncore_data.agent_type_mask |= AGENT_TYPE_CACHE;
+
+ if (status & UNCORE_MEMORY_PRESENT)
+ cluster_info->uncore_data.agent_type_mask |= AGENT_TYPE_MEMORY;
+
+ if (status & UNCORE_IO_PRESENT)
+ cluster_info->uncore_data.agent_type_mask |= AGENT_TYPE_IO;
+}
+
/* Callback for sysfs read for TPMI uncore values. Called under mutex locks. */
static int uncore_read(struct uncore_data *data, unsigned int *value, enum uncore_index index)
{
@@ -552,6 +578,8 @@ static int uncore_probe(struct auxiliary_device *auxdev, const struct auxiliary_
cluster_info->cluster_base = pd_info->uncore_base + mask;
+ uncore_set_agent_type(cluster_info);
+
cluster_info->uncore_data.package_id = pkg;
/* There are no dies like Cascade Lake */
cluster_info->uncore_data.die_id = 0;
--
2.48.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/5] Documentation: admin-guide: pm: Add documentation for agent_types
2025-04-28 17:03 [PATCH v2 0/5] intel-uncore-freq: Add agent_types and die_id attributes Srinivas Pandruvada
2025-04-28 17:03 ` [PATCH v2 1/5] platform/x86/intel-uncore-freq: Add attributes to show agent types Srinivas Pandruvada
@ 2025-04-28 17:03 ` Srinivas Pandruvada
2025-04-28 17:03 ` [PATCH v2 3/5] platform/x86/intel: power-domains: Add interface to get Linux die ID Srinivas Pandruvada
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Srinivas Pandruvada @ 2025-04-28 17:03 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, linux-kernel, Srinivas Pandruvada
Add documentation to describe agent_types attribute.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
v2:
No change
.../admin-guide/pm/intel_uncore_frequency_scaling.rst | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Documentation/admin-guide/pm/intel_uncore_frequency_scaling.rst b/Documentation/admin-guide/pm/intel_uncore_frequency_scaling.rst
index 5151ec312dc0..84608dad84bd 100644
--- a/Documentation/admin-guide/pm/intel_uncore_frequency_scaling.rst
+++ b/Documentation/admin-guide/pm/intel_uncore_frequency_scaling.rst
@@ -97,6 +97,11 @@ Attributes in each directory:
``package_id``
This attribute is used to get the package id of this instance.
+``agent_types``
+ This attribute displays all the hardware agents present within the
+ domain. Each agent has the capability to control one or more hardware
+ subsystems, which include: core, cache, memory, and I/O.
+
The other attributes are same as presented at package_*_die_* level.
In most of current use cases, the "max_freq_khz" and "min_freq_khz"
--
2.48.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 3/5] platform/x86/intel: power-domains: Add interface to get Linux die ID
2025-04-28 17:03 [PATCH v2 0/5] intel-uncore-freq: Add agent_types and die_id attributes Srinivas Pandruvada
2025-04-28 17:03 ` [PATCH v2 1/5] platform/x86/intel-uncore-freq: Add attributes to show agent types Srinivas Pandruvada
2025-04-28 17:03 ` [PATCH v2 2/5] Documentation: admin-guide: pm: Add documentation for agent_types Srinivas Pandruvada
@ 2025-04-28 17:03 ` Srinivas Pandruvada
2025-04-28 17:03 ` [PATCH v2 4/5] platform/x86/intel-uncore-freq: Add attributes to show die_id Srinivas Pandruvada
2025-04-28 17:03 ` [PATCH v2 5/5] Documentation: admin-guide: pm: Add documentation for die_id Srinivas Pandruvada
4 siblings, 0 replies; 9+ messages in thread
From: Srinivas Pandruvada @ 2025-04-28 17:03 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, linux-kernel, Srinivas Pandruvada
The die ID in the Linux topology sysfs is a logical identifier that
differs from the one presented in CPUID leaf 0x1F or via MSR 0x54.
Introduce an interface that returns the Linux CPU die ID based on a
given package ID and power domain ID. This mapping is stored during the
CPU online callback in an array.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
v2:
No change
.../platform/x86/intel/tpmi_power_domains.c | 34 ++++++++++++++++---
.../platform/x86/intel/tpmi_power_domains.h | 1 +
2 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/drivers/platform/x86/intel/tpmi_power_domains.c b/drivers/platform/x86/intel/tpmi_power_domains.c
index 2f01cd22a6ee..9aaebd74a2af 100644
--- a/drivers/platform/x86/intel/tpmi_power_domains.c
+++ b/drivers/platform/x86/intel/tpmi_power_domains.c
@@ -74,6 +74,8 @@ static enum cpuhp_state tpmi_hp_state __read_mostly;
static cpumask_t *tpmi_power_domain_mask;
+static u16 *domain_die_map;
+
/* Lock to protect tpmi_power_domain_mask and tpmi_cpu_hash */
static DEFINE_MUTEX(tpmi_lock);
@@ -152,6 +154,15 @@ cpumask_t *tpmi_get_power_domain_mask(int cpu_no)
}
EXPORT_SYMBOL_NS_GPL(tpmi_get_power_domain_mask, "INTEL_TPMI_POWER_DOMAIN");
+int tpmi_get_linux_die_id(int pkg_id, int domain_id)
+{
+ if (pkg_id >= topology_max_packages() || domain_id >= MAX_POWER_DOMAINS)
+ return -EINVAL;
+
+ return domain_die_map[pkg_id * MAX_POWER_DOMAINS + domain_id];
+}
+EXPORT_SYMBOL_NS_GPL(tpmi_get_linux_die_id, "INTEL_TPMI_POWER_DOMAIN");
+
static int tpmi_get_logical_id(unsigned int cpu, struct tpmi_cpu_info *info)
{
u64 data;
@@ -189,6 +200,9 @@ static int tpmi_cpu_online(unsigned int cpu)
cpumask_set_cpu(cpu, &tpmi_power_domain_mask[index]);
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);
+
return 0;
}
@@ -212,17 +226,28 @@ static int __init tpmi_init(void)
if (!tpmi_power_domain_mask)
return -ENOMEM;
+ domain_die_map = kcalloc(size_mul(topology_max_packages(), MAX_POWER_DOMAINS),
+ sizeof(*domain_die_map), GFP_KERNEL);
+ if (!domain_die_map)
+ goto free_domain_mask;
+
ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
"platform/x86/tpmi_power_domains:online",
tpmi_cpu_online, NULL);
- if (ret < 0) {
- kfree(tpmi_power_domain_mask);
- return ret;
- }
+ if (ret < 0)
+ goto free_domain_map;
tpmi_hp_state = ret;
return 0;
+
+free_domain_map:
+ kfree(domain_die_map);
+
+free_domain_mask:
+ kfree(tpmi_power_domain_mask);
+
+ return ret;
}
module_init(tpmi_init)
@@ -230,6 +255,7 @@ static void __exit tpmi_exit(void)
{
cpuhp_remove_state(tpmi_hp_state);
kfree(tpmi_power_domain_mask);
+ kfree(domain_die_map);
}
module_exit(tpmi_exit)
diff --git a/drivers/platform/x86/intel/tpmi_power_domains.h b/drivers/platform/x86/intel/tpmi_power_domains.h
index e35750dd9273..2fd0dd7afbd2 100644
--- a/drivers/platform/x86/intel/tpmi_power_domains.h
+++ b/drivers/platform/x86/intel/tpmi_power_domains.h
@@ -14,5 +14,6 @@ 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);
cpumask_t *tpmi_get_power_domain_mask(int cpu_no);
+int tpmi_get_linux_die_id(int pkg_id, int domain_id);
#endif
--
2.48.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 4/5] platform/x86/intel-uncore-freq: Add attributes to show die_id
2025-04-28 17:03 [PATCH v2 0/5] intel-uncore-freq: Add agent_types and die_id attributes Srinivas Pandruvada
` (2 preceding siblings ...)
2025-04-28 17:03 ` [PATCH v2 3/5] platform/x86/intel: power-domains: Add interface to get Linux die ID Srinivas Pandruvada
@ 2025-04-28 17:03 ` Srinivas Pandruvada
2025-04-28 17:03 ` [PATCH v2 5/5] Documentation: admin-guide: pm: Add documentation for die_id Srinivas Pandruvada
4 siblings, 0 replies; 9+ messages in thread
From: Srinivas Pandruvada @ 2025-04-28 17:03 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, linux-kernel, Srinivas Pandruvada
For domains with agents to control cores (compute dies) show matching
Linux CPU die ID. Linux CPU ID is a logical die ID, so this may not match
physical die ID or domain_id. So, a mapping is required to get Linux CPU
die ID. This attribute is only presented when CPUID enumerates die ids.
This attribute can be used by orchestration software like Kubernetes to
target specific dies for uncore frequency control.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
v2:
No change
.../uncore-frequency-common.c | 7 +++++
.../uncore-frequency-common.h | 4 ++-
.../uncore-frequency/uncore-frequency-tpmi.c | 28 +++++++++++++++++++
3 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
index cfa3039a0e39..3411d33e5f13 100644
--- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
+++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
@@ -142,6 +142,8 @@ show_uncore_attr(elc_high_threshold_enable,
UNCORE_INDEX_EFF_LAT_CTRL_HIGH_THRESHOLD_ENABLE);
show_uncore_attr(elc_floor_freq_khz, UNCORE_INDEX_EFF_LAT_CTRL_FREQ);
+show_uncore_attr(die_id, UNCORE_INDEX_DIE_ID);
+
#define show_uncore_data(member_name) \
static ssize_t show_##member_name(struct kobject *kobj, \
struct kobj_attribute *attr, char *buf)\
@@ -203,6 +205,11 @@ static int create_attr_group(struct uncore_data *data, char *name)
data->uncore_attrs[index++] = &data->package_id_kobj_attr.attr;
init_attribute_ro(agent_types);
data->uncore_attrs[index++] = &data->agent_types_kobj_attr.attr;
+ if (topology_max_dies_per_package() > 1 &&
+ data->agent_type_mask & AGENT_TYPE_CORE) {
+ init_attribute_ro(die_id);
+ data->uncore_attrs[index++] = &data->die_id_kobj_attr.attr;
+ }
}
data->uncore_attrs[index++] = &data->max_freq_khz_kobj_attr.attr;
diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.h b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.h
index 197ca2ad327f..9e4d7f44a41f 100644
--- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.h
+++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.h
@@ -87,7 +87,8 @@ struct uncore_data {
struct kobj_attribute elc_high_threshold_enable_kobj_attr;
struct kobj_attribute elc_floor_freq_khz_kobj_attr;
struct kobj_attribute agent_types_kobj_attr;
- struct attribute *uncore_attrs[14];
+ struct kobj_attribute die_id_kobj_attr;
+ struct attribute *uncore_attrs[15];
};
#define UNCORE_DOMAIN_ID_INVALID -1
@@ -100,6 +101,7 @@ enum uncore_index {
UNCORE_INDEX_EFF_LAT_CTRL_HIGH_THRESHOLD,
UNCORE_INDEX_EFF_LAT_CTRL_HIGH_THRESHOLD_ENABLE,
UNCORE_INDEX_EFF_LAT_CTRL_FREQ,
+ UNCORE_INDEX_DIE_ID,
};
int uncore_freq_common_init(int (*read)(struct uncore_data *data, unsigned int *value,
diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c
index 70415d80773c..adcf992e4ff0 100644
--- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c
+++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c
@@ -26,6 +26,7 @@
#include <linux/module.h>
#include <linux/intel_tpmi.h>
+#include "../tpmi_power_domains.h"
#include "uncore-frequency-common.h"
#define UNCORE_MAJOR_VERSION 0
@@ -49,6 +50,7 @@ struct tpmi_uncore_cluster_info {
bool root_domain;
bool elc_supported;
u8 __iomem *cluster_base;
+ u16 cdie_id;
struct uncore_data uncore_data;
struct tpmi_uncore_struct *uncore_root;
};
@@ -376,6 +378,9 @@ static void uncore_set_agent_type(struct tpmi_uncore_cluster_info *cluster_info)
/* Callback for sysfs read for TPMI uncore values. Called under mutex locks. */
static int uncore_read(struct uncore_data *data, unsigned int *value, enum uncore_index index)
{
+ struct tpmi_uncore_cluster_info *cluster_info;
+ int ret;
+
switch (index) {
case UNCORE_INDEX_MIN_FREQ:
case UNCORE_INDEX_MAX_FREQ:
@@ -390,6 +395,16 @@ static int uncore_read(struct uncore_data *data, unsigned int *value, enum uncor
case UNCORE_INDEX_EFF_LAT_CTRL_FREQ:
return read_eff_lat_ctrl(data, value, index);
+ case UNCORE_INDEX_DIE_ID:
+ cluster_info = container_of(data, struct tpmi_uncore_cluster_info, uncore_data);
+ ret = tpmi_get_linux_die_id(cluster_info->uncore_data.package_id,
+ cluster_info->cdie_id);
+ if (ret < 0)
+ return ret;
+
+ *value = ret;
+ return 0;
+
default:
break;
}
@@ -439,6 +454,16 @@ static void remove_cluster_entries(struct tpmi_uncore_struct *tpmi_uncore)
}
}
+static void set_cdie_id(int domain_id, struct tpmi_uncore_cluster_info *cluster_info,
+ struct intel_tpmi_plat_info *plat_info)
+{
+
+ cluster_info->cdie_id = domain_id;
+
+ if (plat_info->cdie_mask && cluster_info->uncore_data.agent_type_mask & AGENT_TYPE_CORE)
+ cluster_info->cdie_id = domain_id + ffs(plat_info->cdie_mask) - 1;
+}
+
#define UNCORE_VERSION_MASK GENMASK_ULL(7, 0)
#define UNCORE_LOCAL_FABRIC_CLUSTER_ID_MASK GENMASK_ULL(15, 8)
#define UNCORE_CLUSTER_OFF_MASK GENMASK_ULL(7, 0)
@@ -586,6 +611,8 @@ static int uncore_probe(struct auxiliary_device *auxdev, const struct auxiliary_
cluster_info->uncore_data.domain_id = i;
cluster_info->uncore_data.cluster_id = j;
+ set_cdie_id(i, cluster_info, plat_info);
+
cluster_info->uncore_root = tpmi_uncore;
if (TPMI_MINOR_VERSION(pd_info->ufs_header_ver) >= UNCORE_ELC_SUPPORTED_VERSION)
@@ -659,5 +686,6 @@ module_auxiliary_driver(intel_uncore_aux_driver);
MODULE_IMPORT_NS("INTEL_TPMI");
MODULE_IMPORT_NS("INTEL_UNCORE_FREQUENCY");
+MODULE_IMPORT_NS("INTEL_TPMI_POWER_DOMAIN");
MODULE_DESCRIPTION("Intel TPMI UFS Driver");
MODULE_LICENSE("GPL");
--
2.48.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 5/5] Documentation: admin-guide: pm: Add documentation for die_id
2025-04-28 17:03 [PATCH v2 0/5] intel-uncore-freq: Add agent_types and die_id attributes Srinivas Pandruvada
` (3 preceding siblings ...)
2025-04-28 17:03 ` [PATCH v2 4/5] platform/x86/intel-uncore-freq: Add attributes to show die_id Srinivas Pandruvada
@ 2025-04-28 17:03 ` Srinivas Pandruvada
2025-05-07 13:09 ` Ilpo Järvinen
4 siblings, 1 reply; 9+ messages in thread
From: Srinivas Pandruvada @ 2025-04-28 17:03 UTC (permalink / raw)
To: hdegoede, ilpo.jarvinen
Cc: platform-driver-x86, linux-kernel, Srinivas Pandruvada
Add documentation to describe die_id attribute.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
v2:
Change "attributes" to "attribute"
.../admin-guide/pm/intel_uncore_frequency_scaling.rst | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Documentation/admin-guide/pm/intel_uncore_frequency_scaling.rst b/Documentation/admin-guide/pm/intel_uncore_frequency_scaling.rst
index 84608dad84bd..d7ffda6a8095 100644
--- a/Documentation/admin-guide/pm/intel_uncore_frequency_scaling.rst
+++ b/Documentation/admin-guide/pm/intel_uncore_frequency_scaling.rst
@@ -91,6 +91,11 @@ Attributes in each directory:
``domain_id``
This attribute is used to get the power domain id of this instance.
+``die_id``
+ This attribute is used to get the Linux die id of this instance.
+ This attribute is only present for domains with core agents and
+ when the CPUID leaf 0x1f presents die ID.
+
``fabric_cluster_id``
This attribute is used to get the fabric cluster id of this instance.
--
2.48.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/5] platform/x86/intel-uncore-freq: Add attributes to show agent types
2025-04-28 17:03 ` [PATCH v2 1/5] platform/x86/intel-uncore-freq: Add attributes to show agent types Srinivas Pandruvada
@ 2025-05-07 13:02 ` Ilpo Järvinen
2025-05-07 14:17 ` srinivas pandruvada
0 siblings, 1 reply; 9+ messages in thread
From: Ilpo Järvinen @ 2025-05-07 13:02 UTC (permalink / raw)
To: Srinivas Pandruvada; +Cc: Hans de Goede, platform-driver-x86, LKML
On Mon, 28 Apr 2025, Srinivas Pandruvada wrote:
> Currently, users need detailed hardware information to understand the
> scope of controls within each uncore domain. Uncore frequency controls
> manage subsystems such as core, cache, memory, and I/O. The UFS TPMI
> provides this information, which can be used to present the scope more
> clearly.
>
> Each uncore domain consists of one or more agent types, with each agent
> type controlling one or more uncore hardware subsystems. For example, a
> single agent might control both the core and cache.
>
> Introduce a new attribute called "agent_types." This attribute displays
> a list of agents, separated by space character.
>
> The string representations for agent types are as follows:
> For core agent: core
> For cache agent: cache
> For memory agent: memory
> For I/O agent: io
>
> These agent types are read during probe time for each cluster and stored
> as part of the struct uncore_data.
>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
> v2:
> No change
>
> .../uncore-frequency-common.c | 24 ++++++++++++++++
> .../uncore-frequency-common.h | 17 ++++++++++-
> .../uncore-frequency/uncore-frequency-tpmi.c | 28 +++++++++++++++++++
> 3 files changed, 68 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
> index 4e2c6a2d7e6e..cfa3039a0e39 100644
> --- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
> +++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
> @@ -43,6 +43,28 @@ static ssize_t show_package_id(struct kobject *kobj, struct kobj_attribute *attr
> return sprintf(buf, "%u\n", data->package_id);
> }
>
> +static ssize_t show_agent_types(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
> +{
> + struct uncore_data *data = container_of(attr, struct uncore_data, agent_types_kobj_attr);
> + int length = 0;
> +
> + if (data->agent_type_mask & AGENT_TYPE_CORE)
> + length += sysfs_emit_at(buf, length, "core ");
> +
> + if (data->agent_type_mask & AGENT_TYPE_CACHE)
> + length += sysfs_emit_at(buf, length, "cache ");
> +
> + if (data->agent_type_mask & AGENT_TYPE_MEMORY)
> + length += sysfs_emit_at(buf, length, "memory ");
> +
> + if (data->agent_type_mask & AGENT_TYPE_IO)
> + length += sysfs_emit_at(buf, length, "io ");
Is this set going to get expanded soon? It would feel more future proof to
do this mapping using a loop and array. You also chose the quick and dirty
approach wrt. trailing spaces as getting rid of the extra space is a bit
tedious when open coding the mapping like that ;-).
--
i.
> +
> + length += sysfs_emit_at(buf, length, "\n");
> +
> + return length;
> +}
> +
> static ssize_t show_attr(struct uncore_data *data, char *buf, enum uncore_index index)
> {
> unsigned int value;
> @@ -179,6 +201,8 @@ static int create_attr_group(struct uncore_data *data, char *name)
> data->uncore_attrs[index++] = &data->fabric_cluster_id_kobj_attr.attr;
> init_attribute_root_ro(package_id);
> data->uncore_attrs[index++] = &data->package_id_kobj_attr.attr;
> + init_attribute_ro(agent_types);
> + data->uncore_attrs[index++] = &data->agent_types_kobj_attr.attr;
> }
>
> data->uncore_attrs[index++] = &data->max_freq_khz_kobj_attr.attr;
> diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.h b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.h
> index 26c854cd5d97..197ca2ad327f 100644
> --- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.h
> +++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.h
> @@ -11,6 +11,17 @@
>
> #include <linux/device.h>
>
> +/*
> + * Define uncore agents, which are under uncore frequency control.
> + * It is possible that there are common uncore frequency control to more than
> + * one agents. So these defines are used as a bit mask.
> + */
> +#define AGENT_TYPE_NONE 0
> +#define AGENT_TYPE_CORE 0x01
> +#define AGENT_TYPE_CACHE 0x02
> +#define AGENT_TYPE_MEMORY 0x04
> +#define AGENT_TYPE_IO 0x08
> +
> /**
> * struct uncore_data - Encapsulate all uncore data
> * @stored_uncore_data: Last user changed MSR 620 value, which will be restored
> @@ -25,6 +36,7 @@
> * @cluster_id: cluster id in a domain
> * @instance_id: Unique instance id to append to directory name
> * @name: Sysfs entry name for this instance
> + * @agent_type_mask: Bit mask of all hardware agents for this domain
> * @uncore_attr_group: Attribute group storage
> * @max_freq_khz_kobj_attr: Storage for kobject attribute max_freq_khz
> * @mix_freq_khz_kobj_attr: Storage for kobject attribute min_freq_khz
> @@ -41,6 +53,7 @@
> * @elc_high_threshold_enable_kobj_attr:
> Storage for kobject attribute elc_high_threshold_enable
> * @elc_floor_freq_khz_kobj_attr: Storage for kobject attribute elc_floor_freq_khz
> + * @agent_types_kobj_attr: Storage for kobject attribute agent_type
> * @uncore_attrs: Attribute storage for group creation
> *
> * This structure is used to encapsulate all data related to uncore sysfs
> @@ -58,6 +71,7 @@ struct uncore_data {
> int cluster_id;
> int instance_id;
> char name[32];
> + u16 agent_type_mask;
>
> struct attribute_group uncore_attr_group;
> struct kobj_attribute max_freq_khz_kobj_attr;
> @@ -72,7 +86,8 @@ struct uncore_data {
> struct kobj_attribute elc_high_threshold_percent_kobj_attr;
> struct kobj_attribute elc_high_threshold_enable_kobj_attr;
> struct kobj_attribute elc_floor_freq_khz_kobj_attr;
> - struct attribute *uncore_attrs[13];
> + struct kobj_attribute agent_types_kobj_attr;
> + struct attribute *uncore_attrs[14];
> };
>
> #define UNCORE_DOMAIN_ID_INVALID -1
> diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c
> index 4aa6c227ec82..70415d80773c 100644
> --- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c
> +++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c
> @@ -74,6 +74,12 @@ struct tpmi_uncore_struct {
> /* Bit definitions for STATUS register */
> #define UNCORE_CURRENT_RATIO_MASK GENMASK_ULL(6, 0)
>
> +/* Uncore agent type bits */
> +#define UNCORE_CORE_PRESENT BIT(23)
> +#define UNCORE_CACHE_PRESENT BIT(24)
> +#define UNCORE_MEMORY_PRESENT BIT(25)
> +#define UNCORE_IO_PRESENT BIT(26)
> +
> /* Bit definitions for CONTROL register */
> #define UNCORE_MAX_RATIO_MASK GENMASK_ULL(14, 8)
> #define UNCORE_MIN_RATIO_MASK GENMASK_ULL(21, 15)
> @@ -347,6 +353,26 @@ static int uncore_read_freq(struct uncore_data *data, unsigned int *freq)
> return 0;
> }
>
> +/* Helper function to read agent type over MMIO and set the agent type */
> +static void uncore_set_agent_type(struct tpmi_uncore_cluster_info *cluster_info)
> +{
> + u64 status;
> +
> + status = readq((u8 __iomem *)cluster_info->cluster_base + UNCORE_STATUS_INDEX);
> +
> + if (status & UNCORE_CORE_PRESENT)
> + cluster_info->uncore_data.agent_type_mask |= AGENT_TYPE_CORE;
> +
> + if (status & UNCORE_CACHE_PRESENT)
> + cluster_info->uncore_data.agent_type_mask |= AGENT_TYPE_CACHE;
> +
> + if (status & UNCORE_MEMORY_PRESENT)
> + cluster_info->uncore_data.agent_type_mask |= AGENT_TYPE_MEMORY;
> +
> + if (status & UNCORE_IO_PRESENT)
> + cluster_info->uncore_data.agent_type_mask |= AGENT_TYPE_IO;
> +}
> +
> /* Callback for sysfs read for TPMI uncore values. Called under mutex locks. */
> static int uncore_read(struct uncore_data *data, unsigned int *value, enum uncore_index index)
> {
> @@ -552,6 +578,8 @@ static int uncore_probe(struct auxiliary_device *auxdev, const struct auxiliary_
>
> cluster_info->cluster_base = pd_info->uncore_base + mask;
>
> + uncore_set_agent_type(cluster_info);
> +
> cluster_info->uncore_data.package_id = pkg;
> /* There are no dies like Cascade Lake */
> cluster_info->uncore_data.die_id = 0;
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 5/5] Documentation: admin-guide: pm: Add documentation for die_id
2025-04-28 17:03 ` [PATCH v2 5/5] Documentation: admin-guide: pm: Add documentation for die_id Srinivas Pandruvada
@ 2025-05-07 13:09 ` Ilpo Järvinen
0 siblings, 0 replies; 9+ messages in thread
From: Ilpo Järvinen @ 2025-05-07 13:09 UTC (permalink / raw)
To: Srinivas Pandruvada; +Cc: Hans de Goede, platform-driver-x86, LKML
[-- Attachment #1: Type: text/plain, Size: 1534 bytes --]
On Mon, 28 Apr 2025, Srinivas Pandruvada wrote:
> Add documentation to describe die_id attribute.
>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
> v2:
> Change "attributes" to "attribute"
>
> .../admin-guide/pm/intel_uncore_frequency_scaling.rst | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/Documentation/admin-guide/pm/intel_uncore_frequency_scaling.rst b/Documentation/admin-guide/pm/intel_uncore_frequency_scaling.rst
> index 84608dad84bd..d7ffda6a8095 100644
> --- a/Documentation/admin-guide/pm/intel_uncore_frequency_scaling.rst
> +++ b/Documentation/admin-guide/pm/intel_uncore_frequency_scaling.rst
> @@ -91,6 +91,11 @@ Attributes in each directory:
> ``domain_id``
> This attribute is used to get the power domain id of this instance.
>
> +``die_id``
> + This attribute is used to get the Linux die id of this instance.
> + This attribute is only present for domains with core agents and
> + when the CPUID leaf 0x1f presents die ID.
> +
> ``fabric_cluster_id``
> This attribute is used to get the fabric cluster id of this instance.
>
>
For patches #2-#5,
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
It would have been nice to use cleanup.h in #3 but there's no good
alternative for no_free_ptr() that doesn't have __must_check (IIRC,
somebody proposed a solution to this relatively recently but I don't see
that in linux/cleanup.h currently so lets forget that for now).
--
i.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/5] platform/x86/intel-uncore-freq: Add attributes to show agent types
2025-05-07 13:02 ` Ilpo Järvinen
@ 2025-05-07 14:17 ` srinivas pandruvada
0 siblings, 0 replies; 9+ messages in thread
From: srinivas pandruvada @ 2025-05-07 14:17 UTC (permalink / raw)
To: Ilpo Järvinen; +Cc: Hans de Goede, platform-driver-x86, LKML
On Wed, 2025-05-07 at 16:02 +0300, Ilpo Järvinen wrote:
> On Mon, 28 Apr 2025, Srinivas Pandruvada wrote:
>
> > Currently, users need detailed hardware information to understand
> > the
> > scope of controls within each uncore domain. Uncore frequency
> > controls
> > manage subsystems such as core, cache, memory, and I/O. The UFS
> > TPMI
> > provides this information, which can be used to present the scope
> > more
> > clearly.
> >
> > Each uncore domain consists of one or more agent types, with each
> > agent
> > type controlling one or more uncore hardware subsystems. For
> > example, a
> > single agent might control both the core and cache.
> >
> > Introduce a new attribute called "agent_types." This attribute
> > displays
> > a list of agents, separated by space character.
> >
> > The string representations for agent types are as follows:
> > For core agent: core
> > For cache agent: cache
> > For memory agent: memory
> > For I/O agent: io
> >
> > These agent types are read during probe time for each cluster and
> > stored
> > as part of the struct uncore_data.
> >
> > Signed-off-by: Srinivas Pandruvada
> > <srinivas.pandruvada@linux.intel.com>
> > ---
> > v2:
> > No change
> >
> > .../uncore-frequency-common.c | 24
> > ++++++++++++++++
> > .../uncore-frequency-common.h | 17 ++++++++++-
> > .../uncore-frequency/uncore-frequency-tpmi.c | 28
> > +++++++++++++++++++
> > 3 files changed, 68 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-
> > frequency-common.c b/drivers/platform/x86/intel/uncore-
> > frequency/uncore-frequency-common.c
> > index 4e2c6a2d7e6e..cfa3039a0e39 100644
> > --- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-
> > common.c
> > +++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-
> > common.c
> > @@ -43,6 +43,28 @@ static ssize_t show_package_id(struct kobject
> > *kobj, struct kobj_attribute *attr
> > return sprintf(buf, "%u\n", data->package_id);
> > }
> >
> > +static ssize_t show_agent_types(struct kobject *kobj, struct
> > kobj_attribute *attr, char *buf)
> > +{
> > + struct uncore_data *data = container_of(attr, struct
> > uncore_data, agent_types_kobj_attr);
> > + int length = 0;
> > +
> > + if (data->agent_type_mask & AGENT_TYPE_CORE)
> > + length += sysfs_emit_at(buf, length, "core ");
> > +
> > + if (data->agent_type_mask & AGENT_TYPE_CACHE)
> > + length += sysfs_emit_at(buf, length, "cache ");
> > +
> > + if (data->agent_type_mask & AGENT_TYPE_MEMORY)
> > + length += sysfs_emit_at(buf, length, "memory ");
> > +
> > + if (data->agent_type_mask & AGENT_TYPE_IO)
> > + length += sysfs_emit_at(buf, length, "io ");
>
> Is this set going to get expanded soon?
Unlikely, as this list is adding every frequency scaled subsystem.
But I will try to change to loop. No issue.
Thanks,
Srinivas
> It would feel more future proof to
> do this mapping using a loop and array. You also chose the quick and
> dirty
> approach wrt. trailing spaces as getting rid of the extra space is a
> bit
> tedious when open coding the mapping like that ;-).
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-05-07 14:18 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-28 17:03 [PATCH v2 0/5] intel-uncore-freq: Add agent_types and die_id attributes Srinivas Pandruvada
2025-04-28 17:03 ` [PATCH v2 1/5] platform/x86/intel-uncore-freq: Add attributes to show agent types Srinivas Pandruvada
2025-05-07 13:02 ` Ilpo Järvinen
2025-05-07 14:17 ` srinivas pandruvada
2025-04-28 17:03 ` [PATCH v2 2/5] Documentation: admin-guide: pm: Add documentation for agent_types Srinivas Pandruvada
2025-04-28 17:03 ` [PATCH v2 3/5] platform/x86/intel: power-domains: Add interface to get Linux die ID Srinivas Pandruvada
2025-04-28 17:03 ` [PATCH v2 4/5] platform/x86/intel-uncore-freq: Add attributes to show die_id Srinivas Pandruvada
2025-04-28 17:03 ` [PATCH v2 5/5] Documentation: admin-guide: pm: Add documentation for die_id Srinivas Pandruvada
2025-05-07 13:09 ` Ilpo Järvinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox