linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] skd: use ktime_get_real_seconds()
@ 2017-11-02 11:42 Arnd Bergmann
  2017-11-02 14:27 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2017-11-02 11:42 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Arnd Bergmann, Jens Axboe, linux-block, linux-kernel

Like many storage drivers, skd uses an unsigned 32-bit number for
interchanging the current time with the firmware. This will overflow in
y2106 and is otherwise safe.

However, the get_seconds() function is generally considered deprecated
since the behavior is different between 32-bit and 64-bit architectures,
and using it may indicate a bigger problem.

To annotate that we've thought about this, let's add a comment here
and migrate to the ktime_get_real_seconds() function that consistently
returns a 64-bit number.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/block/skd_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
index 64d0fc17c174..2819f23e8bf2 100644
--- a/drivers/block/skd_main.c
+++ b/drivers/block/skd_main.c
@@ -1967,7 +1967,8 @@ static void skd_isr_msg_from_dev(struct skd_device *skdev)
 		break;
 
 	case FIT_MTD_CMD_LOG_HOST_ID:
-		skdev->connect_time_stamp = get_seconds();
+		/* hardware interface overflows in y2106 */
+		skdev->connect_time_stamp = (u32)ktime_get_real_seconds();
 		data = skdev->connect_time_stamp & 0xFFFF;
 		mtd = FIT_MXD_CONS(FIT_MTD_CMD_LOG_TIME_STAMP_LO, 0, data);
 		SKD_WRITEL(skdev, mtd, FIT_MSG_TO_DEVICE);
-- 
2.9.0

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

* Re: [PATCH] skd: use ktime_get_real_seconds()
  2017-11-02 11:42 [PATCH] skd: use ktime_get_real_seconds() Arnd Bergmann
@ 2017-11-02 14:27 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2017-11-02 14:27 UTC (permalink / raw)
  To: Arnd Bergmann, Bart Van Assche; +Cc: linux-block, linux-kernel

On 11/02/2017 05:42 AM, Arnd Bergmann wrote:
> Like many storage drivers, skd uses an unsigned 32-bit number for
> interchanging the current time with the firmware. This will overflow in
> y2106 and is otherwise safe.
> 
> However, the get_seconds() function is generally considered deprecated
> since the behavior is different between 32-bit and 64-bit architectures,
> and using it may indicate a bigger problem.
> 
> To annotate that we've thought about this, let's add a comment here
> and migrate to the ktime_get_real_seconds() function that consistently
> returns a 64-bit number.

Thanks Arnd, applied.

-- 
Jens Axboe

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

end of thread, other threads:[~2017-11-02 14:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-02 11:42 [PATCH] skd: use ktime_get_real_seconds() Arnd Bergmann
2017-11-02 14:27 ` Jens Axboe

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).