From 20103b94784383ee40be7fc075349f4e4b485054 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Thu, 23 Feb 2012 14:29:23 -0700 Subject: [PATCH] --- yaml --- r: 294739 b: refs/heads/master c: 47087700ce3ccb2bf69f4dcb6ad7f59764e51308 h: refs/heads/master i: 294737: 6dabc23ef8bb8ebdd1aeabd2a171a273fbfa8d89 294735: d8de5ceeaaa3b70d71da027b6dff59d0b9dd3a5a v: v3 --- [refs] | 2 +- trunk/Documentation/kernel-parameters.txt | 9 +-- trunk/drivers/pci/Kconfig | 13 ---- trunk/drivers/pci/pci.c | 4 +- trunk/drivers/pci/pci.h | 2 +- trunk/drivers/pci/setup-bus.c | 78 ++++++----------------- 6 files changed, 25 insertions(+), 83 deletions(-) diff --git a/[refs] b/[refs] index f157489e0860..694907b2fe78 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b07f2ebc109b607789f648dedcff4b125f9afec6 +refs/heads/master: 47087700ce3ccb2bf69f4dcb6ad7f59764e51308 diff --git a/trunk/Documentation/kernel-parameters.txt b/trunk/Documentation/kernel-parameters.txt index 7dc523e082a2..7fb7a4b161ff 100644 --- a/trunk/Documentation/kernel-parameters.txt +++ b/trunk/Documentation/kernel-parameters.txt @@ -2109,13 +2109,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted. the default. off: Turn ECRC off on: Turn ECRC on. - realloc= Enable/disable reallocating PCI bridge resources - if allocations done by BIOS are too small to - accommodate resources required by all child - devices. - off: Turn realloc off - on: Turn realloc on - realloc same as realloc=on + realloc reallocate PCI resources if allocations done by BIOS + are erroneous. pcie_aspm= [PCIE] Forcibly enable or disable PCIe Active State Power Management. diff --git a/trunk/drivers/pci/Kconfig b/trunk/drivers/pci/Kconfig index 848bfb84c04c..37856f7c7781 100644 --- a/trunk/drivers/pci/Kconfig +++ b/trunk/drivers/pci/Kconfig @@ -31,19 +31,6 @@ config PCI_DEBUG When in doubt, say N. -config PCI_REALLOC_ENABLE_AUTO - bool "Enable PCI resource re-allocation detection" - depends on PCI - help - Say Y here if you want the PCI core to detect if PCI resource - re-allocation needs to be enabled. You can always use pci=realloc=on - or pci=realloc=off to override it. Note this feature is a no-op - unless PCI_IOV support is also enabled; in that case it will - automatically re-allocate PCI resources if SR-IOV BARs have not - been allocated by the BIOS. - - When in doubt, say N. - config PCI_STUB tristate "PCI Stub driver" depends on PCI diff --git a/trunk/drivers/pci/pci.c b/trunk/drivers/pci/pci.c index e9f9dc183cfc..8f30736dbf3f 100644 --- a/trunk/drivers/pci/pci.c +++ b/trunk/drivers/pci/pci.c @@ -3772,10 +3772,8 @@ static int __init pci_setup(char *str) pci_no_msi(); } else if (!strcmp(str, "noaer")) { pci_no_aer(); - } else if (!strncmp(str, "realloc=", 8)) { - pci_realloc_get_opt(str + 8); } else if (!strncmp(str, "realloc", 7)) { - pci_realloc_get_opt("on"); + pci_realloc(); } else if (!strcmp(str, "nodomains")) { pci_no_domains(); } else if (!strncmp(str, "cbiosize=", 9)) { diff --git a/trunk/drivers/pci/pci.h b/trunk/drivers/pci/pci.h index 1fc63b39f83f..586ac9b097e4 100644 --- a/trunk/drivers/pci/pci.h +++ b/trunk/drivers/pci/pci.h @@ -149,7 +149,7 @@ static inline void pci_no_msi(void) { } static inline void pci_msi_init_pci_dev(struct pci_dev *dev) { } #endif -void pci_realloc_get_opt(char *); +extern void pci_realloc(void); static inline int pci_no_d1d2(struct pci_dev *dev) { diff --git a/trunk/drivers/pci/setup-bus.c b/trunk/drivers/pci/setup-bus.c index c9214a14b49b..6db307fa20f5 100644 --- a/trunk/drivers/pci/setup-bus.c +++ b/trunk/drivers/pci/setup-bus.c @@ -25,8 +25,11 @@ #include #include #include +#include #include "pci.h" +unsigned int __weak pci_flags; + struct pci_dev_resource { struct list_head list; struct resource *res; @@ -48,6 +51,13 @@ static void free_list(struct list_head *head) } } +int pci_realloc_enable = 0; +#define pci_realloc_enabled() pci_realloc_enable +void pci_realloc(void) +{ + pci_realloc_enable = 1; +} + /** * add_to_list() - add a new resource tracker to the list * @head: Head of the list @@ -1266,58 +1276,6 @@ static int __init pci_get_max_depth(void) return depth; } -/* - * -1: undefined, will auto detect later - * 0: disabled by user - * 1: disabled by auto detect - * 2: enabled by user - * 3: enabled by auto detect - */ -enum enable_type { - undefined = -1, - user_disabled, - auto_disabled, - user_enabled, - auto_enabled, -}; - -static enum enable_type pci_realloc_enable __initdata = undefined; -void __init pci_realloc_get_opt(char *str) -{ - if (!strncmp(str, "off", 3)) - pci_realloc_enable = user_disabled; - else if (!strncmp(str, "on", 2)) - pci_realloc_enable = user_enabled; -} -static bool __init pci_realloc_enabled(void) -{ - return pci_realloc_enable >= user_enabled; -} - -static void __init pci_realloc_detect(void) -{ -#if defined(CONFIG_PCI_IOV) && defined(CONFIG_PCI_REALLOC_ENABLE_AUTO) - struct pci_dev *dev = NULL; - - if (pci_realloc_enable != undefined) - return; - - for_each_pci_dev(dev) { - int i; - - for (i = PCI_IOV_RESOURCES; i <= PCI_IOV_RESOURCE_END; i++) { - struct resource *r = &dev->resource[i]; - - /* Not assigned, or rejected by kernel ? */ - if (r->flags && !r->start) { - pci_realloc_enable = auto_enabled; - - return; - } - } - } -#endif -} /* * first try will not touch pci bridge res @@ -1337,10 +1295,10 @@ pci_assign_unassigned_resources(void) struct pci_dev_resource *fail_res; unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH; + unsigned long failed_type; int pci_try_num = 1; /* don't realloc if asked to do so */ - pci_realloc_detect(); if (pci_realloc_enabled()) { int max_depth = pci_get_max_depth(); @@ -1372,12 +1330,16 @@ pci_assign_unassigned_resources(void) if (list_empty(&fail_head)) goto enable_and_dump; - if (tried_times >= pci_try_num) { - if (pci_realloc_enable == undefined) - printk(KERN_INFO "Some PCI device resources are unassigned, try booting with pci=realloc\n"); - else if (pci_realloc_enable == auto_enabled) - printk(KERN_INFO "Automatically enabled pci realloc, if you have problem, try booting with pci=realloc=off\n"); + failed_type = 0; + list_for_each_entry(fail_res, &fail_head, list) + failed_type |= fail_res->flags; + /* + * io port are tight, don't try extra + * or if reach the limit, don't want to try more + */ + failed_type &= type_mask; + if ((failed_type == IORESOURCE_IO) || (tried_times >= pci_try_num)) { free_list(&fail_head); goto enable_and_dump; }