Skip to content

Commit cb8d61d

Browse files
Felix Fietkaulinvjw
authored andcommitted
ath9k: add additional checks for the baseband hang detection
Since even with the latest changes the false positive issue of the baseband hang check is not fully solved yet, additional checks are needed. If the baseband hang occurs, the rx_clear signal will be stuck to high, so we can use the cycle counters to confirm it. With this patch, a hardware reset is only triggered if the baseband hang check returned true three times in a row, with a beacon interval between each check and if the busy time was also 99% or more during the check intervals. Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent b1f9331 commit cb8d61d

2 files changed

Lines changed: 38 additions & 9 deletions

File tree

‎drivers/net/wireless/ath/ath9k/ath9k.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,8 @@ struct ath_softc {
602602
struct completion paprd_complete;
603603
bool paprd_pending;
604604

605+
unsigned int hw_busy_count;
606+
605607
u32 intrstatus;
606608
u32 sc_flags; /* SC_OP_* */
607609
u16 ps_flags; /* PS_* */

‎drivers/net/wireless/ath/ath9k/main.c‎

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,23 @@ static void ath_update_survey_nf(struct ath_softc *sc, int channel)
153153
}
154154
}
155155

156-
static void ath_update_survey_stats(struct ath_softc *sc)
156+
/*
157+
* Updates the survey statistics and returns the busy time since last
158+
* update in %, if the measurement duration was long enough for the
159+
* result to be useful, -1 otherwise.
160+
*/
161+
static int ath_update_survey_stats(struct ath_softc *sc)
157162
{
158163
struct ath_hw *ah = sc->sc_ah;
159164
struct ath_common *common = ath9k_hw_common(ah);
160165
int pos = ah->curchan - &ah->channels[0];
161166
struct survey_info *survey = &sc->survey[pos];
162167
struct ath_cycle_counters *cc = &common->cc_survey;
163168
unsigned int div = common->clockrate * 1000;
169+
int ret = 0;
164170

165171
if (!ah->curchan)
166-
return;
172+
return -1;
167173

168174
if (ah->power_mode == ATH9K_PM_AWAKE)
169175
ath_hw_cycle_counters_update(common);
@@ -178,9 +184,18 @@ static void ath_update_survey_stats(struct ath_softc *sc)
178184
survey->channel_time_rx += cc->rx_frame / div;
179185
survey->channel_time_tx += cc->tx_frame / div;
180186
}
187+
188+
if (cc->cycles < div)
189+
return -1;
190+
191+
if (cc->cycles > 0)
192+
ret = cc->rx_busy * 100 / cc->cycles;
193+
181194
memset(cc, 0, sizeof(*cc));
182195

183196
ath_update_survey_nf(sc, pos);
197+
198+
return ret;
184199
}
185200

186201
/*
@@ -202,6 +217,8 @@ int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
202217
if (sc->sc_flags & SC_OP_INVALID)
203218
return -EIO;
204219

220+
sc->hw_busy_count = 0;
221+
205222
del_timer_sync(&common->ani.timer);
206223
cancel_work_sync(&sc->paprd_work);
207224
cancel_work_sync(&sc->hw_check_work);
@@ -569,17 +586,25 @@ static void ath_node_detach(struct ath_softc *sc, struct ieee80211_sta *sta)
569586
void ath_hw_check(struct work_struct *work)
570587
{
571588
struct ath_softc *sc = container_of(work, struct ath_softc, hw_check_work);
572-
int i;
589+
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
590+
unsigned long flags;
591+
int busy;
573592

574593
ath9k_ps_wakeup(sc);
594+
if (ath9k_hw_check_alive(sc->sc_ah))
595+
goto out;
575596

576-
for (i = 0; i < 3; i++) {
577-
if (ath9k_hw_check_alive(sc->sc_ah))
578-
goto out;
597+
spin_lock_irqsave(&common->cc_lock, flags);
598+
busy = ath_update_survey_stats(sc);
599+
spin_unlock_irqrestore(&common->cc_lock, flags);
579600

580-
msleep(1);
581-
}
582-
ath_reset(sc, true);
601+
ath_dbg(common, ATH_DBG_RESET, "Possible baseband hang, "
602+
"busy=%d (try %d)\n", busy, sc->hw_busy_count + 1);
603+
if (busy >= 99) {
604+
if (++sc->hw_busy_count >= 3)
605+
ath_reset(sc, true);
606+
} else if (busy >= 0)
607+
sc->hw_busy_count = 0;
583608

584609
out:
585610
ath9k_ps_restore(sc);
@@ -930,6 +955,8 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
930955
struct ieee80211_hw *hw = sc->hw;
931956
int r;
932957

958+
sc->hw_busy_count = 0;
959+
933960
/* Stop ANI */
934961
del_timer_sync(&common->ani.timer);
935962

0 commit comments

Comments
 (0)