aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Kardashevskiy <aik@ozlabs.ru>2017-10-16 15:36:38 +1100
committerAlexey Kardashevskiy <aik@ozlabs.ru>2017-11-06 13:28:50 +1100
commitecda95906930b808b9dca663bb956fd91fb3fea5 (patch)
treeb09e26411804f3c7555b41636589742e44bb5aa6
parentf8d999c7d9ab44eb86f32f4ada7f98d52364bbf1 (diff)
downloadSLOF-ecda95906930b808b9dca663bb956fd91fb3fea5.zip
SLOF-ecda95906930b808b9dca663bb956fd91fb3fea5.tar.gz
SLOF-ecda95906930b808b9dca663bb956fd91fb3fea5.tar.bz2
fdt: Implement "fdt-fetch" method for client interface
The guest kernel fetches the device tree via the client interface, calling it for every node and property, and traversing the entire tree twice - first to build strings blob, second - to build struct blob. On top of that there is also not so efficient implementation of the "getprop" method - it calls slow "get-property" which does full search for a property. As the result, on a 256 CPU + 256 Intel E1000 virtual devices, the guest's flatten_device_tree() takes roughly 8.5sec. However now we have a FDT rendering helper in SLOF which takes about 350ms to render the FDT. This implements a client interface call to allow the guest to read it during early boot and save time. The produced DTB is almost the same as the guest kernel would have produced itself - the differences are: 1. SLOF creates an empty reserved map; the guest can easily fix it up later; 2. SLOF only reuses 40 most popular strings; the guest reuses everything it can - on a 256CPU + 256 PCI devices guest, the difference is about 20KB for 350KB FDT blob. Note, that the guest also ditches the "name" property just like SLOF does: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/kernel/prom_init.c?h=v4.13#n2302 Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> --- If the guest tries "fdt-fetch" and SLOF does not have it, than SLOF prints an error: === copying OF device tree... fdt-fetch NOT FOUNDBuilding dt strings... Building dt structure... === and the guest continues with the old method. We could suppress SLOF error for such unlikely situation though.
-rw-r--r--slof/fs/client.fs16
1 files changed, 16 insertions, 0 deletions
diff --git a/slof/fs/client.fs b/slof/fs/client.fs
index 7d537a6..8a7f6ac 100644
--- a/slof/fs/client.fs
+++ b/slof/fs/client.fs
@@ -308,4 +308,20 @@ ALSO client-voc DEFINITIONS
: set-callback ( newfunc -- oldfunc )
client-callback @ swap client-callback ! ;
+\ Custom method to get FDT blob
+: fdt-fetch ( buf len -- ret )
+ fdt-flatten-tree ( buf len dtb )
+ dup >r
+ >fdth_tsize l@ ( buf len size r: dtb )
+ 2dup < IF
+ ." ERROR: need " .d ." bytes, the buffer is " .d ." bytes only" cr
+ drop
+ -1
+ ELSE
+ nip r@ -rot move
+ 0
+ THEN
+ r> fdt-flatten-tree-free
+;
+
PREVIOUS DEFINITIONS