diff options
author | Nico Huber <nico.h@gmx.de> | 2020-05-24 18:32:51 +0200 |
---|---|---|
committer | Arthur Heymans <arthur@aheymans.xyz> | 2023-06-22 19:07:48 +0000 |
commit | 866eff06edb962633723295b36b89a80befb757d (patch) | |
tree | 8adb01dc872f2ee77c7310e29bddbe3fa53ce513 /src | |
parent | ee57065daddf0ae42851472e40da0b812c95a397 (diff) |
allocator_v4: Manually inline some thin functions
Inline functions that are only called once to improve readability. The
calling functions still have rather short bodies, and the reader won't
have to look down yet another layer to understand what they are doing.
Change-Id: Ib4aa5d61dfa88c804a1aaee028185e00c5fbb923
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/65422
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Diffstat (limited to 'src')
-rw-r--r-- | src/device/resource_allocator_v4.c | 68 |
1 files changed, 22 insertions, 46 deletions
diff --git a/src/device/resource_allocator_v4.c b/src/device/resource_allocator_v4.c index d17499cf89..fb0320a8eb 100644 --- a/src/device/resource_allocator_v4.c +++ b/src/device/resource_allocator_v4.c @@ -268,27 +268,6 @@ static void compute_domain_resources(const struct device *domain) } } -static unsigned char get_alignment_by_resource_type(const unsigned long type) -{ - if (type & IORESOURCE_MEM) - return 12; /* Page-aligned --> log2(4KiB) */ - else if (type & IORESOURCE_IO) - return 0; /* No special alignment required --> log2(1) */ - - die("Unexpected resource type: flags(%lu)!\n", type); -} - -static void update_constraints(struct memranges *ranges, const struct device *dev, - const struct resource *res) -{ - if (!res->size) - return; - - print_fixed_res(dev, res, __func__); - - memranges_create_hole(ranges, res->base, res->size); -} - /* * Scan the entire tree to identify any fixed resources allocated by * any device to ensure that the address map for domain resources are @@ -310,7 +289,10 @@ static void avoid_fixed_resources(struct memranges *ranges, const struct device for (res = dev->resource_list; res != NULL; res = res->next) { if ((res->flags & mask_match) != mask_match) continue; - update_constraints(ranges, dev, res); + if (!res->size) + continue; + print_fixed_res(dev, res, __func__); + memranges_create_hole(ranges, res->base, res->size); } bus = dev->link_list; @@ -321,28 +303,6 @@ static void avoid_fixed_resources(struct memranges *ranges, const struct device avoid_fixed_resources(ranges, child, mask_match); } -static void constrain_domain_resources(const struct device *domain, struct memranges *ranges, - unsigned long type) -{ - unsigned long mask_match = type | IORESOURCE_FIXED; - - if (type == IORESOURCE_IO) { - /* - * Don't allow allocations in the VGA I/O range. PCI has special - * cases for that. - */ - memranges_create_hole(ranges, 0x3b0, 0x3df - 0x3b0 + 1); - - /* - * Resource allocator no longer supports the legacy behavior where - * I/O resource allocation is guaranteed to avoid aliases over legacy - * PCI expansion card addresses. - */ - } - - avoid_fixed_resources(ranges, domain, mask_match); -} - /* * This function creates a list of memranges of given type using the * resource that is provided. It applies additional constraints to @@ -356,8 +316,10 @@ static void setup_resource_ranges(const struct device *const domain, const unsigned long type, struct memranges *const ranges) { + /* Align mem resources to 2^12 (4KiB pages) at a minimum, so they + can be memory-mapped individually (e.g. for virtualization guests). */ + const unsigned char alignment = type == IORESOURCE_MEM ? 12 : 0; const unsigned long type_mask = IORESOURCE_TYPE_MASK | IORESOURCE_FIXED; - const unsigned char alignment = get_alignment_by_resource_type(type); memranges_init_empty_with_alignment(ranges, NULL, 0, alignment); @@ -368,7 +330,21 @@ static void setup_resource_ranges(const struct device *const domain, memranges_insert(ranges, res->base, res->limit - res->base + 1, type); } - constrain_domain_resources(domain, ranges, type); + if (type == IORESOURCE_IO) { + /* + * Don't allow allocations in the VGA I/O range. PCI has special + * cases for that. + */ + memranges_create_hole(ranges, 0x3b0, 0x3df - 0x3b0 + 1); + + /* + * Resource allocator no longer supports the legacy behavior where + * I/O resource allocation is guaranteed to avoid aliases over legacy + * PCI expansion card addresses. + */ + } + + avoid_fixed_resources(ranges, domain, type | IORESOURCE_FIXED); print_resource_ranges(domain, ranges); } |