From patchwork Thu Oct 2 22:43:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dinguyen@opensource.altera.com X-Patchwork-Id: 5020641 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DA38A9FAE8 for ; Thu, 2 Oct 2014 22:49:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EC9B6201EF for ; Thu, 2 Oct 2014 22:49:38 +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 84DA4201CE for ; Thu, 2 Oct 2014 22:49:37 +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 1XZp9Q-0006dT-MH; Thu, 02 Oct 2014 22:47:08 +0000 Received: from mail-bn1on0065.outbound.protection.outlook.com ([157.56.110.65] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XZp9N-0006c4-NB for linux-arm-kernel@lists.infradead.org; Thu, 02 Oct 2014 22:47:06 +0000 Received: from BY1PR0301MB1192.namprd03.prod.outlook.com (25.160.195.150) by BY1PR0301MB0838.namprd03.prod.outlook.com (25.160.193.144) with Microsoft SMTP Server (TLS) id 15.0.1039.15; Thu, 2 Oct 2014 22:46:40 +0000 Received: from [137.57.160.210] (64.129.157.38) by BY1PR0301MB1192.namprd03.prod.outlook.com (25.160.195.150) with Microsoft SMTP Server (TLS) id 15.0.1044.10; Thu, 2 Oct 2014 22:46:38 +0000 Message-ID: <542DD4F5.1050602@opensource.altera.com> Date: Thu, 2 Oct 2014 17:43:01 -0500 From: Dinh Nguyen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: Russell King - ARM Linux Subject: Re: [PATCH] arm: socfpga: fix fetching cpu1start_addr for system with > 2GB of ram References: <1412161334-12359-1-git-send-email-dinguyen@opensource.altera.com> <20141001132057.GO5182@n2100.arm.linux.org.uk> In-Reply-To: <20141001132057.GO5182@n2100.arm.linux.org.uk> X-Originating-IP: [64.129.157.38] X-ClientProxiedBy: BLUPR08CA0049.namprd08.prod.outlook.com (10.141.200.29) To BY1PR0301MB1192.namprd03.prod.outlook.com (25.160.195.150) X-Microsoft-Antispam: UriScan:;UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BY1PR0301MB1192; X-Forefront-PRVS: 03524FBD26 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(979002)(6049001)(6009001)(76104003)(24454002)(199003)(479174003)(51914003)(189002)(377454003)(51704005)(107046002)(87976001)(120916001)(106356001)(47776003)(105586002)(31966008)(10300001)(77096002)(122386001)(20776003)(99396003)(87266999)(85852003)(64706001)(101416001)(110136001)(59896002)(65956001)(66066001)(65806001)(97736003)(102836001)(23746002)(86362001)(64126003)(50466002)(21056001)(76176999)(95666004)(46102003)(50986999)(76482002)(4396001)(65816999)(85306004)(92566001)(83506001)(33656002)(19580405001)(80316001)(42186005)(80022003)(54356999)(19580395003)(92726001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0301MB1192; H:[137.57.160.210]; FPR:; MLV:ovrnspm; PTR:InfoNoRecords; A:0; MX:1; LANG:en; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BY1PR0301MB0838; X-OriginatorOrg: opensource.altera.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141002_154705_955176_3ADF4ACE X-CRM114-Status: GOOD ( 16.21 ) X-Spam-Score: -0.2 (/) Cc: dinh.linux@gmail.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 On 10/01/2014 08:20 AM, Russell King - ARM Linux wrote: > On Wed, Oct 01, 2014 at 06:02:14AM -0500, dinguyen@opensource.altera.com wrote: >> From: Dinh Nguyen >> >> When CPU1 is brought out of reset, it's MMU is not turned yet, so it will only >> be able to use physical addresses. For systems with 1GB or less, clearing >> 0x40000000 will work just fine. However for systems with 2GB or more, we >> need to clear at least 0x80000000. >> >> Essentially, the bic instruction is converting the cpu1start_addr from a >> virtual to a physical address. We should be using bic 0xf0000000 for all >> systems. > > Err. Why not do the job properly rather than create this type of hack? > This is not a fast path, so it's really not required to code it for an > absolute minimum number of cycles. So... > > adr r0, 1f @ physical address of '1' > ldmia r0, {r1, r2} @ load virtual address of '1' and 'cpu1start_addr' > sub r0, r0, r1 @ offset between virtual and physical > ldr r2, [r2, r0] @ load *cpu1start_addr > bx r2 > ... > .align > 1: .long . > .long cpu1start_addr > > will fix it properly. > Thanks for the suggestion and the code, but it didn't seem to work for me. But I think I found a way to just load in the value of cpu1start_addr directly with this patch. Please let me know what you think of this solution: diff --git a/arch/arm/mach-socfpga/headsmp.S b/arch/arm/mach-socfpga/headsmp.S index 95c115d..3ca9ed1 100644 --- a/arch/arm/mach-socfpga/headsmp.S +++ b/arch/arm/mach-socfpga/headsmp.S @@ -13,17 +13,14 @@ .arch armv7-a ENTRY(secondary_trampoline) - movw r2, #:lower16:cpu1start_addr - movt r2, #:upper16:cpu1start_addr - - /* The socfpga VT cannot handle a 0xC0000000 page offset when loading - the cpu1start_addr, we bit clear it. Tested on HW and VT. */ - bic r2, r2, #0x40000000 - - ldr r0, [r2] + ldr r0, 1f ldr r1, [r0] bx r1 + .globl cpu1start_addr +cpu1start_addr: +1: .space 4 + ENTRY(secondary_trampoline_end) ENTRY(socfpga_secondary_startup) diff --git a/arch/arm/mach-socfpga/socfpga.c b/arch/arm/mach-socfpga/socfpga.c index adbf383..0fe1883 100644 --- a/arch/arm/mach-socfpga/socfpga.c +++ b/arch/arm/mach-socfpga/socfpga.c @@ -29,7 +29,6 @@ void __iomem *socfpga_scu_base_addr = ((void __iomem *)(SOCFPGA_SCU_VIRT_BASE)); void __iomem *sys_manager_base_addr; void __iomem *rst_manager_base_addr; -unsigned long cpu1start_addr;