Commit bd064f0a authored by Bjorn Helgaas's avatar Bjorn Helgaas

PCI: Mark resources as IORESOURCE_UNSET if we can't assign them

When assigning addresses to resources, mark them with IORESOURCE_UNSET
before we start and clear IORESOURCE_UNSET if assignment is successful.
That means that if we print the resource during assignment, we will show
the size, not a meaningless address.

Also, clear IORESOURCE_UNSET if we do assign an address, so we print the
address when it is valid.
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent f44116ae
...@@ -4244,6 +4244,7 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev) ...@@ -4244,6 +4244,7 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
"Rounding up size of resource #%d to %#llx.\n", "Rounding up size of resource #%d to %#llx.\n",
i, (unsigned long long)size); i, (unsigned long long)size);
} }
r->flags |= IORESOURCE_UNSET;
r->end = size - 1; r->end = size - 1;
r->start = 0; r->start = 0;
} }
...@@ -4257,6 +4258,7 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev) ...@@ -4257,6 +4258,7 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
r = &dev->resource[i]; r = &dev->resource[i];
if (!(r->flags & IORESOURCE_MEM)) if (!(r->flags & IORESOURCE_MEM))
continue; continue;
r->flags |= IORESOURCE_UNSET;
r->end = resource_size(r) - 1; r->end = resource_size(r) - 1;
r->start = 0; r->start = 0;
} }
......
...@@ -296,6 +296,7 @@ static void quirk_s3_64M(struct pci_dev *dev) ...@@ -296,6 +296,7 @@ static void quirk_s3_64M(struct pci_dev *dev)
struct resource *r = &dev->resource[0]; struct resource *r = &dev->resource[0];
if ((r->start & 0x3ffffff) || r->end != r->start + 0x3ffffff) { if ((r->start & 0x3ffffff) || r->end != r->start + 0x3ffffff) {
r->flags |= IORESOURCE_UNSET;
r->start = 0; r->start = 0;
r->end = 0x3ffffff; r->end = 0x3ffffff;
} }
...@@ -937,6 +938,8 @@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_FE_GATE_700C ...@@ -937,6 +938,8 @@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_FE_GATE_700C
static void quirk_dunord(struct pci_dev *dev) static void quirk_dunord(struct pci_dev *dev)
{ {
struct resource *r = &dev->resource [1]; struct resource *r = &dev->resource [1];
r->flags |= IORESOURCE_UNSET;
r->start = 0; r->start = 0;
r->end = 0xffffff; r->end = 0xffffff;
} }
...@@ -1740,6 +1743,7 @@ static void quirk_tc86c001_ide(struct pci_dev *dev) ...@@ -1740,6 +1743,7 @@ static void quirk_tc86c001_ide(struct pci_dev *dev)
struct resource *r = &dev->resource[0]; struct resource *r = &dev->resource[0];
if (r->start & 0x8) { if (r->start & 0x8) {
r->flags |= IORESOURCE_UNSET;
r->start = 0; r->start = 0;
r->end = 0xf; r->end = 0xf;
} }
...@@ -1769,6 +1773,7 @@ static void quirk_plx_pci9050(struct pci_dev *dev) ...@@ -1769,6 +1773,7 @@ static void quirk_plx_pci9050(struct pci_dev *dev)
dev_info(&dev->dev, dev_info(&dev->dev,
"Re-allocating PLX PCI 9050 BAR %u to length 256 to avoid bit 7 bug\n", "Re-allocating PLX PCI 9050 BAR %u to length 256 to avoid bit 7 bug\n",
bar); bar);
r->flags |= IORESOURCE_UNSET;
r->start = 0; r->start = 0;
r->end = 0xff; r->end = 0xff;
} }
......
...@@ -197,8 +197,10 @@ void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom) ...@@ -197,8 +197,10 @@ void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom)
void pci_cleanup_rom(struct pci_dev *pdev) void pci_cleanup_rom(struct pci_dev *pdev)
{ {
struct resource *res = &pdev->resource[PCI_ROM_RESOURCE]; struct resource *res = &pdev->resource[PCI_ROM_RESOURCE];
if (res->flags & IORESOURCE_ROM_COPY) { if (res->flags & IORESOURCE_ROM_COPY) {
kfree((void*)(unsigned long)res->start); kfree((void*)(unsigned long)res->start);
res->flags |= IORESOURCE_UNSET;
res->flags &= ~IORESOURCE_ROM_COPY; res->flags &= ~IORESOURCE_ROM_COPY;
res->start = 0; res->start = 0;
res->end = 0; res->end = 0;
......
...@@ -263,6 +263,7 @@ int pci_assign_resource(struct pci_dev *dev, int resno) ...@@ -263,6 +263,7 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
resource_size_t align, size; resource_size_t align, size;
int ret; int ret;
res->flags |= IORESOURCE_UNSET;
align = pci_resource_alignment(dev, res); align = pci_resource_alignment(dev, res);
if (!align) { if (!align) {
dev_info(&dev->dev, "BAR %d: can't assign %pR " dev_info(&dev->dev, "BAR %d: can't assign %pR "
...@@ -282,6 +283,7 @@ int pci_assign_resource(struct pci_dev *dev, int resno) ...@@ -282,6 +283,7 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
ret = pci_revert_fw_address(res, dev, resno, size); ret = pci_revert_fw_address(res, dev, resno, size);
if (!ret) { if (!ret) {
res->flags &= ~IORESOURCE_UNSET;
res->flags &= ~IORESOURCE_STARTALIGN; res->flags &= ~IORESOURCE_STARTALIGN;
dev_info(&dev->dev, "BAR %d: assigned %pR\n", resno, res); dev_info(&dev->dev, "BAR %d: assigned %pR\n", resno, res);
if (resno < PCI_BRIDGE_RESOURCES) if (resno < PCI_BRIDGE_RESOURCES)
...@@ -297,6 +299,7 @@ int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsiz ...@@ -297,6 +299,7 @@ int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsiz
resource_size_t new_size; resource_size_t new_size;
int ret; int ret;
res->flags |= IORESOURCE_UNSET;
if (!res->parent) { if (!res->parent) {
dev_info(&dev->dev, "BAR %d: can't reassign an unassigned resource %pR " dev_info(&dev->dev, "BAR %d: can't reassign an unassigned resource %pR "
"\n", resno, res); "\n", resno, res);
...@@ -307,6 +310,7 @@ int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsiz ...@@ -307,6 +310,7 @@ int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsiz
new_size = resource_size(res) + addsize; new_size = resource_size(res) + addsize;
ret = _pci_assign_resource(dev, resno, new_size, min_align); ret = _pci_assign_resource(dev, resno, new_size, min_align);
if (!ret) { if (!ret) {
res->flags &= ~IORESOURCE_UNSET;
res->flags &= ~IORESOURCE_STARTALIGN; res->flags &= ~IORESOURCE_STARTALIGN;
dev_info(&dev->dev, "BAR %d: reassigned %pR\n", resno, res); dev_info(&dev->dev, "BAR %d: reassigned %pR\n", resno, res);
if (resno < PCI_BRIDGE_RESOURCES) if (resno < PCI_BRIDGE_RESOURCES)
......
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