From patchwork Mon Sep 28 20:21:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 523593 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 55189140909 for ; Tue, 29 Sep 2015 06:25:45 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752856AbbI1UXH (ORCPT ); Mon, 28 Sep 2015 16:23:07 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:59484 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751271AbbI1UXG (ORCPT ); Mon, 28 Sep 2015 16:23:06 -0400 Received: from wuerfel.lan. ([149.172.15.242]) by mrelayeu.kundenserver.de (mreue103) with ESMTPSA (Nemesis) id 0MbK2G-1ZzQot2FL2-00Im4h; Mon, 28 Sep 2015 22:23:03 +0200 From: Arnd Bergmann To: y2038@lists.linaro.org Cc: Thomas Gleixner , John Stultz , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Rodolfo Giometti , linux-net-drivers@solarflare.com, Shradha Shah , Richard Cochran , Arnd Bergmann Subject: [PATCH 5/5] net: sfc: avoid using timespec Date: Mon, 28 Sep 2015 22:21:32 +0200 Message-Id: <1443471692-2946597-6-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.1.0.rc2 In-Reply-To: <1443471692-2946597-1-git-send-email-arnd@arndb.de> References: <1443471692-2946597-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:LypNHQFhG5UezAkFbiKkHz5pSLeppjlIN3D2tw86kOULU38CGLc s0bqzMQVIO+7eidobHvGZjYOQ8HykoXengRT76916yW8JUNiOT3QAoJ42BlA6HRD2ikffJ1 VC+KRKBFop7RG1o266yjuKEt85mQKgB6O6Xncd0nQ3qVzwIUX3QQ/uUbfAnsQCIEqhAKUJ+ n5h0kJiAWVfCgVBx8btCA== X-UI-Out-Filterresults: notjunk:1; V01:K0:wdS8DQQILZs=:WW4N4IwWw0+oX46slV5fE2 7g8NIwenMQD1ZQrsRQjNhqGm95sFCwgITtsW7a8MumTNKp+ZLSIOzJsHgEeai6LtclbMcADM4 2DctKirJrFnSXErT6EiTc6wVJ6Q1Z8X6Q/pzn1eMK3Hz0LXveUvwwdLdvzlUCh0l/uPJBWrs3 GAbyKB/ll5fbUn6/ED+wfMR/NUWtyedxkP7VeEzumECuFyYsFQhMzwky4JWn6dKcE8Zm8b8ZV xcyzMT/tRE//hMlwr3QIbNuqrkyjL/fnz2ZyGMa/54flaOjt1X59V7jUoYXxmAzIP88QxIuWN GBbLhHvL/w3AyzwZGKV7hFPUW7Yd10zJodsq/RFyWLSrs6z2auKVGmRcC3+a2VYRg0s9kX12o xWLShAJd6MYYCf2QmvQ/MrprgyfwldidSXG4Wo6hm+ldLC9h4AlSFaseo4ofIoM25oNh4nKYd PbYHCckkT4qCZPWIp0CPWZAfIwE+KBubHpbCyvR0a8Q1rOJpWUaXx3+IJQFrmOz6sebyviWLc +DuRRNBIb1MVNzAZCcfrlRi6QdmwbrArAYpZaqSZpdqtnyqNEzbrsPyekY413XcwyTuH6uS8E LmhXXHMU2QeVgOehSF8Ga1V2fCep9AnEhhqOY2jXBs/Jm/RT0qfhs4t7bNiE75+/y2wpAGQX8 6DBsTgXPBtoOl0NFF8XJOy6pJ7iw29OX03M7Ka1B+wtfd0Rb1dzXmW4Ug2V96/ssxNAw= Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The sfc driver internally uses a time format based on 32-bit (unsigned) seconds and 32-bit nanoseconds. This means it will overflow in 2106, but the value we pass into it is a signed 32-bit tv_sec that already overflows in 2038 to a negative value. This patch changes the logic to use the lower 32 bits of the timespec64 tv_sec in efx_ptp_ns_to_s_ns, which will have the correct value beyond the overflow. While this does not change any of the register values, it lets us keep using the driver after we deprecate the use of the timespec type in the kernel. In the efx_ptp_process_times function, the change to use timespec64 is similar, in that the tv_sec portion is ignored anyway and we only care about the nanosecond portion that remains unchanged. Signed-off-by: Arnd Bergmann Reviewed-by: Thomas Gleixner --- drivers/net/ethernet/sfc/ptp.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c index fe849dbf9f80..c771e0af4e06 100644 --- a/drivers/net/ethernet/sfc/ptp.c +++ b/drivers/net/ethernet/sfc/ptp.c @@ -401,8 +401,8 @@ size_t efx_ptp_update_stats(struct efx_nic *efx, u64 *stats) /* For Siena platforms NIC time is s and ns */ static void efx_ptp_ns_to_s_ns(s64 ns, u32 *nic_major, u32 *nic_minor) { - struct timespec ts = ns_to_timespec(ns); - *nic_major = ts.tv_sec; + struct timespec64 ts = ns_to_timespec64(ns); + *nic_major = (u32)ts.tv_sec; *nic_minor = ts.tv_nsec; } @@ -431,8 +431,8 @@ static ktime_t efx_ptp_s_ns_to_ktime_correction(u32 nic_major, u32 nic_minor, */ static void efx_ptp_ns_to_s27(s64 ns, u32 *nic_major, u32 *nic_minor) { - struct timespec ts = ns_to_timespec(ns); - u32 maj = ts.tv_sec; + struct timespec64 ts = ns_to_timespec64(ns); + u32 maj = (u32)ts.tv_sec; u32 min = (u32)(((u64)ts.tv_nsec * NS_TO_S27_MULT + (1ULL << (NS_TO_S27_SHIFT - 1))) >> NS_TO_S27_SHIFT); @@ -737,14 +737,14 @@ efx_ptp_process_times(struct efx_nic *efx, MCDI_DECLARE_STRUCT_PTR(synch_buf), */ for (i = 0; i < number_readings; i++) { s32 window, corrected; - struct timespec wait; + struct timespec64 wait; efx_ptp_read_timeset( MCDI_ARRAY_STRUCT_PTR(synch_buf, PTP_OUT_SYNCHRONIZE_TIMESET, i), &ptp->timeset[i]); - wait = ktime_to_timespec( + wait = ktime_to_timespec64( ptp->nic_to_kernel_time(0, ptp->timeset[i].wait, 0)); window = ptp->timeset[i].window; corrected = window - wait.tv_nsec; @@ -803,7 +803,7 @@ efx_ptp_process_times(struct efx_nic *efx, MCDI_DECLARE_STRUCT_PTR(synch_buf), ptp->timeset[last_good].minor, 0); /* Calculate delay from NIC top of second to last_time */ - delta.tv_nsec += ktime_to_timespec(mc_time).tv_nsec; + delta.tv_nsec += ktime_to_timespec64(mc_time).tv_nsec; /* Set PPS timestamp to match NIC top of second */ ptp->host_time_pps = *last_time;