// SPDX-License-Identifier: GPL-2.0-only /* * linux/drivers/clocksource/acpi_pm.c * * This file contains the ACPI PM based clocksource. * * This code was largely moved from the i386 timer_pm.c file * which was (C) Dominik Brodowski <linux@brodo.de> 2003 * and contained the following comments: * * Driver to use the Power Management Timer (PMTMR) available in some * southbridges as primary timing source for the Linux kernel. * * Based on parts of linux/drivers/acpi/hardware/hwtimer.c, timer_pit.c, * timer_hpet.c, and on Arjan van de Ven's implementation for 2.4.
*/
/* * The I/O port the PMTMR resides at. * The location is detected during setup_arch(), * in arch/i386/kernel/acpi/boot.c
*/
u32 pmtmr_ioport __read_mostly;
staticinline u32 read_pmtmr(void)
{ /* mask the output to 24 bits */ return inl(pmtmr_ioport) & ACPI_PM_MASK;
}
/* * It has been reported that because of various broken * chipsets (ICH4, PIIX4 and PIIX4E) where the ACPI PM clock * source is not latched, you must read it multiple * times to ensure a safe value is read:
*/ do {
v1 = read_pmtmr();
v2 = read_pmtmr();
v3 = read_pmtmr();
} while (unlikely((v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1)
|| (v3 > v1 && v3 < v2)));
/* * PIIX4 Errata: * * The power management timer may return improper results when read. * Although the timer value settles properly after incrementing, * while incrementing there is a 3 ns window every 69.8 ns where the * timer value is indeterminate (a 4.2% chance that the data will be * incorrect when read). As a result, the ACPI free running count up * timer specification is violated due to erroneous reads.
*/ staticvoid acpi_pm_check_blacklist(struct pci_dev *dev)
{ if (acpi_pm_good) return;
/* the bug has been fixed in PIIX4M */ if (dev->revision < 3) {
pr_warn("* Found PM-Timer Bug on the chipset. Due to workarounds for a bug,\n" "* this clock source is slow. Consider trying other clock sources\n");
staticvoid acpi_pm_check_graylist(struct pci_dev *dev)
{ if (acpi_pm_good) return;
pr_warn("* The chipset may have PM-Timer Bug. Due to workarounds for a bug,\n" "* this clock source is slow. If you are sure your timer does not have\n" "* this bug, please use \"acpi_pm_good\" to disable the workaround\n");
#ifndef CONFIG_X86_64 #include <asm/mach_timer.h> #define PMTMR_EXPECTED_RATE \
((CALIBRATE_LATCH * (PMTMR_TICKS_PER_SEC >> 10)) / (PIT_TICK_RATE>>10)) /* * Some boards have the PMTMR running way too fast. We check * the PMTMR rate against PIT channel 2 to catch these cases.
*/ staticint verify_pmtmr_rate(void)
{
u64 value1, value2; unsignedlong count, delta;
/* Check that the PMTMR delta is within 5% of what we expect */ if (delta < (PMTMR_EXPECTED_RATE * 19) / 20 ||
delta > (PMTMR_EXPECTED_RATE * 21) / 20) {
pr_info("PM-Timer running at invalid rate: %lu%% of normal - aborting.\n",
100UL * delta / PMTMR_EXPECTED_RATE); return -1;
}
/* 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
/* "verify" this timing source: */ for (j = 0; j < ACPI_PM_MONOTONICITY_CHECKS; j++) {
udelay(100 * j);
value1 = clocksource_acpi_pm.read(&clocksource_acpi_pm); for (i = 0; i < ACPI_PM_READ_CHECKS; i++) {
value2 = clocksource_acpi_pm.read(&clocksource_acpi_pm); if (value2 == value1) continue; if (value2 > value1) break; if ((value2 < value1) && ((value2) < 0xFFF)) break;
pr_info("PM-Timer had inconsistent results: %#llx, %#llx - aborting.\n",
value1, value2);
pmtmr_ioport = 0; return -EINVAL;
} if (i == ACPI_PM_READ_CHECKS) {
pr_info("PM-Timer failed consistency check (%#llx) - aborting.\n",
value1);
pmtmr_ioport = 0; return -ENODEV;
}
}
if (verify_pmtmr_rate() != 0){
pmtmr_ioport = 0; return -ENODEV;
}
if (tsc_clocksource_watchdog_disabled())
clocksource_acpi_pm.flags |= CLOCK_SOURCE_MUST_VERIFY; return clocksource_register_hz(&clocksource_acpi_pm, PMTMR_TICKS_PER_SEC);
}
/* We use fs_initcall because we want the PCI fixups to have run * but we still need to load before device_initcall
*/
fs_initcall(init_acpi_pm_clocksource);
/* * Allow an override of the IOPort. Stupid BIOSes do not tell us about * the PMTimer, but we might know where it is.
*/ staticint __init parse_pmtmr(char *arg)
{ unsignedint base; int ret;
ret = kstrtouint(arg, 16, &base); if (ret) {
pr_warn("PMTMR: invalid 'pmtmr=' value: '%s'\n", arg); return 1;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.