device_util,agesa/family14: Do not consider unassigned resources in find_pci_tolm()

This change updates find_pci_tolm() to not consider any unassigned
resources. This is achieved by adding the following checks:
1. Call search_bus_resources() with mask set to IORESOURCE_MEM |
IORESOURCE_ASSIGNED.
2. In the callback tolm_test, check that the new resource selected has
a non-zero size.

This change is being made so that the resource allocator does not have
to set the IORESOURCE_ASSIGNED flag for marking a resource as
invalid.

Change-Id: I796784dd93aa165e20a672c985b4875991901c87
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/41524
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
Furquan Shaikh 2020-05-18 16:00:53 -07:00 committed by Patrick Georgi
parent f531244d20
commit afaae8aa00
2 changed files with 11 additions and 3 deletions

View File

@ -883,6 +883,13 @@ void tolm_test(void *gp, struct device *dev, struct resource *new)
best = *best_p; best = *best_p;
/*
* If resource is not allocated any space i.e. size is zero,
* then do not consider this resource in tolm calculations.
*/
if (new->size == 0)
return;
if (!best || (best->base > new->base)) if (!best || (best->base > new->base))
best = new; best = new;
@ -893,9 +900,9 @@ u32 find_pci_tolm(struct bus *bus)
{ {
struct resource *min = NULL; struct resource *min = NULL;
u32 tolm; u32 tolm;
unsigned long mask_match = IORESOURCE_MEM | IORESOURCE_ASSIGNED;
search_bus_resources(bus, IORESOURCE_MEM, IORESOURCE_MEM, search_bus_resources(bus, mask_match, mask_match, tolm_test, &min);
tolm_test, &min);
tolm = 0xffffffffUL; tolm = 0xffffffffUL;

View File

@ -284,8 +284,9 @@ static void amdfam14_link_read_bases(struct device *dev, u32 nodeid, u32 link)
static u32 my_find_pci_tolm(struct bus *bus, u32 tolm) static u32 my_find_pci_tolm(struct bus *bus, u32 tolm)
{ {
struct resource *min; struct resource *min;
unsigned long mask_match = IORESOURCE_MEM | IORESOURCE_ASSIGNED;
min = 0; min = 0;
search_bus_resources(bus, IORESOURCE_MEM, IORESOURCE_MEM, tolm_test, search_bus_resources(bus, mask_match, mask_match, tolm_test,
&min); &min);
if (min && tolm > min->base) { if (min && tolm > min->base) {
tolm = min->base; tolm = min->base;