From patchwork Mon Nov 27 11:48:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 119690 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp138466qgn; Mon, 27 Nov 2017 03:49:37 -0800 (PST) X-Google-Smtp-Source: AGs4zMZOabxowKYSLWu9rdTKdL9ybMmRlEV9GsorY0VRJSuB6qFIfENwS9Jij7jtYC0x/N942xZF X-Received: by 10.98.68.203 with SMTP id m72mr405197pfi.180.1511783376884; Mon, 27 Nov 2017 03:49:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511783376; cv=none; d=google.com; s=arc-20160816; b=sdkuX7pvM3I0uMOZVMjwThsdA0TKD4iSV25w6G5UjqIpdHCJ3iO60KE13+WtTv1kVX A0BYD5GDm/+X+2FBpD5+GQv47j8zOQssisI0+zy9/iIKjpPabqPFYyYS7PrUwR3u+ap9 +odmBYJ+4A3U5+YVIhmB46hePYs1tlapnhweo8Cyu7cZNwlseoaLyHhB83sVpxuE3Ndf 68XJt22I9Hhx0y786/ZWos7GFWYeAutm8QSwwOuMHC/JqdoeXAk4BjeLiWNYKEZMoi7z DayscqCYnRih7X7/cFm6r4czFhRrwhusyR0g6Pp6J2j/zyLHSS6hUUhLicVU8oumi2xh AziA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=oOYqDZETCEbhI5Qm0ModFfYDDvl2k+CDInFCSHy/1sY=; b=XWFqK83PsYfkHythdsrv83OiwhkLyxzGbJYBMqubS/G97Pf6N0H1uA8yXrlMcqndm9 LDa+r2yOksLBPMWnFqr/bLgjuVgfDYTEP6ACeAVTBv5vfLH6KsF0epCwAdVjyy6e2l8k 2f1lVQEOfmCO40XyH5qrX8s8JADYfMPstnHvfM0+xR+aKlxpyoCqv/uTqVPpTWHp6Sjk mKlaW3nM1VqOG2LISXwazlmbXe15F9yooFEg4YylPpAbhC4whaI2xjMjWSs3g5C3axpz 0VYm7D0umnpiKRH4BpCqZ9R9uHMV+pybtefUQy5oA4xlCRLi1fsVAkHH07KyxMPbKlgn MGqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w16si21729919plp.371.2017.11.27.03.49.36; Mon, 27 Nov 2017 03:49:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752423AbdK0Ltf (ORCPT + 28 others); Mon, 27 Nov 2017 06:49:35 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:50301 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752096AbdK0Ltb (ORCPT ); Mon, 27 Nov 2017 06:49:31 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0MIxJ3-1eGnrs3tcH-002XW3; Mon, 27 Nov 2017 12:49:14 +0100 From: Arnd Bergmann To: Kalle Valo Cc: y2038@lists.linaro.org, Arnd Bergmann , Johannes Berg , Arend Van Spriel , Iain Hunter , "Reizer, Eyal" , "David S. Miller" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] wlcore: use boottime for fw time sync Date: Mon, 27 Nov 2017 12:48:19 +0100 Message-Id: <20171127114903.2779545-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:UM4jJyzprUV7OeomTTFAQd60Bf1IljoxMvIGjRJ+wvwkIPq5B0N s2qbZOvzJLnSZutDvAgPQZiC+cE1MYBf+EwJmvsPTrSGr/6pU8cHSpgSLxwpFpFVnzGn7xe nzNEfH0EUbJrbzaTDNLoA8Ryg/PxF12hQBCcRVtdux9MtC29RYXNUUXzIj35PY61V2s0qcG +ruObZSS+X7cdOASy2Avg== X-UI-Out-Filterresults: notjunk:1; V01:K0:ayRShwpa5QU=:uxzTfoXwadaNtYijRNNSWj E6ZR1u3gF7/qucYHO+6GeaJltCvkwDLeiD0GoKJmGqBAxW/HjOU+v9+k7mMmrMxogt7olZOb7 UwhyDZ0MhFebyxnjK4bGmbgmH+nGST0b/umxTzBm1pKqZW0D/FiOx+jctLPlIYjZytySxeCMO POXQPQ2UCqWA76G8YIr0RIAhe/ro94qhLol2BAGT0BGDJOA9mql3F4PGla3VpX/ZujcN01m/h ZCk899OHU+aIxrFy+5jQy38c6fa2C3+9snM6rjhw2fx8wr4D2v2I9Tnpnwa9DGRtcILFXIuAL wRIK/78K1M8+zPvLCweRrWKONVd+seVAuld8OqKJXtLqVv8+1i5zdSe7gXuyrUtYom8WBLs1w owIE9uPoQdBkik5EMwe3NVTWmVOG2ATK4+PnIDlecGnC5qD6KnuVbzFIn0WFqYJsqKhXWGBUI HJp/UHsXauFD/j2cdIEOex4afKZp6f1JEgGkOqoEuMMLyS3ycBzIhIEoIlPaCnIG9udDIXJ5Z ElLj9BRd6I+cQdwwKiQWCN6TPgzKz+7iYJOBEZ98J7uiWiBcqCyOjKD1Fg4iAP4t+oZkHtSIG 0yfe649ZuurSV01Zz//b4YgMwLDCwXBryCFsBAKq0TO+GtamXkLezE5BYqLbXwVlVj0IxFJFJ cFXO9zXhLXgZOf2YOirNoZ2mYD9JFCTX7B6PBl8xOZTixU9WtMYruB1wSHNOOLlHfobYaPuiQ rYU9Uh2jbQR8GJDaAN3nrhdgkjaOQqCD1uxwYQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/net/wireless/ti/wlcore/main.c | 4 +--- drivers/net/wireless/ti/wlcore/tx.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) -- 2.9.0 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, static int wlcore_fw_status(struct wl1271 *wl, struct wl_fw_status *status) { struct wl12xx_vif *wlvif; - struct timespec ts; u32 old_tx_blk_count = wl->tx_blocks_available; int avail, freed_blocks; int i; @@ -485,8 +484,7 @@ static int wlcore_fw_status(struct wl1271 *wl, struct wl_fw_status *status) } /* update the host-chipset time offset */ - getnstimeofday(&ts); - wl->time_offset = (timespec_to_ns(&ts) >> 10) - + wl->time_offset = (ktime_get_boot_ns() >> 10) - (s64)(status->fw_localtime); 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, struct sk_buff *skb, u32 extra, struct ieee80211_tx_info *control, u8 hlid) { - struct timespec ts; struct wl1271_tx_hw_descr *desc; int ac, rate_idx; s64 hosttime; @@ -287,8 +286,7 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif, } /* configure packet life time */ - getnstimeofday(&ts); - hosttime = (timespec_to_ns(&ts) >> 10); + hosttime = (ktime_get_boot_ns() >> 10); desc->start_time = cpu_to_le32(hosttime - wl->time_offset); is_dummy = wl12xx_is_dummy_packet(wl, skb);