From ec7b31353fe2bd4b7846235fd4ba56d0ceb08196 Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Sat, 23 May 2020 18:20:47 +0200 Subject: allocator_v4: Completely ignore resources with 0 limit It seems pass 1 and 2 were inconsistent. The first would account for resources with a limit of 0 even though the second can't assign anything for them. Change-Id: I86fb8edc8d4b3c9310517e07f29f73a6b859a7c4 Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/c/coreboot/+/65402 Reviewed-by: Angel Pons Tested-by: build bot (Jenkins) Reviewed-by: Lean Sheng Tan Reviewed-by: Tim Wawrzynczak --- src/device/resource_allocator_v4.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/device/resource_allocator_v4.c b/src/device/resource_allocator_v4.c index 18667b7623..2b62fc8e2f 100644 --- a/src/device/resource_allocator_v4.c +++ b/src/device/resource_allocator_v4.c @@ -69,6 +69,10 @@ static void update_bridge_resource(const struct device *bridge, struct resource if (!child_res->size) continue; + /* Resources with 0 limit can't be assigned anything. */ + if (!child_res->limit) + continue; + /* * Propagate the resource alignment to the bridge resource. The * condition can only be true for the first (largest) resource. For all @@ -84,15 +88,14 @@ static void update_bridge_resource(const struct device *bridge, struct resource bridge_res->align = child_res->align; /* - * Propagate the resource limit to the bridge resource only if child - * resource limit is non-zero. If a downstream device has stricter - * requirements w.r.t. limits for any resource, that constraint needs to - * be propagated back up to the downstream bridges of the domain. This - * guarantees that the resource allocation which starts at the domain - * level takes into account all these constraints thus working on a - * global view. + * Propagate the resource limit to the bridge resource. If a downstream + * device has stricter requirements w.r.t. limits for any resource, that + * constraint needs to be propagated back up to the downstream bridges + * of the domain. This guarantees that the resource allocation which + * starts at the domain level takes into account all these constraints + * thus working on a global view. */ - if (child_res->limit && (child_res->limit < bridge_res->limit)) + if (child_res->limit < bridge_res->limit) bridge_res->limit = child_res->limit; /* -- cgit v1.2.3