Skip to content

[Deepin-Kernel-SIG] [linux 6.6-y] [Intel] [Backport] Backport uncore freq driver fixes and support for agent_types and die_id sysfs attributes#1481

Merged
opsiff merged 10 commits intodeepin-community:linux-6.6.yfrom
Avenger-285714:linux-6.6.y
Feb 6, 2026
Merged

[Deepin-Kernel-SIG] [linux 6.6-y] [Intel] [Backport] Backport uncore freq driver fixes and support for agent_types and die_id sysfs attributes#1481
opsiff merged 10 commits intodeepin-community:linux-6.6.yfrom
Avenger-285714:linux-6.6.y

Conversation

@Avenger-285714
Copy link
Copy Markdown
Member

@Avenger-285714 Avenger-285714 commented Feb 6, 2026

Backport uncore freq driver fixes and support for agent_types and die_id sysfs attributes

Test:
Tested on GNR/CWF, and the new uncore sysfs attributes are shown correctly.
For example, below is got on a CWF 1 Socket machine with 5 uncore domains.
/sys/devices/system/cpu/intel_uncore_frequency/uncore00/agent_types:core cache memory
/sys/devices/system/cpu/intel_uncore_frequency/uncore01/agent_types:core cache memory
/sys/devices/system/cpu/intel_uncore_frequency/uncore02/agent_types:core cache memory
/sys/devices/system/cpu/intel_uncore_frequency/uncore03/agent_types:io
/sys/devices/system/cpu/intel_uncore_frequency/uncore04/agent_types:io

1: platform/x86/intel-uncore-freq: Add attributes to show agent types
2: Documentation: admin-guide: pm: Add documentation for agent_types
3: platform/x86/intel: power-domains: Add interface to get Linux die ID
4: platform/x86/intel-uncore-freq: Add attributes to show die_id
5: Documentation: admin-guide: pm: Add documentation for die_id
6: platform/x86/intel-uncore-freq: avoid non-literal format string
7: platform/x86/intel-uncore-freq: Present unique domain ID per package
8: platform/x86/intel-uncore-freq: Fix warning in partitioned system
9: platform/x86/intel: power-domains: Fix error code in tpmi_init()
10: platform/x86: intel-uncore-freq: fix all header kernel-doc warnings

Link: https://gitee.com/OpenCloudOS/OpenCloudOS-Kernel/pulls/580

Summary by Sourcery

Backport Intel uncore frequency TPMI driver updates to expose new topology attributes and improve domain handling.

New Features:

  • Expose per-domain agent_types sysfs attribute listing uncore hardware agent types controlled by the frequency domain.
  • Expose die_id sysfs attribute for core-agent uncore domains using TPMI power domain information.

Bug Fixes:

  • Fix TPMI power domain initialization error handling to clean up allocations on failure.
  • Ensure consistent and unique uncore domain IDs across packages and partitions, avoiding warnings on partitioned systems.

Enhancements:

  • Extend TPMI power domain infrastructure to map power domains to Linux die IDs and provide a public lookup API.
  • Derive uncore agent type masks from TPMI UFS status registers and plumb them through the common uncore data path.
  • Adjust TPMI uncore root-domain detection logic to account for partitioned platforms.

Documentation:

  • Update Intel uncore frequency scaling documentation to describe the new agent_types and die_id sysfs attributes.

spandruvada and others added 10 commits February 6, 2026 14:24
commit b98fa87 upstream.

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.

Intel-SIG: commit b98fa87 platform/x86/intel-uncore-freq: Add attributes to show agent types
Backport uncore freq driver fixes and support for agent_types and die_id sysfs attributes

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/r/20250508230250.1186619-2-srinivas.pandruvada@linux.intel.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: WangYuli <wangyuli@aosc.io>
commit bfbe772 upstream.

Add documentation to describe agent_types attribute.

Intel-SIG: commit bfbe772 Documentation: admin-guide: pm: Add documentation for agent_types
Backport uncore freq driver fixes and support for agent_types and die_id sysfs attributes

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20250508230250.1186619-3-srinivas.pandruvada@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: WangYuli <wangyuli@aosc.io>
commit e37be5d upstream.

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.

Intel-SIG: commit e37be5d platform/x86/intel: power-domains: Add interface to get Linux die ID
Backport uncore freq driver fixes and support for agent_types and die_id sysfs attributes

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20250508230250.1186619-4-srinivas.pandruvada@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: WangYuli <wangyuli@aosc.io>
commit 247b43f upstream.

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.

Intel-SIG: commit 247b43f platform/x86/intel-uncore-freq: Add attributes to show die_id
Backport uncore freq driver fixes and support for agent_types and die_id sysfs attributes

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20250508230250.1186619-5-srinivas.pandruvada@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
[ Zhang Rui: resolve conflict (use old topo Macro) and amend commit log ]
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: WangYuli <wangyuli@aosc.io>
commit e636e3f upstream.

Add documentation to describe die_id attribute.

Intel-SIG: commit e636e3f Documentation: admin-guide: pm: Add documentation for die_id
Backport uncore freq driver fixes and support for agent_types and die_id sysfs attributes

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20250508230250.1186619-6-srinivas.pandruvada@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: WangYuli <wangyuli@aosc.io>
commit 0c44b46 upstream.

Using a string variable in place of a format string causes a W=1 build warning:

drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c:61:40: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
   61 |                 length += sysfs_emit_at(buf, length, agent_name[agent]);
      |                                                      ^~~~~~~~~~~~~~~~~

Use the safer "%s" format string to print it instead.

Intel-SIG: commit 0c44b46 platform/x86/intel-uncore-freq: avoid non-literal format string
Backport uncore freq driver fixes and support for agent_types and die_id sysfs attributes

Fixes: b98fa87 ("platform/x86/intel-uncore-freq: Add attributes to show agent types")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/r/20250610093459.2646337-1-arnd@kernel.org
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: WangYuli <wangyuli@aosc.io>
commit 6d47b4f upstream.

A partitioned system configured with only one package and one compute
die, warning will be generated for duplicate sysfs entry. This typically
occurs during the platform bring-up phase.

Partitioned systems expose dies, equivalent to TPMI compute domains,
through the CPUID. Each partitioned system must contains at least one
compute die per partition, resulting in a minimum of two dies per
package. Hence the function topology_max_dies_per_package() returns at
least two, and the condition "topology_max_dies_per_package() > 1"
prevents the creation of a root domain.

In this case topology_max_dies_per_package() will return 1 and root
domain will be created for partition 0 and a duplicate sysfs warning
for partition 1 as both partitions have same package ID.

To address this also check for non zero partition in addition to
topology_max_dies_per_package() > 1.

Intel-SIG: commit 6d47b4f platform/x86/intel-uncore-freq: Fix warning in partitioned system
Backport uncore freq driver fixes and support for agent_types and die_id sysfs attributes

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/r/20250819211034.3776284-1-srinivas.pandruvada@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
[ Zhang Rui: resolve conflict (use old X86 macro) and amend commit log ]
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: WangYuli <wangyuli@aosc.io>
commit a191224 upstream.

In partitioned systems, the domain ID is unique in the partition and a
package can have multiple partitions.

Some user-space tools, such as turbostat, assume the domain ID is unique
per package. These tools map CPU power domains, which are unique to a
package. However, this approach does not work in partitioned systems.

There is no architectural definition of "partition" to present to user
space.

To support these tools, set the domain_id to be unique per package. For
compute die IDs, uniqueness can be achieved using the platform info
cdie_mask, mirroring the behavior observed in non-partitioned systems.

For IO dies, which lack a direct CPU relationship, any unique logical
ID can be assigned. Here domain IDs for IO dies are configured after all
compute domain IDs. During the probe, keep the index of the next IO
domain ID after the last IO domain ID of the current partition. Since
CPU packages are symmetric, partition information is same for all
packages.

The Intel Speed Select driver has already implemented a similar change
to make the domain ID unique, with compute dies listed first, followed
by I/O dies.

Intel-SIG: commit a191224 platform/x86/intel-uncore-freq: Present unique domain ID per package
Backport uncore freq driver fixes and support for agent_types and die_id sysfs attributes

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/r/20250903191154.1081159-1-srinivas.pandruvada@linux.intel.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
[ Zhang Rui: resolve conflict and amend commit log ]
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: WangYuli <wangyuli@aosc.io>
commit 1d0a619 upstream.

Return -ENOMEM instead of success if kcalloc() fails.

Intel-SIG: commit 1d0a619 platform/x86/intel: power-domains: Fix error code in tpmi_init()
Backport uncore freq driver fixes and support for agent_types and die_id sysfs attributes

Fixes: e37be5d ("platform/x86/intel: power-domains: Add interface to get Linux die ID")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/aEKvIGCt6d8Gcx4S@stanley.mountain
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: WangYuli <wangyuli@aosc.io>
commit db30233 upstream.

In file uncore-frequency/uncore-frequency-common.h,
correct all kernel-doc warnings by adding missing leading " *" to some
lines, adding a missing kernel-doc entry, and fixing a name typo.

Warning: uncore-frequency-common.h:50 bad line:
   Storage for kobject attribute elc_low_threshold_percent
Warning: uncore-frequency-common.h:52 bad line:
   Storage for kobject attribute elc_high_threshold_percent
Warning: uncore-frequency-common.h:54 bad line:
   Storage for kobject attribute elc_high_threshold_enable
Warning: uncore-frequency-common.h:92 struct member
 'min_freq_khz_kobj_attr' not described in 'uncore_data'
Warning: uncore-frequency-common.h:92 struct member
 'die_id_kobj_attr' not described in 'uncore_data'

Intel-SIG: commit db30233 platform/x86: intel-uncore-freq: fix all header kernel-doc warnings
Backport uncore freq driver fixes and support for agent_types and die_id sysfs attributes

Fixes: 24b6616 ("platform/x86/intel-uncore-freq: Add efficiency latency control to sysfs interface")
Fixes: 416de02 ("platform/x86: intel-uncore-freq: Fix types in sysfs callbacks")
Fixes: 247b43f ("platform/x86/intel-uncore-freq: Add attributes to show die_id")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://patch.msgid.link/20251111060938.1998542-1-rdunlap@infradead.org
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: WangYuli <wangyuli@aosc.io>
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Feb 6, 2026

Reviewer's Guide

Backports Intel uncore frequency TPMI driver enhancements to expose agent types and die_id via sysfs, adds a TPMI power-domain helper for mapping TPMI domains to Linux die IDs, and refactors TPMI uncore domain ID assignment and init error handling to support partitioned systems while fixing minor issues and kernel-doc warnings.

Sequence diagram for sysfs die_id read via TPMI power domains

sequenceDiagram
    actor Userspace
    participant Sysfs
    participant uncore_frequency_tpmi_driver as uncore_read
    participant tpmi_uncore_cluster_info as cluster_info
    participant tpmi_power_domains as tpmi_get_linux_die_id
    participant topology

    Userspace->>Sysfs: read uncoreXX/die_id
    Sysfs->>uncore_read: invoke with index UNCORE_INDEX_DIE_ID
    uncore_read->>cluster_info: container_of(data)
    uncore_read->>tpmi_get_linux_die_id: tpmi_get_linux_die_id(package_id, cdie_id)
    tpmi_get_linux_die_id->>tpmi_get_linux_die_id: validate pkg_id and domain_id
    tpmi_get_linux_die_id->>tpmi_get_linux_die_id: lookup domain_die_map[pkg_id * MAX_POWER_DOMAINS + domain_id]
    tpmi_get_linux_die_id-->>uncore_read: return linux_die_id or error
    uncore_read-->>Sysfs: return die_id value
    Sysfs-->>Userspace: deliver die_id text
Loading

Class diagram for updated uncore and TPMI power-domain data structures

classDiagram
    class uncore_data {
        <<struct>>
        int stored_uncore_data
        u32 max_freq_khz
        u32 min_freq_khz
        u32 initial_max_freq_khz
        u32 initial_min_freq_khz
        u32 current_freq_khz
        u32 fabric_cluster_id
        u32 package_id
        int die_id
        int domain_id
        int cluster_id
        int instance_id
        char name
        u16 agent_type_mask
        attribute_group uncore_attr_group
        kobj_attribute max_freq_khz_kobj_attr
        kobj_attribute min_freq_khz_kobj_attr
        kobj_attribute initial_max_freq_khz_kobj_attr
        kobj_attribute initial_min_freq_khz_kobj_attr
        kobj_attribute current_freq_khz_kobj_attr
        kobj_attribute fabric_cluster_id_kobj_attr
        kobj_attribute package_id_kobj_attr
        kobj_attribute elc_low_threshold_percent_kobj_attr
        kobj_attribute elc_high_threshold_percent_kobj_attr
        kobj_attribute elc_high_threshold_enable_kobj_attr
        kobj_attribute elc_floor_freq_khz_kobj_attr
        kobj_attribute agent_types_kobj_attr
        kobj_attribute die_id_kobj_attr
        attribute *uncore_attrs[15]
    }

    class tpmi_uncore_cluster_info {
        <<struct>>
        bool root_domain
        bool elc_supported
        u8 *cluster_base
        u16 cdie_id
        uncore_data uncore_data
        tpmi_uncore_struct *uncore_root
        void uncore_set_agent_type()
    }

    class intel_tpmi_plat_info {
        <<struct>>
        u8 partition
        u8 cdie_mask
        void *ufs_header_ver
    }

    class tpmi_power_domains {
        <<module>>
        cpumask_t *tpmi_power_domain_mask
        u16 *domain_die_map
        mutex tpmi_lock
        int tpmi_init()
        void tpmi_exit()
        int tpmi_cpu_online(unsigned_int cpu)
        cpumask_t *tpmi_get_power_domain_mask(int cpu_no)
        int tpmi_get_linux_die_id(int pkg_id, int domain_id)
    }

    class topology {
        <<subsystem>>
        int topology_max_die_per_package()
        int topology_max_packages()
        int topology_die_id(int cpu)
    }

    class uncore_frequency_tpmi_driver {
        <<module>>
        mutex domain_lock
        u8 io_die_start[2]
        u8 io_die_index_next
        void set_domain_id(int id, int num_resources, intel_tpmi_plat_info *plat_info, tpmi_uncore_cluster_info *cluster_info)
        void set_cdie_id(int domain_id, tpmi_uncore_cluster_info *cluster_info, intel_tpmi_plat_info *plat_info)
        void uncore_set_agent_type(tpmi_uncore_cluster_info *cluster_info)
        int uncore_read(uncore_data *data, unsigned_int *value, uncore_index index)
    }

    class uncore_index {
        <<enum>>
        UNCORE_INDEX_MIN_FREQ
        UNCORE_INDEX_MAX_FREQ
        UNCORE_INDEX_CURR_MAX_FREQ
        UNCORE_INDEX_CURR_MIN_FREQ
        UNCORE_INDEX_CURR_FREQ
        UNCORE_INDEX_ELC_LOW_THRESHOLD
        UNCORE_INDEX_ELC_HIGH_THRESHOLD
        UNCORE_INDEX_ELC_HIGH_THRESHOLD_ENABLE
        UNCORE_INDEX_ELC_FLOOR_FREQ
        UNCORE_INDEX_DIE_ID
    }

    class agent_type_mask_constants {
        <<defines>>
        AGENT_TYPE_CORE = 0x01
        AGENT_TYPE_CACHE = 0x02
        AGENT_TYPE_MEMORY = 0x04
        AGENT_TYPE_IO = 0x08
    }

    uncore_frequency_tpmi_driver --> tpmi_uncore_cluster_info : manages
    tpmi_uncore_cluster_info *-- uncore_data : contains
    uncore_frequency_tpmi_driver --> intel_tpmi_plat_info : uses
    uncore_frequency_tpmi_driver --> tpmi_power_domains : calls tpmi_get_linux_die_id
    tpmi_power_domains --> topology : uses
    uncore_frequency_tpmi_driver --> topology : uses
    uncore_data --> uncore_index : uses
    uncore_data --> agent_type_mask_constants : uses bitmask
Loading

File-Level Changes

Change Details Files
Expose uncore domain agent types and die_id via new sysfs attributes in the common uncore frequency code and TPMI backend.
  • Extend uncore_data with an agent_type_mask field and kobj attributes for agent_types and die_id, increasing the attribute array size accordingly
  • Implement show_agent_types() to print a space-separated list of enabled agent type names based on agent_type_mask
  • Create sysfs attributes conditionally: agent_types when any agent_type_mask bits are set; die_id only on multi-die packages for core-type domains
  • Add UNCORE_INDEX_DIE_ID to the uncore attribute index enum and wire it through show_attr()/show_uncore_attr()
drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.h
Enhance the TPMI uncore-frequency driver to read agent types from hardware, compute stable per-package domain IDs across partitions, and expose Linux die IDs for core domains.
  • Include the TPMI power-domain header and import its namespace to use new die-id mapping helpers
  • Extend tpmi_uncore_cluster_info with a cdie_id field and track per-cluster agent_type_mask by reading UFS_STATUS over MMIO
  • Introduce set_cdie_id() to derive canonical die IDs from TPMI domain IDs and platform cdie_mask, and set_domain_id() to assign unique domain_id values for IO and core domains across partitions using a mutex-protected scheme
  • Add UNCORE_INDEX_DIE_ID handling in uncore_read() that uses tpmi_get_linux_die_id() and returns die_id via sysfs
  • Adjust uncore_probe() to initialize agent types, cdie_id, and domain_id using the new helpers and to treat partitioned systems like multi-die topologies for root_domain selection
drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c
Extend TPMI power-domain core to maintain a mapping from TPMI power domains to Linux die IDs and clean up resource management and error paths.
  • Add a global domain_die_map array indexed by package and domain, protected by existing TPMI lock semantics
  • Populate domain_die_map in tpmi_cpu_online() using topology_die_id(cpu) keyed by pkg_id and punit_domain_id for the CPU
  • Provide tpmi_get_linux_die_id() API with argument validation and export it in the INTEL_TPMI_POWER_DOMAIN namespace
  • Allocate and free domain_die_map alongside tpmi_power_domain_mask, and fix tpmi_init() error path to free both resources appropriately
  • Export the new helper prototype via tpmi_power_domains.h
drivers/platform/x86/intel/tpmi_power_domains.c
drivers/platform/x86/intel/tpmi_power_domains.h
Minor behavioral adjustments and cleanups in uncore TPMI driver initialization to support partitioned systems and imports.
  • Change the root_domain skip condition to also treat platforms with partitions as non-root-domain capable unless multi-die or partitioned
  • Import the INTEL_TPMI_POWER_DOMAIN module namespace in the TPMI uncore-frequency driver to satisfy symbol usage
drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • In tpmi_get_linux_die_id(), returning the raw value from domain_die_map without checking whether that entry has actually been populated can silently return 0 for unmapped domains; consider using an explicit initialization sentinel and/or a validity check to distinguish "not yet mapped" from a real die 0.
  • The MAX_PARTITIONS limit in set_domain_id()/io_die_start handling is hard-coded to 2; it would be helpful to derive this from platform information or at least guard/log when plat_info->partition >= MAX_PARTITIONS so that future platforms with more partitions do not quietly fall back to non-unique domain_id behavior.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In tpmi_get_linux_die_id(), returning the raw value from domain_die_map without checking whether that entry has actually been populated can silently return 0 for unmapped domains; consider using an explicit initialization sentinel and/or a validity check to distinguish "not yet mapped" from a real die 0.
- The MAX_PARTITIONS limit in set_domain_id()/io_die_start handling is hard-coded to 2; it would be helpful to derive this from platform information or at least guard/log when plat_info->partition >= MAX_PARTITIONS so that future platforms with more partitions do not quietly fall back to non-unique domain_id behavior.

## Individual Comments

### Comment 1
<location> `Documentation/admin-guide/pm/intel_uncore_frequency_scaling.rst:107-108` </location>
<code_context>
 	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.
</code_context>

<issue_to_address>
**nitpick (typo):** Remove the colon after `include` for smoother grammar.

It would read more smoothly as `which include core, cache, memory, and I/O.`

```suggestion
	domain. Each agent has the capability to control one or more hardware
	subsystems, which include core, cache, memory, and I/O.
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +107 to +108
domain. Each agent has the capability to control one or more hardware
subsystems, which include: core, cache, memory, and I/O.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (typo): Remove the colon after include for smoother grammar.

It would read more smoothly as which include core, cache, memory, and I/O.

Suggested change
domain. Each agent has the capability to control one or more hardware
subsystems, which include: core, cache, memory, and I/O.
domain. Each agent has the capability to control one or more hardware
subsystems, which include core, cache, memory, and I/O.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR backports Intel uncore frequency driver fixes and enhancements from upstream to support new sysfs attributes (agent_types and die_id) and fix issues with domain ID assignment in partitioned systems. The changes enable proper identification of uncore frequency domains by their hardware agent types (core, cache, memory, I/O) and Linux die IDs on multi-die systems.

Changes:

  • Added agent_types sysfs attribute to display hardware agents (core, cache, memory, I/O) controlled by each uncore frequency domain
  • Added die_id sysfs attribute for core agent domains on multi-die systems
  • Fixed domain ID assignment for IO agents in partitioned systems and improved uniqueness of domain IDs per package
  • Enhanced tpmi_power_domains module with die ID mapping functionality and improved error handling

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c Adds agent type detection, die ID tracking, and improved domain ID assignment logic for IO agents in partitioned systems
drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.h Defines agent type constants, adds agent_type_mask and die_id fields to uncore_data structure, expands attribute array, and adds UNCORE_INDEX_DIE_ID enum
drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c Implements show_agent_types() function and conditionally adds agent_types and die_id sysfs attributes
drivers/platform/x86/intel/tpmi_power_domains.h Adds tpmi_get_linux_die_id() function declaration
drivers/platform/x86/intel/tpmi_power_domains.c Implements domain-to-die mapping with domain_die_map array, adds tpmi_get_linux_die_id() function, and improves error handling in tpmi_init()
Documentation/admin-guide/pm/intel_uncore_frequency_scaling.rst Documents the new agent_types and die_id sysfs attributes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

/* Unlikely but cdie_mask may have holes, so take range */
cdie_range = fls(plat_info->cdie_mask) - ffs(plat_info->cdie_mask) + 1;
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential issue when cdie_mask is 0. The ffs() and fls() functions return 0 when the input is 0, which would result in cdie_range being calculated as 0 - 0 + 1 = 1, which is incorrect. Consider adding a check for plat_info->cdie_mask being 0 before this calculation, similar to the check at line 527 in set_cdie_id().

Suggested change
cdie_range = fls(plat_info->cdie_mask) - ffs(plat_info->cdie_mask) + 1;
if (!plat_info->cdie_mask)
cdie_range = 0;
else
cdie_range = fls(plat_info->cdie_mask) - ffs(plat_info->cdie_mask) + 1;

Copilot uses AI. Check for mistakes.
static void set_cdie_id(int domain_id, struct tpmi_uncore_cluster_info *cluster_info,
struct intel_tpmi_plat_info *plat_info)
{

Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra blank line after function opening brace. This is inconsistent with Linux kernel coding style which typically doesn't have a blank line immediately after the opening brace of a function.

Suggested change

Copilot uses AI. Check for mistakes.
@opsiff opsiff merged commit 3750761 into deepin-community:linux-6.6.y Feb 6, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants