From: Zhan Xusheng <zhanxusheng1024@gmail.com>
To: Miri Korenblit <miriam.rachel.korenblit@intel.com>,
linux-wireless@vger.kernel.org
Cc: Johannes Berg <johannes.berg@intel.com>,
Richard Cochran <richardcochran@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
zhanxusheng@xiaomi.com
Subject: [PATCH 0/2] wifi: iwlwifi: Fix GP2 to nanoseconds overflow on 32-bit
Date: Wed, 5 Aug 2026 16:25:13 +0800 [thread overview]
Message-ID: <20260805082515.4136842-1-zhanxusheng@xiaomi.com> (raw)
GP2 is a free-running 32-bit microsecond hardware counter. Both the mvm
and mld PTP code convert a u32 GP2 value to nanoseconds with
gp2 * NSEC_PER_USEC
NSEC_PER_USEC is a plain 'long' (1000L), so on 32-bit builds the
multiplication is performed in 32-bit arithmetic and overflows once the
GP2 value exceeds ~4.29 million microseconds (~4.3 s). Since GP2 wraps
only every 2^32 microseconds (~71.5 min), the product is truncated for
almost the entire counter range, producing bogus PTP timestamps.
Most conversions in the same files already cast to u64 first
((u64)gp2 * NSEC_PER_USEC); a handful of sites (the adjfine path, the
stored scale_update_gp2 and the monitor/RX timestamp path) simply missed
the cast. These patches add the missing u64 casts so the multiplications
are done in 64-bit, matching the existing call sites. 64-bit builds are
unaffected. The mld driver inherited the same pattern (and bug) from
mvm, so it is fixed in a separate patch with its own Fixes: tags.
Found by code inspection; not tested on 32-bit hardware. The change is a
straightforward u64 cast matching the surrounding code.
Zhan Xusheng (2):
wifi: iwlwifi: mvm: Fix GP2 to nanoseconds overflow on 32-bit
wifi: iwlwifi: mld: Fix GP2 to nanoseconds overflow on 32-bit
drivers/net/wireless/intel/iwlwifi/mld/ptp.c | 4 ++--
drivers/net/wireless/intel/iwlwifi/mld/rx.c | 6 ++----
drivers/net/wireless/intel/iwlwifi/mvm/ptp.c | 4 ++--
drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 4 ++--
4 files changed, 8 insertions(+), 10 deletions(-)
--
2.43.0
next reply other threads:[~2026-08-05 8:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 8:25 Zhan Xusheng [this message]
2026-08-05 8:25 ` [PATCH 1/2] wifi: iwlwifi: mvm: Fix GP2 to nanoseconds overflow on 32-bit Zhan Xusheng
2026-08-05 8:25 ` [PATCH 2/2] wifi: iwlwifi: mld: " Zhan Xusheng
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=20260805082515.4136842-1-zhanxusheng@xiaomi.com \
--to=zhanxusheng1024@gmail.com \
--cc=johannes.berg@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=miriam.rachel.korenblit@intel.com \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=zhanxusheng@xiaomi.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