Skip to content

Commit b9d8a29

Browse files
committed
Merge tag 'x86_misc_for_v6.14_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull misc x86 updates from Borislav Petkov: - The first part of a restructuring of AMD's representation of a northbridge which is legacy now, and the creation of the new AMD node concept which represents the Zen architecture of having a collection of I/O devices within an SoC. Those nodes comprise the so-called data fabric on Zen. This has at least one practical advantage of not having to add a PCI ID each time a new data fabric PCI device releases. Eventually, the lot more uniform provider of data fabric functionality amd_node.c will be used by all the drivers which need it - Smaller cleanups * tag 'x86_misc_for_v6.14_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/amd_node: Use defines for SMN register offsets x86/amd_node: Remove dependency on AMD_NB x86/amd_node: Update __amd_smn_rw() error paths x86/amd_nb: Move SMN access code to a new amd_node driver x86/amd_nb, hwmon: (k10temp): Simplify amd_pci_dev_to_node_id() x86/amd_nb: Simplify function 3 search x86/amd_nb: Use topology info to get AMD node count x86/amd_nb: Simplify root device search x86/amd_nb: Simplify function 4 search x86: Start moving AMD node functionality out of AMD_NB x86/amd_nb: Clean up early_is_amd_nb() x86/amd_nb: Restrict init function to AMD-based systems x86/mtrr: Rename mtrr_overwrite_state() to guest_force_mtrr_state()
2 parents 48795f9 + 79821b9 commit b9d8a29

File tree

24 files changed

+317
-320
lines changed

24 files changed

+317
-320
lines changed

MAINTAINERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,14 @@ L: linux-i2c@vger.kernel.org
11201120
S: Supported
11211121
F: drivers/i2c/busses/i2c-amd-asf-plat.c
11221122

1123+
AMD NODE DRIVER
1124+
M: Mario Limonciello <mario.limonciello@amd.com>
1125+
M: Yazen Ghannam <yazen.ghannam@amd.com>
1126+
L: linux-kernel@vger.kernel.org
1127+
S: Supported
1128+
F: arch/x86/include/asm/amd_node.h
1129+
F: arch/x86/kernel/amd_node.c
1130+
11231131
AMD PDS CORE DRIVER
11241132
M: Shannon Nelson <shannon.nelson@amd.com>
11251133
M: Brett Creeley <brett.creeley@amd.com>

arch/x86/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3128,6 +3128,10 @@ config TS5500
31283128
endif # X86_32
31293129

31303130
config AMD_NB
3131+
def_bool y
3132+
depends on AMD_NODE
3133+
3134+
config AMD_NODE
31313135
def_bool y
31323136
depends on CPU_SUP_AMD && PCI
31333137

arch/x86/hyperv/ivm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ void __init hv_vtom_init(void)
664664
x86_platform.guest.enc_status_change_finish = hv_vtom_set_host_visibility;
665665

666666
/* Set WB as the default cache mode. */
667-
mtrr_overwrite_state(NULL, 0, MTRR_TYPE_WRBACK);
667+
guest_force_mtrr_state(NULL, 0, MTRR_TYPE_WRBACK);
668668
}
669669

670670
#endif /* defined(CONFIG_AMD_MEM_ENCRYPT) || defined(CONFIG_INTEL_TDX_GUEST) */

arch/x86/include/asm/amd_nb.h

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <linux/ioport.h>
66
#include <linux/pci.h>
7+
#include <asm/amd_node.h>
78

89
struct amd_nb_bus_dev_range {
910
u8 bus;
@@ -20,9 +21,6 @@ extern int amd_numa_init(void);
2021
extern int amd_get_subcaches(int);
2122
extern int amd_set_subcaches(int, unsigned long);
2223

23-
int __must_check amd_smn_read(u16 node, u32 address, u32 *value);
24-
int __must_check amd_smn_write(u16 node, u32 address, u32 value);
25-
2624
struct amd_l3_cache {
2725
unsigned indices;
2826
u8 subcaches[4];
@@ -51,23 +49,6 @@ u16 amd_nb_num(void);
5149
bool amd_nb_has_feature(unsigned int feature);
5250
struct amd_northbridge *node_to_amd_nb(int node);
5351

54-
static inline u16 amd_pci_dev_to_node_id(struct pci_dev *pdev)
55-
{
56-
struct pci_dev *misc;
57-
int i;
58-
59-
for (i = 0; i != amd_nb_num(); i++) {
60-
misc = node_to_amd_nb(i)->misc;
61-
62-
if (pci_domain_nr(misc->bus) == pci_domain_nr(pdev->bus) &&
63-
PCI_SLOT(misc->devfn) == PCI_SLOT(pdev->devfn))
64-
return i;
65-
}
66-
67-
WARN(1, "Unable to find AMD Northbridge id for %s\n", pci_name(pdev));
68-
return 0;
69-
}
70-
7152
static inline bool amd_gart_present(void)
7253
{
7354
if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)

arch/x86/include/asm/amd_node.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* AMD Node helper functions and common defines
4+
*
5+
* Copyright (c) 2024, Advanced Micro Devices, Inc.
6+
* All Rights Reserved.
7+
*
8+
* Author: Yazen Ghannam <Yazen.Ghannam@amd.com>
9+
*
10+
* Note:
11+
* Items in this file may only be used in a single place.
12+
* However, it's prudent to keep all AMD Node functionality
13+
* in a unified place rather than spreading throughout the
14+
* kernel.
15+
*/
16+
17+
#ifndef _ASM_X86_AMD_NODE_H_
18+
#define _ASM_X86_AMD_NODE_H_
19+
20+
#include <linux/pci.h>
21+
22+
#define MAX_AMD_NUM_NODES 8
23+
#define AMD_NODE0_PCI_SLOT 0x18
24+
25+
struct pci_dev *amd_node_get_func(u16 node, u8 func);
26+
struct pci_dev *amd_node_get_root(u16 node);
27+
28+
static inline u16 amd_num_nodes(void)
29+
{
30+
return topology_amd_nodes_per_pkg() * topology_max_packages();
31+
}
32+
33+
int __must_check amd_smn_read(u16 node, u32 address, u32 *value);
34+
int __must_check amd_smn_write(u16 node, u32 address, u32 value);
35+
36+
#endif /*_ASM_X86_AMD_NODE_H_*/

arch/x86/include/asm/mtrr.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ struct mtrr_state_type {
5858
*/
5959
# ifdef CONFIG_MTRR
6060
void mtrr_bp_init(void);
61-
void mtrr_overwrite_state(struct mtrr_var_range *var, unsigned int num_var,
62-
mtrr_type def_type);
61+
void guest_force_mtrr_state(struct mtrr_var_range *var, unsigned int num_var,
62+
mtrr_type def_type);
6363
extern u8 mtrr_type_lookup(u64 addr, u64 end, u8 *uniform);
6464
extern void mtrr_save_fixed_ranges(void *);
6565
extern void mtrr_save_state(void);
@@ -75,9 +75,9 @@ void mtrr_disable(void);
7575
void mtrr_enable(void);
7676
void mtrr_generic_set_state(void);
7777
# else
78-
static inline void mtrr_overwrite_state(struct mtrr_var_range *var,
79-
unsigned int num_var,
80-
mtrr_type def_type)
78+
static inline void guest_force_mtrr_state(struct mtrr_var_range *var,
79+
unsigned int num_var,
80+
mtrr_type def_type)
8181
{
8282
}
8383

arch/x86/kernel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
119119
obj-$(CONFIG_HPET_TIMER) += hpet.o
120120

121121
obj-$(CONFIG_AMD_NB) += amd_nb.o
122+
obj-$(CONFIG_AMD_NODE) += amd_node.o
122123
obj-$(CONFIG_DEBUG_NMI_SELFTEST) += nmi_selftest.o
123124

124125
obj-$(CONFIG_KVM_GUEST) += kvm.o kvmclock.o

0 commit comments

Comments
 (0)