Skip to contentSkip to conversation

platform/x86/amd/hsmp: Make amd_hsmp and hsmp_acpi as mutually exclusive drivers

PATCH In review Suma Hegde 4 participants 6 messages Apr 25, 2025 – Apr 30, 2025

Subsystems (2)
lore
Share & tools
lore

Suma Hegde

author
#0 lore raw

PATCH v2 1/1 platform/x86/amd/hsmp: Make amd_hsmp and hsmp_acpi as mutually exclusive drivers

amd_hsmp and hsmp_acpi are intended to be mutually exclusive drivers and amd_hsmp is for legacy platforms. To achieve this, it is essential to check for the presence of the ACPI device in plat.c. If the hsmp ACPI device entry is found, allow the hsmp_acpi driver to manage the hsmp and return an error from plat.c.

Additionally, rename the driver from amd_hsmp to hsmp_acpi to prevent "Driver 'amd_hsmp' is already registered, aborting..." error in case both drivers are loaded simultaneously.

Also, support both platform device based and ACPI based probing for family 0x1A models 0x00 to 0x0F, implement only ACPI based probing for family 0x1A, models 0x10 to 0x1F. Return false from legacy_hsmp_support() for this platform.
This aligns with the condition check in is_f1a_m0h().

---
Changes since v1:
1. Change commit message and commit description
2. Merge below patch by Gregory Price into this
https://lore.kernel.org/platform-driver-x86/aALZxvHWmphNL1wa@gourry-fedora-PF4VCD3F/

 drivers/platform/x86/amd/hsmp/acpi.c | 3 +--
 drivers/platform/x86/amd/hsmp/hsmp.h | 1 +
 drivers/platform/x86/amd/hsmp/plat.c | 6 +++++-
 3 files changed, 7 insertions(+), 3 deletions(-)
drivers/platform/x86/amd/hsmp/acpi.c +1 -2
index c1eccb3c80c5..eaae044e4f82 100644
@@ -27,9 +27,8 @@
 
 #include "hsmp.h"
 
-#define DRIVER_NAME		"amd_hsmp"
+#define DRIVER_NAME		"hsmp_acpi"
 #define DRIVER_VERSION		"2.3"
-#define ACPI_HSMP_DEVICE_HID	"AMDI0097"
 
 /* These are the strings specified in ACPI table */
 #define MSG_IDOFF_STR		"MsgIdOffset"
drivers/platform/x86/amd/hsmp/hsmp.h +1 -0
index af8b21f821d6..d58d4f0c20d5 100644
@@ -23,6 +23,7 @@
 
 #define HSMP_CDEV_NAME		"hsmp_cdev"
 #define HSMP_DEVNODE_NAME	"hsmp"
+#define ACPI_HSMP_DEVICE_HID    "AMDI0097"
 
 struct hsmp_mbaddr_info {
 	u32 base_addr;
drivers/platform/x86/amd/hsmp/plat.c +5 -1
index b9782a078dbd..81931e808bbc 100644
@@ -11,6 +11,7 @@
 
 #include <asm/amd_hsmp.h>
 
+#include <linux/acpi.h>
 #include <linux/build_bug.h>
 #include <linux/device.h>
 #include <linux/module.h>
@@ -266,7 +267,7 @@ static bool legacy_hsmp_support(void)
 		}
 	case 0x1A:
 		switch (boot_cpu_data.x86_model) {
-		case 0x00 ... 0x1F:
+		case 0x00 ... 0x0F:
 			return true;
 		default:
 			return false;
@@ -288,6 +289,9 @@ static int __init hsmp_plt_init(void)
 		return ret;
 	}
 
+	if (acpi_dev_present(ACPI_HSMP_DEVICE_HID, NULL, -1))
+		return -ENODEV;
+
 	hsmp_pdev = get_hsmp_pdev();
 	if (!hsmp_pdev)
 		return -ENOMEM;
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 9 lines · Suma Hegde

amd_hsmp and hsmp_acpi are intended to be mutually exclusive drivers and amd_hsmp is for legacy platforms. To achieve this, it is essential to check for the presence of the ACPI device in plat.c. If the hsmp ACPI device entry is found, allow the hsmp_acpi driver to manage the hsmp and return an error from plat.c.

Additionally, rename the driver from amd_hsmp to hsmp_acpi to prevent "Driver 'amd_hsmp' is already registered, aborting..." error in case both drivers are loaded simultaneously.

This rename has userspace visible impact through sysfs, no? I'm just wondering what's the expected fallout once this patch goes to stable kernels?

Signature · 1 line
 i.
Quoted 82 lines

Also, support both platform device based and ACPI based probing for family 0x1A models 0x00 to 0x0F, implement only ACPI based probing for family 0x1A, models 0x10 to 0x1F. Return false from legacy_hsmp_support() for this platform.
This aligns with the condition check in is_f1a_m0h().

---
Changes since v1:
1. Change commit message and commit description
2. Merge below patch by Gregory Price into this
https://lore.kernel.org/platform-driver-x86/aALZxvHWmphNL1wa@gourry-fedora-PF4VCD3F/

 drivers/platform/x86/amd/hsmp/acpi.c | 3 +--
 drivers/platform/x86/amd/hsmp/hsmp.h | 1 +
 drivers/platform/x86/amd/hsmp/plat.c | 6 +++++-
 3 files changed, 7 insertions(+), 3 deletions(-)
drivers/platform/x86/amd/hsmp/acpi.c +1 -2
index c1eccb3c80c5..eaae044e4f82 100644
@@ -27,9 +27,8 @@
 
 #include "hsmp.h"
 
-#define DRIVER_NAME		"amd_hsmp"
+#define DRIVER_NAME		"hsmp_acpi"
 #define DRIVER_VERSION		"2.3"
-#define ACPI_HSMP_DEVICE_HID	"AMDI0097"
 
 /* These are the strings specified in ACPI table */
 #define MSG_IDOFF_STR		"MsgIdOffset"
drivers/platform/x86/amd/hsmp/hsmp.h +1 -0
index af8b21f821d6..d58d4f0c20d5 100644
@@ -23,6 +23,7 @@
 
 #define HSMP_CDEV_NAME		"hsmp_cdev"
 #define HSMP_DEVNODE_NAME	"hsmp"
+#define ACPI_HSMP_DEVICE_HID    "AMDI0097"
 
 struct hsmp_mbaddr_info {
 	u32 base_addr;
drivers/platform/x86/amd/hsmp/plat.c +5 -1
index b9782a078dbd..81931e808bbc 100644
@@ -11,6 +11,7 @@
 
 #include <asm/amd_hsmp.h>
 
+#include <linux/acpi.h>
 #include <linux/build_bug.h>
 #include <linux/device.h>
 #include <linux/module.h>
@@ -266,7 +267,7 @@ static bool legacy_hsmp_support(void)
 		}
 	case 0x1A:
 		switch (boot_cpu_data.x86_model) {
-		case 0x00 ... 0x1F:
+		case 0x00 ... 0x0F:
 			return true;
 		default:
 			return false;
@@ -288,6 +289,9 @@ static int __init hsmp_plt_init(void)
 		return ret;
 	}
 
+	if (acpi_dev_present(ACPI_HSMP_DEVICE_HID, NULL, -1))
+		return -ENODEV;
+
 	hsmp_pdev = get_hsmp_pdev();
 	if (!hsmp_pdev)
 		return -ENOMEM;
#2 lore raw

Hi,

Quoted 8 lines · Ilpo Järvinen
Quoted 6 lines · Suma Hegde

amd_hsmp and hsmp_acpi are intended to be mutually exclusive drivers and amd_hsmp is for legacy platforms. To achieve this, it is essential to check for the presence of the ACPI device in plat.c. If the hsmp ACPI device entry is found, allow the hsmp_acpi driver to manage the hsmp and return an error from plat.c.

Quoted 5 lines
Quoted 3 lines

Additionally, rename the driver from amd_hsmp to hsmp_acpi to prevent "Driver 'amd_hsmp' is already registered, aborting..." error in case both drivers are loaded simultaneously.

This rename has userspace visible impact through sysfs, no?

Not really it will only change the name under /sys/bus/platform/drivers and the name one needs to echo to bind / unbind when doing manual binding I don't expect anyone to be doing manual binding / unbinding especially not in a scripted manner where this would really manner.

Quoted 3 lines

I'm just
wondering what's the expected fallout once this patch goes to stable kernels?

I would not expect there to be any fallout from this rename going to stable series.

Regards,

Hans

#3 lore raw
In reply to Ilpo Järvinen
Quoted 8 lines · Ilpo Järvinen
Quoted 6 lines · Suma Hegde

amd_hsmp and hsmp_acpi are intended to be mutually exclusive drivers and amd_hsmp is for legacy platforms. To achieve this, it is essential to check for the presence of the ACPI device in plat.c. If the hsmp ACPI device entry is found, allow the hsmp_acpi driver to manage the hsmp and return an error from plat.c.

Quoted 8 lines
Quoted 3 lines

Additionally, rename the driver from amd_hsmp to hsmp_acpi to prevent "Driver 'amd_hsmp' is already registered, aborting..." error in case both drivers are loaded simultaneously.

This rename has userspace visible impact through sysfs, no? I'm just wondering what's the expected fallout once this patch goes to stable kernels?

I suppose the real question there is whether these should actually be different drivers, as opposed to backends for a single front-end. In which case, some of the split work previously would need to be reworked.

~Gregory

author
#4 lore raw

Hi Gregory,

Quoted 15 lines · Gregory Price

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 11 lines · Ilpo Järvinen
Quoted 9 lines · Suma Hegde

amd_hsmp and hsmp_acpi are intended to be mutually exclusive drivers and amd_hsmp is for legacy platforms. To achieve this, it is essential to check for the presence of the ACPI device in plat.c. If the hsmp ACPI device entry is found, allow the hsmp_acpi driver to manage the hsmp and return an error from plat.c.

Additionally, rename the driver from amd_hsmp to hsmp_acpi to prevent "Driver 'amd_hsmp' is already registered, aborting..." error in case both drivers are loaded simultaneously.

Quoted 7 lines
Quoted 4 lines

This rename has userspace visible impact through sysfs, no? I'm just wondering what's the expected fallout once this patch goes to stable kernels?

I suppose the real question there is whether these should actually be different drivers, as opposed to backends for a single front-end. In which case, some of the split work previously would need to be reworked.

No, these are not 2 different drivers, both can not co-exist. Its necessary to make them mutually exclusive

and amd_hsmp is only for legacy platforms.

Quoted 2 lines

~Gregory

Thanks and Regards,

Suma

maintainer
#5 lore raw
In reply to Suma Hegde
Quoted 11 lines · Suma Hegde

amd_hsmp and hsmp_acpi are intended to be mutually exclusive drivers and amd_hsmp is for legacy platforms. To achieve this, it is essential to check for the presence of the ACPI device in plat.c. If the hsmp ACPI device entry is found, allow the hsmp_acpi driver to manage the hsmp and return an error from plat.c.

Additionally, rename the driver from amd_hsmp to hsmp_acpi to prevent "Driver 'amd_hsmp' is already registered, aborting..." error in case both drivers are loaded simultaneously.

[...]

Thank you for your contribution, it has been applied to my local review-ilpo-fixes branch. Note it will show up in the public platform-drivers-x86/review-ilpo-fixes branch only once I've pushed my local branch there, which might take a while.

The list of commits applied:
[1/1] platform/x86/amd/hsmp: Make amd_hsmp and hsmp_acpi as mutually exclusive drivers

      commit: 0581d384f344ed0a963dd27cbff3c7af80c189e7

--
i.