[PATCH] cpuidle: avoid singing capacitors

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Venkatesh Pallipadi <venkatesh.pallipadi@...>, Adam Belay <abelay@...>
Cc: <linux-pm@...>, LKML <linux-kernel@...>, Andi Kleen <andi@...>, Lee Revell <rlrevell@...>
Date: Monday, March 3, 2008 - 4:18 pm

Many devices today are of a less than stellar quality, and singing
capacitors are a common problem. A high-pitch noise is created, caused
by power fluctuations as the processor enters and leaves deep sleep at
a high frequency.

Instead of just disabling the deep sleep (which wastes power). This
patch merely reduces the number of times it is entered so that the
frequency doesn't exceed 500 Hz. That should make sure the problem is
inaudible.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
--

I've been playing around with this for a bit, and the jiffies approach
just had too many gotchas. So I tried using the information that was
already present in the menu governor. This is what I came up with.

It solves the primary problem of getting rid of the noise. I've also
tried some crude power measurements and I couldn't get any difference
with and without the patch. Powertop also nicely shows that the CPU is
still spending almost all of its time in C3. Therefore, I'm letting the
effects of it be enabled by default.

So I'm taking the [RFC] off it. Please still test and see that it
solves the issue on other machines, and the it does not cause any big
power surges.

diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index 78d77c5..d9c43e3 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -16,6 +16,8 @@
 
 #define BREAK_FUZZ     4       /* 4 us */
 
+static unsigned int min_deep_sleep = 2000;
+
 struct menu_device {
        int             last_state_idx;
 
@@ -50,6 +52,19 @@ static int menu_select(struct cpuidle_device *dev)
                        break;
                if (s->exit_latency > pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY))
                        break;
+
+               /*
+                * In order to avoid the problem of "singing capacitors",
+                * don't enter a deep sleep for short durations (by
+                * default, nothing shorter than 2 ms). This will,
+                * hopefully, keep the problem inaudible.
+                */
+               if (s->flags & CPUIDLE_FLAG_DEEP) {
+                       if (min_deep_sleep > data->expected_us)
+                               break;
+                       if (min_deep_sleep > data->predicted_us)
+                               break;
+               }
        }
 
        data->last_state_idx = i - 1;
@@ -132,6 +147,9 @@ static void __exit exit_menu(void)
        cpuidle_unregister_governor(&menu_governor);
 }
 
+module_param(min_deep_sleep, uint, 0644)
+MODULE_PARM_DESC(min_deep_sleep, "min time (us) to spend in deep sleep to avoid noise")
+
 MODULE_LICENSE("GPL");
 module_init(init_menu);
 module_exit(exit_menu);



-- 
     -- Pierre Ossman

  Linux kernel, MMC maintainer        http://www.kernel.org
  PulseAudio, core developer          http://pulseaudio.org
  rdesktop, core developer          http://www.rdesktop.org
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC][PATCH] cpuidle: avoid singing capacitors, Pierre Ossman, (Fri Feb 29, 2:38 pm)
[PATCH] cpuidle: avoid singing capacitors, Pierre Ossman, (Mon Mar 3, 4:18 pm)
Re: [PATCH] cpuidle: avoid singing capacitors, Pavel Machek, (Mon Mar 3, 4:46 pm)
Re: [PATCH] cpuidle: avoid singing capacitors, Pierre Ossman, (Mon Mar 3, 5:03 pm)
Re: [PATCH] cpuidle: avoid singing capacitors, Pavel Machek, (Mon Mar 3, 5:08 pm)
RE: [PATCH] cpuidle: avoid singing capacitors, Pallipadi, Venkatesh, (Mon Mar 3, 5:14 pm)
Re: [PATCH] cpuidle: avoid singing capacitors, Pierre Ossman, (Mon Mar 3, 5:17 pm)
RE: [PATCH] cpuidle: avoid singing capacitors, Pallipadi, Venkatesh, (Mon Mar 3, 6:04 pm)
Re: [PATCH] cpuidle: avoid singing capacitors, Andi Kleen, (Mon Mar 3, 7:09 pm)
RE: [linux-pm] [PATCH] cpuidle: avoid singing capacitors, Pallipadi, Venkatesh, (Tue Mar 4, 3:01 pm)
Re: [linux-pm] [PATCH] cpuidle: avoid singing capacitors, Pierre Ossman, (Sun Mar 9, 10:16 am)
Re: [linux-pm] [PATCH] cpuidle: avoid singing capacitors, Pierre Ossman, (Tue Mar 11, 3:51 am)
Re: [linux-pm] [PATCH] cpuidle: avoid singing capacitors, Pierre Ossman, (Tue Mar 11, 11:20 am)
Re: [linux-pm] [PATCH] cpuidle: avoid singing capacitors, Pierre Ossman, (Tue Mar 11, 1:31 pm)
Re: [linux-pm] [PATCH] cpuidle: avoid singing capacitors, Pierre Ossman, (Mon Mar 10, 8:49 am)
Re: [linux-pm] [PATCH] cpuidle: avoid singing capacitors, Pierre Ossman, (Thu Mar 13, 12:34 pm)
Re: [linux-pm] [PATCH] cpuidle: avoid singing capacitors, Pierre Ossman, (Fri Mar 14, 3:40 pm)
RE: [linux-pm] [PATCH] cpuidle: avoid singing capacitors, Pallipadi, Venkatesh, (Fri Mar 14, 5:15 pm)
Re: [linux-pm] [PATCH] cpuidle: avoid singing capacitors, Pierre Ossman, (Fri Mar 14, 8:41 pm)
Re: [linux-pm] [PATCH] cpuidle: avoid singing capacitors, Pierre Ossman, (Thu Mar 13, 1:49 pm)
RE: [linux-pm] [PATCH] cpuidle: avoid singing capacitors, Pallipadi, Venkatesh, (Thu Mar 13, 12:47 pm)
Re: [linux-pm] [PATCH] cpuidle: avoid singing capacitors, Pierre Ossman, (Thu Mar 13, 1:44 pm)
Re: [linux-pm] [PATCH] cpuidle: avoid singing capacitors, Pierre Ossman, (Mon Mar 10, 9:29 am)
Re: [linux-pm] [PATCH] cpuidle: avoid singing capacitors, Henrique de Moraes Holschuh..., (Sun Mar 9, 3:30 pm)
Re: [linux-pm] [PATCH] cpuidle: avoid singing capacitors, Henrique de Moraes Holschuh..., (Sun Mar 9, 4:41 pm)
Re: [linux-pm] [PATCH] cpuidle: avoid singing capacitors, Henrique de Moraes Holschuh..., (Sun Mar 9, 4:54 pm)
Re: [linux-pm] [PATCH] cpuidle: avoid singing capacitors, Rafael J. Wysocki, (Sun Mar 9, 2:19 pm)
Re: [linux-pm] [PATCH] cpuidle: avoid singing capacitors, Pierre Ossman, (Wed Mar 5, 12:53 pm)
Re: [RFC][PATCH] cpuidle: avoid singing capacitors, Andi Kleen, (Mon Mar 3, 8:36 am)
Re: [RFC][PATCH] cpuidle: avoid singing capacitors, Lee Revell, (Sat Mar 1, 10:27 pm)
Re: [RFC][PATCH] cpuidle: avoid singing capacitors, Pierre Ossman, (Sun Mar 2, 10:17 am)
Re: [RFC][PATCH] cpuidle: avoid singing capacitors, Pierre Ossman, (Sat Mar 1, 9:40 am)
Re: [RFC][PATCH] cpuidle: avoid singing capacitors, Lennart Sorensen, (Fri Feb 29, 5:44 pm)
Re: [RFC][PATCH] cpuidle: avoid singing capacitors, Pierre Ossman, (Sat Mar 1, 8:31 am)