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 1/3] platform/x86/amd/hsmp: Serialize ACPI HSMP is_probed with a probe mutex
Date: Sun, 14 Jun 2026 00:47:53 +0530 [thread overview]
Message-ID: <20260613191755.2358969-2-muralidhara.mk@amd.com> (raw)
In-Reply-To: <20260613191755.2358969-1-muralidhara.mk@amd.com>
Add hsmp_acpi_probe_mutex and hold it across ACPI probe, remove, and
init_acpi() so concurrent platform probes cannot race the global is_probed
handshake or the one-time socket allocation. Use lockdep_assert_held() in
init_acpi() to catch incorrect locking under lockdep.
Signed-off-by: Muralidhara M K <muralidhara.mk@amd.com>
---
drivers/platform/x86/amd/hsmp/acpi.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c
index 97ed71593bdf..696884a91c22 100644
--- a/drivers/platform/x86/amd/hsmp/acpi.c
+++ b/drivers/platform/x86/amd/hsmp/acpi.c
@@ -18,8 +18,11 @@
#include <linux/device.h>
#include <linux/dev_printk.h>
#include <linux/ioport.h>
+#include <linux/cleanup.h>
+#include <linux/lockdep.h>
#include <linux/kstrtox.h>
#include <linux/module.h>
+#include <linux/mutex.h>
#include <linux/platform_device.h>
#include <linux/sysfs.h>
#include <linux/topology.h>
@@ -38,6 +41,8 @@
static struct hsmp_plat_device *hsmp_pdev;
+static DEFINE_MUTEX(hsmp_acpi_probe_mutex);
+
struct hsmp_sys_attr {
struct device_attribute dattr;
u32 msg_id;
@@ -459,11 +464,17 @@ static ssize_t hsmp_freq_limit_source_show(struct device *dev, struct device_att
return len;
}
+/**
+ * init_acpi() - Parse ACPI mailbox resources for one socket and validate HSMP.
+ * @dev: ACPI companion device for this socket.
+ */
static int init_acpi(struct device *dev)
{
u16 sock_ind;
int ret;
+ lockdep_assert_held(&hsmp_acpi_probe_mutex);
+
ret = hsmp_get_uid(dev, &sock_ind);
if (ret)
return ret;
@@ -584,6 +595,8 @@ static int hsmp_acpi_probe(struct platform_device *pdev)
if (!hsmp_pdev)
return -ENOMEM;
+ guard(mutex)(&hsmp_acpi_probe_mutex);
+
if (!hsmp_pdev->is_probed) {
hsmp_pdev->num_sockets = topology_max_packages();
if (!hsmp_pdev->num_sockets) {
@@ -619,6 +632,7 @@ static int hsmp_acpi_probe(struct platform_device *pdev)
static void hsmp_acpi_remove(struct platform_device *pdev)
{
+ mutex_lock(&hsmp_acpi_probe_mutex);
/*
* We register only one misc_device even on multi-socket system.
* So, deregister should happen only once.
@@ -627,6 +641,7 @@ static void hsmp_acpi_remove(struct platform_device *pdev)
hsmp_misc_deregister();
hsmp_pdev->is_probed = false;
}
+ mutex_unlock(&hsmp_acpi_probe_mutex);
}
static struct platform_driver amd_hsmp_driver = {
--
2.34.1
next prev parent reply other threads:[~2026-06-13 19:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-13 19:17 [PATCH 0/3] platform/x86/amd/hsmp: Harden ACPI probe, metric DRAM, and socket teardown Muralidhara M K
2026-06-13 19:17 ` Muralidhara M K [this message]
2026-06-13 19:17 ` [PATCH 2/3] platform/x86/amd/hsmp: Add explicit metric DRAM mapping and per-socket mutexes Muralidhara M K
2026-06-13 19:17 ` [PATCH 3/3] platform/x86/amd/hsmp: ACPI HSMP refcounted sockets and coordinated release Muralidhara M K
2026-06-16 8:28 ` [PATCH 0/3] platform/x86/amd/hsmp: Harden ACPI probe, metric DRAM, and socket teardown M K, Muralidhara
2026-06-16 12:19 ` Ilpo Järvinen
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=20260613191755.2358969-2-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®