rtlwifi: Don't block interrupts in spinlocks

Now power state transitions are not called from an
interrupt context, there's no need to block interrupts.

This code appears to block interrupts for too long,
causing my trackpad to lose sync occasionally.

Signed-off-by: Mike McCormack <mikem@ring3k.org>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
Mike McCormack 2011-05-31 08:49:36 +09:00 committed by John W. Linville
parent 67fc6052a4
commit 312d5479dc
3 changed files with 26 additions and 38 deletions

View File

@ -85,7 +85,6 @@ bool rtl_ps_set_rf_state(struct ieee80211_hw *hw,
struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
bool actionallowed = false; bool actionallowed = false;
u16 rfwait_cnt = 0; u16 rfwait_cnt = 0;
unsigned long flag;
/*protect_or_not = true; */ /*protect_or_not = true; */
@ -98,10 +97,9 @@ bool rtl_ps_set_rf_state(struct ieee80211_hw *hw,
*should wait to be executed. *should wait to be executed.
*/ */
while (true) { while (true) {
spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flag); spin_lock(&rtlpriv->locks.rf_ps_lock);
if (ppsc->rfchange_inprogress) { if (ppsc->rfchange_inprogress) {
spin_unlock_irqrestore(&rtlpriv->locks.rf_ps_lock, spin_unlock(&rtlpriv->locks.rf_ps_lock);
flag);
RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
("RF Change in progress!" ("RF Change in progress!"
@ -122,8 +120,7 @@ bool rtl_ps_set_rf_state(struct ieee80211_hw *hw,
} }
} else { } else {
ppsc->rfchange_inprogress = true; ppsc->rfchange_inprogress = true;
spin_unlock_irqrestore(&rtlpriv->locks.rf_ps_lock, spin_unlock(&rtlpriv->locks.rf_ps_lock);
flag);
break; break;
} }
} }
@ -171,9 +168,9 @@ no_protect:
rtlpriv->cfg->ops->set_rf_power_state(hw, state_toset); rtlpriv->cfg->ops->set_rf_power_state(hw, state_toset);
if (!protect_or_not) { if (!protect_or_not) {
spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flag); spin_lock(&rtlpriv->locks.rf_ps_lock);
ppsc->rfchange_inprogress = false; ppsc->rfchange_inprogress = false;
spin_unlock_irqrestore(&rtlpriv->locks.rf_ps_lock, flag); spin_unlock(&rtlpriv->locks.rf_ps_lock);
} }
return actionallowed; return actionallowed;
@ -287,12 +284,11 @@ void rtl_ips_nic_on(struct ieee80211_hw *hw)
struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
enum rf_pwrstate rtstate; enum rf_pwrstate rtstate;
unsigned long flags;
if (mac->opmode != NL80211_IFTYPE_STATION) if (mac->opmode != NL80211_IFTYPE_STATION)
return; return;
spin_lock_irqsave(&rtlpriv->locks.ips_lock, flags); spin_lock(&rtlpriv->locks.ips_lock);
if (ppsc->inactiveps) { if (ppsc->inactiveps) {
rtstate = ppsc->rfpwr_state; rtstate = ppsc->rfpwr_state;
@ -308,7 +304,7 @@ void rtl_ips_nic_on(struct ieee80211_hw *hw)
} }
} }
spin_unlock_irqrestore(&rtlpriv->locks.ips_lock, flags); spin_unlock(&rtlpriv->locks.ips_lock);
} }
/*for FW LPS*/ /*for FW LPS*/
@ -426,7 +422,6 @@ void rtl_lps_enter(struct ieee80211_hw *hw)
struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_priv *rtlpriv = rtl_priv(hw);
unsigned long flag;
if (!ppsc->fwctrl_lps) if (!ppsc->fwctrl_lps)
return; return;
@ -447,7 +442,7 @@ void rtl_lps_enter(struct ieee80211_hw *hw)
if (mac->link_state != MAC80211_LINKED) if (mac->link_state != MAC80211_LINKED)
return; return;
spin_lock_irqsave(&rtlpriv->locks.lps_lock, flag); spin_lock(&rtlpriv->locks.lps_lock);
/* Idle for a while if we connect to AP a while ago. */ /* Idle for a while if we connect to AP a while ago. */
if (mac->cnt_after_linked >= 2) { if (mac->cnt_after_linked >= 2) {
@ -459,7 +454,7 @@ void rtl_lps_enter(struct ieee80211_hw *hw)
} }
} }
spin_unlock_irqrestore(&rtlpriv->locks.lps_lock, flag); spin_unlock(&rtlpriv->locks.lps_lock);
} }
/*Leave the leisure power save mode.*/ /*Leave the leisure power save mode.*/
@ -468,9 +463,8 @@ void rtl_lps_leave(struct ieee80211_hw *hw)
struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
unsigned long flag;
spin_lock_irqsave(&rtlpriv->locks.lps_lock, flag); spin_lock(&rtlpriv->locks.lps_lock);
if (ppsc->fwctrl_lps) { if (ppsc->fwctrl_lps) {
if (ppsc->dot11_psmode != EACTIVE) { if (ppsc->dot11_psmode != EACTIVE) {
@ -491,7 +485,7 @@ void rtl_lps_leave(struct ieee80211_hw *hw)
rtl_lps_set_psmode(hw, EACTIVE); rtl_lps_set_psmode(hw, EACTIVE);
} }
} }
spin_unlock_irqrestore(&rtlpriv->locks.lps_lock, flag); spin_unlock(&rtlpriv->locks.lps_lock);
} }
/* For sw LPS*/ /* For sw LPS*/
@ -580,7 +574,6 @@ void rtl_swlps_rf_awake(struct ieee80211_hw *hw)
struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
unsigned long flag;
if (!rtlpriv->psc.swctrl_lps) if (!rtlpriv->psc.swctrl_lps)
return; return;
@ -593,9 +586,9 @@ void rtl_swlps_rf_awake(struct ieee80211_hw *hw)
RT_CLEAR_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM); RT_CLEAR_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM);
} }
spin_lock_irqsave(&rtlpriv->locks.lps_lock, flag); spin_lock(&rtlpriv->locks.lps_lock);
rtl_ps_set_rf_state(hw, ERFON, RF_CHANGE_BY_PS, false); rtl_ps_set_rf_state(hw, ERFON, RF_CHANGE_BY_PS, false);
spin_unlock_irqrestore(&rtlpriv->locks.lps_lock, flag); spin_unlock(&rtlpriv->locks.lps_lock);
} }
void rtl_swlps_rfon_wq_callback(void *data) void rtl_swlps_rfon_wq_callback(void *data)
@ -612,7 +605,6 @@ void rtl_swlps_rf_sleep(struct ieee80211_hw *hw)
struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
unsigned long flag;
u8 sleep_intv; u8 sleep_intv;
if (!rtlpriv->psc.sw_ps_enabled) if (!rtlpriv->psc.sw_ps_enabled)
@ -629,16 +621,16 @@ void rtl_swlps_rf_sleep(struct ieee80211_hw *hw)
if (rtlpriv->link_info.busytraffic) if (rtlpriv->link_info.busytraffic)
return; return;
spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flag); spin_lock(&rtlpriv->locks.rf_ps_lock);
if (rtlpriv->psc.rfchange_inprogress) { if (rtlpriv->psc.rfchange_inprogress) {
spin_unlock_irqrestore(&rtlpriv->locks.rf_ps_lock, flag); spin_unlock(&rtlpriv->locks.rf_ps_lock);
return; return;
} }
spin_unlock_irqrestore(&rtlpriv->locks.rf_ps_lock, flag); spin_unlock(&rtlpriv->locks.rf_ps_lock);
spin_lock_irqsave(&rtlpriv->locks.lps_lock, flag); spin_lock(&rtlpriv->locks.lps_lock);
rtl_ps_set_rf_state(hw, ERFSLEEP, RF_CHANGE_BY_PS, false); rtl_ps_set_rf_state(hw, ERFSLEEP, RF_CHANGE_BY_PS, false);
spin_unlock_irqrestore(&rtlpriv->locks.lps_lock, flag); spin_unlock(&rtlpriv->locks.lps_lock);
if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_ASPM && if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_ASPM &&
!RT_IN_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM)) { !RT_IN_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM)) {

View File

@ -46,13 +46,12 @@ u32 rtl92c_phy_query_rf_reg(struct ieee80211_hw *hw,
struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_priv *rtlpriv = rtl_priv(hw);
u32 original_value, readback_value, bitshift; u32 original_value, readback_value, bitshift;
struct rtl_phy *rtlphy = &(rtlpriv->phy); struct rtl_phy *rtlphy = &(rtlpriv->phy);
unsigned long flags;
RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), "
"rfpath(%#x), bitmask(%#x)\n", "rfpath(%#x), bitmask(%#x)\n",
regaddr, rfpath, bitmask)); regaddr, rfpath, bitmask));
spin_lock_irqsave(&rtlpriv->locks.rf_lock, flags); spin_lock(&rtlpriv->locks.rf_lock);
if (rtlphy->rf_mode != RF_OP_BY_FW) { if (rtlphy->rf_mode != RF_OP_BY_FW) {
original_value = _rtl92c_phy_rf_serial_read(hw, original_value = _rtl92c_phy_rf_serial_read(hw,
@ -65,7 +64,7 @@ u32 rtl92c_phy_query_rf_reg(struct ieee80211_hw *hw,
bitshift = _rtl92c_phy_calculate_bit_shift(bitmask); bitshift = _rtl92c_phy_calculate_bit_shift(bitmask);
readback_value = (original_value & bitmask) >> bitshift; readback_value = (original_value & bitmask) >> bitshift;
spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags); spin_unlock(&rtlpriv->locks.rf_lock);
RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
("regaddr(%#x), rfpath(%#x), " ("regaddr(%#x), rfpath(%#x), "
@ -120,13 +119,12 @@ void rtl92ce_phy_set_rf_reg(struct ieee80211_hw *hw,
struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_phy *rtlphy = &(rtlpriv->phy); struct rtl_phy *rtlphy = &(rtlpriv->phy);
u32 original_value, bitshift; u32 original_value, bitshift;
unsigned long flags;
RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
("regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n", ("regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
regaddr, bitmask, data, rfpath)); regaddr, bitmask, data, rfpath));
spin_lock_irqsave(&rtlpriv->locks.rf_lock, flags); spin_lock(&rtlpriv->locks.rf_lock);
if (rtlphy->rf_mode != RF_OP_BY_FW) { if (rtlphy->rf_mode != RF_OP_BY_FW) {
if (bitmask != RFREG_OFFSET_MASK) { if (bitmask != RFREG_OFFSET_MASK) {
@ -153,7 +151,7 @@ void rtl92ce_phy_set_rf_reg(struct ieee80211_hw *hw,
_rtl92c_phy_fw_rf_serial_write(hw, rfpath, regaddr, data); _rtl92c_phy_fw_rf_serial_write(hw, rfpath, regaddr, data);
} }
spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags); spin_unlock(&rtlpriv->locks.rf_lock);
RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), "
"bitmask(%#x), data(%#x), " "bitmask(%#x), data(%#x), "

View File

@ -180,19 +180,18 @@ u32 rtl92s_phy_query_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
{ {
struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_priv *rtlpriv = rtl_priv(hw);
u32 original_value, readback_value, bitshift; u32 original_value, readback_value, bitshift;
unsigned long flags;
RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), rfpath(%#x), " RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), rfpath(%#x), "
"bitmask(%#x)\n", regaddr, rfpath, bitmask)); "bitmask(%#x)\n", regaddr, rfpath, bitmask));
spin_lock_irqsave(&rtlpriv->locks.rf_lock, flags); spin_lock(&rtlpriv->locks.rf_lock);
original_value = _rtl92s_phy_rf_serial_read(hw, rfpath, regaddr); original_value = _rtl92s_phy_rf_serial_read(hw, rfpath, regaddr);
bitshift = _rtl92s_phy_calculate_bit_shift(bitmask); bitshift = _rtl92s_phy_calculate_bit_shift(bitmask);
readback_value = (original_value & bitmask) >> bitshift; readback_value = (original_value & bitmask) >> bitshift;
spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags); spin_unlock(&rtlpriv->locks.rf_lock);
RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), rfpath(%#x), " RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), rfpath(%#x), "
"bitmask(%#x), original_value(%#x)\n", regaddr, rfpath, "bitmask(%#x), original_value(%#x)\n", regaddr, rfpath,
@ -207,7 +206,6 @@ void rtl92s_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_phy *rtlphy = &(rtlpriv->phy); struct rtl_phy *rtlphy = &(rtlpriv->phy);
u32 original_value, bitshift; u32 original_value, bitshift;
unsigned long flags;
if (!((rtlphy->rf_pathmap >> rfpath) & 0x1)) if (!((rtlphy->rf_pathmap >> rfpath) & 0x1))
return; return;
@ -215,7 +213,7 @@ void rtl92s_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)," RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x),"
" data(%#x), rfpath(%#x)\n", regaddr, bitmask, data, rfpath)); " data(%#x), rfpath(%#x)\n", regaddr, bitmask, data, rfpath));
spin_lock_irqsave(&rtlpriv->locks.rf_lock, flags); spin_lock(&rtlpriv->locks.rf_lock);
if (bitmask != RFREG_OFFSET_MASK) { if (bitmask != RFREG_OFFSET_MASK) {
original_value = _rtl92s_phy_rf_serial_read(hw, rfpath, original_value = _rtl92s_phy_rf_serial_read(hw, rfpath,
@ -226,7 +224,7 @@ void rtl92s_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
_rtl92s_phy_rf_serial_write(hw, rfpath, regaddr, data); _rtl92s_phy_rf_serial_write(hw, rfpath, regaddr, data);
spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags); spin_unlock(&rtlpriv->locks.rf_lock);
RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x), " RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x), "
"data(%#x), rfpath(%#x)\n", regaddr, bitmask, data, rfpath)); "data(%#x), rfpath(%#x)\n", regaddr, bitmask, data, rfpath));