* PATCH: apm.c - runtime parameter for APM Idle call
@ 2001-12-16 18:45 Borsenkow Andrej
2001-12-17 3:34 ` Dave Jones
0 siblings, 1 reply; 3+ messages in thread
From: Borsenkow Andrej @ 2001-12-16 18:45 UTC (permalink / raw)
To: Mandrake kernel list; +Cc: linux-kernel list, Cooker list
[-- Attachment #1: Type: text/plain, Size: 1084 bytes --]
After investigating kapm_idled problem here it turned out quite simple -
BIOS neither slows down CPU nor halts it so kapm_idled enters busy loop
doing basically
while !system_busy
do nothing
eating away CPU. This applies to patch of Andreas as well.
I do not like an option of recompiling without CONFIG_APM_CPU_IDLE
because I think about distribution kernel in the first place. I have
ASUS CUSL2 motherboard - it is not unusual brand and obviously many
people have the same problem and you cannot expect all of them to
recompile kernel. So this patch adds runtime parameter (no-)apm-idle
that has the same effect - enabling/disabling usage of APM Idle BIOS
calls. It is initialised according to CONFIG_APM_CPU_IDLE and should be
100% compatible.
If Andreas patch is accepted it needs the same treatment.
I thought once about run-time detection - if BIOS reports that Idle does
not slow down CPU try Idle call once and compare jiffies (probably
repeat several times to be sure). Is it sensible?
Patch is agains 2.4.16-9.dk but should apply to any version I guess.
-andrej
[-- Attachment #2: apm-idle.diff --]
[-- Type: text/x-diff, Size: 1106 bytes --]
--- arch/i386/kernel/apm.c.org Sat Nov 10 00:58:02 2001
+++ arch/i386/kernel/apm.c Sun Dec 16 21:23:27 2001
@@ -383,6 +383,11 @@
static int allow_ints;
#endif
static int broken_psr;
+#ifdef CONFIG_APM_CPU_IDLE
+static int apm_idle_enabled = 1;
+#else
+static int apm_idle_enabled;
+#endif
static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue);
static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue);
@@ -1366,7 +1371,8 @@
*/
set_current_state(TASK_INTERRUPTIBLE);
apm_event_handler();
-#ifdef CONFIG_APM_CPU_IDLE
+ if (!apm_idle_enabled)
+ continue;
if (!system_idle())
continue;
@@ -1393,7 +1399,6 @@
apm_event_handler();
timeout = 1;
}
-#endif
}
remove_wait_queue(&apm_waitqueue, &wait);
}
@@ -1814,6 +1819,8 @@
if ((strncmp(str, "realmode-power-off", 18) == 0) ||
(strncmp(str, "realmode_power_off", 18) == 0))
apm_info.realmode_power_off = !invert;
+ if (strncmp(str, "apm-idle", 8) == 0)
+ apm_idle_enabled = !invert;
str = strchr(str, ',');
if (str != NULL)
str += strspn(str, ", \t");
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH: apm.c - runtime parameter for APM Idle call
2001-12-16 18:45 PATCH: apm.c - runtime parameter for APM Idle call Borsenkow Andrej
@ 2001-12-17 3:34 ` Dave Jones
2001-12-18 17:54 ` PATCH: apm.c - detection of brokern APM Idle call implementation Borsenkow Andrej
0 siblings, 1 reply; 3+ messages in thread
From: Dave Jones @ 2001-12-17 3:34 UTC (permalink / raw)
To: Borsenkow Andrej; +Cc: Mandrake kernel list, linux-kernel list, Cooker list
On 16 Dec 2001, Borsenkow Andrej wrote:
> I thought once about run-time detection - if BIOS reports that Idle does
> not slow down CPU try Idle call once and compare jiffies (probably
> repeat several times to be sure). Is it sensible?
A far simpler way would be to add DMI blacklist entries for the BIOSes
that don't do this, although this assumes the problem machine has a DMI
compliant BIOS.
Dave.
--
| Dave Jones. http://www.codemonkey.org.uk
| SuSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
* PATCH: apm.c - detection of brokern APM Idle call implementation
2001-12-17 3:34 ` Dave Jones
@ 2001-12-18 17:54 ` Borsenkow Andrej
0 siblings, 0 replies; 3+ messages in thread
From: Borsenkow Andrej @ 2001-12-18 17:54 UTC (permalink / raw)
To: Dave Jones; +Cc: Mandrake kernel list, linux-kernel list, Cooker list
[-- Attachment #1: Type: text/plain, Size: 1003 bytes --]
On Пнд, 2001-12-17 at 06:34, Dave Jones wrote:
> On 16 Dec 2001, Borsenkow Andrej wrote:
>
> > I thought once about run-time detection - if BIOS reports that Idle does
> > not slow down CPU try Idle call once and compare jiffies (probably
> > repeat several times to be sure). Is it sensible?
>
> A far simpler way would be to add DMI blacklist entries for the BIOSes
> that don't do this, although this assumes the problem machine has a DMI
> compliant BIOS.
>
Well, the following three-liners (+ comments) seems to do it. It checks
if clock was advanced after return from APM Idle - if not we assume BIOS
did not halt CPU and do it ourselves. The addidional condition &&
!current->need_resched is for the case when BIOS did halt CPU and
non-clock interrupt happened that waked up somebody else. But may be I
am just plain paranoid. The code has no impact for "BIOS slows CPU"
case.
It works here for broken BIOS. I appreciate if people with good BIOS
test it.
-andrej
[-- Attachment #2: apm-idle-2.diff --]
[-- Type: text/x-diff, Size: 813 bytes --]
--- apm.c.bor Tue Dec 18 20:30:08 2001
+++ apm.c Tue Dec 18 20:42:24 2001
@@ -1381,13 +1381,18 @@
*/
if (apm_do_idle() != -1) {
unsigned long start = jiffies;
+ unsigned long before;
while ((!exit_kapmd) && system_idle()) {
- if (apm_do_idle()) {
+ before = jiffies;
+ if (apm_do_idle() || (jiffies == before && !current->need_resched)) {
set_current_state(TASK_INTERRUPTIBLE);
/* APM needs us to snooze .. either
the BIOS call failed (-1) or it
slowed the clock (1). We sleep
- until it talks to us again */
+ until it talks to us again.
+ If clock did not advance CPU was
+ not halted by BIOS so we do it
+ now*/
schedule_timeout(1);
}
if ((jiffies - start) > APM_CHECK_TIMEOUT) {
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-12-18 17:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-12-16 18:45 PATCH: apm.c - runtime parameter for APM Idle call Borsenkow Andrej
2001-12-17 3:34 ` Dave Jones
2001-12-18 17:54 ` PATCH: apm.c - detection of brokern APM Idle call implementation Borsenkow Andrej
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox