diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2008-09-11 11:09:49 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-09-11 11:14:29 +0200 |
commit | f1926ce63b996b42772b39e4b47bb4ef4ba748b4 (patch) | |
tree | 3721b28841d6eccbf62ac910a5479133d7e445db /drivers/clocksource | |
parent | 6ef62164e794c480259ac158aa6c8c7b85746545 (diff) | |
download | linux-arm64-f1926ce63b996b42772b39e4b47bb4ef4ba748b4.tar.gz linux-arm64-f1926ce63b996b42772b39e4b47bb4ef4ba748b4.tar.bz2 linux-arm64-f1926ce63b996b42772b39e4b47bb4ef4ba748b4.zip |
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>
Diffstat (limited to 'drivers/clocksource')
-rw-r--r-- | drivers/clocksource/acpi_pm.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c index 4eee533f3f4..71d2ac4e3f4 100644 --- a/drivers/clocksource/acpi_pm.c +++ b/drivers/clocksource/acpi_pm.c @@ -178,11 +178,13 @@ static int verify_pmtmr_rate(void) /* Number of monotonicity checks to perform during initialization */ #define ACPI_PM_MONOTONICITY_CHECKS 10 +/* Number of reads we try to get two different values */ +#define ACPI_PM_READ_CHECKS 10000 static int __init init_acpi_pm_clocksource(void) { cycle_t value1, value2; - unsigned int i, j, good = 0; + unsigned int i, j = 0; if (!pmtmr_ioport) return -ENODEV; @@ -192,29 +194,26 @@ static int __init init_acpi_pm_clocksource(void) /* "verify" this timing source: */ for (j = 0; j < ACPI_PM_MONOTONICITY_CHECKS; j++) { + udelay(100 * j); value1 = clocksource_acpi_pm.read(); - for (i = 0; i < 10000; i++) { + for (i = 0; i < ACPI_PM_READ_CHECKS; 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 != ACPI_PM_MONOTONICITY_CHECKS) { - printk(KERN_INFO "PM-Timer failed consistency check " - " (0x%#llx) - aborting.\n", value1); - return -ENODEV; + if (i == ACPI_PM_READ_CHECKS) { + printk(KERN_INFO "PM-Timer failed consistency check " + " (0x%#llx) - aborting.\n", value1); + return -ENODEV; + } } if (verify_pmtmr_rate() != 0) |