[PATCH v7 2/4] platform/x86/amd/hsmp: Route metric table through the client messages
From: Muralidhara M K
Date: Thu Sep 24 2026 - 12:13:11 EST
Wire the client metric table and metric table DRAM address messages
into the metric table read path for the Family 1Ah client platforms,
and fetch the DRAM base for them during ACPI probe.
Add metric_tbl_msg and metric_dram_msg to struct hsmp_plat_desc, and
have hsmp_metric_tbl_read_locked() and hsmp_get_tbl_dram_base() take
the message ID from there instead of a shared constant, since the
client set numbers these messages differently from the server set
(05h/06h vs 24h/25h). Have hsmp_get_tbl_dram_base() take response_sz
from hsmp_msg_response_sz() too, since the client set has no
descriptor table to take it from directly.
Add enum ryzen_master_proto_versions, and split the single unconditional
proto_ver check gating the hsmp_get_tbl_dram_base() call in init_acpi()
into a RYZEN_MASTER_PROTO_VER1 clause for client platforms and a
HSMP_PROTO_VER6 clause for server. proto_ver holds the Ryzen Master
interface version on client platforms, a separate numbering space from
enum hsmp_proto_versions; the single check happened to skip client
today only because RYZEN_MASTER_PROTO_VER1 is numerically below
HSMP_PROTO_VER6, and would misread a higher future client interface
version as HSMP_PROTO_VER6 without the explicit split.
Signed-off-by: Muralidhara M K <muralidhara.mk@xxxxxxx>
Reviewed-by: Mario Limonciello (AMD) <superm1@xxxxxxxxxx>
---
arch/x86/include/uapi/asm/amd_hsmp.h | 9 +++++++++
drivers/platform/x86/amd/hsmp/acpi.c | 3 ++-
drivers/platform/x86/amd/hsmp/hsmp.c | 14 ++++++++++----
3 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/arch/x86/include/uapi/asm/amd_hsmp.h b/arch/x86/include/uapi/asm/amd_hsmp.h
index 7274cf040a66..b4f64b2407b6 100644
--- a/arch/x86/include/uapi/asm/amd_hsmp.h
+++ b/arch/x86/include/uapi/asm/amd_hsmp.h
@@ -106,6 +106,15 @@ enum hsmp_proto_versions {
HSMP_PROTO_VER7
};
+/*
+ * Ryzen Master SMC interface version, reported by
+ * HSMP_CLIENT_GET_INTERFACE_VER. Separate numbering space from enum
+ * hsmp_proto_versions, which applies to the server set only.
+ */
+enum ryzen_master_proto_versions {
+ RYZEN_MASTER_PROTO_VER1 = 1,
+};
+
struct hsmp_msg_desc {
int num_args;
int response_sz;
diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c
index 8257cd1da48e..8b4bf57c3485 100644
--- a/drivers/platform/x86/amd/hsmp/acpi.c
+++ b/drivers/platform/x86/amd/hsmp/acpi.c
@@ -557,7 +557,8 @@ static int init_acpi(struct device *dev)
return ret;
}
- if (hsmp_pdev->proto_ver >= HSMP_PROTO_VER6) {
+ if ((is_client_platform() && hsmp_pdev->proto_ver >= RYZEN_MASTER_PROTO_VER1) ||
+ (!is_client_platform() && hsmp_pdev->proto_ver >= HSMP_PROTO_VER6)) {
ret = hsmp_get_tbl_dram_base(sock_ind);
if (ret)
dev_info(dev, "Failed to init metric table\n");
diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c
index cf33c874096b..ecfd2f92a531 100644
--- a/drivers/platform/x86/amd/hsmp/hsmp.c
+++ b/drivers/platform/x86/amd/hsmp/hsmp.c
@@ -57,6 +57,8 @@ struct hsmp_plat_desc {
u32 num_msgs;
u32 test_msg;
u32 proto_ver_msg;
+ u32 metric_tbl_msg;
+ u32 metric_dram_msg;
};
static const struct hsmp_plat_desc hsmp_desc_server = {
@@ -64,6 +66,8 @@ static const struct hsmp_plat_desc hsmp_desc_server = {
.num_msgs = HSMP_MSG_ID_MAX,
.test_msg = HSMP_TEST,
.proto_ver_msg = HSMP_GET_PROTO_VER,
+ .metric_tbl_msg = HSMP_GET_METRIC_TABLE,
+ .metric_dram_msg = HSMP_GET_METRIC_TABLE_DRAM_ADDR,
};
/*
@@ -77,6 +81,8 @@ static const struct hsmp_plat_desc hsmp_desc_client = {
.num_msgs = HSMP_CLIENT_MSG_ID_MAX,
.test_msg = HSMP_CLIENT_TEST,
.proto_ver_msg = HSMP_CLIENT_GET_INTERFACE_VER,
+ .metric_tbl_msg = HSMP_CLIENT_GET_METRICS_TABLE,
+ .metric_dram_msg = HSMP_CLIENT_GET_METRICS_TABLE_DRAM_ADDR,
};
static struct hsmp_plat_device hsmp_pdev;
@@ -681,11 +687,11 @@ static ssize_t hsmp_metric_tbl_read_locked(struct hsmp_socket *sock, char *buf,
return -EINVAL;
}
- msg.msg_id = HSMP_GET_METRIC_TABLE;
+ msg.msg_id = hsmp_desc()->metric_tbl_msg;
msg.sock_ind = sock->sock_ind;
/*
- * HSMP_GET_METRIC_TABLE makes firmware refill this socket's shared
+ * The metric table message makes firmware refill this socket's shared
* metric DRAM region, which is then copied out below. Hold the
* per-socket lock across the fill-and-copy so concurrent readers of the
* same socket cannot return a torn snapshot.
@@ -751,8 +757,8 @@ int hsmp_get_tbl_dram_base(u16 sock_ind)
int ret;
msg.sock_ind = sock_ind;
- msg.response_sz = hsmp_msg_desc_table[HSMP_GET_METRIC_TABLE_DRAM_ADDR].response_sz;
- msg.msg_id = HSMP_GET_METRIC_TABLE_DRAM_ADDR;
+ msg.msg_id = hsmp_desc()->metric_dram_msg;
+ msg.response_sz = hsmp_msg_response_sz(msg.msg_id);
ret = hsmp_send_message_locked(&msg);
if (ret)
--
2.34.1