From: "Loïc Kassel via B4 Relay" <devnull+loic.kassel.gmail.com@kernel.org>
To: Johannes Berg <johannes@sipsolutions.net>,
Benjamin Berg <benjamin.berg@intel.com>,
Miri Korenblit <miriam.rachel.korenblit@intel.com>
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
"Loïc Kassel" <loic.kassel@gmail.com>
Subject: [PATCH wireless] wifi: mac80211_hwsim: use CLOCK_BOOTTIME for the beacon timer
Date: Fri, 23 Oct 2026 19:21:54 +0200 [thread overview]
Message-ID: <20261023-hwsim-beacon-clock-v1-1-9b3f3ffc099b@gmail.com> (raw)
From: Loïc Kassel <loic.kassel@gmail.com>
The simulated TSF is based on boottime, and the beacon timer is re-armed
with an absolute expiry derived from the TSF through
mac80211_hwsim_tsf_to_boottime(). The timer itself is however still set
up with CLOCK_MONOTONIC.
Boottime keeps running while the system is suspended, monotonic does
not. After the host has been suspended once, every beacon is therefore
scheduled too late by the total time spent in suspend, and APs
practically stop sending beacons.
Set the beacon timer up with CLOCK_BOOTTIME so that it is consistent
with the TSF.
The bug was analysed, and this change and commit message drafted, with
the help of an AI assistant (Claude, Opus 5.5). I reviewed the change
and tested it on v7.2.11 (Fedora 44), applying the same one-line change
to that kernel's mac80211_hwsim and loading it as an out-of-tree module.
With hostapd started after a suspend (boottime 61 s ahead of monotonic),
an associated station received about 10 beacons per second with no
beacon loss, and scans found all APs. With the unmodified module, in the
same situation, beacons practically stopped and APs without associated
stations were not found by scans.
Fixes: 933f5bec98a1 ("wifi: mac80211_hwsim: register beacon timer by calculating TBTT")
Closes: https://lore.kernel.org/linux-wireless/CAAzpgGdksHZjx4jc20zqnAG_PQ2e1ggANQjt2eiycUiWc+vPHg@mail.gmail.com/
Signed-off-by: Loïc Kassel <loic.kassel@gmail.com>
---
Benjamin confirmed the analysis in the report thread and suggested that
I send the fix myself. This is my first kernel patch.
---
drivers/net/wireless/virtual/mac80211_hwsim_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim_main.c b/drivers/net/wireless/virtual/mac80211_hwsim_main.c
index b9446577ff..203bf9a4b9 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim_main.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim_main.c
@@ -6136,7 +6136,7 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
for (i = 0; i < ARRAY_SIZE(data->link_data); i++) {
hrtimer_setup(&data->link_data[i].beacon_timer, mac80211_hwsim_beacon,
- CLOCK_MONOTONIC, HRTIMER_MODE_ABS_SOFT);
+ CLOCK_BOOTTIME, HRTIMER_MODE_ABS_SOFT);
data->link_data[i].link_id = i;
}
---
base-commit: 9d8ec0b5b5295bd23d979d1b2b905de25c36fff2
change-id: 20261023-hwsim-beacon-clock-ea8fe1d0c998
Best regards,
--
Loïc Kassel <loic.kassel@gmail.com>
reply other threads:[~2026-10-23 17:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261023-hwsim-beacon-clock-v1-1-9b3f3ffc099b@gmail.com \
--to=devnull+loic.kassel.gmail.com@kernel.org \
--cc=benjamin.berg@intel.com \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=loic.kassel@gmail.com \
--cc=miriam.rachel.korenblit@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®