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