From: "H. J. Lu" <hjl@lucon.org>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Jeff Garzik <jgarzik@pobox.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: PATCH: Support PCI device sorting (Re: PCI device order problem)
Date: Fri, 25 Oct 2002 20:26:00 -0700 [thread overview]
Message-ID: <20021025202600.A3293@lucon.org> (raw)
In-Reply-To: <20021025091102.A15082@lucon.org>; from hjl@lucon.org on Fri, Oct 25, 2002 at 09:11:02AM -0700
[-- Attachment #1: Type: text/plain, Size: 90 bytes --]
Here is a patch to add an option to sort the PCI device by bus, slot
and function.
H.J.
[-- Attachment #2: linux-2.4.18-pci-order.patch --]
[-- Type: text/plain, Size: 3295 bytes --]
--- linux/arch/i386/config.in.order Thu Oct 24 21:09:20 2002
+++ linux/arch/i386/config.in Fri Oct 25 16:34:13 2002
@@ -257,6 +257,7 @@ else
if [ "$CONFIG_PCI_GODIRECT" = "y" -o "$CONFIG_PCI_GOANY" = "y" ]; then
define_bool CONFIG_PCI_DIRECT y
fi
+ bool ' Sort device by bus, slot, function' CONFIG_PCI_SORT_BY_BUS_SLOT_FUNC
fi
fi
--- linux/arch/i386/kernel/pci-i386.h.order Sun Nov 11 10:09:32 2001
+++ linux/arch/i386/kernel/pci-i386.h Fri Oct 25 19:26:51 2002
@@ -21,6 +21,7 @@
#define PCI_ASSIGN_ROMS 0x1000
#define PCI_BIOS_IRQ_SCAN 0x2000
#define PCI_ASSIGN_ALL_BUSSES 0x4000
+#define PCI_BUS_SORT 0x8000
extern unsigned int pci_probe;
--- linux/arch/i386/kernel/pci-pc.c.order Thu Oct 24 21:09:20 2002
+++ linux/arch/i386/kernel/pci-pc.c Fri Oct 25 19:58:18 2002
@@ -19,7 +19,11 @@
#include "pci-i386.h"
+#ifdef CONFIG_PCI_SORT_BY_BUS_SLOT_FUNC
+unsigned int pci_probe = PCI_PROBE_BIOS | PCI_BUS_SORT | PCI_PROBE_CONF1 | PCI_PROBE_CONF2;
+#else
unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2;
+#endif
int pcibios_last_bus = -1;
struct pci_bus *pci_root_bus = NULL;
@@ -871,6 +875,53 @@ static struct pci_ops * __devinit pci_fi
return NULL;
}
+static void __devinit pci_sort_by_bus_slot_func(void)
+{
+ LIST_HEAD(sorted_devices);
+ struct list_head *ln;
+ struct pci_dev *dev, *d;
+ int n;
+ int s, slot;
+ int f, func;
+
+ printk(KERN_INFO "PCI: Sorting device list by bus, slot, function...\n");
+
+ /* Starting from bus 0, ... */
+ for (n=0; n <= pcibios_last_bus; n++) {
+ if (!pci_bus_exists(&pci_root_buses, n))
+ continue;
+
+ while (!list_empty(&pci_devices)) {
+ /* Find the lowest remaining PCI slot/function. */
+ slot = INT_MAX;
+ func = INT_MAX;
+ dev = NULL;
+ for (ln=pci_devices.next; ln != &pci_devices; ln=ln->next) {
+ d = pci_dev_g(ln);
+ s = PCI_SLOT(d->devfn);
+ f = PCI_FUNC(d->devfn);
+ if (d->bus->number == n
+ && (s < slot || (s == slot && f < func))) {
+ slot = s;
+ func = f;
+ dev = d;
+ }
+ }
+
+ if (dev) {
+ list_del(&dev->global_list);
+ list_add_tail(&dev->global_list, &sorted_devices);
+ }
+ else {
+ /* Stop if we don't find any devices on
+ this bus. */
+ break;
+ }
+ }
+ }
+ list_splice(&sorted_devices, &pci_devices);
+}
+
/*
* Sort the device list according to PCI BIOS. Nasty hack, but since some
* fool forgot to define the `correct' device order in the PCI BIOS specs
@@ -1392,8 +1443,10 @@ void __init pcibios_init(void)
pcibios_resource_survey();
+ if ((pci_probe & PCI_BUS_SORT) && !(pci_probe & PCI_NO_SORT))
+ pci_sort_by_bus_slot_func();
#ifdef CONFIG_PCI_BIOS
- if ((pci_probe & PCI_BIOS_SORT) && !(pci_probe & PCI_NO_SORT))
+ else if ((pci_probe & PCI_BIOS_SORT) && !(pci_probe & PCI_NO_SORT))
pcibios_sort();
#endif
}
@@ -1404,6 +1457,17 @@ char * __devinit pcibios_setup(char *st
pci_probe = 0;
return NULL;
}
+#ifdef CONFIG_PCI_SORT_BY_BUS_SLOT_FUNC
+ else if (!strcmp(str, "nobussort")) {
+ pci_probe &= ~PCI_BUS_SORT;
+ return NULL;
+ }
+#else
+ else if (!strcmp(str, "bussort")) {
+ pci_probe |= PCI_BUS_SORT;
+ return NULL;
+ }
+#endif
#ifdef CONFIG_PCI_BIOS
else if (!strcmp(str, "bios")) {
pci_probe = PCI_PROBE_BIOS;
next prev parent reply other threads:[~2002-10-26 3:19 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-24 23:39 PCI device order problem H. J. Lu
2002-10-24 23:49 ` Jeff Garzik
2002-10-24 23:56 ` H. J. Lu
2002-10-25 0:14 ` Jeff Garzik
2002-10-25 0:18 ` H. J. Lu
2002-10-25 10:00 ` Alan Cox
2002-10-25 16:11 ` H. J. Lu
2002-10-26 3:26 ` H. J. Lu [this message]
2002-10-26 21:12 ` PATCH: Support PCI device sorting (Re: PCI device order problem) Jeff Garzik
2002-10-26 21:27 ` H. J. Lu
2002-10-26 21:34 ` Jeff Garzik
2002-10-26 21:44 ` H. J. Lu
2002-10-26 22:04 ` Jeff Garzik
2002-10-26 22:20 ` H. J. Lu
2002-10-26 22:29 ` Jeff Garzik
2002-10-26 22:53 ` H. J. Lu
2002-10-26 22:58 ` Jeff Garzik
2002-10-26 23:45 ` Alan Cox
2002-10-26 23:53 ` H. J. Lu
2002-10-26 23:57 ` Jeff Garzik
2002-10-27 0:05 ` Jeff Garzik
2002-10-27 0:25 ` H. J. Lu
2002-10-27 17:42 ` Greg KH
2002-10-27 20:42 ` H. J. Lu
2002-10-28 0:26 ` Jeff Garzik
2002-10-27 0:30 ` Alan Cox
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=20021025202600.A3293@lucon.org \
--to=hjl@lucon.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=jgarzik@pobox.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;
as well as URLs for NNTP newsgroup(s).