PCI: Don't reassign resources that are already aligned
The "pci=resource_alignment=" kernel argument designates devices for which we want alignment greater than is required by the PCI specs. Previously we set IORESOURCE_UNSET for every MEM resource of those devices, even if the resource was *already* sufficiently aligned. If a resource is already sufficiently aligned, leave it alone and don't try to reassign it. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
parent
81a5e70e0d
commit
0dde1c08d1
|
@ -5065,30 +5065,28 @@ static void pci_request_resource_alignment(struct pci_dev *dev, int bar,
|
||||||
}
|
}
|
||||||
|
|
||||||
size = resource_size(r);
|
size = resource_size(r);
|
||||||
if (size < align) {
|
if (size >= align)
|
||||||
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Increase the size of the resource. BARs are aligned on
|
* Increase the size of the resource. BARs are aligned on their
|
||||||
* their size, so when we reallocate space for this
|
* size, so when we reallocate space for this resource, we'll
|
||||||
* resource, we'll allocate it with the larger alignment.
|
* allocate it with the larger alignment. It also prevents
|
||||||
* It also prevents assignment of any other BARs inside the
|
* assignment of any other BARs inside the size. If we're
|
||||||
* size. If we're requesting page alignment, this means no
|
* requesting page alignment, this means no other BARs will share
|
||||||
* other BARs will share the page.
|
* the page.
|
||||||
*
|
*
|
||||||
* This makes the resource larger than the hardware BAR,
|
* This makes the resource larger than the hardware BAR, which may
|
||||||
* which may break drivers that compute things based on the
|
* break drivers that compute things based on the resource size,
|
||||||
* resource size, e.g., to find registers at a fixed offset
|
* e.g., to find registers at a fixed offset before the end of the
|
||||||
* before the end of the BAR. We hope users don't request
|
* BAR. We hope users don't request alignment for such devices.
|
||||||
* alignment for such devices.
|
*/
|
||||||
*/
|
dev_info(&dev->dev, "BAR%d %pR: requesting alignment to %#llx\n",
|
||||||
size = align;
|
bar, r, (unsigned long long)align);
|
||||||
dev_info(&dev->dev, "BAR%d %pR: requesting alignment to %#llx\n",
|
|
||||||
bar, r, (unsigned long long)align);
|
|
||||||
|
|
||||||
}
|
|
||||||
r->flags |= IORESOURCE_UNSET;
|
|
||||||
r->end = size - 1;
|
|
||||||
r->start = 0;
|
r->start = 0;
|
||||||
|
r->end = align - 1;
|
||||||
|
r->flags |= IORESOURCE_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue