Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4177001ybl; Mon, 26 Aug 2019 06:41:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwImyj2NzZi/+A80feQxJr0UZ0jt9UsqbVE/xKgoT2EeBPh9X2zU80oan2T1PJF6ojb14kw X-Received: by 2002:a65:5003:: with SMTP id f3mr2652294pgo.335.1566826895633; Mon, 26 Aug 2019 06:41:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566826895; cv=none; d=google.com; s=arc-20160816; b=jD10wt5EmIS5GSiwGmGjo/R1Kvmv1AdAuJgbL4K0CFhCIlrBeHtQJ8oqah3mz1yDUn KPOd9kaltCacXjMYOYZLw7FS8z2cST2+Cc2NJBl7QwJy56EvY4aiuCZeKT8wptiLO16f EiStSX68kqS3vyDXSAvTkmbwP4ziwH+CuLeR9ZHOeP7agL2SsgOCkrfU2YTDIE1PvX6t FrA8LYZGkXrA0ZoKBOc+BOSJROBLmLnOnZpUqEFosX6bVR5fkycppKajp+aACq0pq5uE stNwsL9g7yWeWAf0FDyLmO/CZFbcuzctHqzPqJP1XPOIAwjaFWaX/QFRkPFMXN3bS+er etDQ== 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:dkim-signature; bh=yY3k41gmYf/DTKvMuEJLOJQmABAXRkhQIZBCeG8ju+s=; b=NVeJDCUu1OIbL0ePmMM89iogicz92QV5oc4R9cXzM6/XrJ/HR3W7Rqz6SAVdcecqoZ bv+INM92TwURt015lLTAhLToJ/R6LV0XY3FgvSPyB/jQ2873/VNJPFbYnN7FwAwTmNdK nLqTlqOLFDjc0Z2ErXnWviI6l48WcwvNBp6nOv3nOT3yNIPTvrYRXscBLvHr75V2Y/Oj tK5NLRFSKzjZuaKAkPwl62P34FTntA2RtFx1BbOktC5cWl2+F5zikKHvKbo7P3Cv8lJJ 4q6iWkp+eBEeQoVEcurEzK+JXk5vq/YetAPeuJ0HnNcvFhZIwdv/2JfN4ztL0Ygcxd58 IqiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b="Y/SwOjPQ"; 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 g5si9772308plp.435.2019.08.26.06.41.19; Mon, 26 Aug 2019 06:41:35 -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=@c-s.fr header.s=mail header.b="Y/SwOjPQ"; 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 S1731134AbfHZNkJ (ORCPT + 99 others); Mon, 26 Aug 2019 09:40:09 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:9243 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728862AbfHZNkJ (ORCPT ); Mon, 26 Aug 2019 09:40:09 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 46HCmf2BRGz9v6M8; Mon, 26 Aug 2019 15:40:02 +0200 (CEST) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=Y/SwOjPQ; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id RGrgdY2y_xm7; Mon, 26 Aug 2019 15:40:02 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 46HCmf17Bcz9v6M7; Mon, 26 Aug 2019 15:40:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1566826802; bh=yY3k41gmYf/DTKvMuEJLOJQmABAXRkhQIZBCeG8ju+s=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=Y/SwOjPQCG5asoLq8HEiW+NmcAW6rp7X9WBxmSHDBLAgvDkYIo2M2gj6I191Fm1oT wmYMKR+1N+9Gr7hTTnQPr80A67lICgWnilEeGHZTO6YKv9nOBGP8zqn/dpvoFYFcoG F8x0WGFlmLGe/3/5b4sGJsBtIX/R1pUkq5kwk4xk= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 4B5D58B7E1; Mon, 26 Aug 2019 15:40:07 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id Jyrpu0M7eqWM; Mon, 26 Aug 2019 15:40:07 +0200 (CEST) Received: from [172.25.230.103] (po15451.idsi0.si.c-s.fr [172.25.230.103]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 113768B7DE; Mon, 26 Aug 2019 15:40:07 +0200 (CEST) Subject: Re: [PATCH] powerpc/time: use feature fixup in __USE_RTC() instead of cpu feature. To: Benjamin Herrenschmidt , Michael Ellerman , Paul Mackerras Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org References: <55c267ac6e0cd289970accfafbf9dda11a324c2e.1566802736.git.christophe.leroy@c-s.fr> <87blwc40i4.fsf@concordia.ellerman.id.au> <60da7620a43dc29317a062f1d58dcfde8d32b258.camel@kernel.crashing.org> From: Christophe Leroy Message-ID: Date: Mon, 26 Aug 2019 15:40:07 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <60da7620a43dc29317a062f1d58dcfde8d32b258.camel@kernel.crashing.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 26/08/2019 à 15:25, Benjamin Herrenschmidt a écrit : > On Mon, 2019-08-26 at 21:41 +1000, Michael Ellerman wrote: >> Christophe Leroy writes: >>> sched_clock(), used by printk(), calls __USE_RTC() to know >>> whether to use realtime clock or timebase. >>> >>> __USE_RTC() uses cpu_has_feature() which is initialised by >>> machine_init(). Before machine_init(), __USE_RTC() returns true, >>> leading to a program check exception on CPUs not having realtime >>> clock. >>> >>> In order to be able to use printk() earlier, use feature fixup. >>> Feature fixups are applies in early_init(), enabling the use of >>> printk() earlier. >>> >>> Signed-off-by: Christophe Leroy >>> --- >>> arch/powerpc/include/asm/time.h | 9 ++++++++- >>> 1 file changed, 8 insertions(+), 1 deletion(-) >> >> The other option would be just to make this a compile time decision, eg. >> add CONFIG_PPC_601 and use that to gate whether we use RTC. >> >> Given how many 601 users there are, maybe 1?, I think that would be a >> simpler option and avoids complicating the code / binary for everyone >> else. > > Didn't we ditch 601 support years ago anyway ? We had workaround we > threw out I think... There are still workarounds for 601 in the kernel, for exemple (in arch/powerpc/include/asm/ppc_asm.h) /* various errata or part fixups */ #ifdef CONFIG_PPC601_SYNC_FIX #define SYNC \ BEGIN_FTR_SECTION \ sync; \ isync; \ END_FTR_SECTION_IFSET(CPU_FTR_601) #define SYNC_601 \ BEGIN_FTR_SECTION \ sync; \ END_FTR_SECTION_IFSET(CPU_FTR_601) #define ISYNC_601 \ BEGIN_FTR_SECTION \ isync; \ END_FTR_SECTION_IFSET(CPU_FTR_601) #else #define SYNC #define SYNC_601 #define ISYNC_601 #endif But if you think we can get rid of 601 completely, I'm happy with that. Christophe > > Cheers, > Ben. > >> cheers >> >>> diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h >>> index 54f4ec1f9fab..3455cb54c333 100644 >>> --- a/arch/powerpc/include/asm/time.h >>> +++ b/arch/powerpc/include/asm/time.h >>> @@ -42,7 +42,14 @@ struct div_result { >>> /* Accessor functions for the timebase (RTC on 601) registers. */ >>> /* If one day CONFIG_POWER is added just define __USE_RTC as 1 */ >>> #ifdef CONFIG_PPC_BOOK3S_32 >>> -#define __USE_RTC() (cpu_has_feature(CPU_FTR_USE_RTC)) >>> +static inline bool __USE_RTC(void) >>> +{ >>> + asm_volatile_goto(ASM_FTR_IFCLR("nop;", "b %1;", %0) :: >>> + "i" (CPU_FTR_USE_RTC) :: l_use_rtc); >>> + return false; >>> +l_use_rtc: >>> + return true; >>> +} >>> #else >>> #define __USE_RTC() 0 >>> #endif >>> -- >>> 2.13.3