Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp472655yba; Fri, 3 May 2019 05:29:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvdk29R8MG8DhjwJHRPEkHDAOCh4uWCsPiXNRTVz6Cgo1I/pLUCoBDPf/WuqZ0lozxHAwU X-Received: by 2002:a63:e406:: with SMTP id a6mr10102830pgi.132.1556886555465; Fri, 03 May 2019 05:29:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556886555; cv=none; d=google.com; s=arc-20160816; b=xEvihCxg6pHXlxNExxHE194m/mr9NDZblarKMBQRn+9KwyR7xK9yRru7nyPe1U5dge 8WdIconn0VVBsgTPBpeHw5BUZELL5b5pVDPV19L01ogpggwxrT7DU+l5fae0p3GSOAs8 vVurxhNXeq9OJsqlC5XJ0s/3HQ5m/z/kNUEkSXdz1Ak6Dxfw2zlt4ai3SRdJXsym8dLi fLzWwp1cxVsNvoOhdtnD+HFsVAxHU8PIcyfmdkjX6o/yRkuW3pNhtbx4zNaU3wjHQPVm W9+KvjTR2BZOjpIQ0WMPn3NHS48/N8w+M+YLFfXdcEZUn2eUfjSWXO2ewWS03xfnQqHV Ss5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=GDiBzSj4s/zGBV/+MMNhWpQAi3gkIAYNBVktbdFKSgw=; b=AqmAqOj8wUEUre392YhGxONazZJo4X6NW5fMaMZL7gtinXgOsxLIWPU7p8NjJk6ppt 2IVGPFCcEaBnhkQWRBXCyfU0kZ05W0kBsAFKrOio3BpYcMTB+ORGsXUWl4CTFTuZeLyI BmEc8+UPMMcw6zLEKiVGLK8aAKwEFDYtVtpNipUYUHO56llib1Oeuj54LIQE0LAEryvC YZZuvCzawy0cnjqQygxnRsfE6cxQXfIEesftp9CpkPXvExo97jVQm1f8ychKE9QW04YH NN4Z6QN0CvL5YP87BqA8m6rfyXN6LywUG3NDff90gt5C28qzNyrgCbGDsUt4zOP3JKfy 6jKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZCsrwsTS; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3si2241887pld.425.2019.05.03.05.28.59; Fri, 03 May 2019 05:29:15 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZCsrwsTS; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727559AbfECM2J (ORCPT + 99 others); Fri, 3 May 2019 08:28:09 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:45306 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726047AbfECM2I (ORCPT ); Fri, 3 May 2019 08:28:08 -0400 Received: by mail-lj1-f193.google.com with SMTP id w12so5016374ljh.12; Fri, 03 May 2019 05:28:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=GDiBzSj4s/zGBV/+MMNhWpQAi3gkIAYNBVktbdFKSgw=; b=ZCsrwsTS2xpFfckVXsgcYwTbevaFBpmuAtPyYh/AlT7a064cvWcOGOMSm2JediMlzR fLvxowlzmy3ahD4X0FVY62lr3IhpOK3Se/C3fnRq8gnQrA2t6MwbWBOVRh0zWraGBiaf 9m1yLzrM1MONeXbI3aJVuJdQ4MYtFIW4Lin9fiiR5cB/d3DguKEireYtvi8SryIXqQ3N 98sxP+P3WaBMzOsP98j0HtRmyY7sEXSTstSPyUvAk4tY620NebwV01nTriPR+fPW4TSu rI+car/C+XaPozjD4BPgF4EzLpBYIgMDxsAzYK4SQbkOjZJZEUi8pR8r2nOtwh+uZQ8r qlZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=GDiBzSj4s/zGBV/+MMNhWpQAi3gkIAYNBVktbdFKSgw=; b=q0d8MgiO4e7jcRRzwUI8U49FFUpmef9p7GWH6JJutG8deRVJ17/L21jpgvtQ3/J27Z jB2vbLR7PLfRwu+9VKFWTMf8XNNEl/Q6foGIEu+v4f9kANyNk/E/pfRQysSKzOdgUTxp BtASqneDmjiXtbmHsHIxH7GOcbvvzoOpbXhgwaR/BkNlm/c999ZCO4hawzZ+oo3+FFeS fD1bxuUyLrT9jUHLbNnig2IlFs9TUM1qPbzT2VYsSkD1nhNYkB2cXki+BQHGw3FT6LKg apDzPKkXBS08hB+95EsESlHWaU1eLLYNKFBk/eHpLWh5DO6wtcPnX0VTUKbx0jAyQ/82 dsTg== X-Gm-Message-State: APjAAAWhgsKsuR78npV1ugwlAdJT+t3riBfokC2qWDIFDwoDy+XE6K1A IKsv2UL2xanXR9pxPFNhhS0= X-Received: by 2002:a2e:8446:: with SMTP id u6mr5024354ljh.71.1556886485682; Fri, 03 May 2019 05:28:05 -0700 (PDT) Received: from [10.17.182.120] (ll-74.141.223.85.sovam.net.ua. [85.223.141.74]) by smtp.gmail.com with ESMTPSA id b29sm405382lfo.38.2019.05.03.05.28.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 May 2019 05:28:04 -0700 (PDT) Subject: Re: [PATCH V2] ARM: mach-shmobile: Don't init CNTVOFF if PSCI is available To: Geert Uytterhoeven Cc: Linux-Renesas , Linux Kernel Mailing List , Julien Grall , Simon Horman , Magnus Damm , Russell King , Biju Das , Oleksandr Tyshchenko References: <1556882268-27451-1-git-send-email-olekstysh@gmail.com> From: Oleksandr Message-ID: Date: Fri, 3 May 2019 15:28:03 +0300 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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03.05.19 14:38, Geert Uytterhoeven wrote: > Hi Oleksandr, Hi Geert > > On Fri, May 3, 2019 at 1:21 PM Oleksandr Tyshchenko wrote: >> From: Oleksandr Tyshchenko >> >> If PSCI is available then most likely we are running on PSCI-enabled >> U-Boot which, we assume, has already taken care of resetting CNTVOFF >> before switching to non-secure mode and we don't need to. >> >> Also, don't init CNTVOFF if we are running on top of Xen hypervisor, >> as CNTVOFF is controlled by hypervisor itself and shouldn't be touched >> by Dom0 in such case. >> >> Signed-off-by: Oleksandr Tyshchenko >> CC: Julien Grall > Thanks for your patch! Thank you for review! > >> --- >> You can find previous discussion here: >> https://lkml.org/lkml/2019/4/17/810 >> >> Changes in v2: >> - Clarify patch subject/description >> - Don't use CONFIG_ARM_PSCI option, check whether the PSCI is available, >> by using psci_smp_available() >> - Check whether we are running on top of Xen, by using xen_domain() >> --- >> arch/arm/mach-shmobile/setup-rcar-gen2.c | 13 ++++++++++++- >> 1 file changed, 12 insertions(+), 1 deletion(-) >> >> diff --git a/arch/arm/mach-shmobile/setup-rcar-gen2.c b/arch/arm/mach-shmobile/setup-rcar-gen2.c >> index eea60b2..bc8537b 100644 >> --- a/arch/arm/mach-shmobile/setup-rcar-gen2.c >> +++ b/arch/arm/mach-shmobile/setup-rcar-gen2.c >> @@ -17,7 +17,9 @@ >> #include >> #include >> #include >> +#include >> #include >> +#include >> #include >> #include "common.h" >> #include "rcar-gen2.h" >> @@ -63,7 +65,16 @@ void __init rcar_gen2_timer_init(void) >> void __iomem *base; >> u32 freq; >> >> - secure_cntvoff_init(); >> + /* >> + * If PSCI is available then most likely we are running on PSCI-enabled >> + * U-Boot which, we assume, has already taken care of resetting CNTVOFF >> + * before switching to non-secure mode and we don't need to. >> + * Another check is to be sure that we are not running on top of Xen >> + * hypervisor, as CNTVOFF is controlled by hypervisor itself and >> + * shouldn't be touched by Dom0 in such case. >> + */ >> + if (!psci_smp_available() && !xen_domain()) >> + secure_cntvoff_init(); >> >> if (of_machine_is_compatible("renesas,r8a7745") || >> of_machine_is_compatible("renesas,r8a77470") || > How do you prevent secure_cntvoff_init() from being called for secondary > CPUs in arch/arm/mach-shmobile/headsmp-apmu.S? Good question. > > With PSCI, it is not called if "enable-method" in DT is "psci"', so that case > is covered, I guess. Yes. > > What about XEN? Do you override the "enable-method"? > If yes, perhaps a check for "renesas,apmu" is more appropriate? No, I don't override. The correct way to run Xen would be to use PSCI, so Linux shouldn't do any platform low level operation with secondary CPU cores (on/off, reset, etc) by itself when running on top of Xen hypervisor. As Xen brings available secondary cores up before starting first domain (Dom0) using PSCI CPU_ON call to FW, and these cores are entered Xen in Hyp mode, so any attempts from Dom0 to perform CPU power management directly (using APMU, RST, etc) may result in something not good. I think that in case when someone wants to run Xen on R-Car Gen2 system (which is SMP) without PSCI enabled, we need to forbid even trying to start secondary cores using APMU. What do you think? > > Gr{oetje,eeting}s, > > Geert > -- Regards, Oleksandr Tyshchenko