Commit e6930c4b authored by Sujith Manoharan's avatar Sujith Manoharan Committed by John W. Linville

ath9k: Use separate operational flags for BTCOEX

Also, use atomic operations to check the flags.
Signed-off-by: default avatarSujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 4cb54fa3
...@@ -441,12 +441,18 @@ void ath_start_ani(struct ath_common *common); ...@@ -441,12 +441,18 @@ void ath_start_ani(struct ath_common *common);
/* BTCOEX */ /* BTCOEX */
/**********/ /**********/
enum bt_op_flags {
BT_OP_PRIORITY_DETECTED,
BT_OP_SCAN,
};
struct ath_btcoex { struct ath_btcoex {
bool hw_timer_enabled; 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 */
u32 bt_priority_cnt; u32 bt_priority_cnt;
unsigned long bt_priority_time; unsigned long bt_priority_time;
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 usec */
u32 btcoex_period; /* in usec */ u32 btcoex_period; /* in usec */
...@@ -588,10 +594,8 @@ struct ath_ant_comb { ...@@ -588,10 +594,8 @@ struct ath_ant_comb {
#define SC_OP_BEACONS BIT(1) #define SC_OP_BEACONS BIT(1)
#define SC_OP_RXFLUSH BIT(2) #define SC_OP_RXFLUSH BIT(2)
#define SC_OP_TSF_RESET BIT(3) #define SC_OP_TSF_RESET BIT(3)
#define SC_OP_BT_PRIORITY_DETECTED BIT(4) #define SC_OP_ANI_RUN BIT(4)
#define SC_OP_BT_SCAN BIT(5) #define SC_OP_PRIM_STA_VIF BIT(5)
#define SC_OP_ANI_RUN BIT(6)
#define SC_OP_PRIM_STA_VIF BIT(7)
/* Powersave flags */ /* Powersave flags */
#define PS_WAIT_FOR_BEACON BIT(0) #define PS_WAIT_FOR_BEACON BIT(0)
......
...@@ -132,17 +132,18 @@ static void ath_detect_bt_priority(struct ath_softc *sc) ...@@ -132,17 +132,18 @@ static void ath_detect_bt_priority(struct ath_softc *sc)
if (time_after(jiffies, btcoex->bt_priority_time + if (time_after(jiffies, btcoex->bt_priority_time +
msecs_to_jiffies(ATH_BT_PRIORITY_TIME_THRESHOLD))) { msecs_to_jiffies(ATH_BT_PRIORITY_TIME_THRESHOLD))) {
sc->sc_flags &= ~(SC_OP_BT_PRIORITY_DETECTED | SC_OP_BT_SCAN); clear_bit(BT_OP_PRIORITY_DETECTED, &btcoex->op_flags);
clear_bit(BT_OP_SCAN, &btcoex->op_flags);
/* Detect if colocated bt started scanning */ /* Detect if colocated bt started scanning */
if (btcoex->bt_priority_cnt >= ATH_BT_CNT_SCAN_THRESHOLD) { if (btcoex->bt_priority_cnt >= ATH_BT_CNT_SCAN_THRESHOLD) {
ath_dbg(ath9k_hw_common(sc->sc_ah), BTCOEX, ath_dbg(ath9k_hw_common(sc->sc_ah), BTCOEX,
"BT scan detected\n"); "BT scan detected\n");
sc->sc_flags |= (SC_OP_BT_SCAN | set_bit(BT_OP_PRIORITY_DETECTED, &btcoex->op_flags);
SC_OP_BT_PRIORITY_DETECTED); set_bit(BT_OP_SCAN, &btcoex->op_flags);
} else if (btcoex->bt_priority_cnt >= ATH_BT_CNT_THRESHOLD) { } else if (btcoex->bt_priority_cnt >= ATH_BT_CNT_THRESHOLD) {
ath_dbg(ath9k_hw_common(sc->sc_ah), BTCOEX, ath_dbg(ath9k_hw_common(sc->sc_ah), BTCOEX,
"BT priority traffic detected\n"); "BT priority traffic detected\n");
sc->sc_flags |= SC_OP_BT_PRIORITY_DETECTED; set_bit(BT_OP_PRIORITY_DETECTED, &btcoex->op_flags);
} }
btcoex->bt_priority_cnt = 0; btcoex->bt_priority_cnt = 0;
...@@ -196,7 +197,7 @@ static void ath_btcoex_period_timer(unsigned long data) ...@@ -196,7 +197,7 @@ static void ath_btcoex_period_timer(unsigned long data)
ath9k_ps_wakeup(sc); ath9k_ps_wakeup(sc);
if (!(ah->caps.hw_caps & ATH9K_HW_CAP_MCI)) if (!(ah->caps.hw_caps & ATH9K_HW_CAP_MCI))
ath_detect_bt_priority(sc); ath_detect_bt_priority(sc);
is_btscan = sc->sc_flags & SC_OP_BT_SCAN; is_btscan = test_bit(BT_OP_SCAN, &btcoex->op_flags);
spin_lock_bh(&btcoex->btcoex_lock); spin_lock_bh(&btcoex->btcoex_lock);
...@@ -219,8 +220,7 @@ static void ath_btcoex_period_timer(unsigned long data) ...@@ -219,8 +220,7 @@ static void ath_btcoex_period_timer(unsigned long data)
ath9k_ps_restore(sc); ath9k_ps_restore(sc);
timer_period = btcoex->btcoex_period / 1000; timer_period = btcoex->btcoex_period / 1000;
mod_timer(&btcoex->period_timer, jiffies + mod_timer(&btcoex->period_timer, jiffies + msecs_to_jiffies(timer_period));
msecs_to_jiffies(timer_period));
} }
/* /*
...@@ -233,14 +233,14 @@ static void ath_btcoex_no_stomp_timer(void *arg) ...@@ -233,14 +233,14 @@ static void ath_btcoex_no_stomp_timer(void *arg)
struct ath_hw *ah = sc->sc_ah; struct ath_hw *ah = sc->sc_ah;
struct ath_btcoex *btcoex = &sc->btcoex; struct ath_btcoex *btcoex = &sc->btcoex;
struct ath_common *common = ath9k_hw_common(ah); struct ath_common *common = ath9k_hw_common(ah);
bool is_btscan = sc->sc_flags & SC_OP_BT_SCAN;
ath_dbg(common, BTCOEX, "no stomp timer running\n"); ath_dbg(common, BTCOEX, "no stomp timer running\n");
ath9k_ps_wakeup(sc); ath9k_ps_wakeup(sc);
spin_lock_bh(&btcoex->btcoex_lock); spin_lock_bh(&btcoex->btcoex_lock);
if (btcoex->bt_stomp_type == ATH_BTCOEX_STOMP_LOW || is_btscan) if (btcoex->bt_stomp_type == ATH_BTCOEX_STOMP_LOW ||
test_bit(BT_OP_SCAN, &btcoex->op_flags))
ath9k_hw_btcoex_bt_stomp(ah, ATH_BTCOEX_STOMP_NONE); ath9k_hw_btcoex_bt_stomp(ah, ATH_BTCOEX_STOMP_NONE);
else if (btcoex->bt_stomp_type == ATH_BTCOEX_STOMP_ALL) else if (btcoex->bt_stomp_type == ATH_BTCOEX_STOMP_ALL)
ath9k_hw_btcoex_bt_stomp(ah, ATH_BTCOEX_STOMP_LOW); ath9k_hw_btcoex_bt_stomp(ah, ATH_BTCOEX_STOMP_LOW);
...@@ -292,7 +292,7 @@ void ath9k_btcoex_timer_resume(struct ath_softc *sc) ...@@ -292,7 +292,7 @@ void ath9k_btcoex_timer_resume(struct ath_softc *sc)
btcoex->bt_priority_cnt = 0; btcoex->bt_priority_cnt = 0;
btcoex->bt_priority_time = jiffies; btcoex->bt_priority_time = jiffies;
sc->sc_flags &= ~(SC_OP_BT_PRIORITY_DETECTED | SC_OP_BT_SCAN); btcoex->op_flags &= ~(BT_OP_PRIORITY_DETECTED | BT_OP_SCAN);
mod_timer(&btcoex->period_timer, jiffies); mod_timer(&btcoex->period_timer, jiffies);
} }
...@@ -316,12 +316,13 @@ void ath9k_btcoex_timer_pause(struct ath_softc *sc) ...@@ -316,12 +316,13 @@ void ath9k_btcoex_timer_pause(struct ath_softc *sc)
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)
{ {
struct ath_btcoex *btcoex = &sc->btcoex;
struct ath_mci_profile *mci = &sc->btcoex.mci; struct ath_mci_profile *mci = &sc->btcoex.mci;
u16 aggr_limit = 0; u16 aggr_limit = 0;
if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI) && mci->aggr_limit) if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI) && mci->aggr_limit)
aggr_limit = (max_4ms_framelen * mci->aggr_limit) >> 4; aggr_limit = (max_4ms_framelen * mci->aggr_limit) >> 4;
else if (sc->sc_flags & SC_OP_BT_PRIORITY_DETECTED) else if (test_bit(BT_OP_PRIORITY_DETECTED, &btcoex->op_flags))
aggr_limit = min((max_4ms_framelen * 3) / 8, aggr_limit = min((max_4ms_framelen * 3) / 8,
(u32)ATH_AMPDU_LIMIT_MAX); (u32)ATH_AMPDU_LIMIT_MAX);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment