9
0
Fork 0

of: speed up unflatten

We calculate the full path of the current node using fdt_get_path which
takes a lot of time since libfdt has to iterate over the dtb several times.
Speed this up by creating and using a of_find_child function which does
not have to iterate over the whole tree but only over its direct children.
On an i.MX51 board this speeds up unflatten the tree from 60ms to 3.7ms.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2013-01-11 16:33:18 +01:00
parent db474fe0bb
commit 555dc6cc60
1 changed files with 22 additions and 7 deletions

View File

@ -854,6 +854,27 @@ int of_probe(void)
return 0;
}
static struct device_node *of_find_child(struct device_node *node, const char *name)
{
struct device_node *_n;
if (!root_node)
return NULL;
if (!node && !*name)
return root_node;
if (!node)
node = root_node;
list_for_each_entry(_n, &node->children, parent_list) {
if (!strcmp(_n->name, name))
return _n;
}
return NULL;
}
/*
* Parse a flat device tree binary blob and store it in the barebox
* internal tree format,
@ -871,8 +892,6 @@ int of_unflatten_dtb(struct fdt_header *fdt)
int depth = 10000;
struct device_node *node = NULL, *n;
struct property *p;
char buf[1024];
int ret;
nodeoffset = fdt_path_offset(fdt, "/");
if (nodeoffset < 0) {
@ -893,11 +912,7 @@ int of_unflatten_dtb(struct fdt_header *fdt)
if (pathp == NULL)
pathp = "/* NULL pointer error */";
ret = fdt_get_path(fdt, nodeoffset, buf, 1024);
if (ret)
return -EINVAL;
n = of_find_node_by_path(buf);
n = of_find_child(node, pathp);
if (n) {
node = n;
} else {