Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 294739
b: refs/heads/master
c: 4708770
h: refs/heads/master
i:
  294737: 6dabc23
  294735: d8de5ce
v: v3
  • Loading branch information
Bjorn Helgaas committed Feb 24, 2012
1 parent 0d3a476 commit 20103b9
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 83 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b07f2ebc109b607789f648dedcff4b125f9afec6
refs/heads/master: 47087700ce3ccb2bf69f4dcb6ad7f59764e51308
9 changes: 2 additions & 7 deletions trunk/Documentation/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 0 additions & 13 deletions trunk/drivers/pci/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions trunk/drivers/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/pci/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
78 changes: 20 additions & 58 deletions trunk/drivers/pci/setup-bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
#include <linux/ioport.h>
#include <linux/cache.h>
#include <linux/slab.h>
#include <asm-generic/pci-bridge.h>
#include "pci.h"

unsigned int __weak pci_flags;

struct pci_dev_resource {
struct list_head list;
struct resource *res;
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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();

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 20103b9

Please sign in to comment.