@@ -1001,22 +1001,27 @@ void mt7921_mac_tx_free(struct mt7921_dev *dev, struct sk_buff *skb)
1001
1001
mt76_put_txwi (mdev , txwi );
1002
1002
}
1003
1003
1004
- mt7921_mac_sta_poll (dev );
1005
-
1006
1004
if (wake ) {
1007
1005
spin_lock_bh (& dev -> token_lock );
1008
1006
mt7921_set_tx_blocked (dev , false);
1009
1007
spin_unlock_bh (& dev -> token_lock );
1010
1008
}
1011
1009
1012
- mt76_worker_schedule (& dev -> mt76 .tx_worker );
1013
-
1014
1010
napi_consume_skb (skb , 1 );
1015
1011
1016
1012
list_for_each_entry_safe (skb , tmp , & free_list , list ) {
1017
1013
skb_list_del_init (skb );
1018
1014
napi_consume_skb (skb , 1 );
1019
1015
}
1016
+
1017
+ if (test_bit (MT76_STATE_PM , & dev -> phy .mt76 -> state ))
1018
+ return ;
1019
+
1020
+ mt7921_mac_sta_poll (dev );
1021
+
1022
+ mt76_connac_power_save_sched (& dev -> mphy , & dev -> pm );
1023
+
1024
+ mt76_worker_schedule (& dev -> mt76 .tx_worker );
1020
1025
}
1021
1026
1022
1027
void mt7921_tx_complete_skb (struct mt76_dev * mdev , struct mt76_queue_entry * e )
@@ -1166,9 +1171,14 @@ void mt7921_update_channel(struct mt76_dev *mdev)
1166
1171
{
1167
1172
struct mt7921_dev * dev = container_of (mdev , struct mt7921_dev , mt76 );
1168
1173
1174
+ if (mt76_connac_pm_wake (& dev -> mphy , & dev -> pm ))
1175
+ return ;
1176
+
1169
1177
mt7921_phy_update_channel (& mdev -> phy , 0 );
1170
1178
/* reset obss airtime */
1171
1179
mt76_set (dev , MT_WF_RMAC_MIB_TIME0 (0 ), MT_WF_RMAC_MIB_RXTIME_CLR );
1180
+
1181
+ mt76_connac_power_save_sched (& dev -> mphy , & dev -> pm );
1172
1182
}
1173
1183
1174
1184
static bool
@@ -1257,7 +1267,7 @@ void mt7921_mac_reset_work(struct work_struct *work)
1257
1267
napi_disable (& dev -> mt76 .napi [2 ]);
1258
1268
napi_disable (& dev -> mt76 .tx_napi );
1259
1269
1260
- mutex_lock ( & dev -> mt76 . mutex );
1270
+ mt7921_mutex_acquire ( dev );
1261
1271
1262
1272
mt76_wr (dev , MT_MCU_INT_EVENT , MT_MCU_INT_EVENT_DMA_STOPPED );
1263
1273
@@ -1292,7 +1302,7 @@ void mt7921_mac_reset_work(struct work_struct *work)
1292
1302
mt76_wr (dev , MT_MCU_INT_EVENT , MT_MCU_INT_EVENT_RESET_DONE );
1293
1303
mt7921_wait_reset_state (dev , MT_MCU_CMD_NORMAL_STATE );
1294
1304
1295
- mutex_unlock ( & dev -> mt76 . mutex );
1305
+ mt7921_mutex_release ( dev );
1296
1306
1297
1307
ieee80211_queue_delayed_work (mt76_hw (dev ), & dev -> mphy .mac_work ,
1298
1308
MT7921_WATCHDOG_TIME );
@@ -1373,7 +1383,10 @@ void mt7921_mac_work(struct work_struct *work)
1373
1383
mac_work .work );
1374
1384
phy = mphy -> priv ;
1375
1385
1376
- mutex_lock (& mphy -> dev -> mutex );
1386
+ if (test_bit (MT76_STATE_PM , & mphy -> state ))
1387
+ goto out ;
1388
+
1389
+ mt7921_mutex_acquire (phy -> dev );
1377
1390
1378
1391
mt76_update_survey (mphy -> dev );
1379
1392
if (++ mphy -> mac_work_count == 5 ) {
@@ -1386,8 +1399,75 @@ void mt7921_mac_work(struct work_struct *work)
1386
1399
mt7921_mac_sta_stats_work (phy );
1387
1400
};
1388
1401
1389
- mutex_unlock ( & mphy -> dev -> mutex );
1402
+ mt7921_mutex_release ( phy -> dev );
1390
1403
1391
- ieee80211_queue_delayed_work (mphy -> hw , & mphy -> mac_work ,
1404
+ out :
1405
+ ieee80211_queue_delayed_work (phy -> mt76 -> hw , & mphy -> mac_work ,
1392
1406
MT7921_WATCHDOG_TIME );
1393
1407
}
1408
+
1409
+ void mt7921_pm_wake_work (struct work_struct * work )
1410
+ {
1411
+ struct mt7921_dev * dev ;
1412
+ struct mt76_phy * mphy ;
1413
+
1414
+ dev = (struct mt7921_dev * )container_of (work , struct mt7921_dev ,
1415
+ pm .wake_work );
1416
+ mphy = dev -> phy .mt76 ;
1417
+
1418
+ if (!mt7921_mcu_drv_pmctrl (dev ))
1419
+ mt76_connac_pm_dequeue_skbs (mphy , & dev -> pm );
1420
+ else
1421
+ dev_err (mphy -> dev -> dev , "failed to wake device\n" );
1422
+
1423
+ ieee80211_wake_queues (mphy -> hw );
1424
+ complete_all (& dev -> pm .wake_cmpl );
1425
+ }
1426
+
1427
+ void mt7921_pm_power_save_work (struct work_struct * work )
1428
+ {
1429
+ struct mt7921_dev * dev ;
1430
+ unsigned long delta ;
1431
+
1432
+ dev = (struct mt7921_dev * )container_of (work , struct mt7921_dev ,
1433
+ pm .ps_work .work );
1434
+
1435
+ delta = dev -> pm .idle_timeout ;
1436
+ if (time_is_after_jiffies (dev -> pm .last_activity + delta )) {
1437
+ delta = dev -> pm .last_activity + delta - jiffies ;
1438
+ goto out ;
1439
+ }
1440
+
1441
+ if (!mt7921_mcu_fw_pmctrl (dev ))
1442
+ return ;
1443
+ out :
1444
+ queue_delayed_work (dev -> mt76 .wq , & dev -> pm .ps_work , delta );
1445
+ }
1446
+
1447
+ int mt7921_mac_set_beacon_filter (struct mt7921_phy * phy ,
1448
+ struct ieee80211_vif * vif ,
1449
+ bool enable )
1450
+ {
1451
+ struct mt7921_dev * dev = phy -> dev ;
1452
+ bool ext_phy = phy != & dev -> phy ;
1453
+ int err ;
1454
+
1455
+ if (!dev -> pm .enable )
1456
+ return - EOPNOTSUPP ;
1457
+
1458
+ err = mt7921_mcu_set_bss_pm (dev , vif , enable );
1459
+ if (err )
1460
+ return err ;
1461
+
1462
+ if (enable ) {
1463
+ vif -> driver_flags |= IEEE80211_VIF_BEACON_FILTER ;
1464
+ mt76_set (dev , MT_WF_RFCR (ext_phy ),
1465
+ MT_WF_RFCR_DROP_OTHER_BEACON );
1466
+ } else {
1467
+ vif -> driver_flags &= ~IEEE80211_VIF_BEACON_FILTER ;
1468
+ mt76_clear (dev , MT_WF_RFCR (ext_phy ),
1469
+ MT_WF_RFCR_DROP_OTHER_BEACON );
1470
+ }
1471
+
1472
+ return 0 ;
1473
+ }
0 commit comments