From patchwork Wed Mar 20 15:57:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 15439 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 493D623E2C for ; Wed, 20 Mar 2013 15:57:21 +0000 (UTC) Received: from mail-vb0-f43.google.com (mail-vb0-f43.google.com [209.85.212.43]) by fiordland.canonical.com (Postfix) with ESMTP id D8F9EA18DFE for ; Wed, 20 Mar 2013 15:57:20 +0000 (UTC) Received: by mail-vb0-f43.google.com with SMTP id fs19so1202287vbb.2 for ; Wed, 20 Mar 2013 08:57:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=DfYut+i27aCWeyxxVV1YKAng22OFyEzfziGjddHKM5Q=; b=nNhdpRkKWcIy9ivcsuaxxhJqV27aaBAxbIIcAodc2gjfwbstHaaHjJ9E1NMGRWLvvn hqXfhzfsT3Dbe33a9QiibsrngtcSU5hALKvJVo5Mwb8O1sJE/7Ogz18WrCzRSYupw07l +PCKMg28qR91QDZN1OIUVJpoK7GSn6BRF72zG3jZTZVFBxKY1YhULAu3rrdtgbqGpyeF UkT+vscFVeY16PGjqxPzJXuIKtMb3y50vlpdmgR2V3fzP8SWioBF5TUtE32FwY6vLB9N rN0FuaHytbwhKLjUNBZl5bDVldY2mrl62WNpe/oM25+l6tATSdrNP24fVbpo9sP9ZvZN 9OuQ== X-Received: by 10.52.93.20 with SMTP id cq20mr7383215vdb.38.1363795040206; Wed, 20 Mar 2013 08:57:20 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.233.198 with SMTP id ty6csp19101vec; Wed, 20 Mar 2013 08:57:19 -0700 (PDT) X-Received: by 10.180.97.132 with SMTP id ea4mr791456wib.23.1363795038360; Wed, 20 Mar 2013 08:57:18 -0700 (PDT) Received: from mail-wi0-x236.google.com ([2a00:1450:400c:c05::236]) by mx.google.com with ESMTPS id hk4si1007939wjb.181.2013.03.20.08.57.17 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 20 Mar 2013 08:57:18 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c05::236 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=2a00:1450:400c:c05::236; Authentication-Results: mx.google.com; spf=neutral (google.com: 2a00:1450:400c:c05::236 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) smtp.mail=daniel.lezcano@linaro.org Received: by mail-wi0-f182.google.com with SMTP id hi18so2010542wib.3 for ; Wed, 20 Mar 2013 08:57:17 -0700 (PDT) X-Received: by 10.180.75.110 with SMTP id b14mr4833479wiw.21.1363795036065; Wed, 20 Mar 2013 08:57:16 -0700 (PDT) Received: from mai.home (AToulouse-654-1-276-229.w90-5.abo.wanadoo.fr. [90.5.59.229]) by mx.google.com with ESMTPS id h10sm4005774wic.8.2013.03.20.08.57.13 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 20 Mar 2013 08:57:15 -0700 (PDT) From: Daniel Lezcano To: rjw@sisk.pl Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, patches@linaro.org, lenb@kernel.org Subject: [PATCH] cpuidle : handle clockevent notify from the cpuidle framework Date: Wed, 20 Mar 2013 16:57:13 +0100 Message-Id: <1363795033-26445-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQlGy5IofNuUxJPDRFx12HiPGdCmkAD7xGRyk3/h+bbWWe+dl7yuBVJ1EeFfZ8Sm0Nv6R2nI When a cpu enters a deep idle state, the local timers are stopped and the time framework falls back to the timer device used as a broadcast timer. The different cpuidle drivers are calling clockevents_notify ENTER/EXIT when the idle state stops the local timer. The proposed patch introduces a new flag CPUIDLE_FLAG_TIMER_STOP to let the cpuidle framework to call clockevents_notify instead of duplicating again and again these lines in all the cpuidle drivers. Signed-off-by: Daniel Lezcano Reviewed-by: Thomas Gleixner --- drivers/cpuidle/cpuidle.c | 9 +++++++++ include/linux/cpuidle.h | 1 + 2 files changed, 10 insertions(+) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index eba6929..c500370 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -8,6 +8,7 @@ * This code is licenced under the GPL. */ +#include #include #include #include @@ -146,12 +147,20 @@ int cpuidle_idle_call(void) trace_cpu_idle_rcuidle(next_state, dev->cpu); + if (drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP) + clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, + &dev->cpu); + if (cpuidle_state_is_coupled(dev, drv, next_state)) entered_state = cpuidle_enter_state_coupled(dev, drv, next_state); else entered_state = cpuidle_enter_state(dev, drv, next_state); + if (drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP) + clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, + &dev->cpu); + trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu); /* give the governor an opportunity to reflect on the outcome */ diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 480c14d..a837b33 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -57,6 +57,7 @@ struct cpuidle_state { /* Idle State Flags */ #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */ #define CPUIDLE_FLAG_COUPLED (0x02) /* state applies to multiple cpus */ +#define CPUIDLE_FLAG_TIMER_STOP (0x04) /* timer is stopped on this state */ #define CPUIDLE_DRIVER_FLAGS_MASK (0xFFFF0000)