From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Andre Hedrick <andre@linux-ide.org>,
martin@dalecki.de, Vojtech Pavlik <vojtech@suse.cz>,
William Lee Irwin III <wli@holomorphy.com>,
linux-kernel@vger.kernel.org
Subject: Re: [RFC/CFT] cmd640 irqlocking fixes
Date: 25 Jul 2002 14:08:48 +0100 [thread overview]
Message-ID: <1027602528.9488.68.camel@irongate.swansea.linux.org.uk> (raw)
In-Reply-To: <1027601555.9489.57.camel@irongate.swansea.linux.org.uk>
Martin this patch should do the job. It uses the correct pci_config_lock
and it also adds the 2.4 probe safety checks for deciding which pci
modes to use.
--- ../linux-2.5.28/drivers/ide/cmd640.c Thu Jul 25 10:49:19 2002
+++ drivers/ide/cmd640.c Thu Jul 25 11:41:27 2002
@@ -216,27 +216,27 @@
/* PCI method 1 access */
-static void put_cmd640_reg_pci1 (unsigned short reg, byte val)
+extern spinlock_t pci_config_lock;
+
+static void put_cmd640_reg_pci1 (unsigned short reg, u8 val)
{
unsigned long flags;
-
- save_flags(flags);
- cli();
- outl_p((reg & 0xfc) | cmd640_key, 0xcf8);
+
+ spin_lock_irqsave(&pci_config_lock, flags);
+ outb_p((reg & 0xfc) | cmd640_key, 0xcf8);
outb_p(val, (reg & 3) | 0xcfc);
- restore_flags(flags);
+ spin_unlock_irqrestore(&pci_config_lock, flags);
}
static u8 get_cmd640_reg_pci1 (unsigned short reg)
{
u8 b;
unsigned long flags;
-
- save_flags(flags);
- cli();
- outl_p((reg & 0xfc) | cmd640_key, 0xcf8);
- b = inb_p((reg & 3) | 0xcfc);
- restore_flags(flags);
+
+ spin_lock_irqsave(&pci_config_lock, flags);
+ outb_p((reg & 0xfc) | cmd640_key, 0xcf8);
+ b=inb_p((reg & 3) | 0xcfc);
+ spin_unlock_irqrestore(&pci_config_lock, flags);
return b;
}
@@ -245,26 +245,24 @@
static void put_cmd640_reg_pci2 (unsigned short reg, u8 val)
{
unsigned long flags;
-
- save_flags(flags);
- cli();
+
+ spin_lock_irqsave(&pci_config_lock, flags);
outb_p(0x10, 0xcf8);
outb_p(val, cmd640_key + reg);
outb_p(0, 0xcf8);
- restore_flags(flags);
+ spin_unlock_irqrestore(&pci_config_lock, flags);
}
static u8 get_cmd640_reg_pci2 (unsigned short reg)
{
u8 b;
unsigned long flags;
-
- save_flags(flags);
- cli();
+
+ spin_lock_irqsave(&pci_config_lock, flags);
outb_p(0x10, 0xcf8);
b = inb_p(cmd640_key + reg);
outb_p(0, 0xcf8);
- restore_flags(flags);
+ spin_unlock_irqrestore(&pci_config_lock, flags);
return b;
}
@@ -701,9 +699,62 @@
#endif
+/**
+ * pci_conf1 - check for PCI type 1 configuration
+ *
+ * Issues a safe probe sequence for PCI configuration type 1 and
+ * returns non-zero if conf1 is supported. Takes the pci_config lock
+ */
+
+static int pci_conf1(void)
+{
+ u32 tmp;
+ unsigned long flags;
+
+ spin_lock_irqsave(&pci_config_lock, flags);
+
+ OUT_BYTE(0x01, 0xCFB);
+ tmp = inl(0xCF8);
+ outl(0x80000000, 0xCF8);
+ if (inl(0xCF8) == 0x80000000) {
+ spin_unlock_irqrestore(&pci_config_lock, flags);
+ outl(tmp, 0xCF8);
+ return 1;
+ }
+ outl(tmp, 0xCF8);
+ spin_unlock_irqrestore(&pci_config_lock, flags);
+ return 0;
+}
+
+/**
+ * pci_conf2 - check for PCI type 2 configuration
+ *
+ * Issues a safe probe sequence for PCI configuration type 2 and
+ * returns non-zero if conf2 is supported. Takes the pci_config lock.
+ */
+
+
+static int pci_conf2(void)
+{
+ unsigned long flags;
+ spin_lock_irqsave(&pci_config_lock, flags);
+
+ OUT_BYTE(0x00, 0xCFB);
+ OUT_BYTE(0x00, 0xCF8);
+ OUT_BYTE(0x00, 0xCFA);
+ if (IN_BYTE(0xCF8) == 0x00 && IN_BYTE(0xCF8) == 0x00) {
+ spin_unlock_irqrestore(&pci_config_lock, flags);
+ return 1;
+ }
+ spin_unlock_irqrestore(&pci_config_lock, flags);
+ return 0;
+}
+
+
/*
* Probe for a cmd640 chipset, and initialize it if found. Called from ide.c
*/
+
int __init ide_probe_for_cmd640x(void)
{
#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
@@ -718,9 +769,10 @@
bus_type = "VLB";
} else {
cmd640_vlb = 0;
- if (probe_for_cmd640_pci1())
+ /* Find out what kind of PCI probing is supported */
+ if (pci_conf1() && probe_for_cmd640_pci1())
bus_type = "PCI (type1)";
- else if (probe_for_cmd640_pci2())
+ else if (pci_conf2() && probe_for_cmd640_pci2())
bus_type = "PCI (type2)";
else
return 0;
next prev parent reply other threads:[~2002-07-25 11:52 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-24 22:58 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 [this message]
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
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=1027602528.9488.68.camel@irongate.swansea.linux.org.uk \
--to=alan@lxorguk.ukuu.org.uk \
--cc=andre@linux-ide.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin@dalecki.de \
--cc=vojtech@suse.cz \
--cc=wli@holomorphy.com \
/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
all inboxes | Powered by JetHome®