Ver Fonte

[PATCH] ppc32: Fix cpufreq vs. sleep issue

Recent kernels occasionally trigger a PMU timeout on some mac laptops,
typically on wakeup from sleep.  This seem to be caused by either a too big
latency caused by the cpufreq switch on wakeup from sleep or by an
interrupt beeing lost due to the reset of the interrupt controller done
during wakeup.

This patch makes that code more robust by stopping PMU auto poll activity
around cpufreq changes on machines that use the PMU for such changes (long
latency switching involving a CPU hard reset and flush of all caches) and
by removing the reset of the open pic interrupt controller on wakeup (that
can cause the loss of an interrupt and Darwin doesn't do it, so it must not
be necessary).

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Benjamin Herrenschmidt há 20 anos atrás
pai
commit
b16eeb4729

+ 4 - 0
arch/ppc/platforms/pmac_cpufreq.c

@@ -271,6 +271,8 @@ static int __pmac pmu_set_cpu_speed(int low_speed)
 #ifdef DEBUG_FREQ
 #ifdef DEBUG_FREQ
 	printk(KERN_DEBUG "HID1, before: %x\n", mfspr(SPRN_HID1));
 	printk(KERN_DEBUG "HID1, before: %x\n", mfspr(SPRN_HID1));
 #endif
 #endif
+	pmu_suspend();
+
 	/* Disable all interrupt sources on openpic */
 	/* Disable all interrupt sources on openpic */
  	pic_prio = openpic_get_priority();
  	pic_prio = openpic_get_priority();
 	openpic_set_priority(0xf);
 	openpic_set_priority(0xf);
@@ -345,6 +347,8 @@ static int __pmac pmu_set_cpu_speed(int low_speed)
 	debug_calc_bogomips();
 	debug_calc_bogomips();
 #endif
 #endif
 
 
+	pmu_resume();
+
 	preempt_enable();
 	preempt_enable();
 
 
 	return 0;
 	return 0;

+ 1 - 3
arch/ppc/syslib/open_pic.c

@@ -275,7 +275,7 @@ static void __init openpic_enable_sie(void)
 }
 }
 #endif
 #endif
 
 
-#if defined(CONFIG_EPIC_SERIAL_MODE) || defined(CONFIG_PM)
+#if defined(CONFIG_EPIC_SERIAL_MODE)
 static void openpic_reset(void)
 static void openpic_reset(void)
 {
 {
 	openpic_setfield(&OpenPIC->Global.Global_Configuration0,
 	openpic_setfield(&OpenPIC->Global.Global_Configuration0,
@@ -993,8 +993,6 @@ int openpic_resume(struct sys_device *sysdev)
 		return 0;
 		return 0;
 	}
 	}
 
 
-	openpic_reset();
-
 	/* OpenPIC sometimes seem to need some time to be fully back up... */
 	/* OpenPIC sometimes seem to need some time to be fully back up... */
 	do {
 	do {
 		openpic_set_spurious(OPENPIC_VEC_SPURIOUS);
 		openpic_set_spurious(OPENPIC_VEC_SPURIOUS);

+ 4 - 4
drivers/macintosh/via-pmu.c

@@ -2421,7 +2421,7 @@ pmac_wakeup_devices(void)
 
 
 	/* Re-enable local CPU interrupts */
 	/* Re-enable local CPU interrupts */
 	local_irq_enable();
 	local_irq_enable();
-	mdelay(100);
+	mdelay(10);
 	preempt_enable();
 	preempt_enable();
 
 
 	/* Re-enable clock spreading on some machines */
 	/* Re-enable clock spreading on some machines */
@@ -2549,7 +2549,9 @@ powerbook_sleep_Core99(void)
 		return ret;
 		return ret;
 	}
 	}
 
 
-	printk(KERN_DEBUG "HID1, before: %x\n", mfspr(SPRN_HID1));
+	/* Stop environment and ADB interrupts */
+	pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0);
+	pmu_wait_complete(&req);
 
 
 	/* Tell PMU what events will wake us up */
 	/* Tell PMU what events will wake us up */
 	pmu_request(&req, NULL, 4, PMU_POWER_EVENTS, PMU_PWR_CLR_WAKEUP_EVENTS,
 	pmu_request(&req, NULL, 4, PMU_POWER_EVENTS, PMU_PWR_CLR_WAKEUP_EVENTS,
@@ -2611,8 +2613,6 @@ powerbook_sleep_Core99(void)
 	pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, pmu_intr_mask);
 	pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, pmu_intr_mask);
 	pmu_wait_complete(&req);
 	pmu_wait_complete(&req);
 
 
-	printk(KERN_DEBUG "HID1, after: %x\n", mfspr(SPRN_HID1));
-
 	pmac_wakeup_devices();
 	pmac_wakeup_devices();
 
 
 	return 0;
 	return 0;