diff options
author | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2009-08-14 09:47:31 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2009-08-15 04:55:46 -0400 |
commit | d4f587c67fc39e0030ddd718675e252e208da4d7 (patch) | |
tree | 2222681c57966cc6b8404afdff3ab1a09ac7ea69 /arch/mips | |
parent | 75c5158f70c065b9704b924503d96e8297838f79 (diff) |
timekeeping: Increase granularity of read_persistent_clock()
The persistent clock of some architectures (e.g. s390) have a
better granularity than seconds. To reduce the delta between the
host clock and the guest clock in a virtualized system change the
read_persistent_clock function to return a struct timespec.
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Acked-by: John Stultz <johnstul@us.ibm.com>
Cc: Daniel Walker <dwalker@fifo99.com>
LKML-Reference: <20090814134811.013873340@de.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/mips')
-rw-r--r-- | arch/mips/dec/time.c | 5 | ||||
-rw-r--r-- | arch/mips/lasat/ds1603.c | 5 | ||||
-rw-r--r-- | arch/mips/lasat/sysctl.c | 8 | ||||
-rw-r--r-- | arch/mips/lemote/lm2e/setup.c | 5 | ||||
-rw-r--r-- | arch/mips/mti-malta/malta-time.c | 5 | ||||
-rw-r--r-- | arch/mips/pmc-sierra/yosemite/setup.c | 5 | ||||
-rw-r--r-- | arch/mips/sibyte/swarm/setup.c | 15 | ||||
-rw-r--r-- | arch/mips/sni/time.c | 5 |
8 files changed, 35 insertions, 18 deletions
diff --git a/arch/mips/dec/time.c b/arch/mips/dec/time.c index 463136e6685a..02f505f23c32 100644 --- a/arch/mips/dec/time.c +++ b/arch/mips/dec/time.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <asm/dec/ioasic.h> | 18 | #include <asm/dec/ioasic.h> |
19 | #include <asm/dec/machtype.h> | 19 | #include <asm/dec/machtype.h> |
20 | 20 | ||
21 | unsigned long read_persistent_clock(void) | 21 | void read_persistent_clock(struct timespec *ts) |
22 | { | 22 | { |
23 | unsigned int year, mon, day, hour, min, sec, real_year; | 23 | unsigned int year, mon, day, hour, min, sec, real_year; |
24 | unsigned long flags; | 24 | unsigned long flags; |
@@ -53,7 +53,8 @@ unsigned long read_persistent_clock(void) | |||
53 | 53 | ||
54 | year += real_year - 72 + 2000; | 54 | year += real_year - 72 + 2000; |
55 | 55 | ||
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; | ||
57 | } | 58 | } |
58 | 59 | ||
59 | /* | 60 | /* |
diff --git a/arch/mips/lasat/ds1603.c b/arch/mips/lasat/ds1603.c index 52cb1436a12a..c6fd96ff118d 100644 --- a/arch/mips/lasat/ds1603.c +++ b/arch/mips/lasat/ds1603.c | |||
@@ -135,7 +135,7 @@ static void rtc_end_op(void) | |||
135 | lasat_ndelay(1000); | 135 | lasat_ndelay(1000); |
136 | } | 136 | } |
137 | 137 | ||
138 | unsigned long read_persistent_clock(void) | 138 | void read_persistent_clock(struct timespec *ts) |
139 | { | 139 | { |
140 | unsigned long word; | 140 | unsigned long word; |
141 | unsigned long flags; | 141 | unsigned long flags; |
@@ -147,7 +147,8 @@ unsigned long read_persistent_clock(void) | |||
147 | rtc_end_op(); | 147 | rtc_end_op(); |
148 | spin_unlock_irqrestore(&rtc_lock, flags); | 148 | spin_unlock_irqrestore(&rtc_lock, flags); |
149 | 149 | ||
150 | return word; | 150 | ts->tv_sec = word; |
151 | ts->tv_nsec = 0; | ||
151 | } | 152 | } |
152 | 153 | ||
153 | int rtc_mips_set_mmss(unsigned long time) | 154 | int rtc_mips_set_mmss(unsigned long time) |
diff --git a/arch/mips/lasat/sysctl.c b/arch/mips/lasat/sysctl.c index 8f88886feb12..3f04d4c406b7 100644 --- a/arch/mips/lasat/sysctl.c +++ b/arch/mips/lasat/sysctl.c | |||
@@ -92,10 +92,12 @@ static int rtctmp; | |||
92 | int proc_dolasatrtc(ctl_table *table, int write, struct file *filp, | 92 | int proc_dolasatrtc(ctl_table *table, int write, struct file *filp, |
93 | void *buffer, size_t *lenp, loff_t *ppos) | 93 | void *buffer, size_t *lenp, loff_t *ppos) |
94 | { | 94 | { |
95 | struct timespec ts; | ||
95 | int r; | 96 | int r; |
96 | 97 | ||
97 | if (!write) { | 98 | if (!write) { |
98 | rtctmp = read_persistent_clock(); | 99 | read_persistent_clock(&ts); |
100 | rtctmp = ts.tv_sec; | ||
99 | /* check for time < 0 and set to 0 */ | 101 | /* check for time < 0 and set to 0 */ |
100 | if (rtctmp < 0) | 102 | if (rtctmp < 0) |
101 | rtctmp = 0; | 103 | rtctmp = 0; |
@@ -134,9 +136,11 @@ int sysctl_lasat_rtc(ctl_table *table, | |||
134 | void *oldval, size_t *oldlenp, | 136 | void *oldval, size_t *oldlenp, |
135 | void *newval, size_t newlen) | 137 | void *newval, size_t newlen) |
136 | { | 138 | { |
139 | struct timespec ts; | ||
137 | int r; | 140 | int r; |
138 | 141 | ||
139 | rtctmp = read_persistent_clock(); | 142 | read_persistent_clock(&ts); |
143 | rtctmp = ts.tv_sec; | ||
140 | if (rtctmp < 0) | 144 | if (rtctmp < 0) |
141 | rtctmp = 0; | 145 | rtctmp = 0; |
142 | r = sysctl_intvec(table, oldval, oldlenp, newval, newlen); | 146 | r = sysctl_intvec(table, oldval, oldlenp, newval, newlen); |
diff --git a/arch/mips/lemote/lm2e/setup.c b/arch/mips/lemote/lm2e/setup.c index ebd6ceaef2fd..24b355df6127 100644 --- a/arch/mips/lemote/lm2e/setup.c +++ b/arch/mips/lemote/lm2e/setup.c | |||
@@ -54,9 +54,10 @@ void __init plat_time_init(void) | |||
54 | mips_hpt_frequency = cpu_clock_freq / 2; | 54 | mips_hpt_frequency = cpu_clock_freq / 2; |
55 | } | 55 | } |
56 | 56 | ||
57 | unsigned long read_persistent_clock(void) | 57 | void read_persistent_clock(struct timespec *ts) |
58 | { | 58 | { |
59 | return mc146818_get_cmos_time(); | 59 | ts->tv_sec = mc146818_get_cmos_time(); |
60 | ts->tv_nsec = 0; | ||
60 | } | 61 | } |
61 | 62 | ||
62 | void (*__wbflush)(void); | 63 | void (*__wbflush)(void); |
diff --git a/arch/mips/mti-malta/malta-time.c b/arch/mips/mti-malta/malta-time.c index 0b97d47691fc..3c6f190aa61c 100644 --- a/arch/mips/mti-malta/malta-time.c +++ b/arch/mips/mti-malta/malta-time.c | |||
@@ -100,9 +100,10 @@ static unsigned int __init estimate_cpu_frequency(void) | |||
100 | return count; | 100 | return count; |
101 | } | 101 | } |
102 | 102 | ||
103 | unsigned long read_persistent_clock(void) | 103 | void read_persistent_clock(struct timespec *ts) |
104 | { | 104 | { |
105 | return mc146818_get_cmos_time(); | 105 | ts->tv_sec = mc146818_get_cmos_time(); |
106 | ts->tv_nsec = 0; | ||
106 | } | 107 | } |
107 | 108 | ||
108 | static void __init plat_perf_setup(void) | 109 | static void __init plat_perf_setup(void) |
diff --git a/arch/mips/pmc-sierra/yosemite/setup.c b/arch/mips/pmc-sierra/yosemite/setup.c index 2d3c0dca275d..3498ac9c35af 100644 --- a/arch/mips/pmc-sierra/yosemite/setup.c +++ b/arch/mips/pmc-sierra/yosemite/setup.c | |||
@@ -70,7 +70,7 @@ void __init bus_error_init(void) | |||
70 | } | 70 | } |
71 | 71 | ||
72 | 72 | ||
73 | unsigned long read_persistent_clock(void) | 73 | void read_persistent_clock(struct timespec *ts) |
74 | { | 74 | { |
75 | unsigned int year, month, day, hour, min, sec; | 75 | unsigned int year, month, day, hour, min, sec; |
76 | unsigned long flags; | 76 | unsigned long flags; |
@@ -92,7 +92,8 @@ unsigned long read_persistent_clock(void) | |||
92 | m48t37_base->control = 0x00; | 92 | m48t37_base->control = 0x00; |
93 | spin_unlock_irqrestore(&rtc_lock, flags); | 93 | spin_unlock_irqrestore(&rtc_lock, flags); |
94 | 94 | ||
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; | ||
96 | } | 97 | } |
97 | 98 | ||
98 | int rtc_mips_set_time(unsigned long tim) | 99 | int rtc_mips_set_time(unsigned long tim) |
diff --git a/arch/mips/sibyte/swarm/setup.c b/arch/mips/sibyte/swarm/setup.c index 672e45d495a9..623ffc933c4c 100644 --- a/arch/mips/sibyte/swarm/setup.c +++ b/arch/mips/sibyte/swarm/setup.c | |||
@@ -87,19 +87,26 @@ enum swarm_rtc_type { | |||
87 | 87 | ||
88 | enum swarm_rtc_type swarm_rtc_type; | 88 | enum swarm_rtc_type swarm_rtc_type; |
89 | 89 | ||
90 | unsigned long read_persistent_clock(void) | 90 | void read_persistent_clock(struct timespec *ts) |
91 | { | 91 | { |
92 | unsigned long sec; | ||
93 | |||
92 | switch (swarm_rtc_type) { | 94 | switch (swarm_rtc_type) { |
93 | case RTC_XICOR: | 95 | case RTC_XICOR: |
94 | return xicor_get_time(); | 96 | sec = xicor_get_time(); |
97 | break; | ||
95 | 98 | ||
96 | case RTC_M4LT81: | 99 | case RTC_M4LT81: |
97 | return m41t81_get_time(); | 100 | sec = m41t81_get_time(); |
101 | break; | ||
98 | 102 | ||
99 | case RTC_NONE: | 103 | case RTC_NONE: |
100 | default: | 104 | default: |
101 | return mktime(2000, 1, 1, 0, 0, 0); | 105 | sec = mktime(2000, 1, 1, 0, 0, 0); |
106 | break; | ||
102 | } | 107 | } |
108 | ts->tv_sec = sec; | ||
109 | tv->tv_nsec = 0; | ||
103 | } | 110 | } |
104 | 111 | ||
105 | int rtc_mips_set_time(unsigned long sec) | 112 | int rtc_mips_set_time(unsigned long sec) |
diff --git a/arch/mips/sni/time.c b/arch/mips/sni/time.c index 0d9ec1a5c24a..62df6a598e0a 100644 --- a/arch/mips/sni/time.c +++ b/arch/mips/sni/time.c | |||
@@ -182,7 +182,8 @@ void __init plat_time_init(void) | |||
182 | setup_pit_timer(); | 182 | setup_pit_timer(); |
183 | } | 183 | } |
184 | 184 | ||
185 | unsigned long read_persistent_clock(void) | 185 | void read_persistent_clock(struct timespec *ts) |
186 | { | 186 | { |
187 | return -1; | 187 | ts->tv_sec = -1; |
188 | ts->tv_nsec = 0; | ||
188 | } | 189 | } |