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

From: Muralidhara M K

Date: Fri Oct 09 2026 - 02:16:54 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, lifting the
defensive client exclusion placed on that call several commits ago.

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 replace the single
!is_client_platform() exclusion guarding the hsmp_get_tbl_dram_base()
call in init_acpi() with a RYZEN_MASTER_PROTO_VER1 clause for client
platforms alongside the existing 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;
gating the two platforms on their own version enum avoids relying on
numeric coincidence between the two, and lets a client interface
version bump be reasoned about independently of the 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 | 11 +++++++++--
drivers/platform/x86/amd/hsmp/hsmp.c | 14 ++++++++++----
3 files changed, 28 insertions(+), 6 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 1e5028aea54b..167c76c13ad0 100644
--- a/drivers/platform/x86/amd/hsmp/acpi.c
+++ b/drivers/platform/x86/amd/hsmp/acpi.c
@@ -567,8 +567,15 @@ static int init_acpi(struct device *dev)
return ret;
}

- /* Exclude client platforms from the metric table DRAM base lookup */
- if (!is_client_platform() && hsmp_pdev->proto_ver >= HSMP_PROTO_VER6) {
+ /*
+ * proto_ver holds the Ryzen Master interface version on client
+ * platforms, a separate numbering space from enum
+ * hsmp_proto_versions; gate the two platforms on their own
+ * version enum rather than relying on numeric coincidence
+ * between the two.
+ */
+ 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 87765116952a..84022a7f47a5 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