linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [RESEND 2] scsi: esas2r: use ktime_get_real_seconds()
@ 2018-04-20 16:02 Arnd Bergmann
  2018-04-20 23:34 ` Martin K. Petersen
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2018-04-20 16:02 UTC (permalink / raw)
  To: Bradley Grove, James E.J. Bottomley, Martin K. Petersen
  Cc: Christoph Hellwig, Tomas Henzl, Arnd Bergmann, linux-scsi, linux-kernel

do_gettimeofday() is deprecated because of the y2038 overflow.
Here, we use the result to pass into a 32-bit field in the firmware,
which still risks an overflow, but if the firmware is written
to expect unsigned values, it can at least last until y2106,
and there is not much we can do about it.

This changes do_gettimeofday() to ktime_get_real_seconds(), which
at least simplifies the code a bit, and avoids the deprecated
interface. I'm adding a comment about the overflow to document
what happens.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
Originally submitted in November 2017, no reply.
Sent again in January, still no reply.

Resending once more now, could you please apply the trivial patch?
---
 drivers/scsi/esas2r/esas2r_init.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/esas2r/esas2r_init.c b/drivers/scsi/esas2r/esas2r_init.c
index 9dffcb28c9b7..9db645dde35e 100644
--- a/drivers/scsi/esas2r/esas2r_init.c
+++ b/drivers/scsi/esas2r/esas2r_init.c
@@ -1202,8 +1202,6 @@ static bool esas2r_format_init_msg(struct esas2r_adapter *a,
 	case ESAS2R_INIT_MSG_START:
 	case ESAS2R_INIT_MSG_REINIT:
 	{
-		struct timeval now;
-		do_gettimeofday(&now);
 		esas2r_hdebug("CFG init");
 		esas2r_build_cfg_req(a,
 				     rq,
@@ -1212,7 +1210,8 @@ static bool esas2r_format_init_msg(struct esas2r_adapter *a,
 				     NULL);
 		ci = (struct atto_vda_cfg_init *)&rq->vrq->cfg.data.init;
 		ci->sgl_page_size = cpu_to_le32(sgl_page_size);
-		ci->epoch_time = cpu_to_le32(now.tv_sec);
+		/* firmware interface overflows in y2106 */
+		ci->epoch_time = cpu_to_le32(ktime_get_real_seconds());
 		rq->flags |= RF_FAILURE_OK;
 		a->init_msg = ESAS2R_INIT_MSG_INIT;
 		break;
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] [RESEND 2] scsi: esas2r: use ktime_get_real_seconds()
  2018-04-20 16:02 [PATCH] [RESEND 2] scsi: esas2r: use ktime_get_real_seconds() Arnd Bergmann
@ 2018-04-20 23:34 ` Martin K. Petersen
  0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2018-04-20 23:34 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Bradley Grove, James E.J. Bottomley, Martin K. Petersen,
	Christoph Hellwig, Tomas Henzl, linux-scsi, linux-kernel


Arnd,

> do_gettimeofday() is deprecated because of the y2038 overflow.  Here,
> we use the result to pass into a 32-bit field in the firmware, which
> still risks an overflow, but if the firmware is written to expect
> unsigned values, it can at least last until y2106, and there is not
> much we can do about it.
>
> This changes do_gettimeofday() to ktime_get_real_seconds(), which at
> least simplifies the code a bit, and avoids the deprecated
> interface. I'm adding a comment about the overflow to document what
> happens.

Applied to 4.18/scsi-queue. Thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-04-20 23:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-20 16:02 [PATCH] [RESEND 2] scsi: esas2r: use ktime_get_real_seconds() Arnd Bergmann
2018-04-20 23:34 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).