[PATCH v3 0/7] platform/x86/amd/hsmp: Add support for Family 1Ah, Model 50h-5Fh

Muralidhara M K posted 7 patches 1 week ago
arch/x86/include/uapi/asm/amd_hsmp.h | 278 +++++++++++++++++++++++++--
drivers/platform/x86/amd/hsmp/acpi.c |  34 +---
drivers/platform/x86/amd/hsmp/hsmp.c | 125 ++++++++++--
drivers/platform/x86/amd/hsmp/hsmp.h |   6 +-
4 files changed, 373 insertions(+), 70 deletions(-)
[PATCH v3 0/7] platform/x86/amd/hsmp: Add support for Family 1Ah, Model 50h-5Fh
Posted by Muralidhara M K 1 week ago
Hi,

This series adds AMD HSMP (Host System Management Port) support for
Family 1Ah, Model 50h-5Fh processors (HSMP protocol version 7) on top
of the existing platform/x86/amd/hsmp driver.

Highlights:

 - New HSMP messages for Family 1Ah Model 50h-5Fh: PC6/CC6 control,
   CCD power, Tdelta, SVI3 VR temperature, DIMM sideband, Floor/SDPS
   limit control and an "enabled HSMP commands" capability query.
 - UAPI structures (hsmp_metric_table_zen6 and friends) describing
   the per-IOD/per-CCD metric table layout for protocol version 7.
 - response_sz validation is unified to a single upper-bound check
   so older userspace built against an earlier descriptor table
   keeps working as new response words are added on newer platforms.
 - Metric-table region size is sourced from firmware (args[2] of
   HSMP_GET_METRIC_TABLE_DRAM_ADDR) rather than hard-coded to
   sizeof(struct hsmp_metric_table), so the driver can map and
   validate the larger ~13 KB protocol-version-7 layout (and any
   future growth) without further code changes.
 - Concurrent metric-table reads on the same socket are serialized
   with a per-socket mutex managed via scoped guard(mutex), so two
   simultaneous readers can no longer interleave the SMU refresh
   command and the memcpy_fromio() and produce a torn snapshot.

Changes in v3:

 - Switched the method of reading the metric table from the binary
   sysfs attribute (metrics_bin) to a character-device IOCTL
   (HSMP_IOCTL_GET_TELEMETRY_DATA on /dev/hsmp), as suggested during
   the v2 review. The sysfs binary attribute is capped at PAGE_SIZE
   (4 KB) on the standard read path, which cannot accommodate the
   ~13 KB hsmp_metric_table_zen6 layout used on Family 1Ah Model
   50h-5Fh; the IOCTL has no such cap and works for both the
   existing protocol-version-6 table and the new protocol-version-7
   table. Userspace sizes its buffer using the matching UAPI struct
   (hsmp_metric_table or hsmp_metric_table_zen6) and the kernel
   rejects any size that disagrees with the firmware-reported table
   size with -EINVAL, so a short copy can never silently truncate
   the snapshot.
 - The metrics_bin sysfs attribute is dropped from the ACPI driver
   path (AMDI0097) in favour of the new IOCTL. This is an ABI change
   for ACPI-driver users: userspace must now read telemetry via
   HSMP_IOCTL_GET_TELEMETRY_DATA on /dev/hsmp. The non-ACPI plat.c
   path (Family 1Ah Model 0h-Fh, fixed at protocol version 6) is
   intentionally left untouched and its per-socket metrics_bin
   remains available for existing tooling on those systems.
 - The proto_ver gate that enables metric-table discovery in
   init_acpi() is widened from "== HSMP_PROTO_VER6" to
   ">= HSMP_PROTO_VER6" so hsmp_get_tbl_dram_base() runs on
   protocol version 7 (and any future compatible version).
 - Per-socket metric_tbl_lock is now initialised with
   devm_mutex_init() and taken via scoped guard(mutex) in
   hsmp_metric_tbl_read(), instead of an open-coded
   mutex_init()/mutex_destroy() pair.

Link to v2:
https://lore.kernel.org/platform-driver-x86/20260427155129.545327-1-muralidhara.mk@amd.com/T/#m9f1a19ba6e037e5a7f30441620f2fe4b2c3cf0fa

Thanks,
Murali

Muralidhara M K (6):
  platform/x86/amd/hsmp: Add UAPI structures for Family 1Ah Model
    50h-5Fh metrics table
  platform/x86/amd/hsmp: Unify response_sz validation to an upper-bound
    check
  platform/x86/amd/hsmp: Source metric-table size from firmware
  platform/x86/amd/hsmp: Add IOCTL_GET_TELEMETRY_DATA for metric table
    reads
  platform/x86/amd/hsmp: Drop ACPI sysfs metrics_bin in favour of the
    IOCTL
  platform/x86/amd/hsmp: Make metric table read locking use guard(mutex)

Suma Hegde (1):
  platform/x86/amd/hsmp: Add new HSMP messages for Family 1Ah, Model
    50h-5Fh

 arch/x86/include/uapi/asm/amd_hsmp.h | 278 +++++++++++++++++++++++++--
 drivers/platform/x86/amd/hsmp/acpi.c |  34 +---
 drivers/platform/x86/amd/hsmp/hsmp.c | 125 ++++++++++--
 drivers/platform/x86/amd/hsmp/hsmp.h |   6 +-
 4 files changed, 373 insertions(+), 70 deletions(-)

-- 
2.34.1