[PATCH rtw-next v5 2/3] wifi: rtw88: update the beacon from a wiphy work
From: Mehmet Fide
Date: Thu Oct 08 2026 - 02:24:42 EST
From: Mehmet Fide <mehmet.fide@xxxxxxxxxxxxxxxxxx>
set_tim() queues update_beacon_work to rebuild the reserved page with
the new TIM. Make it a wiphy work so that it runs under the wiphy lock
like the other beacon downloads and can look at mac80211 state; the
next patch needs that to tell whether a channel switch is being
announced.
rtw_core_stop() runs without the wiphy lock on the IPS path and can no
longer cancel the work, so the work checks RTW_FLAG_RUNNING under the
driver mutex instead, as the watchdog and the C2H work do.
Signed-off-by: Mehmet Fide <mehmet.fide@xxxxxxxxxxxxxxxxxx>
---
New in v5.
drivers/net/wireless/realtek/rtw88/fw.c | 10 +++++++++-
drivers/net/wireless/realtek/rtw88/fw.h | 2 +-
drivers/net/wireless/realtek/rtw88/mac80211.c | 2 +-
drivers/net/wireless/realtek/rtw88/main.c | 4 ++--
drivers/net/wireless/realtek/rtw88/main.h | 2 +-
5 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c
index 3cd17a3bb494..e01d79a70e37 100644
--- a/drivers/net/wireless/realtek/rtw88/fw.c
+++ b/drivers/net/wireless/realtek/rtw88/fw.c
@@ -1802,14 +1802,22 @@ int rtw_fw_download_rsvd_page(struct rtw_dev *rtwdev)
return ret;
}
-void rtw_fw_update_beacon_work(struct work_struct *work)
+void rtw_fw_update_beacon_work(struct wiphy *wiphy, struct wiphy_work *work)
{
struct rtw_dev *rtwdev = container_of(work, struct rtw_dev,
update_beacon_work);
+ lockdep_assert_wiphy(wiphy);
+
mutex_lock(&rtwdev->mutex);
+
+ if (!test_bit(RTW_FLAG_RUNNING, rtwdev->flags))
+ goto out;
+
rtw_fw_download_rsvd_page(rtwdev);
rtw_send_rsvd_page_h2c(rtwdev);
+
+out:
mutex_unlock(&rtwdev->mutex);
}
diff --git a/drivers/net/wireless/realtek/rtw88/fw.h b/drivers/net/wireless/realtek/rtw88/fw.h
index 48ad9ceab6ea..d433f454094d 100644
--- a/drivers/net/wireless/realtek/rtw88/fw.h
+++ b/drivers/net/wireless/realtek/rtw88/fw.h
@@ -863,7 +863,7 @@ void rtw_add_rsvd_page_pno(struct rtw_dev *rtwdev,
void rtw_add_rsvd_page_sta(struct rtw_dev *rtwdev,
struct rtw_vif *rtwvif);
int rtw_fw_download_rsvd_page(struct rtw_dev *rtwdev);
-void rtw_fw_update_beacon_work(struct work_struct *work);
+void rtw_fw_update_beacon_work(struct wiphy *wiphy, struct wiphy_work *work);
void rtw_send_rsvd_page_h2c(struct rtw_dev *rtwdev);
int rtw_dump_drv_rsvd_page(struct rtw_dev *rtwdev,
u32 offset, u32 size, u32 *buf);
diff --git a/drivers/net/wireless/realtek/rtw88/mac80211.c b/drivers/net/wireless/realtek/rtw88/mac80211.c
index 2a9b09fa76e7..7fcf91bfe761 100644
--- a/drivers/net/wireless/realtek/rtw88/mac80211.c
+++ b/drivers/net/wireless/realtek/rtw88/mac80211.c
@@ -551,7 +551,7 @@ static int rtw_ops_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
{
struct rtw_dev *rtwdev = hw->priv;
- ieee80211_queue_work(hw, &rtwdev->update_beacon_work);
+ wiphy_work_queue(hw->wiphy, &rtwdev->update_beacon_work);
return 0;
}
diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
index 0f23498b5c96..647393af9fd9 100644
--- a/drivers/net/wireless/realtek/rtw88/main.c
+++ b/drivers/net/wireless/realtek/rtw88/main.c
@@ -1554,7 +1554,6 @@ void rtw_core_stop(struct rtw_dev *rtwdev)
mutex_unlock(&rtwdev->mutex);
cancel_work_sync(&rtwdev->c2h_work);
- cancel_work_sync(&rtwdev->update_beacon_work);
cancel_delayed_work_sync(&rtwdev->watch_dog_work);
cancel_delayed_work_sync(&coex->bt_relink_work);
cancel_delayed_work_sync(&coex->bt_reenable_work);
@@ -2169,7 +2168,8 @@ int rtw_core_init(struct rtw_dev *rtwdev)
INIT_WORK(&rtwdev->c2h_work, rtw_c2h_work);
INIT_WORK(&rtwdev->ips_work, rtw_ips_work);
INIT_WORK(&rtwdev->fw_recovery_work, rtw_fw_recovery_work);
- INIT_WORK(&rtwdev->update_beacon_work, rtw_fw_update_beacon_work);
+ wiphy_work_init(&rtwdev->update_beacon_work,
+ rtw_fw_update_beacon_work);
INIT_WORK(&rtwdev->ba_work, rtw_txq_ba_work);
skb_queue_head_init(&rtwdev->c2h_queue);
skb_queue_head_init(&rtwdev->coex.queue);
diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h
index d59f6e323adf..bb48529759c3 100644
--- a/drivers/net/wireless/realtek/rtw88/main.h
+++ b/drivers/net/wireless/realtek/rtw88/main.h
@@ -2093,7 +2093,7 @@ struct rtw_dev {
struct work_struct c2h_work;
struct work_struct ips_work;
struct work_struct fw_recovery_work;
- struct work_struct update_beacon_work;
+ struct wiphy_work update_beacon_work;
/* used to protect txqs list */
spinlock_t txq_lock;
--
2.55.0