2002-03-02 12:37:37

by Stephen Mollett

[permalink] [raw]
Subject: Handling of bogus PCI bus numbering

The 2.4 PCI subsystem seems not to handle bogus BIOS-assigned PCI bus numbers
well. (OK, it shouldn't be necessary for the OS to have to tweak the
numbering, but alas, it is.)

I've got an IBM Thinkpad 240 and the BIOS incorrectly assigns bus number 0 to
the CardBus (obviously, bus 0 is the primary internal PCI bus). Because of
this, it's impossible to use CardBus devices - when one is inserted, its
device number (00:00.0) collides with the 82443BX Northbridge and Card
Services understandably gets rather confused, thinking I've just plugged in a
440BX chip... ahem.

I've emailed Martin Mares (listed as the PCI maintainer in the PCI-driver
source) a while back but I think he must be busy at the moment. I had a look
at the source myself with a view to trying to write a patch but had to get
myself a stiff drink after about 5 minutes to help me recover from the
shell-shock :o)

(I'm using stock 2.4.17 on the machine at the moment.)

Here's /proc/pci without any CardBus devices inserted:

PCI devices found:
Bus 0, device 0, function 0:
Host bridge: Intel Corp. 440BX/ZX - 82443BX/ZX Host bridge (AGP disabled)
(rev 3).
Master Capable. Latency=64.
Prefetchable 32 bit memory at 0xf8000000 [0xfbffffff].
Bus 0, device 7, function 0:
Bridge: Intel Corp. 82371AB PIIX4 ISA (rev 2).
Bus 0, device 7, function 1:
IDE interface: Intel Corp. 82371AB PIIX4 IDE (rev 1).
Master Capable. Latency=64.
I/O at 0x1040 [0x104f].
Bus 0, device 7, function 2:
USB Controller: Intel Corp. 82371AB PIIX4 USB (rev 1).
IRQ 10.
Master Capable. Latency=64.
I/O at 0x1060 [0x107f].
Bus 0, device 7, function 3:
Bridge: Intel Corp. 82371AB PIIX4 ACPI (rev 2).
IRQ 9.
Bus 0, device 9, function 0:
VGA compatible controller: Neomagic Corporation NM2160 [MagicGraph 128XD]
(rev 1).
Master Capable. Latency=128. Min Gnt=16.Max Lat=255.
Prefetchable 32 bit memory at 0xf5000000 [0xf5ffffff].
Non-prefetchable 32 bit memory at 0xf4000000 [0xf41fffff].
Non-prefetchable 32 bit memory at 0xf4200000 [0xf42fffff].
Bus 0, device 10, function 0:
CardBus bridge: Texas Instruments PCI1211 (rev 0).
IRQ 11.
Master Capable. Latency=168. Min Gnt=192.Max Lat=7.
Non-prefetchable 32 bit memory at 0x10000000 [0x10000fff].
Bus 0, device 11, function 0:
Multimedia audio controller: ESS Technology ES1969 Solo-1 Audiodrive (rev
2).
IRQ 3.
Master Capable. Latency=64. Min Gnt=2.Max Lat=24.
I/O at 0x1000 [0x103f].
I/O at 0x1090 [0x109f].
I/O at 0x1080 [0x108f].
I/O at 0x10a4 [0x10a7].
I/O at 0x10a0 [0x10a3].
Bus 0, device 12, function 0:
Communication controller: Lucent Microelectronics WinModem 56k (rev 1).
IRQ 10.
Master Capable. No bursts. Min Gnt=252.Max Lat=14.
Non-prefetchable 32 bit memory at 0xf4300000 [0xf43000ff].
I/O at 0x10a8 [0x10af].
I/O at 0x1400 [0x14ff].

With a 3Com 3CCFE575CT CardBus 100Mbit NIC inserted, /proc/pci is identical
except for one extra device at the end of the listing:

Bus 0, device 0, function 0:
Host bridge: (rev 3).
Master Capable. Latency=64.

and the entry for the CardBus bridge, which shows Min Gnt=128 instead of 192.

Card Services (version 3.1.31, from pcmcia-cs.sf.net) reports:

Mar 2 12:10:08 rodin cardmgr[47]: unsupported card in socket 0
Mar 2 12:10:08 rodin kernel: cs: cb_alloc(bus 0): vendor 0x8086, device
0x7192
Mar 2 12:10:08 rodin cardmgr[47]: no product info available
Mar 2 12:10:08 rodin cardmgr[47]: PCI id: 0x8086, 0x7192

when I insert the NIC.

Please cc any responses to me - I can't take the lkml traffic!

Thanks
Stephen


2002-03-03 12:00:46

by Stephen Mollett

[permalink] [raw]
Subject: Re: Handling of bogus PCI bus numbering

On Saturday 02 Mar 2002 15:15, Kai Germaschewski wrote:
> On Sat, 2 Mar 2002, Stephen Mollett wrote:
>> I've got an IBM Thinkpad 240 and the BIOS incorrectly assigns bus number
>> 0 to the CardBus ...
> Could you replace "#undef DEBUG" with "#define DEBUG" in drivers/pci/pci.c
> and arch/i386/kernel/pci-i386.h, rebuild the kernel and send "dmesg"
> output after rebooting/inserting the card?

Here's the full output. The card was inserted immediately after the boot
completed - the insertion shows up as the last line of the messages.

Stephen

Linux version 2.4.17-pcidebug (root@rodin) (gcc version 2.95.3 20010315
(release)) #6 Sun Mar 3 11:26:37 GMT 2002
BIOS-provided physical RAM map:
BIOS-e820: 0000000000000000 - 000000000009fc00 (usable)
BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved)
BIOS-e820: 00000000000e0000 - 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 - 000000000bff0000 (usable)
BIOS-e820: 000000000bff0000 - 000000000bfffc00 (ACPI data)
BIOS-e820: 000000000bfffc00 - 000000000c000000 (ACPI NVS)
BIOS-e820: 00000000fff80000 - 0000000100000000 (reserved)
On node 0 totalpages: 49136
zone(0): 4096 pages.
zone(1): 45040 pages.
zone(2): 0 pages.
Local APIC disabled by BIOS -- reenabling.
Could not enable APIC!
Kernel command line: BOOT_IMAGE=Linux-Backup ro root=302
Initializing CPU#0
Detected 298.650 MHz processor.
Console: colour VGA+ 80x30
Calibrating delay loop... 596.37 BogoMIPS
Memory: 191648k/196544k available (829k kernel code, 4508k reserved, 195k
data, 188k init, 0k highmem)
Dentry-cache hash table entries: 32768 (order: 6, 262144 bytes)
Inode-cache hash table entries: 16384 (order: 5, 131072 bytes)
Mount-cache hash table entries: 4096 (order: 3, 32768 bytes)
Buffer-cache hash table entries: 8192 (order: 3, 32768 bytes)
Page-cache hash table entries: 65536 (order: 6, 262144 bytes)
CPU: Before vendor init, caps: 0183f9ff 00000000 00000000, vendor = 0
CPU: L1 I cache: 16K, L1 D cache: 16K
CPU: L2 cache: 128K
CPU: After vendor init, caps: 0183f9ff 00000000 00000000 00000000
Intel machine check architecture supported.
Intel machine check reporting enabled on CPU#0.
CPU: After generic, caps: 0183f9ff 00000000 00000000 00000000
CPU: Common caps: 0183f9ff 00000000 00000000 00000000
CPU: Intel Celeron (Mendocino) stepping 0a
Enabling fast FPU save and restore... done.
Checking 'hlt' instruction... OK.
POSIX conformance testing by UNIFIX
mtrr: v1.40 (20010327) Richard Gooch ([email protected])
mtrr: detected mtrr type: Intel
PCI: BIOS32 Service Directory structure at 0xc00f6b30
PCI: BIOS32 Service Directory entry at 0xfd7c0
PCI: BIOS probe returned s=00 hw=01 ver=02.10 l=00
PCI: PCI BIOS revision 2.10 entry at 0xfd9e5, last bus=0
PCI: Using configuration type 1
PCI: Probing PCI hardware
Scanning bus 00
Found 00:00 [8086/7192] 000600 00
Found 00:38 [8086/7110] 000680 00
Found 00:39 [8086/7111] 000101 00
PCI: IDE base address fixup for 00:07.1
Found 00:3a [8086/7112] 000c03 00
Found 00:3b [8086/7113] 000680 00
Found 00:48 [10c8/0004] 000300 00
Found 00:50 [104c/ac1e] 000607 02
Found 00:58 [125d/1969] 000401 00
Found 00:60 [11c1/0449] 000780 00
Fixups for bus 00
PCI: Scanning for ghost devices on bus 0
Scanning behind PCI bridge 00:0a.0, config 010000, pass 0
Scanning behind PCI bridge 00:0a.0, config 010000, pass 1
Bus scan for 00 returning with max=01
PCI: IRQ init
PCI: Interrupt Routing Table found at 0xc00fdf60
00:00 slot=00 0:60/def8 1:61/def8 2:62/def8 3:63/def8
00:07 slot=00 0:60/def8 1:61/def8 2:62/def8 3:63/8eb8
00:09 slot=00 0:00/def8 1:00/def8 2:00/def8 3:00/def8
00:0a slot=00 0:61/8eb8 1:00/def8 2:00/def8 3:00/def8
00:0b slot=00 0:62/8eb8 1:00/def8 2:00/def8 3:00/def8
00:0c slot=00 0:63/8eb8 1:00/def8 2:00/def8 3:00/def8
PCI: Attempting to find IRQ router for 8086:122e
PCI: Using IRQ router PIIX [8086/7110] at 00:07.0
PCI: IRQ fixup
00:09.0: ignoring bogus IRQ 255
IRQ for 00:09.0:0 -> not routed
PCI: Allocating resources
PCI: Resource f8000000-fbffffff (f=1208, d=0, p=0)
PCI: Resource 00001040-0000104f (f=101, d=0, p=0)
PCI: Resource 00001060-0000107f (f=101, d=0, p=0)
PCI: Resource f5000000-f5ffffff (f=1208, d=0, p=0)
PCI: Resource f4000000-f41fffff (f=200, d=0, p=0)
PCI: Resource f4200000-f42fffff (f=200, d=0, p=0)
PCI: Resource 00001000-0000103f (f=101, d=0, p=0)
PCI: Resource 00001090-0000109f (f=101, d=0, p=0)
PCI: Resource 00001080-0000108f (f=101, d=0, p=0)
PCI: Resource 000010a4-000010a7 (f=105, d=0, p=0)
PCI: Resource 000010a0-000010a3 (f=101, d=0, p=0)
PCI: Resource f4300000-f43000ff (f=200, d=0, p=0)
PCI: Resource 000010a8-000010af (f=109, d=0, p=0)
PCI: Resource 00001400-000014ff (f=101, d=0, p=0)
PCI: Sorting device list...
Limiting direct PCI/PCI transfers.
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
IBM machine detected. Enabling interrupts during APM calls.
apm: BIOS version 1.2 Flags 0x03 (Driver version 1.15)
Starting kswapd
pty: 256 Unix98 ptys configured
block: 128 slots per queue, batch=32
Uniform Multi-Platform E-IDE driver Revision: 6.31
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
PIIX4: IDE controller on PCI bus 00 dev 39
PIIX4: chipset revision 1
PIIX4: not 100% native mode: will probe irqs later
ide0: BM-DMA at 0x1040-0x1047, BIOS settings: hda:DMA, hdb:pio
ide1: BM-DMA at 0x1048-0x104f, BIOS settings: hdc:pio, hdd:pio
hda: IBM-DBCA-206480, ATA DISK drive
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
hda: 12685680 sectors (6495 MB) w/420KiB Cache, CHS=789/255/63, UDMA(33)
Partition check:
hda: hda1 hda2 hda3 hda4
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 1024 buckets, 8Kbytes
TCP: Hash tables configured (established 16384 bind 16384)
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
reiserfs: checking transaction log (device 03:02) ...
Using tea hash to sort names
ReiserFS version 3.6.25
VFS: Mounted root (reiserfs filesystem) readonly.
Freeing unused kernel memory: 188k freed
reiserfs: checking transaction log (device 03:03) ...
Using tea hash to sort names
ReiserFS version 3.6.25
reiserfs: checking transaction log (device 03:04) ...
Using tea hash to sort names
ReiserFS version 3.6.25
Real Time Clock Driver v1.10e
Linux PCMCIA Card Services 3.1.31
kernel build: 2.4.17-pcidebug #6 Sun Mar 3 11:26:37 GMT 2002
options: [pci] [cardbus] [apm] [pnp]
PnP: PNP BIOS installation structure at 0xc00f6b80
PnP: PNP BIOS version 1.0, entry at f0000:8440, dseg at 400
Intel ISA/PCI/CardBus PCIC probe:
IRQ for 00:0a.0:0 -> PIRQ 61, mask 8eb8, excl 0000 -> newirq=11 -> got IRQ 11
PCI: Found IRQ 11 for device 00:0a.0
TI 1211 rev 00 PCI-to-CardBus at slot 00:0a, mem 0x10000000
host opts [0]: [ring] [pci + serial irq] [pci irq 11] [lat 168/176] [bus
0/1]
ISA irqs (scanned) = 5,15 PCI status changes
parport0: PC-style at 0x3bc (0x7bc), irq 7, using FIFO
[PCSPP,TRISTATE,COMPAT,ECP]
lp0: using parport0 (interrupt-driven).
lp0: compatibility mode
lp0: compatibility mode
Serial driver version 5.05c (2001-07-08) with MANY_PORTS SHARE_IRQ SERIAL_PCI
enabled
ttyS00 at 0x03f8 (irq = 4) is a 16550A
ttyS02 at 0x03e8 (irq = 4) is a 16550A
cs: cb_alloc(bus 0): vendor 0x8086, device 0x7192

2002-03-03 13:48:15

by Alan

[permalink] [raw]
Subject: Re: Handling of bogus PCI bus numbering

> The 2.4 PCI subsystem seems not to handle bogus BIOS-assigned PCI bus numbers
> well. (OK, it shouldn't be necessary for the OS to have to tweak the
> numbering, but alas, it is.)

Does the pci=assign-busses option help ?

2002-03-03 14:46:03

by Alan

[permalink] [raw]
Subject: Re: Handling of bogus PCI bus numbering - case closed

> >> numbers well...
> > Does the pci=assign-busses option help ?
>
> Yes :)
> The CardBus gets assigned a real bus number at last.
>
> I must have been so brain-fried when I was scouring the documentation and
> source that I overlooked that one.

Its not terribly well documented. Can you run dmidecode on your laptop
and hopefully we can catch that laptop and automtically do bus assignment
for it

2002-03-03 14:43:57

by Stephen Mollett

[permalink] [raw]
Subject: Re: Handling of bogus PCI bus numbering - case closed

On Sunday 03 Mar 2002 14:02, Alan Cox wrote:
>> The 2.4 PCI subsystem seems not to handle bogus BIOS-assigned PCI bus
>> numbers well...
> Does the pci=assign-busses option help ?

Yes :)

The CardBus gets assigned a real bus number at last.

I must have been so brain-fried when I was scouring the documentation and
source that I overlooked that one.

Thanks

Stephen

2002-03-03 16:34:58

by Stephen Mollett

[permalink] [raw]
Subject: Re: Handling of bogus PCI bus numbering - case closed

On Sunday 03 Mar 2002 15:00, Alan Cox wrote:
> ... Can you run dmidecode on your laptop
> and hopefully we can catch that laptop and automtically do bus assignment
> for it

dmidecode output follows:

SMBIOS 2.3 present.
DMI 2.3 present.
31 structures occupying 876 bytes.
DMI table at 0x000EABC0.
Handle 0x0000
DMI type 0, 20 bytes.
BIOS Information Block
Vendor: IBM
Version: IRET75WW
Release: 11/30/1999
BIOS base: 0xEA720
ROM size: 448K
Capabilities:
Flags: 0x0000000000011F90
Handle 0x0001
DMI type 1, 25 bytes.
System Information Block
Vendor: IBM
Product: 260921G
Version: Not Available
Serial Number: BAZAPVF
Handle 0x0002
DMI type 2, 8 bytes.
Board Information Block
Vendor: IBM
Product: 2609BS1
Version: Not Available
Serial Number: PLR-SERIAL#
Handle 0x0003
DMI type 3, 17 bytes.
Chassis Information Block
Vendor: IBM
Chassis Type: Notebook
Version: Not Available
Serial Number: Not Available
Asset Tag: Not Available
Handle 0x0004
DMI type 4, 32 bytes.
Processor
Socket Designation: MMC 2
Processor Type: Central Processor
Processor Family: Celeron processor
Processor Manufacturer: GenuineIntel
Processor Version: Celeron(TM)
Handle 0x0005
DMI type 5, 20 bytes.
Memory Controller
Handle 0x0006
DMI type 6, 12 bytes.
Memory Bank
Socket: CN24
Banks: 0 1
Speed: 15nS
Type:
Installed Size: 64Mbyte (Double sided)
Enabled Size: 64Mbyte (Double sided)
Handle 0x0007
DMI type 6, 12 bytes.
Memory Bank
Socket: CN25
Banks: 2 3
Speed: 15nS
Type:
Installed Size: 128Mbyte (Double sided)
Enabled Size: 128Mbyte (Double sided)
Handle 0x0008
DMI type 7, 19 bytes.
Cache
Socket: L1 Cache
L1 socketed Internal Cache: write-back
L1 Cache Size: 32K
L1 Cache Maximum: 32K
L1 Cache Type: Asynchronous
Handle 0x0009
DMI type 7, 19 bytes.
Cache
Socket: L2 Cache
L2 socketed External Cache: write-back
L2 Cache Size: 256K
L2 Cache Maximum: 128K
L2 Cache Type: Unknown
Handle 0x000A
DMI type 8, 9 bytes.
Port Connector
Internal Designator: CN7
Internal Connector Type: 9 Pin Dual Inline (pin 10 cut)
External Designator: COM 1
External Connector Type: DB-9 pin male
Port Type: Serial Port 16650A Compatible
Handle 0x000B
DMI type 8, 9 bytes.
Port Connector
Internal Designator: CN1
Internal Connector Type: 25 Pin Dual Inline (pin 26 cut)
External Designator: Parallel
External Connector Type: DB-25 pin female
Port Type: Parallel Port ECP/EPP
Handle 0x000C
DMI type 8, 9 bytes.
Port Connector
Internal Designator: CN14
Internal Connector Type: None
External Designator: Keyboard
External Connector Type: Circular DIN-8 male
Port Type: Keyboard Port
Handle 0x000D
DMI type 8, 9 bytes.
Port Connector
Internal Designator: CN14
Internal Connector Type: None
External Designator: PS/2 Mouse
External Connector Type: Circular DIN-8 male
Port Type: Mouse Port
Handle 0x000E
DMI type 8, 9 bytes.
Port Connector
Internal Designator: CN4
Internal Connector Type: None
External Designator: USB
External Connector Type: Access Bus (USB)
Port Type: USB
Handle 0x000F
DMI type 8, 9 bytes.
Port Connector
Internal Designator: CN13
Internal Connector Type: None
External Designator: Infrared
External Connector Type: Infrared
Port Type: Other
Handle 0x0010
DMI type 8, 9 bytes.
Port Connector
Internal Designator: SM1
Internal Connector Type: None
External Designator: Lucent Modem
External Connector Type: RJ-11
Port Type: Modem Port
Handle 0x0011
DMI type 9, 13 bytes.
Card Slot
Slot: CardBus Slot 1
Type: 32bit PCMCIA VLB
Status: Available.
Slot Features: 5v 3.3v PCCard16 CardBus Zoom-Video
Handle 0x0012
DMI type 10, 8 bytes.
On Board Devices Information
Description: Video (NeoMagic NM2160) : Disabled
Type:
Description: ESS 1946 : Disabled
Type:
Handle 0x0013
DMI type 11, 5 bytes.
OEM Data
Intel 440BX NoteBook
IBM ThinkPad
Handle 0x0014
DMI type 12, 5 bytes.
Configuration Information
Handle 0x0015
DMI type 16, 15 bytes.
Physical Memory Array
Handle 0x0016
DMI type 17, 23 bytes.
Memory Device
Handle 0x0017
DMI type 17, 23 bytes.
Memory Device
Handle 0x0018
DMI type 19, 15 bytes.
Memory Array Mapped Address
Handle 0x0019
DMI type 20, 19 bytes.
Memory Device Mapped Address
Handle 0x001A
DMI type 21, 7 bytes.
03 04 02 ...
Handle 0x001B
DMI type 31, 28 bytes.
00 00 00 00 4e 61 bc 00 4e 61 bc 00 00 00 00 00 ....Na..Na......
00 00 00 00 00 00 00 00 ........
Handle 0x001C
DMI type 32, 20 bytes.
System Boot Information
Handle 0x001D
DMI type 126, 4 bytes.
Inactive
Handle 0x001E
DMI type 127, 4 bytes.
End-of-Table

2002-03-03 22:17:15

by Kai Germaschewski

[permalink] [raw]
Subject: Re: Handling of bogus PCI bus numbering

On Sat, 2 Mar 2002, Stephen Mollett wrote:

> I've got an IBM Thinkpad 240 and the BIOS incorrectly assigns bus number 0 to
> the CardBus (obviously, bus 0 is the primary internal PCI bus). Because of
> this, it's impossible to use CardBus devices - when one is inserted, its
> device number (00:00.0) collides with the 82443BX Northbridge and Card
> Services understandably gets rather confused, thinking I've just plugged in a
> 440BX chip... ahem.

Could you replace "#undef DEBUG" with "#define DEBUG" in drivers/pci/pci.c
and arch/i386/kernel/pci-i386.h, rebuild the kernel and send "dmesg"
output after rebooting/inserting the card?

--Kai