Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4049389ybl; Mon, 26 Aug 2019 04:49:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqx5ThfM1cwXIj8EccUrRIKD0wAk+nR0Esup6bhkEIFgF3lH6zVXqwe1bZltwKStCUXPncX5 X-Received: by 2002:a17:902:b196:: with SMTP id s22mr3080280plr.241.1566820188809; Mon, 26 Aug 2019 04:49:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566820188; cv=none; d=google.com; s=arc-20160816; b=WsYQWhtoBBRm5fxkrFbwdnHu+eIhdCpL7of5KP3/dr7MnaiymLfb624jJLJQMGpuD5 vM5PQ0uVJuFImYB3Kl0OxNVdKcO9VgS4MmhAc84ehlmP94w5ss/fktcIs7/wy9stQw8c nr4ZYBaPbDp5C0FdxkpbWx/yHOHHkUcQgGxqjykUABy/gi7Juifv1dielYb/Z9BhnVqN K/Gtn2kWrWeBAzJZSmHDDyWz4WSggkTEwpSvb4IUJmWVgnRhle7tqWXSYc7cM/uEpzA3 aorXnoraLMOzrkW/+452xzm6ZgAPIkfZiGfqg4cZMOQBhgf/HGv+8GgnmTJoqrKGscA8 JfvQ== 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=/3WuMrmdmWS/5c4f2953Y2GY9Thjm0CP+EMv8HdNY7A=; b=WJ/KLxKEwvPUpffoCS6QUofeBWCsTxEhW2zLZvwDC8NNjIQa0Oxm0dSX4NgXFW33sg c2eS/o9EbzaIF89OJomGps63zSFjnAsgWSU1N3rHaQwsQ2NOCwKcWBKKSfNBUP8LiyJ9 HttxPJBgkocO0w0A2rdzrt+M6YfSW4YVL9hyGX+gtXT95Yo5clxb0+8OY3PjBBs2fpQS Qh1poJxs373b7ntOiAkVqYbWIORDs3nGGhYftgGtv+/FsFjMjPoEmfSUmjwnlRraPfMR m866XE27qN/wn36QKr6eHWTrz6QekER8enQ/ufid+oaQZEFxQdkBGf7gYMIp7WPitQOE vK0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=DHe4OChf; 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 x21si9258724pln.397.2019.08.26.04.49.33; Mon, 26 Aug 2019 04:49:48 -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=DHe4OChf; 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 S1731011AbfHZLst (ORCPT + 99 others); Mon, 26 Aug 2019 07:48:49 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:31654 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730841AbfHZLss (ORCPT ); Mon, 26 Aug 2019 07:48:48 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 46H9J474ncz9v6VH; Mon, 26 Aug 2019 13:48:36 +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=DHe4OChf; 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 MtV9cCNuh1wj; Mon, 26 Aug 2019 13:48:36 +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 46H9J45wZjz9v6VG; Mon, 26 Aug 2019 13:48:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1566820116; bh=/3WuMrmdmWS/5c4f2953Y2GY9Thjm0CP+EMv8HdNY7A=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=DHe4OChf62mrSsZsw5oDG402l8JwrMpk5BSCEU2X1imYi53QpoXclriQwbQ7g+vVX YB7D0NDfO/Mhpxc62/VIlNbKvWLdIAIwq2FKo/8p+hlRo2jciMygkjZQ+bPfprCiYc f8KMBQzS25e/thiKiAkyJdJf6bhNv45H1KVWdMwM= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id C9C218B7E1; Mon, 26 Aug 2019 13:48:41 +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 9Ki3Zbb64eje; Mon, 26 Aug 2019 13:48:41 +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 A6AD18B7DE; Mon, 26 Aug 2019 13:48:41 +0200 (CEST) Subject: Re: [PATCH] powerpc/time: use feature fixup in __USE_RTC() instead of cpu feature. To: Michael Ellerman , Benjamin Herrenschmidt , 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> From: Christophe Leroy Message-ID: Date: Mon, 26 Aug 2019 13:48:41 +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: <87blwc40i4.fsf@concordia.ellerman.id.au> 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 à 13:41, Michael Ellerman a écrit : > 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. Euh ... yes OK, why not. And that would help simplify many places in the code. I can propose something in that direction, but it will be a bigger change. > > 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. However this patch doesn't complicate things more than it was with cpu_has_feature() which does exactly the same but using static keys, does it ? Christophe > > 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