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: 31131 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C6769203E6 for ; Thu, 29 May 2014 14:29:16 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id z6sf1927734yhz.5 for ; Thu, 29 May 2014 07:29:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:date:from:to:cc:subject:message-id :references:mime-version:in-reply-to:user-agent:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe :content-type:content-transfer-encoding:content-disposition; bh=1CH0dG7JAw/82WYzZQm2HD/wcatxyyqtLfw+eBWZl+Q=; b=XVYvGkRkYKf3gvsQdMhjjg5//2idLeOP/cBPUt5p8Y/qFQyJw9YKVY6SGPM2hi8/s2 /nlVitjQs261vYEfwXKStHjF2m75s/jJkuyCG0YFu3wyooHl2LpfoSRoe70s5cqcbWlB f3EPewnPc58MfXRayvYQ8USGSr20fhytX1o245QAiW40TjktfHiuq5kz0xP0bNLRrLjG XuZuJ80R2P+p6VZiHufXDgmR6q1aPM1ACRbPCbgbgeKMPp9BRiaAhbil4LBRLxS/5Mr7 myCOp9rkN2OfT4sSTYJExU9pHauuEkNbvQg+eE1ZdBeEgSou9E66huqmsV9Rco5PFv9A dDgQ== X-Gm-Message-State: ALoCoQnz6hoC7+er50kMed9qW/sbAqxBSQu2g4tQHsii+GwblJPj8NaKIDjqUv5/+rPuk7sWr093 X-Received: by 10.236.192.196 with SMTP id i44mr1672729yhn.23.1401373756304; Thu, 29 May 2014 07:29:16 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.104.49 with SMTP id z46ls564428qge.50.gmail; Thu, 29 May 2014 07:29:16 -0700 (PDT) X-Received: by 10.52.241.98 with SMTP id wh2mr5656255vdc.37.1401373756118; Thu, 29 May 2014 07:29:16 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id sw4si582719vdc.69.2014.05.29.07.29.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 May 2014 07:29:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id il7so464019vcb.32 for ; Thu, 29 May 2014 07:29:16 -0700 (PDT) X-Received: by 10.53.13.133 with SMTP id ey5mr5876562vdd.8.1401373755991; Thu, 29 May 2014 07:29:15 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp33116vcb; Thu, 29 May 2014 07:29:15 -0700 (PDT) X-Received: by 10.68.239.137 with SMTP id vs9mr9524232pbc.84.1401373755160; Thu, 29 May 2014 07:29:15 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hb8si1199667pbc.8.2014.05.29.07.29.14; Thu, 29 May 2014 07:29:14 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934021AbaE2O3J (ORCPT + 27 others); Thu, 29 May 2014 10:29:09 -0400 Received: from service87.mimecast.com ([91.220.42.44]:60906 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932413AbaE2O3H convert rfc822-to-8bit (ORCPT ); Thu, 29 May 2014 10:29:07 -0400 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 Cc: Preeti U Murthy , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Will Deacon 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lorenzo.pieralisi@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Content-Disposition: inline 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");