diff --git a/arch/arm/mach-msm/include/mach/camera.h b/arch/arm/mach-msm/include/mach/camera.h index 47d9b5fbb42..87e7de1a76a 100644 --- a/arch/arm/mach-msm/include/mach/camera.h +++ b/arch/arm/mach-msm/include/mach/camera.h @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include "linux/types.h" @@ -414,7 +414,7 @@ struct msm_sync { struct msm_camvpe_fn vpefn; struct msm_sensor_ctrl sctrl; struct msm_strobe_flash_ctrl sfctrl; - struct wake_lock wake_lock; + struct pm_qos_request idle_pm_qos; struct platform_device *pdev; int16_t ignore_qcmd_type; uint8_t ignore_qcmd; diff --git a/arch/arm/mach-msm/qdsp5/audio_mvs.c b/arch/arm/mach-msm/qdsp5/audio_mvs.c index 5ccd18b6dcc..9b524b4bc16 100644 --- a/arch/arm/mach-msm/qdsp5/audio_mvs.c +++ b/arch/arm/mach-msm/qdsp5/audio_mvs.c @@ -20,8 +20,11 @@ #include #include #include +#include + #include #include +#include #define MVS_PROG 0x30000014 #define MVS_VERS 0x00030001 @@ -330,7 +333,7 @@ struct audio_mvs_info_type { struct mutex out_lock; struct wake_lock suspend_lock; - struct wake_lock idle_lock; + struct pm_qos_request pm_qos_req; }; static struct audio_mvs_info_type audio_mvs_info; @@ -691,7 +694,8 @@ static int audio_mvs_start(struct audio_mvs_info_type *audio) /* Prevent sleep. */ wake_lock(&audio->suspend_lock); - wake_lock(&audio->idle_lock); + pm_qos_update_request(&audio->pm_qos_req, + msm_cpuidle_get_deep_idle_latency()); /* Acquire MVS. */ memset(&acquire_msg, 0, sizeof(acquire_msg)); @@ -778,8 +782,8 @@ static int audio_mvs_stop(struct audio_mvs_info_type *audio) } /* Allow sleep. */ + pm_qos_update_request(&audio->pm_qos_req, PM_QOS_DEFAULT_VALUE); wake_unlock(&audio->suspend_lock); - wake_unlock(&audio->idle_lock); return rc; } @@ -1599,9 +1603,8 @@ static int audio_mvs_open(struct inode *inode, struct file *file) wake_lock_init(&audio_mvs_info.suspend_lock, WAKE_LOCK_SUSPEND, "audio_mvs_suspend"); - wake_lock_init(&audio_mvs_info.idle_lock, - WAKE_LOCK_IDLE, - "audio_mvs_idle"); + pm_qos_add_request(&audio_mvs_info.pm_qos_req, PM_QOS_CPU_DMA_LATENCY, + PM_QOS_DEFAULT_VALUE); audio_mvs_info.rpc_endpt = msm_rpc_connect_compatible(MVS_PROG, MVS_VERS_COMP_VER2, diff --git a/arch/arm/mach-msm/qdsp5/audio_out.c b/arch/arm/mach-msm/qdsp5/audio_out.c index 91ce29d2e12..8eaf829bf51 100644 --- a/arch/arm/mach-msm/qdsp5/audio_out.c +++ b/arch/arm/mach-msm/qdsp5/audio_out.c @@ -28,12 +28,14 @@ #include #include #include +#include #include #include #include #include +#include #include "audmgr.h" @@ -155,7 +157,7 @@ struct audio { int stopped; /* set when stopped, cleared on flush */ struct wake_lock wakelock; - struct wake_lock idlelock; + struct pm_qos_request pm_qos_req; audpp_cmd_cfg_object_params_volume vol_pan; }; @@ -204,13 +206,14 @@ static void audio_prevent_sleep(struct audio *audio) { MM_DBG("\n"); /* Macro prints the file name and function */ wake_lock(&audio->wakelock); - wake_lock(&audio->idlelock); + pm_qos_update_request(&audio->pm_qos_req, + msm_cpuidle_get_deep_idle_latency()); } static void audio_allow_sleep(struct audio *audio) { + pm_qos_update_request(&audio->pm_qos_req, PM_QOS_DEFAULT_VALUE); wake_unlock(&audio->wakelock); - wake_unlock(&audio->idlelock); MM_DBG("\n"); /* Macro prints the file name and function */ } @@ -1147,7 +1150,8 @@ static int __init audio_init(void) spin_lock_init(&the_audio.dsp_lock); init_waitqueue_head(&the_audio.wait); wake_lock_init(&the_audio.wakelock, WAKE_LOCK_SUSPEND, "audio_pcm"); - wake_lock_init(&the_audio.idlelock, WAKE_LOCK_IDLE, "audio_pcm_idle"); + pm_qos_add_request(&the_audio.pm_qos_req, PM_QOS_CPU_DMA_LATENCY, + PM_QOS_DEFAULT_VALUE); return (misc_register(&audio_misc) || misc_register(&audpp_misc)); } diff --git a/arch/arm/mach-msm/qdsp5v2/audio_mvs.c b/arch/arm/mach-msm/qdsp5v2/audio_mvs.c index fae24012057..99da8362a3a 100644 --- a/arch/arm/mach-msm/qdsp5v2/audio_mvs.c +++ b/arch/arm/mach-msm/qdsp5v2/audio_mvs.c @@ -20,7 +20,10 @@ #include #include #include +#include + #include +#include #define MVS_PROG 0x30000014 #define MVS_VERS 0x00030001 @@ -326,7 +329,7 @@ struct audio_mvs_info_type { struct mutex out_lock; struct wake_lock suspend_lock; - struct wake_lock idle_lock; + struct pm_qos_request pm_qos_req; }; static struct audio_mvs_info_type audio_mvs_info; @@ -699,7 +702,8 @@ static int audio_mvs_start(struct audio_mvs_info_type *audio) /* Prevent sleep. */ wake_lock(&audio->suspend_lock); - wake_lock(&audio->idle_lock); + pm_qos_update_request(&audio->pm_qos_req, + msm_cpuidle_get_deep_idle_latency()); /* Acquire MVS. */ memset(&acquire_msg, 0, sizeof(acquire_msg)); @@ -789,8 +793,8 @@ static int audio_mvs_stop(struct audio_mvs_info_type *audio) } /* Allow sleep. */ + pm_qos_update_request(&audio->pm_qos_req, PM_QOS_DEFAULT_VALUE); wake_unlock(&audio->suspend_lock); - wake_unlock(&audio->idle_lock); return rc; } @@ -1677,9 +1681,8 @@ static int __init audio_mvs_init(void) wake_lock_init(&audio_mvs_info.suspend_lock, WAKE_LOCK_SUSPEND, "audio_mvs_suspend"); - wake_lock_init(&audio_mvs_info.idle_lock, - WAKE_LOCK_IDLE, - "audio_mvs_idle"); + pm_qos_add_request(&audio_mvs_info.pm_qos_req, PM_QOS_CPU_DMA_LATENCY, + PM_QOS_DEFAULT_VALUE); audio_mvs_info.rpc_endpt = msm_rpc_connect_compatible(MVS_PROG, MVS_VERS_COMP_VER5, diff --git a/arch/arm/mach-msm/qdsp5v2/audio_out.c b/arch/arm/mach-msm/qdsp5v2/audio_out.c index 288a717ca03..147ac7761dc 100644 --- a/arch/arm/mach-msm/qdsp5v2/audio_out.c +++ b/arch/arm/mach-msm/qdsp5v2/audio_out.c @@ -29,9 +29,9 @@ #include #include #include - #include #include +#include #include #include @@ -42,7 +42,7 @@ #include #include #include - +#include #include #include @@ -95,7 +95,7 @@ struct audio { int voice_state; struct wake_lock wakelock; - struct wake_lock idlelock; + struct pm_qos_request pm_qos_req; struct audpp_cmd_cfg_object_params_volume vol_pan; }; @@ -148,13 +148,14 @@ static void audio_prevent_sleep(struct audio *audio) { MM_DBG("\n"); /* Macro prints the file name and function */ wake_lock(&audio->wakelock); - wake_lock(&audio->idlelock); + pm_qos_update_request(&audio->pm_qos_req, + msm_cpuidle_get_deep_idle_latency()); } static void audio_allow_sleep(struct audio *audio) { + pm_qos_update_request(&audio->pm_qos_req, PM_QOS_DEFAULT_VALUE); wake_unlock(&audio->wakelock); - wake_unlock(&audio->idlelock); MM_DBG("\n"); /* Macro prints the file name and function */ } @@ -721,7 +722,8 @@ static int __init audio_init(void) spin_lock_init(&the_audio.dsp_lock); init_waitqueue_head(&the_audio.wait); wake_lock_init(&the_audio.wakelock, WAKE_LOCK_SUSPEND, "audio_pcm"); - wake_lock_init(&the_audio.idlelock, WAKE_LOCK_IDLE, "audio_pcm_idle"); + pm_qos_add_request(&the_audio.pm_qos_req, PM_QOS_CPU_DMA_LATENCY, + PM_QOS_DEFAULT_VALUE); return misc_register(&audio_misc); } diff --git a/arch/arm/mach-msm/qdsp5v2/audpreproc.c b/arch/arm/mach-msm/qdsp5v2/audpreproc.c index 09611a552ce..c9abdab688e 100644 --- a/arch/arm/mach-msm/qdsp5v2/audpreproc.c +++ b/arch/arm/mach-msm/qdsp5v2/audpreproc.c @@ -20,15 +20,18 @@ #include #include #include +#include + #include #include #include #include #include +#include static DEFINE_MUTEX(audpreproc_lock); static struct wake_lock audpre_wake_lock; -static struct wake_lock audpre_idle_wake_lock; +static struct pm_qos_request audpre_pm_qos_req; struct msm_adspenc_info { const char *module_name; @@ -106,12 +109,13 @@ static struct audpreproc_state the_audpreproc_state = { static inline void prevent_suspend(void) { wake_lock(&audpre_wake_lock); - wake_lock(&audpre_idle_wake_lock); + pm_qos_update_request(&audpre_pm_qos_req, + msm_cpuidle_get_deep_idle_latency()); } static inline void allow_suspend(void) { + pm_qos_update_request(&audpre_pm_qos_req, PM_QOS_DEFAULT_VALUE); wake_unlock(&audpre_wake_lock); - wake_unlock(&audpre_idle_wake_lock); } /* DSP preproc event handler */ @@ -413,8 +417,8 @@ int audpreproc_aenc_alloc(unsigned enc_type, const char **module_name, if (!wakelock_init) { wake_lock_init(&audpre_wake_lock, WAKE_LOCK_SUSPEND, "audpre"); - wake_lock_init(&audpre_idle_wake_lock, WAKE_LOCK_IDLE, - "audpre_idle"); + pm_qos_add_request(&audpre_pm_qos_req, PM_QOS_CPU_DMA_LATENCY, + PM_QOS_DEFAULT_VALUE); wakelock_init = 1; } diff --git a/arch/arm/mach-msm/qdsp5v2/snddev_icodec.c b/arch/arm/mach-msm/qdsp5v2/snddev_icodec.c index dbeda82afa2..80c9a01d1b4 100644 --- a/arch/arm/mach-msm/qdsp5v2/snddev_icodec.c +++ b/arch/arm/mach-msm/qdsp5v2/snddev_icodec.c @@ -16,6 +16,8 @@ #include #include #include +#include + #include #include #include @@ -31,6 +33,7 @@ #include #include #include +#include #define SMPS_AUDIO_PLAYBACK_ID "AUPB" #define SMPS_AUDIO_RECORD_ID "AURC" @@ -159,8 +162,8 @@ struct snddev_icodec_drv_state { struct clk *lpa_p_clk; struct lpa_drv *lpa; - struct wake_lock rx_idlelock; - struct wake_lock tx_idlelock; + struct pm_qos_request rx_pm_qos_req; + struct pm_qos_request tx_pm_qos_req; }; static struct snddev_icodec_drv_state snddev_icodec_drv; @@ -173,7 +176,8 @@ static int snddev_icodec_open_rx(struct snddev_icodec_state *icodec) struct snddev_icodec_drv_state *drv = &snddev_icodec_drv; struct lpa_codec_config lpa_config; - wake_lock(&drv->rx_idlelock); + pm_qos_update_request(&drv->rx_pm_qos_req, + msm_cpuidle_get_deep_idle_latency()); if ((icodec->data->acdb_id == ACDB_ID_HEADSET_SPKR_MONO) || (icodec->data->acdb_id == ACDB_ID_HEADSET_SPKR_STEREO)) { @@ -250,7 +254,7 @@ static int snddev_icodec_open_rx(struct snddev_icodec_state *icodec) icodec->enabled = 1; - wake_unlock(&drv->rx_idlelock); + pm_qos_update_request(&drv->rx_pm_qos_req, PM_QOS_DEFAULT_VALUE); return 0; error_afe: @@ -268,7 +272,7 @@ error_invalid_freq: MM_ERR("encounter error\n"); - wake_unlock(&drv->rx_idlelock); + pm_qos_update_request(&drv->rx_pm_qos_req, PM_QOS_DEFAULT_VALUE); return -ENODEV; } @@ -279,7 +283,8 @@ static int snddev_icodec_open_tx(struct snddev_icodec_state *icodec) struct msm_afe_config afe_config; struct snddev_icodec_drv_state *drv = &snddev_icodec_drv;; - wake_lock(&drv->tx_idlelock); + pm_qos_update_request(&drv->tx_pm_qos_req, + msm_cpuidle_get_deep_idle_latency()); /* Vote for PWM mode*/ err = pmapp_smps_mode_vote(SMPS_AUDIO_RECORD_ID, @@ -332,7 +337,7 @@ static int snddev_icodec_open_tx(struct snddev_icodec_state *icodec) icodec->enabled = 1; - wake_unlock(&drv->tx_idlelock); + pm_qos_update_request(&drv->tx_pm_qos_req, PM_QOS_DEFAULT_VALUE); return 0; error_afe: @@ -354,7 +359,7 @@ error_invalid_freq: MM_ERR("encounter error\n"); - wake_unlock(&drv->tx_idlelock); + pm_qos_update_request(&drv->tx_pm_qos_req, PM_QOS_DEFAULT_VALUE); return -ENODEV; } @@ -381,7 +386,8 @@ static int snddev_icodec_close_rx(struct snddev_icodec_state *icodec) int err; struct snddev_icodec_drv_state *drv = &snddev_icodec_drv; - wake_lock(&drv->rx_idlelock); + pm_qos_update_request(&drv->rx_pm_qos_req, + msm_cpuidle_get_deep_idle_latency()); /* Remove the vote for SMPS mode*/ err = pmapp_smps_mode_vote(SMPS_AUDIO_PLAYBACK_ID, @@ -419,7 +425,7 @@ static int snddev_icodec_close_rx(struct snddev_icodec_state *icodec) icodec->enabled = 0; - wake_unlock(&drv->rx_idlelock); + pm_qos_update_request(&drv->rx_pm_qos_req, PM_QOS_DEFAULT_VALUE); return 0; } @@ -428,7 +434,8 @@ static int snddev_icodec_close_tx(struct snddev_icodec_state *icodec) struct snddev_icodec_drv_state *drv = &snddev_icodec_drv; int i, err; - wake_lock(&drv->tx_idlelock); + pm_qos_update_request(&drv->tx_pm_qos_req, + msm_cpuidle_get_deep_idle_latency()); /* Remove the vote for SMPS mode*/ err = pmapp_smps_mode_vote(SMPS_AUDIO_RECORD_ID, @@ -460,7 +467,7 @@ static int snddev_icodec_close_tx(struct snddev_icodec_state *icodec) icodec->enabled = 0; - wake_unlock(&drv->tx_idlelock); + pm_qos_update_request(&drv->tx_pm_qos_req, PM_QOS_DEFAULT_VALUE); return 0; } @@ -1156,10 +1163,10 @@ static int __init snddev_icodec_init(void) icodec_drv->rx_active = 0; icodec_drv->tx_active = 0; icodec_drv->lpa = NULL; - wake_lock_init(&icodec_drv->tx_idlelock, WAKE_LOCK_IDLE, - "snddev_tx_idle"); - wake_lock_init(&icodec_drv->rx_idlelock, WAKE_LOCK_IDLE, - "snddev_rx_idle"); + pm_qos_add_request(&icodec_drv->tx_pm_qos_req, PM_QOS_CPU_DMA_LATENCY, + PM_QOS_DEFAULT_VALUE); + pm_qos_add_request(&icodec_drv->rx_pm_qos_req, PM_QOS_CPU_DMA_LATENCY, + PM_QOS_DEFAULT_VALUE); return 0; error_lpa_p_clk: diff --git a/arch/arm/mach-msm/qdsp6/audiov2/q6audio.c b/arch/arm/mach-msm/qdsp6/audiov2/q6audio.c index f713e3dff01..af411f14365 100644 --- a/arch/arm/mach-msm/qdsp6/audiov2/q6audio.c +++ b/arch/arm/mach-msm/qdsp6/audiov2/q6audio.c @@ -21,12 +21,14 @@ #include #include #include - #include #include #include #include +#include + #include +#include #include "../dal.h" #include "dal_audio.h" @@ -69,7 +71,7 @@ static struct q6_hw_info q6_audio_hw[Q6_HW_COUNT] = { }, }; -static struct wake_lock idlelock; +static struct pm_qos_request pm_qos_req; static int idlecount; static DEFINE_MUTEX(idlecount_lock); @@ -77,7 +79,8 @@ void audio_prevent_sleep(void) { mutex_lock(&idlecount_lock); if (++idlecount == 1) - wake_lock(&idlelock); + pm_qos_update_request(&pm_qos_req, + msm_cpuidle_get_deep_idle_latency()); mutex_unlock(&idlecount_lock); } @@ -85,7 +88,7 @@ void audio_allow_sleep(void) { mutex_lock(&idlecount_lock); if (--idlecount == 0) - wake_unlock(&idlelock); + pm_qos_update_request(&pm_qos_req, PM_QOS_DEFAULT_VALUE); mutex_unlock(&idlecount_lock); } @@ -616,7 +619,8 @@ static int q6audio_init(void) res = 0; ac_control = ac; - wake_lock_init(&idlelock, WAKE_LOCK_IDLE, "audio_pcm_idle"); + pm_qos_add_request(&pm_qos_req, PM_QOS_CPU_DMA_LATENCY, + PM_QOS_DEFAULT_VALUE); done: if ((res < 0) && ac) audio_client_free(ac); diff --git a/arch/arm/mach-msm/qdsp6/msm_q6vdec.c b/arch/arm/mach-msm/qdsp6/msm_q6vdec.c index c79f0c41116..f28553665cf 100644 --- a/arch/arm/mach-msm/qdsp6/msm_q6vdec.c +++ b/arch/arm/mach-msm/qdsp6/msm_q6vdec.c @@ -30,10 +30,13 @@ #include #include #include +#include #include #include +#include + #include "dal.h" #define DALDEVICEID_VDEC_DEVICE 0x02000026 @@ -257,13 +260,14 @@ static DEFINE_MUTEX(vdec_rm_lock); static int idlecount; static struct wake_lock wakelock; -static struct wake_lock idlelock; +static struct pm_qos_request pm_qos_req; static void prevent_sleep(void) { mutex_lock(&idlecount_lock); if (++idlecount == 1) { - wake_lock(&idlelock); + pm_qos_update_request(&pm_qos_req, + msm_cpuidle_get_deep_idle_latency()); wake_lock(&wakelock); } mutex_unlock(&idlecount_lock); @@ -273,8 +277,8 @@ static void allow_sleep(void) { mutex_lock(&idlecount_lock); if (--idlecount == 0) { - wake_unlock(&idlelock); wake_unlock(&wakelock); + pm_qos_update_request(&pm_qos_req, PM_QOS_DEFAULT_VALUE); } mutex_unlock(&idlecount_lock); } @@ -1444,7 +1448,8 @@ static int __init vdec_init(void) struct device *class_dev; int rc = 0; - wake_lock_init(&idlelock, WAKE_LOCK_IDLE, "vdec_idle"); + pm_qos_add_request(&pm_qos_req, PM_QOS_CPU_DMA_LATENCY, + PM_QOS_DEFAULT_VALUE); wake_lock_init(&wakelock, WAKE_LOCK_SUSPEND, "vdec_suspend"); rc = alloc_chrdev_region(&vdec_device_no, 0, 1, "vdec"); diff --git a/arch/arm/mach-msm/qdsp6/msm_q6venc.c b/arch/arm/mach-msm/qdsp6/msm_q6venc.c index bd5d3f60b38..0917c7010b5 100644 --- a/arch/arm/mach-msm/qdsp6/msm_q6venc.c +++ b/arch/arm/mach-msm/qdsp6/msm_q6venc.c @@ -24,6 +24,10 @@ #include #include #include +#include + +#include + #include "dal.h" #define DALDEVICEID_VENC_DEVICE 0x0200002D @@ -142,13 +146,14 @@ static int venc_ref; static DEFINE_MUTEX(idlecount_lock); static int idlecount; static struct wake_lock wakelock; -static struct wake_lock idlelock; +static struct pm_qos_request pm_qos_req; static void prevent_sleep(void) { mutex_lock(&idlecount_lock); if (++idlecount == 1) { - wake_lock(&idlelock); + pm_qos_update_request(&pm_qos_req, + msm_cpuidle_get_deep_idle_latency()); wake_lock(&wakelock); } mutex_unlock(&idlecount_lock); @@ -158,8 +163,8 @@ static void allow_sleep(void) { mutex_lock(&idlecount_lock); if (--idlecount == 0) { - wake_unlock(&idlelock); wake_unlock(&wakelock); + pm_qos_update_request(&pm_qos_req, PM_QOS_DEFAULT_VALUE); } mutex_unlock(&idlecount_lock); } @@ -1130,7 +1135,8 @@ static int __init q6venc_init(void) { int ret = 0; - wake_lock_init(&idlelock, WAKE_LOCK_IDLE, "venc_idle"); + pm_qos_add_request(&pm_qos_req, PM_QOS_CPU_DMA_LATENCY, + PM_QOS_DEFAULT_VALUE); wake_lock_init(&wakelock, WAKE_LOCK_SUSPEND, "venc_suspend"); venc_device_p = kzalloc(sizeof(struct venc_dev), GFP_KERNEL); diff --git a/arch/arm/mach-msm/qdsp6/q6audio.c b/arch/arm/mach-msm/qdsp6/q6audio.c index bf6f115f91e..2d015fc28c1 100644 --- a/arch/arm/mach-msm/qdsp6/q6audio.c +++ b/arch/arm/mach-msm/qdsp6/q6audio.c @@ -20,12 +20,12 @@ #include #include #include - #include #include #include #include #include +#include #include "dal.h" #include "dal_audio.h" @@ -33,6 +33,7 @@ #include "dal_acdb.h" #include "dal_adie.h" #include +#include #include @@ -77,7 +78,7 @@ static struct q6_hw_info q6_audio_hw[Q6_HW_COUNT] = { }; static struct wake_lock wakelock; -static struct wake_lock idlelock; +static struct pm_qos_request pm_qos_req; static int idlecount; static DEFINE_MUTEX(idlecount_lock); @@ -86,7 +87,8 @@ void audio_prevent_sleep(void) mutex_lock(&idlecount_lock); if (++idlecount == 1) { wake_lock(&wakelock); - wake_lock(&idlelock); + pm_qos_update_request(&pm_qos_req, + msm_cpuidle_get_deep_idle_latency()); } mutex_unlock(&idlecount_lock); } @@ -95,7 +97,7 @@ void audio_allow_sleep(void) { mutex_lock(&idlecount_lock); if (--idlecount == 0) { - wake_unlock(&idlelock); + pm_qos_update_request(&pm_qos_req, PM_QOS_DEFAULT_VALUE); wake_unlock(&wakelock); } mutex_unlock(&idlecount_lock); @@ -959,7 +961,8 @@ static int q6audio_init(void) res = 0; ac_control = ac; - wake_lock_init(&idlelock, WAKE_LOCK_IDLE, "audio_pcm_idle"); + pm_qos_add_request(&pm_qos_req, PM_QOS_CPU_DMA_LATENCY, + PM_QOS_DEFAULT_VALUE); wake_lock_init(&wakelock, WAKE_LOCK_SUSPEND, "audio_pcm_suspend"); done: if ((res < 0) && ac) diff --git a/arch/arm/mach-msm/qdsp6v2/audio_mvs.c b/arch/arm/mach-msm/qdsp6v2/audio_mvs.c index 6e7961cae0e..d748304634d 100644 --- a/arch/arm/mach-msm/qdsp6v2/audio_mvs.c +++ b/arch/arm/mach-msm/qdsp6v2/audio_mvs.c @@ -22,7 +22,10 @@ #include #include #include +#include + #include +#include /* Each buffer is 20 ms, queue holds 200 ms of data. */ #define MVS_MAX_Q_LEN 10 @@ -65,7 +68,7 @@ struct audio_mvs_info_type { spinlock_t dsp_lock; struct wake_lock suspend_lock; - struct wake_lock idle_lock; + struct pm_qos_request pm_qos_req; void *memory_chunk; }; @@ -712,7 +715,8 @@ static int audio_mvs_start(struct audio_mvs_info_type *audio) /* Prevent sleep. */ wake_lock(&audio->suspend_lock); - wake_lock(&audio->idle_lock); + pm_qos_update_request(&audio->pm_qos_req, + msm_cpuidle_get_deep_idle_latency()); rc = voice_set_voc_path_full(1); @@ -747,8 +751,8 @@ static int audio_mvs_stop(struct audio_mvs_info_type *audio) audio->state = AUDIO_MVS_STOPPED; /* Allow sleep. */ + pm_qos_update_request(&audio->pm_qos_req, PM_QOS_DEFAULT_VALUE); wake_unlock(&audio->suspend_lock); - wake_unlock(&audio->idle_lock); return rc; } @@ -1145,9 +1149,8 @@ static int __init audio_mvs_init(void) wake_lock_init(&audio_mvs_info.suspend_lock, WAKE_LOCK_SUSPEND, "audio_mvs_suspend"); - wake_lock_init(&audio_mvs_info.idle_lock, - WAKE_LOCK_IDLE, - "audio_mvs_idle"); + pm_qos_add_request(&audio_mvs_info.pm_qos_req, PM_QOS_CPU_DMA_LATENCY, + PM_QOS_DEFAULT_VALUE); rc = misc_register(&audio_mvs_misc); diff --git a/arch/arm/mach-msm/qdsp6v2/pcm_in.c b/arch/arm/mach-msm/qdsp6v2/pcm_in.c index 667628cae50..620c1ee4b35 100644 --- a/arch/arm/mach-msm/qdsp6v2/pcm_in.c +++ b/arch/arm/mach-msm/qdsp6v2/pcm_in.c @@ -24,12 +24,15 @@ #include #include #include +#include + #include #include #include #include #include #include +#include #define MAX_BUF 4 #define BUFSZ (480 * 8) @@ -55,7 +58,7 @@ struct pcm { atomic_t in_opened; atomic_t in_stopped; struct wake_lock wakelock; - struct wake_lock idlelock; + struct pm_qos_request pm_qos_req; }; static void pcm_in_get_dsp_buffers(struct pcm*, @@ -84,14 +87,15 @@ static void pcm_in_prevent_sleep(struct pcm *audio) { pr_debug("%s:\n", __func__); wake_lock(&audio->wakelock); - wake_lock(&audio->idlelock); + pm_qos_update_request(&audio->pm_qos_req, + msm_cpuidle_get_deep_idle_latency()); } static void pcm_in_allow_sleep(struct pcm *audio) { pr_debug("%s:\n", __func__); + pm_qos_update_request(&audio->pm_qos_req, PM_QOS_DEFAULT_VALUE); wake_unlock(&audio->wakelock); - wake_unlock(&audio->idlelock); } static void pcm_in_get_dsp_buffers(struct pcm *pcm, @@ -353,7 +357,8 @@ static int pcm_in_open(struct inode *inode, struct file *file) snprintf(name, sizeof name, "pcm_in_%x", pcm->ac->session); wake_lock_init(&pcm->wakelock, WAKE_LOCK_SUSPEND, name); snprintf(name, sizeof name, "pcm_in_idle_%x", pcm->ac->session); - wake_lock_init(&pcm->idlelock, WAKE_LOCK_IDLE, name); + pm_qos_add_request(&pcm->pm_qos_req, PM_QOS_CPU_DMA_LATENCY, + PM_QOS_DEFAULT_VALUE); pcm->rec_mode = VOC_REC_NONE; @@ -462,7 +467,7 @@ static int pcm_in_release(struct inode *inode, struct file *file) q6asm_audio_client_free(pcm->ac); pcm_in_allow_sleep(pcm); wake_lock_destroy(&pcm->wakelock); - wake_lock_destroy(&pcm->idlelock); + pm_qos_remove_request(&pcm->pm_qos_req); kfree(pcm); return rc; } diff --git a/arch/arm/mach-msm/qdsp6v2/snddev_icodec.c b/arch/arm/mach-msm/qdsp6v2/snddev_icodec.c index 5d10779ca24..41ef88c5cd4 100644 --- a/arch/arm/mach-msm/qdsp6v2/snddev_icodec.c +++ b/arch/arm/mach-msm/qdsp6v2/snddev_icodec.c @@ -21,12 +21,16 @@ #include #include #include +#include + #include #include #include #include #include #include +#include + #include #include #include "snddev_icodec.h" @@ -66,8 +70,8 @@ struct snddev_icodec_drv_state { struct clk *tx_osrclk; struct clk *tx_bitclk; - struct wake_lock rx_idlelock; - struct wake_lock tx_idlelock; + struct pm_qos_request rx_pm_qos_req; + struct pm_qos_request tx_pm_qos_req; /* handle to pmic8058 regulator smps4 */ struct regulator *snddev_vreg; @@ -297,7 +301,8 @@ static int snddev_icodec_open_rx(struct snddev_icodec_state *icodec) union afe_port_config afe_config; struct snddev_icodec_drv_state *drv = &snddev_icodec_drv; - wake_lock(&drv->rx_idlelock); + pm_qos_update_request(&drv->rx_pm_qos_req, + msm_cpuidle_get_deep_idle_latency()); if (drv->snddev_vreg) { if (!strcmp(icodec->data->name, "headset_stereo_rx")) @@ -402,7 +407,7 @@ static int snddev_icodec_open_rx(struct snddev_icodec_state *icodec) icodec->enabled = 1; - wake_unlock(&drv->rx_idlelock); + pm_qos_update_request(&drv->rx_pm_qos_req, PM_QOS_DEFAULT_VALUE); return 0; error_pamp: @@ -412,7 +417,7 @@ error_invalid_freq: pr_err("%s: encounter error\n", __func__); - wake_unlock(&drv->rx_idlelock); + pm_qos_update_request(&drv->rx_pm_qos_req, PM_QOS_DEFAULT_VALUE); return -ENODEV; } @@ -423,7 +428,8 @@ static int snddev_icodec_open_tx(struct snddev_icodec_state *icodec) union afe_port_config afe_config; struct snddev_icodec_drv_state *drv = &snddev_icodec_drv;; - wake_lock(&drv->tx_idlelock); + pm_qos_update_request(&drv->tx_pm_qos_req, + msm_cpuidle_get_deep_idle_latency()); if (drv->snddev_vreg) vreg_mode_vote(drv->snddev_vreg, 1, SNDDEV_HIGH_POWER_MODE); @@ -509,7 +515,7 @@ static int snddev_icodec_open_tx(struct snddev_icodec_state *icodec) icodec->enabled = 1; - wake_unlock(&drv->tx_idlelock); + pm_qos_update_request(&drv->tx_pm_qos_req, PM_QOS_DEFAULT_VALUE); return 0; error_invalid_freq: @@ -519,7 +525,7 @@ error_invalid_freq: pr_err("%s: encounter error\n", __func__); error_pamp: - wake_unlock(&drv->tx_idlelock); + pm_qos_update_request(&drv->tx_pm_qos_req, PM_QOS_DEFAULT_VALUE); return -ENODEV; } @@ -551,7 +557,8 @@ static int snddev_icodec_close_rx(struct snddev_icodec_state *icodec) { struct snddev_icodec_drv_state *drv = &snddev_icodec_drv; - wake_lock(&drv->rx_idlelock); + pm_qos_update_request(&drv->rx_pm_qos_req, + msm_cpuidle_get_deep_idle_latency()); if (drv->snddev_vreg) vreg_mode_vote(drv->snddev_vreg, 0, SNDDEV_HIGH_POWER_MODE); @@ -580,7 +587,7 @@ static int snddev_icodec_close_rx(struct snddev_icodec_state *icodec) icodec->enabled = 0; - wake_unlock(&drv->rx_idlelock); + pm_qos_update_request(&drv->rx_pm_qos_req, PM_QOS_DEFAULT_VALUE); return 0; } @@ -588,7 +595,8 @@ static int snddev_icodec_close_tx(struct snddev_icodec_state *icodec) { struct snddev_icodec_drv_state *drv = &snddev_icodec_drv; - wake_lock(&drv->tx_idlelock); + pm_qos_update_request(&drv->tx_pm_qos_req, + msm_cpuidle_get_deep_idle_latency()); if (drv->snddev_vreg) vreg_mode_vote(drv->snddev_vreg, 0, SNDDEV_HIGH_POWER_MODE); @@ -614,7 +622,7 @@ static int snddev_icodec_close_tx(struct snddev_icodec_state *icodec) icodec->enabled = 0; - wake_unlock(&drv->tx_idlelock); + pm_qos_update_request(&drv->tx_pm_qos_req, PM_QOS_DEFAULT_VALUE); return 0; } @@ -1075,10 +1083,10 @@ static int __init snddev_icodec_init(void) icodec_drv->tx_active = 0; icodec_drv->snddev_vreg = vreg_init(); - wake_lock_init(&icodec_drv->tx_idlelock, WAKE_LOCK_IDLE, - "snddev_tx_idle"); - wake_lock_init(&icodec_drv->rx_idlelock, WAKE_LOCK_IDLE, - "snddev_rx_idle"); + pm_qos_add_request(&icodec_drv->tx_pm_qos_req, PM_QOS_CPU_DMA_LATENCY, + PM_QOS_DEFAULT_VALUE); + pm_qos_add_request(&icodec_drv->rx_pm_qos_req, PM_QOS_CPU_DMA_LATENCY, + PM_QOS_DEFAULT_VALUE); return 0; error_msm_icodec_gpio_driver: platform_driver_unregister(&msm_cdcclk_ctl_driver); diff --git a/drivers/media/video/msm/msm.h b/drivers/media/video/msm/msm.h index 688339b5e15..a91f0e110f0 100644 --- a/drivers/media/video/msm/msm.h +++ b/drivers/media/video/msm/msm.h @@ -258,7 +258,7 @@ struct msm_cam_media_controller { uint8_t opencnt; /*mctl ref count*/ const char *apps_id; /*ID for app that open this session*/ struct mutex lock; - struct wake_lock wake_lock; /*avoid low power mode when active*/ + struct pm_qos_request idle_pm_qos; /*avoid low power mode when active*/ struct pm_qos_request pm_qos_req_list; struct msm_mctl_pp_info pp_info; struct msm_mctl_stats_t stats_info; /*stats pmem info*/ diff --git a/drivers/media/video/msm/msm_camera.c b/drivers/media/video/msm/msm_camera.c index e609d6e3052..ec1e25333a4 100644 --- a/drivers/media/video/msm/msm_camera.c +++ b/drivers/media/video/msm/msm_camera.c @@ -35,6 +35,8 @@ #include #include #include + +#include DEFINE_MUTEX(ctrl_cmd_lock); #define CAMERA_STOP_VIDEO 58 @@ -3084,7 +3086,7 @@ static int __msm_release(struct msm_sync *sync) msm_queue_drain(&sync->pict_q, list_pict); msm_queue_drain(&sync->event_q, list_config); - wake_unlock(&sync->wake_lock); + pm_qos_update_request(&sync->idle_pm_qos, PM_QOS_DEFAULT_VALUE); sync->apps_id = NULL; sync->core_powered_on = 0; } @@ -3744,7 +3746,8 @@ static int __msm_open(struct msm_cam_device *pmsm, const char *const apps_id, sync->apps_id = apps_id; if (!sync->core_powered_on && !is_controlnode) { - wake_lock(&sync->wake_lock); + pm_qos_update_request(&sync->idle_pm_qos, + msm_cpuidle_get_deep_idle_latency()); msm_camvfe_fn_init(&sync->vfefn, sync); if (sync->vfefn.vfe_init) { @@ -3958,11 +3961,12 @@ static int msm_sync_init(struct msm_sync *sync, msm_queue_init(&sync->pict_q, "pict"); msm_queue_init(&sync->vpe_q, "vpe"); - wake_lock_init(&sync->wake_lock, WAKE_LOCK_IDLE, "msm_camera"); + pm_qos_add_request(&sync->idle_pm_qos, PM_QOS_CPU_DMA_LATENCY, + PM_QOS_DEFAULT_VALUE); rc = msm_camio_probe_on(pdev); if (rc < 0) { - wake_lock_destroy(&sync->wake_lock); + pm_qos_remove_request(&sync->idle_pm_qos); return rc; } rc = sensor_probe(sync->sdata, &sctrl); @@ -3975,7 +3979,7 @@ static int msm_sync_init(struct msm_sync *sync, pr_err("%s: failed to initialize %s\n", __func__, sync->sdata->sensor_name); - wake_lock_destroy(&sync->wake_lock); + pm_qos_remove_request(&sync->idle_pm_qos); return rc; } @@ -3994,7 +3998,7 @@ static int msm_sync_init(struct msm_sync *sync, static int msm_sync_destroy(struct msm_sync *sync) { - wake_lock_destroy(&sync->wake_lock); + pm_qos_remove_request(&sync->idle_pm_qos); return 0; } diff --git a/drivers/media/video/msm/msm_mctl.c b/drivers/media/video/msm/msm_mctl.c index cc3c59b5135..98442716f1e 100644 --- a/drivers/media/video/msm/msm_mctl.c +++ b/drivers/media/video/msm/msm_mctl.c @@ -27,6 +27,8 @@ #include +#include + #include "msm.h" #include "msm_csid.h" #include "msm_csic.h" @@ -567,7 +569,8 @@ static int msm_mctl_open(struct msm_cam_media_controller *p_mctl, /* open sub devices - once only*/ if (!p_mctl->opencnt) { uint32_t csid_version; - wake_lock(&p_mctl->wake_lock); + pm_qos_update_request(&p_mctl->idle_pm_qos, + msm_cpuidle_get_deep_idle_latency()); csid_core = camdev->csid_core; rc = msm_mctl_register_subdevs(p_mctl, csid_core); @@ -716,7 +719,7 @@ act_power_up_failed: pr_err("%s: sensor powerdown failed: %d\n", __func__, rc); sensor_sdev_failed: register_sdev_failed: - wake_unlock(&p_mctl->wake_lock); + pm_qos_update_request(&p_mctl->idle_pm_qos, PM_QOS_DEFAULT_VALUE); mutex_unlock(&p_mctl->lock); return rc; } @@ -777,7 +780,7 @@ static int msm_mctl_release(struct msm_cam_media_controller *p_mctl) v4l2_subdev_call(p_mctl->sensor_sdev, core, s_power, 0); - wake_unlock(&p_mctl->wake_lock); + pm_qos_update_request(&p_mctl->idle_pm_qos, PM_QOS_DEFAULT_VALUE); return rc; } @@ -861,7 +864,8 @@ int msm_mctl_init(struct msm_cam_v4l2_device *pcam) return -EINVAL; } - wake_lock_init(&pmctl->wake_lock, WAKE_LOCK_IDLE, "msm_camera"); + pm_qos_add_request(&pmctl->idle_pm_qos, PM_QOS_CPU_DMA_LATENCY, + PM_QOS_DEFAULT_VALUE); mutex_init(&pmctl->lock); pmctl->opencnt = 0; @@ -901,7 +905,7 @@ int msm_mctl_free(struct msm_cam_v4l2_device *pcam) } mutex_destroy(&pmctl->lock); - wake_lock_destroy(&pmctl->wake_lock); + pm_qos_remove_request(&pmctl->idle_pm_qos); msm_camera_free_mctl(pcam->mctl_handle); return rc; } diff --git a/drivers/mfd/wcd9xxx-core.c b/drivers/mfd/wcd9xxx-core.c index e2dff4b1e95..bbb2509f835 100644 --- a/drivers/mfd/wcd9xxx-core.c +++ b/drivers/mfd/wcd9xxx-core.c @@ -307,7 +307,8 @@ static int wcd9xxx_device_init(struct wcd9xxx *wcd9xxx, int irq) 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 @@ err_irq: 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 @@ static void wcd9xxx_device_exit(struct wcd9xxx *wcd9xxx) 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 @@ static int wcd9xxx_suspend(struct wcd9xxx *wcd9xxx, pm_message_t pmesg) 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 ba3c1e81f4a..68c4557e4c6 100644 --- a/drivers/mfd/wcd9xxx-irq.c +++ b/drivers/mfd/wcd9xxx-irq.c @@ -20,6 +20,8 @@ #include #include +#include + #define BYTE_BIT_MASK(nr) (1UL << ((nr) % BITS_PER_BYTE)) #define BIT_BYTE(nr) ((nr) / BITS_PER_BYTE) @@ -113,7 +115,8 @@ bool wcd9xxx_lock_sleep(struct wcd9xxx *wcd9xxx) 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 @@ void wcd9xxx_unlock_sleep(struct wcd9xxx *wcd9xxx) 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); diff --git a/drivers/video/msm/adv7520.c b/drivers/video/msm/adv7520.c index c0fb370253e..c2f1c0c4494 100644 --- a/drivers/video/msm/adv7520.c +++ b/drivers/video/msm/adv7520.c @@ -18,7 +18,12 @@ #include #include #include +#include + #include + +#include + #include "msm_fb.h" #define DEBUG @@ -64,7 +69,7 @@ static struct work_struct hpd_duty_work; static unsigned int monitor_sense; static boolean hpd_cable_chg_detected; -struct wake_lock wlock; +static struct pm_qos_request pm_qos_req; /* Change HDMI state */ static void change_hdmi_state(int online) @@ -366,7 +371,7 @@ static int adv7520_power_on(struct platform_device *pdev) } else DEV_INFO("power_on: cable NOT detected\n"); adv7520_comm_power(0, 1); - wake_lock(&wlock); + pm_qos_update_request(&pm_qos_req, msm_cpuidle_get_deep_idle_latency()); return 0; } @@ -376,7 +381,7 @@ static int adv7520_power_off(struct platform_device *pdev) DEV_INFO("power_off\n"); adv7520_comm_power(1, 1); adv7520_chip_off(); - wake_unlock(&wlock); + pm_qos_update_request(&pm_qos_req, PM_QOS_DEFAULT_VALUE); adv7520_comm_power(0, 1); clk_disable_unprepare(tv_enc_clk); return 0; @@ -899,7 +904,7 @@ static int __devexit adv7520_remove(struct i2c_client *client) return -ENODEV; } switch_dev_unregister(&external_common_state->sdev); - wake_lock_destroy(&wlock); + pm_qos_remove_request(&pm_qos_req); kfree(dd); dd = NULL; return 0; @@ -1006,7 +1011,8 @@ static int __init adv7520_init(void) *hdtv_mux = 0x8000; iounmap(hdtv_mux); } - wake_lock_init(&wlock, WAKE_LOCK_IDLE, "hdmi_active"); + pm_qos_add_request(&pm_qos_req, PM_QOS_CPU_DMA_LATENCY, + PM_QOS_DEFAULT_VALUE); return 0; diff --git a/include/linux/mfd/wcd9xxx/core.h b/include/linux/mfd/wcd9xxx/core.h index 7917d243251..612b1334ce9 100644 --- a/include/linux/mfd/wcd9xxx/core.h +++ b/include/linux/mfd/wcd9xxx/core.h @@ -14,7 +14,7 @@ #define __MFD_TABLA_CORE_H__ #include -#include +#include #define WCD9XXX_NUM_IRQ_REGS 3 @@ -124,7 +124,7 @@ struct wcd9xxx { struct mutex pm_lock; /* pm_wq notifies change of pm_state */ wait_queue_head_t pm_wq; - struct wake_lock wlock; + struct pm_qos_request pm_qos_req; int wlock_holders; int num_rx_port;