diff options
author | Yinghai Lu <yinghai@kernel.org> | 2013-07-22 17:37:13 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2013-07-25 14:35:02 -0400 |
commit | 223d96fc3249b0ffdc30bf77fd90c93f857e9a6e (patch) | |
tree | c3f430aad2fe8d8eb9b603437c5511586f41eb63 /drivers/pci/setup-bus.c | |
parent | 61e83cdde15f8850087d6c57c8576e25b671db59 (diff) |
PCI: Look for unassigned resources on per-bus basis
When CONFIG_PCI_REALLOC_ENABLE_AUTO=y, pci_realloc_detect() looks at PCI
devices to see if any have SR-IOV resources that need to be assigned. If
it finds any, it turns on automatic resource reallocation.
This patch changes pci_realloc_detect() so it uses pci_walk_bus() on
each root bus instead of using for_each_pci_dev(). This is a step
toward doing reallocation on a per-bus basis, so we can do it for
a hot-added host bridge.
[bhelgaas: changelog, rename callback to iov_resources_unassigned(), use
boolean for "unassigned"]
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/setup-bus.c')
-rw-r--r-- | drivers/pci/setup-bus.c | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index cb6bcbb26226..20c09bd652db 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
@@ -1359,30 +1359,44 @@ static bool __init pci_realloc_enabled(void) | |||
1359 | return pci_realloc_enable >= user_enabled; | 1359 | return pci_realloc_enable >= user_enabled; |
1360 | } | 1360 | } |
1361 | 1361 | ||
1362 | static void __init pci_realloc_detect(void) | ||
1363 | { | ||
1364 | #if defined(CONFIG_PCI_IOV) && defined(CONFIG_PCI_REALLOC_ENABLE_AUTO) | 1362 | #if defined(CONFIG_PCI_IOV) && defined(CONFIG_PCI_REALLOC_ENABLE_AUTO) |
1365 | struct pci_dev *dev = NULL; | 1363 | static int __init iov_resources_unassigned(struct pci_dev *dev, void *data) |
1364 | { | ||
1365 | int i; | ||
1366 | bool *unassigned = data; | ||
1366 | 1367 | ||
1367 | if (pci_realloc_enable != undefined) | 1368 | for (i = PCI_IOV_RESOURCES; i <= PCI_IOV_RESOURCE_END; i++) { |
1368 | return; | 1369 | struct resource *r = &dev->resource[i]; |
1369 | 1370 | ||
1370 | for_each_pci_dev(dev) { | 1371 | /* Not assigned or rejected by kernel? */ |
1371 | int i; | 1372 | if (r->flags && !r->start) { |
1373 | *unassigned = true; | ||
1374 | return 1; /* return early from pci_walk_bus() */ | ||
1375 | } | ||
1376 | } | ||
1372 | 1377 | ||
1373 | for (i = PCI_IOV_RESOURCES; i <= PCI_IOV_RESOURCE_END; i++) { | 1378 | return 0; |
1374 | struct resource *r = &dev->resource[i]; | 1379 | } |
1375 | 1380 | ||
1376 | /* Not assigned, or rejected by kernel ? */ | 1381 | static void __init pci_realloc_detect(void) |
1377 | if (r->flags && !r->start) { | 1382 | { |
1378 | pci_realloc_enable = auto_enabled; | 1383 | bool unassigned = false; |
1384 | struct pci_bus *bus; | ||
1379 | 1385 | ||
1380 | return; | 1386 | if (pci_realloc_enable != undefined) |
1381 | } | 1387 | return; |
1388 | |||
1389 | list_for_each_entry(bus, &pci_root_buses, node) { | ||
1390 | pci_walk_bus(bus, iov_resources_unassigned, &unassigned); | ||
1391 | if (unassigned) { | ||
1392 | pci_realloc_enable = auto_enabled; | ||
1393 | return; | ||
1382 | } | 1394 | } |
1383 | } | 1395 | } |
1384 | #endif | ||
1385 | } | 1396 | } |
1397 | #else | ||
1398 | static void __init pci_realloc_detect(void) { } | ||
1399 | #endif | ||
1386 | 1400 | ||
1387 | /* | 1401 | /* |
1388 | * first try will not touch pci bridge res | 1402 | * first try will not touch pci bridge res |