MLK-21885 lmb: Handle the overlap case for lmb reserve
authorYe Li <ye.li@nxp.com>
Wed, 5 Jun 2019 06:33:38 +0000 (23:33 -0700)
committerYe Li <ye.li@nxp.com>
Thu, 6 Jun 2019 02:34:23 +0000 (19:34 -0700)
commit37d86c68816dffde3dc8dcda5b9d67a195b2f9c2
tree3c4a8582d2911b57c0ddd126551214440451b6bc
parent297a924ddaf456a5a175d9056c0bc45116cc49ce
MLK-21885 lmb: Handle the overlap case for lmb reserve

lmb reserve is used to reserve some memory so that when loading images
(like kernel, dtb, initrd), images won't be loaded into the reserved memory.

The problem in current lmb is it does not handle the overlap case. When adding
a new reserved memory, if the memory region is overlap with regions already been
added in lmb, it will fail. One example is reserved memory in DTB may overlap with
u-boot relocate address. lmb reserves the u-boot relocate address firstly, so when
adding reserved memory from DTB, we will meet failure.

Actually if we handle the overlap case, we can resolve the overlap by using a max
common region for the overlap regions. So that this case won't fail.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
lib/lmb.c