[PATCH 1/7] x86/amd_node: Add a helper for use with `read_poll_timeout`

Mario Limonciello posted 7 patches 10 months ago
[PATCH 1/7] x86/amd_node: Add a helper for use with `read_poll_timeout`
Posted by Mario Limonciello 10 months ago
From: Mario Limonciello <mario.limonciello@amd.com>

Some of the ACP drivers will poll registers through SMN using
`read_poll_timeout` which requires returning the result of the register
read as the argument.

Add a helper to do just that.

Tested by: Venkata Prasad Potturu <venkataprasad.potturu@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 arch/x86/include/asm/amd_node.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/x86/include/asm/amd_node.h b/arch/x86/include/asm/amd_node.h
index 113ad3e8ee40a..9f3f613366f7d 100644
--- a/arch/x86/include/asm/amd_node.h
+++ b/arch/x86/include/asm/amd_node.h
@@ -33,4 +33,15 @@ static inline u16 amd_num_nodes(void)
 int __must_check amd_smn_read(u16 node, u32 address, u32 *value);
 int __must_check amd_smn_write(u16 node, u32 address, u32 value);
 
+/* 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_*/
-- 
2.43.0
[tip: x86/core] x86/amd_node: Add a smn_read_register() helper
Posted by tip-bot2 for Mario Limonciello 9 months ago
The following commit has been merged into the x86/core branch of tip:

Commit-ID:     4476e7f81467b2c1b0aea7383e657181a3f9e652
Gitweb:        https://git.kernel.org/tip/4476e7f81467b2c1b0aea7383e657181a3f9e652
Author:        Mario Limonciello <mario.limonciello@amd.com>
AuthorDate:    Mon, 17 Feb 2025 17:17:41 -06:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 19 Mar 2025 11:18:48 +01:00

x86/amd_node: Add a smn_read_register() helper

Some of the ACP drivers will poll registers through SMN using
read_poll_timeout() which requires returning the result of the register read
as the argument.

Add a helper to do just that.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20250217231747.1656228-2-superm1@kernel.org
---
 arch/x86/include/asm/amd_node.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/x86/include/asm/amd_node.h b/arch/x86/include/asm/amd_node.h
index 002c3af..23fe617 100644
--- a/arch/x86/include/asm/amd_node.h
+++ b/arch/x86/include/asm/amd_node.h
@@ -46,4 +46,15 @@ static inline int __must_check amd_smn_hsmp_rdwr(u16 node, u32 address, u32 *val
 }
 #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_*/
[tip: x86/misc] x86/amd_node: Add a smn_read_register() helper
Posted by tip-bot2 for Mario Limonciello 10 months ago
The following commit has been merged into the x86/misc branch of tip:

Commit-ID:     c893ee3f95f16fcb98da934d61483d0b7d8ed568
Gitweb:        https://git.kernel.org/tip/c893ee3f95f16fcb98da934d61483d0b7d8ed568
Author:        Mario Limonciello <mario.limonciello@amd.com>
AuthorDate:    Mon, 17 Feb 2025 17:17:41 -06:00
Committer:     Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Tue, 18 Feb 2025 18:14:29 +01:00

x86/amd_node: Add a smn_read_register() helper

Some of the ACP drivers will poll registers through SMN using
read_poll_timeout() which requires returning the result of the register read
as the argument.

Add a helper to do just that.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20250217231747.1656228-2-superm1@kernel.org
---
 arch/x86/include/asm/amd_node.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/x86/include/asm/amd_node.h b/arch/x86/include/asm/amd_node.h
index 002c3af..23fe617 100644
--- a/arch/x86/include/asm/amd_node.h
+++ b/arch/x86/include/asm/amd_node.h
@@ -46,4 +46,15 @@ static inline int __must_check amd_smn_hsmp_rdwr(u16 node, u32 address, u32 *val
 }
 #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_*/