From patchwork Wed May 7 05:16:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 4125541 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 74A31BFF02 for ; Wed, 7 May 2014 05:19:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A99DB202B8 for ; Wed, 7 May 2014 05:19:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CF020202AE for ; Wed, 7 May 2014 05:19:15 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WhuDf-0000s4-82; Wed, 07 May 2014 05:16:39 +0000 Received: from seldrel01.sonyericsson.com ([212.209.106.2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WhuDc-0000jC-5s for linux-arm-kernel@lists.infradead.org; Wed, 07 May 2014 05:16:36 +0000 From: Bjorn Andersson To: Russell King , , Subject: [PATCH] ARM: zImage: Allow DTB to override broken ATAG_MEM Date: Tue, 6 May 2014 22:16:16 -0700 Message-ID: <1399439776-18535-1-git-send-email-bjorn.andersson@sonymobile.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140506_221636_410155_71818433 X-CRM114-Status: GOOD ( 11.41 ) X-Spam-Score: -5.0 (-----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Support overriding ATAG_MEM, by specifying non-zero content of the /memory/reg property in the appended DTB. This is needed to work around bootloaders passing broken tags. Signed-off-by: Bjorn Andersson --- arch/arm/boot/compressed/atags_to_fdt.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c index d1153c8..b534cd6 100644 --- a/arch/arm/boot/compressed/atags_to_fdt.c +++ b/arch/arm/boot/compressed/atags_to_fdt.c @@ -95,6 +95,22 @@ static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline) setprop_string(fdt, "/chosen", "bootargs", cmdline); } +static int fdt_overrides_atag_mem(void *fdt) +{ + const char *memory; + int len = 0; + + memory = getprop(fdt, "/memory", "reg", &len); + if (memory) { + while (len--) { + if (*memory != '\0') + return 1; + } + } + + return 0; +} + /* * Convert and fold provided ATAGs into the provided FDT. * @@ -180,7 +196,7 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space) } } - if (memcount) { + if (memcount && !fdt_overrides_atag_mem(fdt)) { setprop(fdt, "/memory", "reg", mem_reg_property, 4 * memcount * memsize); }