From patchwork Wed Jul 11 09:39:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 9946 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id EF5B623E23 for ; Wed, 11 Jul 2012 09:40:09 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id B236CA195D1 for ; Wed, 11 Jul 2012 09:40:09 +0000 (UTC) Received: by ghbz12 with SMTP id z12so1054731ghb.11 for ; Wed, 11 Jul 2012 02:39:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=yWBDsa+soQaDqRSEBxw2uOjLONPxLeSD7TsJHdu86HA=; b=bgrL0KE8j676a2r6UGaRVNfTmB9KJJLgu8ZJDKceHS6c/bQQjRMYmMtmjlfQLWEZte /snLonkMmdg0uTEs9IsvT7kRytyeN58YhPC/iJ0P4fe9/Yo5zcvvqPUKGu2nD3K+qb+t 21776keX+g28i1FC06asqt16+2DSPLmZgOFx90zIsiF5BN2bwUnjTWd1uIeVy28xpvpc Bn+a9ugdaek3lCiib5GXookXGOxqK3EpajDG2BBHAw7f4NFGtSnzXZvxTEgmXjPhwNbs 1ViDO57eUpP8wWNt3IroHYnIWEc6B9QlP1V3a4Q5g44bnDCrHF/A26K45JzEdZXPIxdn 5Diw== Received: by 10.50.163.99 with SMTP id yh3mr13612809igb.53.1341999597850; Wed, 11 Jul 2012 02:39:57 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.235.202 with SMTP id kh10csp5818ibb; Wed, 11 Jul 2012 02:39:55 -0700 (PDT) Received: by 10.14.189.7 with SMTP id b7mr10899612een.126.1341999595422; Wed, 11 Jul 2012 02:39:55 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id s2si3082034wiz.17.2012.07.11.02.39.53 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 11 Jul 2012 02:39:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1SotOe-0008TL-8n; Wed, 11 Jul 2012 10:39:48 +0100 From: Peter Maydell To: linux-arm-kernel@lists.infradead.org Cc: patches@linaro.org, Will Deacon , Nicolas Pitre , Dave Martin , Rob Herring Subject: [PATCH v2] arm: Handle >4GB memory sizes in device tree and mem=size@start option Date: Wed, 11 Jul 2012 10:39:48 +0100 Message-Id: <1341999588-32544-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 X-Gm-Message-State: ALoCoQnCumOmAfZnXy8Ffw2XqMqgyJBhLUlYUeCI5rKfxGlOr7WRjesDx17ks7buWmsoqNL9azl7 The memory regions which are passed to arm_add_memory() from device tree blobs via early_init_dt_add_memory_arch() can have sizes which are larger than will fit in a 32 bit integer, so switch to using a phys_addr_t to hold them, to avoid silently dropping the top 32 bits of the size. Similarly, use phys_addr_t in early_mem() so that mem=size@start command line options specifying more than 4GB behave sensibly. Signed-off-by: Peter Maydell Acked-by: Will Deacon --- Changes v1->v2: * fixed spacing round '-' * made early_mem() handle large sizes too arch/arm/include/asm/setup.h | 4 ++-- arch/arm/kernel/setup.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h index 23ebc0c..24d284a 100644 --- a/arch/arm/include/asm/setup.h +++ b/arch/arm/include/asm/setup.h @@ -196,7 +196,7 @@ static const struct tagtable __tagtable_##fn __tag = { tag, fn } struct membank { phys_addr_t start; - unsigned long size; + phys_addr_t size; unsigned int highmem; }; @@ -217,7 +217,7 @@ extern struct meminfo meminfo; #define bank_phys_end(bank) ((bank)->start + (bank)->size) #define bank_phys_size(bank) (bank)->size -extern int arm_add_memory(phys_addr_t start, unsigned long size); +extern int arm_add_memory(phys_addr_t start, phys_addr_t size); extern void early_print(const char *str, ...); extern void dump_machine_table(void); diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index e15d83b..a81dcec 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -508,7 +508,7 @@ void __init dump_machine_table(void) /* can't use cpu_relax() here as it may require MMU setup */; } -int __init arm_add_memory(phys_addr_t start, unsigned long size) +int __init arm_add_memory(phys_addr_t start, phys_addr_t size) { struct membank *bank = &meminfo.bank[meminfo.nr_banks]; @@ -538,7 +538,7 @@ int __init arm_add_memory(phys_addr_t start, unsigned long size) } #endif - bank->size = size & PAGE_MASK; + bank->size = size & ~(phys_addr_t)(PAGE_SIZE - 1); /* * Check whether this memory region has non-zero size or @@ -558,7 +558,7 @@ int __init arm_add_memory(phys_addr_t start, unsigned long size) static int __init early_mem(char *p) { static int usermem __initdata = 0; - unsigned long size; + phys_addr_t size; phys_addr_t start; char *endp;