From patchwork Thu Jul 7 15:50:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 953372 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p67G0h6D023638 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 7 Jul 2011 16:01:05 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QeqyB-000290-61; Thu, 07 Jul 2011 15:58:27 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qeqvj-000692-FU; Thu, 07 Jul 2011 15:55:55 +0000 Received: from service88.mimecast.com ([195.130.217.12]) by canuck.infradead.org with smtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qeqv6-0005J5-RC for linux-arm-kernel@lists.infradead.org; Thu, 07 Jul 2011 15:55:18 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Thu, 07 Jul 2011 16:51:59 +0100 Received: from e102568-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 7 Jul 2011 16:50:49 +0100 From: Lorenzo Pieralisi To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 07/17] ARM: kernel: save/restore v7 assembly helpers Date: Thu, 7 Jul 2011 16:50:20 +0100 Message-Id: <1310053830-23779-8-git-send-email-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1310053830-23779-1-git-send-email-lorenzo.pieralisi@arm.com> References: <1310053830-23779-1-git-send-email-lorenzo.pieralisi@arm.com> X-OriginalArrivalTime: 07 Jul 2011 15:50:49.0498 (UTC) FILETIME=[A49A8FA0:01CC3CBD] X-MC-Unique: 111070716515909401 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110707_115517_596198_3ADECAFE X-CRM114-Status: GOOD ( 14.77 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [195.130.217.12 listed in list.dnswl.org] Cc: Kevin Hilman , Lorenzo Pieralisi , Russell King , Catalin Marinas , Amit Kucheria , Frank Hofmann , Magnus Damm , Santosh Shilimkar , Amit Kachhap , Colin Cross , Linaro Dev X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 07 Jul 2011 16:01:05 +0000 (UTC) This patch provides v7 assembly functions to disable-clean-invalidate D$ and programme the SCU CPU power status register. The function to disable/clean/invalidate D$ is just a shim that clears the C bit and jump to the respective function defined in proc info. SCU CPU power mode is there to programme the register from an MMU off path where the C environment is not up and running. Using scu_power_mode(...) is not possible, or at least hairy, since it relies on the smp_processor_id() (so the kernel stack) to be up and running, and it might not access any static data (since gcc inserts virtual addresses constants into the code, making it impossible to call when MMU is off and virtual translation is still not up and running). Signed-off-by: Lorenzo Pieralisi --- arch/arm/kernel/sr_v7_helpers.S | 47 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 47 insertions(+), 0 deletions(-) create mode 100644 arch/arm/kernel/sr_v7_helpers.S diff --git a/arch/arm/kernel/sr_v7_helpers.S b/arch/arm/kernel/sr_v7_helpers.S new file mode 100644 index 0000000..6443918 --- /dev/null +++ b/arch/arm/kernel/sr_v7_helpers.S @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2008-2011 ARM Ltd + * + * Author(s): Jon Callan, Lorenzo Pieralisi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include +#include + + .text + @ this function disables data caching, then cleans and invalidates + @ the whole data cache. Apart from the preamble to clear the C bit it + @ uses kernel flushing function provided for v7 + +ENTRY(disable_clean_inv_dcache_v7_all) + ARM( stmfd sp!, {r4-r5, r7, r9-r11, lr} ) + THUMB( stmfd sp!, {r4-r7, r9-r11, lr} ) + + dsb + mrc p15, 0, r3, c1, c0, 0 + bic r3, #4 @ clear C bit + mcr p15, 0, r3, c1, c0, 0 + dsb + + bl v7_flush_dcache_all + ARM( ldmfd sp!, {r4-r5, r7, r9-r11, lr} ) + THUMB( ldmfd sp!, {r4-r7, r9-r11, lr} ) + mov pc, lr +ENDPROC(disable_clean_inv_dcache_v7_all) + + @ Resetting the SCU CPU power register when the MMU is off + @ must be done in assembly since the C environment is not + @ set-up yet +ENTRY(scu_cpu_mode) + ALT_SMP(mrc p15, 0, r2, c0, c0, 5) + ALT_UP(mov r2, #0) + and r2, r2, #15 + strb r1, [r0, r2] + mov pc, lr +ENDPROC(scu_cpu_mode) + .end +