msm: Replace idle wakelocks with pm_qos
Idle wakelocks are being removed so replace them with pm_qos.
Since we don't know every driver's latency requirements we
maintain one-to-one compatabilty with the idle wakelock API by
replacing the wakelock with a pm_qos request of the correct
latency.
Once we determine the actual latency requirements of each driver
we can replace the latency used with the correct latency for the
device.
Change-Id: Icc40f1642218e0de8fc2f56eaf9e8f92914d142f
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
diff --git a/drivers/mfd/wcd9xxx-core.c b/drivers/mfd/wcd9xxx-core.c
index e2dff4b..bbb2509 100644
--- a/drivers/mfd/wcd9xxx-core.c
+++ b/drivers/mfd/wcd9xxx-core.c
@@ -307,7 +307,8 @@
wcd9xxx->wlock_holders = 0;
wcd9xxx->pm_state = WCD9XXX_PM_SLEEPABLE;
init_waitqueue_head(&wcd9xxx->pm_wq);
- wake_lock_init(&wcd9xxx->wlock, WAKE_LOCK_IDLE, "wcd9310-irq");
+ pm_qos_add_request(&wcd9xxx->pm_qos_req, PM_QOS_CPU_DMA_LATENCY,
+ PM_QOS_DEFAULT_VALUE);
dev_set_drvdata(wcd9xxx->dev, wcd9xxx);
@@ -374,7 +375,7 @@
wcd9xxx_irq_exit(wcd9xxx);
err:
wcd9xxx_bring_down(wcd9xxx);
- wake_lock_destroy(&wcd9xxx->wlock);
+ pm_qos_remove_request(&wcd9xxx->pm_qos_req);
mutex_destroy(&wcd9xxx->pm_lock);
mutex_destroy(&wcd9xxx->io_lock);
mutex_destroy(&wcd9xxx->xfer_lock);
@@ -387,7 +388,7 @@
wcd9xxx_bring_down(wcd9xxx);
wcd9xxx_free_reset(wcd9xxx);
mutex_destroy(&wcd9xxx->pm_lock);
- wake_lock_destroy(&wcd9xxx->wlock);
+ pm_qos_remove_request(&wcd9xxx->pm_qos_req);
mutex_destroy(&wcd9xxx->io_lock);
mutex_destroy(&wcd9xxx->xfer_lock);
if (wcd9xxx_intf == WCD9XXX_INTERFACE_TYPE_SLIMBUS)
@@ -986,8 +987,10 @@
int ret = 0;
pr_debug("%s: enter\n", __func__);
- /* wake_lock() can be called after this suspend chain call started.
- * thus suspend can be called while wlock is being held */
+ /*
+ * pm_qos_update_request() can be called after this suspend chain call
+ * started. thus suspend can be called while lock is being held
+ */
mutex_lock(&wcd9xxx->pm_lock);
if (wcd9xxx->pm_state == WCD9XXX_PM_SLEEPABLE) {
pr_debug("%s: suspending system, state %d, wlock %d\n",
diff --git a/drivers/mfd/wcd9xxx-irq.c b/drivers/mfd/wcd9xxx-irq.c
index ba3c1e8..68c4557 100644
--- a/drivers/mfd/wcd9xxx-irq.c
+++ b/drivers/mfd/wcd9xxx-irq.c
@@ -20,6 +20,8 @@
#include <linux/mfd/wcd9xxx/wcd9310_registers.h>
#include <linux/interrupt.h>
+#include <mach/cpuidle.h>
+
#define BYTE_BIT_MASK(nr) (1UL << ((nr) % BITS_PER_BYTE))
#define BIT_BYTE(nr) ((nr) / BITS_PER_BYTE)
@@ -113,7 +115,8 @@
mutex_lock(&wcd9xxx->pm_lock);
if (wcd9xxx->wlock_holders++ == 0) {
pr_debug("%s: holding wake lock\n", __func__);
- wake_lock(&wcd9xxx->wlock);
+ pm_qos_update_request(&wcd9xxx->pm_qos_req,
+ msm_cpuidle_get_deep_idle_latency());
}
mutex_unlock(&wcd9xxx->pm_lock);
if (!wait_event_timeout(wcd9xxx->pm_wq,
@@ -140,7 +143,8 @@
if (--wcd9xxx->wlock_holders == 0) {
wcd9xxx->pm_state = WCD9XXX_PM_SLEEPABLE;
pr_debug("%s: releasing wake lock\n", __func__);
- wake_unlock(&wcd9xxx->wlock);
+ pm_qos_update_request(&wcd9xxx->pm_qos_req,
+ PM_QOS_DEFAULT_VALUE);
}
mutex_unlock(&wcd9xxx->pm_lock);
wake_up_all(&wcd9xxx->pm_wq);