[ARM] S3C24XX: Change clock locking to use spinlocks.
We cannot sleep if we have cpufreq pm enabled during some
of the clock operations, so change to use a spinlock to
protect the clock system.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
diff --git a/arch/arm/plat-s3c24xx/clock.c b/arch/arm/plat-s3c24xx/clock.c
index 1ff1b98..334e696 100644
--- a/arch/arm/plat-s3c24xx/clock.c
+++ b/arch/arm/plat-s3c24xx/clock.c
@@ -37,7 +37,7 @@
#include <linux/interrupt.h>
#include <linux/ioport.h>
#include <linux/clk.h>
-#include <linux/mutex.h>
+#include <linux/spinlock.h>
#include <linux/delay.h>
#include <linux/io.h>
@@ -55,7 +55,11 @@
static LIST_HEAD(clocks);
-DEFINE_MUTEX(clocks_mutex);
+/* We originally used an mutex here, but some contexts (see resume)
+ * are calling functions such as clk_set_parent() with IRQs disabled
+ * causing an BUG to be triggered.
+ */
+DEFINE_SPINLOCK(clocks_lock);
/* enable and disable calls for use with the clk struct */
@@ -77,7 +81,7 @@
else
idno = to_platform_device(dev)->id;
- mutex_lock(&clocks_mutex);
+ spin_lock(&clocks_lock);
list_for_each_entry(p, &clocks, list) {
if (p->id == idno &&
@@ -101,7 +105,7 @@
}
}
- mutex_unlock(&clocks_mutex);
+ spin_unlock(&clocks_lock);
return clk;
}
@@ -117,12 +121,12 @@
clk_enable(clk->parent);
- mutex_lock(&clocks_mutex);
+ spin_lock(&clocks_lock);
if ((clk->usage++) == 0)
(clk->enable)(clk, 1);
- mutex_unlock(&clocks_mutex);
+ spin_unlock(&clocks_lock);
return 0;
}
@@ -131,12 +135,12 @@
if (IS_ERR(clk) || clk == NULL)
return;
- mutex_lock(&clocks_mutex);
+ spin_lock(&clocks_lock);
if ((--clk->usage) == 0)
(clk->enable)(clk, 0);
- mutex_unlock(&clocks_mutex);
+ spin_unlock(&clocks_lock);
clk_disable(clk->parent);
}
@@ -182,9 +186,9 @@
if (clk->set_rate == NULL)
return -EINVAL;
- mutex_lock(&clocks_mutex);
+ spin_lock(&clocks_lock);
ret = (clk->set_rate)(clk, rate);
- mutex_unlock(&clocks_mutex);
+ spin_unlock(&clocks_lock);
return ret;
}
@@ -201,12 +205,12 @@
if (IS_ERR(clk))
return -EINVAL;
- mutex_lock(&clocks_mutex);
+ spin_lock(&clocks_lock);
if (clk->set_parent)
ret = (clk->set_parent)(clk, parent);
- mutex_unlock(&clocks_mutex);
+ spin_unlock(&clocks_lock);
return ret;
}
@@ -302,9 +306,9 @@
/* add to the list of available clocks */
- mutex_lock(&clocks_mutex);
+ spin_lock(&clocks_lock);
list_add(&clk->list, &clocks);
- mutex_unlock(&clocks_mutex);
+ spin_unlock(&clocks_lock);
return 0;
}