[PATCH 2/2] acpi_pm.c: check for monotonicity

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Dominik Brodowski
Date: Monday, August 18, 2008 - 1:11 pm

From 13cc8b6ff0d8198102f60691c38c07151a693c7b Mon Sep 17 00:00:00 2001
From: Dominik Brodowski <linux@dominikbrodowski.net>
Date: Sun, 10 Aug 2008 21:34:54 +0200
Subject: [PATCH 2/2] acpi_pm.c: check for monotonicity

The current check for monotonicity is way too weak: Andreas Mohr reports
( http://lkml.org/lkml/2008/8/10/77  ) that on one of his test systems the
current check only triggers in 50% of all cases, leading to catastrophic timer
behaviour. To fix this issue, expand the check for monotonicity by doing ten
consecutive tests instead of one.

CC: John Stultz <johnstul@us.ibm.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
---
 drivers/clocksource/acpi_pm.c |   42 ++++++++++++++++++++++++----------------
 1 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c
index 2c00edd..f05c4fb 100644
--- a/drivers/clocksource/acpi_pm.c
+++ b/drivers/clocksource/acpi_pm.c
@@ -178,7 +178,7 @@ static int verify_pmtmr_rate(void)
 static int __init init_acpi_pm_clocksource(void)
 {
 	cycle_t value1, value2;
-	unsigned int i;
+	unsigned int i, j, good = 0;
 
 	if (!pmtmr_ioport)
 		return -ENODEV;
@@ -187,24 +187,32 @@ static int __init init_acpi_pm_clocksource(void)
 						clocksource_acpi_pm.shift);
 
 	/* "verify" this timing source: */
-	value1 = clocksource_acpi_pm.read();
-	for (i = 0; i < 10000; i++) {
-		value2 = clocksource_acpi_pm.read();
-		if (value2 == value1)
-			continue;
-		if (value2 > value1)
-			goto pm_good;
-		if ((value2 < value1) && ((value2) < 0xFFF))
-			goto pm_good;
-		printk(KERN_INFO "PM-Timer had inconsistent results:"
-			" 0x%#llx, 0x%#llx - aborting.\n", value1, value2);
-		return -EINVAL;
+	for (j = 0; j < 10; j++) {
+		value1 = clocksource_acpi_pm.read();
+		for (i = 0; i < 10000; i++) {
+			value2 = clocksource_acpi_pm.read();
+			if (value2 == value1)
+				continue;
+			if (value2 > value1)
+				good++;
+				break;
+			if ((value2 < value1) && ((value2) < 0xFFF))
+				good++;
+				break;
+			printk(KERN_INFO "PM-Timer had inconsistent results:"
+			       " 0x%#llx, 0x%#llx - aborting.\n",
+			       value1, value2);
+			return -EINVAL;
+		}
+		udelay(300 * i);
+	}
+
+	if (good != 10) {
+		printk(KERN_INFO "PM-Timer had no reasonable result:"
+		       " 0x%#llx - aborting.\n", value1);
+		return -ENODEV;
 	}
-	printk(KERN_INFO "PM-Timer had no reasonable result:"
-			" 0x%#llx - aborting.\n", value1);
-	return -ENODEV;
 
-pm_good:
 	if (verify_pmtmr_rate() != 0)
 		return -ENODEV;
 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
ACPI PM-Timer on K6-3 SiS5591: Houston..., Andreas Mohr, (Sun Aug 10, 3:17 am)
Re: ACPI PM-Timer on K6-3 SiS5591: Houston..., Dominik Brodowski, (Sun Aug 10, 9:29 am)
Re: ACPI PM-Timer on K6-3 SiS5591: Houston..., Arjan van de Ven, (Sun Aug 10, 9:40 am)
Re: ACPI PM-Timer on K6-3 SiS5591: Houston..., Andreas Mohr, (Sun Aug 10, 12:08 pm)
Re: ACPI PM-Timer on K6-3 SiS5591: Houston..., Dominik Brodowski, (Sun Aug 10, 1:02 pm)
[git pull?] clocksource: ACPI pmtmr bugfixes [Was: Re: ACP ..., Dominik Brodowski, (Mon Aug 18, 12:03 pm)
[PATCH 1/2] acpi_pm.c: use proper read function also in er ..., Dominik Brodowski, (Mon Aug 18, 12:05 pm)
[PATCH 2/2] acpi_pm.c: check for monotonicity, Dominik Brodowski, (Mon Aug 18, 12:05 pm)
Re: [git pull?] clocksource: ACPI pmtmr bugfixes [Was: Re: ..., Dominik Brodowski, (Mon Aug 18, 12:35 pm)
Re: [git pull?] clocksource: ACPI pmtmr bugfixes [Was: Re: ..., Dominik Brodowski, (Mon Aug 18, 1:09 pm)
[PATCH 1/2] acpi_pm.c: use proper read function also in er ..., Dominik Brodowski, (Mon Aug 18, 1:10 pm)
[PATCH 2/2] acpi_pm.c: check for monotonicity, Dominik Brodowski, (Mon Aug 18, 1:11 pm)
Re: [PATCH 2/2] acpi_pm.c: check for monotonicity, Andreas Mohr, (Mon Aug 18, 1:18 pm)
Re: [PATCH 2/2] acpi_pm.c: check for monotonicity, Andrew Morton, (Mon Aug 18, 1:28 pm)
Re: [git pull?] clocksource: ACPI pmtmr bugfixes [Was: Re: ..., Dominik Brodowski, (Mon Aug 18, 1:29 pm)
Re: [PATCH 2/2] acpi_pm.c: check for monotonicity, Dominik Brodowski, (Mon Aug 18, 1:42 pm)
Re: [PATCH 1/2] acpi_pm.c: use proper read function also i ..., Dominik Brodowski, (Tue Aug 19, 2:49 am)
[PATCH v2 1/2] acpi_pm.c: use proper read function also in ..., Dominik Brodowski, (Fri Aug 22, 3:22 pm)
[PATCH v2 2/2] acpi_pm.c: check for monotonicity, Dominik Brodowski, (Fri Aug 22, 3:26 pm)
Re: [PATCH v2 2/2] acpi_pm.c: check for monotonicity, Jochen Voß, (Sat Aug 23, 1:48 am)