Skip to content

Commit 7d02093

Browse files
committed
Merge branch 'timers-for-linus-cleanups' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'timers-for-linus-cleanups' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: avr32: Fix typo in read_persistent_clock() sparc: Convert sparc to use read/update_persistent_clock cris: Convert cris to use read/update_persistent_clock m68k: Convert m68k to use read/update_persistent_clock m32r: Convert m32r to use read/update_peristent_clock blackfin: Convert blackfin to use read/update_persistent_clock ia64: Convert ia64 to use read/update_persistent_clock avr32: Convert avr32 to use read/update_persistent_clock h8300: Convert h8300 to use read/update_persistent_clock frv: Convert frv to use read/update_persistent_clock mn10300: Convert mn10300 to use read/update_persistent_clock alpha: Convert alpha to use read/update_persistent_clock xtensa: Fix unnecessary setting of xtime time: Clean up direct xtime usage in xen
2 parents 6e0b7b2 + e9ddbc0 commit 7d02093

21 files changed

Lines changed: 137 additions & 310 deletions

File tree

‎arch/alpha/Kconfig‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ config ARCH_USES_GETTIMEOFFSET
5555
bool
5656
default y
5757

58+
config GENERIC_CMOS_UPDATE
59+
def_bool y
60+
5861
config ZONE_DMA
5962
bool
6063
default y

‎arch/alpha/kernel/time.c‎

Lines changed: 47 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ static struct {
7575
__u32 last_time;
7676
/* ticks/cycle * 2^48 */
7777
unsigned long scaled_ticks_per_cycle;
78-
/* last time the CMOS clock got updated */
79-
time_t last_rtc_update;
8078
/* partial unused tick */
8179
unsigned long partial_tick;
8280
} state;
@@ -91,6 +89,52 @@ static inline __u32 rpcc(void)
9189
return result;
9290
}
9391

92+
int update_persistent_clock(struct timespec now)
93+
{
94+
return set_rtc_mmss(now.tv_sec);
95+
}
96+
97+
void read_persistent_clock(struct timespec *ts)
98+
{
99+
unsigned int year, mon, day, hour, min, sec, epoch;
100+
101+
sec = CMOS_READ(RTC_SECONDS);
102+
min = CMOS_READ(RTC_MINUTES);
103+
hour = CMOS_READ(RTC_HOURS);
104+
day = CMOS_READ(RTC_DAY_OF_MONTH);
105+
mon = CMOS_READ(RTC_MONTH);
106+
year = CMOS_READ(RTC_YEAR);
107+
108+
if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
109+
sec = bcd2bin(sec);
110+
min = bcd2bin(min);
111+
hour = bcd2bin(hour);
112+
day = bcd2bin(day);
113+
mon = bcd2bin(mon);
114+
year = bcd2bin(year);
115+
}
116+
117+
/* PC-like is standard; used for year >= 70 */
118+
epoch = 1900;
119+
if (year < 20)
120+
epoch = 2000;
121+
else if (year >= 20 && year < 48)
122+
/* NT epoch */
123+
epoch = 1980;
124+
else if (year >= 48 && year < 70)
125+
/* Digital UNIX epoch */
126+
epoch = 1952;
127+
128+
printk(KERN_INFO "Using epoch = %d\n", epoch);
129+
130+
if ((year += epoch) < 1970)
131+
year += 100;
132+
133+
ts->tv_sec = mktime(year, mon, day, hour, min, sec);
134+
}
135+
136+
137+
94138
/*
95139
* timer_interrupt() needs to keep up the real-time clock,
96140
* as well as call the "do_timer()" routine every clocktick
@@ -123,19 +167,6 @@ irqreturn_t timer_interrupt(int irq, void *dev)
123167
if (nticks)
124168
do_timer(nticks);
125169

126-
/*
127-
* If we have an externally synchronized Linux clock, then update
128-
* CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
129-
* called as close as possible to 500 ms before the new second starts.
130-
*/
131-
if (ntp_synced()
132-
&& xtime.tv_sec > state.last_rtc_update + 660
133-
&& xtime.tv_nsec >= 500000 - ((unsigned) TICK_SIZE) / 2
134-
&& xtime.tv_nsec <= 500000 + ((unsigned) TICK_SIZE) / 2) {
135-
int tmp = set_rtc_mmss(xtime.tv_sec);
136-
state.last_rtc_update = xtime.tv_sec - (tmp ? 600 : 0);
137-
}
138-
139170
write_sequnlock(&xtime_lock);
140171

141172
#ifndef CONFIG_SMP
@@ -304,7 +335,7 @@ rpcc_after_update_in_progress(void)
304335
void __init
305336
time_init(void)
306337
{
307-
unsigned int year, mon, day, hour, min, sec, cc1, cc2, epoch;
338+
unsigned int cc1, cc2;
308339
unsigned long cycle_freq, tolerance;
309340
long diff;
310341

@@ -348,43 +379,6 @@ time_init(void)
348379
bogomips yet, but this is close on a 500Mhz box. */
349380
__delay(1000000);
350381

351-
sec = CMOS_READ(RTC_SECONDS);
352-
min = CMOS_READ(RTC_MINUTES);
353-
hour = CMOS_READ(RTC_HOURS);
354-
day = CMOS_READ(RTC_DAY_OF_MONTH);
355-
mon = CMOS_READ(RTC_MONTH);
356-
year = CMOS_READ(RTC_YEAR);
357-
358-
if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
359-
sec = bcd2bin(sec);
360-
min = bcd2bin(min);
361-
hour = bcd2bin(hour);
362-
day = bcd2bin(day);
363-
mon = bcd2bin(mon);
364-
year = bcd2bin(year);
365-
}
366-
367-
/* PC-like is standard; used for year >= 70 */
368-
epoch = 1900;
369-
if (year < 20)
370-
epoch = 2000;
371-
else if (year >= 20 && year < 48)
372-
/* NT epoch */
373-
epoch = 1980;
374-
else if (year >= 48 && year < 70)
375-
/* Digital UNIX epoch */
376-
epoch = 1952;
377-
378-
printk(KERN_INFO "Using epoch = %d\n", epoch);
379-
380-
if ((year += epoch) < 1970)
381-
year += 100;
382-
383-
xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
384-
xtime.tv_nsec = 0;
385-
386-
wall_to_monotonic.tv_sec -= xtime.tv_sec;
387-
wall_to_monotonic.tv_nsec = 0;
388382

389383
if (HZ > (1<<16)) {
390384
extern void __you_loose (void);
@@ -394,7 +388,6 @@ time_init(void)
394388
state.last_time = cc1;
395389
state.scaled_ticks_per_cycle
396390
= ((unsigned long) HZ << FIX_SHIFT) / cycle_freq;
397-
state.last_rtc_update = 0;
398391
state.partial_tick = 0L;
399392

400393
/* Startup the timer source. */

‎arch/avr32/kernel/time.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,17 @@ static struct clock_event_device comparator = {
110110
.set_mode = comparator_mode,
111111
};
112112

113+
void read_persistent_clock(struct timespec *ts)
114+
{
115+
ts->tv_sec = mktime(2007, 1, 1, 0, 0, 0);
116+
ts->tv_nsec = 0;
117+
}
118+
113119
void __init time_init(void)
114120
{
115121
unsigned long counter_hz;
116122
int ret;
117123

118-
xtime.tv_sec = mktime(2007, 1, 1, 0, 0, 0);
119-
xtime.tv_nsec = 0;
120-
121-
set_normalized_timespec(&wall_to_monotonic,
122-
-xtime.tv_sec, -xtime.tv_nsec);
123-
124124
/* figure rate for counter */
125125
counter_hz = clk_get_rate(boot_cpu_data.clk);
126126
counter.mult = clocksource_hz2mult(counter_hz, counter.shift);

‎arch/blackfin/kernel/time-ts.c‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,15 @@ void bfin_coretmr_clockevent_init(void)
353353
#endif /* CONFIG_TICKSOURCE_CORETMR */
354354

355355

356-
void __init time_init(void)
356+
void read_persistent_clock(struct timespec *ts)
357357
{
358358
time_t secs_since_1970 = (365 * 37 + 9) * 24 * 60 * 60; /* 1 Jan 2007 */
359+
ts->tv_sec = secs_since_1970;
360+
ts->tv_nsec = 0;
361+
}
362+
363+
void __init time_init(void)
364+
{
359365

360366
#ifdef CONFIG_RTC_DRV_BFIN
361367
/* [#2663] hack to filter junk RTC values that would cause
@@ -368,11 +374,6 @@ void __init time_init(void)
368374
}
369375
#endif
370376

371-
/* Initialize xtime. From now on, xtime is updated with timer interrupts */
372-
xtime.tv_sec = secs_since_1970;
373-
xtime.tv_nsec = 0;
374-
set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec);
375-
376377
bfin_cs_cycles_init();
377378
bfin_cs_gptimer0_init();
378379

‎arch/blackfin/kernel/time.c‎

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,6 @@ u32 arch_gettimeoffset(void)
112112
}
113113
#endif
114114

115-
static inline int set_rtc_mmss(unsigned long nowtime)
116-
{
117-
return 0;
118-
}
119-
120115
/*
121116
* timer_interrupt() needs to keep up the real-time clock,
122117
* as well as call the "do_timer()" routine every clocktick
@@ -126,29 +121,8 @@ __attribute__((l1_text))
126121
#endif
127122
irqreturn_t timer_interrupt(int irq, void *dummy)
128123
{
129-
/* last time the cmos clock got updated */
130-
static long last_rtc_update;
131-
132124
write_seqlock(&xtime_lock);
133125
do_timer(1);
134-
135-
/*
136-
* If we have an externally synchronized Linux clock, then update
137-
* CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
138-
* called as close as possible to 500 ms before the new second starts.
139-
*/
140-
if (ntp_synced() &&
141-
xtime.tv_sec > last_rtc_update + 660 &&
142-
(xtime.tv_nsec / NSEC_PER_USEC) >=
143-
500000 - ((unsigned)TICK_SIZE) / 2
144-
&& (xtime.tv_nsec / NSEC_PER_USEC) <=
145-
500000 + ((unsigned)TICK_SIZE) / 2) {
146-
if (set_rtc_mmss(xtime.tv_sec) == 0)
147-
last_rtc_update = xtime.tv_sec;
148-
else
149-
/* Do it again in 60s. */
150-
last_rtc_update = xtime.tv_sec - 600;
151-
}
152126
write_sequnlock(&xtime_lock);
153127

154128
#ifdef CONFIG_IPIPE
@@ -161,10 +135,15 @@ irqreturn_t timer_interrupt(int irq, void *dummy)
161135
return IRQ_HANDLED;
162136
}
163137

164-
void __init time_init(void)
138+
void read_persistent_clock(struct timespec *ts)
165139
{
166140
time_t secs_since_1970 = (365 * 37 + 9) * 24 * 60 * 60; /* 1 Jan 2007 */
141+
ts->tv_sec = secs_since_1970;
142+
ts->tv_nsec = 0;
143+
}
167144

145+
void __init time_init(void)
146+
{
168147
#ifdef CONFIG_RTC_DRV_BFIN
169148
/* [#2663] hack to filter junk RTC values that would cause
170149
* userspace to have to deal with time values greater than
@@ -176,11 +155,5 @@ void __init time_init(void)
176155
}
177156
#endif
178157

179-
/* Initialize xtime. From now on, xtime is updated with timer interrupts */
180-
xtime.tv_sec = secs_since_1970;
181-
xtime.tv_nsec = 0;
182-
183-
wall_to_monotonic.tv_sec = -xtime.tv_sec;
184-
185158
time_sched_init(timer_interrupt);
186159
}

‎arch/cris/Kconfig‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ config RWSEM_XCHGADD_ALGORITHM
2323
config GENERIC_TIME
2424
def_bool y
2525

26+
config GENERIC_CMOS_UPDATE
27+
def_bool y
28+
2629
config ARCH_USES_GETTIMEOFFSET
2730
def_bool y
2831

‎arch/cris/arch-v10/kernel/time.c‎

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
/* it will make jiffies at 96 hz instead of 100 hz though */
2727
#undef USE_CASCADE_TIMERS
2828

29-
extern void update_xtime_from_cmos(void);
3029
extern int set_rtc_mmss(unsigned long nowtime);
3130
extern int have_rtc;
3231

@@ -188,8 +187,6 @@ stop_watchdog(void)
188187
#endif
189188
}
190189

191-
/* last time the cmos clock got updated */
192-
static long last_rtc_update = 0;
193190

194191
/*
195192
* timer_interrupt() needs to keep up the real-time clock,
@@ -232,24 +229,6 @@ timer_interrupt(int irq, void *dev_id)
232229
do_timer(1);
233230

234231
cris_do_profile(regs); /* Save profiling information */
235-
236-
/*
237-
* If we have an externally synchronized Linux clock, then update
238-
* CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
239-
* called as close as possible to 500 ms before the new second starts.
240-
*
241-
* The division here is not time critical since it will run once in
242-
* 11 minutes
243-
*/
244-
if (ntp_synced() &&
245-
xtime.tv_sec > last_rtc_update + 660 &&
246-
(xtime.tv_nsec / 1000) >= 500000 - (tick_nsec / 1000) / 2 &&
247-
(xtime.tv_nsec / 1000) <= 500000 + (tick_nsec / 1000) / 2) {
248-
if (set_rtc_mmss(xtime.tv_sec) == 0)
249-
last_rtc_update = xtime.tv_sec;
250-
else
251-
last_rtc_update = xtime.tv_sec - 600; /* do it again in 60 s */
252-
}
253232
return IRQ_HANDLED;
254233
}
255234

@@ -274,22 +253,10 @@ time_init(void)
274253
*/
275254
loops_per_usec = 50;
276255

277-
if(RTC_INIT() < 0) {
278-
/* no RTC, start at 1980 */
279-
xtime.tv_sec = 0;
280-
xtime.tv_nsec = 0;
256+
if(RTC_INIT() < 0)
281257
have_rtc = 0;
282-
} else {
283-
/* get the current time */
258+
else
284259
have_rtc = 1;
285-
update_xtime_from_cmos();
286-
}
287-
288-
/*
289-
* Initialize wall_to_monotonic such that adding it to xtime will yield zero, the
290-
* tv_nsec field must be normalized (i.e., 0 <= nsec < NSEC_PER_SEC).
291-
*/
292-
set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec);
293260

294261
/* Setup the etrax timers
295262
* Base frequency is 25000 hz, divider 250 -> 100 HZ

0 commit comments

Comments
 (0)