From e2f52ea5c0781578b7e23c5f19fb6dc32c4c82a6 Mon Sep 17 00:00:00 2001 From: Aditya Bavanari Date: Thu, 20 Feb 2020 12:46:51 +0530 Subject: [PATCH] asoc: codecs: Add system sleep ops for macro drivers Add system sleep ops and invoke force runtime suspend for all the macro drivers in bolero in order to synchronize system suspend and runtime suspend callbacks. Use freezable delayed work queues instead of normal delayed workqueues in order to avoid contention with pm suspend callflow. Change-Id: Ibb0d35ad80c09e7f2a7032b4daef53c359056dfd Signed-off-by: Aditya Bavanari --- asoc/codecs/bolero/bolero-cdc.c | 2 ++ asoc/codecs/bolero/rx-macro.c | 4 ++++ asoc/codecs/bolero/tx-macro.c | 11 ++++++++--- asoc/codecs/bolero/va-macro.c | 11 ++++++++--- asoc/codecs/bolero/wsa-macro.c | 4 ++++ 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/asoc/codecs/bolero/bolero-cdc.c b/asoc/codecs/bolero/bolero-cdc.c index 63d8d1013a86..7628de0cbc28 100644 --- a/asoc/codecs/bolero/bolero-cdc.c +++ b/asoc/codecs/bolero/bolero-cdc.c @@ -1199,6 +1199,7 @@ static int bolero_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM int bolero_runtime_resume(struct device *dev) { struct bolero_priv *priv = dev_get_drvdata(dev->parent); @@ -1272,6 +1273,7 @@ int bolero_runtime_suspend(struct device *dev) return 0; } EXPORT_SYMBOL(bolero_runtime_suspend); +#endif /* CONFIG_PM */ bool bolero_check_core_votes(struct device *dev) { diff --git a/asoc/codecs/bolero/rx-macro.c b/asoc/codecs/bolero/rx-macro.c index 0dec3d18e1b7..ccb560ac1c6a 100644 --- a/asoc/codecs/bolero/rx-macro.c +++ b/asoc/codecs/bolero/rx-macro.c @@ -4154,6 +4154,10 @@ static const struct of_device_id rx_macro_dt_match[] = { }; static const struct dev_pm_ops bolero_dev_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS( + pm_runtime_force_suspend, + pm_runtime_force_resume + ) SET_RUNTIME_PM_OPS( bolero_runtime_suspend, bolero_runtime_resume, diff --git a/asoc/codecs/bolero/tx-macro.c b/asoc/codecs/bolero/tx-macro.c index 8a9cf8c489e1..ffc43c8aa667 100644 --- a/asoc/codecs/bolero/tx-macro.c +++ b/asoc/codecs/bolero/tx-macro.c @@ -967,11 +967,12 @@ static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w, if (tx_unmute_delay < unmute_delay) tx_unmute_delay = unmute_delay; /* schedule work queue to Remove Mute */ - schedule_delayed_work(&tx_priv->tx_mute_dwork[decimator].dwork, - msecs_to_jiffies(tx_unmute_delay)); + queue_delayed_work(system_freezable_wq, + &tx_priv->tx_mute_dwork[decimator].dwork, + msecs_to_jiffies(tx_unmute_delay)); if (tx_priv->tx_hpf_work[decimator].hpf_cut_off_freq != CF_MIN_3DB_150HZ) { - schedule_delayed_work( + queue_delayed_work(system_freezable_wq, &tx_priv->tx_hpf_work[decimator].dwork, msecs_to_jiffies(hpf_delay)); snd_soc_component_update_bits(component, @@ -3279,6 +3280,10 @@ static const struct of_device_id tx_macro_dt_match[] = { }; static const struct dev_pm_ops bolero_dev_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS( + pm_runtime_force_suspend, + pm_runtime_force_resume + ) SET_RUNTIME_PM_OPS( bolero_runtime_suspend, bolero_runtime_resume, diff --git a/asoc/codecs/bolero/va-macro.c b/asoc/codecs/bolero/va-macro.c index 899e302c2288..eef6e1ef0f6e 100644 --- a/asoc/codecs/bolero/va-macro.c +++ b/asoc/codecs/bolero/va-macro.c @@ -1142,11 +1142,12 @@ static int va_macro_enable_dec(struct snd_soc_dapm_widget *w, */ usleep_range(6000, 6010); /* schedule work queue to Remove Mute */ - schedule_delayed_work(&va_priv->va_mute_dwork[decimator].dwork, - msecs_to_jiffies(va_tx_unmute_delay)); + queue_delayed_work(system_freezable_wq, + &va_priv->va_mute_dwork[decimator].dwork, + msecs_to_jiffies(va_tx_unmute_delay)); if (va_priv->va_hpf_work[decimator].hpf_cut_off_freq != CF_MIN_3DB_150HZ) - schedule_delayed_work( + queue_delayed_work(system_freezable_wq, &va_priv->va_hpf_work[decimator].dwork, msecs_to_jiffies(hpf_delay)); /* apply gain after decimator is enabled */ @@ -3039,6 +3040,10 @@ static const struct of_device_id va_macro_dt_match[] = { }; static const struct dev_pm_ops bolero_dev_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS( + pm_runtime_force_suspend, + pm_runtime_force_resume + ) SET_RUNTIME_PM_OPS( bolero_runtime_suspend, bolero_runtime_resume, diff --git a/asoc/codecs/bolero/wsa-macro.c b/asoc/codecs/bolero/wsa-macro.c index 03bea4e0e964..e7e5efc2587d 100644 --- a/asoc/codecs/bolero/wsa-macro.c +++ b/asoc/codecs/bolero/wsa-macro.c @@ -3239,6 +3239,10 @@ static const struct of_device_id wsa_macro_dt_match[] = { }; static const struct dev_pm_ops bolero_dev_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS( + pm_runtime_force_suspend, + pm_runtime_force_resume + ) SET_RUNTIME_PM_OPS( bolero_runtime_suspend, bolero_runtime_resume,