* [PATCH 2/14] RTC: Remove RTC UIP synchronization on x86_64
2006-03-17 23:30 [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86 Matt Mackall
@ 2006-03-17 23:30 ` Matt Mackall
2006-03-18 5:52 ` Andrew Morton
2006-03-17 23:30 ` [PATCH 4/14] RTC: Remove RTC UIP synchronization on PPC CHRP (arch/ppc) Matt Mackall
` (12 subsequent siblings)
13 siblings, 1 reply; 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_64
Signed-off-by: Matt Mackall <mpm@selenic.com>
Index: rtc/arch/x86_64/kernel/time.c
===================================================================
--- rtc.orig/arch/x86_64/kernel/time.c 2006-03-16 16:48:38.000000000 -0600
+++ rtc/arch/x86_64/kernel/time.c 2006-03-16 17:21:17.000000000 -0600
@@ -514,36 +514,19 @@ unsigned long long sched_clock(void)
static unsigned long get_cmos_time(void)
{
- unsigned int timeout = 1000000, year, mon, day, hour, min, sec;
- unsigned char uip = 0, this = 0;
+ unsigned int year, mon, day, hour, min, sec;
unsigned long flags;
-/*
- * 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. Waiting for this can take up to 1
- * second, we timeout approximately after 2.4 seconds on a machine with
- * standard 8.3 MHz ISA bus.
- */
-
spin_lock_irqsave(&rtc_lock, flags);
- while (timeout && (!uip || this)) {
- uip |= this;
- this = CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP;
- timeout--;
- }
-
- /*
- * Here we are safe to assume the registers won't change for a whole
- * second, so we just go ahead and read them.
- */
- sec = CMOS_READ(RTC_SECONDS);
- min = CMOS_READ(RTC_MINUTES);
- hour = CMOS_READ(RTC_HOURS);
- day = CMOS_READ(RTC_DAY_OF_MONTH);
- mon = CMOS_READ(RTC_MONTH);
- year = CMOS_READ(RTC_YEAR);
+ do {
+ sec = CMOS_READ(RTC_SECONDS);
+ min = CMOS_READ(RTC_MINUTES);
+ hour = CMOS_READ(RTC_HOURS);
+ day = CMOS_READ(RTC_DAY_OF_MONTH);
+ mon = CMOS_READ(RTC_MONTH);
+ year = CMOS_READ(RTC_YEAR);
+ } while (sec != CMOS_READ(RTC_SECONDS));
spin_unlock_irqrestore(&rtc_lock, flags);
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH 2/14] RTC: Remove RTC UIP synchronization on x86_64
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
0 siblings, 1 reply; 21+ messages in thread
From: Andrew Morton @ 2006-03-18 5:52 UTC (permalink / raw)
To: Matt Mackall; +Cc: linux-kernel
Matt Mackall <mpm@selenic.com> wrote:
>
> Remove RTC UIP synchronization on x86_64
Needed rework due to pending changes in get_cmos_time(). Please
check the result.
Patches which affect arch/x86_64/kernel/time.c:
hpet-rtc-emulation-add-watchdog-timer.patch
mark-cyc2ns_scale-readmostly.patch
x86_64-mm-lost-ticks-dump-rip.patch
x86_64-mm-pmtimer-dont-touch-pit.patch
x86_64-mm-reenable-cmos-warning.patch
x86_64-mm-time-style.patch
x86_64-mm-year-check.patch
There are >1600 patches queued up already. There's already a large RTC patch
series from Alessandro Zummo which has been queued for the last several
-mm's.
Your patches did merge up okayish but if they cause significant problems
I'll drop them, sorry.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/14] RTC: Remove RTC UIP synchronization on x86_64
2006-03-18 5:52 ` Andrew Morton
@ 2006-03-18 14:16 ` Matt Mackall
0 siblings, 0 replies; 21+ messages in thread
From: Matt Mackall @ 2006-03-18 14:16 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
On Fri, Mar 17, 2006 at 09:52:55PM -0800, Andrew Morton wrote:
> Matt Mackall <mpm@selenic.com> wrote:
> >
> > Remove RTC UIP synchronization on x86_64
>
> Needed rework due to pending changes in get_cmos_time(). Please
> check the result.
I did a test merge against -mm before I sent it off, and saw a minor
conflict with real_year that was easily fixed up. Assume you had no
trouble with it.
> There are >1600 patches queued up already. There's already a large RTC patch
> series from Alessandro Zummo which has been queued for the last several
> -mm's.
>
> Your patches did merge up okayish but if they cause significant problems
> I'll drop them, sorry.
Understood.
--
Mathematics is the supreme nostalgia of our time.
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 4/14] RTC: Remove RTC UIP synchronization on PPC CHRP (arch/ppc)
2006-03-17 23:30 [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86 Matt Mackall
2006-03-17 23:30 ` [PATCH 2/14] RTC: Remove RTC UIP synchronization on x86_64 Matt Mackall
@ 2006-03-17 23:30 ` Matt Mackall
2006-03-17 23:30 ` [PATCH 3/14] RTC: Remove RTC UIP synchronization on Sparc64 Matt Mackall
` (11 subsequent siblings)
13 siblings, 0 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 PPC CHRP (arch/ppc)
Signed-off-by: Matt Mackall <mpm@selenic.com>
Index: rtc/arch/ppc/platforms/chrp_time.c
===================================================================
--- rtc.orig/arch/ppc/platforms/chrp_time.c 2005-10-27 19:02:08.000000000 -0500
+++ rtc/arch/ppc/platforms/chrp_time.c 2006-03-12 13:00:51.000000000 -0600
@@ -121,33 +121,15 @@ int __chrp chrp_set_rtc_time(unsigned lo
unsigned long __chrp chrp_get_rtc_time(void)
{
unsigned int year, mon, day, hour, min, sec;
- int uip, 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.
- */
-
- /* Since the UIP flag is set for about 2.2 ms and the clock
- * is typically written with a precision of 1 jiffy, trying
- * to obtain a precision better than a few milliseconds is
- * an illusion. Only consistency is interesting, this also
- * allows to use the routine for /dev/rtc without a potential
- * 1 second kernel busy loop triggered by any reader of /dev/rtc.
- */
-
- for ( i = 0; i<1000000; i++) {
- uip = chrp_cmos_clock_read(RTC_FREQ_SELECT);
+ do {
sec = chrp_cmos_clock_read(RTC_SECONDS);
min = chrp_cmos_clock_read(RTC_MINUTES);
hour = chrp_cmos_clock_read(RTC_HOURS);
day = chrp_cmos_clock_read(RTC_DAY_OF_MONTH);
mon = chrp_cmos_clock_read(RTC_MONTH);
year = chrp_cmos_clock_read(RTC_YEAR);
- uip |= chrp_cmos_clock_read(RTC_FREQ_SELECT);
- if ((uip & RTC_UIP)==0) break;
- }
+ } while (sec != chrp_cmos_clock_read(RTC_SECONDS));
if (!(chrp_cmos_clock_read(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
{
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH 3/14] RTC: Remove RTC UIP synchronization on Sparc64
2006-03-17 23:30 [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86 Matt Mackall
2006-03-17 23:30 ` [PATCH 2/14] RTC: Remove RTC UIP synchronization on x86_64 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 ` Matt Mackall
2006-03-17 23:30 ` [PATCH 6/14] RTC: Remove RTC UIP synchronization on PPC Maple Matt Mackall
` (10 subsequent siblings)
13 siblings, 0 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 Sparc64
Signed-off-by: Matt Mackall <mpm@selenic.com>
Index: rtc/arch/sparc64/kernel/time.c
===================================================================
--- rtc.orig/arch/sparc64/kernel/time.c 2006-03-16 16:48:37.000000000 -0600
+++ rtc/arch/sparc64/kernel/time.c 2006-03-17 11:51:53.000000000 -0600
@@ -632,23 +632,8 @@ static void __init set_system_time(void)
mon = MSTK_REG_MONTH(mregs);
year = MSTK_CVT_YEAR( MSTK_REG_YEAR(mregs) );
} else {
- int i;
-
/* Dallas 12887 RTC chip. */
- /* Stolen from arch/i386/kernel/time.c, see there for
- * credits and descriptive comments.
- */
- for (i = 0; i < 1000000; i++) {
- if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP)
- break;
- udelay(10);
- }
- for (i = 0; i < 1000000; i++) {
- if (!(CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP))
- break;
- udelay(10);
- }
do {
sec = CMOS_READ(RTC_SECONDS);
min = CMOS_READ(RTC_MINUTES);
@@ -657,6 +642,7 @@ static void __init set_system_time(void)
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);
BCD_TO_BIN(min);
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH 6/14] RTC: Remove RTC UIP synchronization on PPC Maple
2006-03-17 23:30 [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86 Matt Mackall
` (2 preceding siblings ...)
2006-03-17 23:30 ` [PATCH 3/14] RTC: Remove RTC UIP synchronization on Sparc64 Matt Mackall
@ 2006-03-17 23:30 ` Matt Mackall
2006-03-17 23:30 ` [PATCH 8/14] RTC: Remove RTC UIP synchronization on MIPS MC146818 Matt Mackall
` (9 subsequent siblings)
13 siblings, 0 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 PPC Maple
Signed-off-by: Matt Mackall <mpm@selenic.com>
Index: rtc/arch/powerpc/platforms/maple/time.c
===================================================================
--- rtc.orig/arch/powerpc/platforms/maple/time.c 2006-03-16 16:48:37.000000000 -0600
+++ rtc/arch/powerpc/platforms/maple/time.c 2006-03-16 19:00:12.000000000 -0600
@@ -62,34 +62,14 @@ static void maple_clock_write(unsigned l
void maple_get_rtc_time(struct rtc_time *tm)
{
- int uip, 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.
- */
-
- /* Since the UIP flag is set for about 2.2 ms and the clock
- * is typically written with a precision of 1 jiffy, trying
- * to obtain a precision better than a few milliseconds is
- * an illusion. Only consistency is interesting, this also
- * allows to use the routine for /dev/rtc without a potential
- * 1 second kernel busy loop triggered by any reader of /dev/rtc.
- */
-
- for (i = 0; i<1000000; i++) {
- uip = maple_clock_read(RTC_FREQ_SELECT);
+ do {
tm->tm_sec = maple_clock_read(RTC_SECONDS);
tm->tm_min = maple_clock_read(RTC_MINUTES);
tm->tm_hour = maple_clock_read(RTC_HOURS);
tm->tm_mday = maple_clock_read(RTC_DAY_OF_MONTH);
tm->tm_mon = maple_clock_read(RTC_MONTH);
tm->tm_year = maple_clock_read(RTC_YEAR);
- uip |= maple_clock_read(RTC_FREQ_SELECT);
- if ((uip & RTC_UIP)==0)
- break;
- }
+ } while (tm->tm_sec != maple_clock_read(RTC_SECONDS));
if (!(maple_clock_read(RTC_CONTROL) & RTC_DM_BINARY)
|| RTC_ALWAYS_BCD) {
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH 8/14] RTC: Remove RTC UIP synchronization on MIPS MC146818
2006-03-17 23:30 [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86 Matt Mackall
` (3 preceding siblings ...)
2006-03-17 23:30 ` [PATCH 6/14] RTC: Remove RTC UIP synchronization on PPC Maple Matt Mackall
@ 2006-03-17 23:30 ` Matt Mackall
2006-03-17 23:30 ` [PATCH 7/14] RTC: Remove RTC UIP synchronization on MIPS Footbridge Matt Mackall
` (8 subsequent siblings)
13 siblings, 0 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 MIPS MC146818
Signed-off-by: Matt Mackall <mpm@selenic.com>
Index: rtc/include/asm-mips/mc146818-time.h
===================================================================
--- rtc.orig/include/asm-mips/mc146818-time.h 2006-03-16 16:47:28.000000000 -0600
+++ rtc/include/asm-mips/mc146818-time.h 2006-03-16 17:25:54.000000000 -0600
@@ -86,43 +86,14 @@ static inline int mc146818_set_rtc_mmss(
return retval;
}
-/*
- * Returns true if a clock update is in progress
- */
-static inline unsigned char rtc_is_updating(void)
-{
- unsigned char uip;
- unsigned long flags;
-
- spin_lock_irqsave(&rtc_lock, flags);
- uip = (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP);
- spin_unlock_irqrestore(&rtc_lock, flags);
- return uip;
-}
-
static inline unsigned long mc146818_get_cmos_time(void)
{
unsigned int year, mon, day, hour, min, sec;
- int i;
unsigned long flags;
- /*
- * 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 (rtc_is_updating())
- break;
- for (i = 0 ; i < 1000000 ; i++) /* must try at least 2.228 ms */
- if (!rtc_is_updating())
- break;
-
spin_lock_irqsave(&rtc_lock, flags);
- 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);
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH 7/14] RTC: Remove RTC UIP synchronization on MIPS Footbridge
2006-03-17 23:30 [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86 Matt Mackall
` (4 preceding siblings ...)
2006-03-17 23:30 ` [PATCH 8/14] RTC: Remove RTC UIP synchronization on MIPS MC146818 Matt Mackall
@ 2006-03-17 23:30 ` 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
` (7 subsequent siblings)
13 siblings, 1 reply; 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 MIPS Footbridge
Signed-off-by: Matt Mackall <mpm@selenic.com>
Index: rtc/arch/arm/mach-footbridge/time.c
===================================================================
--- rtc.orig/arch/arm/mach-footbridge/time.c 2005-10-27 19:02:08.000000000 -0500
+++ rtc/arch/arm/mach-footbridge/time.c 2006-03-12 13:00:51.000000000 -0600
@@ -34,27 +34,12 @@ static int rtc_base;
static unsigned long __init get_isa_cmos_time(void)
{
unsigned int year, mon, day, hour, min, sec;
- int i;
// check to see if the RTC makes sense.....
if ((CMOS_READ(RTC_VALID) & RTC_VRT) == 0)
return mktime(1970, 1, 1, 0, 0, 0);
- /* 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);
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH 7/14] RTC: Remove RTC UIP synchronization on MIPS Footbridge
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
0 siblings, 0 replies; 21+ messages in thread
From: Matt Mackall @ 2006-03-17 23:58 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
On Fri, Mar 17, 2006 at 05:30:36PM -0600, Matt Mackall wrote:
> Remove RTC UIP synchronization on MIPS Footbridge
Urgh, this is obviously ARM. And I noticed my per-patch cc:es got
lost.
> Signed-off-by: Matt Mackall <mpm@selenic.com>
>
> Index: rtc/arch/arm/mach-footbridge/time.c
> ===================================================================
> --- rtc.orig/arch/arm/mach-footbridge/time.c 2005-10-27 19:02:08.000000000 -0500
> +++ rtc/arch/arm/mach-footbridge/time.c 2006-03-12 13:00:51.000000000 -0600
> @@ -34,27 +34,12 @@ static int rtc_base;
> static unsigned long __init get_isa_cmos_time(void)
> {
> unsigned int year, mon, day, hour, min, sec;
> - int i;
>
> // check to see if the RTC makes sense.....
> if ((CMOS_READ(RTC_VALID) & RTC_VRT) == 0)
> return mktime(1970, 1, 1, 0, 0, 0);
>
> - /* 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);
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
Mathematics is the supreme nostalgia of our time.
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 5/14] RTC: Remove RTC UIP synchronization on CHRP (arch/powerpc)
2006-03-17 23:30 [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86 Matt Mackall
` (5 preceding siblings ...)
2006-03-17 23:30 ` [PATCH 7/14] RTC: Remove RTC UIP synchronization on MIPS Footbridge Matt Mackall
@ 2006-03-17 23:30 ` Matt Mackall
2006-03-17 23:30 ` [PATCH 10/14] RTC: Remove RTC UIP synchronization on SH03 Matt Mackall
` (6 subsequent siblings)
13 siblings, 0 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 CHRP (arch/powerpc)
Signed-off-by: Matt Mackall <mpm@selenic.com>
Index: rtc/arch/powerpc/platforms/chrp/time.c
===================================================================
--- rtc.orig/arch/powerpc/platforms/chrp/time.c 2006-03-16 16:48:37.000000000 -0600
+++ rtc/arch/powerpc/platforms/chrp/time.c 2006-03-16 19:02:54.000000000 -0600
@@ -122,33 +122,15 @@ int chrp_set_rtc_time(struct rtc_time *t
void chrp_get_rtc_time(struct rtc_time *tm)
{
unsigned int year, mon, day, hour, min, sec;
- int uip, 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.
- */
-
- /* Since the UIP flag is set for about 2.2 ms and the clock
- * is typically written with a precision of 1 jiffy, trying
- * to obtain a precision better than a few milliseconds is
- * an illusion. Only consistency is interesting, this also
- * allows to use the routine for /dev/rtc without a potential
- * 1 second kernel busy loop triggered by any reader of /dev/rtc.
- */
-
- for ( i = 0; i<1000000; i++) {
- uip = chrp_cmos_clock_read(RTC_FREQ_SELECT);
+ do {
sec = chrp_cmos_clock_read(RTC_SECONDS);
min = chrp_cmos_clock_read(RTC_MINUTES);
hour = chrp_cmos_clock_read(RTC_HOURS);
day = chrp_cmos_clock_read(RTC_DAY_OF_MONTH);
mon = chrp_cmos_clock_read(RTC_MONTH);
year = chrp_cmos_clock_read(RTC_YEAR);
- uip |= chrp_cmos_clock_read(RTC_FREQ_SELECT);
- if ((uip & RTC_UIP)==0) break;
- }
+ } while (sec != chrp_cmos_clock_read(RTC_SECONDS));
if (!(chrp_cmos_clock_read(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
BCD_TO_BIN(sec);
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH 10/14] RTC: Remove RTC UIP synchronization on SH03
2006-03-17 23:30 [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86 Matt Mackall
` (6 preceding siblings ...)
2006-03-17 23:30 ` [PATCH 5/14] RTC: Remove RTC UIP synchronization on CHRP (arch/powerpc) Matt Mackall
@ 2006-03-17 23:30 ` Matt Mackall
2006-03-17 23:30 ` [PATCH 11/14] RTC: Remove RTC UIP synchronization on SH MPC1211 Matt Mackall
` (5 subsequent siblings)
13 siblings, 0 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 SH03
Signed-off-by: Matt Mackall <mpm@selenic.com>
Index: 2.6.16-rc4-rtc/arch/sh/boards/sh03/rtc.c
===================================================================
--- 2.6.16-rc4-rtc.orig/arch/sh/boards/sh03/rtc.c 2006-02-24 15:33:43.000000000 -0600
+++ 2.6.16-rc4-rtc/arch/sh/boards/sh03/rtc.c 2006-02-24 15:41:35.000000000 -0600
@@ -48,13 +48,9 @@ extern spinlock_t rtc_lock;
unsigned long get_cmos_time(void)
{
unsigned int year, mon, day, hour, min, sec;
- int i;
spin_lock(&rtc_lock);
again:
- for (i = 0 ; i < 1000000 ; i++) /* may take up to 1 second... */
- if (!(ctrl_inb(RTC_CTL) & RTC_BUSY))
- break;
do {
sec = (ctrl_inb(RTC_SEC1) & 0xf) + (ctrl_inb(RTC_SEC10) & 0x7) * 10;
min = (ctrl_inb(RTC_MIN1) & 0xf) + (ctrl_inb(RTC_MIN10) & 0xf) * 10;
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH 11/14] RTC: Remove RTC UIP synchronization on SH MPC1211
2006-03-17 23:30 [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86 Matt Mackall
` (7 preceding siblings ...)
2006-03-17 23:30 ` [PATCH 10/14] RTC: Remove RTC UIP synchronization on SH03 Matt Mackall
@ 2006-03-17 23:30 ` Matt Mackall
2006-03-17 23:30 ` [PATCH 9/14] RTC: Remove RTC UIP synchronization on MIPS-based DEC Matt Mackall
` (4 subsequent siblings)
13 siblings, 0 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 SH MPC1211
Signed-off-by: Matt Mackall <mpm@selenic.com>
Index: 2.6.16-rc4-rtc/arch/sh/boards/mpc1211/rtc.c
===================================================================
--- 2.6.16-rc4-rtc.orig/arch/sh/boards/mpc1211/rtc.c 2006-02-24 15:33:43.000000000 -0600
+++ 2.6.16-rc4-rtc/arch/sh/boards/mpc1211/rtc.c 2006-02-24 15:48:12.000000000 -0600
@@ -19,26 +19,13 @@
#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
#endif
-/* arc/i386/kernel/time.c */
unsigned long get_cmos_time(void)
{
unsigned int year, mon, day, hour, min, sec;
- int i;
spin_lock(&rtc_lock);
- /* 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);
@@ -46,6 +33,7 @@ unsigned long get_cmos_time(void)
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* [PATCH 9/14] RTC: Remove RTC UIP synchronization on MIPS-based DEC
2006-03-17 23:30 [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86 Matt Mackall
` (8 preceding siblings ...)
2006-03-17 23:30 ` [PATCH 11/14] RTC: Remove RTC UIP synchronization on SH MPC1211 Matt Mackall
@ 2006-03-17 23:30 ` Matt Mackall
2006-03-17 23:30 ` [PATCH 12/14] RTC: Remove RTC UIP synchronization on Alpha Matt Mackall
` (3 subsequent siblings)
13 siblings, 0 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 MIPS-based DEC
Move real_year inside the read loop and move the spinlock up as well
Signed-off-by: Matt Mackall <mpm@selenic.com>
Index: rtc/arch/mips/dec/time.c
===================================================================
--- rtc.orig/arch/mips/dec/time.c 2006-03-16 16:47:15.000000000 -0600
+++ rtc/arch/mips/dec/time.c 2006-03-16 17:32:21.000000000 -0600
@@ -36,41 +36,13 @@
#include <asm/dec/ioasic_addrs.h>
#include <asm/dec/machtype.h>
-
-/*
- * Returns true if a clock update is in progress
- */
-static inline unsigned char dec_rtc_is_updating(void)
-{
- unsigned char uip;
- unsigned long flags;
-
- spin_lock_irqsave(&rtc_lock, flags);
- uip = (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP);
- spin_unlock_irqrestore(&rtc_lock, flags);
- return uip;
-}
-
static unsigned long dec_rtc_get_time(void)
{
unsigned int year, mon, day, hour, min, sec, real_year;
- int i;
unsigned long flags;
- /* The Linux interpretation of the DS1287 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 (dec_rtc_is_updating())
- break;
- for (i = 0; i < 1000000; i++) /* must try at least 2.228 ms */
- if (!dec_rtc_is_updating())
- break;
spin_lock_irqsave(&rtc_lock, flags);
- /* Isn't this overkill? UIP above should guarantee consistency */
+
do {
sec = CMOS_READ(RTC_SECONDS);
min = CMOS_READ(RTC_MINUTES);
@@ -78,7 +50,16 @@ static unsigned long dec_rtc_get_time(vo
day = CMOS_READ(RTC_DAY_OF_MONTH);
mon = CMOS_READ(RTC_MONTH);
year = CMOS_READ(RTC_YEAR);
+ /*
+ * The PROM will reset the year to either '72 or '73.
+ * Therefore we store the real year separately, in one
+ * of unused BBU RAM locations.
+ */
+ real_year = CMOS_READ(RTC_DEC_YEAR);
} while (sec != CMOS_READ(RTC_SECONDS));
+
+ spin_unlock_irqrestore(&rtc_lock, flags);
+
if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
sec = BCD2BIN(sec);
min = BCD2BIN(min);
@@ -87,13 +68,7 @@ static unsigned long dec_rtc_get_time(vo
mon = BCD2BIN(mon);
year = BCD2BIN(year);
}
- /*
- * The PROM will reset the year to either '72 or '73.
- * Therefore we store the real year separately, in one
- * of unused BBU RAM locations.
- */
- real_year = CMOS_READ(RTC_DEC_YEAR);
- spin_unlock_irqrestore(&rtc_lock, flags);
+
year += real_year - 72 + 2000;
return mktime(year, mon, day, hour, min, sec);
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH 12/14] RTC: Remove RTC UIP synchronization on Alpha
2006-03-17 23:30 [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86 Matt Mackall
` (9 preceding siblings ...)
2006-03-17 23:30 ` [PATCH 9/14] RTC: Remove RTC UIP synchronization on MIPS-based DEC Matt Mackall
@ 2006-03-17 23:30 ` Matt Mackall
2006-03-17 23:30 ` [PATCH 13/14] RTC: Fix up some RTC whitespace and style Matt Mackall
` (2 subsequent siblings)
13 siblings, 0 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 Alpha
The sync may still be needed for CPU clock calibration but we don't
sync in the regular case.
Signed-off-by: Matt Mackall <mpm@selenic.com>
Index: rtc/arch/alpha/kernel/time.c
===================================================================
--- rtc.orig/arch/alpha/kernel/time.c 2005-10-27 19:02:08.000000000 -0500
+++ rtc/arch/alpha/kernel/time.c 2006-03-12 13:00:48.000000000 -0600
@@ -318,10 +318,11 @@ time_init(void)
if (!est_cycle_freq)
est_cycle_freq = validate_cc_value(calibrate_cc_with_pit());
- cc1 = rpcc_after_update_in_progress();
+ cc1 = rpcc();
/* Calibrate CPU clock -- attempt #2. */
if (!est_cycle_freq) {
+ cc1 = rpcc_after_update_in_progress();
cc2 = rpcc_after_update_in_progress();
est_cycle_freq = validate_cc_value(cc2 - cc1);
cc1 = cc2;
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH 13/14] RTC: Fix up some RTC whitespace and style
2006-03-17 23:30 [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86 Matt Mackall
` (10 preceding siblings ...)
2006-03-17 23:30 ` [PATCH 12/14] RTC: Remove RTC UIP synchronization on Alpha Matt Mackall
@ 2006-03-17 23:30 ` Matt Mackall
2006-03-17 23:30 ` [PATCH 14/14] RTC: Remove some duplicate BCD definitions Matt Mackall
2006-03-19 18:13 ` [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86 Pavel Machek
13 siblings, 0 replies; 21+ messages in thread
From: Matt Mackall @ 2006-03-17 23:30 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
Fix up some RTC whitespace and style
Signed-off-by: Matt Mackall <mpm@selenic.com>
Index: rtc/arch/sh/boards/mpc1211/rtc.c
===================================================================
--- rtc.orig/arch/sh/boards/mpc1211/rtc.c 2006-03-16 17:23:39.000000000 -0600
+++ rtc/arch/sh/boards/mpc1211/rtc.c 2006-03-17 11:50:08.000000000 -0600
@@ -34,18 +34,21 @@ unsigned long get_cmos_time(void)
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);
- BCD_TO_BIN(min);
- BCD_TO_BIN(hour);
- BCD_TO_BIN(day);
- BCD_TO_BIN(mon);
- BCD_TO_BIN(year);
- }
+ if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
+ BCD_TO_BIN(sec);
+ BCD_TO_BIN(min);
+ BCD_TO_BIN(hour);
+ BCD_TO_BIN(day);
+ BCD_TO_BIN(mon);
+ BCD_TO_BIN(year);
+ }
+
spin_unlock(&rtc_lock);
- if ((year += 1900) < 1970)
+
+ year += 1900;
+ if (year < 1970)
year += 100;
+
return mktime(year, mon, day, hour, min, sec);
}
Index: rtc/include/asm-i386/mach-default/mach_time.h
===================================================================
--- rtc.orig/include/asm-i386/mach-default/mach_time.h 2006-03-16 17:23:39.000000000 -0600
+++ rtc/include/asm-i386/mach-default/mach_time.h 2006-03-16 19:05:41.000000000 -0600
@@ -92,16 +92,17 @@ static inline unsigned long mach_get_cmo
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);
- BCD_TO_BIN(min);
- BCD_TO_BIN(hour);
- BCD_TO_BIN(day);
- BCD_TO_BIN(mon);
- BCD_TO_BIN(year);
- }
- if ((year += 1900) < 1970)
+ if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
+ BCD_TO_BIN(sec);
+ BCD_TO_BIN(min);
+ BCD_TO_BIN(hour);
+ BCD_TO_BIN(day);
+ BCD_TO_BIN(mon);
+ BCD_TO_BIN(year);
+ }
+
+ year += 1900;
+ if (year < 1970)
year += 100;
return mktime(year, mon, day, hour, min, sec);
Index: rtc/arch/ppc/platforms/chrp_time.c
===================================================================
--- rtc.orig/arch/ppc/platforms/chrp_time.c 2006-03-16 17:21:23.000000000 -0600
+++ rtc/arch/ppc/platforms/chrp_time.c 2006-03-16 19:08:38.000000000 -0600
@@ -131,16 +131,18 @@ unsigned long chrp_get_rtc_time(void)
year = chrp_cmos_clock_read(RTC_YEAR);
} while (sec != chrp_cmos_clock_read(RTC_SECONDS));
- if (!(chrp_cmos_clock_read(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
- {
- BCD_TO_BIN(sec);
- BCD_TO_BIN(min);
- BCD_TO_BIN(hour);
- BCD_TO_BIN(day);
- BCD_TO_BIN(mon);
- BCD_TO_BIN(year);
- }
- if ((year += 1900) < 1970)
+ if (!(chrp_cmos_clock_read(RTC_CONTROL) & RTC_DM_BINARY)
+ || RTC_ALWAYS_BCD) {
+ BCD_TO_BIN(sec);
+ BCD_TO_BIN(min);
+ BCD_TO_BIN(hour);
+ BCD_TO_BIN(day);
+ BCD_TO_BIN(mon);
+ BCD_TO_BIN(year);
+ }
+
+ year += 1900;
+ if (year < 1970)
year += 100;
return mktime(year, mon, day, hour, min, sec);
}
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH 14/14] RTC: Remove some duplicate BCD definitions
2006-03-17 23:30 [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86 Matt Mackall
` (11 preceding siblings ...)
2006-03-17 23:30 ` [PATCH 13/14] RTC: Fix up some RTC whitespace and style Matt Mackall
@ 2006-03-17 23:30 ` 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
13 siblings, 1 reply; 21+ messages in thread
From: Matt Mackall @ 2006-03-17 23:30 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
Remove some duplicate BCD definitions
Signed-off-by: Matt Mackall <mpm@selenic.com>
Index: 2.6.16-rc5-rtc/arch/m68k/bvme6000/rtc.c
===================================================================
--- 2.6.16-rc5-rtc.orig/arch/m68k/bvme6000/rtc.c 2006-03-06 16:01:30.000000000 -0600
+++ 2.6.16-rc5-rtc/arch/m68k/bvme6000/rtc.c 2006-03-11 16:07:50.000000000 -0600
@@ -18,6 +18,7 @@
#include <linux/module.h>
#include <linux/mc146818rtc.h> /* For struct rtc_time and ioctls, etc */
#include <linux/smp_lock.h>
+#include <linux/bcd.h>
#include <asm/bvme6000hw.h>
#include <asm/io.h>
@@ -32,9 +33,6 @@
* ioctls.
*/
-#define BCD2BIN(val) (((val)&15) + ((val)>>4)*10)
-#define BIN2BCD(val) ((((val)/10)<<4) + (val)%10)
-
static unsigned char days_in_mo[] =
{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
Index: 2.6.16-rc5-rtc/arch/m68k/mvme16x/rtc.c
===================================================================
--- 2.6.16-rc5-rtc.orig/arch/m68k/mvme16x/rtc.c 2006-03-06 16:01:30.000000000 -0600
+++ 2.6.16-rc5-rtc/arch/m68k/mvme16x/rtc.c 2006-03-11 16:04:47.000000000 -0600
@@ -17,6 +17,7 @@
#include <linux/poll.h>
#include <linux/mc146818rtc.h> /* For struct rtc_time and ioctls, etc */
#include <linux/smp_lock.h>
+#include <linux/bcd.h>
#include <asm/mvme16xhw.h>
#include <asm/io.h>
@@ -31,9 +32,6 @@
* ioctls.
*/
-#define BCD2BIN(val) (((val)&15) + ((val)>>4)*10)
-#define BIN2BCD(val) ((((val)/10)<<4) + (val)%10)
-
static const unsigned char days_in_mo[] =
{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
Index: 2.6.16-rc5-rtc/arch/mips/momentum/ocelot_3/setup.c
===================================================================
--- 2.6.16-rc5-rtc.orig/arch/mips/momentum/ocelot_3/setup.c 2006-03-06 16:01:30.000000000 -0600
+++ 2.6.16-rc5-rtc/arch/mips/momentum/ocelot_3/setup.c 2006-03-11 15:57:35.000000000 -0600
@@ -58,6 +58,7 @@
#include <linux/bootmem.h>
#include <linux/mv643xx.h>
#include <linux/pm.h>
+#include <linux/bcd.h>
#include <asm/time.h>
#include <asm/page.h>
@@ -131,9 +132,6 @@ void setup_wired_tlb_entries(void)
add_wired_entry(ENTRYLO(0xfc000000), ENTRYLO(0xfd000000), (signed)0xfc000000, PM_16M);
}
-#define CONV_BCD_TO_BIN(val) (((val) & 0xf) + (((val) >> 4) * 10))
-#define CONV_BIN_TO_BCD(val) (((val) % 10) + (((val) / 10) << 4))
-
unsigned long m48t37y_get_time(void)
{
unsigned int year, month, day, hour, min, sec;
@@ -143,16 +141,16 @@ unsigned long m48t37y_get_time(void)
/* stop the update */
rtc_base[0x7ff8] = 0x40;
- year = CONV_BCD_TO_BIN(rtc_base[0x7fff]);
- year += CONV_BCD_TO_BIN(rtc_base[0x7ff1]) * 100;
+ year = BCD2BIN(rtc_base[0x7fff]);
+ year += BCD2BIN(rtc_base[0x7ff1]) * 100;
- month = CONV_BCD_TO_BIN(rtc_base[0x7ffe]);
+ month = BCD2BIN(rtc_base[0x7ffe]);
- day = CONV_BCD_TO_BIN(rtc_base[0x7ffd]);
+ day = BCD2BIN(rtc_base[0x7ffd]);
- hour = CONV_BCD_TO_BIN(rtc_base[0x7ffb]);
- min = CONV_BCD_TO_BIN(rtc_base[0x7ffa]);
- sec = CONV_BCD_TO_BIN(rtc_base[0x7ff9]);
+ hour = BCD2BIN(rtc_base[0x7ffb]);
+ min = BCD2BIN(rtc_base[0x7ffa]);
+ sec = BCD2BIN(rtc_base[0x7ff9]);
/* start the update */
rtc_base[0x7ff8] = 0x00;
@@ -175,22 +173,22 @@ int m48t37y_set_time(unsigned long sec)
rtc_base[0x7ff8] = 0x80;
/* year */
- rtc_base[0x7fff] = CONV_BIN_TO_BCD(tm.tm_year % 100);
- rtc_base[0x7ff1] = CONV_BIN_TO_BCD(tm.tm_year / 100);
+ rtc_base[0x7fff] = BIN2BCD(tm.tm_year % 100);
+ rtc_base[0x7ff1] = BIN2BCD(tm.tm_year / 100);
/* month */
- rtc_base[0x7ffe] = CONV_BIN_TO_BCD(tm.tm_mon);
+ rtc_base[0x7ffe] = BIN2BCD(tm.tm_mon);
/* day */
- rtc_base[0x7ffd] = CONV_BIN_TO_BCD(tm.tm_mday);
+ rtc_base[0x7ffd] = BIN2BCD(tm.tm_mday);
/* hour/min/sec */
- rtc_base[0x7ffb] = CONV_BIN_TO_BCD(tm.tm_hour);
- rtc_base[0x7ffa] = CONV_BIN_TO_BCD(tm.tm_min);
- rtc_base[0x7ff9] = CONV_BIN_TO_BCD(tm.tm_sec);
+ rtc_base[0x7ffb] = BIN2BCD(tm.tm_hour);
+ rtc_base[0x7ffa] = BIN2BCD(tm.tm_min);
+ rtc_base[0x7ff9] = BIN2BCD(tm.tm_sec);
/* day of week -- not really used, but let's keep it up-to-date */
- rtc_base[0x7ffc] = CONV_BIN_TO_BCD(tm.tm_wday + 1);
+ rtc_base[0x7ffc] = BIN2BCD(tm.tm_wday + 1);
/* disable writing */
rtc_base[0x7ff8] = 0x00;
Index: 2.6.16-rc5-rtc/arch/mips/tx4938/common/rtc_rx5c348.c
===================================================================
--- 2.6.16-rc5-rtc.orig/arch/mips/tx4938/common/rtc_rx5c348.c 2006-02-17 14:05:34.000000000 -0600
+++ 2.6.16-rc5-rtc/arch/mips/tx4938/common/rtc_rx5c348.c 2006-03-11 15:55:48.000000000 -0600
@@ -14,6 +14,7 @@
#include <linux/string.h>
#include <linux/rtc.h>
#include <linux/time.h>
+#include <linux/bcd.h>
#include <asm/time.h>
#include <asm/tx4938/spi.h>
@@ -77,17 +78,6 @@ spi_rtc_io(unsigned char *inbuf, unsigne
inbufs, incounts, outbufs, outcounts, 0);
}
-/*
- * Conversion between binary and BCD.
- */
-#ifndef BCD_TO_BIN
-#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
-#endif
-
-#ifndef BIN_TO_BCD
-#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
-#endif
-
/* RTC-dependent code for time.c */
static int
Index: 2.6.16-rc5-rtc/arch/sh/boards/mpc1211/rtc.c
===================================================================
--- 2.6.16-rc5-rtc.orig/arch/sh/boards/mpc1211/rtc.c 2006-03-06 18:07:24.000000000 -0600
+++ 2.6.16-rc5-rtc/arch/sh/boards/mpc1211/rtc.c 2006-03-11 15:53:36.000000000 -0600
@@ -9,16 +9,9 @@
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/time.h>
+#include <linux/bcd.h>
#include <linux/mc146818rtc.h>
-#ifndef BCD_TO_BIN
-#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
-#endif
-
-#ifndef BIN_TO_BCD
-#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
-#endif
-
unsigned long get_cmos_time(void)
{
unsigned int year, mon, day, hour, min, sec;
Index: 2.6.16-rc5-rtc/arch/sh/boards/sh03/rtc.c
===================================================================
--- 2.6.16-rc5-rtc.orig/arch/sh/boards/sh03/rtc.c 2006-03-06 18:07:24.000000000 -0600
+++ 2.6.16-rc5-rtc/arch/sh/boards/sh03/rtc.c 2006-03-11 15:54:16.000000000 -0600
@@ -9,6 +9,7 @@
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/time.h>
+#include <linux/bcd.h>
#include <asm/io.h>
#include <linux/rtc.h>
#include <linux/spinlock.h>
@@ -33,14 +34,6 @@
#define RTC_BUSY 1
#define RTC_STOP 2
-#ifndef BCD_TO_BIN
-#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
-#endif
-
-#ifndef BIN_TO_BCD
-#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
-#endif
-
extern void (*rtc_get_time)(struct timespec *);
extern int (*rtc_set_time)(const time_t);
extern spinlock_t rtc_lock;
Index: 2.6.16-rc5-rtc/arch/sh/kernel/cpu/rtc.c
===================================================================
--- 2.6.16-rc5-rtc.orig/arch/sh/kernel/cpu/rtc.c 2005-10-27 19:02:08.000000000 -0500
+++ 2.6.16-rc5-rtc/arch/sh/kernel/cpu/rtc.c 2006-03-11 15:51:36.000000000 -0600
@@ -9,18 +9,10 @@
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/time.h>
-
+#include <linux/bcd.h>
#include <asm/io.h>
#include <asm/rtc.h>
-#ifndef BCD_TO_BIN
-#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
-#endif
-
-#ifndef BIN_TO_BCD
-#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
-#endif
-
void sh_rtc_gettimeofday(struct timespec *ts)
{
unsigned int sec128, sec, sec2, min, hr, wk, day, mon, yr, yr100, cf_bit;
Index: 2.6.16-rc5-rtc/arch/sh64/kernel/time.c
===================================================================
--- 2.6.16-rc5-rtc.orig/arch/sh64/kernel/time.c 2006-03-06 16:01:31.000000000 -0600
+++ 2.6.16-rc5-rtc/arch/sh64/kernel/time.c 2006-03-11 15:52:36.000000000 -0600
@@ -30,6 +30,7 @@
#include <linux/profile.h>
#include <linux/smp.h>
#include <linux/module.h>
+#include <linux/bcd.h>
#include <asm/registers.h> /* required by inline __asm__ stmt. */
@@ -105,14 +106,6 @@
#define RCR1 rtc_base+0x38
#define RCR2 rtc_base+0x3c
-#ifndef BCD_TO_BIN
-#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
-#endif
-
-#ifndef BIN_TO_BCD
-#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
-#endif
-
#define TICK_SIZE (tick_nsec / 1000)
extern unsigned long wall_jiffies;
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH 14/14] RTC: Remove some duplicate BCD definitions
2006-03-17 23:30 ` [PATCH 14/14] RTC: Remove some duplicate BCD definitions Matt Mackall
@ 2006-03-18 5:53 ` Andrew Morton
0 siblings, 0 replies; 21+ messages in thread
From: Andrew Morton @ 2006-03-18 5:53 UTC (permalink / raw)
To: Matt Mackall; +Cc: linux-kernel
Matt Mackall <mpm@selenic.com> wrote:
>
> Remove some duplicate BCD definitions
Needed fixups in arch/m68k/bvme6000/rtc.c due to overlapping changes in
m68k-rtc-driver-cleanup.patch. Please check the result.
***************
*** 18,23 ****
#include <linux/module.h>
#include <linux/mc146818rtc.h> /* For struct rtc_time and ioctls, etc */
#include <linux/smp_lock.h>
#include <asm/bvme6000hw.h>
#include <asm/io.h>
--- 18,24 ----
#include <linux/module.h>
#include <linux/mc146818rtc.h> /* For struct rtc_time and ioctls, etc */
#include <linux/smp_lock.h>
+ #include <linux/bcd.h>
#include <asm/bvme6000hw.h>
#include <asm/io.h>
***************
*** 32,40 ****
* ioctls.
*/
- #define BCD2BIN(val) (((val)&15) + ((val)>>4)*10)
- #define BIN2BCD(val) ((((val)/10)<<4) + (val)%10)
-
static unsigned char days_in_mo[] =
{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
--- 33,38 ----
* ioctls.
*/
static unsigned char days_in_mo[] =
{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86
2006-03-17 23:30 [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86 Matt Mackall
` (12 preceding siblings ...)
2006-03-17 23:30 ` [PATCH 14/14] RTC: Remove some duplicate BCD definitions Matt Mackall
@ 2006-03-19 18:13 ` Pavel Machek
2006-03-21 16:38 ` Matt Mackall
13 siblings, 1 reply; 21+ messages in thread
From: Pavel Machek @ 2006-03-19 18:13 UTC (permalink / raw)
To: Matt Mackall; +Cc: Andrew Morton, linux-kernel
Hi!
> 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.
Heh, nice manipulation attempt. Note you are also introduced timing
error of about 114 years total.
> 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
Eh, very nice, so I should get radio time source for my notebook?
> So this patch series simply removes the synchronization in favor of a
> simple seqlock-like approach using the seconds value.
What about polling RTC from timer interrupt or something like that, so
that you get error in range of 5 msec instead of 500 msec? You can do
the calibration in parallel, then...
Pavel
--
Thanks, Sharp!
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86
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
0 siblings, 1 reply; 21+ messages in thread
From: Matt Mackall @ 2006-03-21 16:38 UTC (permalink / raw)
To: Pavel Machek; +Cc: Andrew Morton, linux-kernel
On Sun, Mar 19, 2006 at 06:13:36PM +0000, Pavel Machek wrote:
> Hi!
>
> > 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.
>
> Heh, nice manipulation attempt. Note you are also introduced timing
> error of about 114 years total.
I'm sure you'll find the average RTC is off by significantly more than
a second anyway. _Or_ is regularly synced over network.
> > 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
>
> Eh, very nice, so I should get radio time source for my notebook?
Depends. Do you need sub-second precision on your wall time? If you're
currently depending on your RTC (not to mention the rest of the kernel
timekeeping system) to give you time of day that matches actual time
to fractions of a second without regular synchronization, you're
kidding yourself.
All my machines seem to grow out of sync by about a minute per week if
ntpd stops running. That's almost a half second per hour.
> > So this patch series simply removes the synchronization in favor of a
> > simple seqlock-like approach using the seconds value.
>
> What about polling RTC from timer interrupt or something like that, so
> that you get error in range of 5 msec instead of 500 msec? You can do
> the calibration in parallel, then...
I considered that and decided it wasn't worth the effort. People who
care (which ought to be the empty set) can run /sbin/hwclock.
--
Mathematics is the supreme nostalgia of our time.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 1/14] RTC: Remove RTC UIP synchronization on x86
2006-03-21 16:38 ` Matt Mackall
@ 2006-03-21 18:40 ` Pavel Machek
0 siblings, 0 replies; 21+ messages in thread
From: Pavel Machek @ 2006-03-21 18:40 UTC (permalink / raw)
To: Matt Mackall; +Cc: Andrew Morton, linux-kernel
On Út 21-03-06 10:38:52, Matt Mackall wrote:
> On Sun, Mar 19, 2006 at 06:13:36PM +0000, Pavel Machek wrote:
> > Hi!
> > > So this patch series simply removes the synchronization in favor of a
> > > simple seqlock-like approach using the seconds value.
> >
> > What about polling RTC from timer interrupt or something like that, so
> > that you get error in range of 5 msec instead of 500 msec? You can do
> > the calibration in parallel, then...
>
> I considered that and decided it wasn't worth the effort. People who
> care (which ought to be the empty set) can run /sbin/hwclock.
Fair enough, hwclock works for me.
Pavel
--
Picture of sleeping (Linux) penguin wanted...
^ permalink raw reply [flat|nested] 21+ messages in thread