mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 13:31:02 +07:00
PCI: Refactor pbus_size_mem()
The original idea comes from Ram Pai. This patch puts the chunk of code for calculating the minimal alignment of memory window into a separate inline function. Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
parent
462d930306
commit
c121504e89
@ -812,6 +812,28 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline resource_size_t calculate_mem_align(resource_size_t *aligns,
|
||||||
|
int max_order)
|
||||||
|
{
|
||||||
|
resource_size_t align = 0;
|
||||||
|
resource_size_t min_align = 0;
|
||||||
|
int order;
|
||||||
|
|
||||||
|
for (order = 0; order <= max_order; order++) {
|
||||||
|
resource_size_t align1 = 1;
|
||||||
|
|
||||||
|
align1 <<= (order + 20);
|
||||||
|
|
||||||
|
if (!align)
|
||||||
|
min_align = align1;
|
||||||
|
else if (ALIGN(align + min_align, min_align) < align1)
|
||||||
|
min_align = align1 >> 1;
|
||||||
|
align += aligns[order];
|
||||||
|
}
|
||||||
|
|
||||||
|
return min_align;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pbus_size_mem() - size the memory window of a given bus
|
* pbus_size_mem() - size the memory window of a given bus
|
||||||
*
|
*
|
||||||
@ -891,20 +913,8 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
|
|||||||
children_add_size += get_res_add_size(realloc_head, r);
|
children_add_size += get_res_add_size(realloc_head, r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
align = 0;
|
|
||||||
min_align = 0;
|
|
||||||
for (order = 0; order <= max_order; order++) {
|
|
||||||
resource_size_t align1 = 1;
|
|
||||||
|
|
||||||
align1 <<= (order + 20);
|
|
||||||
|
|
||||||
if (!align)
|
|
||||||
min_align = align1;
|
|
||||||
else if (ALIGN(align + min_align, min_align) < align1)
|
|
||||||
min_align = align1 >> 1;
|
|
||||||
align += aligns[order];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
min_align = calculate_mem_align(aligns, max_order);
|
||||||
min_align = max(min_align, window_alignment(bus, b_res->flags & mask));
|
min_align = max(min_align, window_alignment(bus, b_res->flags & mask));
|
||||||
size0 = calculate_memsize(size, min_size, 0, resource_size(b_res), min_align);
|
size0 = calculate_memsize(size, min_size, 0, resource_size(b_res), min_align);
|
||||||
if (children_add_size > add_size)
|
if (children_add_size > add_size)
|
||||||
|
Loading…
Reference in New Issue
Block a user