Received: by 10.223.185.116 with SMTP id b49csp815699wrg; Fri, 23 Feb 2018 07:14:45 -0800 (PST) X-Google-Smtp-Source: AH8x225th8o53ejbzmjClSFB9LuqOXfbeB618m4g6Pz+oJt1X1rMkuhMhiaomPFoXKNmbFYGaH8S X-Received: by 2002:a17:902:bb06:: with SMTP id l6-v6mr2023420pls.115.1519398885637; Fri, 23 Feb 2018 07:14:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519398885; cv=none; d=google.com; s=arc-20160816; b=RQDo4SrwLgqFIwZZo9pk7ELCeWlQvccuDZ1AfODwJ+FfsuAHFQz4cLM8jRYYVmgnmH +5NrnTB2+KSUf7op3ZQTiSxFXWljPNLHb44dfBLDJb9DeZPSXXYkX4lkqw9QViGY9VuI 0wX/RFBVmc2CCyK5wfyi/uhIiSQd6qVCNA86XYse/H5RYNOXA9w4JRXPbQd+esPSt239 JYYRF6rVa3keGMlwd92hqEFQ2Lm84zteA0VTWnmfE8i6+9GfFG/m6BLKo7uDBbSMfwTw AvT4wYZ1B4hxYIbf1sXH345o0B0Zi7Jl6hAelhsyMsj27COuEQ/6OXN4hn3mqZHy1LA5 Yl5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=gChEyYTro+HOCwt9dw46nKs45V8RAGsAT0huZC0gfmc=; b=fjnDqpKDO56NjDnC206crDOH1N7RVMN2iuE4visDwPdE7fR9YP0MaTSgi+xhoDpgTH 3UCv53I1R7JnpKPo7RfvWSN5VDgXinIsKcWQ4DCEOX5JvCR6sk8Yjg3/uK0u0W6DYU0q 4f+MuwK7H9LZPQf7dRGo7yZieUGKET/NC6E6vv6LEK+hLKoBrzxxLW0Fws4pizbgyu9v gtgTFICWZimg1Sd6tP5YfxDLX/Z1iaFk354eohIdjkLeJGBW85BqDj2SW0QxUykBD9dV 4aqPZMK99d2mZjNUqpKZXzp5VqBMWlVfWMeMKZuoMWZimQKTBo82qA4+2dd7eymKEMnK 5hgA== 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 n3-v6si1884311pld.347.2018.02.23.07.14.29; Fri, 23 Feb 2018 07:14:45 -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 S1751803AbeBWPMS (ORCPT + 99 others); Fri, 23 Feb 2018 10:12:18 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:53370 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751408AbeBWPMQ (ORCPT ); Fri, 23 Feb 2018 10:12:16 -0500 Received: by mail.free-electrons.com (Postfix, from userid 110) id 66CB62082B; Fri, 23 Feb 2018 16:12:13 +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 localhost (unknown [185.94.189.188]) by mail.free-electrons.com (Postfix) with ESMTPSA id D859E20146; Fri, 23 Feb 2018 16:12:12 +0100 (CET) Date: Fri, 23 Feb 2018 16:12:13 +0100 From: Maxime Ripard To: =?iso-8859-1?Q?Myl=E8ne?= Josserand Cc: linux@armlinux.org.uk, wens@csie.org, robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, clabbe.montjoie@gmail.com, thomas.petazzoni@bootlin.com, quentin.schulz@bootlin.com Subject: Re: [PATCH v4 10/10] ARM: sunxi: smp: Add initialization of CNTVOFF Message-ID: <20180223151213.inrk7ghl6z3pbcol@flea.lan> References: <20180223133742.26044-1-mylene.josserand@bootlin.com> <20180223133742.26044-11-mylene.josserand@bootlin.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ulfzt5j6yrqtig2w" Content-Disposition: inline In-Reply-To: <20180223133742.26044-11-mylene.josserand@bootlin.com> User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --ulfzt5j6yrqtig2w Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Feb 23, 2018 at 02:37:42PM +0100, Myl=E8ne Josserand wrote: > 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. >=20 > Add assembly code used for boot CPU and secondary CPU cores to make > sure that the CNTVOFF register is initialized. >=20 > Signed-off-by: Myl=E8ne Josserand > --- > arch/arm/mach-sunxi/headsmp.S | 21 +++++++++++++++++++++ > arch/arm/mach-sunxi/sunxi.c | 4 ++++ > 2 files changed, 25 insertions(+) >=20 > 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) > =20 > +ENTRY(sunxi_init_cntvoff) > + /* > + * CNTVOFF has to be initialized either from non-secure Hypervisor > + * mode or secure Monitor mode with SCR.NS=3D=3D1. If TrustZone is enab= led > + * 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 =3D 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) > =20 > 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[] =3D { > }; > =20 > extern void __init sun6i_reset_init(void); > +extern void sunxi_init_cntvoff(void); > + > static void __init sun6i_timer_init(void) > { > + sunxi_init_cntvoff(); > + This would deserve a comment explaining why this is needed in the first place, and this is not correct. All the other SoCs listed in that machine have their CNTVOFF setup correctly on CPU0, and since Linux is booted in HYP, it's probably not even valid to do that. Maxime --=20 Maxime Ripard, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com --ulfzt5j6yrqtig2w Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEE0VqZU19dR2zEVaqr0rTAlCFNr3QFAlqQL0wACgkQ0rTAlCFN r3SspBAAi6rjoChO+AIbsyvs22zukl8PstofUuTy35osW5dX0s9aHc3XiZ8gUaRd 1IdxK8z7sn6aAnW4Y2DUMaLvE1/LhExRT/qKJMj0hPUYdU/h0NvabMhsMNkUH7XC 0FtcWWuEViSeJo60Ym92/9IFq1ueXYfDYJsBj3cr0B5AXzjwYIpz0FQdKnvcELG/ tYdtdnRLwvyM45BbEJLRGLxvxbIM6aCgTRHH0BY4bSCGe7fj7PP2Lub6Jb5QYT31 Oq3fyxkhb+WV+O+8+v2i6qLFdtz59jMyy3VUqVAZXIl4kH9wTFBnlZr3frJAkRj/ yQG0umjmUty4xSfv/qB5q91s5nqnAsqKaUuVLK+YK/kqYyHJ9RRaFwaIG960OoBr J65D+MjWUlwpQqc18ttBcPFzSy6RLxU7kXnMoxjGF72vVE3E7QMjR8nXfUVGsSOV aeuTuzueKe1tcBQtjAmPca+QOC8ZMZk2bWGndyOaXl0e1pfBoH3XYjd7pOrj1Pq8 SuUnCSZtGnftdysu+i42n9lR1PoEBCwINr601PIQFGoezRlCmrc2x5Ju3MF3QQu2 mPhc9onrwjFAgxWvLcgxyh5CxbPF8Y8IAUv31esv4aifq4eojZbLH3pW6V4Hl/DT /nxB4M89ZjwzYxdD+ZVQUymkQk5TdyTYxL1BdnQVyFIcKlsc6/o= =NQiv -----END PGP SIGNATURE----- --ulfzt5j6yrqtig2w--