public inbox for driver-core@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH v2 0/7] AMD HSMP: metrics table improvements and Family 1Ah Model 50h-5Fh support
@ 2026-04-27 15:51 Muralidhara M K
  2026-04-27 15:51 ` [PATCH v2 1/7] platform/x86/amd/hsmp: Add new HSMP messages for Family 1Ah, Model 50h-5Fh Muralidhara M K
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Muralidhara M K @ 2026-04-27 15:51 UTC (permalink / raw)
  To: ilpo.jarvinen, gregkh, rafael
  Cc: platform-driver-x86, linux-kernel, driver-core, Muralidhara M K

This series adds HSMP protocol version 7 support for AMD Family 1Ah
Model 50h-5Fh processors and replaces offset-based chunked reading
with a single read method for variable-sized metrics data larger than
4 KB, and addresses locking to allow concurrent reads safely.

The zen6 metric table (~13 KB) exceeds the PAGE_SIZE (4096 bytes) read
cap imposed by kernfs_file_read_iter().  Commit 3124eb1679b2 ("sysfs:
remove bin_attribute.size") cleared i_size for sysfs binary files,
which made kernfs_file_read_iter() fall back to PAGE_SIZE as the
maximum single-read length.  This means userspace gets a silently
truncated snapshot when reading the metric table via sysfs.

To solve this, the series introduces SYSFS_HUGE_BIN_FILE, a new sysfs
mode flag that routes binary attribute reads through the seq_file path
(seq_read_iter) instead of kernfs_file_read_iter().  The seq_file
buffer grows dynamically (doubling from PAGE_SIZE) and has no built-in
size cap, so it can serve arbitrarily large binary attributes in a
single read.

Additionally, the series retrieves the actual metric table size from
the SMU at init time (via args[2] of HSMP_GET_METRIC_TABLE_DRAM_ADDR)
rather than relying on a compiled-in sizeof(), and adds per-socket
mutex serialization for metric table reads using the scoped guard(mutex)
API.

Link: https://lore.kernel.org/platform-driver-x86/81915669-87e0-f06d-7a91-eaec41ecc0e1@linux.intel.com/T/#m28341c51bcf27862ef6615414b1970d3db279fd7

Patch breakdown:

  1/7  HSMP messages    - Define HSMP protocol v7 message IDs and
                          response sizes in the UAPI header.
  2/7  UAPI structs     - Add hsmp_metric_table_zen6 UAPI structures
                          and widen acpi.c proto_ver checks to >= VER6.
  3/7  response_sz      - Unify response_sz validation to an upper-bound
                          check, allowing HSMP_GET_METRIC_TABLE_DRAM_ADDR
                          to return 3 dwords (including table size).
  4/7  SYSFS_HUGE_BIN_FILE - Add the sysfs infrastructure: new flag,
                          seq_show callback, and kernfs_ops for binary
                          files larger than PAGE_SIZE.
  5/7  Dynamic size     - Read actual table size from SMU args[2] at
                          init time; use bin_size callback to report it
                          to sysfs.
  6/7  Read locking     - Add per-socket guard(mutex) serialization for
                          metric table reads to prevent torn snapshots.
  7/7  Wire it up       - Set SYSFS_HUGE_BIN_FILE mode on metric table
                          bin_attributes in both acpi.c and plat.c.

Build-tested each patch individually with W=1, zero warnings.
Tested on AMD Family 1Ah Model 50h platform with HSMP protocol v7.

Muralidhara M K (6):
  platform/x86/amd/hsmp: Add metrics table support for Family 1Ah Model
    50h-5Fh
  platform/x86/amd/hsmp: Unify response_sz validation to an upper-bound
    check
  sysfs: Add SYSFS_HUGE_BIN_FILE flag for binary attributes larger than
    PAGE_SIZE
  platform/x86/amd/hsmp: Add dynamic table size for metric table
  platform/x86/amd/hsmp: Make metric table read locking use guard(mutex)
  platform/x86/amd/hsmp: Support SYSFS_HUGE_BIN_FILE for metric table
    reads

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 | 235 ++++++++++++++++++++++++---
 drivers/platform/x86/amd/hsmp/acpi.c |  14 +-
 drivers/platform/x86/amd/hsmp/hsmp.c |  36 ++--
 drivers/platform/x86/amd/hsmp/hsmp.h |   6 +-
 drivers/platform/x86/amd/hsmp/plat.c |  13 +-
 fs/sysfs/file.c                      |  45 +++++
 fs/sysfs/group.c                     |   8 +-
 include/linux/sysfs.h                |   1 +
 8 files changed, 312 insertions(+), 46 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-04-28  7:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-27 15:51 [PATCH v2 0/7] AMD HSMP: metrics table improvements and Family 1Ah Model 50h-5Fh support Muralidhara M K
2026-04-27 15:51 ` [PATCH v2 1/7] platform/x86/amd/hsmp: Add new HSMP messages for Family 1Ah, Model 50h-5Fh Muralidhara M K
2026-04-27 15:51 ` [PATCH v2 2/7] platform/x86/amd/hsmp: Add metrics table support for Family 1Ah " Muralidhara M K
2026-04-27 15:51 ` [PATCH v2 3/7] platform/x86/amd/hsmp: Unify response_sz validation to an upper-bound check Muralidhara M K
2026-04-27 15:51 ` [PATCH v2 4/7] sysfs: Add SYSFS_HUGE_BIN_FILE flag for binary attributes larger than PAGE_SIZE Muralidhara M K
2026-04-28  7:20   ` K Prateek Nayak
2026-04-27 15:51 ` [PATCH v2 5/7] platform/x86/amd/hsmp: Add dynamic table size for metric table Muralidhara M K
2026-04-27 15:51 ` [PATCH v2 6/7] platform/x86/amd/hsmp: Make metric table read locking use guard(mutex) Muralidhara M K
2026-04-27 15:51 ` [PATCH v2 7/7] platform/x86/amd/hsmp: Support SYSFS_HUGE_BIN_FILE for metric table reads Muralidhara M K

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox