All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] misc: atmel-ssc: lock with mutex instead of spinlock
@ 2020-06-01  3:45 ` Michał Mirosław
  0 siblings, 0 replies; 7+ messages in thread
From: Michał Mirosław @ 2020-06-01  3:45 UTC (permalink / raw)
  To: Nicolas Ferre, Arnd Bergmann, Greg Kroah-Hartman,
	Alexandre Belloni, Ludovic Desroches
  Cc: linux-arm-kernel, linux-kernel

Uninterruptible context is not needed in the driver and causes lockdep
warning because of mutex taken in of_alias_get_id(). Convert the lock to
mutex to avoid the issue.

Cc: stable@vger.kernel.org
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/misc/atmel-ssc.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
index 1322e29bc37a..5cc032097476 100644
--- a/drivers/misc/atmel-ssc.c
+++ b/drivers/misc/atmel-ssc.c
@@ -10,7 +10,7 @@
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/io.h>
-#include <linux/spinlock.h>
+#include <linux/mutex.h>
 #include <linux/atmel-ssc.h>
 #include <linux/slab.h>
 #include <linux/module.h>
@@ -20,7 +20,7 @@
 #include "../../sound/soc/atmel/atmel_ssc_dai.h"
 
 /* Serialize access to ssc_list and user count */
-static DEFINE_SPINLOCK(user_lock);
+static DEFINE_MUTEX(user_lock);
 static LIST_HEAD(ssc_list);
 
 struct ssc_device *ssc_request(unsigned int ssc_num)
@@ -28,7 +28,7 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
 	int ssc_valid = 0;
 	struct ssc_device *ssc;
 
-	spin_lock(&user_lock);
+	mutex_lock(&user_lock);
 	list_for_each_entry(ssc, &ssc_list, list) {
 		if (ssc->pdev->dev.of_node) {
 			if (of_alias_get_id(ssc->pdev->dev.of_node, "ssc")
@@ -44,18 +44,18 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
 	}
 
 	if (!ssc_valid) {
-		spin_unlock(&user_lock);
+		mutex_unlock(&user_lock);
 		pr_err("ssc: ssc%d platform device is missing\n", ssc_num);
 		return ERR_PTR(-ENODEV);
 	}
 
 	if (ssc->user) {
-		spin_unlock(&user_lock);
+		mutex_unlock(&user_lock);
 		dev_dbg(&ssc->pdev->dev, "module busy\n");
 		return ERR_PTR(-EBUSY);
 	}
 	ssc->user++;
-	spin_unlock(&user_lock);
+	mutex_unlock(&user_lock);
 
 	clk_prepare(ssc->clk);
 
@@ -67,14 +67,14 @@ void ssc_free(struct ssc_device *ssc)
 {
 	bool disable_clk = true;
 
-	spin_lock(&user_lock);
+	mutex_lock(&user_lock);
 	if (ssc->user)
 		ssc->user--;
 	else {
 		disable_clk = false;
 		dev_dbg(&ssc->pdev->dev, "device already free\n");
 	}
-	spin_unlock(&user_lock);
+	mutex_unlock(&user_lock);
 
 	if (disable_clk)
 		clk_unprepare(ssc->clk);
@@ -246,9 +246,9 @@ static int ssc_probe(struct platform_device *pdev)
 		return -ENXIO;
 	}
 
-	spin_lock(&user_lock);
+	mutex_lock(&user_lock);
 	list_add_tail(&ssc->list, &ssc_list);
-	spin_unlock(&user_lock);
+	mutex_unlock(&user_lock);
 
 	platform_set_drvdata(pdev, ssc);
 
@@ -267,9 +267,9 @@ static int ssc_remove(struct platform_device *pdev)
 
 	ssc_sound_dai_remove(ssc);
 
-	spin_lock(&user_lock);
+	mutex_lock(&user_lock);
 	list_del(&ssc->list);
-	spin_unlock(&user_lock);
+	mutex_unlock(&user_lock);
 
 	return 0;
 }
-- 
2.20.1


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

* [PATCH] misc: atmel-ssc: lock with mutex instead of spinlock
@ 2020-06-01  3:45 ` Michał Mirosław
  0 siblings, 0 replies; 7+ messages in thread
From: Michał Mirosław @ 2020-06-01  3:45 UTC (permalink / raw)
  To: Nicolas Ferre, Arnd Bergmann, Greg Kroah-Hartman,
	Alexandre Belloni, Ludovic Desroches
  Cc: linux-kernel, linux-arm-kernel

Uninterruptible context is not needed in the driver and causes lockdep
warning because of mutex taken in of_alias_get_id(). Convert the lock to
mutex to avoid the issue.

Cc: stable@vger.kernel.org
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/misc/atmel-ssc.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
index 1322e29bc37a..5cc032097476 100644
--- a/drivers/misc/atmel-ssc.c
+++ b/drivers/misc/atmel-ssc.c
@@ -10,7 +10,7 @@
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/io.h>
-#include <linux/spinlock.h>
+#include <linux/mutex.h>
 #include <linux/atmel-ssc.h>
 #include <linux/slab.h>
 #include <linux/module.h>
@@ -20,7 +20,7 @@
 #include "../../sound/soc/atmel/atmel_ssc_dai.h"
 
 /* Serialize access to ssc_list and user count */
-static DEFINE_SPINLOCK(user_lock);
+static DEFINE_MUTEX(user_lock);
 static LIST_HEAD(ssc_list);
 
 struct ssc_device *ssc_request(unsigned int ssc_num)
@@ -28,7 +28,7 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
 	int ssc_valid = 0;
 	struct ssc_device *ssc;
 
-	spin_lock(&user_lock);
+	mutex_lock(&user_lock);
 	list_for_each_entry(ssc, &ssc_list, list) {
 		if (ssc->pdev->dev.of_node) {
 			if (of_alias_get_id(ssc->pdev->dev.of_node, "ssc")
@@ -44,18 +44,18 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
 	}
 
 	if (!ssc_valid) {
-		spin_unlock(&user_lock);
+		mutex_unlock(&user_lock);
 		pr_err("ssc: ssc%d platform device is missing\n", ssc_num);
 		return ERR_PTR(-ENODEV);
 	}
 
 	if (ssc->user) {
-		spin_unlock(&user_lock);
+		mutex_unlock(&user_lock);
 		dev_dbg(&ssc->pdev->dev, "module busy\n");
 		return ERR_PTR(-EBUSY);
 	}
 	ssc->user++;
-	spin_unlock(&user_lock);
+	mutex_unlock(&user_lock);
 
 	clk_prepare(ssc->clk);
 
@@ -67,14 +67,14 @@ void ssc_free(struct ssc_device *ssc)
 {
 	bool disable_clk = true;
 
-	spin_lock(&user_lock);
+	mutex_lock(&user_lock);
 	if (ssc->user)
 		ssc->user--;
 	else {
 		disable_clk = false;
 		dev_dbg(&ssc->pdev->dev, "device already free\n");
 	}
-	spin_unlock(&user_lock);
+	mutex_unlock(&user_lock);
 
 	if (disable_clk)
 		clk_unprepare(ssc->clk);
@@ -246,9 +246,9 @@ static int ssc_probe(struct platform_device *pdev)
 		return -ENXIO;
 	}
 
-	spin_lock(&user_lock);
+	mutex_lock(&user_lock);
 	list_add_tail(&ssc->list, &ssc_list);
-	spin_unlock(&user_lock);
+	mutex_unlock(&user_lock);
 
 	platform_set_drvdata(pdev, ssc);
 
@@ -267,9 +267,9 @@ static int ssc_remove(struct platform_device *pdev)
 
 	ssc_sound_dai_remove(ssc);
 
-	spin_lock(&user_lock);
+	mutex_lock(&user_lock);
 	list_del(&ssc->list);
-	spin_unlock(&user_lock);
+	mutex_unlock(&user_lock);
 
 	return 0;
 }
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] misc: atmel-ssc: lock with mutex instead of spinlock
  2020-06-01  9:18 ` Markus Elfring
  (?)
@ 2020-06-01 17:31   ` Michał Mirosław
  -1 siblings, 0 replies; 7+ messages in thread
From: Michał Mirosław @ 2020-06-01 17:31 UTC (permalink / raw)
  To: Markus Elfring
  Cc: linux-arm-kernel, kernel-janitors, linux-kernel,
	Alexandre Belloni, Arnd Bergmann, Greg Kroah-Hartman,
	Ludovic Desroches, Nicolas Ferre

On Mon, Jun 01, 2020 at 11:18:48AM +0200, Markus Elfring wrote:
> > Uninterruptible context is not needed in the driver and causes lockdep
> > warning because of mutex taken in of_alias_get_id().
> 
> Was a spin lock taken?
> > Convert the lock to mutex to avoid the issue.
> Would you like to add the tag “Fixes” to the commit message?

I guess we can add:

Fixes: 099343c64e16 ("ARM: at91: atmel-ssc: add device tree support")

Best Regards
Michał Mirosław

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

* Re: [PATCH] misc: atmel-ssc: lock with mutex instead of spinlock
@ 2020-06-01 17:31   ` Michał Mirosław
  0 siblings, 0 replies; 7+ messages in thread
From: Michał Mirosław @ 2020-06-01 17:31 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Alexandre Belloni, Arnd Bergmann, Greg Kroah-Hartman,
	kernel-janitors, linux-kernel, Ludovic Desroches,
	linux-arm-kernel

On Mon, Jun 01, 2020 at 11:18:48AM +0200, Markus Elfring wrote:
> > Uninterruptible context is not needed in the driver and causes lockdep
> > warning because of mutex taken in of_alias_get_id().
> 
> Was a spin lock taken?
> > Convert the lock to mutex to avoid the issue.
> Would you like to add the tag “Fixes” to the commit message?

I guess we can add:

Fixes: 099343c64e16 ("ARM: at91: atmel-ssc: add device tree support")

Best Regards
Michał Mirosław

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

* Re: [PATCH] misc: atmel-ssc: lock with mutex instead of spinlock
@ 2020-06-01 17:31   ` Michał Mirosław
  0 siblings, 0 replies; 7+ messages in thread
From: Michał Mirosław @ 2020-06-01 17:31 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Alexandre Belloni, Arnd Bergmann, Greg Kroah-Hartman,
	kernel-janitors, linux-kernel, Ludovic Desroches,
	linux-arm-kernel

On Mon, Jun 01, 2020 at 11:18:48AM +0200, Markus Elfring wrote:
> > Uninterruptible context is not needed in the driver and causes lockdep
> > warning because of mutex taken in of_alias_get_id().
> 
> Was a spin lock taken?
> > Convert the lock to mutex to avoid the issue.
> Would you like to add the tag “Fixes” to the commit message?

I guess we can add:

Fixes: 099343c64e16 ("ARM: at91: atmel-ssc: add device tree support")

Best Regards
Michał Mirosław

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] misc: atmel-ssc: lock with mutex instead of spinlock
@ 2020-06-01  9:18 ` Markus Elfring
  0 siblings, 0 replies; 7+ messages in thread
From: Markus Elfring @ 2020-06-01  9:18 UTC (permalink / raw)
  To: Michał Mirosław, linux-arm-kernel
  Cc: kernel-janitors, linux-kernel, Alexandre Belloni, Arnd Bergmann,
	Greg Kroah-Hartman, Ludovic Desroches, Nicolas Ferre

> Uninterruptible context is not needed in the driver and causes lockdep
> warning because of mutex taken in of_alias_get_id().

Was a spin lock taken?


> Convert the lock to mutex to avoid the issue.

Would you like to add the tag “Fixes” to the commit message?

Regards,
Markus

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

* Re: [PATCH] misc: atmel-ssc: lock with mutex instead of spinlock
@ 2020-06-01  9:18 ` Markus Elfring
  0 siblings, 0 replies; 7+ messages in thread
From: Markus Elfring @ 2020-06-01  9:18 UTC (permalink / raw)
  To: Michał Mirosław, linux-arm-kernel
  Cc: kernel-janitors, linux-kernel, Alexandre Belloni, Arnd Bergmann,
	Greg Kroah-Hartman, Ludovic Desroches, Nicolas Ferre

> Uninterruptible context is not needed in the driver and causes lockdep
> warning because of mutex taken in of_alias_get_id().

Was a spin lock taken?


> Convert the lock to mutex to avoid the issue.

Would you like to add the tag “Fixes” to the commit message?

Regards,
Markus

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

end of thread, other threads:[~2020-06-01 17:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-01  3:45 [PATCH] misc: atmel-ssc: lock with mutex instead of spinlock Michał Mirosław
2020-06-01  3:45 ` Michał Mirosław
2020-06-01  9:18 Markus Elfring
2020-06-01  9:18 ` Markus Elfring
2020-06-01 17:31 ` Michał Mirosław
2020-06-01 17:31   ` Michał Mirosław
2020-06-01 17:31   ` Michał Mirosław

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.