Re: [PATCH 2/4] platform/x86/amd/hsmp: Add /sys/devices/amd_hsmp socket devices
From: Ilpo Järvinen
Date: Mon Nov 16 2026 - 09:23:30 EST
On Mon, 16 Nov 2026, Erwan Velu wrote:
> On 11/1/26 18:57, Carlos Bilbao wrote:
> > Is this over-engineering it? The platform driver already creates
> > /sys/devices/platform/amd_hsmp/socket0/, socket1/, etc. they're just dumb
> > dirs with only metrics_bin inside. This patch series ignores those and
> > builds a whole new /sys/devices/amd_hsmp/socket0/ tree from scratch with
> > root_device_register(), manual refcounting, etc. instead of building a
> > parallel tree, upgrade what's already there. Turn those existing socketN
> > directories from bare sysfs dirs into proper struct device objects?
>
> Hi Carlos,
>
> Thanks for the review and the acks on 1/4 and 4/4.
>
> I think the commit message did not explain the goal well enough, so let
> me clarify it first. The goal is not only to get more attributes on the
> platform driver. It is to give userspace a single path to the per-socket
> metrics, whichever driver probed.
>
> Today the same metrics are found in different places depending on the
> platform:
>
> - Zen5 (ACPI probe):
> /sys/devices/platform/AMDI0097:00/
> /sys/devices/platform/AMDI0097:01/
> - Zen3/4 (legacy platform probe):
> /sys/devices/platform/amd_hsmp/socket0/
> /sys/devices/platform/amd_hsmp/socket1/
>
> "modprobe amd_hsmp" does the right thing and probes the platform or the
> ACPI driver depending on the system, which is good. But as a
> consequence, userspace cannot know in advance which of the two trees it
> has to read, unless it walks sysfs to find out.
>
> On a Zen5 system there is no amd_hsmp platform device at all, so
> upgrading the existing amd_hsmp/socketN directories only covers one of
> the two cases. A monitoring agent running on a mixed fleet (our case)
> still has to find out which driver probed and use a different layout
> for each.
>
> That said, I agree with your point on the implementation. The separate
> root device and the hand-rolled refcount were the wrong tool. Ilpo also
> pointed out that kref.h was the right helper there. For v2 I would like
> to propose the following:
>
> - Add a device class (e.g. "amd_hsmp") and create one socketN device
> per socket in it, with hsmp_sock_groups.
> - Platform driver: the socketN device is parented to the amd_hsmp
> platform device and replaces the current named attribute group, as
> you suggested. /sys/devices/platform/amd_hsmp/socketN/metrics_bin
> keeps the same path, so nothing changes for existing users.
> - ACPI driver: the socketN device is parented to AMDI0097:0X, and the
> attributes already on AMDI0097:0X are left in place.
> - Userspace gets /sys/class/amd_hsmp/socketN/ on both drivers.
>
> This removes root_device_register() and the manual refcounting, and it
> lets us use device_create_with_groups() instead of building the device
> by hand.
>
> Before working on it, I have a question about the AMDI0097:0X path,
> which I think needs a maintainer decision:
>
> The telemetry files on /sys/devices/platform/AMDI0097:0X/ are
> documented in Documentation/arch/x86/amd_hsmp.rst (since 511a4a5ea2b6),
> but there is no entry in Documentation/ABI/. They are tied to the ACPI
> device name, not to the socket. As far as I understand, the :0X suffix
> is the ACPI instance number, while the socket index comes from _UID, so
> nothing guarantees that the two match.
>
> What is your view for this path?
>
> a) It is stable ABI and stays as is forever. The class path is only
> added next to it.
> b) It stays, but the class path becomes the documented interface,
> with a Documentation/ABI/testing entry. The AMDI0097:0X files are
> documented as kept for compatibility only, and we would propose a
> progressive deprecation of them (e.g. a Documentation/ABI/obsolete
> entry first), so they can eventually be removed once userspace has
> moved to the class path.
> c) Something else you have in mind.
>
> My preference would be b), as it doesn't break anyone today, gives new
> users one documented place to look at, and leaves a clean path to a
> single interface in the long run. But I would rather align with you and
> Naveen on this before sending v2.
The lack of Documentation/ABI entry should not be taken as an indication
for something not being ABI. We generally don't take away ABI without
doing proper deprecation and waiting first.
Sometimes, the old place can be covered with a symlink to the new place.
--
i.