Skip to content

Commit 107d83e

Browse files
Geramyerikarn
Geramy
authored andcommitted
Added in a retry so that when kldload does its first interface creation it works. (#4)
* changed timeout to 2 seconds for sloweer systems I have changed the ATH10K_HTC_WAIT_TIMEOUT_MSEC to 2 seconds instead. * 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. * 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. * re-order * re-trying probe fw until sucessful or errors at the 6th try. * undo changes * attempt at retrying to wait for htc to complete and return stopping hif and restarting hif if htc wait target doesnt finish succesfully. * removed return on hif_stop * attemping to recall ath10k_core_probe_fw trying to reset the atheros chip to to load up properly on error. * add sleep statement sleep a little to let the device catch up and be ready. * dumb auto programming features of VSCode capatilized Sleep * 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. * 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. * oops forgot semicolon * test removing ath10k_core_stop from retrying probe and just hack bmi.done_sent * 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 * forgot struct def * added function to cleanup memory leaks added a function to the process that allows us to cleanup any memory leaks if there are any. * 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. * removed line of code from ath10k
1 parent f30e38f commit 107d83e

File tree

4 files changed

+50
-5
lines changed

4 files changed

+50
-5
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
otus/freebsd/src/sys/.vscode/c_cpp_properties.json

otus/freebsd/src/sys/dev/athp/if_athp_core.c

+31-2
Original file line numberDiff line numberDiff line change
@@ -1690,18 +1690,47 @@ ath10k_core_probe_fw(struct ath10k *ar)
16901690
return ret;
16911691
}
16921692

1693+
/*
1694+
This function has been made to do cleanup to prevent memory leaks if any exist.
1695+
First step tell bmi done has not been sent so it will re-setup bmi.
1696+
*/
1697+
static void
1698+
clean_ath10k_core_probe_fw(struct ath10k * ar)
1699+
{
1700+
ar->bmi.done_sent = false;
1701+
}
1702+
1703+
/*
1704+
anum is the number of attempts that have been tried.
1705+
This is to reload the firmware multiple times because sometimes it fails for no reason,
1706+
it may be a freebsd only issue.
1707+
*/
1708+
static int
1709+
attempt_ath10k_core_probe_fw(struct ath10k *ar, int anum)
1710+
{
1711+
int status = ath10k_core_probe_fw(ar);
1712+
if (status) {
1713+
ath10k_err(ar, "could not probe fw, clean up allocations and memory and retry. (%d)\n", status);
1714+
tsleep(ar, 1, "pausing to wait for the ath cpu to be ready.", 250);
1715+
if(anum < ATH10K_FW_PROBE_RETRIES) {
1716+
clean_ath10k_core_probe_fw(ar);
1717+
return attempt_ath10k_core_probe_fw(ar, anum++);
1718+
}
1719+
}
1720+
return status;
1721+
}
1722+
16931723
static void
16941724
ath10k_core_register_work(void *arg, int npending)
16951725
{
16961726
struct ath10k *ar = arg;
16971727
int status;
16981728

1699-
status = ath10k_core_probe_fw(ar);
1729+
status = attempt_ath10k_core_probe_fw(ar, 0);
17001730
if (status) {
17011731
ath10k_err(ar, "could not probe fw (%d)\n", status);
17021732
goto err;
17031733
}
1704-
17051734
status = ath10k_mac_register(ar);
17061735
if (status) {
17071736
ath10k_err(ar, "could not register to mac80211 (%d)\n", status);

otus/freebsd/src/sys/dev/athp/if_athp_core.h

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#define ATH10K_FLUSH_TIMEOUT_HZ (5)
3030
#define ATH10K_CONNECTION_LOSS_HZ (3)
3131
#define ATH10K_NUM_CHANS 39
32+
#define ATH10K_FW_PROBE_RETRIES 6
3233

3334
/* Antenna noise floor */
3435
#define ATH10K_DEFAULT_NOISE_FLOOR -95

otus/freebsd/src/sys/dev/athp/if_athp_main.c

+16-3
Original file line numberDiff line numberDiff line change
@@ -509,12 +509,11 @@ athp_transmit(struct ieee80211com *ic, struct mbuf *m0)
509509

510510
return (0);
511511
}
512-
513512
/*
514513
* Handle initial notifications about starting the interface here.
515514
*/
516515
static void
517-
athp_parent(struct ieee80211com *ic)
516+
athp_parent(struct ieee80211com *ic, int attempts)
518517
{
519518
struct ath10k *ar = ic->ic_softc;
520519

@@ -540,6 +539,12 @@ athp_parent(struct ieee80211com *ic)
540539
ath10k_err(ar,
541540
"%s: ath10k_start failed; ret=%d\n",
542541
__func__, ret);
542+
if (attempts < 6) {
543+
ath10k_err(ar,
544+
"%s: ath10k_start failed, trying again; ret=%d\n",
545+
__func__, ret);
546+
athp_parent(ic, attempts++);
547+
}
543548
return;
544549
}
545550

@@ -588,6 +593,14 @@ athp_parent(struct ieee80211com *ic)
588593
}
589594
}
590595

596+
/*
597+
* Handle the athp_parent call but attempt retries and starting the interface here
598+
*/
599+
static void
600+
net80211_athp_parent(struct ieee80211com *ic) {
601+
athp_parent(ic, 0);
602+
}
603+
591604
#if 0
592605
/*
593606
* STA mode BSS update - deferred since node additions need deferring.
@@ -2424,7 +2437,7 @@ athp_attach_net80211(struct ath10k *ar)
24242437
ic->ic_set_channel = athp_set_channel;
24252438
ic->ic_transmit = athp_transmit;
24262439
ic->ic_send_mgmt = athp_send_mgmt;
2427-
ic->ic_parent = athp_parent;
2440+
ic->ic_parent = net80211_athp_parent;
24282441
ic->ic_vap_create = athp_vap_create;
24292442
ic->ic_vap_delete = athp_vap_delete;
24302443
ic->ic_wme.wme_update = athp_wme_update;

0 commit comments

Comments
 (0)