From patchwork Thu Jul 26 13:59:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Tomsich X-Patchwork-Id: 949688 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=theobroma-systems.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41btyn3hfGz9rxx for ; Fri, 27 Jul 2018 00:00:17 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 1EC4AC21DFA; Thu, 26 Jul 2018 14:00:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id E2FB4C21C3F; Thu, 26 Jul 2018 14:00:08 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 10081C21CB6; Thu, 26 Jul 2018 14:00:08 +0000 (UTC) Received: from mail.theobroma-systems.com (vegas.theobroma-systems.com [144.76.126.164]) by lists.denx.de (Postfix) with ESMTPS id 825C1C21C3F for ; Thu, 26 Jul 2018 14:00:07 +0000 (UTC) Received: from [86.59.122.178] (port=35020 helo=android.lan) by mail.theobroma-systems.com with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA256:128) (Exim 4.80) (envelope-from ) id 1figoF-0006jj-JL; Thu, 26 Jul 2018 16:00:03 +0200 From: Philipp Tomsich To: u-boot@lists.denx.de Date: Thu, 26 Jul 2018 15:59:43 +0200 Message-Id: <1532613591-8444-2-git-send-email-philipp.tomsich@theobroma-systems.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1532613591-8444-1-git-send-email-philipp.tomsich@theobroma-systems.com> References: <1532613591-8444-1-git-send-email-philipp.tomsich@theobroma-systems.com> Cc: Vagrant Cascadian , Carlo Caione , Andy Yan , Maxime Ripard Subject: [U-Boot] [PATCH 1/9] dm: allow 4GB of DRAM on 32bit systems X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Even on 32bit systems a full 4GB of DRAM may be installed and reported by the DRAM controller. Whether these 4GB are larger available depends on the size/configuration of address decoding windows and architectural features (e.g. consider a hypothetical architecture that uses dedicated instructions to access the 'memory-mapped' peripheral IO ranges). In U-Boot, the available DRAM, as reported by the device-model is independent of the accessible DRAM (i.e. adjusted top and effective size). This was first reported against the RK3288, which may have 4GB DRAM attached, but will have a small (e.g. 128MB) window not accessible due to address decoding limitations. The solution is to increase the types used for storing the ram_size to have at least 33 bits even on 32bit systems... i.e. we need to use a u64 for these always (this was previously only the case for PHYS_64BIT, which will have unwanted side-effects for 32bit systems and would require more intrusive changes). This commit changes the size-field in 'struct ram' and the ram_size in 'gd' to be a u64. Reported-by: Marty E. Plummer Signed-off-by: Philipp Tomsich Reviewed-by: Simon Glass --- include/asm-generic/global_data.h | 2 +- include/ram.h | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 0fd4900..f3d687c 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -55,7 +55,7 @@ typedef struct global_data { unsigned long ram_base; /* Base address of RAM used by U-Boot */ unsigned long ram_top; /* Top address of RAM used by U-Boot */ unsigned long relocaddr; /* Start address of U-Boot in RAM */ - phys_size_t ram_size; /* RAM size */ + u64 ram_size; /* RAM size */ unsigned long mon_len; /* monitor len */ unsigned long irq_sp; /* irq stack pointer */ unsigned long start_addr_sp; /* start_addr_stackpointer */ diff --git a/include/ram.h b/include/ram.h index 67e22d7..1fe024f 100644 --- a/include/ram.h +++ b/include/ram.h @@ -9,7 +9,14 @@ struct ram_info { phys_addr_t base; - size_t size; + /* + * We use a 64bit type for the size to correctly handle 32bit + * systems with 4GB of DRAM (which would overflow a 32bit type + * and read back as 0). For 64bit systems, we assume (for now) + * that they will always have less than 2^65 byte of DRAM + * installed. -- prt + */ + u64 size; }; struct ram_ops {