From 1de1fee9f7e6e30ccd9bd592ddb7abab824d5b60 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Wed, 5 Sep 2018 18:32:10 -0700 Subject: [PATCH 01/28] changed timeout to 2 seconds for sloweer systems I have changed the ATH10K_HTC_WAIT_TIMEOUT_MSEC to 2 seconds instead. --- .gitignore | 2 ++ otus/freebsd/src/sys/dev/athp/hal/htc.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..70ebbd10 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +otus/freebsd/src/sys/.vscode/c_cpp_properties.json diff --git a/otus/freebsd/src/sys/dev/athp/hal/htc.h b/otus/freebsd/src/sys/dev/athp/hal/htc.h index 10b202a0..6ed72db8 100644 --- a/otus/freebsd/src/sys/dev/athp/hal/htc.h +++ b/otus/freebsd/src/sys/dev/athp/hal/htc.h @@ -273,7 +273,7 @@ struct ath10k_htc_svc_conn_resp { #define ATH10K_NUM_CONTROL_TX_BUFFERS 2 #define ATH10K_HTC_MAX_LEN 4096 #define ATH10K_HTC_MAX_CTRL_MSG_LEN 256 -#define ATH10K_HTC_WAIT_TIMEOUT_MSEC (1000) +#define ATH10K_HTC_WAIT_TIMEOUT_MSEC (2000) #define ATH10K_HTC_CONTROL_BUFFER_SIZE (ATH10K_HTC_MAX_CTRL_MSG_LEN + \ sizeof(struct ath10k_htc_hdr)) #define ATH10K_HTC_CONN_SVC_TIMEOUT_MSEC (1000) From d7ac970bd93ceee4347c8bf83a8311d749a3b4ed Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Fri, 7 Sep 2018 11:01:34 -0700 Subject: [PATCH 02/28] took back the change. Instead i'll implement a system that unloads the firmware when the capabilities don't come in correctly and the firmware load crashes. kldload and unload should not have to deal with internal driver issues. --- otus/freebsd/src/sys/dev/athp/hal/htc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/otus/freebsd/src/sys/dev/athp/hal/htc.h b/otus/freebsd/src/sys/dev/athp/hal/htc.h index 6ed72db8..10b202a0 100644 --- a/otus/freebsd/src/sys/dev/athp/hal/htc.h +++ b/otus/freebsd/src/sys/dev/athp/hal/htc.h @@ -273,7 +273,7 @@ struct ath10k_htc_svc_conn_resp { #define ATH10K_NUM_CONTROL_TX_BUFFERS 2 #define ATH10K_HTC_MAX_LEN 4096 #define ATH10K_HTC_MAX_CTRL_MSG_LEN 256 -#define ATH10K_HTC_WAIT_TIMEOUT_MSEC (2000) +#define ATH10K_HTC_WAIT_TIMEOUT_MSEC (1000) #define ATH10K_HTC_CONTROL_BUFFER_SIZE (ATH10K_HTC_MAX_CTRL_MSG_LEN + \ sizeof(struct ath10k_htc_hdr)) #define ATH10K_HTC_CONN_SVC_TIMEOUT_MSEC (1000) From 1c8a86d5c1828ce04ca3e4cf097f0356c1cfc14b Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Fri, 7 Sep 2018 11:29:02 -0700 Subject: [PATCH 03/28] add code to force the driver to attempt to retry to load the interface up to 6 times. add code to force the driver to attempt to retry to load the interface up to 6 times. This should fix kldload issues, as long as the wifi card will work during boot we can automate bringing up the interface in scripts. Thats our first goal. --- otus/freebsd/src/sys/dev/athp/if_athp_main.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_main.c b/otus/freebsd/src/sys/dev/athp/if_athp_main.c index 8c85f23e..ac9e7990 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_main.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_main.c @@ -509,12 +509,18 @@ athp_transmit(struct ieee80211com *ic, struct mbuf *m0) return (0); } - +/* +* Handle the athp_parent call but attempt retries and starting the interface here +*/ +static void +net80211_athp_parent(struct ieee80211com *ic) { + athp_parent(ic, 0); +} /* * Handle initial notifications about starting the interface here. */ static void -athp_parent(struct ieee80211com *ic) +athp_parent(struct ieee80211com *ic, int attempts) { struct ath10k *ar = ic->ic_softc; @@ -540,6 +546,12 @@ athp_parent(struct ieee80211com *ic) ath10k_err(ar, "%s: ath10k_start failed; ret=%d\n", __func__, ret); + if (attempts < 6) { + ath10k_err(ar, + "%s: ath10k_start failed, trying again; ret=%d\n", + __func__, ret); + athp_parent(ic, attempts++); + } return; } @@ -2424,7 +2436,7 @@ athp_attach_net80211(struct ath10k *ar) ic->ic_set_channel = athp_set_channel; ic->ic_transmit = athp_transmit; ic->ic_send_mgmt = athp_send_mgmt; - ic->ic_parent = athp_parent; + ic->ic_parent = net80211_athp_parent; ic->ic_vap_create = athp_vap_create; ic->ic_vap_delete = athp_vap_delete; ic->ic_wme.wme_update = athp_wme_update; From 257202119ac916ad20b773b221d56ae050814cc2 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Fri, 7 Sep 2018 11:30:26 -0700 Subject: [PATCH 04/28] re-order --- otus/freebsd/src/sys/dev/athp/if_athp_main.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_main.c b/otus/freebsd/src/sys/dev/athp/if_athp_main.c index ac9e7990..4653513d 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_main.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_main.c @@ -509,13 +509,6 @@ athp_transmit(struct ieee80211com *ic, struct mbuf *m0) return (0); } -/* -* Handle the athp_parent call but attempt retries and starting the interface here -*/ -static void -net80211_athp_parent(struct ieee80211com *ic) { - athp_parent(ic, 0); -} /* * Handle initial notifications about starting the interface here. */ @@ -600,6 +593,14 @@ athp_parent(struct ieee80211com *ic, int attempts) } } +/* +* Handle the athp_parent call but attempt retries and starting the interface here +*/ +static void +net80211_athp_parent(struct ieee80211com *ic) { + athp_parent(ic, 0); +} + #if 0 /* * STA mode BSS update - deferred since node additions need deferring. From 164b16c748d6494bfc42b69049afdc3f7b07416d Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Fri, 7 Sep 2018 12:16:38 -0700 Subject: [PATCH 05/28] re-trying probe fw until sucessful or errors at the 6th try. --- otus/freebsd/src/sys/dev/athp/if_athp_core.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_core.c b/otus/freebsd/src/sys/dev/athp/if_athp_core.c index fb7724a5..99ccb76b 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_core.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_core.c @@ -1696,7 +1696,16 @@ ath10k_core_register_work(void *arg, int npending) struct ath10k *ar = arg; int status; - status = ath10k_core_probe_fw(ar); + + for(int i = 0; i < 6; i++) { + status = ath10k_core_probe_fw(ar); + if (status) { + ath10k_err(ar, "could not probe fw (%d)\n", status); + } + else + break; + } + if (status) { ath10k_err(ar, "could not probe fw (%d)\n", status); goto err; From 7cfa1b5cfa782b5c690fad560353767c62366316 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Fri, 7 Sep 2018 12:24:45 -0700 Subject: [PATCH 06/28] undo changes --- otus/freebsd/src/sys/dev/athp/if_athp_core.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_core.c b/otus/freebsd/src/sys/dev/athp/if_athp_core.c index 99ccb76b..fb7724a5 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_core.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_core.c @@ -1696,16 +1696,7 @@ ath10k_core_register_work(void *arg, int npending) struct ath10k *ar = arg; int status; - - for(int i = 0; i < 6; i++) { - status = ath10k_core_probe_fw(ar); - if (status) { - ath10k_err(ar, "could not probe fw (%d)\n", status); - } - else - break; - } - + status = ath10k_core_probe_fw(ar); if (status) { ath10k_err(ar, "could not probe fw (%d)\n", status); goto err; From d9c1fa09552a81b1e78c7085818c6ccff62eec69 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Fri, 7 Sep 2018 12:50:08 -0700 Subject: [PATCH 07/28] attempt at retrying to wait for htc to complete and return stopping hif and restarting hif if htc wait target doesnt finish succesfully. --- otus/freebsd/src/sys/dev/athp/if_athp_core.c | 27 ++++++++++++++++++- .../src/sys/dev/athp/if_athp_pci_hif.c | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_core.c b/otus/freebsd/src/sys/dev/athp/if_athp_core.c index fb7724a5..a892e70c 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_core.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_core.c @@ -1426,7 +1426,32 @@ ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode) goto err_htt_rx_detach; } - status = ath10k_htc_wait_target(&ar->htc); + + for(int i = 0; i < 6; i++) { + int ss_status = 0; + //Retry starting hif until successfully attach to HTC + //ath10k_hif_stop(ar); + status = ath10k_htc_wait_target(&ar->htc); + if (status) { + ss_status = ath10k_hif_stop(ar); + if (ss_status) { + status = ss_status; + ath10k_err(ar, "could not stop HIF: %d\n", status); + goto err; + } + ss_status = ath10k_hif_start(ar); + if (ss_status) { + status = ss_status; + ath10k_err(ar, "could not start HIF: %d\n", status); + goto err_htt_rx_detach; + } + continue; + } + else + { + break; + } + } if (status) { ath10k_err(ar, "failed to connect to HTC: %d\n", status); goto err_hif_stop; diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_pci_hif.c b/otus/freebsd/src/sys/dev/athp/if_athp_pci_hif.c index c0e15321..96eca582 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_pci_hif.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_pci_hif.c @@ -1202,6 +1202,7 @@ ath10k_pci_hif_power_up(struct ath10k *ar) ath10k_pci_ce_deinit(ar); err_sleep: + //ath10k_pci_sleep(ar_pci); return ret; } From fcadd32b1e6ff919461c9e39ab41cb389a3362e9 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Fri, 7 Sep 2018 12:51:05 -0700 Subject: [PATCH 08/28] removed return on hif_stop --- otus/freebsd/src/sys/dev/athp/if_athp_core.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_core.c b/otus/freebsd/src/sys/dev/athp/if_athp_core.c index a892e70c..263beffe 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_core.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_core.c @@ -1433,12 +1433,8 @@ ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode) //ath10k_hif_stop(ar); status = ath10k_htc_wait_target(&ar->htc); if (status) { - ss_status = ath10k_hif_stop(ar); - if (ss_status) { - status = ss_status; - ath10k_err(ar, "could not stop HIF: %d\n", status); - goto err; - } + //No return hif_stop since hif_stop can't fail, or shouldn't. + ath10k_hif_stop(ar); ss_status = ath10k_hif_start(ar); if (ss_status) { status = ss_status; From a9370794ef6bda58dd14f926c9a49d0a21c4c135 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Fri, 7 Sep 2018 13:02:36 -0700 Subject: [PATCH 09/28] attemping to recall ath10k_core_probe_fw trying to reset the atheros chip to to load up properly on error. --- otus/freebsd/src/sys/dev/athp/if_athp_core.c | 39 ++++++-------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_core.c b/otus/freebsd/src/sys/dev/athp/if_athp_core.c index 263beffe..17428b7e 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_core.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_core.c @@ -1426,28 +1426,7 @@ ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode) goto err_htt_rx_detach; } - - for(int i = 0; i < 6; i++) { - int ss_status = 0; - //Retry starting hif until successfully attach to HTC - //ath10k_hif_stop(ar); - status = ath10k_htc_wait_target(&ar->htc); - if (status) { - //No return hif_stop since hif_stop can't fail, or shouldn't. - ath10k_hif_stop(ar); - ss_status = ath10k_hif_start(ar); - if (ss_status) { - status = ss_status; - ath10k_err(ar, "could not start HIF: %d\n", status); - goto err_htt_rx_detach; - } - continue; - } - else - { - break; - } - } + status = ath10k_htc_wait_target(&ar->htc); if (status) { ath10k_err(ar, "failed to connect to HTC: %d\n", status); goto err_hif_stop; @@ -1716,13 +1695,19 @@ ath10k_core_register_work(void *arg, int npending) { struct ath10k *ar = arg; int status; - - status = ath10k_core_probe_fw(ar); - if (status) { - ath10k_err(ar, "could not probe fw (%d)\n", status); + for(int i = 0; i < 6; i++) { + status = ath10k_core_probe_fw(ar); + if (status) { + ath10k_err(ar, "could not probe fw (%d)\n", status); + } + else + goto probe_worked; + } + if(status) + { goto err; } - +probe_worked: status = ath10k_mac_register(ar); if (status) { ath10k_err(ar, "could not register to mac80211 (%d)\n", status); From 24c3912076865ad7a678287a6c475a7bdb88ba16 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Fri, 7 Sep 2018 13:03:20 -0700 Subject: [PATCH 10/28] add sleep statement sleep a little to let the device catch up and be ready. --- otus/freebsd/src/sys/dev/athp/if_athp_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_core.c b/otus/freebsd/src/sys/dev/athp/if_athp_core.c index 17428b7e..abfd3c6d 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_core.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_core.c @@ -1699,6 +1699,7 @@ ath10k_core_register_work(void *arg, int npending) status = ath10k_core_probe_fw(ar); if (status) { ath10k_err(ar, "could not probe fw (%d)\n", status); + Sleep(500); } else goto probe_worked; From 1a7bec9fafcecb5384b9267d79cbabbd720a86ce Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Fri, 7 Sep 2018 13:05:59 -0700 Subject: [PATCH 11/28] dumb auto programming features of VSCode capatilized Sleep --- otus/freebsd/src/sys/dev/athp/if_athp_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_core.c b/otus/freebsd/src/sys/dev/athp/if_athp_core.c index abfd3c6d..abb68607 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_core.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_core.c @@ -1699,7 +1699,7 @@ ath10k_core_register_work(void *arg, int npending) status = ath10k_core_probe_fw(ar); if (status) { ath10k_err(ar, "could not probe fw (%d)\n", status); - Sleep(500); + sleep(1); } else goto probe_worked; From 067685eb8239b94bed86f2ebd49d1297fdb5a4cc Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Fri, 7 Sep 2018 13:11:41 -0700 Subject: [PATCH 12/28] not use to freebsd kernel developing. I decided to use pause_sig in the case a signal called us to release before we end sleeping. --- otus/freebsd/src/sys/dev/athp/if_athp_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_core.c b/otus/freebsd/src/sys/dev/athp/if_athp_core.c index abb68607..7cf2f7b8 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_core.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_core.c @@ -1699,7 +1699,7 @@ ath10k_core_register_work(void *arg, int npending) status = ath10k_core_probe_fw(ar); if (status) { ath10k_err(ar, "could not probe fw (%d)\n", status); - sleep(1); + pause_sig("pausing to wait for the ath cpu to be ready.", 1000) } else goto probe_worked; From 8370fbebf566df2f4924470faba51e3d591bd0cf Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Fri, 7 Sep 2018 13:32:04 -0700 Subject: [PATCH 13/28] added in a ath10k_core_stop need to stop the core its not being called on error. I also have set bmi.done_sent = false. --- otus/freebsd/src/sys/dev/athp/if_athp_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_core.c b/otus/freebsd/src/sys/dev/athp/if_athp_core.c index 7cf2f7b8..8580877c 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_core.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_core.c @@ -1700,6 +1700,8 @@ ath10k_core_register_work(void *arg, int npending) if (status) { ath10k_err(ar, "could not probe fw (%d)\n", status); pause_sig("pausing to wait for the ath cpu to be ready.", 1000) + ar->bmi.done_sent = false; + ath10k_core_stop(ar); } else goto probe_worked; From e9c68670f23593315d8b3b97e4eac18f90d63592 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Fri, 7 Sep 2018 13:39:11 -0700 Subject: [PATCH 14/28] oops forgot semicolon --- otus/freebsd/src/sys/dev/athp/if_athp_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_core.c b/otus/freebsd/src/sys/dev/athp/if_athp_core.c index 8580877c..4b774ea7 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_core.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_core.c @@ -1699,7 +1699,7 @@ ath10k_core_register_work(void *arg, int npending) status = ath10k_core_probe_fw(ar); if (status) { ath10k_err(ar, "could not probe fw (%d)\n", status); - pause_sig("pausing to wait for the ath cpu to be ready.", 1000) + pause_sig("pausing to wait for the ath cpu to be ready.", 1000); ar->bmi.done_sent = false; ath10k_core_stop(ar); } From 1f18574a8bed4a659536c9151db7be1a639eb49c Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Fri, 7 Sep 2018 13:49:38 -0700 Subject: [PATCH 15/28] test removing ath10k_core_stop from retrying probe and just hack bmi.done_sent --- otus/freebsd/src/sys/dev/athp/if_athp_core.c | 1 - 1 file changed, 1 deletion(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_core.c b/otus/freebsd/src/sys/dev/athp/if_athp_core.c index 4b774ea7..22bb39c7 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_core.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_core.c @@ -1701,7 +1701,6 @@ ath10k_core_register_work(void *arg, int npending) ath10k_err(ar, "could not probe fw (%d)\n", status); pause_sig("pausing to wait for the ath cpu to be ready.", 1000); ar->bmi.done_sent = false; - ath10k_core_stop(ar); } else goto probe_worked; From 31d612becf62455246474e0239d8153c1b039e70 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Fri, 7 Sep 2018 14:51:52 -0700 Subject: [PATCH 16/28] cleaened up my hack for probe retrying turned the probe retry in to functional code and added a retry limit to core.h called ATH10K_FW_PROBE_RETRYS --- otus/freebsd/src/sys/dev/athp/if_athp_core.c | 40 +++++++++++++------- otus/freebsd/src/sys/dev/athp/if_athp_core.h | 1 + 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_core.c b/otus/freebsd/src/sys/dev/athp/if_athp_core.c index 22bb39c7..8c61b4ed 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_core.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_core.c @@ -1690,26 +1690,40 @@ ath10k_core_probe_fw(struct ath10k *ar) return ret; } +static void +clean_ath10k_core_probe_fw(ath10k * ar) { + //First step tell bmi done has not been sent so it will re-setup bmi. + ar->bmi.done_sent = false; +} + +static int +attempt_ath10k_core_probe_fw(ath10k *ar, int anum) { + //anum is the number of attempts that have been tried. + //This is to reload the firmware multiple times because sometimes it fails for no reason, + //it may be a freebsd only issue. + int status = ath10k_core_probe_fw(ar); + if (status) { + ath10k_err(ar, "could not probe fw, clean up allocations and memory and retry. (%d)\n", status); + pause_sig("pausing to wait for the ath cpu to be ready.", 1000); + if(anum < ATH10K_FW_PROBE_RETRYS) { + clean_ath10k_core_probe_fw(ar); + return attempt_ath10k_core_probe_fw(ar, anum++); + } + } + return status; +} + static void ath10k_core_register_work(void *arg, int npending) { struct ath10k *ar = arg; int status; - for(int i = 0; i < 6; i++) { - status = ath10k_core_probe_fw(ar); - if (status) { - ath10k_err(ar, "could not probe fw (%d)\n", status); - pause_sig("pausing to wait for the ath cpu to be ready.", 1000); - ar->bmi.done_sent = false; - } - else - goto probe_worked; - } - if(status) - { + + status = attempt_ath10k_core_probe_fw(ar, 0); + if (status) { + ath10k_err(ar, "could not probe fw (%d)\n", status); goto err; } -probe_worked: status = ath10k_mac_register(ar); if (status) { ath10k_err(ar, "could not register to mac80211 (%d)\n", status); diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_core.h b/otus/freebsd/src/sys/dev/athp/if_athp_core.h index 45d4db65..7f940a65 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_core.h +++ b/otus/freebsd/src/sys/dev/athp/if_athp_core.h @@ -29,6 +29,7 @@ #define ATH10K_FLUSH_TIMEOUT_HZ (5) #define ATH10K_CONNECTION_LOSS_HZ (3) #define ATH10K_NUM_CHANS 39 +#define ATH10K_FW_PROBE_RETRYS 6 /* Antenna noise floor */ #define ATH10K_DEFAULT_NOISE_FLOOR -95 From 0e6f09764a0ef1da866d25e50e27619982092b3d Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Fri, 7 Sep 2018 14:53:06 -0700 Subject: [PATCH 17/28] forgot struct def --- otus/freebsd/src/sys/dev/athp/if_athp_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_core.c b/otus/freebsd/src/sys/dev/athp/if_athp_core.c index 8c61b4ed..04ddb5f5 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_core.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_core.c @@ -1691,13 +1691,13 @@ ath10k_core_probe_fw(struct ath10k *ar) } static void -clean_ath10k_core_probe_fw(ath10k * ar) { +clean_ath10k_core_probe_fw(struct ath10k * ar) { //First step tell bmi done has not been sent so it will re-setup bmi. ar->bmi.done_sent = false; } static int -attempt_ath10k_core_probe_fw(ath10k *ar, int anum) { +attempt_ath10k_core_probe_fw(struct ath10k *ar, int anum) { //anum is the number of attempts that have been tried. //This is to reload the firmware multiple times because sometimes it fails for no reason, //it may be a freebsd only issue. From 30041e54d9cf9ba238c65f6cb047fcfd04eea608 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Fri, 7 Sep 2018 15:01:32 -0700 Subject: [PATCH 18/28] added function to cleanup memory leaks added a function to the process that allows us to cleanup any memory leaks if there are any. --- otus/freebsd/src/sys/dev/athp/if_athp_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_core.c b/otus/freebsd/src/sys/dev/athp/if_athp_core.c index 04ddb5f5..ca2bab20 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_core.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_core.c @@ -1692,6 +1692,7 @@ ath10k_core_probe_fw(struct ath10k *ar) static void clean_ath10k_core_probe_fw(struct ath10k * ar) { + //This function has been made to do cleanup to prevent memory leaks if any exist. //First step tell bmi done has not been sent so it will re-setup bmi. ar->bmi.done_sent = false; } From ed95bc64cef65bf4f08d427753d7f916156c997c Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Sat, 15 Sep 2018 07:29:12 -0700 Subject: [PATCH 19/28] removed pause_sig pause_sig isn't being used anywhere else and pause_sig is a delay based function which does not put the thread in the sleep queue so I switched it to tsleep instead. --- otus/freebsd/src/sys/dev/athp/if_athp_core.c | 24 ++++++++++++-------- otus/freebsd/src/sys/dev/athp/if_athp_core.h | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_core.c b/otus/freebsd/src/sys/dev/athp/if_athp_core.c index ca2bab20..0c8fda55 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_core.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_core.c @@ -1690,23 +1690,29 @@ ath10k_core_probe_fw(struct ath10k *ar) return ret; } +/* + This function has been made to do cleanup to prevent memory leaks if any exist. +First step tell bmi done has not been sent so it will re-setup bmi. +*/ static void -clean_ath10k_core_probe_fw(struct ath10k * ar) { - //This function has been made to do cleanup to prevent memory leaks if any exist. - //First step tell bmi done has not been sent so it will re-setup bmi. +clean_ath10k_core_probe_fw(struct ath10k * ar) +{ ar->bmi.done_sent = false; } +/* + anum is the number of attempts that have been tried. +This is to reload the firmware multiple times because sometimes it fails for no reason, +it may be a freebsd only issue. +*/ static int -attempt_ath10k_core_probe_fw(struct ath10k *ar, int anum) { - //anum is the number of attempts that have been tried. - //This is to reload the firmware multiple times because sometimes it fails for no reason, - //it may be a freebsd only issue. +attempt_ath10k_core_probe_fw(struct ath10k *ar, int anum) +{ int status = ath10k_core_probe_fw(ar); if (status) { ath10k_err(ar, "could not probe fw, clean up allocations and memory and retry. (%d)\n", status); - pause_sig("pausing to wait for the ath cpu to be ready.", 1000); - if(anum < ATH10K_FW_PROBE_RETRYS) { + tsleep(ar, 1, "pausing to wait for the ath cpu to be ready.", 250); + if(anum < ATH10K_FW_PROBE_RETRIES) { clean_ath10k_core_probe_fw(ar); return attempt_ath10k_core_probe_fw(ar, anum++); } diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_core.h b/otus/freebsd/src/sys/dev/athp/if_athp_core.h index 7f940a65..dedd2ae3 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_core.h +++ b/otus/freebsd/src/sys/dev/athp/if_athp_core.h @@ -29,7 +29,7 @@ #define ATH10K_FLUSH_TIMEOUT_HZ (5) #define ATH10K_CONNECTION_LOSS_HZ (3) #define ATH10K_NUM_CHANS 39 -#define ATH10K_FW_PROBE_RETRYS 6 +#define ATH10K_FW_PROBE_RETRIES 6 /* Antenna noise floor */ #define ATH10K_DEFAULT_NOISE_FLOOR -95 From f8035cece03277fd0548dacc8adc38f643b03e7d Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Sat, 29 Sep 2018 13:59:56 -0700 Subject: [PATCH 20/28] removed line of code from ath10k --- otus/freebsd/src/sys/dev/athp/if_athp_pci_hif.c | 1 - 1 file changed, 1 deletion(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_pci_hif.c b/otus/freebsd/src/sys/dev/athp/if_athp_pci_hif.c index 96eca582..c0e15321 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_pci_hif.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_pci_hif.c @@ -1202,7 +1202,6 @@ ath10k_pci_hif_power_up(struct ath10k *ar) ath10k_pci_ce_deinit(ar); err_sleep: - //ath10k_pci_sleep(ar_pci); return ret; } From c9c1c35a3a5f04282bf08e7db07e9348445a2078 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Sun, 4 Nov 2018 19:44:51 -0800 Subject: [PATCH 21/28] add null check. Grammer correction and add a null check for fwlog locking mutext variable as well as adding a longer timeout for htc connect. --- otus/freebsd/src/sys/dev/athp/hal/htc.h | 2 +- otus/freebsd/src/sys/dev/athp/if_athp_core.c | 2 +- otus/freebsd/src/sys/dev/athp/if_athp_fwlog.c | 22 ++++++++++--------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/otus/freebsd/src/sys/dev/athp/hal/htc.h b/otus/freebsd/src/sys/dev/athp/hal/htc.h index 10b202a0..99132cf2 100644 --- a/otus/freebsd/src/sys/dev/athp/hal/htc.h +++ b/otus/freebsd/src/sys/dev/athp/hal/htc.h @@ -273,7 +273,7 @@ struct ath10k_htc_svc_conn_resp { #define ATH10K_NUM_CONTROL_TX_BUFFERS 2 #define ATH10K_HTC_MAX_LEN 4096 #define ATH10K_HTC_MAX_CTRL_MSG_LEN 256 -#define ATH10K_HTC_WAIT_TIMEOUT_MSEC (1000) +#define ATH10K_HTC_WAIT_TIMEOUT_MSEC (3000) #define ATH10K_HTC_CONTROL_BUFFER_SIZE (ATH10K_HTC_MAX_CTRL_MSG_LEN + \ sizeof(struct ath10k_htc_hdr)) #define ATH10K_HTC_CONN_SVC_TIMEOUT_MSEC (1000) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_core.c b/otus/freebsd/src/sys/dev/athp/if_athp_core.c index 0c8fda55..706bcd31 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_core.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_core.c @@ -1710,7 +1710,7 @@ attempt_ath10k_core_probe_fw(struct ath10k *ar, int anum) { int status = ath10k_core_probe_fw(ar); if (status) { - ath10k_err(ar, "could not probe fw, clean up allocations and memory and retry. (%d)\n", status); + ath10k_err(ar, "could not probe fw, clean up allocations, memory and retry. (%d)\n", status); tsleep(ar, 1, "pausing to wait for the ath cpu to be ready.", 250); if(anum < ATH10K_FW_PROBE_RETRIES) { clean_ath10k_core_probe_fw(ar); diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_fwlog.c b/otus/freebsd/src/sys/dev/athp/if_athp_fwlog.c index d819984f..5538ea53 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_fwlog.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_fwlog.c @@ -1550,18 +1550,20 @@ ath10k_fwlog_print_work(void *arg, int npending) void ath10k_handle_fwlog_msg(struct ath10k *ar, struct athp_buf *skb) { - ATHP_FWLOG_LOCK(ar); + if(ar != null && ar->fwlog_mtx != null) { + ATHP_FWLOG_LOCK(ar); - if (ar->fwlog_tx_queue_len > ATH10K_FWLOG_MAX_EVT_QUEUE) { - ath10k_warn(ar, "reached fwlog queue limit\n"); - athp_freebuf(ar, &ar->buf_rx, skb); - return; - } + if (ar->fwlog_tx_queue_len > ATH10K_FWLOG_MAX_EVT_QUEUE) { + ath10k_warn(ar, "reached fwlog queue limit\n"); + athp_freebuf(ar, &ar->buf_rx, skb); + return; + } - TAILQ_INSERT_TAIL(&ar->fwlog_tx_queue, skb, next); - ar->fwlog_tx_queue_len++; - taskqueue_enqueue(ar->workqueue, &ar->fwlog_tx_work); - ATHP_FWLOG_UNLOCK(ar); + TAILQ_INSERT_TAIL(&ar->fwlog_tx_queue, skb, next); + ar->fwlog_tx_queue_len++; + taskqueue_enqueue(ar->workqueue, &ar->fwlog_tx_work); + ATHP_FWLOG_UNLOCK(ar); + } } void ath10k_fwlog_register(struct ath10k *ar) From 451782da4d1e6facdb963e3eaf66e21d7004b480 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Sun, 4 Nov 2018 19:59:05 -0800 Subject: [PATCH 22/28] used wrong case used wrong case for null, woops so use to the many other programming languages with lowercase null. --- otus/freebsd/src/sys/dev/athp/if_athp_fwlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_fwlog.c b/otus/freebsd/src/sys/dev/athp/if_athp_fwlog.c index 5538ea53..d7e801bb 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_fwlog.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_fwlog.c @@ -1550,7 +1550,7 @@ ath10k_fwlog_print_work(void *arg, int npending) void ath10k_handle_fwlog_msg(struct ath10k *ar, struct athp_buf *skb) { - if(ar != null && ar->fwlog_mtx != null) { + if(ar != NULL && ar->fwlog_mtx != NULL) { ATHP_FWLOG_LOCK(ar); if (ar->fwlog_tx_queue_len > ATH10K_FWLOG_MAX_EVT_QUEUE) { From a81df9cd9b59236f4db0c5854d1a8d8fdfc3cf79 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Sun, 4 Nov 2018 20:16:43 -0800 Subject: [PATCH 23/28] added some mutex checking added mutext checking inside of if_athp_fwlog for some reason its still trying to log on an unitialized mutex, which means somewhere something is still initialized for the first firmware failed load, need to check this out in detail, its weird. --- otus/freebsd/src/sys/dev/athp/if_athp_fwlog.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_fwlog.c b/otus/freebsd/src/sys/dev/athp/if_athp_fwlog.c index d7e801bb..06fd0af5 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_fwlog.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_fwlog.c @@ -1550,7 +1550,7 @@ ath10k_fwlog_print_work(void *arg, int npending) void ath10k_handle_fwlog_msg(struct ath10k *ar, struct athp_buf *skb) { - if(ar != NULL && ar->fwlog_mtx != NULL) { + if(ar != NULL && mtx_initialized(ar->fwlog_mtx) != 0) { ATHP_FWLOG_LOCK(ar); if (ar->fwlog_tx_queue_len > ATH10K_FWLOG_MAX_EVT_QUEUE) { @@ -1564,6 +1564,9 @@ ath10k_handle_fwlog_msg(struct ath10k *ar, struct athp_buf *skb) taskqueue_enqueue(ar->workqueue, &ar->fwlog_tx_work); ATHP_FWLOG_UNLOCK(ar); } + else { + //log that mutext is being locked upon and has never been initialized. + } } void ath10k_fwlog_register(struct ath10k *ar) From 4dcb7dbdcac7fc8797b7dd86ec03b599ad52419d Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Sun, 4 Nov 2018 20:17:13 -0800 Subject: [PATCH 24/28] forgot & --- otus/freebsd/src/sys/dev/athp/if_athp_fwlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_fwlog.c b/otus/freebsd/src/sys/dev/athp/if_athp_fwlog.c index 06fd0af5..8d5cf6ec 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_fwlog.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_fwlog.c @@ -1550,7 +1550,7 @@ ath10k_fwlog_print_work(void *arg, int npending) void ath10k_handle_fwlog_msg(struct ath10k *ar, struct athp_buf *skb) { - if(ar != NULL && mtx_initialized(ar->fwlog_mtx) != 0) { + if(ar != NULL && mtx_initialized(&ar->fwlog_mtx) != 0) { ATHP_FWLOG_LOCK(ar); if (ar->fwlog_tx_queue_len > ATH10K_FWLOG_MAX_EVT_QUEUE) { From d00dac981054b82a53ccae9b5609056266ac10fe Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Sun, 4 Nov 2018 20:31:27 -0800 Subject: [PATCH 25/28] chaned from 3 seconds to 1 didnt do anything. --- otus/freebsd/src/sys/dev/athp/hal/htc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/otus/freebsd/src/sys/dev/athp/hal/htc.h b/otus/freebsd/src/sys/dev/athp/hal/htc.h index 99132cf2..10b202a0 100644 --- a/otus/freebsd/src/sys/dev/athp/hal/htc.h +++ b/otus/freebsd/src/sys/dev/athp/hal/htc.h @@ -273,7 +273,7 @@ struct ath10k_htc_svc_conn_resp { #define ATH10K_NUM_CONTROL_TX_BUFFERS 2 #define ATH10K_HTC_MAX_LEN 4096 #define ATH10K_HTC_MAX_CTRL_MSG_LEN 256 -#define ATH10K_HTC_WAIT_TIMEOUT_MSEC (3000) +#define ATH10K_HTC_WAIT_TIMEOUT_MSEC (1000) #define ATH10K_HTC_CONTROL_BUFFER_SIZE (ATH10K_HTC_MAX_CTRL_MSG_LEN + \ sizeof(struct ath10k_htc_hdr)) #define ATH10K_HTC_CONN_SVC_TIMEOUT_MSEC (1000) From ad31d5de1230980d37ffff771ca8d1ec9086d0ad Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Sun, 4 Nov 2018 21:56:44 -0800 Subject: [PATCH 26/28] removing annoying warnings removing annoying warnings that come out of my serial device, so i cant see or type anything. --- otus/freebsd/src/sys/dev/athp/ath10k/htt_rx.c | 2 +- otus/freebsd/src/sys/dev/athp/if_athp_htt_rx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/otus/freebsd/src/sys/dev/athp/ath10k/htt_rx.c b/otus/freebsd/src/sys/dev/athp/ath10k/htt_rx.c index 1b7a0436..fc1d88e9 100644 --- a/otus/freebsd/src/sys/dev/athp/ath10k/htt_rx.c +++ b/otus/freebsd/src/sys/dev/athp/ath10k/htt_rx.c @@ -1473,7 +1473,7 @@ static bool ath10k_htt_rx_amsdu_allowed(struct ath10k *ar, */ if (!rx_status->freq) { - ath10k_warn(ar, "no channel configured; ignoring frame(s)!\n"); + //ath10k_warn(ar, "no channel configured; ignoring frame(s)!\n"); return false; } diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_htt_rx.c b/otus/freebsd/src/sys/dev/athp/if_athp_htt_rx.c index 44595428..8a20b1a2 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_htt_rx.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_htt_rx.c @@ -2034,7 +2034,7 @@ static bool ath10k_htt_rx_amsdu_allowed(struct ath10k *ar, */ if (!rx_status->c_ieee) { - ath10k_warn(ar, "no channel configured; ignoring frame(s)!\n"); + //ath10k_warn(ar, "no channel configured; ignoring frame(s)!\n"); return false; } From b535d1482bf2541c45f487c0e7e7a60d3e30755d Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Mon, 5 Nov 2018 17:13:11 -0800 Subject: [PATCH 27/28] Revert "removing annoying warnings" This reverts commit ad31d5de1230980d37ffff771ca8d1ec9086d0ad. --- otus/freebsd/src/sys/dev/athp/ath10k/htt_rx.c | 2 +- otus/freebsd/src/sys/dev/athp/if_athp_htt_rx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/otus/freebsd/src/sys/dev/athp/ath10k/htt_rx.c b/otus/freebsd/src/sys/dev/athp/ath10k/htt_rx.c index fc1d88e9..1b7a0436 100644 --- a/otus/freebsd/src/sys/dev/athp/ath10k/htt_rx.c +++ b/otus/freebsd/src/sys/dev/athp/ath10k/htt_rx.c @@ -1473,7 +1473,7 @@ static bool ath10k_htt_rx_amsdu_allowed(struct ath10k *ar, */ if (!rx_status->freq) { - //ath10k_warn(ar, "no channel configured; ignoring frame(s)!\n"); + ath10k_warn(ar, "no channel configured; ignoring frame(s)!\n"); return false; } diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_htt_rx.c b/otus/freebsd/src/sys/dev/athp/if_athp_htt_rx.c index 8a20b1a2..44595428 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_htt_rx.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_htt_rx.c @@ -2034,7 +2034,7 @@ static bool ath10k_htt_rx_amsdu_allowed(struct ath10k *ar, */ if (!rx_status->c_ieee) { - //ath10k_warn(ar, "no channel configured; ignoring frame(s)!\n"); + ath10k_warn(ar, "no channel configured; ignoring frame(s)!\n"); return false; } From 3fa625d28f842c2b75258453f2353a066a8aec12 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Mon, 5 Nov 2018 17:13:47 -0800 Subject: [PATCH 28/28] Revert "Revert "removing annoying warnings"" This reverts commit b535d1482bf2541c45f487c0e7e7a60d3e30755d. --- otus/freebsd/src/sys/dev/athp/ath10k/htt_rx.c | 2 +- otus/freebsd/src/sys/dev/athp/if_athp_htt_rx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/otus/freebsd/src/sys/dev/athp/ath10k/htt_rx.c b/otus/freebsd/src/sys/dev/athp/ath10k/htt_rx.c index 1b7a0436..fc1d88e9 100644 --- a/otus/freebsd/src/sys/dev/athp/ath10k/htt_rx.c +++ b/otus/freebsd/src/sys/dev/athp/ath10k/htt_rx.c @@ -1473,7 +1473,7 @@ static bool ath10k_htt_rx_amsdu_allowed(struct ath10k *ar, */ if (!rx_status->freq) { - ath10k_warn(ar, "no channel configured; ignoring frame(s)!\n"); + //ath10k_warn(ar, "no channel configured; ignoring frame(s)!\n"); return false; } diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_htt_rx.c b/otus/freebsd/src/sys/dev/athp/if_athp_htt_rx.c index 44595428..8a20b1a2 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_htt_rx.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_htt_rx.c @@ -2034,7 +2034,7 @@ static bool ath10k_htt_rx_amsdu_allowed(struct ath10k *ar, */ if (!rx_status->c_ieee) { - ath10k_warn(ar, "no channel configured; ignoring frame(s)!\n"); + //ath10k_warn(ar, "no channel configured; ignoring frame(s)!\n"); return false; }