Skip to content

Commit 247b43f

Browse files
spandruvadaij-intel
authored andcommitted
platform/x86/intel-uncore-freq: Add attributes to show die_id
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 <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent e37be5d commit 247b43f

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ show_uncore_attr(elc_high_threshold_enable,
143143
UNCORE_INDEX_EFF_LAT_CTRL_HIGH_THRESHOLD_ENABLE);
144144
show_uncore_attr(elc_floor_freq_khz, UNCORE_INDEX_EFF_LAT_CTRL_FREQ);
145145

146+
show_uncore_attr(die_id, UNCORE_INDEX_DIE_ID);
147+
146148
#define show_uncore_data(member_name) \
147149
static ssize_t show_##member_name(struct kobject *kobj, \
148150
struct kobj_attribute *attr, char *buf)\
@@ -206,6 +208,11 @@ static int create_attr_group(struct uncore_data *data, char *name)
206208
init_attribute_ro(agent_types);
207209
data->uncore_attrs[index++] = &data->agent_types_kobj_attr.attr;
208210
}
211+
if (topology_max_dies_per_package() > 1 &&
212+
data->agent_type_mask & AGENT_TYPE_CORE) {
213+
init_attribute_ro(die_id);
214+
data->uncore_attrs[index++] = &data->die_id_kobj_attr.attr;
215+
}
209216
}
210217

211218
data->uncore_attrs[index++] = &data->max_freq_khz_kobj_attr.attr;

drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ struct uncore_data {
8888
struct kobj_attribute elc_high_threshold_enable_kobj_attr;
8989
struct kobj_attribute elc_floor_freq_khz_kobj_attr;
9090
struct kobj_attribute agent_types_kobj_attr;
91-
struct attribute *uncore_attrs[14];
91+
struct kobj_attribute die_id_kobj_attr;
92+
struct attribute *uncore_attrs[15];
9293
};
9394

9495
#define UNCORE_DOMAIN_ID_INVALID -1
@@ -101,6 +102,7 @@ enum uncore_index {
101102
UNCORE_INDEX_EFF_LAT_CTRL_HIGH_THRESHOLD,
102103
UNCORE_INDEX_EFF_LAT_CTRL_HIGH_THRESHOLD_ENABLE,
103104
UNCORE_INDEX_EFF_LAT_CTRL_FREQ,
105+
UNCORE_INDEX_DIE_ID,
104106
};
105107

106108
int uncore_freq_common_init(int (*read)(struct uncore_data *data, unsigned int *value,

drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/module.h>
2727
#include <linux/intel_tpmi.h>
2828

29+
#include "../tpmi_power_domains.h"
2930
#include "uncore-frequency-common.h"
3031

3132
#define UNCORE_MAJOR_VERSION 0
@@ -49,6 +50,7 @@ struct tpmi_uncore_cluster_info {
4950
bool root_domain;
5051
bool elc_supported;
5152
u8 __iomem *cluster_base;
53+
u16 cdie_id;
5254
struct uncore_data uncore_data;
5355
struct tpmi_uncore_struct *uncore_root;
5456
};
@@ -369,6 +371,9 @@ static void uncore_set_agent_type(struct tpmi_uncore_cluster_info *cluster_info)
369371
/* Callback for sysfs read for TPMI uncore values. Called under mutex locks. */
370372
static int uncore_read(struct uncore_data *data, unsigned int *value, enum uncore_index index)
371373
{
374+
struct tpmi_uncore_cluster_info *cluster_info;
375+
int ret;
376+
372377
switch (index) {
373378
case UNCORE_INDEX_MIN_FREQ:
374379
case UNCORE_INDEX_MAX_FREQ:
@@ -383,6 +388,16 @@ static int uncore_read(struct uncore_data *data, unsigned int *value, enum uncor
383388
case UNCORE_INDEX_EFF_LAT_CTRL_FREQ:
384389
return read_eff_lat_ctrl(data, value, index);
385390

391+
case UNCORE_INDEX_DIE_ID:
392+
cluster_info = container_of(data, struct tpmi_uncore_cluster_info, uncore_data);
393+
ret = tpmi_get_linux_die_id(cluster_info->uncore_data.package_id,
394+
cluster_info->cdie_id);
395+
if (ret < 0)
396+
return ret;
397+
398+
*value = ret;
399+
return 0;
400+
386401
default:
387402
break;
388403
}
@@ -432,6 +447,16 @@ static void remove_cluster_entries(struct tpmi_uncore_struct *tpmi_uncore)
432447
}
433448
}
434449

450+
static void set_cdie_id(int domain_id, struct tpmi_uncore_cluster_info *cluster_info,
451+
struct intel_tpmi_plat_info *plat_info)
452+
{
453+
454+
cluster_info->cdie_id = domain_id;
455+
456+
if (plat_info->cdie_mask && cluster_info->uncore_data.agent_type_mask & AGENT_TYPE_CORE)
457+
cluster_info->cdie_id = domain_id + ffs(plat_info->cdie_mask) - 1;
458+
}
459+
435460
#define UNCORE_VERSION_MASK GENMASK_ULL(7, 0)
436461
#define UNCORE_LOCAL_FABRIC_CLUSTER_ID_MASK GENMASK_ULL(15, 8)
437462
#define UNCORE_CLUSTER_OFF_MASK GENMASK_ULL(7, 0)
@@ -579,6 +604,8 @@ static int uncore_probe(struct auxiliary_device *auxdev, const struct auxiliary_
579604
cluster_info->uncore_data.domain_id = i;
580605
cluster_info->uncore_data.cluster_id = j;
581606

607+
set_cdie_id(i, cluster_info, plat_info);
608+
582609
cluster_info->uncore_root = tpmi_uncore;
583610

584611
if (TPMI_MINOR_VERSION(pd_info->ufs_header_ver) >= UNCORE_ELC_SUPPORTED_VERSION)
@@ -652,5 +679,6 @@ module_auxiliary_driver(intel_uncore_aux_driver);
652679

653680
MODULE_IMPORT_NS("INTEL_TPMI");
654681
MODULE_IMPORT_NS("INTEL_UNCORE_FREQUENCY");
682+
MODULE_IMPORT_NS("INTEL_TPMI_POWER_DOMAIN");
655683
MODULE_DESCRIPTION("Intel TPMI UFS Driver");
656684
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)