powerpc: Avoid giving out RTC dates below EPOCH
Doing so causes xtime to be negative which crashes the timekeeping code in funny ways when doing suspend/resume Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
This commit is contained in:
@@ -777,7 +777,7 @@ int update_persistent_clock(struct timespec now)
|
|||||||
return ppc_md.set_rtc_time(&tm);
|
return ppc_md.set_rtc_time(&tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_persistent_clock(struct timespec *ts)
|
static void __read_persistent_clock(struct timespec *ts)
|
||||||
{
|
{
|
||||||
struct rtc_time tm;
|
struct rtc_time tm;
|
||||||
static int first = 1;
|
static int first = 1;
|
||||||
@@ -800,10 +800,23 @@ void read_persistent_clock(struct timespec *ts)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ppc_md.get_rtc_time(&tm);
|
ppc_md.get_rtc_time(&tm);
|
||||||
|
|
||||||
ts->tv_sec = mktime(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
|
ts->tv_sec = mktime(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
|
||||||
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void read_persistent_clock(struct timespec *ts)
|
||||||
|
{
|
||||||
|
__read_persistent_clock(ts);
|
||||||
|
|
||||||
|
/* Sanitize it in case real time clock is set below EPOCH */
|
||||||
|
if (ts->tv_sec < 0) {
|
||||||
|
ts->tv_sec = 0;
|
||||||
|
ts->tv_nsec = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* clocksource code */
|
/* clocksource code */
|
||||||
static cycle_t rtc_read(struct clocksource *cs)
|
static cycle_t rtc_read(struct clocksource *cs)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user