[PATCH v2 2/4] platform/x86/amd/hsmp: Route metric table through the client messages
Muralidhara M K <[email protected]> Fri, 31 Jul 2026 21:45:14 +0530
| Newsgroups | org.kernel.vger.platform-driver-x86,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Wire the client metric table and metrics DRAM address messages into the metric table read path for the Family 1Ah client platforms (Models 80h-8Fh and E0h-E3h). The client reaches its metric table through the Ryzen Master SMC message set, so add the two message IDs to struct hsmp_plat_desc and have hsmp_metric_tbl_read_locked() and hsmp_get_tbl_dram_base() take them from there. Unlike the test and version queries, these two are not numbered alike in the two sets - 24h/25h on the server against 05h/06h on the client - which is why they have to come from the descriptor rather than a shared constant. Signed-off-by: Muralidhara M K <[email protected]> --- drivers/platform/x86/amd/hsmp/hsmp.c | 16 ++++++++++++---- drivers/platform/x86/amd/hsmp/hsmp.h | 4 ++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c index 5cb2c4399043..345cc2db7f22 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.c +++ b/drivers/platform/x86/amd/hsmp/hsmp.c @@ -76,6 +76,10 @@ static_assert(ARRAY_SIZE(hsmp_client_msg_desc_table) == HSMP_CLIENT_MSG_ID_MAX); * are also the only ones the two message sets have in common. Messages named * by userspace in an ioctl need no entry here, as that path already resolves * the ID against the running platform's table. + * + * Being common does not mean being numbered alike. The test and version + * queries are 01h and 03h in both sets, but the two metric table messages are + * 24h/25h on the server against 05h/06h on the client. */ static const struct hsmp_plat_desc hsmp_desc_server = { .mbinfo = &hsmp_mbinfo_server, @@ -83,6 +87,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 */ @@ -92,6 +98,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 = { @@ -639,11 +647,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_pdev.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. @@ -709,8 +717,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_pdev.desc->metric_dram_msg; + msg.response_sz = get_msg_desc(msg.msg_id)->response_sz; ret = hsmp_send_message_locked(&msg); if (ret) diff --git a/drivers/platform/x86/amd/hsmp/hsmp.h b/drivers/platform/x86/amd/hsmp/hsmp.h index 3e7814f26635..815804f8054f 100644 --- a/drivers/platform/x86/amd/hsmp/hsmp.h +++ b/drivers/platform/x86/amd/hsmp/hsmp.h @@ -97,6 +97,8 @@ struct hsmp_mbaddr_info { * @test_msg: no-op message used to probe the mailbox. Also the * lowest valid message ID, as ID 0 is reserved. * @proto_ver_msg: returns the interface version. + * @metric_tbl_msg: refills this socket's metric table in DRAM. + * @metric_dram_msg: returns the DRAM address of the metric table. * * Resolved once from the running CPU and reached through hsmp_pdev->desc, so * neither the message plumbing nor the probe paths have to re-derive which @@ -108,6 +110,8 @@ struct hsmp_plat_desc { u32 num_msgs; u32 test_msg; u32 proto_ver_msg; + u32 metric_tbl_msg; + u32 metric_dram_msg; }; struct hsmp_socket { -- 2.34.1