diff options
author | Yinghai Lu <yinghai@kernel.org> | 2012-02-23 22:23:32 -0500 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2012-02-24 12:38:59 -0500 |
commit | b07f2ebc109b607789f648dedcff4b125f9afec6 (patch) | |
tree | 3868d50119a2ba1721914e9b53f12d996c5d45b4 /drivers/pci | |
parent | eb572e7c76f154d75f90a783924f88afc34d5fec (diff) |
PCI: add a PCI resource reallocation config option
Add a new config option, PCI_REALLOC_ENABLE_AUTO, which will
automatically try to re-allocate PCI resources if PCI_IOV support is
enabled and the SR-IOV resources are unassigned. Behavior can still be
controlled using the pci=realloc= parameter.
-v2: According to Jesse, adding one CONFIG option for distribution to
disable it or enable it.
-v3: update Kconfig text (jbarnes)
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/Kconfig | 13 | ||||
-rw-r--r-- | drivers/pci/setup-bus.c | 28 |
2 files changed, 41 insertions, 0 deletions
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index 37856f7c7781..848bfb84c04c 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig | |||
@@ -31,6 +31,19 @@ config PCI_DEBUG | |||
31 | 31 | ||
32 | When in doubt, say N. | 32 | When in doubt, say N. |
33 | 33 | ||
34 | config PCI_REALLOC_ENABLE_AUTO | ||
35 | bool "Enable PCI resource re-allocation detection" | ||
36 | depends on PCI | ||
37 | help | ||
38 | Say Y here if you want the PCI core to detect if PCI resource | ||
39 | re-allocation needs to be enabled. You can always use pci=realloc=on | ||
40 | or pci=realloc=off to override it. Note this feature is a no-op | ||
41 | unless PCI_IOV support is also enabled; in that case it will | ||
42 | automatically re-allocate PCI resources if SR-IOV BARs have not | ||
43 | been allocated by the BIOS. | ||
44 | |||
45 | When in doubt, say N. | ||
46 | |||
34 | config PCI_STUB | 47 | config PCI_STUB |
35 | tristate "PCI Stub driver" | 48 | tristate "PCI Stub driver" |
36 | depends on PCI | 49 | depends on PCI |
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index e21e1c237301..c9214a14b49b 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
@@ -1294,6 +1294,31 @@ static bool __init pci_realloc_enabled(void) | |||
1294 | return pci_realloc_enable >= user_enabled; | 1294 | return pci_realloc_enable >= user_enabled; |
1295 | } | 1295 | } |
1296 | 1296 | ||
1297 | static void __init pci_realloc_detect(void) | ||
1298 | { | ||
1299 | #if defined(CONFIG_PCI_IOV) && defined(CONFIG_PCI_REALLOC_ENABLE_AUTO) | ||
1300 | struct pci_dev *dev = NULL; | ||
1301 | |||
1302 | if (pci_realloc_enable != undefined) | ||
1303 | return; | ||
1304 | |||
1305 | for_each_pci_dev(dev) { | ||
1306 | int i; | ||
1307 | |||
1308 | for (i = PCI_IOV_RESOURCES; i <= PCI_IOV_RESOURCE_END; i++) { | ||
1309 | struct resource *r = &dev->resource[i]; | ||
1310 | |||
1311 | /* Not assigned, or rejected by kernel ? */ | ||
1312 | if (r->flags && !r->start) { | ||
1313 | pci_realloc_enable = auto_enabled; | ||
1314 | |||
1315 | return; | ||
1316 | } | ||
1317 | } | ||
1318 | } | ||
1319 | #endif | ||
1320 | } | ||
1321 | |||
1297 | /* | 1322 | /* |
1298 | * first try will not touch pci bridge res | 1323 | * first try will not touch pci bridge res |
1299 | * second and later try will clear small leaf bridge res | 1324 | * second and later try will clear small leaf bridge res |
@@ -1315,6 +1340,7 @@ pci_assign_unassigned_resources(void) | |||
1315 | int pci_try_num = 1; | 1340 | int pci_try_num = 1; |
1316 | 1341 | ||
1317 | /* don't realloc if asked to do so */ | 1342 | /* don't realloc if asked to do so */ |
1343 | pci_realloc_detect(); | ||
1318 | if (pci_realloc_enabled()) { | 1344 | if (pci_realloc_enabled()) { |
1319 | int max_depth = pci_get_max_depth(); | 1345 | int max_depth = pci_get_max_depth(); |
1320 | 1346 | ||
@@ -1349,6 +1375,8 @@ again: | |||
1349 | if (tried_times >= pci_try_num) { | 1375 | if (tried_times >= pci_try_num) { |
1350 | if (pci_realloc_enable == undefined) | 1376 | if (pci_realloc_enable == undefined) |
1351 | printk(KERN_INFO "Some PCI device resources are unassigned, try booting with pci=realloc\n"); | 1377 | printk(KERN_INFO "Some PCI device resources are unassigned, try booting with pci=realloc\n"); |
1378 | else if (pci_realloc_enable == auto_enabled) | ||
1379 | printk(KERN_INFO "Automatically enabled pci realloc, if you have problem, try booting with pci=realloc=off\n"); | ||
1352 | 1380 | ||
1353 | free_list(&fail_head); | 1381 | free_list(&fail_head); |
1354 | goto enable_and_dump; | 1382 | goto enable_and_dump; |