Commit 6535943f authored by Myron Stowe's avatar Myron Stowe Committed by Jesse Barnes

x86/PCI: Convert maintaining FW-assigned BIOS BAR values to use a list

This patch converts the underlying maintenance aspects of FW-assigned
BIOS BAR values from a statically allocated array within struct pci_dev
to a list of temporary, stand alone, entries.
Signed-off-by: default avatarMyron Stowe <myron.stowe@redhat.com>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent 925845bd
...@@ -261,7 +261,8 @@ static void __init pcibios_allocate_resources(int pass) ...@@ -261,7 +261,8 @@ static void __init pcibios_allocate_resources(int pass)
idx, r, disabled, pass); idx, r, disabled, pass);
if (pci_claim_resource(dev, idx) < 0) { if (pci_claim_resource(dev, idx) < 0) {
/* We'll assign a new address later */ /* We'll assign a new address later */
dev->fw_addr[idx] = r->start; pcibios_save_fw_addr(dev,
idx, r->start);
r->end -= r->start; r->end -= r->start;
r->start = 0; r->start = 0;
} }
...@@ -307,6 +308,7 @@ static int __init pcibios_assign_resources(void) ...@@ -307,6 +308,7 @@ static int __init pcibios_assign_resources(void)
} }
pci_assign_unassigned_resources(); pci_assign_unassigned_resources();
pcibios_fw_addr_list_del();
return 0; return 0;
} }
......
...@@ -158,16 +158,34 @@ static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev, ...@@ -158,16 +158,34 @@ static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev,
return ret; return ret;
} }
/*
* Generic function that returns a value indicating that the device's
* original BIOS BAR address was not saved and so is not available for
* reinstatement.
*
* Can be over-ridden by architecture specific code that implements
* reinstatement functionality rather than leaving it disabled when
* normal allocation attempts fail.
*/
resource_size_t __weak pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx)
{
return 0;
}
static int pci_revert_fw_address(struct resource *res, struct pci_dev *dev, static int pci_revert_fw_address(struct resource *res, struct pci_dev *dev,
int resno, resource_size_t size) int resno, resource_size_t size)
{ {
struct resource *root, *conflict; struct resource *root, *conflict;
resource_size_t start, end; resource_size_t fw_addr, start, end;
int ret = 0; int ret = 0;
fw_addr = pcibios_retrieve_fw_addr(dev, resno);
if (!fw_addr)
return 1;
start = res->start; start = res->start;
end = res->end; end = res->end;
res->start = dev->fw_addr[resno]; res->start = fw_addr;
res->end = res->start + size - 1; res->end = res->start + size - 1;
root = pci_find_parent_resource(dev, res); root = pci_find_parent_resource(dev, res);
...@@ -271,7 +289,7 @@ int pci_assign_resource(struct pci_dev *dev, int resno) ...@@ -271,7 +289,7 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
* where firmware left it. That at least has a chance of * where firmware left it. That at least has a chance of
* working, which is better than just leaving it disabled. * working, which is better than just leaving it disabled.
*/ */
if (ret < 0 && dev->fw_addr[resno]) if (ret < 0)
ret = pci_revert_fw_address(res, dev, resno, size); ret = pci_revert_fw_address(res, dev, resno, size);
if (!ret) { if (!ret) {
......
...@@ -299,7 +299,6 @@ struct pci_dev { ...@@ -299,7 +299,6 @@ struct pci_dev {
*/ */
unsigned int irq; unsigned int irq;
struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */ struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */
resource_size_t fw_addr[DEVICE_COUNT_RESOURCE]; /* FW-assigned addr */
/* These fields are used by common fixups */ /* These fields are used by common fixups */
unsigned int transparent:1; /* Transparent PCI bridge */ unsigned int transparent:1; /* Transparent PCI bridge */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment