@@ -376,11 +376,19 @@ struct dt_node *dt_find_by_phandle(struct dt_node *root, u32 phandle)
return NULL;
}
+/* Any property larger than MAX_ALLOC will be allocated using local_alloc */
+#define MAX_MALLOC 1048576
+
static struct dt_property *new_property(struct dt_node *node,
const char *name, size_t size)
{
- struct dt_property *p = malloc(sizeof(*p) + size);
char *path;
+ struct dt_property *p;
+
+ if (size > MAX_MALLOC)
+ p = local_alloc(0, sizeof(*p)+size, 0x10000);
+ else
+ p = malloc(sizeof(*p) + size);
if (!p) {
path = dt_get_path(node);
As the skiboot heap is only 16MB, we cannot allocate large amounts of memory using malloc. By using local_alloc we can allocate beyond the skiboot heap. This is useful for allocating large DT properties. Any DT properties with size > 1MB will now be allocated using local_alloc instead of malloc. Signed-off-by: Matt Brown <matthew.brown.dev@gmail.com> --- core/device.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)