linux-kernel-test/arch
Matt Domsch 6b4b78fed4 PCI: optionally sort device lists breadth-first
Problem:
New Dell PowerEdge servers have 2 embedded ethernet ports, which are
labeled NIC1 and NIC2 on the chassis, in the BIOS setup screens, and
in the printed documentation.  Assuming no other add-in ethernet ports
in the system, Linux 2.4 kernels name these eth0 and eth1
respectively.  Many people have come to expect this naming.  Linux 2.6
kernels name these eth1 and eth0 respectively (backwards from
expectations).  I also have reports that various Sun and HP servers
have similar behavior.


Root cause:
Linux 2.4 kernels walk the pci_devices list, which happens to be
sorted in breadth-first order (or pcbios_find_device order on i386,
which most often is breadth-first also).  2.6 kernels have both the
pci_devices list and the pci_bus_type.klist_devices list, the latter
is what is walked at driver load time to match the pci_id tables; this
klist happens to be in depth-first order.

On systems where, for physical routing reasons, NIC1 appears on a
lower bus number than NIC2, but NIC2's bridge is discovered first in
the depth-first ordering, NIC2 will be discovered before NIC1.  If the
list were sorted breadth-first, NIC1 would be discovered before NIC2.

A PowerEdge 1955 system has the following topology which easily
exhibits the difference between depth-first and breadth-first device
lists.

-[0000:00]-+-00.0  Intel Corporation 5000P Chipset Memory Controller Hub
           +-02.0-[0000:03-08]--+-00.0-[0000:04-07]--+-00.0-[0000:05-06]----00.0-[0000:06]----00.0  Broadcom Corporation NetXtreme II BCM5708S Gigabit Ethernet (labeled NIC2, 2.4 kernel name eth1, 2.6 kernel name eth0)
           +-1c.0-[0000:01-02]----00.0-[0000:02]----00.0  Broadcom Corporation NetXtreme II BCM5708S Gigabit Ethernet (labeled NIC1, 2.4 kernel name eth0, 2.6 kernel name eth1)


Other factors, such as device driver load order and the presence of
PCI slots at various points in the bus hierarchy further complicate
this problem; I'm not trying to solve those here, just restore the
device order, and thus basic behavior, that 2.4 kernels had.


Solution:

The solution can come in multiple steps.

Suggested fix #1: kernel
Patch below optionally sorts the two device lists into breadth-first
ordering to maintain compatibility with 2.4 kernels.  It adds two new
command line options:
  pci=bfsort
  pci=nobfsort
to force the sort order, or not, as you wish.  It also adds DMI checks
for the specific Dell systems which exhibit "backwards" ordering, to
make them "right".


Suggested fix #2: udev rules from userland
Many people also have the expectation that embedded NICs are always
discovered before add-in NICs (which this patch does not try to do).
Using the PCI IRQ Routing Table provided by system BIOS, it's easy to
determine which PCI devices are embedded, or if add-in, which PCI slot
they're in.  I'm working on a tool that would allow udev to name
ethernet devices in ascending embedded, slot 1 .. slot N order,
subsort by PCI bus/dev/fn breadth-first.  It'll be possible to use it
independent of udev as well for those distributions that don't use
udev in their installers.

Suggested fix #3: system board routing rules
One can constrain the system board layout to put NIC1 ahead of NIC2
regardless of breadth-first or depth-first discovery order.  This adds
a significant level of complexity to board routing, and may not be
possible in all instances (witness the above systems from several
major manufacturers).  I don't want to encourage this particular train
of thought too far, at the expense of not doing #1 or #2 above.


Feedback appreciated.  Patch tested on a Dell PowerEdge 1955 blade
with 2.6.18.

You'll also note I took some liberty and temporarily break the klist
abstraction to simplify and speed up the sort algorithm.  I think
that's both safe and appropriate in this instance.


Signed-off-by: Matt Domsch <Matt_Domsch@dell.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-10-18 11:36:12 -07:00
..
alpha [PATCH] fixing includes in alpha_ksyms.c 2006-10-12 12:25:27 -07:00
arm [ARM] switch to new pci_get_bus_and_slot API 2006-10-17 17:19:59 +01:00
arm26 [PATCH] remove bogus arch-specific syscall exports 2006-10-11 11:17:07 -07:00
avr32 [PATCH] IRQ: Fix AVR32 breakage 2006-10-11 11:14:14 -07:00
cris more misc typo fixes 2006-10-03 22:34:14 +02:00
frv IRQ: Maintain regs pointer globally rather than passing to IRQ handlers 2006-10-05 15:10:12 +01:00
h8300 Remove all inclusions of <linux/config.h> 2006-10-04 03:38:54 -04:00
i386 PCI: optionally sort device lists breadth-first 2006-10-18 11:36:12 -07:00
ia64 [PATCH] mm: use symbolic names instead of indices for zone initialisation 2006-10-11 11:14:14 -07:00
m32r [PATCH] m32r: more __user annotations 2006-10-11 11:17:06 -07:00
m68k [PATCH] clean m68k ksyms 2006-10-11 11:17:06 -07:00
m68knommu [PATCH] m68knommu: sync syscalls with m68k 2006-10-13 08:35:39 -07:00
mips [MIPS] Pass NULL not 0 for pointer value. 2006-10-11 19:31:00 +01:00
parisc [PATCH] remove bogus arch-specific syscall exports 2006-10-11 11:17:07 -07:00
powerpc [POWERPC] Check for offline nodes in pci NUMA code 2006-10-16 15:53:30 +10:00
ppc [POWERPC] ppc: Add missing calls to set_irq_regs 2006-10-16 15:52:14 +10:00
s390 Merge branch 'for-linus' of git://git390.osdl.marist.edu/pub/scm/linux-2.6 2006-10-11 11:20:11 -07:00
sh sh: SH-4A UBC support 2006-10-12 12:16:13 +09:00
sh64 fix file specification in comments 2006-10-03 23:01:26 +02:00
sparc [SPARC]: Sparc compilation fix with floppy enabled 2006-10-17 19:28:54 -07:00
sparc64 [SPARC64]: Update defconfig. 2006-10-17 19:29:41 -07:00
um [PATCH] make UML compile (FC6/x86-64) 2006-10-15 14:18:39 -07:00
v850 Remove all inclusions of <linux/config.h> 2006-10-04 03:38:54 -04:00
x86_64 [PATCH] genirq: clean up irq-flow-type naming 2006-10-17 08:18:45 -07:00
xtensa fix file specification in comments 2006-10-03 23:01:26 +02:00