From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Suma Hegde <suma.hegde@amd.com>
Cc: platform-driver-x86@vger.kernel.org,
Hans de Goede <hdegoede@redhat.com>,
Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>
Subject: Re: [PATCH] platform/x86/amd/hsmp: Use guard mutex to synchronize probe
Date: Thu, 26 Jun 2025 19:31:54 +0300 (EEST) [thread overview]
Message-ID: <ada3eca0-4c86-c3ee-816c-a3635b4ad110@linux.intel.com> (raw)
In-Reply-To: <20250625100216.1462594-1-suma.hegde@amd.com>
On Wed, 25 Jun 2025, Suma Hegde wrote:
In the shortlog, drop word "guard". This should also mention ACPI as the
legacy probe is not affected.
> When async probing is used, 2 hsmp_acpi_probe() calls can race and
> make a mess of things.
Too vague wording.
> So, add guard mutex to synchronize them.
>
> Suggested-by: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Suma Hegde <suma.hegde@amd.com>
> Reviewed-by: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>
> ---
> drivers/platform/x86/amd/hsmp/acpi.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c
> index 2f1faa82d13e..ab2b65f16d1d 100644
> --- a/drivers/platform/x86/amd/hsmp/acpi.c
> +++ b/drivers/platform/x86/amd/hsmp/acpi.c
> @@ -15,11 +15,13 @@
> #include <linux/array_size.h>
> #include <linux/bits.h>
> #include <linux/bitfield.h>
> +#include <linux/cleanup.h>
> #include <linux/device.h>
> #include <linux/dev_printk.h>
> #include <linux/ioport.h>
> #include <linux/kstrtox.h>
> #include <linux/module.h>
> +#include <linux/mutex.h>
> #include <linux/platform_device.h>
> #include <linux/sysfs.h>
> #include <linux/uuid.h>
> @@ -44,6 +46,8 @@ struct hsmp_sys_attr {
> u32 msg_id;
> };
>
> +static DEFINE_MUTEX(hsmp_lock);
> +
> static int amd_hsmp_acpi_rdwr(struct hsmp_socket *sock, u32 offset,
> u32 *value, bool write)
> {
> @@ -585,6 +589,8 @@ static int hsmp_acpi_probe(struct platform_device *pdev)
> if (!hsmp_pdev)
> return -ENOMEM;
>
> + guard(mutex)(&hsmp_lock);
> +
> if (!hsmp_pdev->is_probed) {
> hsmp_pdev->num_sockets = amd_num_nodes();
> if (hsmp_pdev->num_sockets == 0 || hsmp_pdev->num_sockets > MAX_AMD_NUM_NODES)
So is it just the ->sock alloc and misc dev registration that require
protection? (The latter doesn't even seem to require that if a local
variable carries that information over.)
--
i.
next prev parent reply other threads:[~2025-06-26 16:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-25 10:02 [PATCH] platform/x86/amd/hsmp: Use guard mutex to synchronize probe Suma Hegde
2025-06-26 16:31 ` Ilpo Järvinen [this message]
2025-06-26 18:53 ` Hans de Goede
2025-06-27 5:24 ` Suma Hegde
2025-06-27 7:55 ` Ilpo Järvinen
2025-07-07 10:50 ` Suma Hegde
2025-07-07 12:10 ` 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=ada3eca0-4c86-c3ee-816c-a3635b4ad110@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=hdegoede@redhat.com \
--cc=naveenkrishna.chatradhi@amd.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=suma.hegde@amd.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.