platform/x86/amd/hsmp: Family 1Ah client support
Subsystems (4)
v9 cover platform/x86/amd/hsmp: Family 1Ah client support
This series enables the HSMP driver on the Family 1Ah client platforms, Models 80h-8Fh and E0h-E3h.
The client parts probe through the same ACPI _CRS/_DSD as a server socket, but drive a different mailbox and speak the Ryzen Master SMC message set instead of server message IDs.
Patch 1 adds is_client_platform() and hides the pre-existing hwmon attributes, ACPI sysfs attributes, metrics_bin, and metric-table DRAM-base lookup on client platforms, and restricts /dev/hsmp to 0600 there. Patch 2 adds the client message set and routes it through the existing MMIO path. Patch 3 wires the client metric-table messages into the metric-table read path. Patch 4 adds the client telemetry table.
Changes in v9:
- Patch 1: fixed a build failure on CONFIG_ACPI=n configs reported by the kernel test robot. is_client_platform() now gates the acpi_gbl_FADT access with #if IS_ENABLED(CONFIG_ACPI) instead of a runtime check, which does not stop the compiler type-checking the dead branch.
Changes in v8:
- Reordered the series per review from Ilpo Jarvinen: patch 1 now adds is_client_platform() and every client-platform exclusion (attribute hiding, DRAM-base lookup, /dev/hsmp mode) before patch 2 adds client message routing.
- Patch 3 upgrades patch 1's defensive DRAM-base guard to the full RYZEN_MASTER_PROTO_VER1/HSMP_PROTO_VER6 check.
- Patch 4 unchanged.
- Tightened commit messages and code comments to an imperative, concise style.
Changes in v7:
- The client message set no longer has a per-message descriptor table (hsmp_client_msg_desc_table is gone).
Validate num_args and response_sz with HSMP_CLIENT_MAX_MSG_LEN.
- /dev/hsmp is now registered at 0600 on client platforms instead of 0644, since hsmp_ioctl_msg() has no per-message GET/SET gate there and any opener could otherwise issue a destructive client SET message; server platforms are unaffected.
- New patch 3: the pre-existing hwmon registration, ACPI sysfs device attributes and metrics_bin visibility predate the client message set and are wired to hardcoded server message IDs, which mostly collide with unrelated client commands on a client platform. Guard all three with is_client_platform(), keeping smu_fw_version and protocol_version visible since they report the same data on both message sets.
Changes in v6:
- Patch 1: dropped "inline" from get_msg_desc() too, for the same reason as hsmp_desc(): it does a range check and a reserved-type check, not a trivial accessor, so let the compiler decide.
- Squashed what was patch 3 ("Add ACPI client support for Family 1Ah") into patch 2. Patches 1+2 alone, without the old patch 3, would have left hsmp_metric_tbl_read_locked()'s new client message routing unreachable: hsmp_get_tbl_dram_base() never runs on a client platform until the ACPI DRAM-base gate lands, so the two belong together as one atomic change.
- Patch 2 (now including the former patch 3): also guard the pre-existing server proto_ver clause with !is_client_platform(), not just the new client clause, per review. hsmp_pdev->proto_ver is a small Ryzen Master interface version number today, but nothing stops a future client interface version from reaching HSMP_PROTO_VER6 (6) and making that clause spuriously true on a client platform.
- Series is now 3 patches instead of 4, following the squash above and addressed the review comments.
Changes in v5:
- Patch 3: hsmp_pdev->proto_ver holds the Ryzen Master SMC interface version on client platforms, a separate numbering space from the server protocol versions in enum hsmp_proto_versions.
Changes in v4:
- SMU now answers the interface version query on client platforms, so hsmp_desc_client.proto_ver_msg goes back to HSMP_CLIENT_GET_INTERFACE_VER instead of HSMP_CLIENT_GET_METRICS_TABLE_VER. Patch 3 is back down to just the ACPI metric-table-DRAM-base change, since that was the only other thing it did.
Changes in v3:
- is_client_platform() now tells client and server apart through the ACPI-reported PM profile (FADT preferred_profile) instead of a hardcoded Family 1Ah model range, the same signal amd-pstate already keys off of. Future client generations are recognised as long as firmware reports the right PM profile, with no driver update needed.
- hsmp_desc() now resolves the running platform's descriptor once and caches the pointer behind READ_ONCE()/WRITE_ONCE() instead of recomputing it on every call. Concurrent first callers are benign, since every one of them computes and stores that same pointer, so the pair only needs to keep the load/store from being torn or reordered by the compiler, not order it against anything else.
- The client message enum in amd_hsmp.h is now documented with kernel-doc, one @member entry per message describing its inputs and outputs, rather than a block comment plus a same-line comment per enumerator. Noted there that not every platform supports every message and that an unsupported one returns -ENOMSG.
- Patch 4: the Telemetry Table RM layout moved out of the .rst and into amd_hsmp.h as real kernel-doc'd struct/enum declarations, giving userspace one authoritative definition of the byte layout. The .rst now just points at struct hsmp_telemetry_table_rm. The structs are now also packed to a 4-byte boundary to match firmware's actual layout, and the trailing NPU/PMF counters and spare padding firmware carries after the overclocking fields are no longer missing. Verified field-by-field against AMD's internal metrics table header and end-to-end against a live snapshot off Family 1Ah client hardware.
Each patch builds individually and is clean under checkpatch.pl --strict.
Muralidhara M K (4):
platform/x86/amd/hsmp: Recognize Family 1Ah client platforms and hide
server-only paths
platform/x86/amd/hsmp: Add HSMP client support for Family 1Ah platform/x86/amd/hsmp: Route metric table through the client messages platform/x86/amd/hsmp: Document and expose client telemetry table in
UAPI
Documentation/arch/x86/amd_hsmp.rst | 24 +- arch/x86/include/uapi/asm/amd_hsmp.h | 420 +++++++++++++++++++++++++++ drivers/platform/x86/amd/hsmp/acpi.c | 31 +- drivers/platform/x86/amd/hsmp/hsmp.c | 248 +++++++++++----- drivers/platform/x86/amd/hsmp/hsmp.h | 24 ++ 5 files changed, 676 insertions(+), 71 deletions(-)
base-commit: 6c377d19d4a5116d9bec5203aa3c6c11523e7898
Signature · 1 line
2.34.1
PATCH v9 1/4 platform/x86/amd/hsmp: Recognize Family 1Ah client platforms and hide server-only paths
Add is_client_platform(), based on the ACPI-reported PM profile and an AMD vendor check, to detect Family 1Ah client platforms, Models 80h-8Fh and E0h-E3h.
Use is_client_platform() to:
- Hide every ACPI sysfs device attribute except smu_fw_version and protocol_version on client platforms.
- Hide the metrics_bin sysfs binary attribute on client platforms.
- Skip hsmp_create_sensor() in init_acpi() on client platforms.
- Exclude client platforms from the HSMP_GET_METRIC_TABLE_DRAM_ADDR lookup in init_acpi().
- Register /dev/hsmp at 0600 on client platforms, 0644 on server.
--- drivers/platform/x86/amd/hsmp/acpi.c | 24 +++++++++++++++++++----- drivers/platform/x86/amd/hsmp/hsmp.c | 8 +++++++- drivers/platform/x86/amd/hsmp/hsmp.h | 24 ++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 6 deletions(-)
drivers/platform/x86/amd/hsmp/acpi.c +19 -5
@@ -300,16 +300,26 @@ static umode_t hsmp_is_sock_attr_visible(struct kobject *kobj,* so that userspace which expects the file to exist gets a clear * -EOPNOTSUPP from the read handler instead of -ENOENT, and is * pointed at HSMP_IOCTL_GET_TELEMETRY_DATA as the supported path. +* Hide metrics_bin on client platforms. */ -if (hsmp_pdev->proto_ver >=HSMP_PROTO_VER6 ) +if (!is_client_platform () && hsmp_pdev->proto_ver >=HSMP_PROTO_VER6 )return battr->attr.mode;return 0 ; } +/* Defined below by HSMP_DEV_ATTR() */ +static struct hsmp_sys_attr hattr_smu_fw_version; +static struct hsmp_sys_attr hattr_protocol_version; +static umode_t hsmp_is_sock_dev_attr_visible (struct kobject *kobj,struct attribute *attr,int id) { +/* Hide every attribute except smu_fw_version and protocol_version on client platforms */ +if (is_client_platform () && attr != &hattr_smu_fw_version.dattr.attr && + attr != &hattr_protocol_version.dattr.attr) +return 0 ; +return attr->mode; }
@@ -557,15 +567,19 @@ static int init_acpi(struct device *dev)return ret; } -if (hsmp_pdev->proto_ver >=HSMP_PROTO_VER6 ) { +/* Exclude client platforms from the metric table DRAM base lookup */ +if (!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" ); } - ret =hsmp_create_sensor (dev, sock_ind); -if (ret) -dev_info (dev,"Failed to register HSMP sensors with hwmon\n" ); +/* Skip hwmon registration on client platforms */ +if (!is_client_platform ()) { + ret =hsmp_create_sensor (dev, sock_ind); +if (ret) +dev_info (dev,"Failed to register HSMP sensors with hwmon\n" ); + }dev_set_drvdata (dev, &hsmp_pdev->sock[sock_ind]);
drivers/platform/x86/amd/hsmp/hsmp.c +7 -1
@@ -720,7 +720,13 @@ int hsmp_misc_register(struct device *dev)*/ hsmp_pdev.mdev.parent = dev; hsmp_pdev.mdev.nodename =HSMP_DEVNODE_NAME ; - hsmp_pdev.mdev.mode =0644 ; +/* +* hsmp_msg_desc_table[] only describes server messages. On client +* platforms, msg_id mappings differ, making access checks unreliable. +* Restrict /dev/hsmp to root until client-specific validation is +* added. +*/ + hsmp_pdev.mdev.mode =is_client_platform () ?0600 :0644 ;return misc_register (&hsmp_pdev.mdev); }
drivers/platform/x86/amd/hsmp/hsmp.h +24 -0
@@ -10,6 +10,9 @@#ifndef HSMP_H #define HSMP_H +#include <asm/amd/hsmp.h> + +#include <linux/acpi.h> #include <linux/compiler_types.h> #include <linux/device.h> #include <linux/hwmon.h>
@@ -17,6 +20,7 @@#include <linux/miscdevice.h> #include <linux/mutex.h> #include <linux/pci.h> +#include <linux/processor.h> #include <linux/rwsem.h> #include <linux/semaphore.h> #include <linux/sysfs.h>
@@ -32,6 +36,26 @@#define DRIVER_VERSION "2.6" +/* True when the ACPI-reported PM profile indicates a client platform */ +static inline bool is_client_platform (void ) +{ +if (boot_cpu_data.x86_vendor !=X86_VENDOR_AMD ) +return false; + +#if IS_ENABLED (CONFIG_ACPI ) +switch (acpi_gbl_FADT.preferred_profile) { +case PM_DESKTOP : +case PM_MOBILE : +case PM_TABLET : +return true; +default : +return false; + } +#else +return false; +#endif +} +struct hsmp_mbaddr_info {u32 base_addr;u32 msg_id_off;
Signature · 1 line
2.34.1
PATCH v9 2/4 platform/x86/amd/hsmp: Add HSMP client support for Family 1Ah
In reply to Muralidhara M KAdd HSMP client support for the Family 1Ah client platforms, Models 80h-8Fh and E0h-E3h, recognized by the previous commit via is_client_platform(). These parts speak the Ryzen Master SMC (RMSMC) message set instead of the server HSMP messages, and probe via ACPI _CRS/_DSD like a server socket.
Add the client message set to the UAPI header. Introduce struct hsmp_plat_desc to select the test message and protocol-version message at runtime, based on is_client_platform() rather than a fixed set of family/model ranges.
The client set has no per-message descriptor table. validate_message() and hsmp_ioctl_msg() therefore skip msg_id range validation and the /dev/hsmp GET/SET fd-mode gate for client messages, leaving msg_id validity to firmware's response status; validate_message() still bounds client num_args and response_sz to HSMP_CLIENT_MAX_MSG_LEN. Server platforms keep every check, and get_msg_desc() now also enforces a lower msg_id bound there. get_msg_desc() sanitizes msg_id with array_index_nospec() against its own num_msgs bound before indexing the descriptor table, rather than depending on a caller-side clamp. Add hsmp_msg_response_sz(), returning the descriptor table entry on server and the client protocol max otherwise, used by hsmp_cache_proto_ver() since firmware returns only args[0] for client. validate_message() and hsmp_ioctl_msg() distinguish the two sets via the already-resolved hsmp_plat_desc/hsmp_msg_desc pointers, not a second is_client_platform() call.
The /dev/hsmp 0600 restriction and every sysfs/hwmon attribute hidden on client platforms stay from the previous commit: hsmp_ioctl_msg() still has no GET/SET gate for client messages, so an unprivileged opener could otherwise issue destructive SET messages, and the hidden attributes still resolve against unrelated client commands. Lifting either restriction is deferred to the commits that make the corresponding client functionality safe to expose.
Document the client models in amd_hsmp.rst.
--- Documentation/arch/x86/amd_hsmp.rst | 10 +- arch/x86/include/uapi/asm/amd_hsmp.h | 154 ++++++++++++++++++ drivers/platform/x86/amd/hsmp/hsmp.c | 226 ++++++++++++++++++++------- 3 files changed, 329 insertions(+), 61 deletions(-)
Documentation/arch/x86/amd_hsmp.rst +9 -1
@@ -8,6 +8,13 @@ Newer Fam19h(model 0x00-0x1f, 0x30-0x3f, 0x90-0x9f, 0xa0-0xaf), Fam1Ah(model 0x00-0x1f) EPYC server line of processors from AMD support system management functionality via HSMP (Host System Management Port). +The Fam1Ah(model 0x80-0x8f, 0xe0-0xe3) client line of processors is +supported as well. Those models share one mailbox and speak the Ryzen +Master SMC message set instead of the server HSMP message set, so the +message IDs accepted on them are the HSMP_CLIENT_* ones listed in +arch/x86/include/uapi/asm/amd_hsmp.h. The character device and ioctl +interface described below are the same. + The Host System Management Port (HSMP) is an interface to provide OS-level software with access to system management functions via a set of mailbox registers.
@@ -17,7 +24,8 @@ More details on the interface can be found in chapter Eg: https://docs.amd.com/v/u/en-US/55898_B1_pub_0_50 -HSMP interface is supported on EPYC line of server CPUs and MI300A (APU). +HSMP interface is supported on EPYC line of server CPUs, MI300A (APU) and +the Fam1Ah client models listed above. HSMP device
arch/x86/include/uapi/asm/amd_hsmp.h +154 -0
170 lines not on this page · raw message
drivers/platform/x86/amd/hsmp/hsmp.c +166 -60
303 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v9 3/4 platform/x86/amd/hsmp: Route metric table through the client messages
In reply to Muralidhara M KWire 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.
--- 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(-)
arch/x86/include/uapi/asm/amd_hsmp.h +9 -0
@@ -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;
drivers/platform/x86/amd/hsmp/acpi.c +9 -2
@@ -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" );
drivers/platform/x86/amd/hsmp/hsmp.c +10 -4
@@ -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;
@@ -671,11 +677,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.
@@ -741,8 +747,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)
Signature · 1 line
2.34.1
PATCH v9 4/4 platform/x86/amd/hsmp: Document and expose client telemetry table in UAPI
In reply to Muralidhara M KAdd struct hsmp_telemetry_table_rm to the UAPI header, describing the Ryzen Master SMC telemetry table (table version 5, as reported by HSMP_CLIENT_GET_METRICS_TABLE_VER) returned by HSMP_CLIENT_GET_METRICS_TABLE on the Family 1Ah client models, now that the previous commit wires that message up to a usable DRAM mapping.
Point amd_hsmp.rst at struct hsmp_telemetry_table_rm instead of duplicating the layout in prose. The Public PPR for the model in use remains the reference for units and encodings.
--- Documentation/arch/x86/amd_hsmp.rst | 14 ++ arch/x86/include/uapi/asm/amd_hsmp.h | 257 +++++++++++++++++++++++++++ 2 files changed, 271 insertions(+)
Documentation/arch/x86/amd_hsmp.rst +14 -0
@@ -221,9 +221,23 @@ The following IOCTLs are defined: ``sizeof(struct hsmp_metric_table)``. Later version metrics table layout is documented in the Public PPR. + The Family 1Ah client models carry their own telemetry table instead, + described in `Family 1Ah client telemetry table`_ below. + The ioctl would return a non-zero on failure; you can read errno to see what happened. The transaction returns 0 on success. +Family 1Ah client telemetry table +================================= +On the Family 1Ah client models, ``HSMP_CLIENT_GET_METRICS_TABLE`` (05h) +returns the Ryzen Master SMC telemetry table, table version 5 as +reported by ``HSMP_CLIENT_GET_METRICS_TABLE_VER`` (04h). This is the +Telemetry Table RM layout, defined as ``struct hsmp_telemetry_table_rm`` +in amd_hsmp.h. The driver copies the table out without interpreting it. + +See the telemetry table chapter of the AMD Public PPR for the model in +use for the units and encodings of its fields. + More details on the interface and message definitions can be found in chapter "7 Host System Management Port (HSMP)" of the respective family/model PPR eg: https://docs.amd.com/v/u/en-US/55898_B1_pub_0_50
arch/x86/include/uapi/asm/amd_hsmp.h +257 -0
261 lines not on this page · raw message
Signature · 1 line
2.34.1
Ilpo Järvinen
maintainerQuoted 15 lines · Muralidhara M K
This series enables the HSMP driver on the Family 1Ah client platforms, Models 80h-8Fh and E0h-E3h.
The client parts probe through the same ACPI _CRS/_DSD as a server socket, but drive a different mailbox and speak the Ryzen Master SMC message set instead of server message IDs.
Patch 1 adds
is_client_platform()and hides the pre-existing hwmon attributes, ACPI sysfs attributes,metrics_bin, and metric-table DRAM-base lookup on client platforms, and restricts/dev/hsmpto 0600 there. Patch 2 adds the client message set and routes it through the existing MMIO path. Patch 3 wires the client metric-table messages into the metric-table read path. Patch 4 adds the client telemetry table.
Quoted 7 lines
Changes in v9:
- Patch 1: fixed a build failure on
CONFIG_ACPI=nconfigs reported by the kernel test robot.is_client_platform()now gates theacpi_gbl_FADTaccess with #ifIS_ENABLED(CONFIG_ACPI)instead of a runtime check, which does not stop the compiler type-checking the dead branch.
Hi,
I've taken this to the review-ilpo-next branch now.
But please do check the args[0] access mention from sashiko. It looks to me it results just incorrect error code at worst if num_args is 0 (-EPERM vs -EINVAL). As it also looked to be a pre-existing issue, I didn't want to delay this with yet another round because of it but it seems still worth to address if it turns out to be a valid observation.
--
i.
Quoted 115 lines
Changes in v8:
- Reordered the series per review from Ilpo Jarvinen: patch 1 now adds
is_client_platform()and every client-platform exclusion (attribute hiding, DRAM-base lookup,/dev/hsmpmode) before patch 2 adds client message routing.
- Patch 3 upgrades patch 1's defensive DRAM-base guard to the full RYZEN_MASTER_PROTO_VER1/HSMP_PROTO_VER6 check.
- Patch 4 unchanged.
- Tightened commit messages and code comments to an imperative, concise style.Changes in v7:
- The client message set no longer has a per-message descriptor table (
hsmp_client_msg_desc_tableis gone).
Validatenum_argsandresponse_szwithHSMP_CLIENT_MAX_MSG_LEN.
-/dev/hsmpis now registered at 0600 on client platforms instead of 0644, sincehsmp_ioctl_msg()has no per-message GET/SET gate there and any opener could otherwise issue a destructive client SET message; server platforms are unaffected.
- New patch 3: the pre-existing hwmon registration, ACPI sysfs device attributes andmetrics_binvisibility predate the client message set and are wired to hardcoded server message IDs, which mostly collide with unrelated client commands on a client platform. Guard all three withis_client_platform(), keepingsmu_fw_versionandprotocol_versionvisible since they report the same data on both message sets.Changes in v6:
- Patch 1: dropped "inline" from
get_msg_desc()too, for the same reason ashsmp_desc(): it does a range check and a reserved-type check, not a trivial accessor, so let the compiler decide.
- Squashed what was patch 3 ("Add ACPI client support for Family 1Ah") into patch 2. Patches 1+2 alone, without the old patch 3, would have left hsmp_metric_tbl_read_locked()'s new client message routing unreachable:hsmp_get_tbl_dram_base()never runs on a client platform until the ACPI DRAM-base gate lands, so the two belong together as one atomic change.
- Patch 2 (now including the former patch 3): also guard the pre-existing serverproto_verclause with !is_client_platform(), not just the new client clause, per review.hsmp_pdev->proto_veris a small Ryzen Master interface version number today, but nothing stops a future client interface version from reachingHSMP_PROTO_VER6(6) and making that clause spuriously true on a client platform.
- Series is now 3 patches instead of 4, following the squash above and addressed the review comments.Changes in v5:
- Patch 3:
hsmp_pdev->proto_verholds the Ryzen Master SMC interface version on client platforms, a separate numbering space from the server protocol versions in enumhsmp_proto_versions.Changes in v4:
- SMU now answers the interface version query on client platforms, so hsmp_desc_client.proto_ver_msg goes back to
HSMP_CLIENT_GET_INTERFACE_VERinstead ofHSMP_CLIENT_GET_METRICS_TABLE_VER. Patch 3 is back down to just the ACPI metric-table-DRAM-base change, since that was the only other thing it did.Changes in v3:
-
is_client_platform()now tells client and server apart through the ACPI-reported PM profile (FADTpreferred_profile) instead of a hardcoded Family 1Ah model range, the same signal amd-pstate already keys off of. Future client generations are recognised as long as firmware reports the right PM profile, with no driver update needed.
-hsmp_desc()now resolves the running platform's descriptor once and caches the pointer behind READ_ONCE()/WRITE_ONCE() instead of recomputing it on every call. Concurrent first callers are benign, since every one of them computes and stores that same pointer, so the pair only needs to keep the load/store from being torn or reordered by the compiler, not order it against anything else.
- The client message enum inamd_hsmp.his now documented with kernel-doc, one @member entry per message describing its inputs and outputs, rather than a block comment plus a same-line comment per enumerator. Noted there that not every platform supports every message and that an unsupported one returns-ENOMSG.
- Patch 4: the Telemetry Table RM layout moved out of the .rst and intoamd_hsmp.has real kernel-doc'd struct/enum declarations, giving userspace one authoritative definition of the byte layout. The .rst now just points at structhsmp_telemetry_table_rm. The structs are now also packed to a 4-byte boundary to match firmware's actual layout, and the trailing NPU/PMF counters and spare padding firmware carries after the overclocking fields are no longer missing. Verified field-by-field against AMD's internal metrics table header and end-to-end against a live snapshot off Family 1Ah client hardware.Each patch builds individually and is clean under checkpatch.pl --strict.
Muralidhara M K (4):
platform/x86/amd/hsmp: Recognize Family 1Ah client platforms and hide
server-only paths
platform/x86/amd/hsmp: Add HSMP client support for Family 1Ah platform/x86/amd/hsmp: Route metric table through the client messages platform/x86/amd/hsmp: Document and expose client telemetry table in
UAPIDocumentation/arch/x86/amd_hsmp.rst | 24 +- arch/x86/include/uapi/asm/amd_hsmp.h | 420 +++++++++++++++++++++++++++ drivers/platform/x86/amd/hsmp/acpi.c | 31 +- drivers/platform/x86/amd/hsmp/hsmp.c | 248 +++++++++++----- drivers/platform/x86/amd/hsmp/hsmp.h | 24 ++ 5 files changed, 676 insertions(+), 71 deletions(-)base-commit:
6c377d19d4a5116d9bec5203aa3c6c11523e7898
Signature · 1 line
i.
Quoted 30 lines · Ilpo Järvinen
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 15 lines · Muralidhara M K
This series enables the HSMP driver on the Family 1Ah client platforms, Models 80h-8Fh and E0h-E3h.
The client parts probe through the same ACPI _CRS/_DSD as a server socket, but drive a different mailbox and speak the Ryzen Master SMC message set instead of server message IDs.
Patch 1 adds
is_client_platform()and hides the pre-existing hwmon attributes, ACPI sysfs attributes,metrics_bin, and metric-table DRAM-base lookup on client platforms, and restricts/dev/hsmpto 0600 there. Patch 2 adds the client message set and routes it through the existing MMIO path. Patch 3 wires the client metric-table messages into the metric-table read path. Patch 4 adds the client telemetry table.Quoted 7 lines
Changes in v9:
- Patch 1: fixed a build failure on
CONFIG_ACPI=nconfigs reported by the kernel test robot.is_client_platform()now gates theacpi_gbl_FADTaccess with #ifIS_ENABLED(CONFIG_ACPI)instead of a runtime check, which does not stop the compiler type-checking the dead branch.Hi,
Quoted 8 lines
I've taken this to the review-ilpo-next branch now.
But please do check the args[0] access mention from sashiko. It looks to me it results just incorrect error code at worst if
num_argsis 0 (-EPERMvs-EINVAL). As it also looked to be a pre-existing issue, I didn't want to delay this with yet another round because of it but it seems still worth to address if it turns out to be a valid observation.
Thanks.
I have incorporated the args-validation changes and submitted them as part of the following patch series:
https://lore.kernel.org/platform-driver-x86/[email protected]/T/#m4b63f5c69441f965d780eb9bdd29e05e7bf8f9c1
Quoted 122 lines
--
i.Quoted 113 lines
Changes in v8:
- Reordered the series per review from Ilpo Jarvinen: patch 1 now adds
is_client_platform()and every client-platform exclusion (attribute hiding, DRAM-base lookup,/dev/hsmpmode) before patch 2 adds client message routing.
- Patch 3 upgrades patch 1's defensive DRAM-base guard to the full RYZEN_MASTER_PROTO_VER1/HSMP_PROTO_VER6 check.
- Patch 4 unchanged.
- Tightened commit messages and code comments to an imperative, concise style.Changes in v7:
- The client message set no longer has a per-message descriptor table (
hsmp_client_msg_desc_tableis gone).
Validatenum_argsandresponse_szwithHSMP_CLIENT_MAX_MSG_LEN.
-/dev/hsmpis now registered at 0600 on client platforms instead of 0644, sincehsmp_ioctl_msg()has no per-message GET/SET gate there and any opener could otherwise issue a destructive client SET message; server platforms are unaffected.
- New patch 3: the pre-existing hwmon registration, ACPI sysfs device attributes andmetrics_binvisibility predate the client message set and are wired to hardcoded server message IDs, which mostly collide with unrelated client commands on a client platform. Guard all three withis_client_platform(), keepingsmu_fw_versionandprotocol_versionvisible since they report the same data on both message sets.Changes in v6:
- Patch 1: dropped "inline" from
get_msg_desc()too, for the same reason ashsmp_desc(): it does a range check and a reserved-type check, not a trivial accessor, so let the compiler decide.
- Squashed what was patch 3 ("Add ACPI client support for Family 1Ah") into patch 2. Patches 1+2 alone, without the old patch 3, would have left hsmp_metric_tbl_read_locked()'s new client message routing unreachable:hsmp_get_tbl_dram_base()never runs on a client platform until the ACPI DRAM-base gate lands, so the two belong together as one atomic change.
- Patch 2 (now including the former patch 3): also guard the pre-existing serverproto_verclause with !is_client_platform(), not just the new client clause, per review.hsmp_pdev->proto_veris a small Ryzen Master interface version number today, but nothing stops a future client interface version from reachingHSMP_PROTO_VER6(6) and making that clause spuriously true on a client platform.
- Series is now 3 patches instead of 4, following the squash above and addressed the review comments.Changes in v5:
- Patch 3:
hsmp_pdev->proto_verholds the Ryzen Master SMC interface version on client platforms, a separate numbering space from the server protocol versions in enumhsmp_proto_versions.Changes in v4:
- SMU now answers the interface version query on client platforms, so hsmp_desc_client.proto_ver_msg goes back to
HSMP_CLIENT_GET_INTERFACE_VERinstead ofHSMP_CLIENT_GET_METRICS_TABLE_VER. Patch 3 is back down to just the ACPI metric-table-DRAM-base change, since that was the only other thing it did.Changes in v3:
-
is_client_platform()now tells client and server apart through the ACPI-reported PM profile (FADTpreferred_profile) instead of a hardcoded Family 1Ah model range, the same signal amd-pstate already keys off of. Future client generations are recognised as long as firmware reports the right PM profile, with no driver update needed.
-hsmp_desc()now resolves the running platform's descriptor once and caches the pointer behind READ_ONCE()/WRITE_ONCE() instead of recomputing it on every call. Concurrent first callers are benign, since every one of them computes and stores that same pointer, so the pair only needs to keep the load/store from being torn or reordered by the compiler, not order it against anything else.
- The client message enum inamd_hsmp.his now documented with kernel-doc, one @member entry per message describing its inputs and outputs, rather than a block comment plus a same-line comment per enumerator. Noted there that not every platform supports every message and that an unsupported one returns-ENOMSG.
- Patch 4: the Telemetry Table RM layout moved out of the .rst and intoamd_hsmp.has real kernel-doc'd struct/enum declarations, giving userspace one authoritative definition of the byte layout. The .rst now just points at structhsmp_telemetry_table_rm. The structs are now also packed to a 4-byte boundary to match firmware's actual layout, and the trailing NPU/PMF counters and spare padding firmware carries after the overclocking fields are no longer missing. Verified field-by-field against AMD's internal metrics table header and end-to-end against a live snapshot off Family 1Ah client hardware.Each patch builds individually and is clean under checkpatch.pl --strict.
Muralidhara M K (4):
platform/x86/amd/hsmp: Recognize Family 1Ah client platforms and hide
server-only paths
platform/x86/amd/hsmp: Add HSMP client support for Family 1Ah platform/x86/amd/hsmp: Route metric table through the client messages platform/x86/amd/hsmp: Document and expose client telemetry table in
UAPIDocumentation/arch/x86/amd_hsmp.rst | 24 +- arch/x86/include/uapi/asm/amd_hsmp.h | 420 +++++++++++++++++++++++++++ drivers/platform/x86/amd/hsmp/acpi.c | 31 +- drivers/platform/x86/amd/hsmp/hsmp.c | 248 +++++++++++----- drivers/platform/x86/amd/hsmp/hsmp.h | 24 ++ 5 files changed, 676 insertions(+), 71 deletions(-)Quoted 2 lines
base-commit:
6c377d19d4a5116d9bec5203aa3c6c11523e7898--
i.