From 1de1fee9f7e6e30ccd9bd592ddb7abab824d5b60 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Wed, 5 Sep 2018 18:32:10 -0700 Subject: [PATCH 01/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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/45] 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; } From f7bcb75d0aeb1c46b118e3e568fe236759aea948 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Mon, 5 Nov 2018 21:30:00 -0800 Subject: [PATCH 29/45] first commit Initialize commit on trying to move the hostap buffer allocation to the athp_parent instead of the add interface section. --- otus/freebsd/src/sys/dev/athp/if_athp_mac.c | 12 ++++-- otus/freebsd/src/sys/dev/athp/if_athp_main.c | 45 +++++++++++++++++--- otus/freebsd/src/sys/dev/athp/if_athp_var.h | 1 + 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_mac.c b/otus/freebsd/src/sys/dev/athp/if_athp_mac.c index a97be686..61c57a90 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_mac.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_mac.c @@ -5357,7 +5357,6 @@ ath10k_add_interface(struct ath10k *ar, struct ieee80211vap *vif, #if 0 vif->driver_flags |= IEEE80211_VIF_SUPPORTS_UAPSD; #endif - ATHP_CONF_LOCK(ar); arvif->ar = ar; @@ -5441,6 +5440,8 @@ ath10k_add_interface(struct ath10k *ar, struct ieee80211vap *vif, break; case IEEE80211_M_HOSTAP: arvif->vdev_type = WMI_VDEV_TYPE_AP; + /* Need to setup the dma buffer for hostap mode since we allocate it in the power on state 'athp_parent' */ + arvif->beacon_buf = ar->beacon_buf; break; default: ath10k_warn(ar, "%s: unsupported opmode (%d)\n", __func__, opmode); @@ -5476,6 +5477,10 @@ ath10k_add_interface(struct ath10k *ar, struct ieee80211vap *vif, * beacon tx commands. Worst case for this approach is some beacons may * become corrupted, e.g. have garbled IEs or out-of-date TIM bitmap. */ + /* + This is being moved to: + athp_parent + instead were it should be at otherwise we have to deal with locking that could possibly messup the entire add interface call. if (opmode == IEEE80211_M_IBSS || opmode == IEEE80211_M_HOSTAP) { ret = athp_descdma_alloc(ar, &arvif->beacon_buf, @@ -5485,7 +5490,7 @@ ath10k_add_interface(struct ath10k *ar, struct ieee80211vap *vif, "%s: TODO: beacon_buf failed to allocate\n", __func__); goto err; } - } + }*/ if (test_bit(ATH10K_FLAG_HW_CRYPTO_DISABLED, &ar->dev_flags)) arvif->nohwcrypt = true; @@ -5649,7 +5654,8 @@ ath10k_add_interface(struct ath10k *ar, struct ieee80211vap *vif, arvif->vdev_id = 0; err: - athp_descdma_free(ar, &arvif->beacon_buf); + /* This is no longer happening here check athp_parent */ + //athp_descdma_free(ar, &arvif->beacon_buf); ATHP_CONF_UNLOCK(ar); 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 4653513d..8260a25a 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_main.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_main.c @@ -509,6 +509,30 @@ athp_transmit(struct ieee80211com *ic, struct mbuf *m0) return (0); } +/* +* Handle the dma allocations for the power up of the wifi card +*/ +static int +athp_dma_allocate(struct ath10k * ar) +{ + ret = athp_descdma_alloc(ar, &ar->beacon_buf, + "beacon buf", 4, ATH10K_BEACON_BUF_LEN); + if (ret != 0) { + ath10k_warn(ar, + "%s: TODO: beacon_buf failed to allocate\n", __func__); + goto err; + } + return 1; +err: + athp_dma_deallocate(ar); + return 0; +} +/* +* Remove the allocation of the beacon buffer one time +*/ +static void athp_dma_deallocate(struct ath10k * ar) { + athp_descdma_free(ar, &ar->beacon_buf); +} /* * Handle initial notifications about starting the interface here. */ @@ -535,21 +559,28 @@ athp_parent(struct ieee80211com *ic, int attempts) /* Power up */ ret = ath10k_start(ar); - if (ret != 0) { - ath10k_err(ar, - "%s: ath10k_start failed; ret=%d\n", - __func__, ret); + while(ret != 0) { + ret = ath10k_start(ar); + if (ret != 0) { + 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; + else { + break; + } + attempts++; + } } ath10k_warn(ar, "%s: not yet running; start\n", __func__); ieee80211_start_all(ic); + + ret = athp_dma_allocate(ar); ar->sc_isrunning = 1; } } @@ -586,7 +617,7 @@ athp_parent(struct ieee80211com *ic, int attempts) uvp->is_setup = 0; ATHP_CONF_UNLOCK(ar); } - + athp_dma_deallocate(ar); /* Everything is shutdown; power off the chip */ ath10k_warn(ar, "%s: powering down\n", __func__); ath10k_stop(ar); diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_var.h b/otus/freebsd/src/sys/dev/athp/if_athp_var.h index dda41a74..1cb891c1 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_var.h +++ b/otus/freebsd/src/sys/dev/athp/if_athp_var.h @@ -399,6 +399,7 @@ struct ath10k { unsigned long long free_vdev_map; struct ath10k_vif *monitor_arvif; + struct ath10k_vif *beacon_buf; bool monitor; int monitor_vdev_id; bool monitor_started; From 8d33baa27f7119e17b9795b9e7451b36b6c294f4 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Mon, 5 Nov 2018 21:34:21 -0800 Subject: [PATCH 30/45] fixed type error wrong type was used. --- otus/freebsd/src/sys/dev/athp/if_athp_var.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_var.h b/otus/freebsd/src/sys/dev/athp/if_athp_var.h index 1cb891c1..becb4e37 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_var.h +++ b/otus/freebsd/src/sys/dev/athp/if_athp_var.h @@ -399,7 +399,7 @@ struct ath10k { unsigned long long free_vdev_map; struct ath10k_vif *monitor_arvif; - struct ath10k_vif *beacon_buf; + struct athp_descdma *beacon_buf; bool monitor; int monitor_vdev_id; bool monitor_started; From 48ed5601b87aaea45afb51406dab1dcd36fca59c Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Mon, 5 Nov 2018 21:55:36 -0800 Subject: [PATCH 31/45] remove extra pointers remove extra pointers. --- otus/freebsd/src/sys/dev/athp/if_athp_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 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 8260a25a..23deb73b 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_main.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_main.c @@ -515,7 +515,7 @@ athp_transmit(struct ieee80211com *ic, struct mbuf *m0) static int athp_dma_allocate(struct ath10k * ar) { - ret = athp_descdma_alloc(ar, &ar->beacon_buf, + ret = athp_descdma_alloc(ar, ar->beacon_buf, "beacon buf", 4, ATH10K_BEACON_BUF_LEN); if (ret != 0) { ath10k_warn(ar, @@ -531,7 +531,7 @@ athp_dma_allocate(struct ath10k * ar) * Remove the allocation of the beacon buffer one time */ static void athp_dma_deallocate(struct ath10k * ar) { - athp_descdma_free(ar, &ar->beacon_buf); + athp_descdma_free(ar, ar->beacon_buf); } /* * Handle initial notifications about starting the interface here. From 6846ea946775257511c5b15743cc550397904ee3 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Mon, 5 Nov 2018 21:57:51 -0800 Subject: [PATCH 32/45] out of order moved functions in the right order. --- otus/freebsd/src/sys/dev/athp/if_athp_main.c | 14 +++++++------- 1 file changed, 7 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 23deb73b..80e0965e 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_main.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_main.c @@ -510,9 +510,15 @@ athp_transmit(struct ieee80211com *ic, struct mbuf *m0) return (0); } /* +* Remove the allocation of the beacon buffer one time +*/ +void athp_dma_deallocate(struct ath10k * ar) { + athp_descdma_free(ar, ar->beacon_buf); +} +/* * Handle the dma allocations for the power up of the wifi card */ -static int +int athp_dma_allocate(struct ath10k * ar) { ret = athp_descdma_alloc(ar, ar->beacon_buf, @@ -527,12 +533,6 @@ athp_dma_allocate(struct ath10k * ar) athp_dma_deallocate(ar); return 0; } -/* -* Remove the allocation of the beacon buffer one time -*/ -static void athp_dma_deallocate(struct ath10k * ar) { - athp_descdma_free(ar, ar->beacon_buf); -} /* * Handle initial notifications about starting the interface here. */ From a0ad92b15dfdacd41ecc7746f61e03b367f1df1e Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Mon, 5 Nov 2018 21:58:58 -0800 Subject: [PATCH 33/45] forgot initializer --- otus/freebsd/src/sys/dev/athp/if_athp_main.c | 1 + 1 file changed, 1 insertion(+) 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 80e0965e..a83bfcf2 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_main.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_main.c @@ -521,6 +521,7 @@ void athp_dma_deallocate(struct ath10k * ar) { int athp_dma_allocate(struct ath10k * ar) { + int ret; ret = athp_descdma_alloc(ar, ar->beacon_buf, "beacon buf", 4, ATH10K_BEACON_BUF_LEN); if (ret != 0) { From f50fa014b1c45a60ea21be4b1ebd58b27c667583 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Mon, 5 Nov 2018 22:04:02 -0800 Subject: [PATCH 34/45] formatting --- otus/freebsd/src/sys/dev/athp/if_athp_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 a83bfcf2..89d6124e 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_main.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_main.c @@ -512,7 +512,8 @@ athp_transmit(struct ieee80211com *ic, struct mbuf *m0) /* * Remove the allocation of the beacon buffer one time */ -void athp_dma_deallocate(struct ath10k * ar) { +void +athp_dma_deallocate(struct ath10k * ar) { athp_descdma_free(ar, ar->beacon_buf); } /* From ae10d8c5d902152a4454b132eb52473652b23834 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Mon, 5 Nov 2018 22:08:17 -0800 Subject: [PATCH 35/45] removed call to deallocate inside of allocate and the label. removed call to deallocate inside of allocate and the label. --- otus/freebsd/src/sys/dev/athp/if_athp_main.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 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 89d6124e..a57b02f4 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_main.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_main.c @@ -512,28 +512,24 @@ athp_transmit(struct ieee80211com *ic, struct mbuf *m0) /* * Remove the allocation of the beacon buffer one time */ -void -athp_dma_deallocate(struct ath10k * ar) { +void athp_dma_deallocate(struct ath10k * ar) { athp_descdma_free(ar, ar->beacon_buf); } /* * Handle the dma allocations for the power up of the wifi card */ -int -athp_dma_allocate(struct ath10k * ar) +int athp_dma_allocate(struct ath10k * ar) { - int ret; - ret = athp_descdma_alloc(ar, ar->beacon_buf, + int ret = athp_descdma_alloc(ar, ar->beacon_buf, "beacon buf", 4, ATH10K_BEACON_BUF_LEN); if (ret != 0) { ath10k_warn(ar, "%s: TODO: beacon_buf failed to allocate\n", __func__); - goto err; + + athp_descdma_free(ar, ar->beacon_buf); + return 0; } return 1; -err: - athp_dma_deallocate(ar); - return 0; } /* * Handle initial notifications about starting the interface here. From ece8bb03af9a4623d946027558452ed73e28dfbd Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Tue, 6 Nov 2018 11:40:23 -0800 Subject: [PATCH 36/45] added static for compile via git on phone --- otus/freebsd/src/sys/dev/athp/if_athp_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 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 a57b02f4..d2cb4358 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_main.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_main.c @@ -512,13 +512,14 @@ athp_transmit(struct ieee80211com *ic, struct mbuf *m0) /* * Remove the allocation of the beacon buffer one time */ -void athp_dma_deallocate(struct ath10k * ar) { +static void +athp_dma_deallocate(struct ath10k * ar) { athp_descdma_free(ar, ar->beacon_buf); } /* * Handle the dma allocations for the power up of the wifi card */ -int athp_dma_allocate(struct ath10k * ar) +static int athp_dma_allocate(struct ath10k * ar) { int ret = athp_descdma_alloc(ar, ar->beacon_buf, "beacon buf", 4, ATH10K_BEACON_BUF_LEN); From 4a54b9fa146ec84e5900999d020142a5bcffe4d0 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Tue, 6 Nov 2018 11:47:57 -0800 Subject: [PATCH 37/45] added dereference via git on phone --- otus/freebsd/src/sys/dev/athp/if_athp_mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_mac.c b/otus/freebsd/src/sys/dev/athp/if_athp_mac.c index 61c57a90..cc3ce49d 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_mac.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_mac.c @@ -5441,7 +5441,7 @@ ath10k_add_interface(struct ath10k *ar, struct ieee80211vap *vif, case IEEE80211_M_HOSTAP: arvif->vdev_type = WMI_VDEV_TYPE_AP; /* Need to setup the dma buffer for hostap mode since we allocate it in the power on state 'athp_parent' */ - arvif->beacon_buf = ar->beacon_buf; + arvif->beacon_buf = *ar->beacon_buf; break; default: ath10k_warn(ar, "%s: unsupported opmode (%d)\n", __func__, opmode); From 09ffcbf99a90106f7740d2f3af26e68ec5943460 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Tue, 6 Nov 2018 21:04:04 -0800 Subject: [PATCH 38/45] moved dma allocate to attach. --- otus/freebsd/src/sys/dev/athp/if_athp_main.c | 54 ++++++++++---------- 1 file changed, 26 insertions(+), 28 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 d2cb4358..bf3aec7d 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_main.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_main.c @@ -509,29 +509,6 @@ athp_transmit(struct ieee80211com *ic, struct mbuf *m0) return (0); } -/* -* Remove the allocation of the beacon buffer one time -*/ -static void -athp_dma_deallocate(struct ath10k * ar) { - athp_descdma_free(ar, ar->beacon_buf); -} -/* -* Handle the dma allocations for the power up of the wifi card -*/ -static int athp_dma_allocate(struct ath10k * ar) -{ - int ret = athp_descdma_alloc(ar, ar->beacon_buf, - "beacon buf", 4, ATH10K_BEACON_BUF_LEN); - if (ret != 0) { - ath10k_warn(ar, - "%s: TODO: beacon_buf failed to allocate\n", __func__); - - athp_descdma_free(ar, ar->beacon_buf); - return 0; - } - return 1; -} /* * Handle initial notifications about starting the interface here. */ @@ -578,8 +555,6 @@ athp_parent(struct ieee80211com *ic, int attempts) ath10k_warn(ar, "%s: not yet running; start\n", __func__); ieee80211_start_all(ic); - - ret = athp_dma_allocate(ar); ar->sc_isrunning = 1; } } @@ -616,7 +591,6 @@ athp_parent(struct ieee80211com *ic, int attempts) uvp->is_setup = 0; ATHP_CONF_UNLOCK(ar); } - athp_dma_deallocate(ar); /* Everything is shutdown; power off the chip */ ath10k_warn(ar, "%s: powering down\n", __func__); ath10k_stop(ar); @@ -2396,7 +2370,29 @@ athp_attach_11ac(struct ath10k *ar) __func__, m, ar->vht_cap_info); #endif } - +/* +* Remove the allocation of the beacon buffer one time +*/ +static void +athp_dma_deallocate(struct ath10k * ar) { + athp_descdma_free(ar, ar->beacon_buf); +} +/* +* Handle the dma allocations for the power up of the wifi card +*/ +static int athp_dma_allocate(struct ath10k * ar) +{ + int ret = athp_descdma_alloc(ar, ar->beacon_buf, + "beacon buf", 4, ATH10K_BEACON_BUF_LEN); + if (ret != 0) { + ath10k_warn(ar, + "%s: TODO: beacon_buf failed to allocate\n", __func__); + + athp_descdma_free(ar, ar->beacon_buf); + return 0; + } + return 1; +} /* * Attach time setup. * @@ -2492,6 +2488,8 @@ athp_attach_net80211(struct ath10k *ar) athp_attach_11ac(ar); } + athp_dma_allocate(ar); + /* radiotap attach */ ieee80211_radiotap_attach(ic, &ar->sc_txtapu.th.wt_ihdr, sizeof(ar->sc_txtapu), @@ -2520,7 +2518,7 @@ athp_detach_net80211(struct ath10k *ar) /* stop/drain taskq entries */ athp_taskq_flush(ar, 0); athp_taskq_free(ar); - + athp_dma_deallocate(ar); if (ic->ic_softc == ar) ieee80211_ifdetach(ic); From 4969c40b3b9f2d150cc6486a9669af45a40b5711 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Tue, 6 Nov 2018 21:26:44 -0800 Subject: [PATCH 39/45] moved dma allocate in to if_athp_pci attach --- otus/freebsd/src/sys/dev/athp/if_athp_main.c | 27 ++---------------- otus/freebsd/src/sys/dev/athp/if_athp_pci.c | 30 ++++++++++++++++++-- 2 files changed, 30 insertions(+), 27 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 bf3aec7d..d12cf0d9 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_main.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_main.c @@ -2370,29 +2370,6 @@ athp_attach_11ac(struct ath10k *ar) __func__, m, ar->vht_cap_info); #endif } -/* -* Remove the allocation of the beacon buffer one time -*/ -static void -athp_dma_deallocate(struct ath10k * ar) { - athp_descdma_free(ar, ar->beacon_buf); -} -/* -* Handle the dma allocations for the power up of the wifi card -*/ -static int athp_dma_allocate(struct ath10k * ar) -{ - int ret = athp_descdma_alloc(ar, ar->beacon_buf, - "beacon buf", 4, ATH10K_BEACON_BUF_LEN); - if (ret != 0) { - ath10k_warn(ar, - "%s: TODO: beacon_buf failed to allocate\n", __func__); - - athp_descdma_free(ar, ar->beacon_buf); - return 0; - } - return 1; -} /* * Attach time setup. * @@ -2488,7 +2465,7 @@ athp_attach_net80211(struct ath10k *ar) athp_attach_11ac(ar); } - athp_dma_allocate(ar); + //athp_dma_allocate(ar); /* radiotap attach */ ieee80211_radiotap_attach(ic, @@ -2518,7 +2495,7 @@ athp_detach_net80211(struct ath10k *ar) /* stop/drain taskq entries */ athp_taskq_flush(ar, 0); athp_taskq_free(ar); - athp_dma_deallocate(ar); + //athp_dma_deallocate(ar); if (ic->ic_softc == ar) ieee80211_ifdetach(ic); diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_pci.c b/otus/freebsd/src/sys/dev/athp/if_athp_pci.c index 4e0371a7..41f3bba0 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_pci.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_pci.c @@ -696,6 +696,31 @@ athp_attach_preinit(void *arg) ath10k_core_destroy(ar); } +/* +* Remove the allocation of the beacon buffer one time +*/ +static void +athp_dma_deallocate(struct ath10k * ar) { + athp_descdma_free(ar, ar->beacon_buf); +} +/* +* Handle the dma allocations for the power up of the wifi card +*/ +static int +athp_dma_allocate(struct ath10k * ar) +{ + int ret = athp_descdma_alloc(ar, ar->beacon_buf, + "beacon buf", 4, ATH10K_BEACON_BUF_LEN); + if (ret != 0) { + ath10k_warn(ar, + "%s: TODO: beacon_buf failed to allocate\n", __func__); + + athp_descdma_free(ar, ar->beacon_buf); + return 0; + } + return 1; +} + static int athp_pci_attach(device_t dev) { @@ -974,7 +999,8 @@ athp_pci_attach(device_t dev) "%s: couldn't establish preinit hook\n", __func__); goto bad4; } - + /* setup the dma allocations here */ + athp_dma_allocate(ar); return (0); /* Fallthrough for setup failure */ @@ -1025,7 +1051,7 @@ athp_pci_detach(device_t dev) ATHP_LOCK(ar); ar->sc_invalid = 1; ATHP_UNLOCK(ar); - + athp_dma_deallocate(ar); /* Shutdown ioctl handler */ athp_ioctl_teardown(ar); From f776fd62ca8f7779baba2a7234737c34c436c54f Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Tue, 6 Nov 2018 21:28:05 -0800 Subject: [PATCH 40/45] required to add mac.h --- otus/freebsd/src/sys/dev/athp/if_athp_pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_pci.c b/otus/freebsd/src/sys/dev/athp/if_athp_pci.c index 41f3bba0..40b8c3f0 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_pci.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_pci.c @@ -88,6 +88,7 @@ __FBSDID("$FreeBSD$"); #include "if_athp_buf.h" #include "if_athp_trace.h" #include "if_athp_ioctl.h" +#include "if_athp_mac.h" static device_probe_t athp_pci_probe; static device_attach_t athp_pci_attach; From ea7a00df282107a884b6f7157fca7f453b5bfc94 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Tue, 6 Nov 2018 21:40:33 -0800 Subject: [PATCH 41/45] moved beacon allocate before the start of all the task queues. --- otus/freebsd/src/sys/dev/athp/if_athp_pci.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_pci.c b/otus/freebsd/src/sys/dev/athp/if_athp_pci.c index 40b8c3f0..69597ebf 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_pci.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_pci.c @@ -701,14 +701,14 @@ athp_attach_preinit(void *arg) * Remove the allocation of the beacon buffer one time */ static void -athp_dma_deallocate(struct ath10k * ar) { +athp_dma_deallocate_beacon(struct ath10k * ar) { athp_descdma_free(ar, ar->beacon_buf); } /* * Handle the dma allocations for the power up of the wifi card */ static int -athp_dma_allocate(struct ath10k * ar) +athp_dma_allocate_beacon(struct ath10k * ar) { int ret = athp_descdma_alloc(ar, ar->beacon_buf, "beacon buf", 4, ATH10K_BEACON_BUF_LEN); @@ -804,6 +804,9 @@ athp_pci_attach(device_t dev) goto bad0; } + /* setup the dma beacon allocations here */ + athp_dma_allocate_beacon(ar); + /* * Initialise HTT descriptors/memory. */ @@ -1000,8 +1003,6 @@ athp_pci_attach(device_t dev) "%s: couldn't establish preinit hook\n", __func__); goto bad4; } - /* setup the dma allocations here */ - athp_dma_allocate(ar); return (0); /* Fallthrough for setup failure */ @@ -1052,7 +1053,7 @@ athp_pci_detach(device_t dev) ATHP_LOCK(ar); ar->sc_invalid = 1; ATHP_UNLOCK(ar); - athp_dma_deallocate(ar); + athp_dma_deallocate_beacon(ar); /* Shutdown ioctl handler */ athp_ioctl_teardown(ar); From 10993548cff0b1aee0d7d5f7003ee2f0ce33ce6b Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Tue, 6 Nov 2018 21:44:11 -0800 Subject: [PATCH 42/45] changed from pointer to object. --- otus/freebsd/src/sys/dev/athp/if_athp_mac.c | 2 +- otus/freebsd/src/sys/dev/athp/if_athp_pci.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_mac.c b/otus/freebsd/src/sys/dev/athp/if_athp_mac.c index cc3ce49d..47ed056a 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_mac.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_mac.c @@ -5441,7 +5441,7 @@ ath10k_add_interface(struct ath10k *ar, struct ieee80211vap *vif, case IEEE80211_M_HOSTAP: arvif->vdev_type = WMI_VDEV_TYPE_AP; /* Need to setup the dma buffer for hostap mode since we allocate it in the power on state 'athp_parent' */ - arvif->beacon_buf = *ar->beacon_buf; + arvif->beacon_buf = &ar->beacon_buf; break; default: ath10k_warn(ar, "%s: unsupported opmode (%d)\n", __func__, opmode); diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_pci.c b/otus/freebsd/src/sys/dev/athp/if_athp_pci.c index 69597ebf..5864d43d 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_pci.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_pci.c @@ -702,7 +702,7 @@ athp_attach_preinit(void *arg) */ static void athp_dma_deallocate_beacon(struct ath10k * ar) { - athp_descdma_free(ar, ar->beacon_buf); + athp_descdma_free(ar, &ar->beacon_buf); } /* * Handle the dma allocations for the power up of the wifi card @@ -710,7 +710,7 @@ athp_dma_deallocate_beacon(struct ath10k * ar) { static int athp_dma_allocate_beacon(struct ath10k * ar) { - int ret = athp_descdma_alloc(ar, ar->beacon_buf, + int ret = athp_descdma_alloc(ar, &ar->beacon_buf, "beacon buf", 4, ATH10K_BEACON_BUF_LEN); if (ret != 0) { ath10k_warn(ar, From ebc21b8a5f9d44a1bbd82934e25424d7170306f5 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Tue, 6 Nov 2018 21:47:00 -0800 Subject: [PATCH 43/45] pointer change didn't make it. --- otus/freebsd/src/sys/dev/athp/if_athp_pci.c | 2 +- otus/freebsd/src/sys/dev/athp/if_athp_var.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_pci.c b/otus/freebsd/src/sys/dev/athp/if_athp_pci.c index 5864d43d..c5da1712 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_pci.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_pci.c @@ -716,7 +716,7 @@ athp_dma_allocate_beacon(struct ath10k * ar) ath10k_warn(ar, "%s: TODO: beacon_buf failed to allocate\n", __func__); - athp_descdma_free(ar, ar->beacon_buf); + athp_descdma_free(ar, &ar->beacon_buf); return 0; } return 1; diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_var.h b/otus/freebsd/src/sys/dev/athp/if_athp_var.h index becb4e37..3c623505 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_var.h +++ b/otus/freebsd/src/sys/dev/athp/if_athp_var.h @@ -399,7 +399,7 @@ struct ath10k { unsigned long long free_vdev_map; struct ath10k_vif *monitor_arvif; - struct athp_descdma *beacon_buf; + struct athp_descdma beacon_buf; bool monitor; int monitor_vdev_id; bool monitor_started; From ec238ca7de8136272bfc311efcc7d447c790aa42 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Tue, 6 Nov 2018 21:48:10 -0800 Subject: [PATCH 44/45] remove assignment address from non_pointer --- otus/freebsd/src/sys/dev/athp/if_athp_mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_mac.c b/otus/freebsd/src/sys/dev/athp/if_athp_mac.c index 47ed056a..61c57a90 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_mac.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_mac.c @@ -5441,7 +5441,7 @@ ath10k_add_interface(struct ath10k *ar, struct ieee80211vap *vif, case IEEE80211_M_HOSTAP: arvif->vdev_type = WMI_VDEV_TYPE_AP; /* Need to setup the dma buffer for hostap mode since we allocate it in the power on state 'athp_parent' */ - arvif->beacon_buf = &ar->beacon_buf; + arvif->beacon_buf = ar->beacon_buf; break; default: ath10k_warn(ar, "%s: unsupported opmode (%d)\n", __func__, opmode); From 9104f9c751af71ec40474748fa43d57cf69ce952 Mon Sep 17 00:00:00 2001 From: Geramy Loveless Date: Wed, 7 Nov 2018 17:28:42 -0800 Subject: [PATCH 45/45] fixed issue with issue #3 and the htt_rx_ring_refill ath10k_htt_rx_ring_refill does a dma allocate so no other lock can be held during this processor that can't be slept, I found that wmi_tx_beacons was holding the conf lock so I created a wait for that. --- otus/freebsd/src/sys/dev/athp/hal/wmi.h | 1 + otus/freebsd/src/sys/dev/athp/if_athp_core.c | 12 +++++++++++- otus/freebsd/src/sys/dev/athp/if_athp_main.c | 10 +++++++--- otus/freebsd/src/sys/dev/athp/if_athp_var.h | 1 + otus/freebsd/src/sys/dev/athp/if_athp_wmi.c | 16 +++++++++++++++- otus/freebsd/src/sys/dev/athp/if_athp_wmi.h | 1 + 6 files changed, 36 insertions(+), 5 deletions(-) diff --git a/otus/freebsd/src/sys/dev/athp/hal/wmi.h b/otus/freebsd/src/sys/dev/athp/hal/wmi.h index 62fb95e3..ebda87c5 100644 --- a/otus/freebsd/src/sys/dev/athp/hal/wmi.h +++ b/otus/freebsd/src/sys/dev/athp/hal/wmi.h @@ -1973,6 +1973,7 @@ struct wmi_10x_service_ready_event { #define WMI_SERVICE_READY_TIMEOUT_MSEC (5000) #define WMI_UNIFIED_READY_TIMEOUT_MSEC (5000) +#define WMI_TX_BEACONS_READY_TIMEOUT_MSEC (3000) struct wmi_ready_event { __le32 sw_version; 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 706bcd31..4e2cf8ca 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_core.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_core.c @@ -1342,6 +1342,7 @@ ath10k_core_init_firmware_features(struct ath10k *ar) int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode) { + //ath10k_compl_init(&ar->wmi.tx_beacons_ready); int status; ATHP_CONF_LOCK_ASSERT(ar); @@ -1470,6 +1471,12 @@ ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode) goto err_hif_stop; } + status = ath10k_wmi_wait_for_tx_beacons_ready(ar); + if (status) { + ath10k_err(ar, "wmi tx beacons ready event not received\n"); + goto err_hif_stop; + } + status = ath10k_wmi_wait_for_unified_ready(ar); if (status) { ath10k_err(ar, "wmi unified ready event not received\n"); @@ -1481,7 +1488,10 @@ ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode) */ ar->htt.rx_ring.in_ord_rx = !!(test_bit(WMI_SERVICE_RX_FULL_REORDER, ar->wmi.svc_map)); - + /* + * added ath10k_wmi_wait_for_tx_beacons_ready above to wait for cmd_Send to basically finish so we don't have to locks trying to be held at the same time, + * causing a crash. + */ status = ath10k_htt_rx_ring_refill(ar); if (status) { ath10k_err(ar, "failed to refill htt rx ring: %d\n", status); 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 d12cf0d9..fb48618e 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_main.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_main.c @@ -2428,7 +2428,7 @@ athp_attach_net80211(struct ath10k *ar) ic->ic_channels); IEEE80211_ADDR_COPY(ic->ic_macaddr, ar->mac_addr); - + printf("%s: called; ieee80211_ifattach\n", __func__); ieee80211_ifattach(ic); /* required 802.11 methods */ @@ -2461,6 +2461,7 @@ athp_attach_net80211(struct ath10k *ar) /* Initial 11n state; capabilities */ if (ar->ht_cap_info & WMI_HT_CAP_ENABLED) { + printf("%s: called; athp_attach_11n\n", __func__); athp_attach_11n(ar); athp_attach_11ac(ar); } @@ -2468,6 +2469,7 @@ athp_attach_net80211(struct ath10k *ar) //athp_dma_allocate(ar); /* radiotap attach */ + printf("%s: called; ieee80211_radiotap_attach\n", __func__); ieee80211_radiotap_attach(ic, &ar->sc_txtapu.th.wt_ihdr, sizeof(ar->sc_txtapu), ATH10K_TX_RADIOTAP_PRESENT, @@ -2475,11 +2477,13 @@ athp_attach_net80211(struct ath10k *ar) ATH10K_RX_RADIOTAP_PRESENT); // if (bootverbose) - ieee80211_announce(ic); + printf("%s: called; ieee80211_announce\n", __func__); + ieee80211_announce(ic); /* Deferring work (eg crypto key updates) into net80211 taskqueue */ + printf("%s: called; athp_taskq_init\n", __func__); (void) athp_taskq_init(ar); - + printf("%s: called; is returning\n", __func__); return (0); } diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_var.h b/otus/freebsd/src/sys/dev/athp/if_athp_var.h index 3c623505..14650280 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_var.h +++ b/otus/freebsd/src/sys/dev/athp/if_athp_var.h @@ -138,6 +138,7 @@ struct ath10k_wmi { enum ath10k_htc_ep_id eid; struct ath10k_compl service_ready; struct ath10k_compl unified_ready; + struct ath10k_compl tx_beacons_ready; struct ath10k_wait tx_credits_wq; int is_init; DECLARE_BITMAP(svc_map, WMI_SERVICE_MAX); diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_wmi.c b/otus/freebsd/src/sys/dev/athp/if_athp_wmi.c index 6a249ae4..305b33f8 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_wmi.c +++ b/otus/freebsd/src/sys/dev/athp/if_athp_wmi.c @@ -1667,6 +1667,19 @@ int ath10k_wmi_wait_for_service_ready(struct ath10k *ar) return 0; } +int ath10k_wmi_wait_for_tx_beacons_ready(struct ath10k *ar) +{ + unsigned long time_left; + + time_left = ath10k_compl_wait(&ar->wmi.tx_beacons_ready, + "wmi_tx_beacons_ready", &ar->sc_conf_mtx, + WMI_TX_BEACONS_READY_TIMEOUT_MSEC); + if (!time_left) + return -ETIMEDOUT; + return 0; +} + + int ath10k_wmi_wait_for_unified_ready(struct ath10k *ar) { unsigned long time_left; @@ -1806,6 +1819,7 @@ static void ath10k_wmi_tx_beacons_nowait(struct ath10k *ar) ath10k_wmi_tx_beacon_nowait(vif); } ATHP_CONF_UNLOCK(ar); + ath10k_compl_wakeup_one(&ar->wmi.tx_beacons_ready); } static void ath10k_wmi_op_ep_tx_credits(struct ath10k *ar) @@ -6998,7 +7012,7 @@ int ath10k_wmi_attach(struct ath10k *ar) ath10k_compl_init(&ar->wmi.service_ready); ath10k_compl_init(&ar->wmi.unified_ready); - + ath10k_compl_init(&ar->wmi.tx_beacons_ready); if (! ar->wmi.is_init) { TASK_INIT(&ar->svc_rdy_work, 0, ath10k_wmi_event_service_ready_work, ar); } diff --git a/otus/freebsd/src/sys/dev/athp/if_athp_wmi.h b/otus/freebsd/src/sys/dev/athp/if_athp_wmi.h index d3f91c39..1ed86390 100644 --- a/otus/freebsd/src/sys/dev/athp/if_athp_wmi.h +++ b/otus/freebsd/src/sys/dev/athp/if_athp_wmi.h @@ -28,6 +28,7 @@ int ath10k_wmi_attach(struct ath10k *ar); void ath10k_wmi_detach(struct ath10k *ar); void ath10k_wmi_detach_drain(struct ath10k *ar); int ath10k_wmi_wait_for_service_ready(struct ath10k *ar); +int ath10k_wmi_wait_for_tx_beacons_ready(struct ath10k *ar); int ath10k_wmi_wait_for_unified_ready(struct ath10k *ar); struct athp_buf *ath10k_wmi_alloc_skb(struct ath10k *ar, u32 len);