From 74169c1c71b69b19b64d692fc16da35afe51a55b Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Sat, 23 May 2020 18:15:34 +0200 Subject: allocator_v4: Make it explicit that we start with the highest alignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/65401 Tested-by: build bot (Jenkins) Reviewed-by: Kyösti Mälkki Reviewed-by: Angel Pons --- src/device/resource_allocator_v4.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/device/resource_allocator_v4.c b/src/device/resource_allocator_v4.c index 707ccf0a96..18667b7623 100644 --- a/src/device/resource_allocator_v4.c +++ b/src/device/resource_allocator_v4.c @@ -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 -- cgit v1.2.3