public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86
@ 2006-03-17 23:30 Matt Mackall
  2006-03-17 23:30 ` [PATCH 4/14] RTC: Remove RTC UIP synchronization on PPC CHRP (arch/ppc) Matt Mackall
                   ` (13 more replies)
  0 siblings, 14 replies; 21+ messages in thread
From: Matt Mackall @ 2006-03-17 23:30 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

Remove RTC UIP synchronization on x86

Reading the CMOS clock on x86 and some other arches currently takes up
to one second because it synchronizes with the CMOS second tick-over.
This delay shows up at boot time as well a resume time.

This is the currently the most substantial boot time delay for
machines that are working towards instant-on capability. Also, a quick
back of the envelope calculation (.5sec * 2M users * 1 boot a day * 10 years)
suggests it has cost Linux users in the neighborhood of a million
man-hours.

An earlier thread on this topic is here:

http://groups.google.com/group/linux.kernel/browse_frm/thread/8a24255215ff6151/2aa97e66a977653d?hl=en&lr=&ie=UTF-8&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26selm%3D1To2R-2S7-11%40gated-at.bofh.it#2aa97e66a977653d

..from which the consensus seems to be that it's no longer desirable.

In my view, there are basically four cases to consider:

1) networked, need precise walltime: use NTP
2) networked, don't need precise walltime: use NTP anyway
3) not networked, don't need sub-second precision walltime: don't care
4) not networked, need sub-second precision walltime:
   get a network or a radio time source because RTC isn't good enough anyway

So this patch series simply removes the synchronization in favor of a
simple seqlock-like approach using the seconds value.

Note that for purposes of timer accuracy on wakeup, this patch will
cause us to fire timers up to one second late. But as the current
timer resume code will already sync once (or more!), it's no worse for
short timers.


Index: 2.6.16-rc4-rtc/include/asm-i386/mach-default/mach_time.h
===================================================================
--- 2.6.16-rc4-rtc.orig/include/asm-i386/mach-default/mach_time.h	2006-02-24 15:48:47.000000000 -0600
+++ 2.6.16-rc4-rtc/include/asm-i386/mach-default/mach_time.h	2006-02-24 15:49:41.000000000 -0600
@@ -82,21 +82,8 @@ static inline int mach_set_rtc_mmss(unsi
 static inline unsigned long mach_get_cmos_time(void)
 {
 	unsigned int year, mon, day, hour, min, sec;
-	int i;
 
-	/* The Linux interpretation of the CMOS clock register contents:
-	 * When the Update-In-Progress (UIP) flag goes from 1 to 0, the
-	 * RTC registers show the second which has precisely just started.
-	 * Let's hope other operating systems interpret the RTC the same way.
-	 */
-	/* read RTC exactly on falling edge of update flag */
-	for (i = 0 ; i < 1000000 ; i++)	/* may take up to 1 second... */
-		if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP)
-			break;
-	for (i = 0 ; i < 1000000 ; i++)	/* must try at least 2.228 ms */
-		if (!(CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP))
-			break;
-	do { /* Isn't this overkill ? UIP above should guarantee consistency */
+	do {
 		sec = CMOS_READ(RTC_SECONDS);
 		min = CMOS_READ(RTC_MINUTES);
 		hour = CMOS_READ(RTC_HOURS);
@@ -104,6 +91,7 @@ static inline unsigned long mach_get_cmo
 		mon = CMOS_READ(RTC_MONTH);
 		year = CMOS_READ(RTC_YEAR);
 	} while (sec != CMOS_READ(RTC_SECONDS));
+
 	if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
 	  {
 	    BCD_TO_BIN(sec);

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2006-03-21 18:41 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-17 23:30 [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86 Matt Mackall
2006-03-17 23:30 ` [PATCH 4/14] RTC: Remove RTC UIP synchronization on PPC CHRP (arch/ppc) Matt Mackall
2006-03-17 23:30 ` [PATCH 2/14] RTC: Remove RTC UIP synchronization on x86_64 Matt Mackall
2006-03-18  5:52   ` Andrew Morton
2006-03-18 14:16     ` Matt Mackall
2006-03-17 23:30 ` [PATCH 3/14] RTC: Remove RTC UIP synchronization on Sparc64 Matt Mackall
2006-03-17 23:30 ` [PATCH 8/14] RTC: Remove RTC UIP synchronization on MIPS MC146818 Matt Mackall
2006-03-17 23:30 ` [PATCH 6/14] RTC: Remove RTC UIP synchronization on PPC Maple Matt Mackall
2006-03-17 23:30 ` [PATCH 7/14] RTC: Remove RTC UIP synchronization on MIPS Footbridge Matt Mackall
2006-03-17 23:58   ` Matt Mackall
2006-03-17 23:30 ` [PATCH 5/14] RTC: Remove RTC UIP synchronization on CHRP (arch/powerpc) Matt Mackall
2006-03-17 23:30 ` [PATCH 11/14] RTC: Remove RTC UIP synchronization on SH MPC1211 Matt Mackall
2006-03-17 23:30 ` [PATCH 10/14] RTC: Remove RTC UIP synchronization on SH03 Matt Mackall
2006-03-17 23:30 ` [PATCH 9/14] RTC: Remove RTC UIP synchronization on MIPS-based DEC Matt Mackall
2006-03-17 23:30 ` [PATCH 12/14] RTC: Remove RTC UIP synchronization on Alpha Matt Mackall
2006-03-17 23:30 ` [PATCH 13/14] RTC: Fix up some RTC whitespace and style Matt Mackall
2006-03-17 23:30 ` [PATCH 14/14] RTC: Remove some duplicate BCD definitions Matt Mackall
2006-03-18  5:53   ` Andrew Morton
2006-03-19 18:13 ` [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86 Pavel Machek
2006-03-21 16:38   ` Matt Mackall
2006-03-21 18:40     ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox