diff options
author | Nicholas Johnson <nicholas.johnson-opensource@outlook.com.au> | 2019-05-07 15:51:24 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2019-05-07 16:53:08 -0400 |
commit | 0d6076184aecb97cc583bc7f9e125518d6c24404 (patch) | |
tree | bf8862b9b703c75613a5554c90a39eab15ae00ba | |
parent | 113fb03ed1d4c1877cc8817e500867616b222380 (diff) |
PCI: Cleanup setup-bus.c comments and whitespace
Cleanup comments, kernel-doc, coding style. No functional changes
intended; comment and whitespace changes only.
Link: https://lore.kernel.org/lkml/PS2P216MB06427E290A68CDB921FB4B2980250@PS2P216MB0642.KORP216.PROD.OUTLOOK.COM
Signed-off-by: Nicholas Johnson <nicholas.johnson-opensource@outlook.com.au>
[bhelgaas: tidy related things throughout the file]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r-- | drivers/pci/setup-bus.c | 496 |
1 files changed, 249 insertions, 247 deletions
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index ec44a0f3a7ac..6728144308c0 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
@@ -49,17 +49,15 @@ static void free_list(struct list_head *head) | |||
49 | } | 49 | } |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * add_to_list() - add a new resource tracker to the list | 52 | * add_to_list() - Add a new resource tracker to the list |
53 | * @head: Head of the list | 53 | * @head: Head of the list |
54 | * @dev: device corresponding to which the resource | 54 | * @dev: Device to which the resource belongs |
55 | * belongs | 55 | * @res: Resource to be tracked |
56 | * @res: The resource to be tracked | 56 | * @add_size: Additional size to be optionally added to the resource |
57 | * @add_size: additional size to be optionally added | ||
58 | * to the resource | ||
59 | */ | 57 | */ |
60 | static int add_to_list(struct list_head *head, | 58 | static int add_to_list(struct list_head *head, struct pci_dev *dev, |
61 | struct pci_dev *dev, struct resource *res, | 59 | struct resource *res, resource_size_t add_size, |
62 | resource_size_t add_size, resource_size_t min_align) | 60 | resource_size_t min_align) |
63 | { | 61 | { |
64 | struct pci_dev_resource *tmp; | 62 | struct pci_dev_resource *tmp; |
65 | 63 | ||
@@ -80,8 +78,7 @@ static int add_to_list(struct list_head *head, | |||
80 | return 0; | 78 | return 0; |
81 | } | 79 | } |
82 | 80 | ||
83 | static void remove_from_list(struct list_head *head, | 81 | static void remove_from_list(struct list_head *head, struct resource *res) |
84 | struct resource *res) | ||
85 | { | 82 | { |
86 | struct pci_dev_resource *dev_res, *tmp; | 83 | struct pci_dev_resource *dev_res, *tmp; |
87 | 84 | ||
@@ -158,7 +155,7 @@ static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head) | |||
158 | tmp->res = r; | 155 | tmp->res = r; |
159 | tmp->dev = dev; | 156 | tmp->dev = dev; |
160 | 157 | ||
161 | /* fallback is smallest one or list is empty*/ | 158 | /* Fallback is smallest one or list is empty */ |
162 | n = head; | 159 | n = head; |
163 | list_for_each_entry(dev_res, head, list) { | 160 | list_for_each_entry(dev_res, head, list) { |
164 | resource_size_t align; | 161 | resource_size_t align; |
@@ -171,21 +168,20 @@ static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head) | |||
171 | break; | 168 | break; |
172 | } | 169 | } |
173 | } | 170 | } |
174 | /* Insert it just before n*/ | 171 | /* Insert it just before n */ |
175 | list_add_tail(&tmp->list, n); | 172 | list_add_tail(&tmp->list, n); |
176 | } | 173 | } |
177 | } | 174 | } |
178 | 175 | ||
179 | static void __dev_sort_resources(struct pci_dev *dev, | 176 | static void __dev_sort_resources(struct pci_dev *dev, struct list_head *head) |
180 | struct list_head *head) | ||
181 | { | 177 | { |
182 | u16 class = dev->class >> 8; | 178 | u16 class = dev->class >> 8; |
183 | 179 | ||
184 | /* Don't touch classless devices or host bridges or ioapics. */ | 180 | /* Don't touch classless devices or host bridges or IOAPICs */ |
185 | if (class == PCI_CLASS_NOT_DEFINED || class == PCI_CLASS_BRIDGE_HOST) | 181 | if (class == PCI_CLASS_NOT_DEFINED || class == PCI_CLASS_BRIDGE_HOST) |
186 | return; | 182 | return; |
187 | 183 | ||
188 | /* Don't touch ioapic devices already enabled by firmware */ | 184 | /* Don't touch IOAPIC devices already enabled by firmware */ |
189 | if (class == PCI_CLASS_SYSTEM_PIC) { | 185 | if (class == PCI_CLASS_SYSTEM_PIC) { |
190 | u16 command; | 186 | u16 command; |
191 | pci_read_config_word(dev, PCI_COMMAND, &command); | 187 | pci_read_config_word(dev, PCI_COMMAND, &command); |
@@ -204,19 +200,18 @@ static inline void reset_resource(struct resource *res) | |||
204 | } | 200 | } |
205 | 201 | ||
206 | /** | 202 | /** |
207 | * reassign_resources_sorted() - satisfy any additional resource requests | 203 | * reassign_resources_sorted() - Satisfy any additional resource requests |
208 | * | 204 | * |
209 | * @realloc_head : head of the list tracking requests requiring additional | 205 | * @realloc_head: Head of the list tracking requests requiring |
210 | * resources | 206 | * additional resources |
211 | * @head : head of the list tracking requests with allocated | 207 | * @head: Head of the list tracking requests with allocated |
212 | * resources | 208 | * resources |
213 | * | 209 | * |
214 | * Walk through each element of the realloc_head and try to procure | 210 | * Walk through each element of the realloc_head and try to procure additional |
215 | * additional resources for the element, provided the element | 211 | * resources for the element, provided the element is in the head list. |
216 | * is in the head list. | ||
217 | */ | 212 | */ |
218 | static void reassign_resources_sorted(struct list_head *realloc_head, | 213 | static void reassign_resources_sorted(struct list_head *realloc_head, |
219 | struct list_head *head) | 214 | struct list_head *head) |
220 | { | 215 | { |
221 | struct resource *res; | 216 | struct resource *res; |
222 | struct pci_dev_resource *add_res, *tmp; | 217 | struct pci_dev_resource *add_res, *tmp; |
@@ -228,18 +223,18 @@ static void reassign_resources_sorted(struct list_head *realloc_head, | |||
228 | bool found_match = false; | 223 | bool found_match = false; |
229 | 224 | ||
230 | res = add_res->res; | 225 | res = add_res->res; |
231 | /* skip resource that has been reset */ | 226 | /* Skip resource that has been reset */ |
232 | if (!res->flags) | 227 | if (!res->flags) |
233 | goto out; | 228 | goto out; |
234 | 229 | ||
235 | /* skip this resource if not found in head list */ | 230 | /* Skip this resource if not found in head list */ |
236 | list_for_each_entry(dev_res, head, list) { | 231 | list_for_each_entry(dev_res, head, list) { |
237 | if (dev_res->res == res) { | 232 | if (dev_res->res == res) { |
238 | found_match = true; | 233 | found_match = true; |
239 | break; | 234 | break; |
240 | } | 235 | } |
241 | } | 236 | } |
242 | if (!found_match)/* just skip */ | 237 | if (!found_match) /* Just skip */ |
243 | continue; | 238 | continue; |
244 | 239 | ||
245 | idx = res - &add_res->dev->resource[0]; | 240 | idx = res - &add_res->dev->resource[0]; |
@@ -267,14 +262,14 @@ out: | |||
267 | } | 262 | } |
268 | 263 | ||
269 | /** | 264 | /** |
270 | * assign_requested_resources_sorted() - satisfy resource requests | 265 | * assign_requested_resources_sorted() - Satisfy resource requests |
271 | * | 266 | * |
272 | * @head : head of the list tracking requests for resources | 267 | * @head: Head of the list tracking requests for resources |
273 | * @fail_head : head of the list tracking requests that could | 268 | * @fail_head: Head of the list tracking requests that could not be |
274 | * not be allocated | 269 | * allocated |
275 | * | 270 | * |
276 | * Satisfy resource requests of each element in the list. Add | 271 | * Satisfy resource requests of each element in the list. Add requests that |
277 | * requests that could not satisfied to the failed_list. | 272 | * could not be satisfied to the failed_list. |
278 | */ | 273 | */ |
279 | static void assign_requested_resources_sorted(struct list_head *head, | 274 | static void assign_requested_resources_sorted(struct list_head *head, |
280 | struct list_head *fail_head) | 275 | struct list_head *fail_head) |
@@ -290,8 +285,9 @@ static void assign_requested_resources_sorted(struct list_head *head, | |||
290 | pci_assign_resource(dev_res->dev, idx)) { | 285 | pci_assign_resource(dev_res->dev, idx)) { |
291 | if (fail_head) { | 286 | if (fail_head) { |
292 | /* | 287 | /* |
293 | * if the failed res is for ROM BAR, and it will | 288 | * If the failed resource is a ROM BAR and |
294 | * be enabled later, don't add it to the list | 289 | * it will be enabled later, don't add it |
290 | * to the list. | ||
295 | */ | 291 | */ |
296 | if (!((idx == PCI_ROM_RESOURCE) && | 292 | if (!((idx == PCI_ROM_RESOURCE) && |
297 | (!(res->flags & IORESOURCE_ROM_ENABLE)))) | 293 | (!(res->flags & IORESOURCE_ROM_ENABLE)))) |
@@ -310,15 +306,14 @@ static unsigned long pci_fail_res_type_mask(struct list_head *fail_head) | |||
310 | struct pci_dev_resource *fail_res; | 306 | struct pci_dev_resource *fail_res; |
311 | unsigned long mask = 0; | 307 | unsigned long mask = 0; |
312 | 308 | ||
313 | /* check failed type */ | 309 | /* Check failed type */ |
314 | list_for_each_entry(fail_res, fail_head, list) | 310 | list_for_each_entry(fail_res, fail_head, list) |
315 | mask |= fail_res->flags; | 311 | mask |= fail_res->flags; |
316 | 312 | ||
317 | /* | 313 | /* |
318 | * one pref failed resource will set IORESOURCE_MEM, | 314 | * One pref failed resource will set IORESOURCE_MEM, as we can |
319 | * as we can allocate pref in non-pref range. | 315 | * allocate pref in non-pref range. Will release all assigned |
320 | * Will release all assigned non-pref sibling resources | 316 | * non-pref sibling resources according to that bit. |
321 | * according to that bit. | ||
322 | */ | 317 | */ |
323 | return mask & (IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH); | 318 | return mask & (IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH); |
324 | } | 319 | } |
@@ -328,11 +323,11 @@ static bool pci_need_to_release(unsigned long mask, struct resource *res) | |||
328 | if (res->flags & IORESOURCE_IO) | 323 | if (res->flags & IORESOURCE_IO) |
329 | return !!(mask & IORESOURCE_IO); | 324 | return !!(mask & IORESOURCE_IO); |
330 | 325 | ||
331 | /* check pref at first */ | 326 | /* Check pref at first */ |
332 | if (res->flags & IORESOURCE_PREFETCH) { | 327 | if (res->flags & IORESOURCE_PREFETCH) { |
333 | if (mask & IORESOURCE_PREFETCH) | 328 | if (mask & IORESOURCE_PREFETCH) |
334 | return true; | 329 | return true; |
335 | /* count pref if its parent is non-pref */ | 330 | /* Count pref if its parent is non-pref */ |
336 | else if ((mask & IORESOURCE_MEM) && | 331 | else if ((mask & IORESOURCE_MEM) && |
337 | !(res->parent->flags & IORESOURCE_PREFETCH)) | 332 | !(res->parent->flags & IORESOURCE_PREFETCH)) |
338 | return true; | 333 | return true; |
@@ -343,33 +338,33 @@ static bool pci_need_to_release(unsigned long mask, struct resource *res) | |||
343 | if (res->flags & IORESOURCE_MEM) | 338 | if (res->flags & IORESOURCE_MEM) |
344 | return !!(mask & IORESOURCE_MEM); | 339 | return !!(mask & IORESOURCE_MEM); |
345 | 340 | ||
346 | return false; /* should not get here */ | 341 | return false; /* Should not get here */ |
347 | } | 342 | } |
348 | 343 | ||
349 | static void __assign_resources_sorted(struct list_head *head, | 344 | static void __assign_resources_sorted(struct list_head *head, |
350 | struct list_head *realloc_head, | 345 | struct list_head *realloc_head, |
351 | struct list_head *fail_head) | 346 | struct list_head *fail_head) |
352 | { | 347 | { |
353 | /* | 348 | /* |
354 | * Should not assign requested resources at first. | 349 | * Should not assign requested resources at first. They could be |
355 | * they could be adjacent, so later reassign can not reallocate | 350 | * adjacent, so later reassign can not reallocate them one by one in |
356 | * them one by one in parent resource window. | 351 | * parent resource window. |
357 | * Try to assign requested + add_size at beginning | 352 | * |
358 | * if could do that, could get out early. | 353 | * Try to assign requested + add_size at beginning. If could do that, |
359 | * if could not do that, we still try to assign requested at first, | 354 | * could get out early. If could not do that, we still try to assign |
360 | * then try to reassign add_size for some resources. | 355 | * requested at first, then try to reassign add_size for some resources. |
361 | * | 356 | * |
362 | * Separate three resource type checking if we need to release | 357 | * Separate three resource type checking if we need to release |
363 | * assigned resource after requested + add_size try. | 358 | * assigned resource after requested + add_size try. |
364 | * 1. if there is io port assign fail, will release assigned | 359 | * |
365 | * io port. | 360 | * 1. If IO port assignment fails, will release assigned IO |
366 | * 2. if there is pref mmio assign fail, release assigned | 361 | * port. |
367 | * pref mmio. | 362 | * 2. If pref MMIO assignment fails, release assigned pref |
368 | * if assigned pref mmio's parent is non-pref mmio and there | 363 | * MMIO. If assigned pref MMIO's parent is non-pref MMIO |
369 | * is non-pref mmio assign fail, will release that assigned | 364 | * and non-pref MMIO assignment fails, will release that |
370 | * pref mmio. | 365 | * assigned pref MMIO. |
371 | * 3. if there is non-pref mmio assign fail or pref mmio | 366 | * 3. If non-pref MMIO assignment fails or pref MMIO |
372 | * assigned fail, will release assigned non-pref mmio. | 367 | * assignment fails, will release assigned non-pref MMIO. |
373 | */ | 368 | */ |
374 | LIST_HEAD(save_head); | 369 | LIST_HEAD(save_head); |
375 | LIST_HEAD(local_fail_head); | 370 | LIST_HEAD(local_fail_head); |
@@ -398,7 +393,7 @@ static void __assign_resources_sorted(struct list_head *head, | |||
398 | /* | 393 | /* |
399 | * There are two kinds of additional resources in the list: | 394 | * There are two kinds of additional resources in the list: |
400 | * 1. bridge resource -- IORESOURCE_STARTALIGN | 395 | * 1. bridge resource -- IORESOURCE_STARTALIGN |
401 | * 2. SR-IOV resource -- IORESOURCE_SIZEALIGN | 396 | * 2. SR-IOV resource -- IORESOURCE_SIZEALIGN |
402 | * Here just fix the additional alignment for bridge | 397 | * Here just fix the additional alignment for bridge |
403 | */ | 398 | */ |
404 | if (!(dev_res->res->flags & IORESOURCE_STARTALIGN)) | 399 | if (!(dev_res->res->flags & IORESOURCE_STARTALIGN)) |
@@ -407,10 +402,10 @@ static void __assign_resources_sorted(struct list_head *head, | |||
407 | add_align = get_res_add_align(realloc_head, dev_res->res); | 402 | add_align = get_res_add_align(realloc_head, dev_res->res); |
408 | 403 | ||
409 | /* | 404 | /* |
410 | * The "head" list is sorted by the alignment to make sure | 405 | * The "head" list is sorted by alignment so resources with |
411 | * resources with bigger alignment will be assigned first. | 406 | * bigger alignment will be assigned first. After we |
412 | * After we change the alignment of a dev_res in "head" list, | 407 | * change the alignment of a dev_res in "head" list, we |
413 | * we need to reorder the list by alignment to make it | 408 | * need to reorder the list by alignment to make it |
414 | * consistent. | 409 | * consistent. |
415 | */ | 410 | */ |
416 | if (add_align > dev_res->res->start) { | 411 | if (add_align > dev_res->res->start) { |
@@ -435,7 +430,7 @@ static void __assign_resources_sorted(struct list_head *head, | |||
435 | /* Try updated head list with add_size added */ | 430 | /* Try updated head list with add_size added */ |
436 | assign_requested_resources_sorted(head, &local_fail_head); | 431 | assign_requested_resources_sorted(head, &local_fail_head); |
437 | 432 | ||
438 | /* all assigned with add_size ? */ | 433 | /* All assigned with add_size? */ |
439 | if (list_empty(&local_fail_head)) { | 434 | if (list_empty(&local_fail_head)) { |
440 | /* Remove head list from realloc_head list */ | 435 | /* Remove head list from realloc_head list */ |
441 | list_for_each_entry(dev_res, head, list) | 436 | list_for_each_entry(dev_res, head, list) |
@@ -445,13 +440,13 @@ static void __assign_resources_sorted(struct list_head *head, | |||
445 | return; | 440 | return; |
446 | } | 441 | } |
447 | 442 | ||
448 | /* check failed type */ | 443 | /* Check failed type */ |
449 | fail_type = pci_fail_res_type_mask(&local_fail_head); | 444 | fail_type = pci_fail_res_type_mask(&local_fail_head); |
450 | /* remove not need to be released assigned res from head list etc */ | 445 | /* Remove not need to be released assigned res from head list etc */ |
451 | list_for_each_entry_safe(dev_res, tmp_res, head, list) | 446 | list_for_each_entry_safe(dev_res, tmp_res, head, list) |
452 | if (dev_res->res->parent && | 447 | if (dev_res->res->parent && |
453 | !pci_need_to_release(fail_type, dev_res->res)) { | 448 | !pci_need_to_release(fail_type, dev_res->res)) { |
454 | /* remove it from realloc_head list */ | 449 | /* Remove it from realloc_head list */ |
455 | remove_from_list(realloc_head, dev_res->res); | 450 | remove_from_list(realloc_head, dev_res->res); |
456 | remove_from_list(&save_head, dev_res->res); | 451 | remove_from_list(&save_head, dev_res->res); |
457 | list_del(&dev_res->list); | 452 | list_del(&dev_res->list); |
@@ -477,16 +472,15 @@ requested_and_reassign: | |||
477 | /* Satisfy the must-have resource requests */ | 472 | /* Satisfy the must-have resource requests */ |
478 | assign_requested_resources_sorted(head, fail_head); | 473 | assign_requested_resources_sorted(head, fail_head); |
479 | 474 | ||
480 | /* Try to satisfy any additional optional resource | 475 | /* Try to satisfy any additional optional resource requests */ |
481 | requests */ | ||
482 | if (realloc_head) | 476 | if (realloc_head) |
483 | reassign_resources_sorted(realloc_head, head); | 477 | reassign_resources_sorted(realloc_head, head); |
484 | free_list(head); | 478 | free_list(head); |
485 | } | 479 | } |
486 | 480 | ||
487 | static void pdev_assign_resources_sorted(struct pci_dev *dev, | 481 | static void pdev_assign_resources_sorted(struct pci_dev *dev, |
488 | struct list_head *add_head, | 482 | struct list_head *add_head, |
489 | struct list_head *fail_head) | 483 | struct list_head *fail_head) |
490 | { | 484 | { |
491 | LIST_HEAD(head); | 485 | LIST_HEAD(head); |
492 | 486 | ||
@@ -563,17 +557,19 @@ void pci_setup_cardbus(struct pci_bus *bus) | |||
563 | } | 557 | } |
564 | EXPORT_SYMBOL(pci_setup_cardbus); | 558 | EXPORT_SYMBOL(pci_setup_cardbus); |
565 | 559 | ||
566 | /* Initialize bridges with base/limit values we have collected. | 560 | /* |
567 | PCI-to-PCI Bridge Architecture Specification rev. 1.1 (1998) | 561 | * Initialize bridges with base/limit values we have collected. PCI-to-PCI |
568 | requires that if there is no I/O ports or memory behind the | 562 | * Bridge Architecture Specification rev. 1.1 (1998) requires that if there |
569 | bridge, corresponding range must be turned off by writing base | 563 | * are no I/O ports or memory behind the bridge, the corresponding range |
570 | value greater than limit to the bridge's base/limit registers. | 564 | * must be turned off by writing base value greater than limit to the |
571 | 565 | * bridge's base/limit registers. | |
572 | Note: care must be taken when updating I/O base/limit registers | 566 | * |
573 | of bridges which support 32-bit I/O. This update requires two | 567 | * Note: care must be taken when updating I/O base/limit registers of |
574 | config space writes, so it's quite possible that an I/O window of | 568 | * bridges which support 32-bit I/O. This update requires two config space |
575 | the bridge will have some undesirable address (e.g. 0) after the | 569 | * writes, so it's quite possible that an I/O window of the bridge will |
576 | first write. Ditto 64-bit prefetchable MMIO. */ | 570 | * have some undesirable address (e.g. 0) after the first write. Ditto |
571 | * 64-bit prefetchable MMIO. | ||
572 | */ | ||
577 | static void pci_setup_bridge_io(struct pci_dev *bridge) | 573 | static void pci_setup_bridge_io(struct pci_dev *bridge) |
578 | { | 574 | { |
579 | struct resource *res; | 575 | struct resource *res; |
@@ -587,7 +583,7 @@ static void pci_setup_bridge_io(struct pci_dev *bridge) | |||
587 | if (bridge->io_window_1k) | 583 | if (bridge->io_window_1k) |
588 | io_mask = PCI_IO_1K_RANGE_MASK; | 584 | io_mask = PCI_IO_1K_RANGE_MASK; |
589 | 585 | ||
590 | /* Set up the top and bottom of the PCI I/O segment for this bus. */ | 586 | /* Set up the top and bottom of the PCI I/O segment for this bus */ |
591 | res = &bridge->resource[PCI_BRIDGE_RESOURCES + 0]; | 587 | res = &bridge->resource[PCI_BRIDGE_RESOURCES + 0]; |
592 | pcibios_resource_to_bus(bridge->bus, ®ion, res); | 588 | pcibios_resource_to_bus(bridge->bus, ®ion, res); |
593 | if (res->flags & IORESOURCE_IO) { | 589 | if (res->flags & IORESOURCE_IO) { |
@@ -595,19 +591,19 @@ static void pci_setup_bridge_io(struct pci_dev *bridge) | |||
595 | io_base_lo = (region.start >> 8) & io_mask; | 591 | io_base_lo = (region.start >> 8) & io_mask; |
596 | io_limit_lo = (region.end >> 8) & io_mask; | 592 | io_limit_lo = (region.end >> 8) & io_mask; |
597 | l = ((u16) io_limit_lo << 8) | io_base_lo; | 593 | l = ((u16) io_limit_lo << 8) | io_base_lo; |
598 | /* Set up upper 16 bits of I/O base/limit. */ | 594 | /* Set up upper 16 bits of I/O base/limit */ |
599 | io_upper16 = (region.end & 0xffff0000) | (region.start >> 16); | 595 | io_upper16 = (region.end & 0xffff0000) | (region.start >> 16); |
600 | pci_info(bridge, " bridge window %pR\n", res); | 596 | pci_info(bridge, " bridge window %pR\n", res); |
601 | } else { | 597 | } else { |
602 | /* Clear upper 16 bits of I/O base/limit. */ | 598 | /* Clear upper 16 bits of I/O base/limit */ |
603 | io_upper16 = 0; | 599 | io_upper16 = 0; |
604 | l = 0x00f0; | 600 | l = 0x00f0; |
605 | } | 601 | } |
606 | /* Temporarily disable the I/O range before updating PCI_IO_BASE. */ | 602 | /* Temporarily disable the I/O range before updating PCI_IO_BASE */ |
607 | pci_write_config_dword(bridge, PCI_IO_BASE_UPPER16, 0x0000ffff); | 603 | pci_write_config_dword(bridge, PCI_IO_BASE_UPPER16, 0x0000ffff); |
608 | /* Update lower 16 bits of I/O base/limit. */ | 604 | /* Update lower 16 bits of I/O base/limit */ |
609 | pci_write_config_word(bridge, PCI_IO_BASE, l); | 605 | pci_write_config_word(bridge, PCI_IO_BASE, l); |
610 | /* Update upper 16 bits of I/O base/limit. */ | 606 | /* Update upper 16 bits of I/O base/limit */ |
611 | pci_write_config_dword(bridge, PCI_IO_BASE_UPPER16, io_upper16); | 607 | pci_write_config_dword(bridge, PCI_IO_BASE_UPPER16, io_upper16); |
612 | } | 608 | } |
613 | 609 | ||
@@ -617,7 +613,7 @@ static void pci_setup_bridge_mmio(struct pci_dev *bridge) | |||
617 | struct pci_bus_region region; | 613 | struct pci_bus_region region; |
618 | u32 l; | 614 | u32 l; |
619 | 615 | ||
620 | /* Set up the top and bottom of the PCI Memory segment for this bus. */ | 616 | /* Set up the top and bottom of the PCI Memory segment for this bus */ |
621 | res = &bridge->resource[PCI_BRIDGE_RESOURCES + 1]; | 617 | res = &bridge->resource[PCI_BRIDGE_RESOURCES + 1]; |
622 | pcibios_resource_to_bus(bridge->bus, ®ion, res); | 618 | pcibios_resource_to_bus(bridge->bus, ®ion, res); |
623 | if (res->flags & IORESOURCE_MEM) { | 619 | if (res->flags & IORESOURCE_MEM) { |
@@ -636,12 +632,14 @@ static void pci_setup_bridge_mmio_pref(struct pci_dev *bridge) | |||
636 | struct pci_bus_region region; | 632 | struct pci_bus_region region; |
637 | u32 l, bu, lu; | 633 | u32 l, bu, lu; |
638 | 634 | ||
639 | /* Clear out the upper 32 bits of PREF limit. | 635 | /* |
640 | If PCI_PREF_BASE_UPPER32 was non-zero, this temporarily | 636 | * Clear out the upper 32 bits of PREF limit. If |
641 | disables PREF range, which is ok. */ | 637 | * PCI_PREF_BASE_UPPER32 was non-zero, this temporarily disables |
638 | * PREF range, which is ok. | ||
639 | */ | ||
642 | pci_write_config_dword(bridge, PCI_PREF_LIMIT_UPPER32, 0); | 640 | pci_write_config_dword(bridge, PCI_PREF_LIMIT_UPPER32, 0); |
643 | 641 | ||
644 | /* Set up PREF base/limit. */ | 642 | /* Set up PREF base/limit */ |
645 | bu = lu = 0; | 643 | bu = lu = 0; |
646 | res = &bridge->resource[PCI_BRIDGE_RESOURCES + 2]; | 644 | res = &bridge->resource[PCI_BRIDGE_RESOURCES + 2]; |
647 | pcibios_resource_to_bus(bridge->bus, ®ion, res); | 645 | pcibios_resource_to_bus(bridge->bus, ®ion, res); |
@@ -658,7 +656,7 @@ static void pci_setup_bridge_mmio_pref(struct pci_dev *bridge) | |||
658 | } | 656 | } |
659 | pci_write_config_dword(bridge, PCI_PREF_MEMORY_BASE, l); | 657 | pci_write_config_dword(bridge, PCI_PREF_MEMORY_BASE, l); |
660 | 658 | ||
661 | /* Set the upper 32 bits of PREF base & limit. */ | 659 | /* Set the upper 32 bits of PREF base & limit */ |
662 | pci_write_config_dword(bridge, PCI_PREF_BASE_UPPER32, bu); | 660 | pci_write_config_dword(bridge, PCI_PREF_BASE_UPPER32, bu); |
663 | pci_write_config_dword(bridge, PCI_PREF_LIMIT_UPPER32, lu); | 661 | pci_write_config_dword(bridge, PCI_PREF_LIMIT_UPPER32, lu); |
664 | } | 662 | } |
@@ -702,13 +700,13 @@ int pci_claim_bridge_resource(struct pci_dev *bridge, int i) | |||
702 | return 0; | 700 | return 0; |
703 | 701 | ||
704 | if (pci_claim_resource(bridge, i) == 0) | 702 | if (pci_claim_resource(bridge, i) == 0) |
705 | return 0; /* claimed the window */ | 703 | return 0; /* Claimed the window */ |
706 | 704 | ||
707 | if ((bridge->class >> 8) != PCI_CLASS_BRIDGE_PCI) | 705 | if ((bridge->class >> 8) != PCI_CLASS_BRIDGE_PCI) |
708 | return 0; | 706 | return 0; |
709 | 707 | ||
710 | if (!pci_bus_clip_resource(bridge, i)) | 708 | if (!pci_bus_clip_resource(bridge, i)) |
711 | return -EINVAL; /* clipping didn't change anything */ | 709 | return -EINVAL; /* Clipping didn't change anything */ |
712 | 710 | ||
713 | switch (i - PCI_BRIDGE_RESOURCES) { | 711 | switch (i - PCI_BRIDGE_RESOURCES) { |
714 | case 0: | 712 | case 0: |
@@ -725,14 +723,16 @@ int pci_claim_bridge_resource(struct pci_dev *bridge, int i) | |||
725 | } | 723 | } |
726 | 724 | ||
727 | if (pci_claim_resource(bridge, i) == 0) | 725 | if (pci_claim_resource(bridge, i) == 0) |
728 | return 0; /* claimed a smaller window */ | 726 | return 0; /* Claimed a smaller window */ |
729 | 727 | ||
730 | return -EINVAL; | 728 | return -EINVAL; |
731 | } | 729 | } |
732 | 730 | ||
733 | /* Check whether the bridge supports optional I/O and | 731 | /* |
734 | prefetchable memory ranges. If not, the respective | 732 | * Check whether the bridge supports optional I/O and prefetchable memory |
735 | base/limit registers must be read-only and read as 0. */ | 733 | * ranges. If not, the respective base/limit registers must be read-only |
734 | * and read as 0. | ||
735 | */ | ||
736 | static void pci_bridge_check_ranges(struct pci_bus *bus) | 736 | static void pci_bridge_check_ranges(struct pci_bus *bus) |
737 | { | 737 | { |
738 | struct pci_dev *bridge = bus->self; | 738 | struct pci_dev *bridge = bus->self; |
@@ -752,12 +752,14 @@ static void pci_bridge_check_ranges(struct pci_bus *bus) | |||
752 | } | 752 | } |
753 | } | 753 | } |
754 | 754 | ||
755 | /* Helper function for sizing routines: find first available | 755 | /* |
756 | bus resource of a given type. Note: we intentionally skip | 756 | * Helper function for sizing routines: find first available bus resource |
757 | the bus resources which have already been assigned (that is, | 757 | * of a given type. Note: we intentionally skip the bus resources which |
758 | have non-NULL parent resource). */ | 758 | * have already been assigned (that is, have non-NULL parent resource). |
759 | */ | ||
759 | static struct resource *find_free_bus_resource(struct pci_bus *bus, | 760 | static struct resource *find_free_bus_resource(struct pci_bus *bus, |
760 | unsigned long type_mask, unsigned long type) | 761 | unsigned long type_mask, |
762 | unsigned long type) | ||
761 | { | 763 | { |
762 | int i; | 764 | int i; |
763 | struct resource *r; | 765 | struct resource *r; |
@@ -772,19 +774,21 @@ static struct resource *find_free_bus_resource(struct pci_bus *bus, | |||
772 | } | 774 | } |
773 | 775 | ||
774 | static resource_size_t calculate_iosize(resource_size_t size, | 776 | static resource_size_t calculate_iosize(resource_size_t size, |
775 | resource_size_t min_size, | 777 | resource_size_t min_size, |
776 | resource_size_t size1, | 778 | resource_size_t size1, |
777 | resource_size_t add_size, | 779 | resource_size_t add_size, |
778 | resource_size_t children_add_size, | 780 | resource_size_t children_add_size, |
779 | resource_size_t old_size, | 781 | resource_size_t old_size, |
780 | resource_size_t align) | 782 | resource_size_t align) |
781 | { | 783 | { |
782 | if (size < min_size) | 784 | if (size < min_size) |
783 | size = min_size; | 785 | size = min_size; |
784 | if (old_size == 1) | 786 | if (old_size == 1) |
785 | old_size = 0; | 787 | old_size = 0; |
786 | /* To be fixed in 2.5: we should have sort of HAVE_ISA | 788 | /* |
787 | flag in the struct pci_bus. */ | 789 | * To be fixed in 2.5: we should have sort of HAVE_ISA flag in the |
790 | * struct pci_bus. | ||
791 | */ | ||
788 | #if defined(CONFIG_ISA) || defined(CONFIG_EISA) | 792 | #if defined(CONFIG_ISA) || defined(CONFIG_EISA) |
789 | size = (size & 0xff) + ((size & ~0xffUL) << 2); | 793 | size = (size & 0xff) + ((size & ~0xffUL) << 2); |
790 | #endif | 794 | #endif |
@@ -797,11 +801,11 @@ static resource_size_t calculate_iosize(resource_size_t size, | |||
797 | } | 801 | } |
798 | 802 | ||
799 | static resource_size_t calculate_memsize(resource_size_t size, | 803 | static resource_size_t calculate_memsize(resource_size_t size, |
800 | resource_size_t min_size, | 804 | resource_size_t min_size, |
801 | resource_size_t add_size, | 805 | resource_size_t add_size, |
802 | resource_size_t children_add_size, | 806 | resource_size_t children_add_size, |
803 | resource_size_t old_size, | 807 | resource_size_t old_size, |
804 | resource_size_t align) | 808 | resource_size_t align) |
805 | { | 809 | { |
806 | if (size < min_size) | 810 | if (size < min_size) |
807 | size = min_size; | 811 | size = min_size; |
@@ -824,8 +828,7 @@ resource_size_t __weak pcibios_window_alignment(struct pci_bus *bus, | |||
824 | #define PCI_P2P_DEFAULT_IO_ALIGN 0x1000 /* 4KiB */ | 828 | #define PCI_P2P_DEFAULT_IO_ALIGN 0x1000 /* 4KiB */ |
825 | #define PCI_P2P_DEFAULT_IO_ALIGN_1K 0x400 /* 1KiB */ | 829 | #define PCI_P2P_DEFAULT_IO_ALIGN_1K 0x400 /* 1KiB */ |
826 | 830 | ||
827 | static resource_size_t window_alignment(struct pci_bus *bus, | 831 | static resource_size_t window_alignment(struct pci_bus *bus, unsigned long type) |
828 | unsigned long type) | ||
829 | { | 832 | { |
830 | resource_size_t align = 1, arch_align; | 833 | resource_size_t align = 1, arch_align; |
831 | 834 | ||
@@ -833,8 +836,8 @@ static resource_size_t window_alignment(struct pci_bus *bus, | |||
833 | align = PCI_P2P_DEFAULT_MEM_ALIGN; | 836 | align = PCI_P2P_DEFAULT_MEM_ALIGN; |
834 | else if (type & IORESOURCE_IO) { | 837 | else if (type & IORESOURCE_IO) { |
835 | /* | 838 | /* |
836 | * Per spec, I/O windows are 4K-aligned, but some | 839 | * Per spec, I/O windows are 4K-aligned, but some bridges have |
837 | * bridges have an extension to support 1K alignment. | 840 | * an extension to support 1K alignment. |
838 | */ | 841 | */ |
839 | if (bus->self->io_window_1k) | 842 | if (bus->self->io_window_1k) |
840 | align = PCI_P2P_DEFAULT_IO_ALIGN_1K; | 843 | align = PCI_P2P_DEFAULT_IO_ALIGN_1K; |
@@ -847,20 +850,21 @@ static resource_size_t window_alignment(struct pci_bus *bus, | |||
847 | } | 850 | } |
848 | 851 | ||
849 | /** | 852 | /** |
850 | * pbus_size_io() - size the io window of a given bus | 853 | * pbus_size_io() - Size the I/O window of a given bus |
851 | * | 854 | * |
852 | * @bus : the bus | 855 | * @bus: The bus |
853 | * @min_size : the minimum io window that must to be allocated | 856 | * @min_size: The minimum I/O window that must be allocated |
854 | * @add_size : additional optional io window | 857 | * @add_size: Additional optional I/O window |
855 | * @realloc_head : track the additional io window on this list | 858 | * @realloc_head: Track the additional I/O window on this list |
856 | * | 859 | * |
857 | * Sizing the IO windows of the PCI-PCI bridge is trivial, | 860 | * Sizing the I/O windows of the PCI-PCI bridge is trivial, since these |
858 | * since these windows have 1K or 4K granularity and the IO ranges | 861 | * windows have 1K or 4K granularity and the I/O ranges of non-bridge PCI |
859 | * of non-bridge PCI devices are limited to 256 bytes. | 862 | * devices are limited to 256 bytes. We must be careful with the ISA |
860 | * We must be careful with the ISA aliasing though. | 863 | * aliasing though. |
861 | */ | 864 | */ |
862 | static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size, | 865 | static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size, |
863 | resource_size_t add_size, struct list_head *realloc_head) | 866 | resource_size_t add_size, |
867 | struct list_head *realloc_head) | ||
864 | { | 868 | { |
865 | struct pci_dev *dev; | 869 | struct pci_dev *dev; |
866 | struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO, | 870 | struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO, |
@@ -947,33 +951,33 @@ static inline resource_size_t calculate_mem_align(resource_size_t *aligns, | |||
947 | } | 951 | } |
948 | 952 | ||
949 | /** | 953 | /** |
950 | * pbus_size_mem() - size the memory window of a given bus | 954 | * pbus_size_mem() - Size the memory window of a given bus |
951 | * | 955 | * |
952 | * @bus : the bus | 956 | * @bus: The bus |
953 | * @mask: mask the resource flag, then compare it with type | 957 | * @mask: Mask the resource flag, then compare it with type |
954 | * @type: the type of free resource from bridge | 958 | * @type: The type of free resource from bridge |
955 | * @type2: second match type | 959 | * @type2: Second match type |
956 | * @type3: third match type | 960 | * @type3: Third match type |
957 | * @min_size : the minimum memory window that must to be allocated | 961 | * @min_size: The minimum memory window that must be allocated |
958 | * @add_size : additional optional memory window | 962 | * @add_size: Additional optional memory window |
959 | * @realloc_head : track the additional memory window on this list | 963 | * @realloc_head: Track the additional memory window on this list |
960 | * | 964 | * |
961 | * Calculate the size of the bus and minimal alignment which | 965 | * Calculate the size of the bus and minimal alignment which guarantees |
962 | * guarantees that all child resources fit in this size. | 966 | * that all child resources fit in this size. |
963 | * | 967 | * |
964 | * Returns -ENOSPC if there's no available bus resource of the desired type. | 968 | * Return -ENOSPC if there's no available bus resource of the desired |
965 | * Otherwise, sets the bus resource start/end to indicate the required | 969 | * type. Otherwise, set the bus resource start/end to indicate the |
966 | * size, adds things to realloc_head (if supplied), and returns 0. | 970 | * required size, add things to realloc_head (if supplied), and return 0. |
967 | */ | 971 | */ |
968 | static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, | 972 | static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, |
969 | unsigned long type, unsigned long type2, | 973 | unsigned long type, unsigned long type2, |
970 | unsigned long type3, | 974 | unsigned long type3, resource_size_t min_size, |
971 | resource_size_t min_size, resource_size_t add_size, | 975 | resource_size_t add_size, |
972 | struct list_head *realloc_head) | 976 | struct list_head *realloc_head) |
973 | { | 977 | { |
974 | struct pci_dev *dev; | 978 | struct pci_dev *dev; |
975 | resource_size_t min_align, align, size, size0, size1; | 979 | resource_size_t min_align, align, size, size0, size1; |
976 | resource_size_t aligns[18]; /* Alignments from 1Mb to 128Gb */ | 980 | resource_size_t aligns[18]; /* Alignments from 1MB to 128GB */ |
977 | int order, max_order; | 981 | int order, max_order; |
978 | struct resource *b_res = find_free_bus_resource(bus, | 982 | struct resource *b_res = find_free_bus_resource(bus, |
979 | mask | IORESOURCE_PREFETCH, type); | 983 | mask | IORESOURCE_PREFETCH, type); |
@@ -1002,12 +1006,12 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, | |||
1002 | continue; | 1006 | continue; |
1003 | r_size = resource_size(r); | 1007 | r_size = resource_size(r); |
1004 | #ifdef CONFIG_PCI_IOV | 1008 | #ifdef CONFIG_PCI_IOV |
1005 | /* put SRIOV requested res to the optional list */ | 1009 | /* Put SRIOV requested res to the optional list */ |
1006 | if (realloc_head && i >= PCI_IOV_RESOURCES && | 1010 | if (realloc_head && i >= PCI_IOV_RESOURCES && |
1007 | i <= PCI_IOV_RESOURCE_END) { | 1011 | i <= PCI_IOV_RESOURCE_END) { |
1008 | add_align = max(pci_resource_alignment(dev, r), add_align); | 1012 | add_align = max(pci_resource_alignment(dev, r), add_align); |
1009 | r->end = r->start - 1; | 1013 | r->end = r->start - 1; |
1010 | add_to_list(realloc_head, dev, r, r_size, 0/* don't care */); | 1014 | add_to_list(realloc_head, dev, r, r_size, 0 /* Don't care */); |
1011 | children_add_size += r_size; | 1015 | children_add_size += r_size; |
1012 | continue; | 1016 | continue; |
1013 | } | 1017 | } |
@@ -1029,8 +1033,10 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, | |||
1029 | continue; | 1033 | continue; |
1030 | } | 1034 | } |
1031 | size += max(r_size, align); | 1035 | size += max(r_size, align); |
1032 | /* Exclude ranges with size > align from | 1036 | /* |
1033 | calculation of the alignment. */ | 1037 | * Exclude ranges with size > align from calculation of |
1038 | * the alignment. | ||
1039 | */ | ||
1034 | if (r_size <= align) | 1040 | if (r_size <= align) |
1035 | aligns[order] += align; | 1041 | aligns[order] += align; |
1036 | if (order > max_order) | 1042 | if (order > max_order) |
@@ -1081,7 +1087,7 @@ unsigned long pci_cardbus_resource_alignment(struct resource *res) | |||
1081 | } | 1087 | } |
1082 | 1088 | ||
1083 | static void pci_bus_size_cardbus(struct pci_bus *bus, | 1089 | static void pci_bus_size_cardbus(struct pci_bus *bus, |
1084 | struct list_head *realloc_head) | 1090 | struct list_head *realloc_head) |
1085 | { | 1091 | { |
1086 | struct pci_dev *bridge = bus->self; | 1092 | struct pci_dev *bridge = bus->self; |
1087 | struct resource *b_res = &bridge->resource[PCI_BRIDGE_RESOURCES]; | 1093 | struct resource *b_res = &bridge->resource[PCI_BRIDGE_RESOURCES]; |
@@ -1091,8 +1097,8 @@ static void pci_bus_size_cardbus(struct pci_bus *bus, | |||
1091 | if (b_res[0].parent) | 1097 | if (b_res[0].parent) |
1092 | goto handle_b_res_1; | 1098 | goto handle_b_res_1; |
1093 | /* | 1099 | /* |
1094 | * Reserve some resources for CardBus. We reserve | 1100 | * Reserve some resources for CardBus. We reserve a fixed amount |
1095 | * a fixed amount of bus space for CardBus bridges. | 1101 | * of bus space for CardBus bridges. |
1096 | */ | 1102 | */ |
1097 | b_res[0].start = pci_cardbus_io_size; | 1103 | b_res[0].start = pci_cardbus_io_size; |
1098 | b_res[0].end = b_res[0].start + pci_cardbus_io_size - 1; | 1104 | b_res[0].end = b_res[0].start + pci_cardbus_io_size - 1; |
@@ -1116,7 +1122,7 @@ handle_b_res_1: | |||
1116 | } | 1122 | } |
1117 | 1123 | ||
1118 | handle_b_res_2: | 1124 | handle_b_res_2: |
1119 | /* MEM1 must not be pref mmio */ | 1125 | /* MEM1 must not be pref MMIO */ |
1120 | pci_read_config_word(bridge, PCI_CB_BRIDGE_CONTROL, &ctrl); | 1126 | pci_read_config_word(bridge, PCI_CB_BRIDGE_CONTROL, &ctrl); |
1121 | if (ctrl & PCI_CB_BRIDGE_CTL_PREFETCH_MEM1) { | 1127 | if (ctrl & PCI_CB_BRIDGE_CTL_PREFETCH_MEM1) { |
1122 | ctrl &= ~PCI_CB_BRIDGE_CTL_PREFETCH_MEM1; | 1128 | ctrl &= ~PCI_CB_BRIDGE_CTL_PREFETCH_MEM1; |
@@ -1124,10 +1130,7 @@ handle_b_res_2: | |||
1124 | pci_read_config_word(bridge, PCI_CB_BRIDGE_CONTROL, &ctrl); | 1130 | pci_read_config_word(bridge, PCI_CB_BRIDGE_CONTROL, &ctrl); |
1125 | } | 1131 | } |
1126 | 1132 | ||
1127 | /* | 1133 | /* Check whether prefetchable memory is supported by this bridge. */ |
1128 | * Check whether prefetchable memory is supported | ||
1129 | * by this bridge. | ||
1130 | */ | ||
1131 | pci_read_config_word(bridge, PCI_CB_BRIDGE_CONTROL, &ctrl); | 1134 | pci_read_config_word(bridge, PCI_CB_BRIDGE_CONTROL, &ctrl); |
1132 | if (!(ctrl & PCI_CB_BRIDGE_CTL_PREFETCH_MEM0)) { | 1135 | if (!(ctrl & PCI_CB_BRIDGE_CTL_PREFETCH_MEM0)) { |
1133 | ctrl |= PCI_CB_BRIDGE_CTL_PREFETCH_MEM0; | 1136 | ctrl |= PCI_CB_BRIDGE_CTL_PREFETCH_MEM0; |
@@ -1138,9 +1141,8 @@ handle_b_res_2: | |||
1138 | if (b_res[2].parent) | 1141 | if (b_res[2].parent) |
1139 | goto handle_b_res_3; | 1142 | goto handle_b_res_3; |
1140 | /* | 1143 | /* |
1141 | * If we have prefetchable memory support, allocate | 1144 | * If we have prefetchable memory support, allocate two regions. |
1142 | * two regions. Otherwise, allocate one region of | 1145 | * Otherwise, allocate one region of twice the size. |
1143 | * twice the size. | ||
1144 | */ | 1146 | */ |
1145 | if (ctrl & PCI_CB_BRIDGE_CTL_PREFETCH_MEM0) { | 1147 | if (ctrl & PCI_CB_BRIDGE_CTL_PREFETCH_MEM0) { |
1146 | b_res[2].start = pci_cardbus_mem_size; | 1148 | b_res[2].start = pci_cardbus_mem_size; |
@@ -1153,7 +1155,7 @@ handle_b_res_2: | |||
1153 | pci_cardbus_mem_size, pci_cardbus_mem_size); | 1155 | pci_cardbus_mem_size, pci_cardbus_mem_size); |
1154 | } | 1156 | } |
1155 | 1157 | ||
1156 | /* reduce that to half */ | 1158 | /* Reduce that to half */ |
1157 | b_res_3_size = pci_cardbus_mem_size; | 1159 | b_res_3_size = pci_cardbus_mem_size; |
1158 | } | 1160 | } |
1159 | 1161 | ||
@@ -1204,7 +1206,7 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head) | |||
1204 | 1206 | ||
1205 | switch (bus->self->hdr_type) { | 1207 | switch (bus->self->hdr_type) { |
1206 | case PCI_HEADER_TYPE_CARDBUS: | 1208 | case PCI_HEADER_TYPE_CARDBUS: |
1207 | /* don't size cardbuses yet. */ | 1209 | /* Don't size CardBuses yet */ |
1208 | break; | 1210 | break; |
1209 | 1211 | ||
1210 | case PCI_HEADER_TYPE_BRIDGE: | 1212 | case PCI_HEADER_TYPE_BRIDGE: |
@@ -1271,18 +1273,17 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head) | |||
1271 | 1273 | ||
1272 | /* | 1274 | /* |
1273 | * Compute the size required to put everything else in the | 1275 | * Compute the size required to put everything else in the |
1274 | * non-prefetchable window. This includes: | 1276 | * non-prefetchable window. This includes: |
1275 | * | 1277 | * |
1276 | * - all non-prefetchable resources | 1278 | * - all non-prefetchable resources |
1277 | * - 32-bit prefetchable resources if there's a 64-bit | 1279 | * - 32-bit prefetchable resources if there's a 64-bit |
1278 | * prefetchable window or no prefetchable window at all | 1280 | * prefetchable window or no prefetchable window at all |
1279 | * - 64-bit prefetchable resources if there's no | 1281 | * - 64-bit prefetchable resources if there's no prefetchable |
1280 | * prefetchable window at all | 1282 | * window at all |
1281 | * | 1283 | * |
1282 | * Note that the strategy in __pci_assign_resource() must | 1284 | * Note that the strategy in __pci_assign_resource() must match |
1283 | * match that used here. Specifically, we cannot put a | 1285 | * that used here. Specifically, we cannot put a 32-bit |
1284 | * 32-bit prefetchable resource in a 64-bit prefetchable | 1286 | * prefetchable resource in a 64-bit prefetchable window. |
1285 | * window. | ||
1286 | */ | 1287 | */ |
1287 | pbus_size_mem(bus, mask, IORESOURCE_MEM, type2, type3, | 1288 | pbus_size_mem(bus, mask, IORESOURCE_MEM, type2, type3, |
1288 | realloc_head ? 0 : additional_mem_size, | 1289 | realloc_head ? 0 : additional_mem_size, |
@@ -1315,8 +1316,8 @@ static void assign_fixed_resource_on_bus(struct pci_bus *b, struct resource *r) | |||
1315 | } | 1316 | } |
1316 | 1317 | ||
1317 | /* | 1318 | /* |
1318 | * Try to assign any resources marked as IORESOURCE_PCI_FIXED, as they | 1319 | * Try to assign any resources marked as IORESOURCE_PCI_FIXED, as they are |
1319 | * are skipped by pbus_assign_resources_sorted(). | 1320 | * skipped by pbus_assign_resources_sorted(). |
1320 | */ | 1321 | */ |
1321 | static void pdev_assign_fixed_resources(struct pci_dev *dev) | 1322 | static void pdev_assign_fixed_resources(struct pci_dev *dev) |
1322 | { | 1323 | { |
@@ -1427,10 +1428,9 @@ static void pci_bus_allocate_resources(struct pci_bus *b) | |||
1427 | struct pci_bus *child; | 1428 | struct pci_bus *child; |
1428 | 1429 | ||
1429 | /* | 1430 | /* |
1430 | * Carry out a depth-first search on the PCI bus | 1431 | * Carry out a depth-first search on the PCI bus tree to allocate |
1431 | * tree to allocate bridge apertures. Read the | 1432 | * bridge apertures. Read the programmed bridge bases and |
1432 | * programmed bridge bases and recursively claim | 1433 | * recursively claim the respective bridge resources. |
1433 | * the respective bridge resources. | ||
1434 | */ | 1434 | */ |
1435 | if (b->self) { | 1435 | if (b->self) { |
1436 | pci_read_bridge_bases(b); | 1436 | pci_read_bridge_bases(b); |
@@ -1484,7 +1484,7 @@ static void __pci_bridge_assign_resources(const struct pci_dev *bridge, | |||
1484 | IORESOURCE_MEM_64) | 1484 | IORESOURCE_MEM_64) |
1485 | 1485 | ||
1486 | static void pci_bridge_release_resources(struct pci_bus *bus, | 1486 | static void pci_bridge_release_resources(struct pci_bus *bus, |
1487 | unsigned long type) | 1487 | unsigned long type) |
1488 | { | 1488 | { |
1489 | struct pci_dev *dev = bus->self; | 1489 | struct pci_dev *dev = bus->self; |
1490 | struct resource *r; | 1490 | struct resource *r; |
@@ -1495,16 +1495,14 @@ static void pci_bridge_release_resources(struct pci_bus *bus, | |||
1495 | b_res = &dev->resource[PCI_BRIDGE_RESOURCES]; | 1495 | b_res = &dev->resource[PCI_BRIDGE_RESOURCES]; |
1496 | 1496 | ||
1497 | /* | 1497 | /* |
1498 | * 1. if there is io port assign fail, will release bridge | 1498 | * 1. If IO port assignment fails, release bridge IO port. |
1499 | * io port. | 1499 | * 2. If non pref MMIO assignment fails, release bridge nonpref MMIO. |
1500 | * 2. if there is non pref mmio assign fail, release bridge | 1500 | * 3. If 64bit pref MMIO assignment fails, and bridge pref is 64bit, |
1501 | * nonpref mmio. | 1501 | * release bridge pref MMIO. |
1502 | * 3. if there is 64bit pref mmio assign fail, and bridge pref | 1502 | * 4. If pref MMIO assignment fails, and bridge pref is 32bit, |
1503 | * is 64bit, release bridge pref mmio. | 1503 | * release bridge pref MMIO. |
1504 | * 4. if there is pref mmio assign fail, and bridge pref is | 1504 | * 5. If pref MMIO assignment fails, and bridge pref is not |
1505 | * 32bit mmio, release bridge pref mmio | 1505 | * assigned, release bridge nonpref MMIO. |
1506 | * 5. if there is pref mmio assign fail, and bridge pref is not | ||
1507 | * assigned, release bridge nonpref mmio. | ||
1508 | */ | 1506 | */ |
1509 | if (type & IORESOURCE_IO) | 1507 | if (type & IORESOURCE_IO) |
1510 | idx = 0; | 1508 | idx = 0; |
@@ -1524,25 +1522,22 @@ static void pci_bridge_release_resources(struct pci_bus *bus, | |||
1524 | if (!r->parent) | 1522 | if (!r->parent) |
1525 | return; | 1523 | return; |
1526 | 1524 | ||
1527 | /* | 1525 | /* If there are children, release them all */ |
1528 | * if there are children under that, we should release them | ||
1529 | * all | ||
1530 | */ | ||
1531 | release_child_resources(r); | 1526 | release_child_resources(r); |
1532 | if (!release_resource(r)) { | 1527 | if (!release_resource(r)) { |
1533 | type = old_flags = r->flags & PCI_RES_TYPE_MASK; | 1528 | type = old_flags = r->flags & PCI_RES_TYPE_MASK; |
1534 | pci_printk(KERN_DEBUG, dev, "resource %d %pR released\n", | 1529 | pci_printk(KERN_DEBUG, dev, "resource %d %pR released\n", |
1535 | PCI_BRIDGE_RESOURCES + idx, r); | 1530 | PCI_BRIDGE_RESOURCES + idx, r); |
1536 | /* keep the old size */ | 1531 | /* Keep the old size */ |
1537 | r->end = resource_size(r) - 1; | 1532 | r->end = resource_size(r) - 1; |
1538 | r->start = 0; | 1533 | r->start = 0; |
1539 | r->flags = 0; | 1534 | r->flags = 0; |
1540 | 1535 | ||
1541 | /* avoiding touch the one without PREF */ | 1536 | /* Avoiding touch the one without PREF */ |
1542 | if (type & IORESOURCE_PREFETCH) | 1537 | if (type & IORESOURCE_PREFETCH) |
1543 | type = IORESOURCE_PREFETCH; | 1538 | type = IORESOURCE_PREFETCH; |
1544 | __pci_setup_bridge(bus, type); | 1539 | __pci_setup_bridge(bus, type); |
1545 | /* for next child res under same bridge */ | 1540 | /* For next child res under same bridge */ |
1546 | r->flags = old_flags; | 1541 | r->flags = old_flags; |
1547 | } | 1542 | } |
1548 | } | 1543 | } |
@@ -1551,9 +1546,10 @@ enum release_type { | |||
1551 | leaf_only, | 1546 | leaf_only, |
1552 | whole_subtree, | 1547 | whole_subtree, |
1553 | }; | 1548 | }; |
1549 | |||
1554 | /* | 1550 | /* |
1555 | * try to release pci bridge resources that is from leaf bridge, | 1551 | * Try to release PCI bridge resources from leaf bridge, so we can allocate |
1556 | * so we can allocate big new one later | 1552 | * a larger window later. |
1557 | */ | 1553 | */ |
1558 | static void pci_bus_release_bridge_resources(struct pci_bus *bus, | 1554 | static void pci_bus_release_bridge_resources(struct pci_bus *bus, |
1559 | unsigned long type, | 1555 | unsigned long type, |
@@ -1678,7 +1674,7 @@ static int iov_resources_unassigned(struct pci_dev *dev, void *data) | |||
1678 | pcibios_resource_to_bus(dev->bus, ®ion, r); | 1674 | pcibios_resource_to_bus(dev->bus, ®ion, r); |
1679 | if (!region.start) { | 1675 | if (!region.start) { |
1680 | *unassigned = true; | 1676 | *unassigned = true; |
1681 | return 1; /* return early from pci_walk_bus() */ | 1677 | return 1; /* Return early from pci_walk_bus() */ |
1682 | } | 1678 | } |
1683 | } | 1679 | } |
1684 | 1680 | ||
@@ -1686,7 +1682,7 @@ static int iov_resources_unassigned(struct pci_dev *dev, void *data) | |||
1686 | } | 1682 | } |
1687 | 1683 | ||
1688 | static enum enable_type pci_realloc_detect(struct pci_bus *bus, | 1684 | static enum enable_type pci_realloc_detect(struct pci_bus *bus, |
1689 | enum enable_type enable_local) | 1685 | enum enable_type enable_local) |
1690 | { | 1686 | { |
1691 | bool unassigned = false; | 1687 | bool unassigned = false; |
1692 | 1688 | ||
@@ -1701,21 +1697,21 @@ static enum enable_type pci_realloc_detect(struct pci_bus *bus, | |||
1701 | } | 1697 | } |
1702 | #else | 1698 | #else |
1703 | static enum enable_type pci_realloc_detect(struct pci_bus *bus, | 1699 | static enum enable_type pci_realloc_detect(struct pci_bus *bus, |
1704 | enum enable_type enable_local) | 1700 | enum enable_type enable_local) |
1705 | { | 1701 | { |
1706 | return enable_local; | 1702 | return enable_local; |
1707 | } | 1703 | } |
1708 | #endif | 1704 | #endif |
1709 | 1705 | ||
1710 | /* | 1706 | /* |
1711 | * first try will not touch pci bridge res | 1707 | * First try will not touch PCI bridge res. |
1712 | * second and later try will clear small leaf bridge res | 1708 | * Second and later try will clear small leaf bridge res. |
1713 | * will stop till to the max depth if can not find good one | 1709 | * Will stop till to the max depth if can not find good one. |
1714 | */ | 1710 | */ |
1715 | void pci_assign_unassigned_root_bus_resources(struct pci_bus *bus) | 1711 | void pci_assign_unassigned_root_bus_resources(struct pci_bus *bus) |
1716 | { | 1712 | { |
1717 | LIST_HEAD(realloc_head); /* list of resources that | 1713 | LIST_HEAD(realloc_head); |
1718 | want additional resources */ | 1714 | /* List of resources that want additional resources */ |
1719 | struct list_head *add_list = NULL; | 1715 | struct list_head *add_list = NULL; |
1720 | int tried_times = 0; | 1716 | int tried_times = 0; |
1721 | enum release_type rel_type = leaf_only; | 1717 | enum release_type rel_type = leaf_only; |
@@ -1724,7 +1720,7 @@ void pci_assign_unassigned_root_bus_resources(struct pci_bus *bus) | |||
1724 | int pci_try_num = 1; | 1720 | int pci_try_num = 1; |
1725 | enum enable_type enable_local; | 1721 | enum enable_type enable_local; |
1726 | 1722 | ||
1727 | /* don't realloc if asked to do so */ | 1723 | /* Don't realloc if asked to do so */ |
1728 | enable_local = pci_realloc_detect(bus, pci_realloc_enable); | 1724 | enable_local = pci_realloc_detect(bus, pci_realloc_enable); |
1729 | if (pci_realloc_enabled(enable_local)) { | 1725 | if (pci_realloc_enabled(enable_local)) { |
1730 | int max_depth = pci_bus_get_depth(bus); | 1726 | int max_depth = pci_bus_get_depth(bus); |
@@ -1737,13 +1733,14 @@ void pci_assign_unassigned_root_bus_resources(struct pci_bus *bus) | |||
1737 | 1733 | ||
1738 | again: | 1734 | again: |
1739 | /* | 1735 | /* |
1740 | * last try will use add_list, otherwise will try good to have as | 1736 | * Last try will use add_list, otherwise will try good to have as must |
1741 | * must have, so can realloc parent bridge resource | 1737 | * have, so can realloc parent bridge resource |
1742 | */ | 1738 | */ |
1743 | if (tried_times + 1 == pci_try_num) | 1739 | if (tried_times + 1 == pci_try_num) |
1744 | add_list = &realloc_head; | 1740 | add_list = &realloc_head; |
1745 | /* Depth first, calculate sizes and alignments of all | 1741 | /* |
1746 | subordinate buses. */ | 1742 | * Depth first, calculate sizes and alignments of all subordinate buses. |
1743 | */ | ||
1747 | __pci_bus_size_bridges(bus, add_list); | 1744 | __pci_bus_size_bridges(bus, add_list); |
1748 | 1745 | ||
1749 | /* Depth last, allocate resources and update the hardware. */ | 1746 | /* Depth last, allocate resources and update the hardware. */ |
@@ -1752,7 +1749,7 @@ again: | |||
1752 | BUG_ON(!list_empty(add_list)); | 1749 | BUG_ON(!list_empty(add_list)); |
1753 | tried_times++; | 1750 | tried_times++; |
1754 | 1751 | ||
1755 | /* any device complain? */ | 1752 | /* Any device complain? */ |
1756 | if (list_empty(&fail_head)) | 1753 | if (list_empty(&fail_head)) |
1757 | goto dump; | 1754 | goto dump; |
1758 | 1755 | ||
@@ -1769,20 +1766,20 @@ again: | |||
1769 | dev_printk(KERN_DEBUG, &bus->dev, | 1766 | dev_printk(KERN_DEBUG, &bus->dev, |
1770 | "No. %d try to assign unassigned res\n", tried_times + 1); | 1767 | "No. %d try to assign unassigned res\n", tried_times + 1); |
1771 | 1768 | ||
1772 | /* third times and later will not check if it is leaf */ | 1769 | /* Third times and later will not check if it is leaf */ |
1773 | if ((tried_times + 1) > 2) | 1770 | if ((tried_times + 1) > 2) |
1774 | rel_type = whole_subtree; | 1771 | rel_type = whole_subtree; |
1775 | 1772 | ||
1776 | /* | 1773 | /* |
1777 | * Try to release leaf bridge's resources that doesn't fit resource of | 1774 | * Try to release leaf bridge's resources that doesn't fit resource of |
1778 | * child device under that bridge | 1775 | * child device under that bridge. |
1779 | */ | 1776 | */ |
1780 | list_for_each_entry(fail_res, &fail_head, list) | 1777 | list_for_each_entry(fail_res, &fail_head, list) |
1781 | pci_bus_release_bridge_resources(fail_res->dev->bus, | 1778 | pci_bus_release_bridge_resources(fail_res->dev->bus, |
1782 | fail_res->flags & PCI_RES_TYPE_MASK, | 1779 | fail_res->flags & PCI_RES_TYPE_MASK, |
1783 | rel_type); | 1780 | rel_type); |
1784 | 1781 | ||
1785 | /* restore size and flags */ | 1782 | /* Restore size and flags */ |
1786 | list_for_each_entry(fail_res, &fail_head, list) { | 1783 | list_for_each_entry(fail_res, &fail_head, list) { |
1787 | struct resource *res = fail_res->res; | 1784 | struct resource *res = fail_res->res; |
1788 | 1785 | ||
@@ -1797,7 +1794,7 @@ again: | |||
1797 | goto again; | 1794 | goto again; |
1798 | 1795 | ||
1799 | dump: | 1796 | dump: |
1800 | /* dump the resource on buses */ | 1797 | /* Dump the resource on buses */ |
1801 | pci_bus_dump_resources(bus); | 1798 | pci_bus_dump_resources(bus); |
1802 | } | 1799 | } |
1803 | 1800 | ||
@@ -1808,14 +1805,15 @@ void __init pci_assign_unassigned_resources(void) | |||
1808 | list_for_each_entry(root_bus, &pci_root_buses, node) { | 1805 | list_for_each_entry(root_bus, &pci_root_buses, node) { |
1809 | pci_assign_unassigned_root_bus_resources(root_bus); | 1806 | pci_assign_unassigned_root_bus_resources(root_bus); |
1810 | 1807 | ||
1811 | /* Make sure the root bridge has a companion ACPI device: */ | 1808 | /* Make sure the root bridge has a companion ACPI device */ |
1812 | if (ACPI_HANDLE(root_bus->bridge)) | 1809 | if (ACPI_HANDLE(root_bus->bridge)) |
1813 | acpi_ioapic_add(ACPI_HANDLE(root_bus->bridge)); | 1810 | acpi_ioapic_add(ACPI_HANDLE(root_bus->bridge)); |
1814 | } | 1811 | } |
1815 | } | 1812 | } |
1816 | 1813 | ||
1817 | static void extend_bridge_window(struct pci_dev *bridge, struct resource *res, | 1814 | static void extend_bridge_window(struct pci_dev *bridge, struct resource *res, |
1818 | struct list_head *add_list, resource_size_t available) | 1815 | struct list_head *add_list, |
1816 | resource_size_t available) | ||
1819 | { | 1817 | { |
1820 | struct pci_dev_resource *dev_res; | 1818 | struct pci_dev_resource *dev_res; |
1821 | 1819 | ||
@@ -1839,8 +1837,10 @@ static void extend_bridge_window(struct pci_dev *bridge, struct resource *res, | |||
1839 | } | 1837 | } |
1840 | 1838 | ||
1841 | static void pci_bus_distribute_available_resources(struct pci_bus *bus, | 1839 | static void pci_bus_distribute_available_resources(struct pci_bus *bus, |
1842 | struct list_head *add_list, resource_size_t available_io, | 1840 | struct list_head *add_list, |
1843 | resource_size_t available_mmio, resource_size_t available_mmio_pref) | 1841 | resource_size_t available_io, |
1842 | resource_size_t available_mmio, | ||
1843 | resource_size_t available_mmio_pref) | ||
1844 | { | 1844 | { |
1845 | resource_size_t remaining_io, remaining_mmio, remaining_mmio_pref; | 1845 | resource_size_t remaining_io, remaining_mmio, remaining_mmio_pref; |
1846 | unsigned int normal_bridges = 0, hotplug_bridges = 0; | 1846 | unsigned int normal_bridges = 0, hotplug_bridges = 0; |
@@ -1864,7 +1864,7 @@ static void pci_bus_distribute_available_resources(struct pci_bus *bus, | |||
1864 | 1864 | ||
1865 | /* | 1865 | /* |
1866 | * Calculate the total amount of extra resource space we can | 1866 | * Calculate the total amount of extra resource space we can |
1867 | * pass to bridges below this one. This is basically the | 1867 | * pass to bridges below this one. This is basically the |
1868 | * extra space reduced by the minimal required space for the | 1868 | * extra space reduced by the minimal required space for the |
1869 | * non-hotplug bridges. | 1869 | * non-hotplug bridges. |
1870 | */ | 1870 | */ |
@@ -1874,7 +1874,7 @@ static void pci_bus_distribute_available_resources(struct pci_bus *bus, | |||
1874 | 1874 | ||
1875 | /* | 1875 | /* |
1876 | * Calculate how many hotplug bridges and normal bridges there | 1876 | * Calculate how many hotplug bridges and normal bridges there |
1877 | * are on this bus. We will distribute the additional available | 1877 | * are on this bus. We will distribute the additional available |
1878 | * resources between hotplug bridges. | 1878 | * resources between hotplug bridges. |
1879 | */ | 1879 | */ |
1880 | for_each_pci_bridge(dev, bus) { | 1880 | for_each_pci_bridge(dev, bus) { |
@@ -1909,8 +1909,8 @@ static void pci_bus_distribute_available_resources(struct pci_bus *bus, | |||
1909 | 1909 | ||
1910 | /* | 1910 | /* |
1911 | * There is only one bridge on the bus so it gets all available | 1911 | * There is only one bridge on the bus so it gets all available |
1912 | * resources which it can then distribute to the possible | 1912 | * resources which it can then distribute to the possible hotplug |
1913 | * hotplug bridges below. | 1913 | * bridges below. |
1914 | */ | 1914 | */ |
1915 | if (hotplug_bridges + normal_bridges == 1) { | 1915 | if (hotplug_bridges + normal_bridges == 1) { |
1916 | dev = list_first_entry(&bus->devices, struct pci_dev, bus_list); | 1916 | dev = list_first_entry(&bus->devices, struct pci_dev, bus_list); |
@@ -1961,9 +1961,8 @@ static void pci_bus_distribute_available_resources(struct pci_bus *bus, | |||
1961 | } | 1961 | } |
1962 | } | 1962 | } |
1963 | 1963 | ||
1964 | static void | 1964 | static void pci_bridge_distribute_available_resources(struct pci_dev *bridge, |
1965 | pci_bridge_distribute_available_resources(struct pci_dev *bridge, | 1965 | struct list_head *add_list) |
1966 | struct list_head *add_list) | ||
1967 | { | 1966 | { |
1968 | resource_size_t available_io, available_mmio, available_mmio_pref; | 1967 | resource_size_t available_io, available_mmio, available_mmio_pref; |
1969 | const struct resource *res; | 1968 | const struct resource *res; |
@@ -1980,14 +1979,17 @@ pci_bridge_distribute_available_resources(struct pci_dev *bridge, | |||
1980 | available_mmio_pref = resource_size(res); | 1979 | available_mmio_pref = resource_size(res); |
1981 | 1980 | ||
1982 | pci_bus_distribute_available_resources(bridge->subordinate, | 1981 | pci_bus_distribute_available_resources(bridge->subordinate, |
1983 | add_list, available_io, available_mmio, available_mmio_pref); | 1982 | add_list, available_io, |
1983 | available_mmio, | ||
1984 | available_mmio_pref); | ||
1984 | } | 1985 | } |
1985 | 1986 | ||
1986 | void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge) | 1987 | void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge) |
1987 | { | 1988 | { |
1988 | struct pci_bus *parent = bridge->subordinate; | 1989 | struct pci_bus *parent = bridge->subordinate; |
1989 | LIST_HEAD(add_list); /* list of resources that | 1990 | /* List of resources that want additional resources */ |
1990 | want additional resources */ | 1991 | LIST_HEAD(add_list); |
1992 | |||
1991 | int tried_times = 0; | 1993 | int tried_times = 0; |
1992 | LIST_HEAD(fail_head); | 1994 | LIST_HEAD(fail_head); |
1993 | struct pci_dev_resource *fail_res; | 1995 | struct pci_dev_resource *fail_res; |
@@ -1997,9 +1999,9 @@ again: | |||
1997 | __pci_bus_size_bridges(parent, &add_list); | 1999 | __pci_bus_size_bridges(parent, &add_list); |
1998 | 2000 | ||
1999 | /* | 2001 | /* |
2000 | * Distribute remaining resources (if any) equally between | 2002 | * Distribute remaining resources (if any) equally between hotplug |
2001 | * hotplug bridges below. This makes it possible to extend the | 2003 | * bridges below. This makes it possible to extend the hierarchy |
2002 | * hierarchy later without running out of resources. | 2004 | * later without running out of resources. |
2003 | */ | 2005 | */ |
2004 | pci_bridge_distribute_available_resources(bridge, &add_list); | 2006 | pci_bridge_distribute_available_resources(bridge, &add_list); |
2005 | 2007 | ||
@@ -2011,7 +2013,7 @@ again: | |||
2011 | goto enable_all; | 2013 | goto enable_all; |
2012 | 2014 | ||
2013 | if (tried_times >= 2) { | 2015 | if (tried_times >= 2) { |
2014 | /* still fail, don't need to try more */ | 2016 | /* Still fail, don't need to try more */ |
2015 | free_list(&fail_head); | 2017 | free_list(&fail_head); |
2016 | goto enable_all; | 2018 | goto enable_all; |
2017 | } | 2019 | } |
@@ -2020,15 +2022,15 @@ again: | |||
2020 | tried_times + 1); | 2022 | tried_times + 1); |
2021 | 2023 | ||
2022 | /* | 2024 | /* |
2023 | * Try to release leaf bridge's resources that doesn't fit resource of | 2025 | * Try to release leaf bridge's resources that aren't big enough |
2024 | * child device under that bridge | 2026 | * to contain child device resources. |
2025 | */ | 2027 | */ |
2026 | list_for_each_entry(fail_res, &fail_head, list) | 2028 | list_for_each_entry(fail_res, &fail_head, list) |
2027 | pci_bus_release_bridge_resources(fail_res->dev->bus, | 2029 | pci_bus_release_bridge_resources(fail_res->dev->bus, |
2028 | fail_res->flags & PCI_RES_TYPE_MASK, | 2030 | fail_res->flags & PCI_RES_TYPE_MASK, |
2029 | whole_subtree); | 2031 | whole_subtree); |
2030 | 2032 | ||
2031 | /* restore size and flags */ | 2033 | /* Restore size and flags */ |
2032 | list_for_each_entry(fail_res, &fail_head, list) { | 2034 | list_for_each_entry(fail_res, &fail_head, list) { |
2033 | struct resource *res = fail_res->res; | 2035 | struct resource *res = fail_res->res; |
2034 | 2036 | ||
@@ -2107,7 +2109,7 @@ int pci_reassign_bridge_resources(struct pci_dev *bridge, unsigned long type) | |||
2107 | } | 2109 | } |
2108 | 2110 | ||
2109 | list_for_each_entry(dev_res, &saved, list) { | 2111 | list_for_each_entry(dev_res, &saved, list) { |
2110 | /* Skip the bridge we just assigned resources for. */ | 2112 | /* Skip the bridge we just assigned resources for */ |
2111 | if (bridge == dev_res->dev) | 2113 | if (bridge == dev_res->dev) |
2112 | continue; | 2114 | continue; |
2113 | 2115 | ||
@@ -2119,7 +2121,7 @@ int pci_reassign_bridge_resources(struct pci_dev *bridge, unsigned long type) | |||
2119 | return 0; | 2121 | return 0; |
2120 | 2122 | ||
2121 | cleanup: | 2123 | cleanup: |
2122 | /* restore size and flags */ | 2124 | /* Restore size and flags */ |
2123 | list_for_each_entry(dev_res, &failed, list) { | 2125 | list_for_each_entry(dev_res, &failed, list) { |
2124 | struct resource *res = dev_res->res; | 2126 | struct resource *res = dev_res->res; |
2125 | 2127 | ||
@@ -2151,8 +2153,8 @@ cleanup: | |||
2151 | void pci_assign_unassigned_bus_resources(struct pci_bus *bus) | 2153 | void pci_assign_unassigned_bus_resources(struct pci_bus *bus) |
2152 | { | 2154 | { |
2153 | struct pci_dev *dev; | 2155 | struct pci_dev *dev; |
2154 | LIST_HEAD(add_list); /* list of resources that | 2156 | /* List of resources that want additional resources */ |
2155 | want additional resources */ | 2157 | LIST_HEAD(add_list); |
2156 | 2158 | ||
2157 | down_read(&pci_bus_sem); | 2159 | down_read(&pci_bus_sem); |
2158 | for_each_pci_bridge(dev, bus) | 2160 | for_each_pci_bridge(dev, bus) |