From patchwork Fri Feb 23 13:37:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Myl=C3=A8ne_Josserand?= X-Patchwork-Id: 10237815 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 92C4F60209 for ; Fri, 23 Feb 2018 13:59:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81897295F1 for ; Fri, 23 Feb 2018 13:59:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7616F295F5; Fri, 23 Feb 2018 13:59:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 76624295F1 for ; Fri, 23 Feb 2018 13:58:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=q2eGnsog8ZosqfX+ayt31xioTgYA5cTncEgMp3XN/1s=; b=ZmBxiVSQAYMEXW J6Pr2OYfrr0m1fWcnBOswcABozhWA22l28uHCwv0egeJlSMXASyC4W5qXBYezecs7CU/ovsudP7tY PsZOK+b7/UpyHsXu/2j58FcigHZOd0c5DmYc8PzlXI1tgOUZKDTkqruf7cJfyPH1QypRm1v41z/M/ s6IwBbjWciV0lssqXoayzdFUr7Hvtde1Xvl8oqtmv0AtofgBryGZrGWYedjKM8HkQyn7L36wZcaVU vg1RWlcjB7Yn7UxC9EzHpz6+GhVCX4HUWEYj3t4E9ZEmzx4c6XF3yDzC88Cm24mGJqjWA7jjo0Syi zlF2k8gD6D65JTsSQ8bw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1epDs3-000749-Qi; Fri, 23 Feb 2018 13:58:43 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1epDnz-0003Kl-Mq for linux-arm-kernel@bombadil.infradead.org; Fri, 23 Feb 2018 13:54:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=y6wQl8i/QERmtLCx7/qzBBnDYYhBtaGUG1U/qsRJI6E=; b=L2cXttaQoyFtgnewcR4Ds15K7H FWYynZM+U0rImnJSDPMb9T55jq5b53iKS2V3Lu+pxNMcMpB9h5naRL/darVGuL5/VzRGJ5YmXbWar KBWauZHkpCQH7/WVmjTfGiBe1PBJIkOAKJQWuhc3fx992JzD9klqCPDBMcV8VfjjlO2Tjy0vNv8AR KFiT9CWhkxyWqfFbMiyTye1ZHtmArE9aF6yqNzLDENxe1WsU/fO3t+UTRiyrJot1BdHgC+Dt0KpQW u39947/1X03osrroYIsUcCjv+TqApshdjGAZM04Mx4bPIq1J6hK4pbjowx5KdSuFEKZQ69mYanqGr JmZ5XB7Q==; Received: from mail.free-electrons.com ([62.4.15.54]) by casper.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1epDYv-0003Y0-0T for linux-arm-kernel@lists.infradead.org; Fri, 23 Feb 2018 13:39:00 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id AC6AB2091C; Fri, 23 Feb 2018 14:38:38 +0100 (CET) Received: from dell-desktop.lan (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 387892043E; Fri, 23 Feb 2018 14:38:38 +0100 (CET) From: =?UTF-8?q?Myl=C3=A8ne=20Josserand?= To: maxime.ripard@bootlin.com, linux@armlinux.org.uk, wens@csie.org, robh+dt@kernel.org, mark.rutland@arm.com Subject: [PATCH v4 10/10] ARM: sunxi: smp: Add initialization of CNTVOFF Date: Fri, 23 Feb 2018 14:37:42 +0100 Message-Id: <20180223133742.26044-11-mylene.josserand@bootlin.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180223133742.26044-1-mylene.josserand@bootlin.com> References: <20180223133742.26044-1-mylene.josserand@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180223_133857_085233_DDFEEF54 X-CRM114-Status: GOOD ( 17.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, quentin.schulz@bootlin.com, linux-kernel@vger.kernel.org, clabbe.montjoie@gmail.com, thomas.petazzoni@bootlin.com, mylene.josserand@bootlin.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On Cortex-A7, the CNTVOFF register from arch timer is uninitialized. It should be done by the bootloader but it is currently not the case, even for boot CPU because this SoC is booting in secure mode. It leads to an random offset value meaning that each CPU will have a different time, which isn't working very well. Add assembly code used for boot CPU and secondary CPU cores to make sure that the CNTVOFF register is initialized. Signed-off-by: Mylène Josserand --- arch/arm/mach-sunxi/headsmp.S | 21 +++++++++++++++++++++ arch/arm/mach-sunxi/sunxi.c | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/arch/arm/mach-sunxi/headsmp.S b/arch/arm/mach-sunxi/headsmp.S index d5c97e945e69..605896251927 100644 --- a/arch/arm/mach-sunxi/headsmp.S +++ b/arch/arm/mach-sunxi/headsmp.S @@ -65,9 +65,30 @@ ENTRY(sunxi_mc_smp_cluster_cache_enable) first: .word sunxi_mc_smp_first_comer - . ENDPROC(sunxi_mc_smp_cluster_cache_enable) +ENTRY(sunxi_init_cntvoff) + /* + * CNTVOFF has to be initialized either from non-secure Hypervisor + * mode or secure Monitor mode with SCR.NS==1. If TrustZone is enabled + * then it should be handled by the secure code + */ + cps #MON_MODE + mrc p15, 0, r1, c1, c1, 0 /* Get Secure Config */ + orr r0, r1, #1 + mcr p15, 0, r0, c1, c1, 0 /* Set Non Secure bit */ + instr_sync + mov r0, #0 + mcrr p15, 4, r0, r0, c14 /* CNTVOFF = 0 */ + instr_sync + mcr p15, 0, r1, c1, c1, 0 /* Set Secure bit */ + instr_sync + cps #SVC_MODE + ret lr +ENDPROC(sunxi_init_cntvoff) + #ifdef CONFIG_SMP ENTRY(sunxi_boot) bl sunxi_mc_smp_cluster_cache_enable + bl sunxi_init_cntvoff b secondary_startup ENDPROC(sunxi_boot) diff --git a/arch/arm/mach-sunxi/sunxi.c b/arch/arm/mach-sunxi/sunxi.c index 5e9602ce1573..4bb041492b54 100644 --- a/arch/arm/mach-sunxi/sunxi.c +++ b/arch/arm/mach-sunxi/sunxi.c @@ -37,8 +37,12 @@ static const char * const sun6i_board_dt_compat[] = { }; extern void __init sun6i_reset_init(void); +extern void sunxi_init_cntvoff(void); + static void __init sun6i_timer_init(void) { + sunxi_init_cntvoff(); + of_clk_init(NULL); if (IS_ENABLED(CONFIG_RESET_CONTROLLER)) sun6i_reset_init();