allocator_v4: Introduce RESOURCE_ALLOCATION_TOP_DOWN

Add option to resource allocator v4 that restores the top-down
allocation approach at the domain level.

This makes it easier to handle 64-bit resources natively. With
the top-down approach, resources that can be placed either above
or below 4G would be placed above, to save precious space below
the 4G boundary.

Change-Id: Iaf463d3e6b37d52e46761d8e210034fded58a8a4
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/41957
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
Reviewed-by: Subrata Banik <subratabanik@google.com>
This commit is contained in:
Nico Huber
2020-05-25 00:03:14 +02:00
committed by Martin L Roth
parent 38688519cf
commit 526c64249a
5 changed files with 72 additions and 34 deletions

View File

@@ -933,6 +933,11 @@ config RESOURCE_ALLOCATOR_V4
ranges for allocating resources. This allows allocation of resources
above 4G boundary as well.
config RESOURCE_ALLOCATION_TOP_DOWN
bool "Allocate resources from top down"
default y
depends on RESOURCE_ALLOCATOR_V4
config XHCI_UTILS
def_bool n
help

View File

@@ -372,6 +372,9 @@ static void print_resource_ranges(const struct device *dev, const struct memrang
static void allocate_child_resources(struct bus *bus, struct memranges *ranges,
unsigned long type_mask, unsigned long type_match)
{
const bool allocate_top_down =
bus->dev->path.type == DEVICE_PATH_DOMAIN &&
CONFIG(RESOURCE_ALLOCATION_TOP_DOWN);
struct resource *resource = NULL;
const struct device *dev;
@@ -381,7 +384,7 @@ static void allocate_child_resources(struct bus *bus, struct memranges *ranges,
continue;
if (memranges_steal(ranges, resource->limit, resource->size, resource->align,
type_match, &resource->base) == false) {
type_match, &resource->base, allocate_top_down) == false) {
printk(BIOS_ERR, " ERROR: Resource didn't fit!!! ");
printk(BIOS_DEBUG, " %s %02lx * size: 0x%llx limit: %llx %s\n",
dev_path(dev), resource->index,