From patchwork Mon Oct 16 05:49:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 826135 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yFnVj389sz9s7h for ; Mon, 16 Oct 2017 16:50:53 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3yFnVj2CSszDrLB for ; Mon, 16 Oct 2017 16:50:53 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=ozlabs.ru (client-ip=107.173.13.209; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) Received: from ozlabs.ru (ozlabs.ru [107.173.13.209]) by lists.ozlabs.org (Postfix) with ESMTP id 3yFnT118bQzDrFx; Mon, 16 Oct 2017 16:49:24 +1100 (AEDT) Received: from vpl1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 6EC9D3A60101; Mon, 16 Oct 2017 01:48:09 -0400 (EDT) From: Alexey Kardashevskiy To: linuxppc-dev@lists.ozlabs.org Date: Mon, 16 Oct 2017 16:49:17 +1100 Message-Id: <20171016054917.21577-1-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 Subject: [SLOF] [PATCH kernel] RFC: prom_init: Fetch flatten device tree from the system firmware X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , Greg Kurz , slof@lists.ozlabs.org, Paul Mackerras MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" At the moment, on 256CPU + 256 PCI devices guest, it takes the guest about 8.5sec to read the entire device tree. Some explanation can be found here: https://patchwork.ozlabs.org/patch/826124/ but mostly it is because the kernel traverses the tree twice and it calls "getprop" for each properly which is really SLOF as it searches from the linked list beginning every time. Since SLOF has just learned to build FDT and this takes less than 0.5sec for such a big guest, this makes use of the proposed client interface method - "fdt-fetch". If "fdt-fetch" is not available, the old method is used. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/kernel/prom_init.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c index 02190e90c7ae..daa50a153737 100644 --- a/arch/powerpc/kernel/prom_init.c +++ b/arch/powerpc/kernel/prom_init.c @@ -2498,6 +2498,31 @@ static void __init flatten_device_tree(void) prom_panic("Can't allocate initial device-tree chunk\n"); mem_end = mem_start + room; + if (!call_prom_ret("fdt-fetch", 2, 1, NULL, mem_start, + room - sizeof(mem_reserve_map))) { + u32 size; + + hdr = (void *) mem_start; + + /* Fixup the boot cpuid */ + hdr->boot_cpuid_phys = cpu_to_be32(prom.cpu); + + /* Append the reserved map to the end of the blob */ + hdr->off_mem_rsvmap = hdr->totalsize; + size = be32_to_cpu(hdr->totalsize); + rsvmap = (void *) hdr + size; + hdr->totalsize = cpu_to_be32(size + sizeof(mem_reserve_map)); + memcpy(rsvmap, mem_reserve_map, sizeof(mem_reserve_map)); + + /* Store the DT address */ + dt_header_start = mem_start; + +#ifdef DEBUG_PROM + prom_printf("Fetched DTB: %d bytes to @%x\n", size, mem_start); +#endif + goto print_exit; + } + /* Get root of tree */ root = call_prom("peer", 1, 1, (phandle)0); if (root == (phandle)0) @@ -2548,6 +2573,7 @@ static void __init flatten_device_tree(void) /* Copy the reserve map in */ memcpy(rsvmap, mem_reserve_map, sizeof(mem_reserve_map)); +print_exit: #ifdef DEBUG_PROM { int i;