diff options
author | Guo Chao <yan@linux.vnet.ibm.com> | 2014-07-03 20:30:29 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2014-07-03 20:30:29 -0400 |
commit | c33377082dd9ede1e998f7ce416077e4b1c2276c (patch) | |
tree | c35e9737d43a3087fd8afa4253049045fe7c8745 /drivers/pci | |
parent | 7171511eaec5bf23fb06078f59784a3a0626b38f (diff) |
PCI: Keep original resource if we fail to expand it
If we have space assigned to a resource, we try to expand the resource
(e.g., to accommodate SR-IOV resources), and the expansion attempt fails,
we should keep the original assignment.
After bd064f0a231a ("PCI: Mark resources as IORESOURCE_UNSET if we can't
assign them"), we left the resource marked IORESOURCE_UNSET when the
expansion failed, even if it had originally been set. That caused errors
like this:
pci 0003:00:00.0: can't enable device: BAR 15 [mem size 0x0c000000 64bit pref] not assigned
pci 0003:00:00.0: Error enabling bridge (-22), continuing
Fix this by restoring the original flags when reassignment fails.
[bhelgaas: reworked to simplify, changelog]
Fixes: bd064f0a231a ("PCI: Mark resources as IORESOURCE_UNSET if we can't assign them")
Signed-off-by: Guo Chao <yan@linux.vnet.ibm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: stable@vger.kernel.org # v3.15+
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/setup-res.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index caed1ce6facd..481c4e18693a 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c | |||
@@ -320,9 +320,11 @@ int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsiz | |||
320 | resource_size_t min_align) | 320 | resource_size_t min_align) |
321 | { | 321 | { |
322 | struct resource *res = dev->resource + resno; | 322 | struct resource *res = dev->resource + resno; |
323 | unsigned long flags; | ||
323 | resource_size_t new_size; | 324 | resource_size_t new_size; |
324 | int ret; | 325 | int ret; |
325 | 326 | ||
327 | flags = res->flags; | ||
326 | res->flags |= IORESOURCE_UNSET; | 328 | res->flags |= IORESOURCE_UNSET; |
327 | if (!res->parent) { | 329 | if (!res->parent) { |
328 | dev_info(&dev->dev, "BAR %d: can't reassign an unassigned resource %pR\n", | 330 | dev_info(&dev->dev, "BAR %d: can't reassign an unassigned resource %pR\n", |
@@ -339,7 +341,12 @@ int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsiz | |||
339 | dev_info(&dev->dev, "BAR %d: reassigned %pR\n", resno, res); | 341 | dev_info(&dev->dev, "BAR %d: reassigned %pR\n", resno, res); |
340 | if (resno < PCI_BRIDGE_RESOURCES) | 342 | if (resno < PCI_BRIDGE_RESOURCES) |
341 | pci_update_resource(dev, resno); | 343 | pci_update_resource(dev, resno); |
344 | } else { | ||
345 | res->flags = flags; | ||
346 | dev_info(&dev->dev, "BAR %d: %pR (failed to expand by %#llx)\n", | ||
347 | resno, res, (unsigned long long) addsize); | ||
342 | } | 348 | } |
349 | |||
343 | return ret; | 350 | return ret; |
344 | } | 351 | } |
345 | 352 | ||