[PATCH v2 7/7] platform/x86/amd/hsmp: Support SYSFS_HUGE_BIN_FILE for metric table reads

From: Muralidhara M K

Date: Mon Apr 27 2026 - 12:13:20 EST


The metric table for Family 1Ah Model 50h-5Fh (hsmp_metric_table_zen6)
is approximately 13KB, exceeding the PAGE_SIZE (4KB) cap imposed by the
standard sysfs binary attribute read path.

Set the SYSFS_HUGE_BIN_FILE flag in the bin_attribute mode for the
metric table in both acpi.c and plat.c so that reads are routed through
seq_file, which dynamically grows its buffer to accommodate the full
table. This lets userspace read the entire table in a single read()
call.

Drop the static .size initializer from the bin_attribute since the
bin_size callback (added in the previous patch) already provides the
runtime table size at sysfs group registration time.

Co-developed-by: Muthusamy Ramalingam <muthusamy.ramalingam@xxxxxxx>
Signed-off-by: Muthusamy Ramalingam <muthusamy.ramalingam@xxxxxxx>
Signed-off-by: Muralidhara M K <muralidhara.mk@xxxxxxx>
---
Changes v1->v2: New patch

drivers/platform/x86/amd/hsmp/acpi.c | 3 +--
drivers/platform/x86/amd/hsmp/plat.c | 6 ++++--
2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c
index f3cfc99ef73d..ea99625d0f36 100644
--- a/drivers/platform/x86/amd/hsmp/acpi.c
+++ b/drivers/platform/x86/amd/hsmp/acpi.c
@@ -513,9 +513,8 @@ static int init_acpi(struct device *dev)
}

static const struct bin_attribute hsmp_metric_tbl_attr = {
- .attr = { .name = HSMP_METRICS_TABLE_NAME, .mode = 0444},
+ .attr = { .name = HSMP_METRICS_TABLE_NAME, .mode = SYSFS_HUGE_BIN_FILE | 0444},
.read = hsmp_metric_tbl_acpi_read,
- .size = sizeof(struct hsmp_metric_table),
};

static const struct bin_attribute *hsmp_attr_list[] = {
diff --git a/drivers/platform/x86/amd/hsmp/plat.c b/drivers/platform/x86/amd/hsmp/plat.c
index d8dd90dfeb4e..625602a0d44c 100644
--- a/drivers/platform/x86/amd/hsmp/plat.c
+++ b/drivers/platform/x86/amd/hsmp/plat.c
@@ -97,10 +97,12 @@ static_assert(MAX_AMD_NUM_NODES == 8);

#define HSMP_BIN_ATTR(index, _list) \
static const struct bin_attribute attr##index = { \
- .attr = { .name = HSMP_METRICS_TABLE_NAME, .mode = 0444}, \
+ .attr = { \
+ .name = HSMP_METRICS_TABLE_NAME, \
+ .mode = SYSFS_HUGE_BIN_FILE | 0444, \
+ }, \
.private = (void *)index, \
.read = hsmp_metric_tbl_plat_read, \
- .size = sizeof(struct hsmp_metric_table), \
}; \
static const struct bin_attribute _list[] = { \
&attr##index, \
--
2.34.1