[PATCH] x86: pci_assign_unassigned_resources() update

I had some time to think about PCI assign issues in 2.6.13-rc series.

The major problem here is that we call pci_assign_unassigned_resources()
way too early - at subsys_initcall level. Therefore we give no chances
to ACPI and PnP routines (called at fs_initcall level) to reserve their
respective resources properly, as the comments in drivers/pnp/system.c
and drivers/acpi/motherboard.c suggest:

/**
* Reserve motherboard resources after PCI claim BARs,
* but before PCI assign resources for uninitialized PCI devices
*/

So I moved the pci_assign_unassigned_resources() call to
pcibios_assign_resources() (fs_initcall), which should hopefully fix a
lot of problems and make PCIBIOS_MIN_IO tweaks unnecessary.

Other changes:
- remove resource assignment code from pcibios_assign_resources(), since
it duplicates pci_assign_unassigned_resources() functionality and
actually does nothing in 2.6.13;
- modify ROM assignment code as per Ben's suggestion: try to use firmware
settings by default (if PCI_ASSIGN_ROMS is not set);
- set CARDBUS_IO_SIZE back to 4K as it's a wonderful stress test for
various setups.

Confirmed by Tero Roponen <teanropo@cc.jyu.fi> (who had problems with
the 4kB CardBus IO size previously).

Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Ivan Kokshaysky and committed by
Linus Torvalds
81d4af13 ae11be6f

+17 -35
-1
arch/i386/pci/common.c
··· 165 165 if ((pci_probe & PCI_BIOS_SORT) && !(pci_probe & PCI_NO_SORT)) 166 166 pcibios_sort(); 167 167 #endif 168 - pci_assign_unassigned_resources(); 169 168 return 0; 170 169 } 171 170
+16 -33
arch/i386/pci/i386.c
··· 170 170 static int __init pcibios_assign_resources(void) 171 171 { 172 172 struct pci_dev *dev = NULL; 173 - int idx; 174 - struct resource *r; 173 + struct resource *r, *pr; 175 174 176 - for_each_pci_dev(dev) { 177 - int class = dev->class >> 8; 178 - 179 - /* Don't touch classless devices and host bridges */ 180 - if (!class || class == PCI_CLASS_BRIDGE_HOST) 181 - continue; 182 - 183 - for(idx=0; idx<6; idx++) { 184 - r = &dev->resource[idx]; 185 - 186 - /* 187 - * Don't touch IDE controllers and I/O ports of video cards! 188 - */ 189 - if ((class == PCI_CLASS_STORAGE_IDE && idx < 4) || 190 - (class == PCI_CLASS_DISPLAY_VGA && (r->flags & IORESOURCE_IO))) 191 - continue; 192 - 193 - /* 194 - * We shall assign a new address to this resource, either because 195 - * the BIOS forgot to do so or because we have decided the old 196 - * address was unusable for some reason. 197 - */ 198 - if (!r->start && r->end) 199 - pci_assign_resource(dev, idx); 200 - } 201 - 202 - if (pci_probe & PCI_ASSIGN_ROMS) { 175 + if (!(pci_probe & PCI_ASSIGN_ROMS)) { 176 + /* Try to use BIOS settings for ROMs, otherwise let 177 + pci_assign_unassigned_resources() allocate the new 178 + addresses. */ 179 + for_each_pci_dev(dev) { 203 180 r = &dev->resource[PCI_ROM_RESOURCE]; 204 - r->end -= r->start; 205 - r->start = 0; 206 - if (r->end) 207 - pci_assign_resource(dev, PCI_ROM_RESOURCE); 181 + if (!r->flags || !r->start) 182 + continue; 183 + pr = pci_find_parent_resource(dev, r); 184 + if (!pr || request_resource(pr, r) < 0) { 185 + r->end -= r->start; 186 + r->start = 0; 187 + } 208 188 } 209 189 } 190 + 191 + pci_assign_unassigned_resources(); 192 + 210 193 return 0; 211 194 } 212 195
+1 -1
drivers/pci/setup-bus.c
··· 40 40 * FIXME: IO should be max 256 bytes. However, since we may 41 41 * have a P2P bridge below a cardbus bridge, we need 4K. 42 42 */ 43 - #define CARDBUS_IO_SIZE (256) 43 + #define CARDBUS_IO_SIZE (4*1024) 44 44 #define CARDBUS_MEM_SIZE (32*1024*1024) 45 45 46 46 static void __devinit