Commit 735049b8 authored by Yazen Ghannam's avatar Yazen Ghannam Committed by Borislav Petkov (AMD)
Browse files

x86/amd_node, platform/x86/amd/hsmp: Have HSMP use SMN through AMD_NODE



The HSMP interface is just an SMN interface with different offsets.

Define an HSMP wrapper in the SMN code and have the HSMP platform driver
use that rather than a local solution.

Also, remove the "root" member from AMD_NB, since there are no more
users of it.

Signed-off-by: default avatarYazen Ghannam <yazen.ghannam@amd.com>
Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: default avatarCarlos Bilbao <carlos.bilbao@kernel.org>
Acked-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20250130-wip-x86-amd-nb-cleanup-v4-1-b5cc997e471b@amd.com
parent e3cd8596
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ struct amd_l3_cache {
};

struct amd_northbridge {
	struct pci_dev *root;
	struct pci_dev *misc;
	struct pci_dev *link;
	struct amd_l3_cache l3_cache;
+13 −0
Original line number Diff line number Diff line
@@ -30,7 +30,20 @@ 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 */

#endif /*_ASM_X86_AMD_NODE_H_*/
+0 −1
Original line number Diff line number Diff line
@@ -73,7 +73,6 @@ static int amd_cache_northbridges(void)
	amd_northbridges.nb = nb;

	for (i = 0; i < amd_northbridges.num; i++) {
		node_to_amd_nb(i)->root = amd_node_get_root(i);
		node_to_amd_nb(i)->misc = amd_node_get_func(i, 3);

		/*
+9 −0
Original line number Diff line number Diff line
@@ -97,6 +97,9 @@ static DEFINE_MUTEX(smn_mutex);
#define SMN_INDEX_OFFSET	0x60
#define SMN_DATA_OFFSET		0x64

#define HSMP_INDEX_OFFSET	0xc4
#define HSMP_DATA_OFFSET	0xc8

/*
 * SMN accesses may fail in ways that are difficult to detect here in the called
 * functions amd_smn_read() and amd_smn_write(). Therefore, callers must do
@@ -179,6 +182,12 @@ int __must_check amd_smn_write(u16 node, u32 address, u32 value)
}
EXPORT_SYMBOL_GPL(amd_smn_write);

int __must_check amd_smn_hsmp_rdwr(u16 node, u32 address, u32 *value, bool write)
{
	return __amd_smn_rw(HSMP_INDEX_OFFSET, HSMP_DATA_OFFSET, node, address, value, write);
}
EXPORT_SYMBOL_GPL(amd_smn_hsmp_rdwr);

static int amd_cache_roots(void)
{
	u16 node, num_nodes = amd_num_nodes();
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ config AMD_HSMP
	tristate

menu "AMD HSMP Driver"
	depends on AMD_NB || COMPILE_TEST
	depends on AMD_NODE || COMPILE_TEST

config AMD_HSMP_ACPI
	tristate "AMD HSMP ACPI device driver"
Loading