Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/CPU/AMD: Remove amd_get_nb_id()

The Last Level Cache ID is returned by amd_get_nb_id(). In practice,
this value is the same as the AMD NodeId for callers of this function.
The NodeId is saved in struct cpuinfo_x86.cpu_die_id.

Replace calls to amd_get_nb_id() with the logical CPU's cpu_die_id and
remove the function.

Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20201109210659.754018-3-Yazen.Ghannam@amd.com

authored by

Yazen Ghannam and committed by
Borislav Petkov
db970bd2 028c221e

+11 -19
+1 -1
arch/x86/events/amd/core.c
··· 538 538 if (!x86_pmu.amd_nb_constraints) 539 539 return; 540 540 541 - nb_id = amd_get_nb_id(cpu); 541 + nb_id = topology_die_id(cpu); 542 542 WARN_ON_ONCE(nb_id == BAD_APICID); 543 543 544 544 for_each_online_cpu(i) {
-2
arch/x86/include/asm/processor.h
··· 813 813 DECLARE_PER_CPU(u64, msr_misc_features_shadow); 814 814 815 815 #ifdef CONFIG_CPU_SUP_AMD 816 - extern u16 amd_get_nb_id(int cpu); 817 816 extern u32 amd_get_nodes_per_socket(void); 818 817 #else 819 - static inline u16 amd_get_nb_id(int cpu) { return 0; } 820 818 static inline u32 amd_get_nodes_per_socket(void) { return 0; } 821 819 #endif 822 820
+2 -2
arch/x86/kernel/amd_nb.c
··· 384 384 385 385 int amd_get_subcaches(int cpu) 386 386 { 387 - struct pci_dev *link = node_to_amd_nb(amd_get_nb_id(cpu))->link; 387 + struct pci_dev *link = node_to_amd_nb(topology_die_id(cpu))->link; 388 388 unsigned int mask; 389 389 390 390 if (!amd_nb_has_feature(AMD_NB_L3_PARTITIONING)) ··· 398 398 int amd_set_subcaches(int cpu, unsigned long mask) 399 399 { 400 400 static unsigned int reset, ban; 401 - struct amd_northbridge *nb = node_to_amd_nb(amd_get_nb_id(cpu)); 401 + struct amd_northbridge *nb = node_to_amd_nb(topology_die_id(cpu)); 402 402 unsigned int reg; 403 403 int cuid; 404 404
-6
arch/x86/kernel/cpu/amd.c
··· 424 424 clear_cpu_cap(c, X86_FEATURE_AMD_PPIN); 425 425 } 426 426 427 - u16 amd_get_nb_id(int cpu) 428 - { 429 - return per_cpu(cpu_llc_id, cpu); 430 - } 431 - EXPORT_SYMBOL_GPL(amd_get_nb_id); 432 - 433 427 u32 amd_get_nodes_per_socket(void) 434 428 { 435 429 return nodes_per_socket;
+1 -1
arch/x86/kernel/cpu/cacheinfo.c
··· 580 580 if (index < 3) 581 581 return; 582 582 583 - node = amd_get_nb_id(smp_processor_id()); 583 + node = topology_die_id(smp_processor_id()); 584 584 this_leaf->nb = node_to_amd_nb(node); 585 585 if (this_leaf->nb && !this_leaf->nb->l3_cache.indices) 586 586 amd_calc_l3_indices(this_leaf->nb);
+2 -2
arch/x86/kernel/cpu/mce/amd.c
··· 1341 1341 return -ENODEV; 1342 1342 1343 1343 if (is_shared_bank(bank)) { 1344 - nb = node_to_amd_nb(amd_get_nb_id(cpu)); 1344 + nb = node_to_amd_nb(topology_die_id(cpu)); 1345 1345 1346 1346 /* threshold descriptor already initialized on this node? */ 1347 1347 if (nb && nb->bank4) { ··· 1445 1445 * The last CPU on this node using the shared bank is going 1446 1446 * away, remove that bank now. 1447 1447 */ 1448 - nb = node_to_amd_nb(amd_get_nb_id(smp_processor_id())); 1448 + nb = node_to_amd_nb(topology_die_id(smp_processor_id())); 1449 1449 nb->bank4 = NULL; 1450 1450 } 1451 1451
+2 -2
arch/x86/kernel/cpu/mce/inject.c
··· 522 522 if (boot_cpu_has(X86_FEATURE_AMD_DCM) && 523 523 b == 4 && 524 524 boot_cpu_data.x86 < 0x17) { 525 - toggle_nb_mca_mst_cpu(amd_get_nb_id(cpu)); 526 - cpu = get_nbc_for_node(amd_get_nb_id(cpu)); 525 + toggle_nb_mca_mst_cpu(topology_die_id(cpu)); 526 + cpu = get_nbc_for_node(topology_die_id(cpu)); 527 527 } 528 528 529 529 get_online_cpus();
+2 -2
drivers/edac/amd64_edac.c
··· 1133 1133 /* On F10h and later ErrAddr is MC4_ADDR[47:1] */ 1134 1134 static u64 get_error_address(struct amd64_pvt *pvt, struct mce *m) 1135 1135 { 1136 - u16 mce_nid = amd_get_nb_id(m->extcpu); 1136 + u16 mce_nid = topology_die_id(m->extcpu); 1137 1137 struct mem_ctl_info *mci; 1138 1138 u8 start_bit = 1; 1139 1139 u8 end_bit = 47; ··· 3046 3046 int cpu; 3047 3047 3048 3048 for_each_online_cpu(cpu) 3049 - if (amd_get_nb_id(cpu) == nid) 3049 + if (topology_die_id(cpu) == nid) 3050 3050 cpumask_set_cpu(cpu, mask); 3051 3051 } 3052 3052
+1 -1
drivers/edac/mce_amd.c
··· 869 869 static void decode_mc4_mce(struct mce *m) 870 870 { 871 871 unsigned int fam = x86_family(m->cpuid); 872 - int node_id = amd_get_nb_id(m->extcpu); 872 + int node_id = topology_die_id(m->extcpu); 873 873 u16 ec = EC(m->status); 874 874 u8 xec = XEC(m->status, 0x1f); 875 875 u8 offset = 0;