From patchwork Fri Apr 3 03:34:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 46742 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 33429216D1 for ; Fri, 3 Apr 2015 03:35:06 +0000 (UTC) Received: by wgfh4 with SMTP id h4sf20959268wgf.1 for ; Thu, 02 Apr 2015 20:35:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=AKwHxHwL5hjBtGUENknOU9th+6iyWV8QWkfuBDjMd4k=; b=hHvxe0TRzUu28b2rDa3Eb9IgsfM7HT2QniZGnDKvQZvD/ijZwl+dVTCMkIJ4K+vlX5 c+fzyHxm7EN0eXdPskrGnIACXTgs1qaTqHyBGckTPk5Any9UCOwsElsNq04lcILOPszr x+kgOJlZeNu2qQB8qViubnno2Om5wcwhsEn9yWNJqiVd+0EIHaKmQPntSrx0fXMFS2Js 9TLKrNfs9nnQz83M+yz97fP5cSJ4YmUpBTj0+7Yu4t8neTTZsqZVXw4g/xMMV5ff47zz 2G3NHNtQ4DahIacEGgfEBNurfqf0c66HZuM8h9crHM6RZeTqPt0fZUFuYKDMoG6EKPBt tLJw== X-Gm-Message-State: ALoCoQmqr+CbtT62B3ki4lC+bWyfWanrv5Ny3qDzSVG9kmtZ14YxCq+cFgCLI6qbMWaqpzZDpg5K X-Received: by 10.152.37.231 with SMTP id b7mr117304lak.5.1428032105473; Thu, 02 Apr 2015 20:35:05 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.202.133 with SMTP id ki5ls300555lac.90.gmail; Thu, 02 Apr 2015 20:35:05 -0700 (PDT) X-Received: by 10.152.36.131 with SMTP id q3mr422687laj.68.1428032105286; Thu, 02 Apr 2015 20:35:05 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id s17si5715868lal.30.2015.04.02.20.35.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Apr 2015 20:35:05 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by lbdc10 with SMTP id c10so71845247lbd.2 for ; Thu, 02 Apr 2015 20:35:05 -0700 (PDT) X-Received: by 10.112.10.197 with SMTP id k5mr411934lbb.86.1428032105195; Thu, 02 Apr 2015 20:35:05 -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.112.57.201 with SMTP id k9csp1714771lbq; Thu, 2 Apr 2015 20:35:04 -0700 (PDT) X-Received: by 10.68.138.230 with SMTP id qt6mr838804pbb.66.1428032100954; Thu, 02 Apr 2015 20:35:00 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pk6si10032377pbc.162.2015.04.02.20.35.00; Thu, 02 Apr 2015 20:35:00 -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 S1753465AbbDCDex (ORCPT + 27 others); Thu, 2 Apr 2015 23:34:53 -0400 Received: from mail-pd0-f182.google.com ([209.85.192.182]:36060 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752842AbbDCDet (ORCPT ); Thu, 2 Apr 2015 23:34:49 -0400 Received: by pdea3 with SMTP id a3so57598574pde.3 for ; Thu, 02 Apr 2015 20:34:49 -0700 (PDT) X-Received: by 10.70.45.227 with SMTP id q3mr898216pdm.22.1428032089126; Thu, 02 Apr 2015 20:34:49 -0700 (PDT) Received: from localhost ([122.167.118.120]) by mx.google.com with ESMTPSA id dj3sm6589404pbd.48.2015.04.02.20.34.47 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 02 Apr 2015 20:34:48 -0700 (PDT) From: Viresh Kumar To: Thomas Gleixner , Ingo Molnar , Peter Zijlstra Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, Frederic Weisbecker , Kevin Hilman , Daniel Lezcano , Preeti U Murthy , Viresh Kumar Subject: [PATCH V2 2/2] Clockevents: Stop unused clockevent devices Date: Fri, 3 Apr 2015 09:04:05 +0530 Message-Id: <5146b07be7f0bc497e0ebae036590ec2fa73e540.1428031396.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.3.0.rc0.44.ga94655d In-Reply-To: References: In-Reply-To: References: 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: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 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: , To avoid getting spurious interrupts on a tickless CPU, clockevent device can now be stopped by switching to ONESHOT_STOPPED state. The natural place for handling this transition is tick_program_event(). On 'expires == KTIME_MAX', we skip programming the event and so we need to fix such call sites as well, to always call tick_program_event() irrespective of the expires value. Once the clockevent device is required again, check if it was earlier put into ONESHOT_STOPPED state. If yes, switch its state to ONESHOT before programming its event. To make sure we haven't missed any corner case, add a WARN() for the case where we try to reprogram clockevent device while we aren't configured in ONESHOT_STOPPED state. Signed-off-by: Viresh Kumar --- kernel/time/clockevents.c | 4 ++++ kernel/time/hrtimer.c | 6 ++---- kernel/time/tick-oneshot.c | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c index 49ed2ea4294c..8ff54495f60b 100644 --- a/kernel/time/clockevents.c +++ b/kernel/time/clockevents.c @@ -335,6 +335,10 @@ int clockevents_program_event(struct clock_event_device *dev, ktime_t expires, if (dev->state == CLOCK_EVT_STATE_SHUTDOWN) return 0; + /* We must be in ONESHOT state here */ + WARN_ONCE(dev->state != CLOCK_EVT_STATE_ONESHOT, "Current state: %d\n", + dev->state); + /* Shortcut for clockevent devices that can deal with ktime. */ if (dev->features & CLOCK_EVT_FEAT_KTIME) return dev->set_next_ktime(expires, dev); diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 721d29b99d10..d1be3eda83fa 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -543,8 +543,7 @@ hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, int skip_equal) if (cpu_base->hang_detected) return; - if (cpu_base->expires_next.tv64 != KTIME_MAX) - tick_program_event(cpu_base->expires_next, 1); + tick_program_event(cpu_base->expires_next, 1); } /* @@ -1308,8 +1307,7 @@ void hrtimer_interrupt(struct clock_event_device *dev) raw_spin_unlock(&cpu_base->lock); /* Reprogramming necessary ? */ - if (expires_next.tv64 == KTIME_MAX || - !tick_program_event(expires_next, 0)) { + if (!tick_program_event(expires_next, 0)) { cpu_base->hang_detected = 0; return; } diff --git a/kernel/time/tick-oneshot.c b/kernel/time/tick-oneshot.c index 67a64b1670bf..f8de75715c2f 100644 --- a/kernel/time/tick-oneshot.c +++ b/kernel/time/tick-oneshot.c @@ -28,6 +28,22 @@ int tick_program_event(ktime_t expires, int force) { struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev); + if (unlikely(expires.tv64 == KTIME_MAX)) { + /* + * We don't need the clock event device any more, stop it. + */ + clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT_STOPPED); + return 0; + } + + if (unlikely(dev->state == CLOCK_EVT_STATE_ONESHOT_STOPPED)) { + /* + * We need the clock event again, configure it in ONESHOT mode + * before using it. + */ + clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT); + } + return clockevents_program_event(dev, expires, force); }