Commit 9042e17d authored by Marek Puzyniak's avatar Marek Puzyniak Committed by Kalle Valo

ath10k: refactor suspend/resume functions

Suspend/resume callbacks are not protected by configuration mutex
so adding such protection. Also in order to simplify implemetation
of suspend function wait queue is replaced by completion.
Signed-off-by: default avatarMarek Puzyniak <marek.puzyniak@tieto.com>
Signed-off-by: default avatarKalle Valo <kvalo@qca.qualcomm.com>
parent fc36e3ff
...@@ -55,8 +55,7 @@ static void ath10k_send_suspend_complete(struct ath10k *ar) ...@@ -55,8 +55,7 @@ static void ath10k_send_suspend_complete(struct ath10k *ar)
{ {
ath10k_dbg(ATH10K_DBG_BOOT, "boot suspend complete\n"); ath10k_dbg(ATH10K_DBG_BOOT, "boot suspend complete\n");
ar->is_target_paused = true; complete(&ar->target_suspend);
wake_up(&ar->event_queue);
} }
static int ath10k_init_connect_htc(struct ath10k *ar) static int ath10k_init_connect_htc(struct ath10k *ar)
...@@ -703,6 +702,7 @@ struct ath10k *ath10k_core_create(void *hif_priv, struct device *dev, ...@@ -703,6 +702,7 @@ struct ath10k *ath10k_core_create(void *hif_priv, struct device *dev,
init_completion(&ar->scan.started); init_completion(&ar->scan.started);
init_completion(&ar->scan.completed); init_completion(&ar->scan.completed);
init_completion(&ar->scan.on_channel); init_completion(&ar->scan.on_channel);
init_completion(&ar->target_suspend);
init_completion(&ar->install_key_done); init_completion(&ar->install_key_done);
init_completion(&ar->vdev_setup_done); init_completion(&ar->vdev_setup_done);
...@@ -726,8 +726,6 @@ struct ath10k *ath10k_core_create(void *hif_priv, struct device *dev, ...@@ -726,8 +726,6 @@ struct ath10k *ath10k_core_create(void *hif_priv, struct device *dev,
INIT_WORK(&ar->wmi_mgmt_tx_work, ath10k_mgmt_over_wmi_tx_work); INIT_WORK(&ar->wmi_mgmt_tx_work, ath10k_mgmt_over_wmi_tx_work);
skb_queue_head_init(&ar->wmi_mgmt_tx_queue); skb_queue_head_init(&ar->wmi_mgmt_tx_queue);
init_waitqueue_head(&ar->event_queue);
INIT_WORK(&ar->restart_work, ath10k_core_restart); INIT_WORK(&ar->restart_work, ath10k_core_restart);
return ar; return ar;
......
...@@ -375,8 +375,7 @@ struct ath10k { ...@@ -375,8 +375,7 @@ struct ath10k {
const struct ath10k_hif_ops *ops; const struct ath10k_hif_ops *ops;
} hif; } hif;
wait_queue_head_t event_queue; struct completion target_suspend;
bool is_target_paused;
struct ath10k_bmi bmi; struct ath10k_bmi bmi;
struct ath10k_wmi wmi; struct ath10k_wmi wmi;
......
...@@ -3440,21 +3440,20 @@ static int ath10k_suspend(struct ieee80211_hw *hw, ...@@ -3440,21 +3440,20 @@ static int ath10k_suspend(struct ieee80211_hw *hw,
struct ath10k *ar = hw->priv; struct ath10k *ar = hw->priv;
int ret; int ret;
ar->is_target_paused = false; mutex_lock(&ar->conf_mutex);
reinit_completion(&ar->target_suspend);
ret = ath10k_wmi_pdev_suspend_target(ar); ret = ath10k_wmi_pdev_suspend_target(ar);
if (ret) { if (ret) {
ath10k_warn("could not suspend target (%d)\n", ret); ath10k_warn("could not suspend target (%d)\n", ret);
return 1; ret = 1;
goto exit;
} }
ret = wait_event_interruptible_timeout(ar->event_queue, ret = wait_for_completion_timeout(&ar->target_suspend, 1 * HZ);
ar->is_target_paused == true,
1 * HZ); if (ret == 0) {
if (ret < 0) {
ath10k_warn("suspend interrupted (%d)\n", ret);
goto resume;
} else if (ret == 0) {
ath10k_warn("suspend timed out - target pause event never came\n"); ath10k_warn("suspend timed out - target pause event never came\n");
goto resume; goto resume;
} }
...@@ -3465,12 +3464,17 @@ static int ath10k_suspend(struct ieee80211_hw *hw, ...@@ -3465,12 +3464,17 @@ static int ath10k_suspend(struct ieee80211_hw *hw,
goto resume; goto resume;
} }
return 0; ret = 0;
goto exit;
resume: resume:
ret = ath10k_wmi_pdev_resume_target(ar); ret = ath10k_wmi_pdev_resume_target(ar);
if (ret) if (ret)
ath10k_warn("could not resume target (%d)\n", ret); ath10k_warn("could not resume target (%d)\n", ret);
return 1;
ret = 1;
exit:
mutex_unlock(&ar->conf_mutex);
return ret;
} }
static int ath10k_resume(struct ieee80211_hw *hw) static int ath10k_resume(struct ieee80211_hw *hw)
...@@ -3478,19 +3482,26 @@ static int ath10k_resume(struct ieee80211_hw *hw) ...@@ -3478,19 +3482,26 @@ static int ath10k_resume(struct ieee80211_hw *hw)
struct ath10k *ar = hw->priv; struct ath10k *ar = hw->priv;
int ret; int ret;
mutex_lock(&ar->conf_mutex);
ret = ath10k_hif_resume(ar); ret = ath10k_hif_resume(ar);
if (ret) { if (ret) {
ath10k_warn("could not resume hif (%d)\n", ret); ath10k_warn("could not resume hif (%d)\n", ret);
return 1; ret = 1;
goto exit;
} }
ret = ath10k_wmi_pdev_resume_target(ar); ret = ath10k_wmi_pdev_resume_target(ar);
if (ret) { if (ret) {
ath10k_warn("could not resume target (%d)\n", ret); ath10k_warn("could not resume target (%d)\n", ret);
return 1; ret = 1;
goto exit;
} }
return 0; ret = 0;
exit:
mutex_unlock(&ar->conf_mutex);
return ret;
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment