public inbox for linux-next@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: sfr@canb.auug.org.au
Cc: akpm@linux-foundation.org, rob.lee@linaro.org, j-pihet@ti.com,
	khilman@ti.com, deepthi@linux.vnet.ibm.com,
	dan.carpenter@oracle.com, linux-next@vger.kernel.org,
	linux-kernel@vger.kernel.org, hughd@google.com,
	amit.kucheria@linaro.org
Subject: [PATCH] cpuidle : fix random hangs with intel_idle
Date: Thu, 15 Mar 2012 01:09:41 +0100	[thread overview]
Message-ID: <1331770181-800-1-git-send-email-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <alpine.LSU.2.00.1203131454500.1335@eggly.anvils>

The cpuidle consolidation inverts the local_irq_enable for
the poll_idle function with CPU_RELAX.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reported-by: Hugh Dickins <hughd@google.com>
---
 drivers/cpuidle/cpuidle.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 56de5f7..4869b55 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -213,20 +213,25 @@ int cpuidle_wrap_enter(struct cpuidle_device *dev,
 }
 
 #ifdef CONFIG_ARCH_HAS_CPU_RELAX
-static inline int __poll_idle(struct cpuidle_device *dev,
+static int poll_idle(struct cpuidle_device *dev,
 		struct cpuidle_driver *drv, int index)
 {
+	ktime_t	t1, t2;
+	s64 diff;
+
+	t1 = ktime_get();
+	local_irq_enable();
 	while (!need_resched())
 		cpu_relax();
 
-	return index;
-}
+	t2 = ktime_get();
+	diff = ktime_to_us(ktime_sub(t2, t1));
+	if (diff > INT_MAX)
+		diff = INT_MAX;
 
-static int poll_idle(struct cpuidle_device *dev,
-		struct cpuidle_driver *drv, int index)
-{
-	return cpuidle_wrap_enter(dev,	drv, index,
-				__poll_idle);
+	dev->last_residency = (int) diff;
+
+	return index;
 }
 
 static void poll_idle_init(struct cpuidle_driver *drv)
-- 
1.7.5.4

  parent reply	other threads:[~2012-03-15  0:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-13 22:29 next-20120313 cpuidle freezes when booting Hugh Dickins
2012-03-14 11:29 ` Daniel Lezcano
2012-03-14 19:03   ` Hugh Dickins
2012-03-14 19:46     ` Daniel Lezcano
2012-03-14 20:30       ` Hugh Dickins
2012-03-15  0:09 ` Daniel Lezcano [this message]
2012-03-15  0:14   ` [PATCH] cpuidle : fix random hangs with intel_idle Stephen Rothwell
2012-03-15  0:23     ` Hugh Dickins
2012-03-15  2:58       ` Stephen Rothwell
2012-03-16 13:37         ` Amit Kucheria
2012-03-16 14:26           ` Stephen Rothwell
2012-03-20 16:27             ` Rob Lee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1331770181-800-1-git-send-email-daniel.lezcano@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=akpm@linux-foundation.org \
    --cc=amit.kucheria@linaro.org \
    --cc=dan.carpenter@oracle.com \
    --cc=deepthi@linux.vnet.ibm.com \
    --cc=hughd@google.com \
    --cc=j-pihet@ti.com \
    --cc=khilman@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=rob.lee@linaro.org \
    --cc=sfr@canb.auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox