Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4258704ybl; Mon, 26 Aug 2019 07:50:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNaevGzI8ruOhQ2qd6orR7yraPvcxJ58YJZdEDj7lKLziOWfyDOkLI4hc0ZY8sWwopuLQK X-Received: by 2002:a17:902:a58c:: with SMTP id az12mr7279624plb.129.1566831047067; Mon, 26 Aug 2019 07:50:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566831047; cv=none; d=google.com; s=arc-20160816; b=Cn7vjrvBBc+RQt6A/rUVLqAlOodJpljMGIJkZbjV22E29NENg44EuQdbynVoiPzCVO TyoCLiUkfkEjgQLQY0gU2sumlRCz/5BlOJauEzG41NoxCupcVjdtQzWbAgEPKAxGNAtd PIOpfLMtQxJRi9h0rWTe/JMV9Ln3+lqhFSNqdsBQh91woVvFZzkP1txPDDES16WgbhQQ 0Z4eUZiI/AhExaqr729rnublrjHLhZGXFt7SGmVxZSXZNprxPigFhNpBmfv1tIUIOmXJ 0TpudtgReC64whslHGMnfb+sALcJyaNOC+tEz32FoO/Cv7o1yQXQCx8paQ9VK7Mo28eR 04XA== 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:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=c4EBasECrZ2nzGtXCopktGid9Z8D2XxTncziNkI7KjM=; b=Fxfm0t+BdRXHlMX3S/h5r+lckiZzp5r1eCuSr9he4LXeHAOMN7oLAILpP13fDQ2Xh7 M7jSMyVrouaccoCkj1jGW5HdPTK0P5L1EJdajlL7aFvoMGEkasH/ctr+iPn5sk6bswEh RO4dewcJbwBPPryiIksFE5NVmQ8IP3X1Z8my8U3Pglbkilgs7jOS8V5JMrbYUBElJyPp cbkjweJJeAY2Aj2BnKygfdANT397JmTJZoYs2Xx18Otj6S5UiPThSyLT5upRimb9jiBX o00nJM62/mYoV/QTQdNkT7rzfet/FbV3cYKeYVryVBBj1JBXWtr6a/Y5NxgdOQ/R4mGq C9bg== 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 q9si9714910pjv.72.2019.08.26.07.50.31; Mon, 26 Aug 2019 07:50:47 -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 S1731665AbfHZNZq (ORCPT + 99 others); Mon, 26 Aug 2019 09:25:46 -0400 Received: from gate.crashing.org ([63.228.1.57]:54551 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727462AbfHZNZp (ORCPT ); Mon, 26 Aug 2019 09:25:45 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id x7QDPGHZ009715; Mon, 26 Aug 2019 08:25:17 -0500 Message-ID: <60da7620a43dc29317a062f1d58dcfde8d32b258.camel@kernel.crashing.org> Subject: Re: [PATCH] powerpc/time: use feature fixup in __USE_RTC() instead of cpu feature. From: Benjamin Herrenschmidt To: Michael Ellerman , Christophe Leroy , Paul Mackerras Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Mon, 26 Aug 2019 23:25:14 +1000 In-Reply-To: <87blwc40i4.fsf@concordia.ellerman.id.au> References: <55c267ac6e0cd289970accfafbf9dda11a324c2e.1566802736.git.christophe.leroy@c-s.fr> <87blwc40i4.fsf@concordia.ellerman.id.au> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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... 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