[PATCH v6 2/3] platform/x86/amd/hsmp: Route metric table through the client messages

From: Muralidhara M K

Date: Sat Sep 19 2026 - 03:49:08 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).

Add enum ryzen_master_proto_versions, and gate the
hsmp_get_tbl_dram_base() call in init_acpi() on
RYZEN_MASTER_PROTO_VER1 for client platforms, guarding the existing
HSMP_PROTO_VER6 clause with !is_client_platform(). proto_ver holds
the Ryzen Master interface version on client platforms, a separate
numbering space from enum hsmp_proto_versions, so an unguarded
HSMP_PROTO_VER6 check could misread a future client interface
version as a server protocol version.

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 56317e9298b8..9641e5977c2e 100644
--- a/arch/x86/include/uapi/asm/amd_hsmp.h
+++ b/arch/x86/include/uapi/asm/amd_hsmp.h
@@ -95,6 +95,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 3e27287c0517..bb1f130806ad 100644
--- a/drivers/platform/x86/amd/hsmp/hsmp.c
+++ b/drivers/platform/x86/amd/hsmp/hsmp.c
@@ -184,6 +184,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 = {
@@ -191,6 +193,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,
};

/* The client drives a different mailbox with the Ryzen Master SMC message set */
@@ -199,6 +203,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;
@@ -753,11 +759,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.
@@ -823,8 +829,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 = get_msg_desc(msg.msg_id)->response_sz;

ret = hsmp_send_message_locked(&msg);
if (ret)
--
2.34.1