Message ID | 44470619e74f3e480b70deac24578e3e0d5c907e.1651225945.git.michal.simek@amd.com |
---|---|
State | Accepted |
Commit | 9c563e916c91f8ad093e832fbe00ab12dd18ea61 |
Delegated to: | Michal Simek |
Headers | show |
Series | xilinx: Handle board_get_usable_ram_top(0) properly | expand |
pá 29. 4. 2022 v 11:52 odesílatel Michal Simek <monstr@monstr.eu> napsal: > > board_get_usable_ram_top() was designed for getting the top most location > for U-Boot allocation that's why function itself supports via total_size > parameter to find out where the right location for U-Boot is. > But function itself is also reused by different (EFI) which is passing > total_size as 0 to find out where the usable ram top is. For this case > doesn't make sense (a waste time) to call any lmb functions. > That's why simply return gd->ram_top. > > And gd->ram_top is filled already based on previous call for U-Boot iself. > The same solution is also used by stm32mp by commit 92b611e8b003 ("stm32mp: > correctly handle board_get_usable_ram_top(0)") and commit c8510e397fad > ("stm32mp: Fix board_get_usable_ram_top()"). > > Signed-off-by: Michal Simek <michal.simek@amd.com> > --- > > board/xilinx/versal/board.c | 3 +++ > board/xilinx/zynqmp/zynqmp.c | 3 +++ > 2 files changed, 6 insertions(+) > > diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c > index 2e2807eee463..a88f5bb177e2 100644 > --- a/board/xilinx/versal/board.c > +++ b/board/xilinx/versal/board.c > @@ -256,6 +256,9 @@ ulong board_get_usable_ram_top(ulong total_size) > phys_addr_t reg; > struct lmb lmb; > > + if (!total_size) > + return gd->ram_top; > + > /* found enough not-reserved memory to relocated U-Boot */ > lmb_init(&lmb); > lmb_add(&lmb, gd->ram_base, gd->ram_size); > diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c > index 41ecc9559c4b..e311aa772cce 100644 > --- a/board/xilinx/zynqmp/zynqmp.c > +++ b/board/xilinx/zynqmp/zynqmp.c > @@ -516,6 +516,9 @@ ulong board_get_usable_ram_top(ulong total_size) > phys_addr_t reg; > struct lmb lmb; > > + if (!total_size) > + return gd->ram_top; > + > if (!IS_ALIGNED((ulong)gd->fdt_blob, 0x8)) > panic("Not 64bit aligned DT location: %p\n", gd->fdt_blob); > > -- > 2.36.0 > Applied. M
diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c index 2e2807eee463..a88f5bb177e2 100644 --- a/board/xilinx/versal/board.c +++ b/board/xilinx/versal/board.c @@ -256,6 +256,9 @@ ulong board_get_usable_ram_top(ulong total_size) phys_addr_t reg; struct lmb lmb; + if (!total_size) + return gd->ram_top; + /* found enough not-reserved memory to relocated U-Boot */ lmb_init(&lmb); lmb_add(&lmb, gd->ram_base, gd->ram_size); diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 41ecc9559c4b..e311aa772cce 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -516,6 +516,9 @@ ulong board_get_usable_ram_top(ulong total_size) phys_addr_t reg; struct lmb lmb; + if (!total_size) + return gd->ram_top; + if (!IS_ALIGNED((ulong)gd->fdt_blob, 0x8)) panic("Not 64bit aligned DT location: %p\n", gd->fdt_blob);
board_get_usable_ram_top() was designed for getting the top most location for U-Boot allocation that's why function itself supports via total_size parameter to find out where the right location for U-Boot is. But function itself is also reused by different (EFI) which is passing total_size as 0 to find out where the usable ram top is. For this case doesn't make sense (a waste time) to call any lmb functions. That's why simply return gd->ram_top. And gd->ram_top is filled already based on previous call for U-Boot iself. The same solution is also used by stm32mp by commit 92b611e8b003 ("stm32mp: correctly handle board_get_usable_ram_top(0)") and commit c8510e397fad ("stm32mp: Fix board_get_usable_ram_top()"). Signed-off-by: Michal Simek <michal.simek@amd.com> --- board/xilinx/versal/board.c | 3 +++ board/xilinx/zynqmp/zynqmp.c | 3 +++ 2 files changed, 6 insertions(+)