Commit a27238a0 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: mt7615: set macwork timeout according to runtime-pm

Set macwork timeout value according to runtime-pm in order to reduce
power consumption
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 8aff2d91
...@@ -1954,9 +1954,14 @@ void mt7615_pm_wake_work(struct work_struct *work) ...@@ -1954,9 +1954,14 @@ void mt7615_pm_wake_work(struct work_struct *work)
mt76_queue_tx_cleanup(dev, mdev->q_mcu[MT_MCUQ_WM], mt76_queue_tx_cleanup(dev, mdev->q_mcu[MT_MCUQ_WM],
false); false);
} }
if (test_bit(MT76_STATE_RUNNING, &mphy->state))
if (test_bit(MT76_STATE_RUNNING, &mphy->state)) {
unsigned long timeout;
timeout = mt7615_get_macwork_timeout(dev);
ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work,
MT7615_WATCHDOG_TIME); timeout);
}
} }
ieee80211_wake_queues(mphy->hw); ieee80211_wake_queues(mphy->hw);
...@@ -1991,6 +1996,7 @@ void mt7615_mac_work(struct work_struct *work) ...@@ -1991,6 +1996,7 @@ void mt7615_mac_work(struct work_struct *work)
{ {
struct mt7615_phy *phy; struct mt7615_phy *phy;
struct mt76_phy *mphy; struct mt76_phy *mphy;
unsigned long timeout;
mphy = (struct mt76_phy *)container_of(work, struct mt76_phy, mphy = (struct mt76_phy *)container_of(work, struct mt76_phy,
mac_work.work); mac_work.work);
...@@ -2009,8 +2015,9 @@ void mt7615_mac_work(struct work_struct *work) ...@@ -2009,8 +2015,9 @@ void mt7615_mac_work(struct work_struct *work)
mt7615_mutex_release(phy->dev); mt7615_mutex_release(phy->dev);
mt76_tx_status_check(mphy->dev, NULL, false); mt76_tx_status_check(mphy->dev, NULL, false);
ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work,
MT7615_WATCHDOG_TIME); timeout = mt7615_get_macwork_timeout(phy->dev);
ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work, timeout);
} }
void mt7615_tx_token_put(struct mt7615_dev *dev) void mt7615_tx_token_put(struct mt7615_dev *dev)
......
...@@ -28,6 +28,7 @@ static int mt7615_start(struct ieee80211_hw *hw) ...@@ -28,6 +28,7 @@ static int mt7615_start(struct ieee80211_hw *hw)
{ {
struct mt7615_dev *dev = mt7615_hw_dev(hw); struct mt7615_dev *dev = mt7615_hw_dev(hw);
struct mt7615_phy *phy = mt7615_hw_phy(hw); struct mt7615_phy *phy = mt7615_hw_phy(hw);
unsigned long timeout;
bool running; bool running;
int ret; int ret;
...@@ -78,8 +79,8 @@ static int mt7615_start(struct ieee80211_hw *hw) ...@@ -78,8 +79,8 @@ static int mt7615_start(struct ieee80211_hw *hw)
set_bit(MT76_STATE_RUNNING, &phy->mt76->state); set_bit(MT76_STATE_RUNNING, &phy->mt76->state);
ieee80211_queue_delayed_work(hw, &phy->mt76->mac_work, timeout = mt7615_get_macwork_timeout(dev);
MT7615_WATCHDOG_TIME); ieee80211_queue_delayed_work(hw, &phy->mt76->mac_work, timeout);
if (!running) if (!running)
mt7615_mac_reset_counters(dev); mt7615_mac_reset_counters(dev);
...@@ -350,10 +351,12 @@ int mt7615_set_channel(struct mt7615_phy *phy) ...@@ -350,10 +351,12 @@ int mt7615_set_channel(struct mt7615_phy *phy)
mt7615_mutex_release(dev); mt7615_mutex_release(dev);
mt76_worker_schedule(&dev->mt76.tx_worker); mt76_worker_schedule(&dev->mt76.tx_worker);
if (!mt76_testmode_enabled(phy->mt76)) if (!mt76_testmode_enabled(phy->mt76)) {
unsigned long timeout = mt7615_get_macwork_timeout(dev);
ieee80211_queue_delayed_work(phy->mt76->hw, ieee80211_queue_delayed_work(phy->mt76->hw,
&phy->mt76->mac_work, &phy->mt76->mac_work, timeout);
MT7615_WATCHDOG_TIME); }
return ret; return ret;
} }
...@@ -1225,6 +1228,7 @@ static int mt7615_resume(struct ieee80211_hw *hw) ...@@ -1225,6 +1228,7 @@ static int mt7615_resume(struct ieee80211_hw *hw)
{ {
struct mt7615_phy *phy = mt7615_hw_phy(hw); struct mt7615_phy *phy = mt7615_hw_phy(hw);
struct mt7615_dev *dev = mt7615_hw_dev(hw); struct mt7615_dev *dev = mt7615_hw_dev(hw);
unsigned long timeout;
bool running; bool running;
mt7615_mutex_acquire(dev); mt7615_mutex_acquire(dev);
...@@ -1248,8 +1252,8 @@ static int mt7615_resume(struct ieee80211_hw *hw) ...@@ -1248,8 +1252,8 @@ static int mt7615_resume(struct ieee80211_hw *hw)
mt76_connac_mcu_set_suspend_iter, mt76_connac_mcu_set_suspend_iter,
phy->mt76); phy->mt76);
ieee80211_queue_delayed_work(hw, &phy->mt76->mac_work, timeout = mt7615_get_macwork_timeout(dev);
MT7615_WATCHDOG_TIME); ieee80211_queue_delayed_work(hw, &phy->mt76->mac_work, timeout);
mt7615_mutex_release(dev); mt7615_mutex_release(dev);
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
MT7615_MAX_INTERFACES) MT7615_MAX_INTERFACES)
#define MT7615_PM_TIMEOUT (HZ / 12) #define MT7615_PM_TIMEOUT (HZ / 12)
#define MT7615_WATCHDOG_TIME (HZ / 10)
#define MT7615_HW_SCAN_TIMEOUT (HZ / 10) #define MT7615_HW_SCAN_TIMEOUT (HZ / 10)
#define MT7615_RESET_TIMEOUT (30 * HZ) #define MT7615_RESET_TIMEOUT (30 * HZ)
#define MT7615_RATE_RETRY 2 #define MT7615_RATE_RETRY 2
...@@ -461,6 +460,12 @@ static inline u32 mt7615_tx_mcu_int_mask(struct mt7615_dev *dev) ...@@ -461,6 +460,12 @@ static inline u32 mt7615_tx_mcu_int_mask(struct mt7615_dev *dev)
return MT_INT_TX_DONE(dev->mt76.q_mcu[MT_MCUQ_WM]->hw_idx); return MT_INT_TX_DONE(dev->mt76.q_mcu[MT_MCUQ_WM]->hw_idx);
} }
static inline unsigned long
mt7615_get_macwork_timeout(struct mt7615_dev *dev)
{
return dev->pm.enable ? HZ / 3 : HZ / 10;
}
void mt7615_dma_reset(struct mt7615_dev *dev); void mt7615_dma_reset(struct mt7615_dev *dev);
void mt7615_scan_work(struct work_struct *work); void mt7615_scan_work(struct work_struct *work);
void mt7615_roc_work(struct work_struct *work); void mt7615_roc_work(struct work_struct *work);
......
...@@ -268,6 +268,7 @@ void mt7615_mac_reset_work(struct work_struct *work) ...@@ -268,6 +268,7 @@ void mt7615_mac_reset_work(struct work_struct *work)
struct mt7615_phy *phy2; struct mt7615_phy *phy2;
struct mt76_phy *ext_phy; struct mt76_phy *ext_phy;
struct mt7615_dev *dev; struct mt7615_dev *dev;
unsigned long timeout;
dev = container_of(work, struct mt7615_dev, reset_work); dev = container_of(work, struct mt7615_dev, reset_work);
ext_phy = dev->mt76.phy2; ext_phy = dev->mt76.phy2;
...@@ -345,11 +346,11 @@ void mt7615_mac_reset_work(struct work_struct *work) ...@@ -345,11 +346,11 @@ void mt7615_mac_reset_work(struct work_struct *work)
mt7615_mutex_release(dev); mt7615_mutex_release(dev);
timeout = mt7615_get_macwork_timeout(dev);
ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mphy.mac_work, ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mphy.mac_work,
MT7615_WATCHDOG_TIME); timeout);
if (phy2) if (phy2)
ieee80211_queue_delayed_work(ext_phy->hw, ieee80211_queue_delayed_work(ext_phy->hw,
&phy2->mt76->mac_work, &phy2->mt76->mac_work, timeout);
MT7615_WATCHDOG_TIME);
} }
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