Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4047453ybl; Mon, 26 Aug 2019 04:47:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/e7wHIHV0siId8zvAOjlVJ3xZ6j0pUL/R3zW8wmpSOD6ylv8geHxDmF6/pAPYvGJIbXMc X-Received: by 2002:a17:90a:8991:: with SMTP id v17mr18984708pjn.120.1566820063614; Mon, 26 Aug 2019 04:47:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566820063; cv=none; d=google.com; s=arc-20160816; b=oeBaXAdMwez1n/oWs0Mn3Pwyr8BfD2eDdXK0aSAHZ3WSFW3+P1cShc9Fzfkjpesxhq GhESoiCxoxDKPvaUpQAkysraglwH8I/WFBEAS0SvYG3lM4qSHBWf//KlaBr+FkugG/QR wjWZv768oxTERuNJY/PvAYEHQIGPaP5lT/kExTTalz4RGswin51SJl3L8Z8sOd1F1VWX jE8fRJXpXarOQIQKN5M9XrIayYzWjUnMAaShL6JY4Z/qmRuFAGaZfUEE3/ORCm2hy53Y Pm8PrUpBQ37hCwh7OzPq437iFX4g7yIZBqrgnGBeW+Qk5Vaa4qb+U4g9+A462D8IOWKG SbQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=4iESxpoaQO4k5VHsmk98j9y9gIXw0VbNxYVH6HIP4LA=; b=hAa6vjftsMVaDVjzxxBMqqxPQDmamT8HbYp+zgRiN3+gcZVvf3DGoPjJuTGTLqxGjY pJrdeZmi+YXQVwjURKkw0+YWqHnyQHZh6o3kdwrg+hoJN6LK3VoxBuyxRoow5w0i73Ks RNHaG6R/qn9rK+IjmNG0+wxCttwq7NsysinAw5BvoA16gDjLaILlZ4ywlyoCZ/6paZA+ KzOOCAXzFcBkIUzgKoxhTkORmFw2pwnmDoU8mKeuROX6AwMyFU68cFw0FfP5DpKoW2u9 +/jO+NCX+/loFM+pnKHijdnWw5JxscWr0FPSiiAN4gxNV/UXmUAAmn+1nhwebX0KRaYh kdIQ== 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 d3si9485555pjx.75.2019.08.26.04.47.28; Mon, 26 Aug 2019 04:47:43 -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 S1731160AbfHZLlp (ORCPT + 99 others); Mon, 26 Aug 2019 07:41:45 -0400 Received: from ozlabs.org ([203.11.71.1]:48019 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729569AbfHZLlp (ORCPT ); Mon, 26 Aug 2019 07:41:45 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46H98664TJz9sMr; Mon, 26 Aug 2019 21:41:42 +1000 (AEST) From: Michael Ellerman To: Christophe Leroy , Benjamin Herrenschmidt , Paul Mackerras Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH] powerpc/time: use feature fixup in __USE_RTC() instead of cpu feature. In-Reply-To: <55c267ac6e0cd289970accfafbf9dda11a324c2e.1566802736.git.christophe.leroy@c-s.fr> References: <55c267ac6e0cd289970accfafbf9dda11a324c2e.1566802736.git.christophe.leroy@c-s.fr> Date: Mon, 26 Aug 2019 21:41:39 +1000 Message-ID: <87blwc40i4.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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