From nobody Mon Apr 6 15:26:25 2026 Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4841D3F7A9B; Thu, 2 Apr 2026 19:59:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775159986; cv=none; b=ZDqFfpg03USL8jn4RcjxP3JZA2eZPlCnnyInrQT3DJVgFPnWrAmzVJCubiWlGMXdb+BUMFfEbeyW1Lo87BNLQNpBZ9aiDJK0R0161w7c4xnu+nRTlvt8NOr/6QuJEgKEIemI2oaQExkET/6OZvIKfAYJbHMhuYDEQngyhkutUgQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775159986; c=relaxed/simple; bh=aSLgoUdV6fPrMqd3JYKKdJXpGU/+gGrOMfE39wiEFOc=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iZvxsNiZoC2fPhr1npOXfPFwImYAeodAwGpTyqG4MDOYXmbv9ZbkfOcg3CFcAIN9Vwz177UHYmwCHYpW1HRbBx0Rrk3nQxflH3czNwXn3QJaS6fQWBwfif5Xa7CF7uBZlWQsRXcVfYfzlIdYj5UwKBVbIPMBIZm93qNtD1aWb8A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me; spf=pass smtp.mailfrom=pm.me; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b=YH7Qsayr; arc=none smtp.client-ip=185.70.43.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pm.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b="YH7Qsayr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1775159977; x=1775419177; bh=JaZgqln+i0uwiK9eU+T0j4tPbhjPino1ptQo6hxHowM=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=YH7QsayrGSDbAGKRsjcc8alF/YD9R//aIOpl8hjrhD45nw4N3+XLjHMWBg8/fkukv RqEeqqmXGSxhogRs+ijrVwjuk0yyjsuO3U4uRps9davXYT10cQVXvcufN8aDM7cw8T 5mYsXa3aGbFUkht+Uxxd/5AvaeVfjsfmYYWCbCqKjow+Lx/DNCgk1mq+z4f/6uafJ8 feYyxMBNH5uRNHoP9DHxY7ggpiIEGAT7Uqz9SdCmQHVXJF18MBkmb0lNRriqu5EkEN qAxTrZ+9Pk6fgOi8Gko5zkryHH8rYA3n/OCNWmSEesY5ZSsf8/RB8l3O1IojHA/JUQ t8wIXLVImC46A== Date: Thu, 02 Apr 2026 19:59:34 +0000 To: hansg@kernel.org, srinivas.pandruvada@linux.intel.com, ilpo.jarvinen@linux.intel.com From: Maciej Wieczor-Retman Cc: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, dedekind1@gmail.com, artem.bityutskiy@linux.intel.com, m.wieczorretman@pm.me, Maciej Wieczor-Retman Subject: [PATCH v2 1/2] platform/x86/intel-uncore-freq: Rename instance_id Message-ID: <00eb8abdbbbe607724dbb09481513686bfbd14aa.1775159775.git.m.wieczorretman@pm.me> In-Reply-To: References: Feedback-ID: 164464600:user:proton X-Pm-Message-ID: b41ac48e8c40d05143c84dafeaa8a2fc8b8764b4 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Maciej Wieczor-Retman The "instance" word has a specific meaning in TPMI. It is a physical index related to compute dies and IO dies present on a single TPMI partition (which is also a single TPMI device). It's used for mapping MMIO blocks for direct TPMI register access. The currently used "instance_id" uncore_data struct field is a sequentially generated value that's used for appending to uncore directories inside the /sys/devices/system/cpu/intel_uncore_frequency directory. It has no relation to the physical TPMI elements. Signed-off-by: Maciej Wieczor-Retman --- Changelog v2: - Redid the first paragraph to better describe what "instance" is. - Rename seqname_id to seqnum_id to emphasize it's a sequential number not sequential name. .../x86/intel/uncore-frequency/uncore-frequency-common.c | 6 +++--- .../x86/intel/uncore-frequency/uncore-frequency-common.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-c= ommon.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-comm= on.c index 7070c94324e0..25ab511ed8d2 100644 --- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c +++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c @@ -268,7 +268,7 @@ int uncore_freq_add_entry(struct uncore_data *data, int= cpu) if (ret < 0) goto uncore_unlock; =20 - data->instance_id =3D ret; + data->seqnum_id =3D ret; scnprintf(data->name, sizeof(data->name), "uncore%02d", ret); } else { scnprintf(data->name, sizeof(data->name), "package_%02d_die_%02d", @@ -281,7 +281,7 @@ int uncore_freq_add_entry(struct uncore_data *data, int= cpu) ret =3D create_attr_group(data, data->name); if (ret) { if (data->domain_id !=3D UNCORE_DOMAIN_ID_INVALID) - ida_free(&intel_uncore_ida, data->instance_id); + ida_free(&intel_uncore_ida, data->seqnum_id); } else { data->control_cpu =3D cpu; data->valid =3D true; @@ -301,7 +301,7 @@ void uncore_freq_remove_die_entry(struct uncore_data *d= ata) data->control_cpu =3D -1; data->valid =3D false; if (data->domain_id !=3D UNCORE_DOMAIN_ID_INVALID) - ida_free(&intel_uncore_ida, data->instance_id); + ida_free(&intel_uncore_ida, data->seqnum_id); =20 mutex_unlock(&uncore_lock); } diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-c= ommon.h b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-comm= on.h index 0abe850ef54e..0d5fd91ee0aa 100644 --- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.h +++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.h @@ -35,7 +35,7 @@ * @die_id: Die id for this instance * @domain_id: Power domain id for this instance * @cluster_id: cluster id in a domain - * @instance_id: Unique instance id to append to directory name + * @seqnum_id: Unique sequential 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 @@ -71,7 +71,7 @@ struct uncore_data { int die_id; int domain_id; int cluster_id; - int instance_id; + int seqnum_id; char name[32]; u16 agent_type_mask; =20 --=20 2.53.0 From nobody Mon Apr 6 15:26:25 2026 Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65EEB3F7A90; Thu, 2 Apr 2026 19:59:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775159990; cv=none; b=f79RJjwxf/RWg6jHoXWtOeIeCy6pdciYgBNP4mwhzLYgY7DzJXhxpyL3+uGfGqR6Um5bGgSw9b8DVgnPtqsApjR5GgPttD/qkecstbD3r32cmWKskYgJjlgmYd8FJ8mfqqAWD/jOP/wOm7XlYEQTob5djAeve0TytxelUT8Gu30= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775159990; c=relaxed/simple; bh=EbRjYgy+FrCNn2LkKtmtsNnh9H2TlZHUGjoE5XhhRxg=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZSDKm9UdBpWkI0d4XFX6vpvA/jIFLHRTTKz/kxxz0OTtc+TiUCP19AHVcKM1hmhofjlzPN6O2iEAjzeUMBOwK3J6YqLGJzF7bRnG5m6ZbXfDJLiM70NHXPYAlRx5CW1lCvv/aRkUY0A8DS8MbKsZSWA1MsC2U13khNiG47+lfOM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me; spf=pass smtp.mailfrom=pm.me; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b=MxU+KGnp; arc=none smtp.client-ip=185.70.43.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pm.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b="MxU+KGnp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1775159981; x=1775419181; bh=zYgzVU2N/t1QzqJfb24JN2Lu9/ycG7dl/U3m5TJ5InM=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=MxU+KGnpq5SFv9Awudm0beCbVbibMjDL7ZzDO4abPcPcfHs8lKpWMZFJ0CB+gFJM9 d5KLv+06qEvH8po+7QP1ukZfNPDMyOeZTpFW9Cio4TTotYwc3iCOyZ7qt8xYkHdiuX NEvi0GK/PQswm23wdDaEnpfF3vBNLZ8o/Vm2gI7SUoJAhFDm10spPttmhM9pywDzOd yNv8v9Y8kdijTttIsBT1YqYQaNSKUnhIq6CJz7EPV33g+zXi/VjObNnKO3pA5GxgqT W+/wjk/p6qneZK+vObMcokkEz3IgybQZYXGdLwkfjmLR492d1qjIfm8+1WTUwHFnBd YcLiUE3cLWfyQ== Date: Thu, 02 Apr 2026 19:59:38 +0000 To: hansg@kernel.org, srinivas.pandruvada@linux.intel.com, ilpo.jarvinen@linux.intel.com From: Maciej Wieczor-Retman Cc: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, dedekind1@gmail.com, artem.bityutskiy@linux.intel.com, m.wieczorretman@pm.me, Maciej Wieczor-Retman Subject: [PATCH v2 2/2] platform/x86/intel-uncore-freq: Expose instance ID in the sysfs Message-ID: <191ea429fcf60aa6612b89dc9357c6d452c50be4.1775159775.git.m.wieczorretman@pm.me> In-Reply-To: References: Feedback-ID: 164464600:user:proton X-Pm-Message-ID: f481f315030f8e04dc3f1dba1ba3404949d6a7c2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Maciej Wieczor-Retman Insufficient data is exported to allow direct access to TPMI registers through MMIO. On non-partitioned systems domain_id can be used both for mapping CPUs to their compute die IDs and for mapping die indices to their MMIO memory blocks mapped into userspace. However on partitioned systems it can't be used for mapping MMIO blocks anymore. This is due to how TPMI partitioning influences domain_id calculation. The previous association is lost on partitioned systems in order to keep using domain_id for mapping CPUs to compute dies. Expose the instance ID in sysfs that's unique in the scope of one TPMI partition (and hence one TPMI device). It's a physical index into mapped MMIO blocks and can be used by userspace to figure out how to directly access TPMI registers. Signed-off-by: Maciej Wieczor-Retman --- Changelog v2: - Redo the patch message. - Redo the function comment that assigns instance_id. - Modify the documentation. .../pm/intel_uncore_frequency_scaling.rst | 7 +++++++ .../uncore-frequency/uncore-frequency-common.c | 10 ++++++++++ .../uncore-frequency/uncore-frequency-common.h | 6 +++++- .../uncore-frequency/uncore-frequency-tpmi.c | 15 ++++++++++++++- 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/pm/intel_uncore_frequency_scaling.rs= t b/Documentation/admin-guide/pm/intel_uncore_frequency_scaling.rst index d367ba4d744a..b43ad4d5e333 100644 --- a/Documentation/admin-guide/pm/intel_uncore_frequency_scaling.rst +++ b/Documentation/admin-guide/pm/intel_uncore_frequency_scaling.rst @@ -88,8 +88,15 @@ and "fabric_cluster_id" in the directory. =20 Attributes in each directory: =20 +``instance_id`` + This attribute is used to get die indices in userspace mapped MMIO + blocks. Indices are local to a single TPMI partition. Needed for direct + TPMI register access. + ``domain_id`` This attribute is used to get the power domain id of this instance. + Indices are unique in all TPMI partitions on a given CPU package. Can be + used to map compute dies to corresponding CPUs. =20 ``die_id`` This attribute is used to get the Linux die id of this instance. diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-c= ommon.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-comm= on.c index 25ab511ed8d2..7141544ee94b 100644 --- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c +++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c @@ -29,6 +29,13 @@ static ssize_t show_domain_id(struct kobject *kobj, stru= ct kobj_attribute *attr, return sysfs_emit(buf, "%u\n", data->domain_id); } =20 +static ssize_t show_instance_id(struct kobject *kobj, struct kobj_attribut= e *attr, char *buf) +{ + struct uncore_data *data =3D container_of(attr, struct uncore_data, insta= nce_id_kobj_attr); + + return sprintf(buf, "%u\n", data->instance_id); +} + static ssize_t show_fabric_cluster_id(struct kobject *kobj, struct kobj_at= tribute *attr, char *buf) { struct uncore_data *data =3D container_of(attr, struct uncore_data, fabri= c_cluster_id_kobj_attr); @@ -200,6 +207,9 @@ static int create_attr_group(struct uncore_data *data, = char *name) if (data->domain_id !=3D UNCORE_DOMAIN_ID_INVALID) { init_attribute_root_ro(domain_id); data->uncore_attrs[index++] =3D &data->domain_id_kobj_attr.attr; + init_attribute_root_ro(instance_id); + data->uncore_attrs[index++] =3D &data->instance_id_kobj_attr.attr; + init_attribute_root_ro(fabric_cluster_id); data->uncore_attrs[index++] =3D &data->fabric_cluster_id_kobj_attr.attr; init_attribute_root_ro(package_id); diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-c= ommon.h b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-comm= on.h index 0d5fd91ee0aa..e319448dc1a4 100644 --- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.h +++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.h @@ -36,6 +36,7 @@ * @domain_id: Power domain id for this instance * @cluster_id: cluster id in a domain * @seqnum_id: Unique sequential id to append to directory name + * @instance_id: Die indices or feature instances for a single TPMI device * @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 @@ -56,6 +57,7 @@ * @elc_floor_freq_khz_kobj_attr: Storage for kobject attribute elc_floor_= freq_khz * @agent_types_kobj_attr: Storage for kobject attribute agent_type * @die_id_kobj_attr: Attribute storage for die_id information + * @instance_id_kobj_attr: Attribute storage for instance_id value * @uncore_attrs: Attribute storage for group creation * * This structure is used to encapsulate all data related to uncore sysfs @@ -72,6 +74,7 @@ struct uncore_data { int domain_id; int cluster_id; int seqnum_id; + int instance_id; char name[32]; u16 agent_type_mask; =20 @@ -90,7 +93,8 @@ struct uncore_data { struct kobj_attribute elc_floor_freq_khz_kobj_attr; struct kobj_attribute agent_types_kobj_attr; struct kobj_attribute die_id_kobj_attr; - struct attribute *uncore_attrs[15]; + struct kobj_attribute instance_id_kobj_attr; + struct attribute *uncore_attrs[16]; }; =20 #define UNCORE_DOMAIN_ID_INVALID -1 diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-t= pmi.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c index 1237d9570886..1676a2049aad 100644 --- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c +++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c @@ -385,7 +385,19 @@ static u8 io_die_index_next; /* Lock to protect io_die_start, io_die_index_next */ static DEFINE_MUTEX(domain_lock); =20 -static void set_domain_id(int id, int num_resources, +static void set_instance_id(int id, struct tpmi_uncore_cluster_info *clust= er_info) +{ + /* + * On non-partitioned systems domain_id can be used for mapping both + * CPUs to compute die IDs and physical die indexes to MMIO mapped + * memory. However on partitioned systems domain_id loses the second + * association. Therefore instance_id should be used for that instead, + * while domain_id should still be used to match CPUs to compute dies. + */ + cluster_info->uncore_data.instance_id =3D id; +} + +static void set_domain_id(int id, int num_resources, struct oobmsm_plat_info *plat_info, struct tpmi_uncore_cluster_info *cluster_info) { @@ -686,6 +698,7 @@ static int uncore_probe(struct auxiliary_device *auxdev= , const struct auxiliary_ set_cdie_id(i, cluster_info, plat_info); =20 set_domain_id(i, num_resources, plat_info, cluster_info); + set_instance_id(i, cluster_info); =20 cluster_info->uncore_root =3D tpmi_uncore; =20 --=20 2.53.0