Skip to contentSkip to conversation

VIA timer bugfix, patch for 2.4.5

PATCH Jonas Diemer 1 participant 1 message Jun 2, 2001

lore
Share & tools
lore
#0 lore raw

Hi!

I have compiled a little patch that contains the VIA timer bugfix (from the ac kernel). the patch is against linus' 2.4.5 kernel. I have compiled and ran the patched kernel sucessfully.

the only changes made by this patch are done to linux/arch/i386/kernel/timer.c

I would like to have this patch applied to linus' kernel tree (so that it comes in 2.4.6), because alan's kernel has USB problems on my machine.

Here's the patch:

i386/kernel/time.c renamed from i386/kernel/time.c.orig +28 -1
@@ -178,6 +178,15 @@
  	jiffies_t = jiffies;
 
 	count |= inb_p(0x40) << 8;
+	
+        /* VIA686a test code... reset the latch if count > max + 1 */
+        if (count > LATCH) {
+                outb_p(0x34, 0x43);
+                outb_p(LATCH & 0xff, 0x40);
+                outb(LATCH >> 8, 0x40);
+                count = LATCH - 1;
+        }
+	
 	spin_unlock(&i8253_lock);
 
 	/*
@@ -413,7 +422,7 @@
 	if (!user_mode(regs))
 		x86_do_profile(regs->eip);
 #else
-	if (!smp_found_config)
+	if (!using_apic_timer)
 		smp_local_timer_interrupt(regs);
 #endif
 
@@ -492,6 +501,24 @@
 
 		count = inb_p(0x40);    /* read the latched count */
 		count |= inb(0x40) << 8;
+		
+
+                /* VIA686a test code... reset the latch if count > max */
+                if (count > LATCH-1) {
+                        static int last_whine;
+                        outb_p(0x34, 0x43);   
+                        outb_p(LATCH & 0xff, 0x40);
+                        outb(LATCH >> 8, 0x40);
+                        count = LATCH - 1;
+                        if(time_after(jiffies, last_whine))
+                        {
+                                printk(KERN_WARNING "probable hardware bug: clock timer configuration lost - probably a VIA686a motherboard.\n");
+                                printk(KERN_WARNING "probable hardware bug: restoring chip configuration.\n");
+                                last_whine = jiffies + HZ;
+                        }                       
+                }                               
+
+		
 		spin_unlock(&i8253_lock);
 
 		count = ((LATCH-1) - count) * TICK_SIZE;

--end of patch---

This is my first patch, i hope it is ok. i followed the instructions in Documentation/SubmittingPatches to create it.

- Jonas

PS: please CC me any reply, i haven't registered to the mailinglist.