Commit 67e3c63f authored by Michal Kazior's avatar Michal Kazior Committed by Kalle Valo

ath10k: fix core init failpath

HIF was not stopped properly in
ath10k_core_start() upon failure. This could cause
memory leaks of CE completions entries and
possibly other issues as well.

Move the HIF start/stop out of
ath10k_htc_wait_target(). The ctl_resp completion
is already prepared in ath10k_htc_init.
Signed-off-by: default avatarMichal Kazior <michal.kazior@tieto.com>
Signed-off-by: default avatarKalle Valo <kvalo@qca.qualcomm.com>
parent 6a42a47e
...@@ -785,14 +785,22 @@ int ath10k_core_start(struct ath10k *ar) ...@@ -785,14 +785,22 @@ int ath10k_core_start(struct ath10k *ar)
goto err; goto err;
} }
status = ath10k_htc_wait_target(&ar->htc); status = ath10k_hif_start(ar);
if (status) if (status) {
ath10k_err("could not start HIF: %d\n", status);
goto err_wmi_detach; goto err_wmi_detach;
}
status = ath10k_htc_wait_target(&ar->htc);
if (status) {
ath10k_err("failed to connect to HTC: %d\n", status);
goto err_hif_stop;
}
status = ath10k_htt_attach(ar); status = ath10k_htt_attach(ar);
if (status) { if (status) {
ath10k_err("could not attach htt (%d)\n", status); ath10k_err("could not attach htt (%d)\n", status);
goto err_wmi_detach; goto err_hif_stop;
} }
status = ath10k_init_connect_htc(ar); status = ath10k_init_connect_htc(ar);
...@@ -831,6 +839,8 @@ int ath10k_core_start(struct ath10k *ar) ...@@ -831,6 +839,8 @@ int ath10k_core_start(struct ath10k *ar)
ath10k_htc_stop(&ar->htc); ath10k_htc_stop(&ar->htc);
err_htt_detach: err_htt_detach:
ath10k_htt_detach(&ar->htt); ath10k_htt_detach(&ar->htt);
err_hif_stop:
ath10k_hif_stop(ar);
err_wmi_detach: err_wmi_detach:
ath10k_wmi_detach(ar); ath10k_wmi_detach(ar);
err: err:
......
...@@ -539,14 +539,6 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc) ...@@ -539,14 +539,6 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc)
u16 credit_count; u16 credit_count;
u16 credit_size; u16 credit_size;
INIT_COMPLETION(htc->ctl_resp);
status = ath10k_hif_start(htc->ar);
if (status) {
ath10k_err("could not start HIF (%d)\n", status);
goto err_start;
}
status = wait_for_completion_timeout(&htc->ctl_resp, status = wait_for_completion_timeout(&htc->ctl_resp,
ATH10K_HTC_WAIT_TIMEOUT_HZ); ATH10K_HTC_WAIT_TIMEOUT_HZ);
if (status <= 0) { if (status <= 0) {
...@@ -554,15 +546,13 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc) ...@@ -554,15 +546,13 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc)
status = -ETIMEDOUT; status = -ETIMEDOUT;
ath10k_err("ctl_resp never came in (%d)\n", status); ath10k_err("ctl_resp never came in (%d)\n", status);
goto err_target; return status;
} }
if (htc->control_resp_len < sizeof(msg->hdr) + sizeof(msg->ready)) { if (htc->control_resp_len < sizeof(msg->hdr) + sizeof(msg->ready)) {
ath10k_err("Invalid HTC ready msg len:%d\n", ath10k_err("Invalid HTC ready msg len:%d\n",
htc->control_resp_len); htc->control_resp_len);
return -ECOMM;
status = -ECOMM;
goto err_target;
} }
msg = (struct ath10k_htc_msg *)htc->control_resp_buffer; msg = (struct ath10k_htc_msg *)htc->control_resp_buffer;
...@@ -572,8 +562,7 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc) ...@@ -572,8 +562,7 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc)
if (message_id != ATH10K_HTC_MSG_READY_ID) { if (message_id != ATH10K_HTC_MSG_READY_ID) {
ath10k_err("Invalid HTC ready msg: 0x%x\n", message_id); ath10k_err("Invalid HTC ready msg: 0x%x\n", message_id);
status = -ECOMM; return -ECOMM;
goto err_target;
} }
htc->total_transmit_credits = credit_count; htc->total_transmit_credits = credit_count;
...@@ -586,9 +575,8 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc) ...@@ -586,9 +575,8 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc)
if ((htc->total_transmit_credits == 0) || if ((htc->total_transmit_credits == 0) ||
(htc->target_credit_size == 0)) { (htc->target_credit_size == 0)) {
status = -ECOMM;
ath10k_err("Invalid credit size received\n"); ath10k_err("Invalid credit size received\n");
goto err_target; return -ECOMM;
} }
ath10k_htc_setup_target_buffer_assignments(htc); ath10k_htc_setup_target_buffer_assignments(htc);
...@@ -605,14 +593,10 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc) ...@@ -605,14 +593,10 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc)
status = ath10k_htc_connect_service(htc, &conn_req, &conn_resp); status = ath10k_htc_connect_service(htc, &conn_req, &conn_resp);
if (status) { if (status) {
ath10k_err("could not connect to htc service (%d)\n", status); ath10k_err("could not connect to htc service (%d)\n", status);
goto err_target; return status;
} }
return 0; return 0;
err_target:
ath10k_hif_stop(htc->ar);
err_start:
return status;
} }
int ath10k_htc_connect_service(struct ath10k_htc *htc, int ath10k_htc_connect_service(struct ath10k_htc *htc,
......
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