[Skiboot] [PATCH 03/10] core/device: Allow for large DT props
Matt Brown
matthew.brown.dev at gmail.com
Fri Jun 9 16:55:39 AEST 2017
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 at gmail.com>
---
core/device.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/core/device.c b/core/device.c
index 76c2f84..869deae 100644
--- a/core/device.c
+++ b/core/device.c
@@ -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);
--
2.9.3
More information about the Skiboot
mailing list