Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp527640yba; Wed, 24 Apr 2019 05:33:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyA/8A8AHLTBqGz+CPV2lOmtli1EFZ+DY1QlUSyKpE5hUCZA1Vs5BXUQfa0n7vHkw93v73P X-Received: by 2002:a62:a513:: with SMTP id v19mr32745144pfm.212.1556109225938; Wed, 24 Apr 2019 05:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556109225; cv=none; d=google.com; s=arc-20160816; b=RcUQbqX25SDT6dcqXWX7UX5w9yd2TrMSbCYDkAwnPI3ut19y4LDm/hFxaZczD7FpmS Uin/Y6BFznb1dJjdds4jt3sfyTkROvC1G009x0kAsCjzadbzyF9fCh6nkm+RC6dw7ImQ 4RYJRGHO8+LYcuNbCw2QrXP4+/+Vz+p+Qdzewrh7epF/dU+fpavGbvcua7h628bYP/YZ qmp4431/LZeExx6UbHiuMST06TcInfoW1V1TNF1P/SXGfnbe/Vpqp9QY3m9RYKBacY5Q AxISuf1oM1hQBoDEQd4vaI745e5xqgqkR7TpQiX8kfHcLgFKqUQPoXdfpYoYT+hs0cRS G//g== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=EZ6IzYmmKbys9yVs2HMLzGHW111g9xbSAkSWR+cDcJo=; b=nGuCGoCXF7m88PdUjllPAwoEyiZPd4ApznPH11pRJQX5FcZ7QsqtT1eYjxUlsLxmO2 uWDROat8riCX18+WOFWGbqwVLa2Mz5VH14ZemBDYnN0S8wi4lSYFOTEe0a4DtTUlDH2k re4txWLj1QvVr/FrptpCRzWzysxkM8IVZ7Aij/87T8g5rONMce0mP8lDXbip/X3OzuVr dNUxAqz/rZu5KgDW0Ta4ti+UWg88TRb0mwXr/GLxsnQx5FW7qKUdAqOGLlz+q5Vo4UyC a3I5N3rJP/0SxRbVzdyjITvPM/WW2X+tQ6jDB2O0jCzgnnJu1LF8p8Jg/UwCSzV+XBV2 RDvA== 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 h10si19152996plb.348.2019.04.24.05.33.30; Wed, 24 Apr 2019 05:33:45 -0700 (PDT) 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 S1730076AbfDXMb6 (ORCPT + 99 others); Wed, 24 Apr 2019 08:31:58 -0400 Received: from foss.arm.com ([217.140.101.70]:42816 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726167AbfDXMb5 (ORCPT ); Wed, 24 Apr 2019 08:31:57 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2FFE9A78; Wed, 24 Apr 2019 05:31:57 -0700 (PDT) Received: from [10.1.196.50] (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E23AF3F238; Wed, 24 Apr 2019 05:31:55 -0700 (PDT) Subject: Re: [PATCH] ARM: mach-shmobile: Don't configure ARCH timer if PSCI is enabled To: Oleksandr , linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: horms@verge.net.au, magnus.damm@gmail.com, linux@armlinux.org.uk, Oleksandr Tyshchenko References: <1555521040-16706-1-git-send-email-olekstysh@gmail.com> <1b33dca4-e3ae-4588-05f2-37b23ac8df78@arm.com> <8c9a1480-7956-9265-14c8-3fbb472e097d@gmail.com> From: Julien Grall Message-ID: Date: Wed, 24 Apr 2019 13:31:54 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <8c9a1480-7956-9265-14c8-3fbb472e097d@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 18/04/2019 12:15, Oleksandr wrote: > > On 18.04.19 12:32, Julien Grall wrote: >>> diff --git a/arch/arm/mach-shmobile/setup-rcar-gen2.c >>> b/arch/arm/mach-shmobile/setup-rcar-gen2.c >>> index eea60b2..bac4490 100644 >>> --- a/arch/arm/mach-shmobile/setup-rcar-gen2.c >>> +++ b/arch/arm/mach-shmobile/setup-rcar-gen2.c >>> @@ -32,7 +32,7 @@ static const struct of_device_id cpg_matches[] __initconst = { >>>       { /* sentinel */ } >>>   }; >>>   -static unsigned int __init get_extal_freq(void) >>> +static unsigned int __init __maybe_unused get_extal_freq(void) >>>   { >>>       const struct of_device_id *match; >>>       struct device_node *cpg, *extal; >>> @@ -60,6 +60,12 @@ static unsigned int __init get_extal_freq(void) >>>     void __init rcar_gen2_timer_init(void) >>>   { >>> +/* >>> + * If CONFIG_PSCI is enabled then most likely we are running on PSCI-enabled >>> + * U-Boot which, we assume, has already taken care of configuring ARCH timer >>> + * stuff before switching to non-secure mode. >>> + */ >> >> I disagree with that statement. CONFIG_ARM_PSCI may be selected in your >> .config for multiple reasons: >>      - CONFIG_XEN will selected it >>      - you build a .config targeting multiple platforms >> >> Yet you may still want to boot the kernel on older U-boot. Such change would >> make it impossible. >> >> If there are code that should not be called when PSCI is used, then you need >> to make sure the function is not called at runtime. > > I got your point. > > > As I answered in a previous email: > > > But "#if !defined(CONFIG_ARM_PSCI)" wraps secure_cntvoff_init() call as > > well, which resets CNTVOFF, > > > and this is something I tried to avoid the first from being executed on > > a CPU, which is in SVC mode (when running on top of Xen). > > What would be a proper way to avoid calling secure_cntvoff_init() at runtime? > > Check that we are already in non-secure mode and/or cntvoff is already 0? CNTVOFF is controlled by the hypervisor, so you cannot access it from Dom0. If none of this code should be necessary when PSCI is enabled, then you can check the presence of PSCI (see psci_smp_available()). Another solution is to check whether we are running on xen (see xen_domain()). In any case, I would still surround the two checks because the "armgcnt" should really not be touched by Dom0. Cheers, -- Julien Grall