[PATCH] mdacon using spinlocks

From: James Simmons (jsimmons@suse.com)
Date: Wed Oct 11 2000 - 20:20:48 EST


The problems with vgacon with cli made me go and add spinlocks to mdacon
as well to prevent nasty lock ups. Give it a try. Against a test-9
kernel. Here you go:

--- mdacon.c.orig Wed Oct 11 18:09:01 2000
+++ mdacon.c Wed Oct 11 18:14:18 2000
@@ -37,6 +37,7 @@
 #include <linux/vt_kern.h>
 #include <linux/vt_buffer.h>
 #include <linux/selection.h>
+#include <linux/spinlock.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
 #include <linux/init.h>
@@ -44,6 +45,7 @@
 #include <asm/io.h>
 #include <asm/vga.h>
 
+static spinlock_t mda_lock = SPIN_LOCK_UNLOCKED;
 
 /* description of the hardware layout */
 
@@ -80,7 +82,6 @@
 MODULE_PARM(mda_last_vc, "1-255i");
 #endif
 
-
 /* MDA register values
  */
 
@@ -110,23 +111,24 @@
 {
         unsigned long flags;
 
- save_flags(flags); cli();
+ spin_lock_irqsave(&mda_lock, flags);
 
         outb_p(reg, mda_index_port);
         outb_p(val, mda_value_port);
 
- restore_flags(flags);
+ spin_unlock_irqrestore(&mda_lock, flags);
 }
 
 static void write_mda_w(unsigned int val, unsigned char reg)
 {
         unsigned long flags;
 
- save_flags(flags); cli();
+ spin_lock_irqsave(&mda_lock, flags);
 
         outb_p(reg, mda_index_port); outb_p(val >> 8, mda_value_port);
         outb_p(reg+1, mda_index_port); outb_p(val & 0xff, mda_value_port);
 
+ spin_unlock_irqrestore(&mda_lock, flags);
         restore_flags(flags);
 }
 
@@ -134,15 +136,14 @@
 {
         unsigned long flags;
 
- save_flags(flags); cli();
+ spin_lock_irqsave(&mda_lock, flags);
 
         outb_p(reg, mda_index_port);
         outb (val, mda_value_port);
 
         udelay(20); val = (inb_p(mda_value_port) == val);
 
- restore_flags(flags);
-
+ spin_unlock_irqrestore(&mda_lock, flags);
         return val;
 }
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Oct 15 2000 - 21:00:19 EST