From patchwork Tue Oct 3 16:18:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 114702 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2061275qgn; Tue, 3 Oct 2017 09:18:53 -0700 (PDT) X-Received: by 10.99.36.66 with SMTP id k63mr16282500pgk.223.1507047533540; Tue, 03 Oct 2017 09:18:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507047533; cv=none; d=google.com; s=arc-20160816; b=HrZFxE/GOgSD16Zi/53gMS1nyJAZenDNVp3Y0/DxCGzLTt6RgEY4ba8i3gzzPTrggp 7ngL9S6VYEsDx7TexNL3KhAgFgNejmmqvjckxCAchEIqTqQUq4XnE0h414t0ohAVfMaE mOSct3K0UBWBQYriqzwDlHdnfocxwIt43t9YjJXQI5Pz6xGKIlsER3X5Soz1WddEVNMW rjrKFOUmmq5rMyA9EMQBi4JWtKRBlTmvdPw19nMMEpGlcgDJMJh9Nukolun7vTgtpnHk QMUKSjFf80gyUGviTy//WfbynRq3+CYLW7Wte8M6ArWyvIY08dpZaJWusJYxXU8PmQqC 5p6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=iqVy+QtjhuEVatolq/byTMQu+1ZbVzDUDVDZNfukk6E=; b=BL7SNK7/55YlIgz6psqWcWt3ih10O/27DIzA5FVyupNHNIvkUO4dKf3MkDoCCehYq5 TLrLZXETp1l4rUBvpUkagCVTroW+6zjSwjcg83cBVD8Yeub+0XbNeWIzbWFc6a9A+4x9 M7/pU4YRhRbjnDJOXrH4JF4JqWaUQWg75q+KeLIBAcNxTzDRT/q6dDQ8jAI1nLRRJXb1 RnYU8uYQ5YgeuJkNWjqV4k0Qwu71jvfLZcsrZtVmspkxjgfDhMonjA/hUhz+Bl0lAvIz 2HmKlvqRTMUiA/dUWAr+k7vBAVClcnsy2aZTtiEnu+azmP192O2xUbwZmRNgwq9b55nR r7VA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t21si10037083pfk.89.2017.10.03.09.18.53; Tue, 03 Oct 2017 09:18:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752489AbdJCQSv (ORCPT + 26 others); Tue, 3 Oct 2017 12:18:51 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:38360 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751266AbdJCQSU (ORCPT ); Tue, 3 Oct 2017 12:18:20 -0400 Received: by mail-oi0-f68.google.com with SMTP id s145so5423224oie.5; Tue, 03 Oct 2017 09:18:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=iqVy+QtjhuEVatolq/byTMQu+1ZbVzDUDVDZNfukk6E=; b=joWwX4s8+y1/vNT49vx7IdvawbmjTsBiwuKx6RQ1i12es8lCsnt5kCjnQ3sqTO36XB GuTX4j57h13YlqQy8+veeed2U4HPyqh22qL+VKPI4QbG1WtXm+zgJ5JtAc3wpv8VdEvH GPdVpI1Rcrn+EGqUckirPDuh/cwMMdXNOaal31ScoxnACpeegmEEARrqpfheC1zKj5XR WBKVh5+RnmyLuzHitTSxD4V+0zzrTw/UV/Qz1dJDz8RjOffyRg0nyc2xWnTtUDRGm1b8 HRodmJ1iZTz2W0HMF7NfPnW3QPFR8zKeE1NBhHoVX6mcF0UDFdoiUq9rnwz7N0CeWHMk NA5w== X-Gm-Message-State: AMCzsaX7oBxwaPkQfguK8+FrV9cEBf9zUKxdj40Y6ZFrd0LSn+UXZQOb rUvMc7URh45BdGza8KE6vCAKJfQ= X-Google-Smtp-Source: AOwi7QBc+fO8j65GdLOTOtUZFtT1hjyk9xiwRANH83E2fNcHyCoq4yL2cfXlK8TFXMr4YQ+XvsKqJw== X-Received: by 10.157.21.105 with SMTP id z38mr5609201otz.351.1507047499577; Tue, 03 Oct 2017 09:18:19 -0700 (PDT) Received: from localhost.localdomain (216-188-254-6.dyn.grandenetworks.net. [216.188.254.6]) by smtp.googlemail.com with ESMTPSA id y90sm4334451ota.52.2017.10.03.09.18.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Oct 2017 09:18:19 -0700 (PDT) From: Rob Herring To: devicetree@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Nicolas Pitre , Frank Rowand Subject: [PATCH 1/2] of/fdt: add of_fdt_device_is_available function Date: Tue, 3 Oct 2017 11:18:14 -0500 Message-Id: <20171003161815.25999-1-robh@kernel.org> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add an equivalent function to of_device_is_available for flattened DT, and convert the one existing open coded occurrence. Cc: Nicolas Pitre Cc: Frank Rowand Signed-off-by: Rob Herring --- drivers/of/fdt.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) -- 2.11.0 diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 27c535af0be8..f8c39705418b 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -132,6 +132,19 @@ bool of_fdt_is_big_endian(const void *blob, unsigned long node) return false; } +static bool of_fdt_device_is_available(const void *blob, unsigned long node) +{ + const char *status = fdt_getprop(blob, node, "status", NULL); + + if (!status) + return true; + + if (!strcmp(status, "ok") || !strcmp(status, "okay")) + return true; + + return false; +} + /** * of_fdt_match - Return true if node matches a list of compatible values */ @@ -605,7 +618,6 @@ static int __init __fdt_scan_reserved_mem(unsigned long node, const char *uname, int depth, void *data) { static int found; - const char *status; int err; if (!found && depth == 1 && strcmp(uname, "reserved-memory") == 0) { @@ -625,8 +637,7 @@ static int __init __fdt_scan_reserved_mem(unsigned long node, const char *uname, return 1; } - status = of_get_flat_dt_prop(node, "status", NULL); - if (status && strcmp(status, "okay") != 0 && strcmp(status, "ok") != 0) + if (!of_fdt_device_is_available(initial_boot_params, node)) return 0; err = __reserved_mem_reserve_reg(node, uname); From patchwork Tue Oct 3 16:18:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 114701 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2060938qgn; Tue, 3 Oct 2017 09:18:35 -0700 (PDT) X-Received: by 10.98.69.136 with SMTP id n8mr18049007pfi.291.1507047515406; Tue, 03 Oct 2017 09:18:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507047515; cv=none; d=google.com; s=arc-20160816; b=0SU3tqaKoyBdb0ONvt2dgLZKXpDBGfmt3YIo8F18VuBXkprWWSdIscRXIKD4S0fBkP FkVk/wr/K+lEia1lD2wVdCGZJT1ovrY9h14ASfjzhWgCoKQAm6T68VsI3kJzWQVIHySO D1SbKx9JicfKVugqUSyYk3tMhTEBFcKq7tlmGP23lTDyIvDRz4BhY2oI78pvYX0XltAG IekcigK+2DMa2pH0f3xiCuPzNQyMF2ClTaEAgdn5jJGk47CqTL+cnQNL599+qTMJyYbU P70GqU7IigTnvlF94q2R9kihTO8YZnwhCA8NFO6VRuPTi7UR6FYC5Jr+GawO7ARAYlRN yD1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=TpkveIpqbX3wzWd+pKDV3srAxDl9TUuj3UR8Nw0b7LI=; b=kxgm1tCLanzp/38ybPfGiEmsUXjBrY5knJMubvw+R5IzA9CX0KbwzE2+GFVYW1D5qx uBFszhi9S6/mK6Xc8mYlGqz5JMNCwwf9V8wr+wrc7HtK2VCZqtZj3xKmhfS6zYLJCOQI GcOstq/kFRSWmQl2ragobcWfq6ZCe6H8d6Jche7H643ZBXb+5fG05SoDDUgogos+OtC7 EteGxMGqVG8Ht7ZY4obGz01tm2yjo/myX9f+DrWlyqYXy/ka/fEV87anN4RM0L08pGYl f502btefQeP0vikR0sfmgHb2C2fvJjjL+v/ICmpFeFaDm34Y+mrf/JcOb7B8CI2+SXaU vrUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 32si6595533ple.704.2017.10.03.09.18.35; Tue, 03 Oct 2017 09:18:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752410AbdJCQSd (ORCPT + 26 others); Tue, 3 Oct 2017 12:18:33 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:50734 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751409AbdJCQSV (ORCPT ); Tue, 3 Oct 2017 12:18:21 -0400 Received: by mail-oi0-f66.google.com with SMTP id y64so15173486oia.7; Tue, 03 Oct 2017 09:18:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TpkveIpqbX3wzWd+pKDV3srAxDl9TUuj3UR8Nw0b7LI=; b=bhagOhMmfVOU7FhDwZnylpJs+SNqME+br8QYVCJ3loVo9bE51X/CU+ck2uoHdDbF1c hf9AWR4dRdQAfvUbdqP6dW3HQU7XPaavR7NNzj23MIlzN09JCeRiU6aWFpoPNsKOYoBh PXaLGIB6TyFGbvO58MFsLBsq9STMJhSeN9m99NWm6kjWiK37Qyq7vTxMPgkro6yH80HY wHWDLU4RK7NuAzQWxfcTquWOyeIsE4WVxJ6ulCcY7lftoSZgK4BXWsoJzXcHsK6wYwl3 UGG7/3zkENm+SOXSsgWQ2nZVgIhhIsx+iXaN204dKyZPZOZlpmuDSetmRyKj0lADFfEY PWDA== X-Gm-Message-State: AMCzsaW37skcL04F+wgKOevl11BoCiIwjp7tzt+1sDUYe6nJXoJsbDAF fVu9m2XKStAS629AX7G/xaMWd7Q= X-Google-Smtp-Source: AOwi7QBIRKPsPWTe25bzxmO6Qjp7aGmnoiULD5fX+umEnsK159ZONHOn6lgwiFig9r6Wx2OHBd5UKA== X-Received: by 10.202.253.213 with SMTP id b204mr3691031oii.101.1507047500669; Tue, 03 Oct 2017 09:18:20 -0700 (PDT) Received: from localhost.localdomain (216-188-254-6.dyn.grandenetworks.net. [216.188.254.6]) by smtp.googlemail.com with ESMTPSA id y90sm4334451ota.52.2017.10.03.09.18.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Oct 2017 09:18:20 -0700 (PDT) From: Rob Herring To: devicetree@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Nicolas Pitre , Frank Rowand Subject: [PATCH 2/2] of/fdt: skip unflattening of disabled nodes Date: Tue, 3 Oct 2017 11:18:15 -0500 Message-Id: <20171003161815.25999-2-robh@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171003161815.25999-1-robh@kernel.org> References: <20171003161815.25999-1-robh@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For static DT usecases, we don't need the disabled nodes and can skip unflattening. This saves a significant amount of RAM in memory constrained cases. In one example on STM32F469, the RAM usage goes from 118K to 26K. There are a few cases in the kernel that modify the status property dynamically. These all are changes from enabled to disabled, depend on OF_DYNAMIC or are not FDT based (PDT based). Cc: Nicolas Pitre Cc: Frank Rowand Signed-off-by: Rob Herring --- For more background, see this presentation from Nico: https://connect.linaro.org/resource/sfo17/sfo17-100/ drivers/of/fdt.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.11.0 diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index f8c39705418b..efe91c6856a0 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -396,6 +396,10 @@ static int unflatten_dt_nodes(const void *blob, if (WARN_ON_ONCE(depth >= FDT_MAX_DEPTH)) continue; + if (!IS_ENABLED(CONFIG_OF_DYNAMIC) && + !of_fdt_device_is_available(blob, offset)) + continue; + if (!populate_node(blob, offset, &mem, nps[depth], &nps[depth+1], dryrun)) return mem - base;