diff options
author | Alison Schofield <amsfield22@gmail.com> | 2015-11-09 14:34:20 -0500 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2015-11-11 20:51:04 -0500 |
commit | 9c9bd593f30fc8a4d6e70d72b49b5651fa492e65 (patch) | |
tree | 3d92a7bd095e43985f94a271105f3e24c68ee8a5 /drivers | |
parent | 36f8ef7f7684997f1c1efcc775b1d7cdf452ce44 (diff) |
scsi: pmcraid: replace struct timeval with ktime_get_real_seconds()
Replace the use of struct timeval and do_gettimeofday() with
64 bit ktime_get_real_seconds. Prevents 32-bit type overflow
in year 2038 on 32-bit systems.
Driver was using the seconds portion of struct timeval (.tv_secs)
to pass a millseconds timestamp to the firmware. This change maintains
that same behavior using ktime_get_real_seconds.
The structure used to pass the timestamp to firmware is 48 bits and
works fine as long as the top 16 bits are zero and they will be zero
for a long time..ie. thousands of years.
Alternative Change: Add sub second granularity to timestamp
As noted above, the driver only used the seconds portion of timeval,
ignores the microseconds portion, and by multiplying by 1000 effectively
does a <<10 and always writes zero into timestamp[0].
The alternative change would pass all the bits to the firmware:
struct timespec64 ts;
ktime_get_real_ts64(&ts);
timestamp = ts.tv_sec * MSEC_PER_SEC + ts.tv_nsec / NSEC_PER_MSEC;
Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/pmcraid.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index ed31d8cc6266..3f64275cfafd 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <asm/processor.h> | 45 | #include <asm/processor.h> |
46 | #include <linux/libata.h> | 46 | #include <linux/libata.h> |
47 | #include <linux/mutex.h> | 47 | #include <linux/mutex.h> |
48 | #include <linux/ktime.h> | ||
48 | #include <scsi/scsi.h> | 49 | #include <scsi/scsi.h> |
49 | #include <scsi/scsi_host.h> | 50 | #include <scsi/scsi_host.h> |
50 | #include <scsi/scsi_device.h> | 51 | #include <scsi/scsi_device.h> |
@@ -5563,11 +5564,9 @@ static void pmcraid_set_timestamp(struct pmcraid_cmd *cmd) | |||
5563 | __be32 time_stamp_len = cpu_to_be32(PMCRAID_TIMESTAMP_LEN); | 5564 | __be32 time_stamp_len = cpu_to_be32(PMCRAID_TIMESTAMP_LEN); |
5564 | struct pmcraid_ioadl_desc *ioadl = ioarcb->add_data.u.ioadl; | 5565 | struct pmcraid_ioadl_desc *ioadl = ioarcb->add_data.u.ioadl; |
5565 | 5566 | ||
5566 | struct timeval tv; | ||
5567 | __le64 timestamp; | 5567 | __le64 timestamp; |
5568 | 5568 | ||
5569 | do_gettimeofday(&tv); | 5569 | timestamp = ktime_get_real_seconds() * 1000; |
5570 | timestamp = tv.tv_sec * 1000; | ||
5571 | 5570 | ||
5572 | pinstance->timestamp_data->timestamp[0] = (__u8)(timestamp); | 5571 | pinstance->timestamp_data->timestamp[0] = (__u8)(timestamp); |
5573 | pinstance->timestamp_data->timestamp[1] = (__u8)((timestamp) >> 8); | 5572 | pinstance->timestamp_data->timestamp[1] = (__u8)((timestamp) >> 8); |