From patchwork Thu Dec 15 03:27:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 705951 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3tfJtP4YPrz9snk for ; Thu, 15 Dec 2016 14:33:01 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="gS/HUi7G"; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E24B74BDBD; Thu, 15 Dec 2016 04:30:32 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Z-9aE0Qp_2wz; Thu, 15 Dec 2016 04:30:32 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 54A47B38A4; Thu, 15 Dec 2016 04:29:52 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0C5EDB3872 for ; Thu, 15 Dec 2016 04:29:38 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 22mgZSxs_i6w for ; Thu, 15 Dec 2016 04:29:37 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-io0-f174.google.com (mail-io0-f174.google.com [209.85.223.174]) by theia.denx.de (Postfix) with ESMTPS id 82FCEB3850 for ; Thu, 15 Dec 2016 04:29:15 +0100 (CET) Received: by mail-io0-f174.google.com with SMTP id 136so58389479iou.3 for ; Wed, 14 Dec 2016 19:29:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=w0YauV/uLd4OvCJr9kaimVK8PfVVtgBPh2gVHLXvOPg=; b=gS/HUi7GX8Z6SREjM0hhtoR/otBxU8BGwrr400nX2/Q0wA/57EPzUL/Kg09QiTymHx phP2YpNfR9Si2myxyKAt2KN5DUjuEtO0sDw83ZyNehOeWqZ1SbmTWXZM+6K/IUhfIJc6 6/J+nIhZAXzwspTnGtq7knSzN3AIhzJYhn2gRnV/dH6YosxrbIKYt6GKoZgplkPN42NU nvpZCkLMnvsOCLEqymgWpbL6cVJ91tvFKlAYFQ+kli7D4BRMe6LXz69cSWYOf/IeYeOX zgF5cWczF9X5Helr5/+I9twoBIJL3Wg8HojrthOw7073l5ffcPtvzTSbw0KSfFLUHnXT 1zlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=w0YauV/uLd4OvCJr9kaimVK8PfVVtgBPh2gVHLXvOPg=; b=HSmhwOQStBot6eKrFNYcxyBiHEchlMB2CATe46hJKYz2/AGM0IWKbBeA2Bvw3cXjkm 9Rach1OfpSRE1hHbyZW5ZORihX7hasIDq56QSQ8R88LTRhvPeCvvCuRinQUL3b4vKtvZ yoAskIMwLUrOvZm0zPLz9rsFoA7Connj1AYjC0KoEHYyKFCvkMRMUNsilidDLdJbBh8S DSsYi1zBppiwfb+mYU+RTLippQb6i5KfJ7OGc+Xb/knKGlQnmLsZz8kHlpT6nagbNDef 7KTuUcF5xWP7qTBYrEJ9P5soZv6UEu/Mb/wA0/i5faE60IYkb3lkIrApCXHtnKWOTfF1 fgfg== X-Gm-Message-State: AKaTC01/is8/dKgjhwAI2JkQx1LOpL0/pDZw1YyzI4uJVEWfhQxqE3C7bMfAAzifAo//0p2n X-Received: by 10.107.133.76 with SMTP id h73mr649262iod.148.1481772553711; Wed, 14 Dec 2016 19:29:13 -0800 (PST) Received: from kaki.bld.corp.google.com ([100.100.197.46]) by smtp.gmail.com with ESMTPSA id m4sm191789iom.20.2016.12.14.19.29.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Dec 2016 19:29:13 -0800 (PST) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 5F8A040378; Wed, 14 Dec 2016 20:29:12 -0700 (MST) From: Simon Glass To: U-Boot Mailing List Date: Wed, 14 Dec 2016 20:27:52 -0700 Message-Id: <1481772480-29544-22-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1481772480-29544-1-git-send-email-sjg@chromium.org> References: <1481772480-29544-1-git-send-email-sjg@chromium.org> Cc: Mike Frysinger Subject: [U-Boot] [PATCH 21/29] blackfin: Copy the device tree out of BSS X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Blackfin currently uses BSS variables before location. The device tree overlaps with the BSS region, meaning that it gets overwritten by any BSS variable accesses. To work around this, copy it out of the way early in boot. The correct fix would be to adjust blackfin to avoid using BSS so early, but this is a large amount of work and involves testing on many boards. This solution is much more prudent for now. Signed-off-by: Simon Glass --- arch/blackfin/cpu/cpu.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/blackfin/cpu/cpu.c b/arch/blackfin/cpu/cpu.c index a8aaee4..d039c4f 100644 --- a/arch/blackfin/cpu/cpu.c +++ b/arch/blackfin/cpu/cpu.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -296,6 +297,20 @@ void cpu_init_f(ulong bootflag, ulong loaded_from_ldr) memcpy(&_sdata_l1, &_data_l1_lma, (unsigned long)_data_l1_len); } + /* + * Blackfin uses the BSS section before relcation. This is where the + * device tree is located, so we must relocate it before any BSS + * variables are used (e.g. bfin_poweron_retx, below). Copy it to + * the end of BSS. + */ + if (IS_ENABLED(CONFIG_OF_CONTROL)) { + const void *blob = &_image_binary_end; + int fdt_size = fdt_totalsize(blob); + + memcpy(__bss_stop, blob, fdt_size); + gd->fdt_blob = __bss_stop; + } + memset(__bss_start, '\0', __bss_stop - __bss_start); /*