The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@debian.org>
To: Greg KH <greg@kroah.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] PCI direct access resources
Date: Fri, 20 Jun 2003 17:29:29 +0100	[thread overview]
Message-ID: <20030620162929.GT24357@parcelfarce.linux.theplanet.co.uk> (raw)


My mummy always taught me to request resources before I used them.
We weren't reserving the 0xc000-0xcfff range before, either.  I
bet not many people use type 2 accesses these days.

Index: arch/i386/pci/direct.c
===================================================================
RCS file: /var/cvs/linux-2.5/arch/i386/pci/direct.c,v
retrieving revision 1.6
diff -u -p -r1.6 direct.c
--- arch/i386/pci/direct.c	25 Feb 2003 12:39:09 -0000	1.6
+++ arch/i386/pci/direct.c	20 Jun 2003 14:30:26 -0000
@@ -200,6 +200,7 @@
 
 static int __init pci_direct_init(void)
 {
+	struct resource *region, *region2;
 	unsigned int tmp;
 	unsigned long flags;
 
@@ -237,43 +206,53 @@ static int __init pci_direct_init(void)
 	/*
 	 * Check if configuration type 1 works.
 	 */
-	if (pci_probe & PCI_PROBE_CONF1) {
-		outb (0x01, 0xCFB);
-		tmp = inl (0xCF8);
-		outl (0x80000000, 0xCF8);
-		if (inl (0xCF8) == 0x80000000 &&
-		    pci_sanity_check(&pci_direct_conf1)) {
-			outl (tmp, 0xCF8);
-			local_irq_restore(flags);
-			printk(KERN_INFO "PCI: Using configuration type 1\n");
-			if (!request_region(0xCF8, 8, "PCI conf1"))
-				pci_root_ops = NULL;
-			else
-				pci_root_ops = &pci_direct_conf1;
-			return 0;
-		}
-		outl (tmp, 0xCF8);
+	if (!pci_probe & PCI_PROBE_CONF1)
+		goto type2;
+	region = request_region(0xCF8, 8, "PCI conf1");
+	if (!region)
+		goto type2;
+
+	outb(0x01, 0xCFB);
+	tmp = inl(0xCF8);
+	outl(0x80000000, 0xCF8);
+	if (inl(0xCF8) == 0x80000000 &&
+	    pci_sanity_check(&pci_direct_conf1)) {
+		outl(tmp, 0xCF8);
+		local_irq_restore(flags);
+		printk(KERN_INFO "PCI: Using configuration type 1\n");
+		raw_pci_ops = &pci_direct_conf1;
+		return 0;
 	}
+	outl(tmp, 0xCF8);
+	release_resource(region);
 
+ type2:
 	/*
 	 * Check if configuration type 2 works.
 	 */
-	if (pci_probe & PCI_PROBE_CONF2) {
-		outb (0x00, 0xCFB);
-		outb (0x00, 0xCF8);
-		outb (0x00, 0xCFA);
-		if (inb (0xCF8) == 0x00 && inb (0xCFA) == 0x00 &&
-		    pci_sanity_check(&pci_direct_conf2)) {
-			local_irq_restore(flags);
-			printk(KERN_INFO "PCI: Using configuration type 2\n");
-			if (!request_region(0xCF8, 4, "PCI conf2"))
-				pci_root_ops = NULL;
-			else
-				pci_root_ops = &pci_direct_conf2;
-			return 0;
-		}
-	}
+	if (!pci_probe & PCI_PROBE_CONF2)
+		goto out;
+	region = request_region(0xCF8, 4, "PCI conf2");
+	if (!region)
+		goto out;
+	region2 = request_region(0xC000, 0xfff, "PCI conf2");
+	if (!region2)
+		goto fail2;
+	outb(0x00, 0xCFB);
+	outb(0x00, 0xCF8);
+	outb(0x00, 0xCFA);
+	if (inb(0xCF8) == 0x00 && inb(0xCFA) == 0x00 &&
+	    pci_sanity_check(&pci_direct_conf2)) {
+		local_irq_restore(flags);
+		printk(KERN_INFO "PCI: Using configuration type 2\n");
+		raw_pci_ops = &pci_direct_conf2;
+		return 0;
+	}
+	release_resource(region2);
+ fail2:
+	release_resource(region);
 
+ out:
 	local_irq_restore(flags);
 	return 0;
 }

-- 
"It's not Hollywood.  War is real, war is primarily not about defeat or
victory, it is about death.  I've seen thousands and thousands of dead bodies.
Do you think I want to have an academic debate on this subject?" -- Robert Fisk

             reply	other threads:[~2003-06-20 16:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-20 16:29 Matthew Wilcox [this message]
2003-06-20 16:46 ` [PATCH] PCI direct access resources Bartlomiej Zolnierkiewicz

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=20030620162929.GT24357@parcelfarce.linux.theplanet.co.uk \
    --to=willy@debian.org \
    --cc=greg@kroah.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