public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: William Lee Irwin III <wli@holomorphy.com>
To: linux-kernel@vger.kernel.org
Subject: [RFC/CFT] cmd640 irqlocking fixes
Date: Wed, 24 Jul 2002 15:58:26 -0700	[thread overview]
Message-ID: <20020724225826.GF25038@holomorphy.com> (raw)

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);
 }
 
 /*

             reply	other threads:[~2002-07-24 22:55 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-24 22:58 William Lee Irwin III [this message]
2002-07-24 23:16 ` [RFC/CFT] cmd640 irqlocking fixes 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020724225826.GF25038@holomorphy.com \
    --to=wli@holomorphy.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox