Commit a5ba7971045a90a36cef8f7d5a3075600b475b74

Authored by Aaron Durbin
Committed by Linus Torvalds
1 parent 08705b89ec

i386: insert unclaimed MMCONFIG resources

Insert the unclaimed MMCONFIG resources into the resource tree without the
IORESOURCE_BUSY flag during late initialization.  This allows the MMCONFIG
regions to be visible in the iomem resource tree without interfering with
other system resources that were discovered during PCI initialization.

[akpm@linux-foundation.org: nanofixes]
Signed-off-by: Aaron Durbin <adurbin@google.com>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 45 additions and 3 deletions Side-by-side Diff

arch/i386/pci/mmconfig-shared.c
... ... @@ -24,6 +24,9 @@
24 24  
25 25 DECLARE_BITMAP(pci_mmcfg_fallback_slots, 32*PCI_MMCFG_MAX_CHECK_BUS);
26 26  
  27 +/* Indicate if the mmcfg resources have been placed into the resource table. */
  28 +static int __initdata pci_mmcfg_resources_inserted;
  29 +
27 30 /* K8 systems have some devices (typically in the builtin northbridge)
28 31 that are only accessible using type1
29 32 Normally this can be expressed in the MCFG by not listing them
... ... @@ -170,7 +173,7 @@
170 173 return name != NULL;
171 174 }
172 175  
173   -static void __init pci_mmcfg_insert_resources(void)
  176 +static void __init pci_mmcfg_insert_resources(unsigned long resource_flags)
174 177 {
175 178 #define PCI_MMCFG_RESOURCE_NAME_LEN 19
176 179 int i;
177 180  
... ... @@ -194,10 +197,13 @@
194 197 cfg->pci_segment);
195 198 res->start = cfg->address;
196 199 res->end = res->start + (num_buses << 20) - 1;
197   - res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
  200 + res->flags = IORESOURCE_MEM | resource_flags;
198 201 insert_resource(&iomem_resource, res);
199 202 names += PCI_MMCFG_RESOURCE_NAME_LEN;
200 203 }
  204 +
  205 + /* Mark that the resources have been inserted. */
  206 + pci_mmcfg_resources_inserted = 1;
201 207 }
202 208  
203 209 static void __init pci_mmcfg_reject_broken(int type)
204 210  
205 211  
... ... @@ -267,8 +273,44 @@
267 273 if (type == 1)
268 274 unreachable_devices();
269 275 if (known_bridge)
270   - pci_mmcfg_insert_resources();
  276 + pci_mmcfg_insert_resources(IORESOURCE_BUSY);
271 277 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;
  278 + } else {
  279 + /*
  280 + * Signal not to attempt to insert mmcfg resources because
  281 + * the architecture mmcfg setup could not initialize.
  282 + */
  283 + pci_mmcfg_resources_inserted = 1;
272 284 }
273 285 }
  286 +
  287 +static int __init pci_mmcfg_late_insert_resources(void)
  288 +{
  289 + /*
  290 + * If resources are already inserted or we are not using MMCONFIG,
  291 + * don't insert the resources.
  292 + */
  293 + if ((pci_mmcfg_resources_inserted == 1) ||
  294 + (pci_probe & PCI_PROBE_MMCONF) == 0 ||
  295 + (pci_mmcfg_config_num == 0) ||
  296 + (pci_mmcfg_config == NULL) ||
  297 + (pci_mmcfg_config[0].address == 0))
  298 + return 1;
  299 +
  300 + /*
  301 + * Attempt to insert the mmcfg resources but not with the busy flag
  302 + * marked so it won't cause request errors when __request_region is
  303 + * called.
  304 + */
  305 + pci_mmcfg_insert_resources(0);
  306 +
  307 + return 0;
  308 +}
  309 +
  310 +/*
  311 + * Perform MMCONFIG resource insertion after PCI initialization to allow for
  312 + * misprogrammed MCFG tables that state larger sizes but actually conflict
  313 + * with other system resources.
  314 + */
  315 +late_initcall(pci_mmcfg_late_insert_resources);