Skip to content

Commit a03fdb7

Browse files
committed
Merge branch 'timers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'timers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (34 commits) time: Prevent 32 bit overflow with set_normalized_timespec() clocksource: Delay clocksource down rating to late boot clocksource: clocksource_select must be called with mutex locked clocksource: Resolve cpu hotplug dead lock with TSC unstable, fix crash timers: Drop a function prototype clocksource: Resolve cpu hotplug dead lock with TSC unstable timer.c: Fix S/390 comments timekeeping: Fix invalid getboottime() value timekeeping: Fix up read_persistent_clock() breakage on sh timekeeping: Increase granularity of read_persistent_clock(), build fix time: Introduce CLOCK_REALTIME_COARSE x86: Do not unregister PIT clocksource on PIT oneshot setup/shutdown clocksource: Avoid clocksource watchdog circular locking dependency clocksource: Protect the watchdog rating changes with clocksource_mutex clocksource: Call clocksource_change_rating() outside of watchdog_lock timekeeping: Introduce read_boot_clock timekeeping: Increase granularity of read_persistent_clock() timekeeping: Update clocksource with stop_machine timekeeping: Add timekeeper read_clock helper functions timekeeping: Move NTP adjusted clock multiplier to struct timekeeper ... Fix trivial conflict due to MIPS lemote -> loongson renaming.
2 parents 202c467 + 12e0933 commit a03fdb7

File tree

32 files changed

+917
-640
lines changed

32 files changed

+917
-640
lines changed

arch/arm/plat-omap/common.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,8 @@ static struct clocksource clocksource_32k = {
253253
*/
254254
unsigned long long sched_clock(void)
255255
{
256-
unsigned long long ret;
257-
258-
ret = (unsigned long long)clocksource_32k.read(&clocksource_32k);
259-
ret = (ret * clocksource_32k.mult_orig) >> clocksource_32k.shift;
260-
return ret;
256+
return clocksource_cyc2ns(clocksource_32k.read(&clocksource_32k),
257+
clocksource_32k.mult, clocksource_32k.shift);
261258
}
262259

263260
static int __init omap_init_clocksource_32k(void)

arch/m68knommu/kernel/time.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ static unsigned long read_rtc_mmss(void)
7272
return mktime(year, mon, day, hour, min, sec);
7373
}
7474

75-
unsigned long read_persistent_clock(void)
75+
void read_persistent_clock(struct timespec *ts)
7676
{
77-
return read_rtc_mmss();
77+
ts->tv_sec = read_rtc_mmss();
78+
ts->tv_nsec = 0;
7879
}
7980

8081
int update_persistent_clock(struct timespec now)

arch/mips/dec/time.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <asm/dec/ioasic.h>
1919
#include <asm/dec/machtype.h>
2020

21-
unsigned long read_persistent_clock(void)
21+
void read_persistent_clock(struct timespec *ts)
2222
{
2323
unsigned int year, mon, day, hour, min, sec, real_year;
2424
unsigned long flags;
@@ -53,7 +53,8 @@ unsigned long read_persistent_clock(void)
5353

5454
year += real_year - 72 + 2000;
5555

56-
return mktime(year, mon, day, hour, min, sec);
56+
ts->tv_sec = mktime(year, mon, day, hour, min, sec);
57+
ts->tv_nsec = 0;
5758
}
5859

5960
/*

arch/mips/lasat/ds1603.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static void rtc_end_op(void)
135135
lasat_ndelay(1000);
136136
}
137137

138-
unsigned long read_persistent_clock(void)
138+
void read_persistent_clock(struct timespec *ts)
139139
{
140140
unsigned long word;
141141
unsigned long flags;
@@ -147,7 +147,8 @@ unsigned long read_persistent_clock(void)
147147
rtc_end_op();
148148
spin_unlock_irqrestore(&rtc_lock, flags);
149149

150-
return word;
150+
ts->tv_sec = word;
151+
ts->tv_nsec = 0;
151152
}
152153

153154
int rtc_mips_set_mmss(unsigned long time)

arch/mips/lasat/sysctl.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ static int rtctmp;
9292
int proc_dolasatrtc(ctl_table *table, int write, struct file *filp,
9393
void *buffer, size_t *lenp, loff_t *ppos)
9494
{
95+
struct timespec ts;
9596
int r;
9697

9798
if (!write) {
98-
rtctmp = read_persistent_clock();
99+
read_persistent_clock(&ts);
100+
rtctmp = ts.tv_sec;
99101
/* check for time < 0 and set to 0 */
100102
if (rtctmp < 0)
101103
rtctmp = 0;
@@ -134,9 +136,11 @@ int sysctl_lasat_rtc(ctl_table *table,
134136
void *oldval, size_t *oldlenp,
135137
void *newval, size_t newlen)
136138
{
139+
struct timespec ts;
137140
int r;
138141

139-
rtctmp = read_persistent_clock();
142+
read_persistent_clock(&ts);
143+
rtctmp = ts.tv_sec;
140144
if (rtctmp < 0)
141145
rtctmp = 0;
142146
r = sysctl_intvec(table, oldval, oldlenp, newval, newlen);

arch/mips/loongson/common/time.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ void __init plat_time_init(void)
2121
mips_hpt_frequency = cpu_clock_freq / 2;
2222
}
2323

24-
unsigned long read_persistent_clock(void)
24+
void read_persistent_clock(struct timespec *ts)
2525
{
26-
return mc146818_get_cmos_time();
26+
ts->tv_sec = return mc146818_get_cmos_time();
27+
ts->tv_nsec = 0;
2728
}

arch/mips/mti-malta/malta-time.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ static unsigned int __init estimate_cpu_frequency(void)
100100
return count;
101101
}
102102

103-
unsigned long read_persistent_clock(void)
103+
void read_persistent_clock(struct timespec *ts)
104104
{
105-
return mc146818_get_cmos_time();
105+
ts->tv_sec = mc146818_get_cmos_time();
106+
ts->tv_nsec = 0;
106107
}
107108

108109
static void __init plat_perf_setup(void)

arch/mips/pmc-sierra/yosemite/setup.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void __init bus_error_init(void)
7070
}
7171

7272

73-
unsigned long read_persistent_clock(void)
73+
void read_persistent_clock(struct timespec *ts)
7474
{
7575
unsigned int year, month, day, hour, min, sec;
7676
unsigned long flags;
@@ -92,7 +92,8 @@ unsigned long read_persistent_clock(void)
9292
m48t37_base->control = 0x00;
9393
spin_unlock_irqrestore(&rtc_lock, flags);
9494

95-
return mktime(year, month, day, hour, min, sec);
95+
ts->tv_sec = mktime(year, month, day, hour, min, sec);
96+
ts->tv_nsec = 0;
9697
}
9798

9899
int rtc_mips_set_time(unsigned long tim)

arch/mips/sibyte/swarm/setup.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,26 @@ enum swarm_rtc_type {
8787

8888
enum swarm_rtc_type swarm_rtc_type;
8989

90-
unsigned long read_persistent_clock(void)
90+
void read_persistent_clock(struct timespec *ts)
9191
{
92+
unsigned long sec;
93+
9294
switch (swarm_rtc_type) {
9395
case RTC_XICOR:
94-
return xicor_get_time();
96+
sec = xicor_get_time();
97+
break;
9598

9699
case RTC_M4LT81:
97-
return m41t81_get_time();
100+
sec = m41t81_get_time();
101+
break;
98102

99103
case RTC_NONE:
100104
default:
101-
return mktime(2000, 1, 1, 0, 0, 0);
105+
sec = mktime(2000, 1, 1, 0, 0, 0);
106+
break;
102107
}
108+
ts->tv_sec = sec;
109+
tv->tv_nsec = 0;
103110
}
104111

105112
int rtc_mips_set_time(unsigned long sec)

arch/mips/sni/time.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ void __init plat_time_init(void)
182182
setup_pit_timer();
183183
}
184184

185-
unsigned long read_persistent_clock(void)
185+
void read_persistent_clock(struct timespec *ts)
186186
{
187-
return -1;
187+
ts->tv_sec = -1;
188+
ts->tv_nsec = 0;
188189
}

arch/powerpc/kernel/time.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -774,26 +774,31 @@ int update_persistent_clock(struct timespec now)
774774
return ppc_md.set_rtc_time(&tm);
775775
}
776776

777-
unsigned long read_persistent_clock(void)
777+
void read_persistent_clock(struct timespec *ts)
778778
{
779779
struct rtc_time tm;
780780
static int first = 1;
781781

782+
ts->tv_nsec = 0;
782783
/* XXX this is a litle fragile but will work okay in the short term */
783784
if (first) {
784785
first = 0;
785786
if (ppc_md.time_init)
786787
timezone_offset = ppc_md.time_init();
787788

788789
/* get_boot_time() isn't guaranteed to be safe to call late */
789-
if (ppc_md.get_boot_time)
790-
return ppc_md.get_boot_time() -timezone_offset;
790+
if (ppc_md.get_boot_time) {
791+
ts->tv_sec = ppc_md.get_boot_time() - timezone_offset;
792+
return;
793+
}
794+
}
795+
if (!ppc_md.get_rtc_time) {
796+
ts->tv_sec = 0;
797+
return;
791798
}
792-
if (!ppc_md.get_rtc_time)
793-
return 0;
794799
ppc_md.get_rtc_time(&tm);
795-
return mktime(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
796-
tm.tm_hour, tm.tm_min, tm.tm_sec);
800+
ts->tv_sec = mktime(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
801+
tm.tm_hour, tm.tm_min, tm.tm_sec);
797802
}
798803

799804
/* clocksource code */

arch/s390/kernel/time.c

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,14 @@ static void timing_alert_interrupt(__u16 code)
184184
static void etr_reset(void);
185185
static void stp_reset(void);
186186

187-
unsigned long read_persistent_clock(void)
187+
void read_persistent_clock(struct timespec *ts)
188188
{
189-
struct timespec ts;
189+
tod_to_timeval(get_clock() - TOD_UNIX_EPOCH, ts);
190+
}
190191

191-
tod_to_timeval(get_clock() - TOD_UNIX_EPOCH, &ts);
192-
return ts.tv_sec;
192+
void read_boot_clock(struct timespec *ts)
193+
{
194+
tod_to_timeval(sched_clock_base_cc - TOD_UNIX_EPOCH, ts);
193195
}
194196

195197
static cycle_t read_tod_clock(struct clocksource *cs)
@@ -207,6 +209,10 @@ static struct clocksource clocksource_tod = {
207209
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
208210
};
209211

212+
struct clocksource * __init clocksource_default_clock(void)
213+
{
214+
return &clocksource_tod;
215+
}
210216

211217
void update_vsyscall(struct timespec *wall_time, struct clocksource *clock)
212218
{
@@ -244,10 +250,6 @@ void update_vsyscall_tz(void)
244250
*/
245251
void __init time_init(void)
246252
{
247-
struct timespec ts;
248-
unsigned long flags;
249-
cycle_t now;
250-
251253
/* Reset time synchronization interfaces. */
252254
etr_reset();
253255
stp_reset();
@@ -263,26 +265,6 @@ void __init time_init(void)
263265
if (clocksource_register(&clocksource_tod) != 0)
264266
panic("Could not register TOD clock source");
265267

266-
/*
267-
* The TOD clock is an accurate clock. The xtime should be
268-
* initialized in a way that the difference between TOD and
269-
* xtime is reasonably small. Too bad that timekeeping_init
270-
* sets xtime.tv_nsec to zero. In addition the clock source
271-
* change from the jiffies clock source to the TOD clock
272-
* source add another error of up to 1/HZ second. The same
273-
* function sets wall_to_monotonic to a value that is too
274-
* small for /proc/uptime to be accurate.
275-
* Reset xtime and wall_to_monotonic to sane values.
276-
*/
277-
write_seqlock_irqsave(&xtime_lock, flags);
278-
now = get_clock();
279-
tod_to_timeval(now - TOD_UNIX_EPOCH, &xtime);
280-
clocksource_tod.cycle_last = now;
281-
clocksource_tod.raw_time = xtime;
282-
tod_to_timeval(sched_clock_base_cc - TOD_UNIX_EPOCH, &ts);
283-
set_normalized_timespec(&wall_to_monotonic, -ts.tv_sec, -ts.tv_nsec);
284-
write_sequnlock_irqrestore(&xtime_lock, flags);
285-
286268
/* Enable TOD clock interrupts on the boot cpu. */
287269
init_cpu_timer();
288270

arch/sh/kernel/time.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,9 @@ void (*rtc_sh_get_time)(struct timespec *) = null_rtc_get_time;
3939
int (*rtc_sh_set_time)(const time_t) = null_rtc_set_time;
4040

4141
#ifdef CONFIG_GENERIC_CMOS_UPDATE
42-
unsigned long read_persistent_clock(void)
42+
void read_persistent_clock(struct timespec *ts)
4343
{
44-
struct timespec tv;
45-
rtc_sh_get_time(&tv);
46-
return tv.tv_sec;
44+
rtc_sh_get_time(ts);
4745
}
4846

4947
int update_persistent_clock(struct timespec now)

arch/x86/include/asm/vgtod.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct vsyscall_gtod_data {
2121
u32 shift;
2222
} clock;
2323
struct timespec wall_to_monotonic;
24+
struct timespec wall_time_coarse;
2425
};
2526
extern struct vsyscall_gtod_data __vsyscall_gtod_data
2627
__section_vsyscall_gtod_data;

arch/x86/kernel/i8253.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@
1919
DEFINE_SPINLOCK(i8253_lock);
2020
EXPORT_SYMBOL(i8253_lock);
2121

22-
#ifdef CONFIG_X86_32
23-
static void pit_disable_clocksource(void);
24-
#else
25-
static inline void pit_disable_clocksource(void) { }
26-
#endif
27-
2822
/*
2923
* HPET replaces the PIT, when enabled. So we need to know, which of
3024
* the two timers is used
@@ -57,12 +51,10 @@ static void init_pit_timer(enum clock_event_mode mode,
5751
outb_pit(0, PIT_CH0);
5852
outb_pit(0, PIT_CH0);
5953
}
60-
pit_disable_clocksource();
6154
break;
6255

6356
case CLOCK_EVT_MODE_ONESHOT:
6457
/* One shot setup */
65-
pit_disable_clocksource();
6658
outb_pit(0x38, PIT_MODE);
6759
break;
6860

@@ -200,17 +192,6 @@ static struct clocksource pit_cs = {
200192
.shift = 20,
201193
};
202194

203-
static void pit_disable_clocksource(void)
204-
{
205-
/*
206-
* Use mult to check whether it is registered or not
207-
*/
208-
if (pit_cs.mult) {
209-
clocksource_unregister(&pit_cs);
210-
pit_cs.mult = 0;
211-
}
212-
}
213-
214195
static int __init init_pit_clocksource(void)
215196
{
216197
/*

arch/x86/kernel/rtc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,16 @@ static int set_rtc_mmss(unsigned long nowtime)
178178
}
179179

180180
/* not static: needed by APM */
181-
unsigned long read_persistent_clock(void)
181+
void read_persistent_clock(struct timespec *ts)
182182
{
183183
unsigned long retval, flags;
184184

185185
spin_lock_irqsave(&rtc_lock, flags);
186186
retval = get_wallclock();
187187
spin_unlock_irqrestore(&rtc_lock, flags);
188188

189-
return retval;
189+
ts->tv_sec = retval;
190+
ts->tv_nsec = 0;
190191
}
191192

192193
int update_persistent_clock(struct timespec now)

0 commit comments

Comments
 (0)