From patchwork Fri May 9 08:40:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 29882 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f200.google.com (mail-yk0-f200.google.com [209.85.160.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2A28C20534 for ; Fri, 9 May 2014 08:41:27 +0000 (UTC) Received: by mail-yk0-f200.google.com with SMTP id q9sf7678246ykb.11 for ; Fri, 09 May 2014 01:41:26 -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=fhRm/rJn8hUrKmhBzQnEHednouGHeJiHpdhx2jZ3LrM=; b=JIGxRJJgFWNlzR2vmYlWusA//ta8OlAeklJDZDWpHVNTfJKVENHh4ykgZRUbJTqCLz HvcDPitvmzVeA2nNxsJCMJWKBeJCkLxhs/2b37/FRzRxlGAx6uRSjmhX4G8jyCRON+fe 9dHIZGkayPJbOlVLeHiaLi3Z3hY6dAwcav5vG275ayq2Rv9vc5RixLUnuCJs6XlWaA7p NIIkrdu58HODtGN+m/8F9RY+vLRgxUphNIcwHcrPi285rL9CSRRRdV97cE/EcEWNMrUY m5AfD92MSMD2y3wHdwA3p/GAccZLGBUYLDVRJbC7QfhdxdLq88znAZu4DOdjhYMVvkrm 14Ug== X-Gm-Message-State: ALoCoQkg0iagSkjQ1oXw03L6c+7yIhU2NqkLft6jIkTR6ak5bXvTQw0K2/wFrcWunldnxH0Wy3IU X-Received: by 10.236.171.169 with SMTP id r29mr3820407yhl.32.1399624886844; Fri, 09 May 2014 01:41:26 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.108.229 with SMTP id j92ls199652qgf.14.gmail; Fri, 09 May 2014 01:41:26 -0700 (PDT) X-Received: by 10.52.116.101 with SMTP id jv5mr6247215vdb.11.1399624886561; Fri, 09 May 2014 01:41:26 -0700 (PDT) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id up2si614879vec.104.2014.05.09.01.41.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 09 May 2014 01:41:26 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id jz11so4746620veb.7 for ; Fri, 09 May 2014 01:41:26 -0700 (PDT) X-Received: by 10.221.40.193 with SMTP id tr1mr658054vcb.31.1399624886467; Fri, 09 May 2014 01:41:26 -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 ib8csp61225vcb; Fri, 9 May 2014 01:41:26 -0700 (PDT) X-Received: by 10.182.33.6 with SMTP id n6mr11293695obi.48.1399624885908; Fri, 09 May 2014 01:41:25 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ot5si1906583pbc.166.2014.05.09.01.41.25; Fri, 09 May 2014 01:41:25 -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 S1756369AbaEIIlH (ORCPT + 27 others); Fri, 9 May 2014 04:41:07 -0400 Received: from mail-we0-f173.google.com ([74.125.82.173]:53978 "EHLO mail-we0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756349AbaEIIlD (ORCPT ); Fri, 9 May 2014 04:41:03 -0400 Received: by mail-we0-f173.google.com with SMTP id u57so3605466wes.4 for ; Fri, 09 May 2014 01:41:01 -0700 (PDT) X-Received: by 10.180.8.66 with SMTP id p2mr2215639wia.37.1399624861462; Fri, 09 May 2014 01:41:01 -0700 (PDT) Received: from localhost ([213.122.173.131]) by mx.google.com with ESMTPSA id q9sm4600104wjo.3.2014.05.09.01.40.57 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 09 May 2014 01:41:00 -0700 (PDT) From: Viresh Kumar To: tglx@linutronix.de Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, fweisbec@gmail.com, arvind.chauhan@arm.com, preeti@linux.vnet.ibm.com, khilman@linaro.org, Viresh Kumar Subject: [PATCH 2/2] tick: SHUTDOWN event-dev if no events are required for KTIME_MAX Date: Fri, 9 May 2014 14:10:23 +0530 Message-Id: <0fe81b08a8aa32912ce7b4a015fdc09b6e3830e3.1399623699.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.0.0.rc2 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=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) 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: , When expires is set to KTIME_MAX in tick_program_event(), we are sure that there are no events enqueued for a very long time and so there is no point keeping event device running. We will get interrupted without any work to do many a times, for example when timer's counter overflows. So, its better to SHUTDOWN the event device then and restart it ones we get a request for next event. For implementing this a new field 'last_mode' is added to 'struct clock_event_device' to keep track of last mode used. Signed-off-by: Viresh Kumar --- include/linux/clockchips.h | 1 + kernel/time/tick-oneshot.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h index 2e4cb67..36a4ca6 100644 --- a/include/linux/clockchips.h +++ b/include/linux/clockchips.h @@ -105,6 +105,7 @@ struct clock_event_device { u32 mult; u32 shift; enum clock_event_mode mode; + enum clock_event_mode last_mode; unsigned int features; unsigned long retries; diff --git a/kernel/time/tick-oneshot.c b/kernel/time/tick-oneshot.c index 8241090..9543815 100644 --- a/kernel/time/tick-oneshot.c +++ b/kernel/time/tick-oneshot.c @@ -27,8 +27,20 @@ int tick_program_event(ktime_t expires, int force) { struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev); + int ret = 0; - return clockevents_program_event(dev, expires, force); + /* Shut down event device if it is not required for long */ + if (unlikely(expires.tv64 == KTIME_MAX)) { + dev->last_mode = dev->mode; + clockevents_set_mode(dev, CLOCK_EVT_MODE_SHUTDOWN); + } else { + /* restore mode when restarting event dev */ + if (unlikely(dev->mode == CLOCK_EVT_MODE_SHUTDOWN)) + clockevents_set_mode(dev, dev->last_mode); + ret = clockevents_program_event(dev, expires, force); + } + + return ret; } /**