clocksource, acpi_pm.c: fix check for monotonicity

Actually check the monotonicity of the ACPI PMTMR ten times, only delay for
0.9 miliseconds at most, and bail out early if some problem is determined.

Reported-by: Jochen Voß <jochen.voss@googlemail.com>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by Dominik Brodowski and committed by Ingo Molnar f1926ce6 6ef62164

+10 -11
+10 -11
drivers/clocksource/acpi_pm.c
··· 178 179 /* Number of monotonicity checks to perform during initialization */ 180 #define ACPI_PM_MONOTONICITY_CHECKS 10 181 182 static int __init init_acpi_pm_clocksource(void) 183 { 184 cycle_t value1, value2; 185 - unsigned int i, j, good = 0; 186 187 if (!pmtmr_ioport) 188 return -ENODEV; ··· 194 195 /* "verify" this timing source: */ 196 for (j = 0; j < ACPI_PM_MONOTONICITY_CHECKS; j++) { 197 value1 = clocksource_acpi_pm.read(); 198 - for (i = 0; i < 10000; i++) { 199 value2 = clocksource_acpi_pm.read(); 200 if (value2 == value1) 201 continue; 202 if (value2 > value1) 203 - good++; 204 break; 205 if ((value2 < value1) && ((value2) < 0xFFF)) 206 - good++; 207 break; 208 printk(KERN_INFO "PM-Timer had inconsistent results:" 209 " 0x%#llx, 0x%#llx - aborting.\n", 210 value1, value2); 211 return -EINVAL; 212 } 213 - udelay(300 * i); 214 - } 215 - 216 - if (good != ACPI_PM_MONOTONICITY_CHECKS) { 217 - printk(KERN_INFO "PM-Timer failed consistency check " 218 - " (0x%#llx) - aborting.\n", value1); 219 - return -ENODEV; 220 } 221 222 if (verify_pmtmr_rate() != 0)
··· 178 179 /* Number of monotonicity checks to perform during initialization */ 180 #define ACPI_PM_MONOTONICITY_CHECKS 10 181 + /* Number of reads we try to get two different values */ 182 + #define ACPI_PM_READ_CHECKS 10000 183 184 static int __init init_acpi_pm_clocksource(void) 185 { 186 cycle_t value1, value2; 187 + unsigned int i, j = 0; 188 189 if (!pmtmr_ioport) 190 return -ENODEV; ··· 192 193 /* "verify" this timing source: */ 194 for (j = 0; j < ACPI_PM_MONOTONICITY_CHECKS; j++) { 195 + udelay(100 * j); 196 value1 = clocksource_acpi_pm.read(); 197 + for (i = 0; i < ACPI_PM_READ_CHECKS; i++) { 198 value2 = clocksource_acpi_pm.read(); 199 if (value2 == value1) 200 continue; 201 if (value2 > value1) 202 break; 203 if ((value2 < value1) && ((value2) < 0xFFF)) 204 break; 205 printk(KERN_INFO "PM-Timer had inconsistent results:" 206 " 0x%#llx, 0x%#llx - aborting.\n", 207 value1, value2); 208 return -EINVAL; 209 } 210 + if (i == ACPI_PM_READ_CHECKS) { 211 + printk(KERN_INFO "PM-Timer failed consistency check " 212 + " (0x%#llx) - aborting.\n", value1); 213 + return -ENODEV; 214 + } 215 } 216 217 if (verify_pmtmr_rate() != 0)