Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1222658 > unrolled thread

[PATCH] bnx2x: use ktime_get_seconds() for timestamp

Started byArnd Bergmann <arnd@arndb.de>
First post2015-09-11 11:40 +0200
Last post2015-09-12 00:10 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] bnx2x: use ktime_get_seconds() for timestamp Arnd Bergmann <arnd@arndb.de> - 2015-09-11 11:40 +0200
    RE: [PATCH] bnx2x: use ktime_get_seconds() for timestamp Yuval Mintz <Yuval.Mintz@qlogic.com> - 2015-09-11 12:30 +0200
    Re: [PATCH] bnx2x: use ktime_get_seconds() for timestamp David Miller <davem@davemloft.net> - 2015-09-12 00:10 +0200

#1222658 — [PATCH] bnx2x: use ktime_get_seconds() for timestamp

FromArnd Bergmann <arnd@arndb.de>
Date2015-09-11 11:40 +0200
Subject[PATCH] bnx2x: use ktime_get_seconds() for timestamp
Message-ID<q7sYi-63o-25@gated-at.bofh.it>
commit c48f350ff5e7 "bnx2x: Add MFW dump support" added the
bnx2x_update_mfw_dump() function that reads the current time and stores
it in a 32-bit field that gets passed into a buffer in a fixed format.

This is potentially broken when the epoch overflows in 2038, and
otherwise overflows in 2106. As we're trying to avoid uses of
struct timeval for this reason, I noticed the addition of this
function, and tried to rewrite it in a way that is more explicit
about the overflow and that will keep working once we deprecate
struct timeval.

I assume that it is not possible to change the ABI any more, otherwise
we should try to use a 64-bit field for the seconds right away.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Yuval Mintz <Yuval.Mintz@qlogic.com>
Cc: Ariel Elior <Ariel.Elior@qlogic.com>
---
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index e3da2bddf143..89a174fa1300 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -3705,16 +3705,14 @@ out:
 
 void bnx2x_update_mfw_dump(struct bnx2x *bp)
 {
-	struct timeval epoc;
 	u32 drv_ver;
 	u32 valid_dump;
 
 	if (!SHMEM2_HAS(bp, drv_info))
 		return;
 
-	/* Update Driver load time */
-	do_gettimeofday(&epoc);
-	SHMEM2_WR(bp, drv_info.epoc, epoc.tv_sec);
+	/* Update Driver load time, possibly broken in y2038 */
+	SHMEM2_WR(bp, drv_info.epoc, (u32)ktime_get_real_seconds());
 
 	drv_ver = bnx2x_update_mng_version_utility(DRV_MODULE_VERSION, true);
 	SHMEM2_WR(bp, drv_info.drv_ver, drv_ver);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1222693

FromYuval Mintz <Yuval.Mintz@qlogic.com>
Date2015-09-11 12:30 +0200
Message-ID<q7tKG-7d0-11@gated-at.bofh.it>
In reply to#1222658
> I assume that it is not possible to change the ABI any more, otherwise
> we should try to use a 64-bit field.

Actually, I did suggest exactly that to our management team,
But this was the decided ABI. 

Acked-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1223127

FromDavid Miller <davem@davemloft.net>
Date2015-09-12 00:10 +0200
Message-ID<q7EG6-6jS-21@gated-at.bofh.it>
In reply to#1222658
From: Arnd Bergmann <arnd@arndb.de>
Date: Fri, 11 Sep 2015 11:33:01 +0200

> commit c48f350ff5e7 "bnx2x: Add MFW dump support" added the
> bnx2x_update_mfw_dump() function that reads the current time and stores
> it in a 32-bit field that gets passed into a buffer in a fixed format.
> 
> This is potentially broken when the epoch overflows in 2038, and
> otherwise overflows in 2106. As we're trying to avoid uses of
> struct timeval for this reason, I noticed the addition of this
> function, and tried to rewrite it in a way that is more explicit
> about the overflow and that will keep working once we deprecate
> struct timeval.
> 
> I assume that it is not possible to change the ABI any more, otherwise
> we should try to use a 64-bit field for the seconds right away.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web