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