From patchwork Thu May 29 14:29:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 4265551 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 168709F30B for ; Thu, 29 May 2014 14:31:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 24F0A2034B for ; Thu, 29 May 2014 14:31:48 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3D0A7201C7 for ; Thu, 29 May 2014 14:31:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wq1Km-000268-HC; Thu, 29 May 2014 14:29:32 +0000 Received: from service87.mimecast.com ([91.220.42.44]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wq1Kj-00020F-Ug for linux-arm-kernel@lists.infradead.org; Thu, 29 May 2014 14:29:30 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Thu, 29 May 2014 15:29:05 +0100 Received: from red-moon ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 29 May 2014 15:29:05 +0100 Date: Thu, 29 May 2014 15:29:12 +0100 From: Lorenzo Pieralisi To: Mark Rutland Subject: Re: [PATCH] arm64: kernel: initialize broadcast hrtimer based clock event device Message-ID: <20140529142912.GB20798@red-moon> References: <1401355381-11446-1-git-send-email-lorenzo.pieralisi@arm.com> <53871444.3080206@linux.vnet.ibm.com> <20140529123929.GF24233@leverpostej> MIME-Version: 1.0 In-Reply-To: <20140529123929.GF24233@leverpostej> User-Agent: Mutt/1.5.21 (2010-09-15) X-OriginalArrivalTime: 29 May 2014 14:29:05.0059 (UTC) FILETIME=[57F64F30:01CF7B4A] X-MC-Unique: 114052915290521201 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140529_072930_327091_90741D10 X-CRM114-Status: GOOD ( 25.05 ) X-Spam-Score: -0.7 (/) Cc: Preeti U Murthy , Will Deacon , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, May 29, 2014 at 01:39:29PM +0100, Mark Rutland wrote: [...] > > > The side effect of having a CPU always-on has implications on power management > > > platform capabilities and makes CPUidle suboptimal, since at least a CPU is > > > kept always in a shallow idle state by the kernel to relay timer interrupts, > > > but at least leaves the kernel with a functional system with some working power > > > management capabilities. > > > > > > The hrtimer based clock event device has lowest possible rating so that, > > > if a platform contains a functional HW clock event device with broadcast > > > capabilities, that device is always chosen as a tick broadcast device instead > > > of the software based one, now present by default. > > > > I think this statement "instead of the software based one, now present > > by default" is incorrect. The hrtimer based clock event device will come > > into picture only when the arch calls tick_setup_hrtimer_broadcast() > > explicitly. Otherwise either the arch should register a real clock > > device which does broadcast or should disable deep idle states where the > > local timers stop. So I would suggest skipping the last paragraph as it > > is not conveying anything in specific. The fact that a clock device with > > the highest rating will be chosen is already known and need not be > > mentioned explicitly IMHO. > > I think it is worth keeping the paragraph to allay anyone's fear that > the hrtimer based broadcast device might be selected in preference to a > real suitable clock. I would otherwise not be aware that the hrtimer > based broadcast device had the lowest rating (and would have to go and > look that up separately). > > As the arch code has delegated timer registration to > clocksoruce_of_init, it doesn't know whether any of the real devices > that may have been registered are suitable as a broadcast source for > oneshot events. So we can't conditionally register the hrtimer based > broadcast device. > > Perhaps we could replace "now present by default" with "which is > unconditionally registered in case no suitable hardware device is > present"? How about this: -- >8 -- Subject: [PATCH] arm64: kernel: initialize broadcast hrtimer based clock event device On platforms implementing CPU power management, the CPUidle subsystem can allow CPUs to enter idle states where local timers logic is lost on power down. To keep the software timers functional the kernel relies on an always-on broadcast timer to be present in the platform to relay the interrupt signalling the timer expiries. For platforms implementing CPU core gating that do not implement an always-on HW timer or implement it in a broken way, this patch adds code to initialize the kernel hrtimer based clock event device upon boot (which can be chosen as tick broadcast device by the kernel). It relies on a dynamically chosen CPU to be always powered-up. This CPU then relays the timer interrupt to CPUs in deep-idle states through its HW local timer device. The side effect of having a CPU always-on has implications on power management platform capabilities and makes CPUidle suboptimal, since at least a CPU is kept always in a shallow idle state by the kernel to relay timer interrupts, but at least leaves the kernel with a functional system with some working power management capabilities. The hrtimer based clock event device has lowest possible rating so that, if a platform contains a functional HW clock event device with broadcast capabilities, that device is always chosen as a tick broadcast device instead of the hrtimer based one, which is unconditionally registered in case no suitable hardware clock event device is present. Cc: Preeti U Murthy Cc: Will Deacon Acked-by: Mark Rutland Signed-off-by: Lorenzo Pieralisi --- arch/arm64/kernel/time.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c index 6815987..1a7125c 100644 --- a/arch/arm64/kernel/time.c +++ b/arch/arm64/kernel/time.c @@ -18,6 +18,7 @@ * along with this program. If not, see . */ +#include #include #include #include @@ -69,6 +70,8 @@ void __init time_init(void) of_clk_init(NULL); clocksource_of_init(); + tick_setup_hrtimer_broadcast(); + arch_timer_rate = arch_timer_get_rate(); if (!arch_timer_rate) panic("Unable to initialise architected timer.\n");