allocator_v4: Make it explicit that we start with the highest alignment

As we walk the results of largest_resource(), we actually know that the
condition can only be true for the first return value. So there's no
need to keep track of the first loop iteration.

Change-Id: I6d6b99e38706c0c70f3570222d97a1d71ba79744
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/65401
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Nico Huber 2020-05-23 18:15:34 +02:00 committed by Felix Held
parent b327704a3f
commit 74169c1c71
1 changed files with 6 additions and 9 deletions

View File

@ -43,7 +43,6 @@ static void update_bridge_resource(const struct device *bridge, struct resource
const struct device *child;
struct resource *child_res;
resource_t base;
bool first_child_res = true;
const unsigned long type_mask = IORESOURCE_TYPE_MASK | IORESOURCE_PREFETCH;
struct bus *bus = bridge->link_list;
@ -71,21 +70,19 @@ static void update_bridge_resource(const struct device *bridge, struct resource
continue;
/*
* Propagate the resource alignment to the bridge resource if this is
* the first child resource with non-zero size being considered. For all
* Propagate the resource alignment to the bridge resource. The
* condition can only be true for the first (largest) resource. For all
* other children resources, alignment is taken care of by updating the
* base to round up as per the child resource alignment. It is
* guaranteed that pass 2 follows the exact same method of picking the
* resource for allocation using largest_resource(). Thus, as long as
* the alignment for first child resource is propagated up to the bridge
* resource, it can be guaranteed that the alignment for all resources
* is appropriately met.
* the alignment for the largest child resource is propagated up to the
* bridge resource, it can be guaranteed that the alignment for all
* resources is appropriately met.
*/
if (first_child_res && (child_res->align > bridge_res->align))
if (child_res->align > bridge_res->align)
bridge_res->align = child_res->align;
first_child_res = false;
/*
* Propagate the resource limit to the bridge resource only if child
* resource limit is non-zero. If a downstream device has stricter