Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp428491yba; Fri, 3 May 2019 04:40:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyA0xX2UTqBrp3BkzbrKAB6Jeai7h+YnyZsPn7HL6ld1trGCZbSxaLINbDRLoy3tVey+tVM X-Received: by 2002:a17:902:9b83:: with SMTP id y3mr9641133plp.165.1556883656327; Fri, 03 May 2019 04:40:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556883656; cv=none; d=google.com; s=arc-20160816; b=MYKHcqV3GFLfBY5K3RWqCkJ3sp4aArYwYNOobuN+ST+ZWTyu2DVJAfkdj1wmOM42q+ +WnAMJ/7kIp6cL80BqQ2T9C0vkZMrnI/nlthUx9FqvTBOdXGk5cgafIoDGlHdRE7fgzw TQkz8qAJh2DiiapEE8lEtf3broG7xwJTFtiOdjCRH9IFhZN0muKt/d9/B9wulThKo5CO xy7lyf9vAK+9fZijj9yD5S4NdsqYLfJv2XzbBqfw2S0M7Gdnn4sEunCwuNxgK682xFbf Sar6mF0eUal0tVzBes6UYPmadio/pi2uRTRc5/EnduWhz3FxVfoeWB7DLp08/QeNIwLx a5Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=FvqZ/fQUnKqtTENumzYLYcCbYX7oGb9GDcUl0ClcFis=; b=Ddbn9o4kp5Evssgt3r9HrMZP97maow7phyOeYGsA1knA/WglRRct4GzckoLx8+sFGc xCIsLG5XFs/n/LpzeZxp9VgzIbCBEkmKOSqjgHAfoGs69HXUU7t4PkkJ3ZafIzzvwtmd PcV767LwERa2zvlbaUkbfplC/hoqkQ4Oep05ZxLjUOH0yAo44LtmaOYtNfN8UMyqybGv IDK0MWO+hPR8aVvs3s3fN+vPvb82CLGOvziGz+y9Meh5zh3XQxOb19dUXxCTsP3AImGy /hUaG2TCcZmIGt+BRzkcoM4eDIT6Ovyat9mrfQrWHckWzSwtHaG4xMc7iQyk6jL0WY7J y9BA== 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 t3si2035343plo.359.2019.05.03.04.40.40; Fri, 03 May 2019 04:40:56 -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 S1727678AbfECLi5 (ORCPT + 99 others); Fri, 3 May 2019 07:38:57 -0400 Received: from mail-ua1-f66.google.com ([209.85.222.66]:39680 "EHLO mail-ua1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726377AbfECLi4 (ORCPT ); Fri, 3 May 2019 07:38:56 -0400 Received: by mail-ua1-f66.google.com with SMTP id 88so1885986uau.6; Fri, 03 May 2019 04:38:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FvqZ/fQUnKqtTENumzYLYcCbYX7oGb9GDcUl0ClcFis=; b=UnpbDTizDlNXjxbGLpg7eQtmTnIy0/PfKqgqwFucQHPI2DDxNhfKlf/UXqG0yQ9NvN dwVy6I07yGHeq7tBdlAYBy0+4hYr1o4e+YwE+8w74uggdoPt0jZ+eJonPJAuVkALfdlB SmHnjHl4vm+GHlzBFHFz9QOqjhcABTNRhMoPXnL1Cm8cK9SaJ8XSZqe8xY6UMGXuu1ep bHYtWUD+nl24knwb/zK95oPFSowOlNrzEMtQCAEGn+4NNs4WxNO7WdUvwV1H6HhBcgUA qHcKIuUktd/l0ri8mf72MD883QJ5K0X3zbJj8S05+BOPV4bPX+wIhB5dgFVery4oqXOp JiIA== X-Gm-Message-State: APjAAAXa3zuJmeSxj1zWfKcPBMak3jscQTwZMp4KUdlLezUijgO6BJyw 4JFNwL3ipeEVbbd9aTMedVIOieivu8+dffzETk/Yu2DC X-Received: by 2002:a9f:352a:: with SMTP id o39mr4938847uao.78.1556883534530; Fri, 03 May 2019 04:38:54 -0700 (PDT) MIME-Version: 1.0 References: <1556882268-27451-1-git-send-email-olekstysh@gmail.com> In-Reply-To: <1556882268-27451-1-git-send-email-olekstysh@gmail.com> From: Geert Uytterhoeven Date: Fri, 3 May 2019 13:38:42 +0200 Message-ID: Subject: Re: [PATCH V2] ARM: mach-shmobile: Don't init CNTVOFF if PSCI is available To: Oleksandr Tyshchenko Cc: Linux-Renesas , Linux Kernel Mailing List , Julien Grall , Simon Horman , Magnus Damm , Russell King , Biju Das , Oleksandr Tyshchenko Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Oleksandr, 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! > --- > 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? With PSCI, it is not called if "enable-method" in DT is "psci"', so that case is covered, I guess. What about XEN? Do you override the "enable-method"? If yes, perhaps a check for "renesas,apmu" is more appropriate? Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds