Message ID | 20191203120447.24820-2-igor.opaniuk@gmail.com |
---|---|
State | Accepted |
Commit | 949b5a969d107613b61a1e5eaf9e43c75a97f42c |
Delegated to: | Stefano Babic |
Headers | show |
Series | android: colibri_imx7: reserve DDR memory for Cortex-M4 | expand |
On Tue, 2019-12-03 at 14:04 +0200, Igor Opaniuk wrote: > CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe. > > > From: Igor Opaniuk <igor.opaniuk@toradex.com> > > Add support for setting linux,usable-memory property in the memory > node of device tree for the kernel [1]. Isn't this same/similar to fdt_add_mem_rsv() ? Jocke
Hi Joakim, On Tue, Dec 3, 2019 at 5:02 PM Joakim Tjernlund <Joakim.Tjernlund@infinera.com> wrote: > > On Tue, 2019-12-03 at 14:04 +0200, Igor Opaniuk wrote: > > CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe. > > > > > > From: Igor Opaniuk <igor.opaniuk@toradex.com> > > > > Add support for setting linux,usable-memory property in the memory > > node of device tree for the kernel [1]. > > Isn't this same/similar to fdt_add_mem_rsv() ? I would say they are opposite :) - linux,usable-memory property let the kernel be aware about all the memory he can use. - memreserve - what memory to exclude. I think both should be helpful. > > Jocke > Thanks
diff --git a/common/fdt_support.c b/common/fdt_support.c index 6834399039..02cf5c6241 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -467,6 +467,41 @@ int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks) } return 0; } + +int fdt_set_usable_memory(void *blob, u64 start[], u64 size[], int areas) +{ + int err, nodeoffset; + int len; + u8 tmp[8 * 16]; /* Up to 64-bit address + 64-bit size */ + + if (areas > 8) { + printf("%s: num areas %d exceeds hardcoded limit %d\n", + __func__, areas, 8); + return -1; + } + + err = fdt_check_header(blob); + if (err < 0) { + printf("%s: %s\n", __func__, fdt_strerror(err)); + return err; + } + + /* find or create "/memory" node. */ + nodeoffset = fdt_find_or_add_subnode(blob, 0, "memory"); + if (nodeoffset < 0) + return nodeoffset; + + len = fdt_pack_reg(blob, tmp, start, size, areas); + + err = fdt_setprop(blob, nodeoffset, "linux,usable-memory", tmp, len); + if (err < 0) { + printf("WARNING: could not set %s %s.\n", + "reg", fdt_strerror(err)); + return err; + } + + return 0; +} #endif int fdt_fixup_memory(void *blob, u64 start, u64 size) diff --git a/include/fdt_support.h b/include/fdt_support.h index cefb2b2cce..2286ea7793 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -94,6 +94,7 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size); */ #ifdef CONFIG_ARCH_FIXUP_FDT_MEMORY int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks); +int fdt_set_usable_memory(void *blob, u64 start[], u64 size[], int banks); #else static inline int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks)