diff options
author | Kan Liang <kan.liang@linux.intel.com> | 2023-01-12 12:01:01 -0800 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2023-01-21 00:06:11 +0100 |
commit | dbf061b26221fa1a99e6489dd61f5b4ee97a24e8 (patch) | |
tree | 58f0211c5963e2b5c9131e47d15937abdf674206 /arch/x86/events/intel/uncore.c | |
parent | 0eed28220598cd990d094b7b9f8c832c425080c0 (diff) |
perf/x86/uncore: Factor out uncore_device_to_die()
The same code is used to retrieve the logical die ID with a given PCI
device in both the discovery code and the code that supports a system
with > 8 nodes.
Factor out uncore_device_to_die() to replace the duplicate code.
No functional change.
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Michael Petlan <mpetlan@redhat.com>
Link: https://lore.kernel.org/r/20230112200105.733466-2-kan.liang@linux.intel.com
Diffstat (limited to 'arch/x86/events/intel/uncore.c')
-rw-r--r-- | arch/x86/events/intel/uncore.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c index 459b1aafd4d4..eeaa92f06b44 100644 --- a/arch/x86/events/intel/uncore.c +++ b/arch/x86/events/intel/uncore.c @@ -65,6 +65,21 @@ int uncore_die_to_segment(int die) return bus ? pci_domain_nr(bus) : -EINVAL; } +int uncore_device_to_die(struct pci_dev *dev) +{ + int node = pcibus_to_node(dev->bus); + int cpu; + + for_each_cpu(cpu, cpumask_of_pcibus(dev->bus)) { + struct cpuinfo_x86 *c = &cpu_data(cpu); + + if (c->initialized && cpu_to_node(cpu) == node) + return c->logical_die_id; + } + + return -1; +} + static void uncore_free_pcibus_map(void) { struct pci2phy_map *map, *tmp; |