From patchwork Thu Apr 21 02:55:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 66281 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp2851855qge; Wed, 20 Apr 2016 22:58:45 -0700 (PDT) X-Received: by 10.28.147.8 with SMTP id v8mr12109203wmd.92.1461218325728; Wed, 20 Apr 2016 22:58:45 -0700 (PDT) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id k15si12852198wmh.107.2016.04.20.22.58.45; Wed, 20 Apr 2016 22:58:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D86CEA780C; Thu, 21 Apr 2016 07:49:08 +0200 (CEST) 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 0FVR1y99L3cv; Thu, 21 Apr 2016 07:49:08 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DD002A7686; Thu, 21 Apr 2016 07:44:20 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9B195A75E1 for ; Thu, 21 Apr 2016 04:55:33 +0200 (CEST) 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 CeYwRbTk-H0z for ; Thu, 21 Apr 2016 04:55:33 +0200 (CEST) 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 conuserg-07.nifty.com (conuserg-07.nifty.com [210.131.2.74]) by theia.denx.de (Postfix) with ESMTPS id 9D868A760C for ; Thu, 21 Apr 2016 04:54:43 +0200 (CEST) Received: from beagle.diag.org (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id u3L2sQao017163; Thu, 21 Apr 2016 11:54:29 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com u3L2sQao017163 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1461207269; bh=YcUuHsrs6KEruPVWJGKcoWygfPB7++JlnznySvNSEFw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bej8uzp2WxUnXYfF/VJb7QaG3AyIkxod7R8pKkYVjTTe2939agnJAdIl33tbpcTIS qtLothWi1E+tuyBGLUvTfWdG4xuByFZ5zJa1cjyBK+q9Gnd6YFs9lbxRmwDX9TVwEv LZOUvx1aQVQwbZ5LTqDlJOy/Cj7fFXt7HFqKwNcvBjjTUsoADgz7BZcjKwGpBH6ikF EZgBqBDo4jQIuCKiyQJIwVRPRbXpwtShHB91JQMn2hq2lz0h81sSqiro1lCGlTDFoM BCO7gVCPwubjm+36ZNHxgRx3T6kVMBvXVZozhOXFbkw28mG+kxUquGAX0WtHNP3tbS lFYRAoyxxNETg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Thu, 21 Apr 2016 11:55:06 +0900 Message-Id: <1461207314-32272-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461207314-32272-1-git-send-email-yamada.masahiro@socionext.com> References: <1461207314-32272-1-git-send-email-yamada.masahiro@socionext.com> Subject: [U-Boot] [PATCH v3 03/11] ARM: uniphier: avoid unaligned access to DT on 64bit SoC 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" Because DT properties are 4-byte aligned, the pointer access *(fdt64_t *) in this code causes unaligned access. Signed-off-by: Masahiro Yamada --- Changes in v3: None Changes in v2: None arch/arm/mach-uniphier/dram_init.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) -- 1.9.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot diff --git a/arch/arm/mach-uniphier/dram_init.c b/arch/arm/mach-uniphier/dram_init.c index 815f243..ef0e2e8 100644 --- a/arch/arm/mach-uniphier/dram_init.c +++ b/arch/arm/mach-uniphier/dram_init.c @@ -6,6 +6,7 @@ #include #include +#include #include DECLARE_GLOBAL_DATA_PTR; @@ -40,8 +41,7 @@ int dram_init(void) val += ac; - gd->ram_size = sc == 2 ? fdt64_to_cpu(*(fdt64_t *)val) : - fdt32_to_cpu(*val); + gd->ram_size = fdtdec_get_number(val, sc); debug("DRAM size = %08lx\n", (unsigned long)gd->ram_size); @@ -71,11 +71,9 @@ void dram_init_banksize(void) for (i = 0; i < CONFIG_NR_DRAM_BANKS && len >= cells; i++, len -= cells) { - gd->bd->bi_dram[i].start = ac == 2 ? - fdt64_to_cpu(*(fdt64_t *)val) : fdt32_to_cpu(*val); + gd->bd->bi_dram[i].start = fdtdec_get_number(val, ac); val += ac; - gd->bd->bi_dram[i].size = sc == 2 ? - fdt64_to_cpu(*(fdt64_t *)val) : fdt32_to_cpu(*val); + gd->bd->bi_dram[i].size = fdtdec_get_number(val, sc); val += sc; debug("DRAM bank %d: start = %08lx, size = %08lx\n",