Skip to content

Commit 14c8530

Browse files
Alanbjorn-helgaas
authored andcommitted
PCI: Support BAR sizes up to 8GB
This is needed for some of the Xeon Phi type systems. [bhelgaas: added Nikhil, use ARRAY_SIZE() to connect with decl, folded in Kevin's "order < 0" fix to ARRAY_SIZE() usage] Signed-off-by: Nikhil P Rao <[email protected]> Signed-off-by: Alan Cox <[email protected]> Signed-off-by: Kevin Hilman <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent e4c7296 commit 14c8530

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

drivers/pci/setup-bus.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
921921
{
922922
struct pci_dev *dev;
923923
resource_size_t min_align, align, size, size0, size1;
924-
resource_size_t aligns[12]; /* Alignments from 1Mb to 2Gb */
924+
resource_size_t aligns[14]; /* Alignments from 1Mb to 8Gb */
925925
int order, max_order;
926926
struct resource *b_res = find_free_bus_resource(bus, type);
927927
unsigned int mem64_mask = 0;
@@ -957,19 +957,24 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
957957
continue;
958958
}
959959
#endif
960-
/* For bridges size != alignment */
960+
/*
961+
* aligns[0] is for 1MB (since bridge memory
962+
* windows are always at least 1MB aligned), so
963+
* keep "order" from being negative for smaller
964+
* resources.
965+
*/
961966
align = pci_resource_alignment(dev, r);
962967
order = __ffs(align) - 20;
963-
if (order > 11) {
968+
if (order < 0)
969+
order = 0;
970+
if (order >= ARRAY_SIZE(aligns)) {
964971
dev_warn(&dev->dev, "disabling BAR %d: %pR "
965972
"(bad alignment %#llx)\n", i, r,
966973
(unsigned long long) align);
967974
r->flags = 0;
968975
continue;
969976
}
970977
size += r_size;
971-
if (order < 0)
972-
order = 0;
973978
/* Exclude ranges with size > align from
974979
calculation of the alignment. */
975980
if (r_size == align)

0 commit comments

Comments
 (0)