Commit 99f6996d authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Kalle Valo

wlcore: use boottime for fw time sync

Using getnstimeofday()/timespec_to_ns() causes an overflow on 32-bit
architectures in 2038, and may suffer from time jumps due to
settimeofday() or leap seconds.

I don't see a reason why this needs to be UTC, so either monotonic
or boot time would be better here. Assuming that the fw time keeps
running during suspend, boottime is better than monotonic, and
ktime_get_boot_ns() will also save the additional conversion to
nanoseconds.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 4628257b
...@@ -388,7 +388,6 @@ static void wl12xx_irq_update_links_status(struct wl1271 *wl, ...@@ -388,7 +388,6 @@ static void wl12xx_irq_update_links_status(struct wl1271 *wl,
static int wlcore_fw_status(struct wl1271 *wl, struct wl_fw_status *status) static int wlcore_fw_status(struct wl1271 *wl, struct wl_fw_status *status)
{ {
struct wl12xx_vif *wlvif; struct wl12xx_vif *wlvif;
struct timespec ts;
u32 old_tx_blk_count = wl->tx_blocks_available; u32 old_tx_blk_count = wl->tx_blocks_available;
int avail, freed_blocks; int avail, freed_blocks;
int i; int i;
...@@ -485,8 +484,7 @@ static int wlcore_fw_status(struct wl1271 *wl, struct wl_fw_status *status) ...@@ -485,8 +484,7 @@ static int wlcore_fw_status(struct wl1271 *wl, struct wl_fw_status *status)
} }
/* update the host-chipset time offset */ /* update the host-chipset time offset */
getnstimeofday(&ts); wl->time_offset = (ktime_get_boot_ns() >> 10) -
wl->time_offset = (timespec_to_ns(&ts) >> 10) -
(s64)(status->fw_localtime); (s64)(status->fw_localtime);
wl->fw_fast_lnk_map = status->link_fast_bitmap; wl->fw_fast_lnk_map = status->link_fast_bitmap;
......
...@@ -264,7 +264,6 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif, ...@@ -264,7 +264,6 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif,
struct sk_buff *skb, u32 extra, struct sk_buff *skb, u32 extra,
struct ieee80211_tx_info *control, u8 hlid) struct ieee80211_tx_info *control, u8 hlid)
{ {
struct timespec ts;
struct wl1271_tx_hw_descr *desc; struct wl1271_tx_hw_descr *desc;
int ac, rate_idx; int ac, rate_idx;
s64 hosttime; s64 hosttime;
...@@ -287,8 +286,7 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif, ...@@ -287,8 +286,7 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif,
} }
/* configure packet life time */ /* configure packet life time */
getnstimeofday(&ts); hosttime = (ktime_get_boot_ns() >> 10);
hosttime = (timespec_to_ns(&ts) >> 10);
desc->start_time = cpu_to_le32(hosttime - wl->time_offset); desc->start_time = cpu_to_le32(hosttime - wl->time_offset);
is_dummy = wl12xx_is_dummy_packet(wl, skb); is_dummy = wl12xx_is_dummy_packet(wl, skb);
......
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