From: Arnd Bergmann <arnd@arndb.de>
To: y2038@lists.linaro.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
John Stultz <john.stultz@linaro.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Rodolfo Giometti <giometti@enneenne.com>,
linux-net-drivers@solarflare.com,
Shradha Shah <sshah@solarflare.com>,
Richard Cochran <richardcochran@gmail.com>,
Arnd Bergmann <arnd@arndb.de>
Subject: [PATCH 5/5] net: sfc: avoid using timespec
Date: Mon, 28 Sep 2015 22:21:32 +0200 [thread overview]
Message-ID: <1443471692-2946597-6-git-send-email-arnd@arndb.de> (raw)
In-Reply-To: <1443471692-2946597-1-git-send-email-arnd@arndb.de>
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 <arnd@arndb.de>
---
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;
--
2.1.0.rc2
next prev parent reply other threads:[~2015-09-28 20:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-28 20:21 [PATCH 0/5] y2038 conversion for ntp/pps and sfc driver Arnd Bergmann
2015-09-28 20:21 ` [PATCH 1/5] ntp/pps: use timespec64 for hardpps() Arnd Bergmann
2015-09-30 7:20 ` Thomas Gleixner
2015-09-28 20:21 ` [PATCH 2/5] ntp/pps: replace getnstime_raw_and_real with 64-bit version Arnd Bergmann
2015-09-30 7:20 ` Thomas Gleixner
2015-09-28 20:21 ` [PATCH 3/5] ntp: use timespec64 in sync_cmos_clock Arnd Bergmann
2015-09-30 7:22 ` Thomas Gleixner
2015-09-28 20:21 ` [PATCH 4/5] ntp/pps: use y2038 safe types in pps_event_time Arnd Bergmann
2015-09-30 7:25 ` Thomas Gleixner
2015-09-28 20:21 ` Arnd Bergmann [this message]
2015-09-30 7:26 ` [PATCH 5/5] net: sfc: avoid using timespec Thomas Gleixner
2015-09-29 19:17 ` [PATCH 0/5] y2038 conversion for ntp/pps and sfc driver Richard Cochran
2015-09-30 4:06 ` David Miller
2015-09-30 7:27 ` Thomas Gleixner
2015-10-01 17:00 ` John Stultz
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=1443471692-2946597-6-git-send-email-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=giometti@enneenne.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-net-drivers@solarflare.com \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=sshah@solarflare.com \
--cc=tglx@linutronix.de \
--cc=y2038@lists.linaro.org \
/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