Skip to contentSkip to conversation

scsi: bfa: bfad_bsg: Use ktime_get_real_seconds()

PATCH Superseded Amitoj Kaur Chawla 3 participants 3 messages Oct 24, 2015 – Nov 3, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: bfa: bfad_bsg: Use ktime_get_real_seconds()

32 bit systems using 'struct timeval' will break in the year 2038, so we modify the code appropriately.

This patch replaces the use of struct timeval and do_gettimeofday() with ktime_get_real_seconds().

---
 drivers/scsi/bfa/bfad_bsg.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/bfa/bfad_bsg.c +3 -3
index 023b9d4..ba2de73 100644
@@ -16,6 +16,7 @@
  */
 
 #include <linux/uaccess.h>
+#include <linux/ktime.h>
 #include "bfad_drv.h"
 #include "bfad_im.h"
 #include "bfad_bsg.h"
@@ -2093,13 +2094,12 @@ bfad_iocmd_fcpim_cfg_profile(struct bfad_s *bfad, void *cmd, unsigned int v_cmd)
 {
 	struct bfa_bsg_fcpim_profile_s *iocmd =
 				(struct bfa_bsg_fcpim_profile_s *)cmd;
-	struct timeval  tv;
 	unsigned long	flags;
 
-	do_gettimeofday(&tv);
 	spin_lock_irqsave(&bfad->bfad_lock, flags);
 	if (v_cmd == IOCMD_FCPIM_PROFILE_ON)
-		iocmd->status = bfa_fcpim_profile_on(&bfad->bfa, tv.tv_sec);
+		iocmd->status = bfa_fcpim_profile_on(&bfad->bfa, 
+						ktime_get_real_seconds());
 	else if (v_cmd == IOCMD_FCPIM_PROFILE_OFF)
 		iocmd->status = bfa_fcpim_profile_off(&bfad->bfa);
 	spin_unlock_irqrestore(&bfad->bfad_lock, flags);
Signature · 1 line
1.9.1
#1 lore raw
Quoted 25 lines · Amitoj Kaur Chawla

32 bit systems using 'struct timeval' will break in the year 2038, so we modify the code appropriately.

This patch replaces the use of struct timeval and do_gettimeofday() with ktime_get_real_seconds().

---
 drivers/scsi/bfa/bfad_bsg.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/bfa/bfad_bsg.c +1 -0
index 023b9d4..ba2de73 100644
@@ -16,6 +16,7 @@
  */
 
 #include <linux/uaccess.h>
+#include <linux/ktime.h>
 #include "bfad_drv.h"
 #include "bfad_im.h"
 #include "bfad_bsg.h"
@@ -2093,13 +2094,12 @@ bfad_iocmd_fcpim_cfg_profile(struct bfad_s *bfad, void *cmd, unsigned int v_cmd)
 {

drivers/scsi/bfa/bfad_bsg.c bfad_iocmd_fcpim_cfg_profile(struct bfad_s *bfad, void *cmd, unsigned int v_cmd) · line 2101

Quoted 10 lines
drivers/scsi/bfa/bfad_bsg.c +1 -3
 	struct bfa_bsg_fcpim_profile_s *iocmd =
 				(struct bfa_bsg_fcpim_profile_s *)cmd;
-	struct timeval  tv;
 	unsigned long	flags;
 
-	do_gettimeofday(&tv);
 	spin_lock_irqsave(&bfad->bfad_lock, flags);
 	if (v_cmd == IOCMD_FCPIM_PROFILE_ON)
-		iocmd->status = bfa_fcpim_profile_on(&bfad->bfa, tv.tv_sec);
+		iocmd->status = bfa_fcpim_profile_on(&bfad->bfa, 

trailing whitespace.

regards
sudip

#2 lore raw
In reply to Amitoj Kaur Chawla
Quoted 7 lines · On Sunday 25 October 2015 03:33:58 Amitoj Kaur Chawla wrote:

32 bit systems using 'struct timeval' will break in the year 2038, so we modify the code appropriately.

This patch replaces the use of struct timeval and do_gettimeofday() with ktime_get_real_seconds().

Sorry for taking so long to review this, I'm only now catching up with my mails from the kernel summit.

This patch looks incomplete:

drivers/scsi/bfa/bfad_bsg.c bfad_iocmd_fcpim_cfg_profile(struct bfad_s *bfad, void *cmd, unsigned int v_cmd) · line 2105

Quoted 8 lines
drivers/scsi/bfa/bfad_bsg.c +2 -1
 	if (v_cmd == IOCMD_FCPIM_PROFILE_ON)
-		iocmd->status = bfa_fcpim_profile_on(&bfad->bfa, tv.tv_sec);
+		iocmd->status = bfa_fcpim_profile_on(&bfad->bfa, 
+						ktime_get_real_seconds());
 	else if (v_cmd == IOCMD_FCPIM_PROFILE_OFF)
 		iocmd->status = bfa_fcpim_profile_off(&bfad->bfa);
 	spin_unlock_irqrestore(&bfad->bfad_lock, flags);

bfa_fcpim_profile_on() takes a "u32" argument, so this will still overflow in year 2106. As you did in the later patches, you need to follow the variable to see how it is used, and whether it can be extended to time64_t consistently. Try to do the conversion as late as possible, and add a code comment about the overflow if the data ends up in a structure that cannot be changed.

Arnd