mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Muralidhara M K <muralidhara.mk@amd.com>
To: <ilpo.jarvinen@linux.intel.com>
Cc: <platform-driver-x86@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Muralidhara M K <muralidhara.mk@amd.com>
Subject: [PATCH v7 3/4] platform/x86/amd/hsmp: Hide server-only attributes on client platforms
Date: Thu, 24 Sep 2026 21:19:46 +0530	[thread overview]
Message-ID: <20260924154947.1706669-4-muralidhara.mk@amd.com> (raw)
In-Reply-To: <20260924154947.1706669-1-muralidhara.mk@amd.com>

Most ACPI sysfs device attributes are wired to hardcoded server
message IDs (HSMP_GET_SOCKET_POWER and friends); hwmon power
attributes registered from init_acpi() have the same problem. On a
Family 1Ah client platform these numeric IDs resolve against enum
hsmp_client_message_ids instead, and mostly collide with unrelated
client commands, e.g. HSMP_GET_SOCKET_POWER (4) is
HSMP_CLIENT_GET_METRICS_TABLE_VER on the client side.

Hide the affected ACPI sysfs attributes on client platforms except
smu_fw_version and protocol_version, which report the same data in
both tables. Forward-declare hattr_smu_fw_version and
hattr_protocol_version ahead of their HSMP_DEV_ATTR() definitions.
Skip hsmp_create_sensor() in init_acpi() on client platforms for the
same reason.

The metrics_bin sysfs binary attribute has the same visibility problem:
hsmp_is_sock_attr_visible() gates it on hsmp_pdev->proto_ver against
HSMP_PROTO_VER6 with no is_client_platform() check. Exclude client
platforms outright there too, matching the ACPI sysfs attributes
above: the client set has its own telemetry table, read only through
HSMP_IOCTL_GET_TELEMETRY_DATA.

Signed-off-by: Muralidhara M K <muralidhara.mk@amd.com>
---
 drivers/platform/x86/amd/hsmp/acpi.c | 29 ++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c
index 8b4bf57c3485..d775ea8ba603 100644
--- a/drivers/platform/x86/amd/hsmp/acpi.c
+++ b/drivers/platform/x86/amd/hsmp/acpi.c
@@ -300,16 +300,31 @@ 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.
+	 * The client set has its own telemetry table, read only through
+	 * HSMP_IOCTL_GET_TELEMETRY_DATA; never show this file there.
 	 */
-	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(); same message ID in both message tables */
+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)
 {
+	/*
+	 * smu_fw_version and protocol_version map to the same data in both
+	 * message tables. Every other attribute here uses server-only
+	 * message IDs that resolve to unrelated client commands.
+	 */
+	if (is_client_platform() && attr != &hattr_smu_fw_version.dattr.attr &&
+	    attr != &hattr_protocol_version.dattr.attr)
+		return 0;
+
 	return attr->mode;
 }
 
@@ -564,9 +579,15 @@ static int init_acpi(struct device *dev)
 			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");
+	/*
+	 * hwmon attributes use server-only message IDs, which resolve to
+	 * unrelated client commands 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]);
 
-- 
2.34.1


  parent reply	other threads:[~2026-09-24 15:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24 15:49 [PATCH v7 0/4] platform/x86/amd/hsmp: Family 1Ah client support Muralidhara M K
2026-09-24 15:49 ` [PATCH v7 1/4] platform/x86/amd/hsmp: Add HSMP client support for Family 1Ah Muralidhara M K
2026-09-24 15:49 ` [PATCH v7 2/4] platform/x86/amd/hsmp: Route metric table through the client messages Muralidhara M K
2026-09-24 15:49 ` Muralidhara M K [this message]
2026-10-08 11:58   ` [PATCH v7 3/4] platform/x86/amd/hsmp: Hide server-only attributes on client platforms Ilpo Järvinen
2026-10-09  5:08     ` M K, Muralidhara
2026-09-24 15:49 ` [PATCH v7 4/4] platform/x86/amd/hsmp: Document and expose client telemetry table in UAPI Muralidhara M K

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260924154947.1706669-4-muralidhara.mk@amd.com \
    --to=muralidhara.mk@amd.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®