diff mbox

[RFC,1/7] devicetree: Add 8k instead of double dtb size when reserving extra memory

Message ID 20100407041002.20274.51604.stgit@angua
State New
Headers show

Commit Message

Grant Likely April 7, 2010, 4:10 a.m. UTC
If a small 'seed' dtb file is loaded into qemu and then heavily modified
(say for runtime population of all the device nodes), then 2x the dtb
size turns out not to be very much.

This patch changes the device tree loading code to add a fixed 8k of
additional space to the dtb buffer.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---

 device_tree.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Comments

Paul Brook April 9, 2010, noon UTC | #1
> If a small 'seed' dtb file is loaded into qemu and then heavily modified
> (say for runtime population of all the device nodes), then 2x the dtb
> size turns out not to be very much.
> 
> This patch changes the device tree loading code to add a fixed 8k of
> additional space to the dtb buffer.

In that case you almost certainly want double+8k. Or have the calleee tell you 
how much they're expecting to grow the tree.

Paul
Grant Likely April 9, 2010, 2:55 p.m. UTC | #2
On Fri, Apr 9, 2010 at 6:00 AM, Paul Brook <paul@codesourcery.com> wrote:
>> If a small 'seed' dtb file is loaded into qemu and then heavily modified
>> (say for runtime population of all the device nodes), then 2x the dtb
>> size turns out not to be very much.
>>
>> This patch changes the device tree loading code to add a fixed 8k of
>> additional space to the dtb buffer.
>
> In that case you almost certainly want double+8k. Or have the calleee tell you
> how much they're expecting to grow the tree.

Good point.  I think I like the latter option.

g.
diff mbox

Patch

diff --git a/device_tree.c b/device_tree.c
index 426a631..bad4810 100644
--- a/device_tree.c
+++ b/device_tree.c
@@ -41,8 +41,8 @@  void *load_device_tree(const char *filename_path, int *sizep)
         goto fail;
     }
 
-    /* Expand to 2x size to give enough room for manipulation.  */
-    dt_size *= 2;
+    /* Expand size to give enough room for manipulation.  */
+    dt_size += 8 * 1024;
     /* First allocate space in qemu for device tree */
     fdt = qemu_mallocz(dt_size);