Skip to contentSkip to conversation

platform/x86/amd/hsmp: Check for hsmp ACPI device

PATCH In review Suma Hegde 2 participants 3 messages Apr 24, 2025 – Apr 25, 2025

Subsystems (2)
lore
Share & tools
lore

Suma Hegde

author
#0 lore raw

PATCH 1/1 platform/x86/amd/hsmp: Check for hsmp ACPI device

If the hsmp ACPI device entry exists, allow the hsmp_acpi driver to manage the hsmp and return error from plat.c.

amd_hsmp and hsmp_acpi are intended to be mutually exclusive drivers and this check for availability of hsmp ACPI device is necessary to ensure this.

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().

---
This patch should be rebased on below patch by Gregory Price.
https://lore.kernel.org/platform-driver-x86/[email protected]/T/#t

 drivers/platform/x86/amd/hsmp/acpi.c | 1 -
 drivers/platform/x86/amd/hsmp/hsmp.h | 1 +
 drivers/platform/x86/amd/hsmp/plat.c | 6 +++++-
 3 files changed, 6 insertions(+), 2 deletions(-)
drivers/platform/x86/amd/hsmp/acpi.c +0 -1
index 088cb2416d7e..eaae044e4f82 100644
@@ -29,7 +29,6 @@
 
 #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
#1 lore raw
Quoted 13 lines · Suma Hegde

If the hsmp ACPI device entry exists, allow the hsmp_acpi driver to manage the hsmp and return error from plat.c.

amd_hsmp and hsmp_acpi are intended to be mutually exclusive drivers and this check for availability of hsmp ACPI device is necessary to ensure this.

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().

Quoted 5 lines

---
This patch should be rebased on below patch by Gregory Price.
https://lore.kernel.org/platform-driver-x86/[email protected]/T/#t

Just roll my patch into this and add

Fixes 7d3135d163 ("platform/x86/amd/hsmp: Create separate ACPI, plat and common drivers")

should make the pick up easier, and they both deal with the same patch.

Quoted 64 lines
 drivers/platform/x86/amd/hsmp/acpi.c | 1 -
 drivers/platform/x86/amd/hsmp/hsmp.h | 1 +
 drivers/platform/x86/amd/hsmp/plat.c | 6 +++++-
 3 files changed, 6 insertions(+), 2 deletions(-)
drivers/platform/x86/amd/hsmp/acpi.c +0 -1
index 088cb2416d7e..eaae044e4f82 100644
@@ -29,7 +29,6 @@
 
 #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
author
#2 lore raw

Hi Gregory,

Quoted 17 lines · Gregory Price

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

Quoted 13 lines · Suma Hegde

If the hsmp ACPI device entry exists, allow the hsmp_acpi driver to manage the hsmp and return error from plat.c.

amd_hsmp and hsmp_acpi are intended to be mutually exclusive drivers and this check for availability of hsmp ACPI device is necessary to ensure this.

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().

Quoted 6 lines
Quoted 5 lines

---
This patch should be rebased on below patch by Gregory Price.
https://lore.kernel.org/platform-driver-x86/[email protected]/T/#t

Just roll my patch into this and add

Ok, I will merge your changes into this,  add below lines and send v2.

Quoted 64 lines
Fixes 7d3135d163 ("platform/x86/amd/hsmp: Create separate ACPI, plat and common drivers")

should make the pick up easier, and they both deal with the same patch.

Quoted 54 lines
  drivers/platform/x86/amd/hsmp/acpi.c | 1 -
  drivers/platform/x86/amd/hsmp/hsmp.h | 1 +
  drivers/platform/x86/amd/hsmp/plat.c | 6 +++++-
  3 files changed, 6 insertions(+), 2 deletions(-)
drivers/platform/x86/amd/hsmp/acpi.c +0 -1
index 088cb2416d7e..eaae044e4f82 100644
@@ -29,7 +29,6 @@
 
  #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 +2 -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;
       }
 
Quoted 8 lines
Quoted 8 lines
drivers/platform/x86/amd/hsmp/plat.c +3 -1
+     if (acpi_dev_present(ACPI_HSMP_DEVICE_HID, NULL, -1))
+             return -ENODEV;
+
       hsmp_pdev = get_hsmp_pdev();
       if (!hsmp_pdev)
               return -ENOMEM;
--

2.25.1

Thanks and Regards,

Suma