Skip to content

Commit e6e6e5e

Browse files
yghannambp3tk0v
authored andcommitted
x86: Start moving AMD node functionality out of AMD_NB
The "AMD Node" concept spans many families of systems and applies to a number of subsystems and drivers. Currently, the AMD Northbridge code is overloaded with AMD node functionality. However, the node concept is broader than just northbridges. Start files to host common AMD node functions and definitions. Include a helper to find an AMD node device function based on the convention described in AMD documentation. Anything that needs node functionality should include this rather than amd_nb.h. The AMD_NB code will be reduced to only northbridge-specific code needed for legacy systems. Signed-off-by: Yazen Ghannam <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e13f51b commit e6e6e5e

File tree

5 files changed

+73
-0
lines changed

5 files changed

+73
-0
lines changed

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,13 @@ L: [email protected]
11211121
S: Supported
11221122
F: drivers/i2c/busses/i2c-amd-asf-plat.c
11231123

1124+
AMD NODE DRIVER
1125+
M: Yazen Ghannam <[email protected]>
1126+
1127+
S: Supported
1128+
F: arch/x86/include/asm/amd_node.h
1129+
F: arch/x86/kernel/amd_node.c
1130+
11241131
AMD PDS CORE DRIVER
11251132
M: Shannon Nelson <[email protected]>
11261133
M: Brett Creeley <[email protected]>

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/include/asm/amd_node.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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 <[email protected]>
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+
27+
#endif /*_ASM_X86_AMD_NODE_H_*/

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

arch/x86/kernel/amd_node.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
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 <[email protected]>
9+
*/
10+
11+
#include <asm/amd_node.h>
12+
13+
/*
14+
* AMD Nodes are a physical collection of I/O devices within an SoC. There can be one
15+
* or more nodes per package.
16+
*
17+
* The nodes are software-visible through PCI config space. All nodes are enumerated
18+
* on segment 0 bus 0. The device (slot) numbers range from 0x18 to 0x1F (maximum 8
19+
* nodes) with 0x18 corresponding to node 0, 0x19 to node 1, etc. Each node can be a
20+
* multi-function device.
21+
*
22+
* On legacy systems, these node devices represent integrated Northbridge functionality.
23+
* On Zen-based systems, these node devices represent Data Fabric functionality.
24+
*
25+
* See "Configuration Space Accesses" section in BKDGs or
26+
* "Processor x86 Core" -> "Configuration Space" section in PPRs.
27+
*/
28+
struct pci_dev *amd_node_get_func(u16 node, u8 func)
29+
{
30+
if (node >= MAX_AMD_NUM_NODES)
31+
return NULL;
32+
33+
return pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(AMD_NODE0_PCI_SLOT + node, func));
34+
}

0 commit comments

Comments
 (0)