ath9k_hw: use a software timer for btcoex no_stomp_timer

TSF accuracy is not needed here, and there is only one usable generic
timer that is supported by all chips and uses the primary TSF counter.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
Felix Fietkau 2013-12-14 18:03:37 +01:00 committed by John W. Linville
parent e45e91d881
commit 168c6f89a2
3 changed files with 15 additions and 47 deletions

View File

@ -477,20 +477,19 @@ enum bt_op_flags {
}; };
struct ath_btcoex { struct ath_btcoex {
bool hw_timer_enabled;
spinlock_t btcoex_lock; spinlock_t btcoex_lock;
struct timer_list period_timer; /* Timer for BT period */ struct timer_list period_timer; /* Timer for BT period */
struct timer_list no_stomp_timer;
u32 bt_priority_cnt; u32 bt_priority_cnt;
unsigned long bt_priority_time; unsigned long bt_priority_time;
unsigned long op_flags; unsigned long op_flags;
int bt_stomp_type; /* Types of BT stomping */ int bt_stomp_type; /* Types of BT stomping */
u32 btcoex_no_stomp; /* in usec */ u32 btcoex_no_stomp; /* in msec */
u32 btcoex_period; /* in msec */ u32 btcoex_period; /* in msec */
u32 btscan_no_stomp; /* in usec */ u32 btscan_no_stomp; /* in msec */
u32 duty_cycle; u32 duty_cycle;
u32 bt_wait_time; u32 bt_wait_time;
int rssi_count; int rssi_count;
struct ath_gen_timer *no_stomp_timer; /* Timer for no BT stomping */
struct ath_mci_profile mci; struct ath_mci_profile mci;
u8 stomp_audio; u8 stomp_audio;
}; };

View File

@ -257,19 +257,9 @@ static void ath_btcoex_period_timer(unsigned long data)
spin_unlock_bh(&btcoex->btcoex_lock); spin_unlock_bh(&btcoex->btcoex_lock);
/* if (btcoex->btcoex_period != btcoex->btcoex_no_stomp)
* btcoex_period is in msec while (btocex/btscan_)no_stomp are in usec, mod_timer(&btcoex->no_stomp_timer,
* ensure that we properly convert btcoex_period to usec jiffies + msecs_to_jiffies(timer_period));
* for any comparision with (btcoex/btscan_)no_stomp.
*/
if (btcoex->btcoex_period * 1000 != btcoex->btcoex_no_stomp) {
if (btcoex->hw_timer_enabled)
ath9k_gen_timer_stop(ah, btcoex->no_stomp_timer);
ath9k_gen_timer_start(ah, btcoex->no_stomp_timer, timer_period,
timer_period * 10);
btcoex->hw_timer_enabled = true;
}
ath9k_ps_restore(sc); ath9k_ps_restore(sc);
@ -282,7 +272,7 @@ static void ath_btcoex_period_timer(unsigned long data)
* Generic tsf based hw timer which configures weight * Generic tsf based hw timer which configures weight
* registers to time slice between wlan and bt traffic * registers to time slice between wlan and bt traffic
*/ */
static void ath_btcoex_no_stomp_timer(void *arg) static void ath_btcoex_no_stomp_timer(unsigned long arg)
{ {
struct ath_softc *sc = (struct ath_softc *)arg; struct ath_softc *sc = (struct ath_softc *)arg;
struct ath_hw *ah = sc->sc_ah; struct ath_hw *ah = sc->sc_ah;
@ -311,24 +301,18 @@ static int ath_init_btcoex_timer(struct ath_softc *sc)
struct ath_btcoex *btcoex = &sc->btcoex; struct ath_btcoex *btcoex = &sc->btcoex;
btcoex->btcoex_period = ATH_BTCOEX_DEF_BT_PERIOD; btcoex->btcoex_period = ATH_BTCOEX_DEF_BT_PERIOD;
btcoex->btcoex_no_stomp = (100 - ATH_BTCOEX_DEF_DUTY_CYCLE) * 1000 * btcoex->btcoex_no_stomp = (100 - ATH_BTCOEX_DEF_DUTY_CYCLE) *
btcoex->btcoex_period / 100; btcoex->btcoex_period / 100;
btcoex->btscan_no_stomp = (100 - ATH_BTCOEX_BTSCAN_DUTY_CYCLE) * 1000 * btcoex->btscan_no_stomp = (100 - ATH_BTCOEX_BTSCAN_DUTY_CYCLE) *
btcoex->btcoex_period / 100; btcoex->btcoex_period / 100;
setup_timer(&btcoex->period_timer, ath_btcoex_period_timer, setup_timer(&btcoex->period_timer, ath_btcoex_period_timer,
(unsigned long) sc); (unsigned long) sc);
setup_timer(&btcoex->no_stomp_timer, ath_btcoex_no_stomp_timer,
(unsigned long) sc);
spin_lock_init(&btcoex->btcoex_lock); spin_lock_init(&btcoex->btcoex_lock);
btcoex->no_stomp_timer = ath_gen_timer_alloc(sc->sc_ah,
ath_btcoex_no_stomp_timer,
ath_btcoex_no_stomp_timer,
(void *) sc, AR_FIRST_NDP_TIMER);
if (!btcoex->no_stomp_timer)
return -ENOMEM;
return 0; return 0;
} }
@ -343,10 +327,7 @@ void ath9k_btcoex_timer_resume(struct ath_softc *sc)
ath_dbg(ath9k_hw_common(ah), BTCOEX, "Starting btcoex timers\n"); ath_dbg(ath9k_hw_common(ah), BTCOEX, "Starting btcoex timers\n");
/* make sure duty cycle timer is also stopped when resuming */ /* make sure duty cycle timer is also stopped when resuming */
if (btcoex->hw_timer_enabled) { del_timer_sync(&btcoex->no_stomp_timer);
ath9k_gen_timer_stop(sc->sc_ah, btcoex->no_stomp_timer);
btcoex->hw_timer_enabled = false;
}
btcoex->bt_priority_cnt = 0; btcoex->bt_priority_cnt = 0;
btcoex->bt_priority_time = jiffies; btcoex->bt_priority_time = jiffies;
@ -363,24 +344,16 @@ void ath9k_btcoex_timer_resume(struct ath_softc *sc)
void ath9k_btcoex_timer_pause(struct ath_softc *sc) void ath9k_btcoex_timer_pause(struct ath_softc *sc)
{ {
struct ath_btcoex *btcoex = &sc->btcoex; struct ath_btcoex *btcoex = &sc->btcoex;
struct ath_hw *ah = sc->sc_ah;
del_timer_sync(&btcoex->period_timer); del_timer_sync(&btcoex->period_timer);
del_timer_sync(&btcoex->no_stomp_timer);
if (btcoex->hw_timer_enabled) {
ath9k_gen_timer_stop(ah, btcoex->no_stomp_timer);
btcoex->hw_timer_enabled = false;
}
} }
void ath9k_btcoex_stop_gen_timer(struct ath_softc *sc) void ath9k_btcoex_stop_gen_timer(struct ath_softc *sc)
{ {
struct ath_btcoex *btcoex = &sc->btcoex; struct ath_btcoex *btcoex = &sc->btcoex;
if (btcoex->hw_timer_enabled) { del_timer_sync(&btcoex->no_stomp_timer);
ath9k_gen_timer_stop(sc->sc_ah, btcoex->no_stomp_timer);
btcoex->hw_timer_enabled = false;
}
} }
u16 ath9k_btcoex_aggr_limit(struct ath_softc *sc, u32 max_4ms_framelen) u16 ath9k_btcoex_aggr_limit(struct ath_softc *sc, u32 max_4ms_framelen)
@ -447,10 +420,6 @@ void ath9k_deinit_btcoex(struct ath_softc *sc)
{ {
struct ath_hw *ah = sc->sc_ah; struct ath_hw *ah = sc->sc_ah;
if ((sc->btcoex.no_stomp_timer) &&
ath9k_hw_get_btcoex_scheme(sc->sc_ah) == ATH_BTCOEX_CFG_3WIRE)
ath_gen_timer_free(sc->sc_ah, sc->btcoex.no_stomp_timer);
if (ath9k_hw_mci_is_enabled(ah)) if (ath9k_hw_mci_is_enabled(ah))
ath_mci_cleanup(sc); ath_mci_cleanup(sc);
} }

View File

@ -200,7 +200,7 @@ static void ath_mci_update_scheme(struct ath_softc *sc)
if (btcoex->duty_cycle > ATH_MCI_MAX_DUTY_CYCLE) if (btcoex->duty_cycle > ATH_MCI_MAX_DUTY_CYCLE)
btcoex->duty_cycle = ATH_MCI_MAX_DUTY_CYCLE; btcoex->duty_cycle = ATH_MCI_MAX_DUTY_CYCLE;
btcoex->btcoex_no_stomp = btcoex->btcoex_period * 1000 * btcoex->btcoex_no_stomp = btcoex->btcoex_period *
(100 - btcoex->duty_cycle) / 100; (100 - btcoex->duty_cycle) / 100;
ath9k_hw_btcoex_enable(sc->sc_ah); ath9k_hw_btcoex_enable(sc->sc_ah);