diff options
| author | Ingo Molnar <[email protected]> | 2025-04-22 06:31:41 +0000 |
|---|---|---|
| committer | Ingo Molnar <[email protected]> | 2025-04-22 06:31:41 +0000 |
| commit | c96f564e6f943cf5d8536e1c43f243aa7c42b4ed (patch) | |
| tree | ada98ccab9b31fe9519b4e6ea2beec63ad98cb16 /arch/x86/include/asm/amd/node.h | |
| parent | x86/microcode/AMD: Clean the cache if update did not load microcode (diff) | |
| parent | Merge branch 'linus' into x86/cpu, to resolve conflicts (diff) | |
| download | kernel-c96f564e6f943cf5d8536e1c43f243aa7c42b4ed.tar.gz kernel-c96f564e6f943cf5d8536e1c43f243aa7c42b4ed.zip | |
Merge branch 'x86/cpu' into x86/microcode, to pick up dependent commits
Avoid a conflict in <asm/cpufeatures.h> by merging pending x86/cpu changes.
Signed-off-by: Ingo Molnar <[email protected]>
Diffstat (limited to 'arch/x86/include/asm/amd/node.h')
| -rw-r--r-- | arch/x86/include/asm/amd/node.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/arch/x86/include/asm/amd/node.h b/arch/x86/include/asm/amd/node.h new file mode 100644 index 000000000000..23fe617898a8 --- /dev/null +++ b/arch/x86/include/asm/amd/node.h @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * AMD Node helper functions and common defines + * + * Copyright (c) 2024, Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Author: Yazen Ghannam <[email protected]> + * + * Note: + * Items in this file may only be used in a single place. + * However, it's prudent to keep all AMD Node functionality + * in a unified place rather than spreading throughout the + * kernel. + */ + +#ifndef _ASM_X86_AMD_NODE_H_ +#define _ASM_X86_AMD_NODE_H_ + +#include <linux/pci.h> + +#define MAX_AMD_NUM_NODES 8 +#define AMD_NODE0_PCI_SLOT 0x18 + +struct pci_dev *amd_node_get_func(u16 node, u8 func); +struct pci_dev *amd_node_get_root(u16 node); + +static inline u16 amd_num_nodes(void) +{ + return topology_amd_nodes_per_pkg() * topology_max_packages(); +} + +#ifdef CONFIG_AMD_NODE +int __must_check amd_smn_read(u16 node, u32 address, u32 *value); +int __must_check amd_smn_write(u16 node, u32 address, u32 value); + +/* Should only be used by the HSMP driver. */ +int __must_check amd_smn_hsmp_rdwr(u16 node, u32 address, u32 *value, bool write); +#else +static inline int __must_check amd_smn_read(u16 node, u32 address, u32 *value) { return -ENODEV; } +static inline int __must_check amd_smn_write(u16 node, u32 address, u32 value) { return -ENODEV; } + +static inline int __must_check amd_smn_hsmp_rdwr(u16 node, u32 address, u32 *value, bool write) +{ + return -ENODEV; +} +#endif /* CONFIG_AMD_NODE */ + +/* helper for use with read_poll_timeout */ +static inline int smn_read_register(u32 reg) +{ + int data, rc; + + rc = amd_smn_read(0, reg, &data); + if (rc) + return rc; + + return data; +} +#endif /*_ASM_X86_AMD_NODE_H_*/ |
