patch-2.4.0-test12 linux/arch/mips64/sgi-ip27/ip27-timer.c

Next file: linux/arch/parisc/Makefile
Previous file: linux/arch/mips64/sgi-ip27/ip27-setup.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test11/linux/arch/mips64/sgi-ip27/ip27-timer.c linux/arch/mips64/sgi-ip27/ip27-timer.c
@@ -14,7 +14,7 @@
 
 #include <asm/pgtable.h>
 #include <asm/sgialib.h>
-#include <asm/ioc3.h>
+#include <asm/sn/ioc3.h>
 #include <asm/m48t35.h>
 #include <asm/sn/klconfig.h>
 #include <asm/sn/arch.h>
@@ -23,7 +23,8 @@
 #include <asm/sn/sn0/ip27.h>
 #include <asm/sn/sn0/hub.h>
 
-/* This is a hack; we really need to figure these values out dynamically
+/*
+ * This is a hack; we really need to figure these values out dynamically
  * 
  * Since 800 ns works very well with various HUB frequencies, such as
  * 360, 380, 390 and 400 MHZ, we use 800 ns rtc cycle time.
@@ -43,49 +44,47 @@
 
 
 static int set_rtc_mmss(unsigned long nowtime)
-{               
-        int retval = 0;
-        int real_seconds, real_minutes, cmos_minutes;
+{
+	int retval = 0;
+	int real_seconds, real_minutes, cmos_minutes;
 	struct m48t35_rtc *rtc;
 	nasid_t nid;
 
 	nid = get_nasid();
-	rtc = (struct m48t35_rtc *)
-	    KL_CONFIG_CH_CONS_INFO(nid)->memory_base + IOC3_BYTEBUS_DEV0;
-                
+	rtc = (struct m48t35_rtc *)(KL_CONFIG_CH_CONS_INFO(nid)->memory_base + 
+							IOC3_BYTEBUS_DEV0);
+
 	rtc->control |= M48T35_RTC_READ;
 	cmos_minutes = rtc->min;
 	BCD_TO_BIN(cmos_minutes);
 	rtc->control &= ~M48T35_RTC_READ;
-         
-        /*      
-         * Since we're only adjusting minutes and seconds,
-         * don't interfere with hour overflow. This avoids
-         * messing with unknown time zones but requires your
-         * RTC not to be off by more than 15 minutes
-         */     
-        real_seconds = nowtime % 60;
-        real_minutes = nowtime / 60;
-        if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1)
-                real_minutes += 30;             /* correct for half hour time zone */           
-        real_minutes %= 60;
-                
-        if (abs(real_minutes - cmos_minutes) < 30) {
+
+	/*
+	 * Since we're only adjusting minutes and seconds, don't interfere with
+	 * hour overflow. This avoids messing with unknown time zones but
+	 * requires your RTC not to be off by more than 15 minutes
+	 */
+	real_seconds = nowtime % 60;
+	real_minutes = nowtime / 60;
+	if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1)
+		real_minutes += 30;	/* correct for half hour time zone */
+	real_minutes %= 60;
+
+	if (abs(real_minutes - cmos_minutes) < 30) {
 		BIN_TO_BCD(real_seconds);
 		BIN_TO_BCD(real_minutes);
 		rtc->control |= M48T35_RTC_SET;
-                rtc->sec = real_seconds;
-                rtc->min = real_minutes;
+		rtc->sec = real_seconds;
+		rtc->min = real_minutes;
 		rtc->control &= ~M48T35_RTC_SET;
-        } else {
-                printk(KERN_WARNING
-                       "set_rtc_mmss: can't update from %d to %d\n",
-                       cmos_minutes, real_minutes);
-                retval = -1;
-        }
+	} else {
+		printk(KERN_WARNING
+		       "set_rtc_mmss: can't update from %d to %d\n",
+		       cmos_minutes, real_minutes);
+		retval = -1;
+	}
 
-                
-        return retval;
+	return retval;
 }
 
 void rt_timer_interrupt(struct pt_regs *regs)
@@ -110,41 +109,28 @@
 		do_timer(regs);
 
 #ifdef CONFIG_SMP
-	if (current->pid) {
-		unsigned int *inc, *inc2;
+	{
 		int user = user_mode(regs);
 
-		update_one_process(current, 1, user, !user, cpu);
-		if (--current->counter <= 0) {
-			current->counter = 0;
-			current->need_resched = 1;
-		}
-
-		if (user) {
-			if (current->nice > 0) {
-				inc = &kstat.cpu_nice;
-				inc2 = &kstat.per_cpu_nice[cpu];
-			} else {
-				inc = &kstat.cpu_user;
-				inc2 = &kstat.per_cpu_user[cpu];
-			}
-		} else {
-			inc = &kstat.cpu_system;
-			inc2 = &kstat.per_cpu_system[cpu];
-		}
-		atomic_inc((atomic_t *)inc);
-		atomic_inc((atomic_t *)inc2);
+		/*
+		 * update_process_times() expects us to have done irq_enter().
+		 * Besides, if we don't timer interrupts ignore the global
+		 * interrupt lock, which is the WrongThing (tm) to do.
+		 * Picked from i386 code.
+		 */
+		irq_enter(cpu, 0);
+		update_process_times(user);
+		irq_exit(cpu, 0);
 	}
 #endif /* CONFIG_SMP */
 	
-        /*
-         * If we have an externally synchronized Linux clock, then update
-         * RTC clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
-         * called as close as possible to when a second starts.
-         */
-
-        if ((time_status & STA_UNSYNC) == 0 &&
-            xtime.tv_sec > last_rtc_update + 660) {
+	/*
+	 * If we have an externally synchronized Linux clock, then update
+	 * RTC clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
+	 * called as close as possible to when a second starts.
+	 */
+	if ((time_status & STA_UNSYNC) == 0 &&
+	    xtime.tv_sec > last_rtc_update + 660) {
 		if (xtime.tv_usec >= 1000000 - ((unsigned) tick) / 2) {
 			if (set_rtc_mmss(xtime.tv_sec + 1) == 0)
 				last_rtc_update = xtime.tv_sec;
@@ -206,9 +192,9 @@
 
 	xtime = *tv;
 	time_adjust = 0;		/* stop active adjtime() */
-	time_state = TIME_BAD;
-	time_maxerror = MAXPHASE;
-	time_esterror = MAXPHASE;
+	time_status |= STA_UNSYNC;
+	time_maxerror = NTP_PHASE_LIMIT;
+	time_esterror = NTP_PHASE_LIMIT;
 	write_unlock_irq(&xtime_lock);
 }
 
@@ -219,10 +205,8 @@
 #include <asm/sn/sn0/hubio.h>
 #include <asm/pci/bridge.h>
 
-#define DEBUG_RTC
-
-static unsigned long __init get_m48t35_time(void)
-{       
+static __init unsigned long get_m48t35_time(void)
+{
         unsigned int year, month, date, hour, min, sec;
 	struct m48t35_rtc *rtc;
 	nasid_t nid;
@@ -231,7 +215,7 @@
 	rtc = (struct m48t35_rtc *)(KL_CONFIG_CH_CONS_INFO(nid)->memory_base + 
 							IOC3_BYTEBUS_DEV0);
 
-        rtc->control |= M48T35_RTC_READ;
+	rtc->control |= M48T35_RTC_READ;
 	sec = rtc->sec;
 	min = rtc->min;
 	hour = rtc->hour;
@@ -252,8 +236,6 @@
         return mktime(year, month, date, hour, min, sec);
 }
 
-extern void ioc3_eth_init(void);
-
 void __init time_init(void)
 {
 	xtime.tv_sec = get_m48t35_time();
@@ -265,7 +247,7 @@
 	lboard_t *board;
 	klcpu_t *cpu;
 	int cpuid;
-	
+
 	/* Don't use ARCS.  ARCS is fragile.  Klconfig is simple and sane.  */
 	board = find_lboard(KL_CONFIG_INFO(get_nasid()), KLTYPE_IP27);
 	if (!board)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)