mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] platform/x86/intel/vsec: Remove a useless mutex
@ 2024-11-02 15:59 Christophe JAILLET
  2024-11-02 19:39 ` Hans de Goede
  2024-11-04 13:16 ` Ilpo Järvinen
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2024-11-02 15:59 UTC (permalink / raw)
  To: srinivas.pandruvada, David E. Box, Hans de Goede, Ilpo Järvinen
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, platform-driver-x86

ida_alloc()/ida_free() don't need any mutex, so remove this one.

It was introduced by commit 9a90ea7d3784 ("platform/x86/intel/vsec: Use
mutex for ida_alloc() and ida_free()").

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
See:
https://elixir.bootlin.com/linux/v6.11.2/source/lib/idr.c#L375
https://elixir.bootlin.com/linux/v6.11.2/source/lib/idr.c#L484

Review with care. This patch is clearly the opposite of the one in Fixes
which states that locking IS needed.
IIUC, idr_ functions need locking, but not ida_.

If I'm wrong, could you elaborate why? (because many other places will
need to be fixed and the doc certainly needs updating)
---
 drivers/platform/x86/intel/vsec.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c
index 7b5cc9993974..9e0f8e38178c 100644
--- a/drivers/platform/x86/intel/vsec.c
+++ b/drivers/platform/x86/intel/vsec.c
@@ -79,17 +79,13 @@ static void intel_vsec_remove_aux(void *data)
 	auxiliary_device_uninit(data);
 }
 
-static DEFINE_MUTEX(vsec_ida_lock);
-
 static void intel_vsec_dev_release(struct device *dev)
 {
 	struct intel_vsec_device *intel_vsec_dev = dev_to_ivdev(dev);
 
 	xa_erase(&auxdev_array, intel_vsec_dev->id);
 
-	mutex_lock(&vsec_ida_lock);
 	ida_free(intel_vsec_dev->ida, intel_vsec_dev->auxdev.id);
-	mutex_unlock(&vsec_ida_lock);
 
 	kfree(intel_vsec_dev->resource);
 	kfree(intel_vsec_dev);
@@ -113,9 +109,7 @@ int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent,
 		return ret;
 	}
 
-	mutex_lock(&vsec_ida_lock);
 	id = ida_alloc(intel_vsec_dev->ida, GFP_KERNEL);
-	mutex_unlock(&vsec_ida_lock);
 	if (id < 0) {
 		xa_erase(&auxdev_array, intel_vsec_dev->id);
 		kfree(intel_vsec_dev->resource);
-- 
2.47.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] platform/x86/intel/vsec: Remove a useless mutex
  2024-11-02 15:59 [PATCH] platform/x86/intel/vsec: Remove a useless mutex Christophe JAILLET
@ 2024-11-02 19:39 ` Hans de Goede
  2024-11-04 13:16 ` Ilpo Järvinen
  1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2024-11-02 19:39 UTC (permalink / raw)
  To: Christophe JAILLET, srinivas.pandruvada, David E. Box,
	Ilpo Järvinen
  Cc: linux-kernel, kernel-janitors, platform-driver-x86

Hi,

On 2-Nov-24 4:59 PM, Christophe JAILLET wrote:
> ida_alloc()/ida_free() don't need any mutex, so remove this one.
> 
> It was introduced by commit 9a90ea7d3784 ("platform/x86/intel/vsec: Use
> mutex for ida_alloc() and ida_free()").
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> See:
> https://elixir.bootlin.com/linux/v6.11.2/source/lib/idr.c#L375
> https://elixir.bootlin.com/linux/v6.11.2/source/lib/idr.c#L484
> 
> Review with care. This patch is clearly the opposite of the one in Fixes
> which states that locking IS needed.
> IIUC, idr_ functions need locking, but not ida_.
> 
> If I'm wrong, could you elaborate why? (because many other places will
> need to be fixed and the doc certainly needs updating)

This is my bad, looking at the ida docs they clearly state
no locking is necessary.

Back then I was working on / reviewing some other stuff using
idr which does need locking and I likely simply confused the 2
and suggested for the locking to be added.

Anyways dropping the locking looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
>  drivers/platform/x86/intel/vsec.c | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c
> index 7b5cc9993974..9e0f8e38178c 100644
> --- a/drivers/platform/x86/intel/vsec.c
> +++ b/drivers/platform/x86/intel/vsec.c
> @@ -79,17 +79,13 @@ static void intel_vsec_remove_aux(void *data)
>  	auxiliary_device_uninit(data);
>  }
>  
> -static DEFINE_MUTEX(vsec_ida_lock);
> -
>  static void intel_vsec_dev_release(struct device *dev)
>  {
>  	struct intel_vsec_device *intel_vsec_dev = dev_to_ivdev(dev);
>  
>  	xa_erase(&auxdev_array, intel_vsec_dev->id);
>  
> -	mutex_lock(&vsec_ida_lock);
>  	ida_free(intel_vsec_dev->ida, intel_vsec_dev->auxdev.id);
> -	mutex_unlock(&vsec_ida_lock);
>  
>  	kfree(intel_vsec_dev->resource);
>  	kfree(intel_vsec_dev);
> @@ -113,9 +109,7 @@ int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent,
>  		return ret;
>  	}
>  
> -	mutex_lock(&vsec_ida_lock);
>  	id = ida_alloc(intel_vsec_dev->ida, GFP_KERNEL);
> -	mutex_unlock(&vsec_ida_lock);
>  	if (id < 0) {
>  		xa_erase(&auxdev_array, intel_vsec_dev->id);
>  		kfree(intel_vsec_dev->resource);


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] platform/x86/intel/vsec: Remove a useless mutex
  2024-11-02 15:59 [PATCH] platform/x86/intel/vsec: Remove a useless mutex Christophe JAILLET
  2024-11-02 19:39 ` Hans de Goede
@ 2024-11-04 13:16 ` Ilpo Järvinen
  1 sibling, 0 replies; 3+ messages in thread
From: Ilpo Järvinen @ 2024-11-04 13:16 UTC (permalink / raw)
  To: srinivas.pandruvada, David E. Box, Hans de Goede, Christophe JAILLET
  Cc: linux-kernel, kernel-janitors, platform-driver-x86

On Sat, 02 Nov 2024 16:59:41 +0100, Christophe JAILLET wrote:

> ida_alloc()/ida_free() don't need any mutex, so remove this one.
> 
> It was introduced by commit 9a90ea7d3784 ("platform/x86/intel/vsec: Use
> mutex for ida_alloc() and ida_free()").
> 
> 


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

The list of commits applied:
[1/1] platform/x86/intel/vsec: Remove a useless mutex
      commit: ab49d7bf991a524a976c9fbbeb53b050ebe4323f

--
 i.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-04 13:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-02 15:59 [PATCH] platform/x86/intel/vsec: Remove a useless mutex Christophe JAILLET
2024-11-02 19:39 ` Hans de Goede
2024-11-04 13:16 ` Ilpo Järvinen

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®