Received: by 10.223.185.116 with SMTP id b49csp715116wrg; Fri, 23 Feb 2018 05:46:08 -0800 (PST) X-Google-Smtp-Source: AH8x224XkPVSq3yxMtkfo7BUat+qgmH7mQF2IvAHzeOn1B8kiD9iDFIZ5FvA4FxxlDNfiZlotP3m X-Received: by 2002:a17:902:5269:: with SMTP id z96-v6mr1775668plh.385.1519393567968; Fri, 23 Feb 2018 05:46:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519393567; cv=none; d=google.com; s=arc-20160816; b=QRZD6i/xvLSLX2fclaYMZHxRi5u2YXsTP0UnPFB3l2A4nzHeIhR+fX/d/+HVjsPDLz 5DylHEK0/znqXAuNLAst/+YLHY1v9hF3cp1VTj2FnnpUe/ZbmG3P3hQj+lab3IWujCOX fMtKm1sMoDr3Z2Enk3WrvdrOVrHQMq6PY9sf05xmW/l0n9LYuT/CHkogwaD5XUmVygY+ Qh64jB76U781zrx0ofI2hjHja1qr6Dtim9PfXyhmNiPUIVnPsOARtZ8gVCyJPm3CojEJ YY+DAWobxgFu4rbmQ2qmnik0O1rvOSq0kFq95enb619bH55EPLMdkojXRR98m4u15utt g2xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=y6wQl8i/QERmtLCx7/qzBBnDYYhBtaGUG1U/qsRJI6E=; b=Nm5RCgEwI164Si3HZOEEKPjm4npdZ48lb93phLrVvhPBz/B7gKT8ZYYcicA7jQBytX WkszWvwcTXwitivA2t/u0zwRS2OmC3lt75VdE9x1Pm4Xzga0ldu7ODh7P3wClI8QXUrV 42MLB1qZXiuk3NjOwe/Knhxg6kQZFYP6OD+R2vshjVFlrhSMHSQEBXTkuThhsNeAlVKj tueT4X+Ii5+JBMLyWJunfR2Xkftl9xYaay4XS4YSTERSki/UTf+o1QB33mIr9Hpe3J5z ekhR46OXwWFTA41ZgngdfjlLJ5xJzWqB5W3IUZaVzzJhZacG7vEIDJMUZI1UEnEMXVo0 Wyhg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f17si1547904pge.270.2018.02.23.05.45.53; Fri, 23 Feb 2018 05:46:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751715AbeBWNou (ORCPT + 99 others); Fri, 23 Feb 2018 08:44:50 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:48948 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751863AbeBWNil (ORCPT ); Fri, 23 Feb 2018 08:38:41 -0500 Received: by mail.free-electrons.com (Postfix, from userid 110) id AC6AB2091C; Fri, 23 Feb 2018 14:38:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 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 Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, clabbe.montjoie@gmail.com, thomas.petazzoni@bootlin.com, mylene.josserand@bootlin.com, quentin.schulz@bootlin.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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(); -- 2.11.0