public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC/CFT] cmd640 irqlocking fixes
@ 2002-07-24 22:58 William Lee Irwin III
  2002-07-24 23:16 ` William Lee Irwin III
                   ` (2 more replies)
  0 siblings, 3 replies; 32+ messages in thread
From: William Lee Irwin III @ 2002-07-24 22:58 UTC (permalink / raw)
  To: linux-kernel

I don't have one of these, and I'm not even sure what it is. But here's
a wild guess at a fix.


Cheers,
Bill
===== drivers/ide/cmd640.c 1.11 vs edited =====
--- 1.11/drivers/ide/cmd640.c	Wed May 22 04:21:11 2002
+++ edited/drivers/ide/cmd640.c	Wed Jul 24 18:51:54 2002
@@ -115,6 +115,12 @@
 #include "ata-timing.h"
 
 /*
+ * Is this remotely correct?
+ */
+static spinlock_t cmd640_lock = SPIN_LOCK_UNLOCKED;
+
+
+/*
  * This flag is set in ide.c by the parameter:  ide0=cmd640_vlb
  */
 int cmd640_vlb = 0;
@@ -220,11 +226,10 @@
 {
 	unsigned long flags;
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&cmd640_lock, flags);
 	outl_p((reg & 0xfc) | cmd640_key, 0xcf8);
 	outb_p(val, (reg & 3) | 0xcfc);
-	restore_flags(flags);
+	spin_unlock_irqrestore(&cmd640_lock, flags);
 }
 
 static u8 get_cmd640_reg_pci1 (unsigned short reg)
@@ -232,11 +237,10 @@
 	u8 b;
 	unsigned long flags;
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&cmd640_lock, flags);
 	outl_p((reg & 0xfc) | cmd640_key, 0xcf8);
 	b = inb_p((reg & 3) | 0xcfc);
-	restore_flags(flags);
+	spin_unlock_irqrestore(&cmd640_lock, flags);
 	return b;
 }
 
@@ -246,12 +250,11 @@
 {
 	unsigned long flags;
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&cmd640_lock, flags);
 	outb_p(0x10, 0xcf8);
 	outb_p(val, cmd640_key + reg);
 	outb_p(0, 0xcf8);
-	restore_flags(flags);
+	spin_unlock_irqrestore(&cmd640_lock, flags);
 }
 
 static u8 get_cmd640_reg_pci2 (unsigned short reg)
@@ -259,12 +262,11 @@
 	u8 b;
 	unsigned long flags;
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&cmd640_lock, flags);
 	outb_p(0x10, 0xcf8);
 	b = inb_p(cmd640_key + reg);
 	outb_p(0, 0xcf8);
-	restore_flags(flags);
+	spin_unlock_irqrestore(&cmd640_lock, flags);
 	return b;
 }
 
@@ -274,11 +276,10 @@
 {
 	unsigned long flags;
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&cmd640_lock, flags);
 	outb_p(reg, cmd640_key);
 	outb_p(val, cmd640_key + 4);
-	restore_flags(flags);
+	spin_unlock_irqrestore(&cmd640_lock, flags);
 }
 
 static u8 get_cmd640_reg_vlb (unsigned short reg)
@@ -286,11 +287,10 @@
 	u8 b;
 	unsigned long flags;
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&cmd640_lock, flags);
 	outb_p(reg, cmd640_key);
 	b = inb_p(cmd640_key + 4);
-	restore_flags(flags);
+	spin_unlock_irqrestore(&cmd640_lock, flags);
 	return b;
 }
 
@@ -367,8 +367,7 @@
 {
 	unsigned long flags;
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&cmd640_lock, flags);
 
 	outb_p(0x0a, 0x170 + IDE_SELECT_OFFSET);	/* select drive0 */
 	udelay(100);
@@ -376,11 +375,11 @@
 		outb_p(0x1a, 0x170 + IDE_SELECT_OFFSET); /* select drive1 */
 		udelay(100);
 		if ((inb_p(0x170 + IDE_SELECT_OFFSET) & 0x1f) != 0x1a) {
-			restore_flags(flags);
+			spin_unlock_irqrestore(&cmd640_lock, flags);
 			return 0; /* nothing responded */
 		}
 	}
-	restore_flags(flags);
+	spin_unlock_irqrestore(&cmd640_lock, flags);
 	return 1; /* success */
 }
 
@@ -461,8 +460,7 @@
 	u8 b;
 	unsigned long flags;
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&cmd640_lock, flags);
 	b = get_cmd640_reg(reg);
 	if (mode) {	/* want prefetch on? */
 # if CMD640_PREFETCH_MASKS
@@ -478,7 +476,7 @@
 		b |= prefetch_masks[index];	/* disable prefetch */
 	}
 	put_cmd640_reg(reg, b);
-	restore_flags(flags);
+	spin_unlock_irqrestore(&cmd640_lock, flags);
 }
 
 /*
@@ -579,8 +577,7 @@
 	/*
 	 * Now that everything is ready, program the new timings
 	 */
-	save_flags (flags);
-	cli();
+	spin_lock_irqsave(&cmd640_lock, flags);
 	/*
 	 * Program the address_setup clocks into ARTTIM reg,
 	 * and then the active/recovery counts into the DRWTIM reg
@@ -589,7 +586,7 @@
 	setup_count |= get_cmd640_reg(arttim_regs[index]) & 0x3f;
 	put_cmd640_reg(arttim_regs[index], setup_count);
 	put_cmd640_reg(drwtim_regs[index], pack_nibbles(active_count, recovery_count));
-	restore_flags(flags);
+	spin_unlock_irqrestore(&cmd640_lock, flags);
 }
 
 /*

^ permalink raw reply	[flat|nested] 32+ messages in thread
* Re: [RFC/CFT] cmd640 irqlocking fixes
@ 2002-07-25 12:50 Petr Vandrovec
  2002-07-25 14:34 ` Alan Cox
  0 siblings, 1 reply; 32+ messages in thread
From: Petr Vandrovec @ 2002-07-25 12:50 UTC (permalink / raw)
  To: Alan Cox
  Cc: Andre Hedrick, martin, Vojtech Pavlik, William Lee Irwin III,
	linux-kernel

On 25 Jul 02 at 14:08, Alan Cox wrote:

> +   OUT_BYTE(0x00, 0xCFB);
> +   OUT_BYTE(0x00, 0xCF8);
> +   OUT_BYTE(0x00, 0xCFA);
> +   if (IN_BYTE(0xCF8) == 0x00 && IN_BYTE(0xCF8) == 0x00) {
                                            ^^^^^
It should be 0xCFA according to arch/i386/pci/direct.c...
                                        Petr Vandrovec
                                        vandrove@vc.cvut.cz
                                        

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

end of thread, other threads:[~2002-07-29  7:22 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-07-24 22:58 [RFC/CFT] cmd640 irqlocking fixes William Lee Irwin III
2002-07-24 23:16 ` William Lee Irwin III
2002-07-25  1:05 ` Alan Cox
2002-07-25  7:54   ` Vojtech Pavlik
2002-07-25  8:28     ` Marcin Dalecki
2002-07-25  8:55       ` Vojtech Pavlik
2002-07-25  8:56         ` Marcin Dalecki
2002-07-25 10:24           ` Alan Cox
2002-07-25 10:37             ` Marcin Dalecki
2002-07-25 10:51             ` Andre Hedrick
2002-07-25 12:52               ` Alan Cox
2002-07-25 12:05                 ` Andre Hedrick
2002-07-25 13:08                 ` Alan Cox
2002-07-25 11:53                   ` Marcin Dalecki
2002-07-25 12:30                   ` Andre Hedrick
2002-07-25 14:33                     ` Alan Cox
2002-07-25 13:39                   ` Benjamin Herrenschmidt
2002-07-25 14:18                     ` PCI config locking (WAS Re: [RFC/CFT] cmd640 irqlocking fixes)2 Benjamin Herrenschmidt
2002-07-25 15:45                       ` Alan Cox
2002-07-25 14:40                         ` benh
2002-07-25 16:10                           ` Alan Cox
2002-07-25 23:04                           ` Alan Cox
2002-07-25 14:48                         ` Dave Jones
2002-07-25 15:44                           ` Thunder from the hill
2002-07-29  7:13                           ` David S. Miller
2002-07-26  0:41                       ` Marcin Dalecki
2002-07-26  0:15         ` [RFC/CFT] cmd640 irqlocking fixes Albert D. Cahalan
2002-07-25 10:22     ` Alan Cox
2002-07-25  8:01 ` Marcin Dalecki
  -- strict thread matches above, loose matches on Subject: below --
2002-07-25 12:50 Petr Vandrovec
2002-07-25 14:34 ` Alan Cox
2002-07-26  2:15   ` Marcin Dalecki

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