Skip to content

Commit

Permalink
UefiPayloadPkg: FdtParserLib: Improve handling of cross-node dependency
Browse files Browse the repository at this point in the history
Again, FDTs are not meant to have strict orders. Encounter the GMA
string and PCI RB node number in any order, then handle them at the end.

Signed-off-by: Benjamin Doron <[email protected]>
  • Loading branch information
benjamindoron committed Dec 17, 2024
1 parent 891f0ba commit 1fda1d0
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions UefiPayloadPkg/Library/FdtParserLib/FdtParserLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ ParseDtb (
UINT8 NodeType;
EFI_BOOT_MODE BootMode;
CHAR8 *GmaStr;
INT32 PciRbNode;
UINT8 ReservedMemoryDepth;
INTN NumRsv;
EFI_PHYSICAL_ADDRESS Addr;
Expand All @@ -839,6 +840,8 @@ ParseDtb (
PciEnumDone = 1;
BootMode = 0;
NodeType = 0;
GmaStr = "<NULL>";
PciRbNode = 0;
ReservedMemoryDepth = 0xFF;

DEBUG ((DEBUG_INFO, "FDT = 0x%x %x\n", Fdt, Fdt32ToCpu (*((UINT32 *)Fdt))));
Expand Down Expand Up @@ -945,9 +948,8 @@ ParseDtb (
GmaStr = ParseFrameBuffer (Fdt, Node);
break;
case PciRootBridge:
DEBUG ((DEBUG_INFO, "ParsePciRootBridge, index :%x \n", index));
ParsePciRootBridge (Fdt, Node, RootBridgeCount, GmaStr, &index);
DEBUG ((DEBUG_INFO, "After ParsePciRootBridge, index :%x\n", index));
DEBUG ((DEBUG_INFO, "Found PciRootBridge\n"));
PciRbNode = Node;

This comment has been minimized.

Copy link
@dhaval-rivos

dhaval-rivos Dec 28, 2024

Contributor

This is causing issue with multiple root bridges. This is not a single run but for multiple nodes it gets called multiple times. If we really want to do this, will have to have an array of PciRbNodes and process them all together to create multiple RB entries.

break;
case Options:
// FIXME: Need to ensure this node gets parsed first so that it gets
Expand All @@ -961,6 +963,14 @@ ParseDtb (
}
}

// Post processing: TODO: Need to look into it. Such cross dependency on DT nodes
// may not be good idea
if (PciRbNode) {
DEBUG ((DEBUG_INFO, "ParsePciRootBridge, index :%x\n", index));
ParsePciRootBridge (Fdt, PciRbNode, RootBridgeCount, GmaStr, &index);
DEBUG ((DEBUG_INFO, "After ParsePciRootBridge, index :%x\n", index));
}

// Post processing: TODO: Need to look into it. Such cross dependency on DT nodes
// may not be good idea. Instead have this prop part of RB
mPciRootBridgeInfo->ResourceAssigned = (BOOLEAN)PciEnumDone;
Expand Down

0 comments on commit 1fda1d0

Please sign in to comment.