Commit e4a9616c authored by Hari Bathini's avatar Hari Bathini Committed by Michael Ellerman

powerpc/rtas: Make timestamp related code y2038-safe

While we are here, let us make timestamp related code y2038-safe.
Suggested-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarHari Bathini <hbathini@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent f7618299
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <asm/page.h> #include <asm/page.h>
#include <linux/time.h>
/* /*
* Definitions for talking to the RTAS on CHRP machines. * Definitions for talking to the RTAS on CHRP machines.
...@@ -343,7 +344,7 @@ extern int early_init_dt_scan_rtas(unsigned long node, ...@@ -343,7 +344,7 @@ extern int early_init_dt_scan_rtas(unsigned long node,
extern void pSeries_log_error(char *buf, unsigned int err_type, int fatal); extern void pSeries_log_error(char *buf, unsigned int err_type, int fatal);
#ifdef CONFIG_PPC_PSERIES #ifdef CONFIG_PPC_PSERIES
extern unsigned long last_rtas_event; extern time64_t last_rtas_event;
extern int clobbering_unread_rtas_event(void); extern int clobbering_unread_rtas_event(void);
extern int pseries_devicetree_update(s32 scope); extern int pseries_devicetree_update(s32 scope);
extern void post_mobility_fixup(void); extern void post_mobility_fixup(void);
......
...@@ -376,7 +376,7 @@ static int zip_oops(size_t text_len) ...@@ -376,7 +376,7 @@ static int zip_oops(size_t text_len)
} }
oops_hdr->version = cpu_to_be16(OOPS_HDR_VERSION); oops_hdr->version = cpu_to_be16(OOPS_HDR_VERSION);
oops_hdr->report_length = cpu_to_be16(zipped_len); oops_hdr->report_length = cpu_to_be16(zipped_len);
oops_hdr->timestamp = cpu_to_be64(get_seconds()); oops_hdr->timestamp = cpu_to_be64(ktime_get_real_seconds());
return 0; return 0;
} }
...@@ -423,7 +423,7 @@ static int nvram_pstore_write(enum pstore_type_id type, ...@@ -423,7 +423,7 @@ static int nvram_pstore_write(enum pstore_type_id type,
oops_hdr->version = cpu_to_be16(OOPS_HDR_VERSION); oops_hdr->version = cpu_to_be16(OOPS_HDR_VERSION);
oops_hdr->report_length = cpu_to_be16(size); oops_hdr->report_length = cpu_to_be16(size);
oops_hdr->timestamp = cpu_to_be64(get_seconds()); oops_hdr->timestamp = cpu_to_be64(ktime_get_real_seconds());
if (compressed) if (compressed)
err_type = ERR_TYPE_KERNEL_PANIC_GZ; err_type = ERR_TYPE_KERNEL_PANIC_GZ;
...@@ -721,7 +721,7 @@ static void oops_to_nvram(struct kmsg_dumper *dumper, ...@@ -721,7 +721,7 @@ static void oops_to_nvram(struct kmsg_dumper *dumper,
err_type = ERR_TYPE_KERNEL_PANIC; err_type = ERR_TYPE_KERNEL_PANIC;
oops_hdr->version = cpu_to_be16(OOPS_HDR_VERSION); oops_hdr->version = cpu_to_be16(OOPS_HDR_VERSION);
oops_hdr->report_length = cpu_to_be16(text_len); oops_hdr->report_length = cpu_to_be16(text_len);
oops_hdr->timestamp = cpu_to_be64(get_seconds()); oops_hdr->timestamp = cpu_to_be64(ktime_get_real_seconds());
} }
(void) nvram_write_os_partition(&oops_log_partition, oops_buf, (void) nvram_write_os_partition(&oops_log_partition, oops_buf,
......
...@@ -36,10 +36,10 @@ static DEFINE_SPINLOCK(nvram_lock); ...@@ -36,10 +36,10 @@ static DEFINE_SPINLOCK(nvram_lock);
/* See clobbering_unread_rtas_event() */ /* See clobbering_unread_rtas_event() */
#define NVRAM_RTAS_READ_TIMEOUT 5 /* seconds */ #define NVRAM_RTAS_READ_TIMEOUT 5 /* seconds */
static unsigned long last_unread_rtas_event; /* timestamp */ static time64_t last_unread_rtas_event; /* timestamp */
#ifdef CONFIG_PSTORE #ifdef CONFIG_PSTORE
unsigned long last_rtas_event; time64_t last_rtas_event;
#endif #endif
static ssize_t pSeries_nvram_read(char *buf, size_t count, loff_t *index) static ssize_t pSeries_nvram_read(char *buf, size_t count, loff_t *index)
...@@ -144,9 +144,9 @@ int nvram_write_error_log(char * buff, int length, ...@@ -144,9 +144,9 @@ int nvram_write_error_log(char * buff, int length,
int rc = nvram_write_os_partition(&rtas_log_partition, buff, length, int rc = nvram_write_os_partition(&rtas_log_partition, buff, length,
err_type, error_log_cnt); err_type, error_log_cnt);
if (!rc) { if (!rc) {
last_unread_rtas_event = get_seconds(); last_unread_rtas_event = ktime_get_real_seconds();
#ifdef CONFIG_PSTORE #ifdef CONFIG_PSTORE
last_rtas_event = get_seconds(); last_rtas_event = ktime_get_real_seconds();
#endif #endif
} }
...@@ -200,7 +200,7 @@ int clobbering_unread_rtas_event(void) ...@@ -200,7 +200,7 @@ int clobbering_unread_rtas_event(void)
{ {
return (oops_log_partition.index == rtas_log_partition.index return (oops_log_partition.index == rtas_log_partition.index
&& last_unread_rtas_event && last_unread_rtas_event
&& get_seconds() - last_unread_rtas_event <= && ktime_get_real_seconds() - last_unread_rtas_event <=
NVRAM_RTAS_READ_TIMEOUT); NVRAM_RTAS_READ_TIMEOUT);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment