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

"M K, Muralidhara" <[email protected]> Thu, 30 Jul 2026 15:12:11 +0530
Newsgroups org.kernel.vger.platform-driver-x86,org.kernel.vger.linux-kernel
Message-ID <[email protected]>

On 7/30/2026 2:59 AM, Mario Limonciello wrote:
> 
> 
> On 7/29/26 11:40, Muralidhara M K wrote:
>> 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), and initialise the metric table on the platform
>> driver probe.
>>
>> 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.
>>
>> Fetch the metric table on the client whatever interface version was
>> reported. That query is already non-fatal there, since some client SMU
>> builds reject it while the mailbox works, so hsmp_pdev->proto_ver cannot
>> gate the client metric table the way HSMP_PROTO_VER6 gates it on the
>> server.
>>
>> Signed-off-by: Muralidhara M K <[email protected]>
>> ---
>>   drivers/platform/x86/amd/hsmp/hsmp.c | 16 ++++++++++++----
>>   drivers/platform/x86/amd/hsmp/hsmp.h |  4 ++++
>>   drivers/platform/x86/amd/hsmp/plat.c |  7 ++++++-
>>   3 files changed, 22 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/ 
>> x86/amd/hsmp/hsmp.c
>> index 9b65dbd47965..2326506929a4 100644
>> --- a/drivers/platform/x86/amd/hsmp/hsmp.c
>> +++ b/drivers/platform/x86/amd/hsmp/hsmp.c
>> @@ -65,6 +65,10 @@ static const struct hsmp_mbaddr_info 
>> hsmp_mbinfo_client = {
>>    * 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,
>> @@ -72,6 +76,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 */
>> @@ -81,6 +87,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 = {
>> @@ -643,11 +651,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.
>> @@ -713,8 +721,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 b4bd9800dee1..c46d53dbcd43 100644
>> --- a/drivers/platform/x86/amd/hsmp/hsmp.h
>> +++ b/drivers/platform/x86/amd/hsmp/hsmp.h
>> @@ -103,6 +103,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.
>>    */
>>   struct hsmp_plat_desc {
>>       const struct hsmp_mbaddr_info    *mbinfo;
>> @@ -110,6 +112,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 {
>> diff --git a/drivers/platform/x86/amd/hsmp/plat.c b/drivers/platform/ 
>> x86/amd/hsmp/plat.c
>> index 7423c98a7b3e..bc29b0ec18f7 100644
>> --- a/drivers/platform/x86/amd/hsmp/plat.c
>> +++ b/drivers/platform/x86/amd/hsmp/plat.c
>> @@ -185,7 +185,12 @@ static int init_platform_device(struct device *dev)
>>               dev_warn(dev, "Interface version query unsupported on 
>> client SMU; continuing\n");
>>           }
>> -        if (hsmp_pdev->proto_ver == HSMP_PROTO_VER6) {
>> +        /*
>> +         * On the client the metric table is fetched with
>> +         * HSMP_CLIENT_GET_METRICS_TABLE_DRAM_ADDR whatever interface
>> +         * version was reported, since that query may be unsupported.
>> +         */
> 
> What version was reported on client platforms?  Since it's the first 
> time client is being supported with HSMP, maybe it's best that client 
> should be reporting 6.
> 
> Then this part of the patch could get dropped later.
> 
Currently client version is different than server. So it needs a 
explicit condition for client programs.
But, I will check with the SMU team on this.

>> +        if (is_client_platform() || hsmp_pdev->proto_ver == 
>> HSMP_PROTO_VER6) {
>>               ret = hsmp_get_tbl_dram_base(i);
>>               if (ret)
>>                   dev_info(dev, "Failed to init metric table\n");
>