From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D71BC43219 for ; Fri, 3 May 2019 11:38:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5425F2087F for ; Fri, 3 May 2019 11:38:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727683AbfECLi5 (ORCPT ); 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-Google-Smtp-Source: APXvYqwvxMEGmN+05vhczm0D2Rwg1KLtmbn0eGLmZc26G8TzEjlkd065DbCBKz/hao2kh5PwvFcbplRQhvjGWR0zK+A= 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