aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2017-11-27 06:48:19 -0500
committerKalle Valo <kvalo@codeaurora.org>2017-12-07 08:20:01 -0500
commit99f6996d4cba794f0d65d2e58a1b5b7341bdebda (patch)
treeac8df3860e290eb1d0884e4e59b558fd6ca32018
parent4628257bf3006c18e0037459922624f02a138aed (diff)
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: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
-rw-r--r--drivers/net/wireless/ti/wlcore/main.c4
-rw-r--r--drivers/net/wireless/ti/wlcore/tx.c4
2 files changed, 2 insertions, 6 deletions
diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c
index d47921a84509..946a7124b09e 100644
--- a/drivers/net/wireless/ti/wlcore/main.c
+++ b/drivers/net/wireless/ti/wlcore/main.c
@@ -388,7 +388,6 @@ static void wl12xx_irq_update_links_status(struct wl1271 *wl,
388static int wlcore_fw_status(struct wl1271 *wl, struct wl_fw_status *status) 388static int wlcore_fw_status(struct wl1271 *wl, struct wl_fw_status *status)
389{ 389{
390 struct wl12xx_vif *wlvif; 390 struct wl12xx_vif *wlvif;
391 struct timespec ts;
392 u32 old_tx_blk_count = wl->tx_blocks_available; 391 u32 old_tx_blk_count = wl->tx_blocks_available;
393 int avail, freed_blocks; 392 int avail, freed_blocks;
394 int i; 393 int i;
@@ -485,8 +484,7 @@ static int wlcore_fw_status(struct wl1271 *wl, struct wl_fw_status *status)
485 } 484 }
486 485
487 /* update the host-chipset time offset */ 486 /* update the host-chipset time offset */
488 getnstimeofday(&ts); 487 wl->time_offset = (ktime_get_boot_ns() >> 10) -
489 wl->time_offset = (timespec_to_ns(&ts) >> 10) -
490 (s64)(status->fw_localtime); 488 (s64)(status->fw_localtime);
491 489
492 wl->fw_fast_lnk_map = status->link_fast_bitmap; 490 wl->fw_fast_lnk_map = status->link_fast_bitmap;
diff --git a/drivers/net/wireless/ti/wlcore/tx.c b/drivers/net/wireless/ti/wlcore/tx.c
index a3f5e9ca492a..00e9b4624dcf 100644
--- a/drivers/net/wireless/ti/wlcore/tx.c
+++ b/drivers/net/wireless/ti/wlcore/tx.c
@@ -264,7 +264,6 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif,
264 struct sk_buff *skb, u32 extra, 264 struct sk_buff *skb, u32 extra,
265 struct ieee80211_tx_info *control, u8 hlid) 265 struct ieee80211_tx_info *control, u8 hlid)
266{ 266{
267 struct timespec ts;
268 struct wl1271_tx_hw_descr *desc; 267 struct wl1271_tx_hw_descr *desc;
269 int ac, rate_idx; 268 int ac, rate_idx;
270 s64 hosttime; 269 s64 hosttime;
@@ -287,8 +286,7 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif,
287 } 286 }
288 287
289 /* configure packet life time */ 288 /* configure packet life time */
290 getnstimeofday(&ts); 289 hosttime = (ktime_get_boot_ns() >> 10);
291 hosttime = (timespec_to_ns(&ts) >> 10);
292 desc->start_time = cpu_to_le32(hosttime - wl->time_offset); 290 desc->start_time = cpu_to_le32(hosttime - wl->time_offset);
293 291
294 is_dummy = wl12xx_is_dummy_packet(wl, skb); 292 is_dummy = wl12xx_is_dummy_packet(wl, skb);