PCI: only enable pci realloc when SRIOV bar is not assigned
If bios does not assign those BAR or wrong address, then kernel will
try to do pci realloc.
in that case, user still can use pci=realloc=off to override it.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 1c97e14..3070e1b 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1271,6 +1271,31 @@
return pci_realloc_enable > 0;
}
+static void __init pci_realloc_detect(void)
+{
+ struct pci_dev *dev = NULL;
+
+ if (pci_realloc_enable != -1)
+ return;
+
+#ifdef CONFIG_PCI_IOV
+ 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 = 2;
+
+ return;
+ }
+ }
+ }
+#endif
+}
+
/*
* first try will not touch pci bridge res
* second and later try will clear small leaf bridge res
@@ -1292,6 +1317,7 @@
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();