Skip to content

Commit 6bcfe67

Browse files
Sujith Manoharanlinvjw
authored andcommitted
ath9k_htc: Fix IDLE power save
Remove the radio enable/disable stuff and fix the transition to FULL_SLEEP mode when the device is idle. Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent d8a2c51 commit 6bcfe67

3 files changed

Lines changed: 20 additions & 124 deletions

File tree

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,6 @@ bool ath9k_htc_setpower(struct ath9k_htc_priv *priv,
572572

573573
void ath9k_start_rfkill_poll(struct ath9k_htc_priv *priv);
574574
void ath9k_htc_rfkill_poll_state(struct ieee80211_hw *hw);
575-
void ath9k_htc_radio_enable(struct ieee80211_hw *hw);
576-
void ath9k_htc_radio_disable(struct ieee80211_hw *hw);
577575

578576
#ifdef CONFIG_MAC80211_LEDS
579577
void ath9k_init_leds(struct ath9k_htc_priv *priv);

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

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -310,95 +310,3 @@ void ath9k_start_rfkill_poll(struct ath9k_htc_priv *priv)
310310
if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
311311
wiphy_rfkill_start_polling(priv->hw->wiphy);
312312
}
313-
314-
void ath9k_htc_radio_enable(struct ieee80211_hw *hw)
315-
{
316-
struct ath9k_htc_priv *priv = hw->priv;
317-
struct ath_hw *ah = priv->ah;
318-
struct ath_common *common = ath9k_hw_common(ah);
319-
int ret;
320-
u8 cmd_rsp;
321-
322-
if (!ah->curchan)
323-
ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
324-
325-
/* Reset the HW */
326-
ret = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
327-
if (ret) {
328-
ath_err(common,
329-
"Unable to reset hardware; reset status %d (freq %u MHz)\n",
330-
ret, ah->curchan->channel);
331-
}
332-
333-
ath9k_cmn_update_txpow(ah, priv->curtxpow, priv->txpowlimit,
334-
&priv->curtxpow);
335-
336-
/* Start RX */
337-
WMI_CMD(WMI_START_RECV_CMDID);
338-
ath9k_host_rx_init(priv);
339-
340-
/* Start TX */
341-
htc_start(priv->htc);
342-
spin_lock_bh(&priv->tx.tx_lock);
343-
priv->tx.flags &= ~ATH9K_HTC_OP_TX_QUEUES_STOP;
344-
spin_unlock_bh(&priv->tx.tx_lock);
345-
ieee80211_wake_queues(hw);
346-
347-
WMI_CMD(WMI_ENABLE_INTR_CMDID);
348-
349-
/* Enable LED */
350-
ath9k_hw_cfg_output(ah, ah->led_pin,
351-
AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
352-
ath9k_hw_set_gpio(ah, ah->led_pin, 0);
353-
}
354-
355-
void ath9k_htc_radio_disable(struct ieee80211_hw *hw)
356-
{
357-
struct ath9k_htc_priv *priv = hw->priv;
358-
struct ath_hw *ah = priv->ah;
359-
struct ath_common *common = ath9k_hw_common(ah);
360-
int ret;
361-
u8 cmd_rsp;
362-
363-
ath9k_htc_ps_wakeup(priv);
364-
365-
/* Disable LED */
366-
ath9k_hw_set_gpio(ah, ah->led_pin, 1);
367-
ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
368-
369-
WMI_CMD(WMI_DISABLE_INTR_CMDID);
370-
371-
/* Stop TX */
372-
ieee80211_stop_queues(hw);
373-
ath9k_htc_tx_drain(priv);
374-
WMI_CMD(WMI_DRAIN_TXQ_ALL_CMDID);
375-
376-
/* Stop RX */
377-
WMI_CMD(WMI_STOP_RECV_CMDID);
378-
379-
/* Clear the WMI event queue */
380-
ath9k_wmi_event_drain(priv);
381-
382-
/*
383-
* The MIB counters have to be disabled here,
384-
* since the target doesn't do it.
385-
*/
386-
ath9k_hw_disable_mib_counters(ah);
387-
388-
if (!ah->curchan)
389-
ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
390-
391-
/* Reset the HW */
392-
ret = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
393-
if (ret) {
394-
ath_err(common,
395-
"Unable to reset hardware; reset status %d (freq %u MHz)\n",
396-
ret, ah->curchan->channel);
397-
}
398-
399-
/* Disable the PHY */
400-
ath9k_hw_phy_disable(ah);
401-
402-
ath9k_htc_ps_restore(priv);
403-
ath9k_htc_setpower(priv, ATH9K_PM_FULL_SLEEP);
404-
}

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

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,19 @@ void ath9k_htc_ps_wakeup(struct ath9k_htc_priv *priv)
7575

7676
void ath9k_htc_ps_restore(struct ath9k_htc_priv *priv)
7777
{
78+
bool reset;
79+
7880
mutex_lock(&priv->htc_pm_lock);
7981
if (--priv->ps_usecount != 0)
8082
goto unlock;
8183

82-
if (priv->ps_idle)
84+
if (priv->ps_idle) {
85+
ath9k_hw_setrxabort(priv->ah, true);
86+
ath9k_hw_stopdmarecv(priv->ah, &reset);
8387
ath9k_hw_setpower(priv->ah, ATH9K_PM_FULL_SLEEP);
84-
else if (priv->ps_enabled)
88+
} else if (priv->ps_enabled) {
8589
ath9k_hw_setpower(priv->ah, ATH9K_PM_NETWORK_SLEEP);
90+
}
8691

8792
unlock:
8893
mutex_unlock(&priv->htc_pm_lock);
@@ -1178,24 +1183,20 @@ static int ath9k_htc_config(struct ieee80211_hw *hw, u32 changed)
11781183
struct ath9k_htc_priv *priv = hw->priv;
11791184
struct ath_common *common = ath9k_hw_common(priv->ah);
11801185
struct ieee80211_conf *conf = &hw->conf;
1186+
bool chip_reset = false;
1187+
int ret = 0;
11811188

11821189
mutex_lock(&priv->mutex);
1190+
ath9k_htc_ps_wakeup(priv);
11831191

11841192
if (changed & IEEE80211_CONF_CHANGE_IDLE) {
1185-
bool enable_radio = false;
1186-
bool idle = !!(conf->flags & IEEE80211_CONF_IDLE);
1187-
11881193
mutex_lock(&priv->htc_pm_lock);
1189-
if (!idle && priv->ps_idle)
1190-
enable_radio = true;
1191-
priv->ps_idle = idle;
1192-
mutex_unlock(&priv->htc_pm_lock);
11931194

1194-
if (enable_radio) {
1195-
ath_dbg(common, CONFIG, "not-idle: enabling radio\n");
1196-
ath9k_htc_setpower(priv, ATH9K_PM_AWAKE);
1197-
ath9k_htc_radio_enable(hw);
1198-
}
1195+
priv->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE);
1196+
if (priv->ps_idle)
1197+
chip_reset = true;
1198+
1199+
mutex_unlock(&priv->htc_pm_lock);
11991200
}
12001201

12011202
/*
@@ -1210,7 +1211,7 @@ static int ath9k_htc_config(struct ieee80211_hw *hw, u32 changed)
12101211
ath9k_htc_remove_monitor_interface(priv);
12111212
}
12121213

1213-
if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
1214+
if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || chip_reset) {
12141215
struct ieee80211_channel *curchan = hw->conf.channel;
12151216
int pos = curchan->hw_value;
12161217

@@ -1223,8 +1224,8 @@ static int ath9k_htc_config(struct ieee80211_hw *hw, u32 changed)
12231224

12241225
if (ath9k_htc_set_channel(priv, hw, &priv->ah->channels[pos]) < 0) {
12251226
ath_err(common, "Unable to set channel\n");
1226-
mutex_unlock(&priv->mutex);
1227-
return -EINVAL;
1227+
ret = -EINVAL;
1228+
goto out;
12281229
}
12291230

12301231
}
@@ -1246,21 +1247,10 @@ static int ath9k_htc_config(struct ieee80211_hw *hw, u32 changed)
12461247
priv->txpowlimit, &priv->curtxpow);
12471248
}
12481249

1249-
if (changed & IEEE80211_CONF_CHANGE_IDLE) {
1250-
mutex_lock(&priv->htc_pm_lock);
1251-
if (!priv->ps_idle) {
1252-
mutex_unlock(&priv->htc_pm_lock);
1253-
goto out;
1254-
}
1255-
mutex_unlock(&priv->htc_pm_lock);
1256-
1257-
ath_dbg(common, CONFIG, "idle: disabling radio\n");
1258-
ath9k_htc_radio_disable(hw);
1259-
}
1260-
12611250
out:
1251+
ath9k_htc_ps_restore(priv);
12621252
mutex_unlock(&priv->mutex);
1263-
return 0;
1253+
return ret;
12641254
}
12651255

12661256
#define SUPPORTED_FILTERS \

0 commit comments

Comments
 (0)