ACPI / LPIT: Add LPIT table support
Subsystems (2)
RFC PATCH 1/1 ACPI / LPIT: Add LPIT table support
Added functionality to read LPIT table, which provides:
- Sysfs interface to read residency counters via /sys/devices/system/cpu/cpuidle/low_power_idle_cpu_residency_us /sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us
Here the count "low_power_idle_cpu_residency_us" shows the time spent by CPU package in low power state. This is read via MSR interface, which points to MSR for PKG C10.
Here the count "low_power_idle_system_residency_us" show the count the system was in low power state. This is read via MMIO interface. This is mapped to SLP_S0 residency on modern Intel systems. This residency is achieved only when CPU is in PKG C10 and all functional blocks are in low power state.
It is possible that none of the above counters present or anyone of the counter present or all counters present.
For example: On my Kabylake system both of the above counters present.
This counter can be read by tools like turbostat to display. Or it can be used to debug, if the modern systems are reaching desired low power state.
- Provides an interface to read residency counter memory address This address can be used to get the base address of PMC memory mapped IO. This is utilized by intel_pmc_core driver to print more debug information.
--- drivers/acpi/Kconfig | 5 ++ drivers/acpi/Makefile | 1 + drivers/acpi/acpi_lpit.c | 162 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/acpi/scan.c | 3 + include/acpi/acpi_lpit.h | 34 ++++++++++ 5 files changed, 205 insertions(+) create mode 100644 drivers/acpi/acpi_lpit.c create mode 100644 include/acpi/acpi_lpit.h
drivers/acpi/Kconfig +5 -0
@@ -53,6 +53,7 @@ config ACPI_GENERIC_GSI config ACPI_SYSTEM_POWER_STATES_SUPPORT bool + select ACPI_LPIT config ACPI_CCA_REQUIRED bool
@@ -80,6 +81,10 @@ endif config ACPI_SPCR_TABLE bool +config ACPI_LPIT + bool + depends on X86 + config ACPI_SLEEP bool depends on SUSPEND || HIBERNATION
drivers/acpi/Makefile +1 -0
@@ -56,6 +56,7 @@ acpi-$(CONFIG_DEBUG_FS) += debugfs.o acpi-$(CONFIG_ACPI_NUMA) += numa.o acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o acpi-y += acpi_lpat.o +acpi-$(CONFIG_ACPI_LPIT) += acpi_lpit.o acpi-$(CONFIG_ACPI_GENERIC_GSI) += irq.o acpi-$(CONFIG_ACPI_WATCHDOG) += acpi_watchdog.o
drivers/acpi/acpi_lpit.c new file +162 -0
162 lines not on this page · raw message
drivers/acpi/scan.c +3 -0
@@ -15,6 +15,8 @@#include <linux/dma-mapping.h> #include <linux/platform_data/x86/apple.h> +#include <acpi/acpi_lpit.h> +#include <asm/pgtable.h> #include "internal.h"
@@ -2122,6 +2124,7 @@ int __init acpi_scan_init(void)acpi_int340x_thermal_init ();acpi_amba_init ();acpi_watchdog_init (); +acpi_init_lpit ();acpi_scan_add_handler (&generic_device_handler);
include/acpi/acpi_lpit.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* acpi_lpit.h - LPIT table processing functions interface +* +* Copyright (C) 2017 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License version +* 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef ACPI_LPIT_H +#define ACPI_LPIT_H + +#ifdef CONFIG_ACPI_LPIT + +void acpi_init_lpit (void ); +int lpit_read_residency_count_address (u64 *address); + +#else + +static inline void acpi_init_lpit (void ) { } + +static inline int lpit_read_residency_count_address (u64 *address) +{ +return -EINVAL ; +} + +#endif +#endif
Signature · 1 line
2.7.5