Bug 62511 - [PATCH]Incorrect coalescing of overlapping ACPI resources may fail to resolve some overlaps
Summary: [PATCH]Incorrect coalescing of overlapping ACPI resources may fail to resolve...
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: PCI (show other bugs)
Hardware: x86-64 Linux
: P1 normal
Assignee: drivers_pci@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-03 23:12 UTC by Alexey Neyman
Modified: 2014-06-04 00:48 UTC (History)
2 users (show)

See Also:
Kernel Version: 3.12.0-rc3+
Subsystem:
Regression: No
Bisected commit-id:


Attachments
Patch to fix the issue (972 bytes, patch)
2013-10-03 23:12 UTC, Alexey Neyman
Details | Diff

Description Alexey Neyman 2013-10-03 23:12:29 UTC
Created attachment 110211 [details]
Patch to fix the issue

I have a board with a BIOS bug that reports the following I/O port regions in _CRS on one of the host bridges:

0x0000-0x03af // #0
0x03e0-0x0cf7 // #1
0x03b0-0x03bb // #2
0x03c0-0x03df // #3
0x0000-0xdfff // #4
0xf000-0xffff // #5

Obviously, region number #4 is erroneous as it overlaps with regions #0..3. The code in coalesce_windows() in arch/x86/pci/acpi.c attempts to recover from such kind of BIOS bugs by merging the overlapping regions. Current code expands region #0 to 0x0000-0xdffff and makes region #4 ignored. As a result, overlap of the expanded region #0 with regions #1..3 remains undetected (as the inner loop already compared them with region #0). As a result, regions #1..3 are inserted into the resource tree even though they overlap with adjusted region #0 - which later results in resource conflicts for PCI devices with IO ports in one of those regions (e.g., for an PCI IDE controller in legacy mode - which has port 0x3f6). The kernel then refuses to initialize these devices.

The fix: instead of expanding res1 and ignoring res2, do the opposite. The res2 window is yet to be compared against all windows between res1 and res2 (regions #1..3 in the above example), so the resulting resource map will include just the expanded region - and will ignore any overlapping ones.

I am not at liberty to disclose full hardware configuration of the board at this time; I could quote the relevant messages from dmesg output.

Without the fix:

root@localhost:~# dmesg
...
[    0.500318] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-7f])
[    0.500619] acpi PNP0A08:00: Requesting ACPI _OSC control (0x1d)
[    0.500992] acpi PNP0A08:00: ACPI _OSC control (0x1c) granted
[    0.501342] acpi PNP0A08:00: host bridge window expanded to [io  0x0000-0xdfff]; [io  0x0000-0xdfff] ignored
[    0.501522] acpi PNP0A08:00: fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge.
[    0.501731] PCI host bridge to bus 0000:00
[    0.501836] pci_bus 0000:00: root bus resource [bus 00-7f]
[    0.501941] pci_bus 0000:00: root bus resource [io  0x0000-0xdfff]
[    0.502047] pci_bus 0000:00: root bus resource [io  0x03e0-0x0cf7] 
[    0.502156] pci_bus 0000:00: root bus resource [io  0x03b0-0x03bb]
[    0.502263] pci_bus 0000:00: root bus resource [io  0x03c0-0x03df]
[    0.502370] pci_bus 0000:00: root bus resource [io  0xf000-0xffff]
[    0.502478] pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000bffff]
[    0.502588] pci_bus 0000:00: root bus resource [mem 0x000d0000-0x000dffff]
[    0.502696] pci_bus 0000:00: root bus resource [mem 0xf9000000-0xfbffffff]
[    0.502805] pci_bus 0000:00: root bus resource [mem 0xfed40000-0xfed44fff]                                         
...  
[    0.541605] pci 0000:00:1f.2: address space collision: [io  0x03f6] conflicts with PCI Bus 0000:00 [io  0x03e0-0x0cf7]
[    0.541780] pci 0000:00:1f.3: address space collision: [io  0x0400-0x041f] conflicts with PCI Bus 0000:00 [io  0x03e0-0x0cf7]
...  
root@localhost:~# cat /proc/ioports | grep 'PCI Bus 0000:00' 
0000-dfff : PCI Bus 0000:00 
  03b0-03bb : PCI Bus 0000:00
  03c0-03df : PCI Bus 0000:00
  03e0-0cf7 : PCI Bus 0000:00
f000-ffff : PCI Bus 0000:00

With the fix:

root@localhost:~# dmesg 
...  
[    0.502521] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-7f])                                                 
[    0.502822] acpi PNP0A08:00: Requesting ACPI _OSC control (0x1d)                                                   
[    0.503215] acpi PNP0A08:00: ACPI _OSC control (0x1c) granted
[    0.503580] acpi PNP0A08:00: host bridge window expanded to [io  0x0000-0xdfff]; [io  0x0000-0x03af] ignored       
[    0.503746] acpi PNP0A08:00: host bridge window expanded to [io  0x0000-0xdfff]; [io  0x03e0-0x0cf7] ignored       
[    0.503912] acpi PNP0A08:00: host bridge window expanded to [io  0x0000-0xdfff]; [io  0x03b0-0x03bb] ignored 
[    0.504077] acpi PNP0A08:00: host bridge window expanded to [io  0x0000-0xdfff]; [io  0x03c0-0x03df] ignored       
[    0.504245] acpi PNP0A08:00: fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge.
[    0.504453] PCI host bridge to bus 0000:00
[    0.504562] pci_bus 0000:00: root bus resource [bus 00-7f]                                                         
[    0.504669] pci_bus 0000:00: root bus resource [io  0x0000-0xdfff]
[    0.504776] pci_bus 0000:00: root bus resource [io  0xf000-0xffff]                                                 
[    0.504883] pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000bffff]
[    0.504991] pci_bus 0000:00: root bus resource [mem 0x000d0000-0x000dffff]                                         
[    0.505100] pci_bus 0000:00: root bus resource [mem 0xf9000000-0xfbffffff]                                         
[    0.505212] pci_bus 0000:00: root bus resource [mem 0xfed40000-0xfed44fff]
...  
[    0.512343] pci 0000:00:1f.2: [8086:3a20] type 00 class 0x01018a
[    0.512359] pci 0000:00:1f.2: reg 0x10: [io  0x0000-0x0007]                                                        
[    0.512366] pci 0000:00:1f.2: reg 0x14: [io  0x0000-0x0003]                                                        
[    0.512374] pci 0000:00:1f.2: reg 0x18: [io  0x0000-0x0007]                                                        
[    0.512382] pci 0000:00:1f.2: reg 0x1c: [io  0x0000-0x0003]                                                        
[    0.512389] pci 0000:00:1f.2: reg 0x20: [io  0xff90-0xff9f]                                                        
[    0.512397] pci 0000:00:1f.2: reg 0x24: [io  0xffa0-0xffaf]                                                        
[    0.512521] pci 0000:00:1f.3: [8086:3a30] type 00 class 0x0c0500                                                   
[    0.512536] pci 0000:00:1f.3: reg 0x10: [mem 0xfbed2000-0xfbed20ff 64bit]                                          
[    0.512559] pci 0000:00:1f.3: reg 0x20: [io  0x0400-0x041f]
...
[    3.077156] ata_piix 0000:00:1f.2: version 2.13
[    3.077285] ata_piix 0000:00:1f.2: MAP [
[    3.077388]  P0 P2 P1 P3 ]
[    3.077693] ata_piix 0000:00:1f.2: setting latency timer to 64
...
[    3.468528] i801_smbus 0000:00:1f.3: SMBus using PCI Interrupt
...
root@localhost:~# cat /proc/ioports | grep 'PCI Bus 0000:00'
0000-dfff : PCI Bus 0000:00
f000-ffff : PCI Bus 0000:00
Comment 1 Alan 2013-11-13 14:16:39 UTC
See Documentation/SubmittingPatches

Patches neeed to be emailed with a Signed-off-by: so we have an authorship/audit trail.
Comment 2 Alexey Neyman 2013-11-13 17:47:00 UTC
It has been emailed with signed-off-by header, see here:

https://lkml.org/lkml/2013/10/9/564

It was in that thread that I was directed to create a bug - which I did.
Comment 3 Bjorn Helgaas 2014-06-04 00:48:21 UTC
Resolved by

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=3ad674d6c6c5724c83f10f422d826420c83536cd

which appeared in v3.13-rc1.

Note You need to log in before you can comment on or make changes to this bug.