All of lore.kernel.org
 help / color / mirror / Atom feed
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 v2 1/4] platform/x86/amd/hsmp: Use mutex to synchronize ACPI based probe
Date: Tue, 19 Aug 2025 11:23:53 +0300 (EEST)	[thread overview]
Message-ID: <6a754baa-e61b-1807-c399-004a6f43c2f2@linux.intel.com> (raw)
In-Reply-To: <20250723051251.3009625-2-suma.hegde@amd.com>

On Wed, 23 Jul 2025, Suma Hegde wrote:

> The hsmp_acpi_probe() function is called for each socket. When
> asynchronous probing is enabled, it can lead to race conditions
> due to multiple probes accessing shared data (hsmp_pdev->sock
> and the hsmp_pdev->is_probed variable), which may cause potential
> issues.
> 
> To resolve these issues, a guard mutex has been introduced to ensure
> synchronized execution.
> 
> 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>

I guess Fixes tag would be in order for this and some other patches in 
the series too.

-- 
 i.

> ---
> Changes since v1:
> 1. Guard the remove() also
> 2. Update commit description
> 
>  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 d974c2289f5a..b981ae3157ea 100644
> --- a/drivers/platform/x86/amd/hsmp/acpi.c
> +++ b/drivers/platform/x86/amd/hsmp/acpi.c
> @@ -13,6 +13,7 @@
>  
>  #include <linux/acpi.h>
>  #include <linux/array_size.h>
> +#include <linux/cleanup.h>
>  #include <linux/bits.h>
>  #include <linux/bitfield.h>
>  #include <linux/device.h>
> @@ -20,6 +21,7 @@
>  #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)
>  {
> @@ -584,6 +588,7 @@ static int hsmp_acpi_probe(struct platform_device *pdev)
>  	hsmp_pdev = get_hsmp_pdev();
>  	if (!hsmp_pdev)
>  		return -ENOMEM;
> +	guard(mutex)(&hsmp_lock);
>  
>  	if (!hsmp_pdev->is_probed) {
>  		hsmp_pdev->num_sockets = amd_num_nodes();
> @@ -620,6 +625,7 @@ static int hsmp_acpi_probe(struct platform_device *pdev)
>  
>  static void hsmp_acpi_remove(struct platform_device *pdev)
>  {
> +	guard(mutex)(&hsmp_lock);
>  	/*
>  	 * We register only one misc_device even on multi-socket system.
>  	 * So, deregister should happen only once.
> 

  reply	other threads:[~2025-08-19  8:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-23  5:12 [PATCH v2 0/4] platform/x86/amd/hsmp: Fix potential issues during async probing of ACPI driver Suma Hegde
2025-07-23  5:12 ` [PATCH v2 1/4] platform/x86/amd/hsmp: Use mutex to synchronize ACPI based probe Suma Hegde
2025-08-19  8:23   ` Ilpo Järvinen [this message]
2025-07-23  5:12 ` [PATCH v2 2/4] platform/x86/amd/hsmp: Add reference counter to track ACPI probe and removal Suma Hegde
2025-07-23  7:17   ` Ilpo Järvinen
2025-07-23  5:12 ` [PATCH v2 3/4] platform/x86/amd/hsmp: Move initialization of num_sockets to hsmp_common_init() Suma Hegde
2025-07-23  5:12 ` [PATCH v2 4/4] platform/x86/amd/hsmp: Ensure initialization of the sock struct in hsmp_send_message() Suma Hegde
2025-07-23  7:10   ` Ilpo Järvinen
2025-07-24  9:20     ` Suma Hegde
2025-08-02 12:31       ` Suma Hegde
2025-08-19  8:21         ` 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=6a754baa-e61b-1807-c399-004a6f43c2f2@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.