From: Paul Mackerras This patch fixes a problem where my new powerbook would sometimes hang or crash when changing CPU speed. We had schedule_timeout(HZ/1000) in there, intended to provide a delay of one millisecond. However, even with HZ=1000, it was (I believe) only waiting for the next jiffy before proceeding, which could be less than a millisecond. Changing the code to use msleep, and specifying a time of 1 jiffy + 1ms has fixed the problem. (When I looked at the msleep code, it appeared to me that msleep(1) with HZ=1000 would sleep for between 0 and 1ms.) Ben also asked me to remove the code that changes the AACK delay enable, after looking in the Darwin sources and seeing that Darwin does not change this in its corresponding code. Signed-off-by: Paul Mackerras Signed-off-by: Andrew Morton --- 25-akpm/arch/ppc/platforms/pmac_cpufreq.c | 13 +++---------- 1 files changed, 3 insertions(+), 10 deletions(-) diff -puN arch/ppc/platforms/pmac_cpufreq.c~ppc32-fix-cpu-voltage-change-delay arch/ppc/platforms/pmac_cpufreq.c --- 25/arch/ppc/platforms/pmac_cpufreq.c~ppc32-fix-cpu-voltage-change-delay 2004-10-09 20:50:36.010291800 -0700 +++ 25-akpm/arch/ppc/platforms/pmac_cpufreq.c 2004-10-09 20:50:36.014291192 -0700 @@ -140,11 +140,8 @@ static int __pmac dfs_set_cpu_speed(int if (low_speed == 0) { /* ramping up, set voltage first */ pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, voltage_gpio, 0x05); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ/1000); - } else { - /* ramping down, enable aack delay first */ - pmac_call_feature(PMAC_FTR_AACK_DELAY_ENABLE, NULL, 1, 0); + /* Make sure we sleep for at least 1ms */ + msleep(1 + jiffies_to_msecs(1)); } /* set frequency */ @@ -153,11 +150,7 @@ static int __pmac dfs_set_cpu_speed(int if (low_speed == 1) { /* ramping down, set voltage last */ pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, voltage_gpio, 0x04); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ/1000); - } else { - /* ramping up, disable aack delay last */ - pmac_call_feature(PMAC_FTR_AACK_DELAY_ENABLE, NULL, 0, 0); + msleep(1 + jiffies_to_msecs(1)); } return 0; _