ath9k: fix ASPM initialization on resume
PATCH 3/3 ath9k: use ieee80211_free_txskb
In reply to Felix FietkauUsing ieee80211_free_txskb for tx frames is required, since mac80211 clones skbs for which socket tx status is requested.
--- drivers/net/wireless/ath/ath9k/beacon.c | 2 +- drivers/net/wireless/ath/ath9k/main.c | 2 +- drivers/net/wireless/ath/ath9k/xmit.c | 53 +++++++++++++++++-------------- 3 files changed, 31 insertions(+), 26 deletions(-)
drivers/net/wireless/ath/ath9k/beacon.c +1 -1
@@ -120,7 +120,7 @@ static void ath9k_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb)if (ath_tx_start (hw, skb, &txctl) !=0 ) {ath_dbg (common,XMIT ,"CABQ TX failed\n" ); -dev_kfree_skb_any (skb); +ieee80211_free_txskb (hw, skb); } }
drivers/net/wireless/ath/ath9k/main.c +1 -1
@@ -765,7 +765,7 @@ static void ath9k_tx(struct ieee80211_hw *hw,return ; exit: -dev_kfree_skb_any (skb); +ieee80211_free_txskb (hw, skb); }static void ath9k_stop (struct ieee80211_hw *hw)
drivers/net/wireless/ath/ath9k/xmit.c +29 -24
116 lines not on this page · raw message
Signature · 1 line
1.7.9.6 (Apple Git-31.1)
PATCH 1/3 ath9k: fix ASPM initialization on resume
ath_pci_aspm_init is only called on card init, so PCI registers get reset after a suspend/resume cycle.
--- drivers/net/wireless/ath/ath9k/pci.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wireless/ath/ath9k/pci.c +5 -0
@@ -333,6 +333,9 @@ static int ath_pci_suspend(struct device *device)static int ath_pci_resume (struct device *device) {struct pci_dev *pdev =to_pci_dev (device); +struct ieee80211_hw *hw =pci_get_drvdata (pdev); +struct ath_softc *sc = hw->priv; +struct ath_common *common =ath9k_hw_common (sc->sc_ah);u32 val;/*
@@ -344,6 +347,8 @@ static int ath_pci_resume(struct device *device)if ((val &0x0000ff00 ) !=0 )pci_write_config_dword (pdev,0x40 , val &0xffff00ff ); +ath_pci_aspm_init (common); +return 0 ; }
Signature · 1 line
1.7.9.6 (Apple Git-31.1)
PATCH 2/3 ath9k: improve suspend/resume reliability
Ensure that drv_start() always returns true, as a failing hw start usually eventually leads to crashes when there's still a station entry present. Call a power-on reset after a resume and after a hw reset failure to bring the hardware back to life again.
--- drivers/net/wireless/ath/ath9k/hw.c | 5 +++++ drivers/net/wireless/ath/ath9k/hw.h | 1 + drivers/net/wireless/ath/ath9k/main.c | 13 ++++--------- drivers/net/wireless/ath/ath9k/pci.c | 4 +++- 4 files changed, 13 insertions(+), 10 deletions(-)
drivers/net/wireless/ath/ath9k/hw.c +5 -0
@@ -1450,9 +1450,14 @@ static bool ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type)REG_WRITE (ah,AR_RTC_FORCE_WAKE ,AR_RTC_FORCE_WAKE_EN |AR_RTC_FORCE_WAKE_ON_INT ); +if (!ah->reset_power_on) + type =ATH9K_RESET_POWER_ON ; +switch (type) {case ATH9K_RESET_POWER_ON : ret =ath9k_hw_set_reset_power_on (ah); +if (!ret) + ah->reset_power_on = true;break ;case ATH9K_RESET_WARM :case ATH9K_RESET_COLD :
drivers/net/wireless/ath/ath9k/hw.h +1 -0
@@ -741,6 +741,7 @@ struct ath_hw {u32 rfkill_polarity;u32 ah_flags; +bool reset_power_on;bool htc_reset_init;enum nl80211_iftype opmode;
drivers/net/wireless/ath/ath9k/main.c +4 -9
@@ -639,8 +639,7 @@ static int ath9k_start(struct ieee80211_hw *hw)ath_err (common,"Unable to reset hardware; reset status %d (freq %u MHz)\n" , r, curchan->center_freq); -spin_unlock_bh (&sc->sc_pcu_lock); - goto mutex_unlock; + ah->reset_power_on = false; }/* Setup our intr mask. */
@@ -665,11 +664,8 @@ static int ath9k_start(struct ieee80211_hw *hw)clear_bit (SC_OP_INVALID , &sc->sc_flags); sc->sc_ah->is_monitoring = false; -if (!ath_complete_reset (sc, false)) { - r = -EIO ; -spin_unlock_bh (&sc->sc_pcu_lock); - goto mutex_unlock; - } +if (!ath_complete_reset (sc, false)) + ah->reset_power_on = false;if (ah->led_pin >=0 ) { ath9k_hw_cfg_output(ah, ah->led_pin,
@@ -688,12 +684,11 @@ static int ath9k_start(struct ieee80211_hw *hw)if (ah->caps.pcie_lcr_extsync_en && common->bus_ops->extn_synch_en) common->bus_ops->extn_synch_en (common); -mutex_unlock:mutex_unlock (&sc->mutex);ath9k_ps_restore (sc); -return r; +return 0 ; } static void ath9k_tx(struct ieee80211_hw *hw,
drivers/net/wireless/ath/ath9k/pci.c +3 -1
@@ -335,7 +335,8 @@ static int ath_pci_resume(struct device *device)struct pci_dev *pdev =to_pci_dev (device);struct ieee80211_hw *hw =pci_get_drvdata (pdev);struct ath_softc *sc = hw->priv; -struct ath_common *common =ath9k_hw_common (sc->sc_ah); +struct ath_hw *ah = sc->sc_ah; +struct ath_common *common =ath9k_hw_common (ah);u32 val;/*
@@ -348,6 +349,7 @@ static int ath_pci_resume(struct device *device)pci_write_config_dword (pdev,0x40 , val &0xffff00ff );ath_pci_aspm_init (common); + ah->reset_power_on = false;return 0 ; }
Signature · 1 line
1.7.9.6 (Apple Git-31.1)
PATCH 2/3 ath9k: improve suspend/resume reliability
Quoted 4 lines · Felix Fietkau
Ensure that
drv_start()always returns true, as a failing hw start usually eventually leads to crashes when there's still a station entry present. Call a power-on reset after a resume and after a hw reset failure to bring the hardware back to life again.
In what situations did HW reset (via start() or resume()) fail ?
Sujith
Re: [PATCH 3.7 2/3] ath9k: improve suspend/resume reliability
Quoted 7 lines · Sujith Manoharan
Quoted 4 lines · Felix Fietkau
Ensure that
drv_start()always returns true, as a failing hw start usually eventually leads to crashes when there's still a station entry present. Call a power-on reset after a resume and after a hw reset failure to bring the hardware back to life again.In what situations did HW reset (via
start()orresume()) fail ?
I don't know what situations caused it, but this happened on a few ChromeOS devices in the wild, and my patch fixed it.
- Felix
RE: [PATCH 3.7 2/3] ath9k: improve suspend/resume reliability
Quoted 7 lines · Sujith Manoharan
Quoted 4 lines · Felix Fietkau
Ensure that
drv_start()always returns true, as a failing hw start usually eventually leads to crashes when there's still a station entry present. Call a power-on reset after a resume and after a hw reset failure to bring the hardware back to life again.In what situations did HW reset (via
start()orresume()) fail ?
I don't know what situations caused it, but this happened on a few ChromeOS devices in the wild, and my patch fixed it.
Well, the cause for the real issue, the HW reset failure is still unknown. I think we might be papering over some other bug here.
Sujith
Re: [PATCH 3.7 2/3] ath9k: improve suspend/resume reliability
Quoted 7 lines · Sujith
Quoted 6 lines · Sujith Manoharan
Quoted 4 lines · Felix Fietkau
Ensure that
drv_start()always returns true, as a failing hw start usually eventually leads to crashes when there's still a station entry present. Call a power-on reset after a resume and after a hw reset failure to bring the hardware back to life again.
Quoted 6 lines
Quoted 3 lines
In what situations did HW reset (via
start()orresume()) fail ? I don't know what situations caused it, but this happened on a few ChromeOS devices in the wild, and my patch fixed it.Well, the cause for the real issue, the HW reset failure is still unknown. I think we might be papering over some other bug here.
After a suspend/resume cycle, the card definitely needs at least one power-on reset (since we can assume that the card was power cycled), as is done on driver initialization as well. My patch ensures that this happens by setting a flag on resume.
If for some reason the drv_start() reset still fails (and I'm not aware of any such instances), it's still much better to return 0. The reset failure will still appear in log messages.
If we return an error code in drv_start, this tends to create a mess of either WARN_ON/BUG_ON calls triggered at a later point in time (if a station was connected), or just a complete loss of wifi functionality.
- Felix