mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-03-28 01:45:45 +00:00
bootconfig: Allocate xbc_nodes array dynamically
To reduce the large static array from kernel data, allocate xbc_nodes array dynamically only if the kernel loads a bootconfig. Note that this also add dummy memblock.h for user-spacae bootconfig tool. Link: http://lkml.kernel.org/r/158108569699.3187.6512834527603883707.stgit@devnote2 Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:
parent
f61872bb58
commit
a91e4f12ff
2 changed files with 24 additions and 3 deletions
|
@ -6,12 +6,13 @@
|
||||||
|
|
||||||
#define pr_fmt(fmt) "bootconfig: " fmt
|
#define pr_fmt(fmt) "bootconfig: " fmt
|
||||||
|
|
||||||
|
#include <linux/bootconfig.h>
|
||||||
#include <linux/bug.h>
|
#include <linux/bug.h>
|
||||||
#include <linux/ctype.h>
|
#include <linux/ctype.h>
|
||||||
#include <linux/errno.h>
|
#include <linux/errno.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/memblock.h>
|
||||||
#include <linux/printk.h>
|
#include <linux/printk.h>
|
||||||
#include <linux/bootconfig.h>
|
|
||||||
#include <linux/string.h>
|
#include <linux/string.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -23,7 +24,7 @@
|
||||||
* node (for array).
|
* node (for array).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static struct xbc_node xbc_nodes[XBC_NODE_MAX] __initdata;
|
static struct xbc_node *xbc_nodes __initdata;
|
||||||
static int xbc_node_num __initdata;
|
static int xbc_node_num __initdata;
|
||||||
static char *xbc_data __initdata;
|
static char *xbc_data __initdata;
|
||||||
static size_t xbc_data_size __initdata;
|
static size_t xbc_data_size __initdata;
|
||||||
|
@ -719,7 +720,8 @@ void __init xbc_destroy_all(void)
|
||||||
xbc_data = NULL;
|
xbc_data = NULL;
|
||||||
xbc_data_size = 0;
|
xbc_data_size = 0;
|
||||||
xbc_node_num = 0;
|
xbc_node_num = 0;
|
||||||
memset(xbc_nodes, 0, sizeof(xbc_nodes));
|
memblock_free(__pa(xbc_nodes), sizeof(struct xbc_node) * XBC_NODE_MAX);
|
||||||
|
xbc_nodes = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -748,6 +750,13 @@ int __init xbc_init(char *buf)
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xbc_nodes = memblock_alloc(sizeof(struct xbc_node) * XBC_NODE_MAX,
|
||||||
|
SMP_CACHE_BYTES);
|
||||||
|
if (!xbc_nodes) {
|
||||||
|
pr_err("Failed to allocate memory for bootconfig nodes.\n");
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
memset(xbc_nodes, 0, sizeof(struct xbc_node) * XBC_NODE_MAX);
|
||||||
xbc_data = buf;
|
xbc_data = buf;
|
||||||
xbc_data_size = ret + 1;
|
xbc_data_size = ret + 1;
|
||||||
last_parent = NULL;
|
last_parent = NULL;
|
||||||
|
|
12
tools/bootconfig/include/linux/memblock.h
Normal file
12
tools/bootconfig/include/linux/memblock.h
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
/* SPDX-License-Identifier: GPL-2.0 */
|
||||||
|
#ifndef _XBC_LINUX_MEMBLOCK_H
|
||||||
|
#define _XBC_LINUX_MEMBLOCK_H
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define __pa(addr) (addr)
|
||||||
|
#define SMP_CACHE_BYTES 0
|
||||||
|
#define memblock_alloc(size, align) malloc(size)
|
||||||
|
#define memblock_free(paddr, size) free(paddr)
|
||||||
|
|
||||||
|
#endif
|
Loading…
Add table
Reference in a new issue