ACPI introduction _ Linux

Source: Internet
Author: User
Tags using git dmesg

Http://www.columbia.edu /~ Ariel/ACPI/acpi_howto.txt

ACPI-the advanced configuration & Power interface. ACPI is the abstraction layer between OS, bios, and hardware. It allows independent development of the OS and platform. For example, the new OS can control the old platform, and the old OS can also control the new platform without additional modifications. The basic structure of ACPI is as follows:

A basic method in the computer field is to add an abstraction layer, so that the upper and lower layers of the abstraction layer develop independently. ACPI actually draws on similar ideas. ACPI abstraction is mainly implemented through the information provided in the ACPI table, including the ACPI register, AMLCodeAnd configuration information.

    • ACPI register, which describes ACPI-related registers. OS can directly obtain information about these registers from the ACPI table, so you do not need to know the specific hardware configuration.
    • AML code, a type of C code. Provided by the bios, the AML interpreter of the OS (named ACPI CA in Linux) interprets and executes the code. This is the key to the ACPI abstraction layer, which will be described in detail below.
    • Configuration information. ACPI contains a lot of configuration information, such as multi-processor configuration information (madt), NUMA configuration information (srat, slit), and high-precision timer (hpet.

AML code is the key to abstraction. To eliminate platform relevance, BIOS uses the AML code to implement Platform-related operations. The operating system does not need to know the details of the platform. It only needs to explain and execute the Code. In the process of interpreting and executing the code, the platform-related operations are executed. The ACPI Specification defines some standard AML functions, and the OS can implement specific functions by performing such a standard function. For example:

scope (_ sb. pci0.lpc) {operationregion (lpcs, pci_config, 0x00, 0x0100) field (lpcs, anyacc, nolock, preserve) {offset (0x60), Pira, 8 ,}} device (lnka) {method (_ DIS, 0, notserialized) {or (\ _ sb. pci0.lpc. pira, 0x80, \ _ sb. pci0.lpc. pira) }}

For example, to disable the lnka device, The ACPI Specification defines that the OS must execute the _ dis function of the device. From the hardware point of view, to disable the lnka device, you need to set the maximum position of the configuration space register of a PCI device to 0 × 60. The OS does not need to know the hardware details. It just needs to explain and execute the _ dis function. The above code is the AML code, provided by the bios, with the 'or (\ _ sb. pci0.lpc. pira, 0 × 80, \ _ sb. pci0.lpc. pira) 'is actually to register \ _ sb. pci0.lpc. pira is the highest bit, and PIRA is the registers 0 × 60 in the configuration space of the PCI device LPC. From this code segment, we can clearly see that BIOS hides (abstract) Hardware details in the form of AML code, so that the OS can see a platform-independent hardware.

More ACPI predefined functions can be found in the ACPI specification and can be downloaded from the http://www.acpi.info to the latest specification.

The AML interpreter used in Linux/ACPI implementation is acpica-The ACPI component architecture. It can be obtained from http://www.intel.com/policy/iapc/acpi/downloads.htm. It contains an AML interpreter (Linux kernel includes this interpreter, and many other operating systems, such as BSD and opensolaris), a compiler (ACPI source language (ASL) compiled into AML code) and some test tools.

The latest Linux/ACPI code can use git in http://www.kernel.org/git? P = Linux/kernel/git/lenb/linux-acpi-2.6.git get.

Why ACPI Learning

ACPI is the standard firmware specification for Intel (i386, x86_64, IA64) platforms. Most operating systems can obtain information from BIOS, in addition, the current trend is that any new feature-related information in the future can only be obtained from ACPI. The content of ACPI is complex. Learning ACPI can at least help us understand:

    • Configuration information. This information is obtained from the configuration of the legacy PNP device, to the multi-processor, to NUMA. For example, the current multiple core information can only be obtained from ACPI. In Linux, many codes are used to process the configuration information, such as APIC and ioapic settings.
    • ACPI related devices. Laptop-related devices, including power buttons, batteries, external power supplies, fans, and hotkeys.
    • Underlying hardware. For example, PCI interrupt routing and chipset (mainly nanqiao PCI-to-LPC Bridge) operations.
    • Power Management. The power management defined by ACPI includes CPU power management (p-state adjustment frequency, idle C-state, throtting T-state), device power management (D-state ), system Power Management (suspend-to-Ram, suspend-to-disk, power off) and so on.
    • Device hot swapping. ACPI describes the hot swapping of devices in a unified way, from a single PCI device to the docking station of the laptop, to the whole PCI hierarchy, CPU, memory, even the entire NUMA node.

To understand the modern PC platform, you must understand ACPI.

Tips for ACPI Problems

First, you can check whether this is a regression. If the previous version of Linux kernel can work, but the new version does not work, it is a regression. You can test different kernel to find out which version introduced the bug. Using Git-bisect is a good choice. It can help you locate which patch causes regression. Some git-bisect related information is as follows: http://www.stardust.webpages.pl/files/handbook/handbook-en.pdf http://www.kernel.org/pub/software/scm/git/docs/tutorial.html http://www.kernel.org/pub/software/scm/git/docs/git-bisect.html

The system cannot be started.

Try the Kernel Parameter "ACPI = off". If this parameter has not changed, this is not an ACPI bug. Conversely, this is probably an ACPI bug. After confirming that it is an ACPI bug, we have other parameters to further differentiate which part of the bug is ACPI.

ACPI = HT

 
This parameter is almost the same as "ACPI = off". It disables all ACPI functions except for the content related to the multi-processor configuration. If ACPI = off is normal, but ACPI = HT is abnormal, There is a bug in the Code for parsing the ACPI table or Linux SMP.

PCI = noacpi

 
Do not use ACPI to process any PCI-related content, including enumerative PCI root bus and PCI device interruption routing.

ACPI = noirq

 
Do not use ACPI to handle PCI device interruption routing. The difference from PCI = noacpi is that it allows the use of ACPI to enumerate PCI root bus.

Pnpacpi = off

Do not use ACPI to enumerate PNP devices, such as serial ports, pS2 keyboards, and mouse.

Noapic

 
Do not use io-APIC for device interruption routing. One of the effects of this is that the interrupt route table returned by ACPI is for PIC (8259.

Nolapic

 
Do not use local-APIC or IO-APIC.
Device interruption Problems

There are many possibilities for interruptions, such as drivers.ProgramThere are bugs. The most common interruption problem caused by ACPI is kernel output: "irqxx: nobody cared !". This means that the kernel receives an interrupt, but there is no driver to handle it. The kernel will disable the interruption, so that all devices attached to the interruption will stop working. PCI = noacpi, ACPI = noirq, pnpacpi = OFF, noapic, and nolapic can help isolate some problems. Another useful parameter is "irqpoll". When the above interruption problem occurs, it can enable the kernel to automatically detect which device has triggered the interruption. This parameter is useful for debugging systems that have problems with interrupted routes.

Suspend to ram

A common problem with STR is that the system does not die after resume is returned. For example, the system can be accessed through the network or the keyboard lamp works normally. You can try the Kernel Parameter acpi_sleep = s3_bios/s3_mode, which will try to turn the display on. If not, try vbetools (http://www.srcf.ucam.org /~ Mjg59/vbetool). After resume returns, enter $ vbetool post for convenience. You can call this command in your STR script.

Another common problem with STR is that the system cannot return resume. You can try acpi_sleep = s3_beep. If you cannot hear the sound from your computer's speakers, the resume code is not executed at all. This may be the cause of the bios, or the cause of Linux. There is no good solution yet. On the contrary, it may be because of Linux driver. You can try to load as few drivers as possible and keep only the most basic drivers, such as hard drive.

Suspend to disk

TBD

ACPI debug Parameters

The parameters are ACPI. debug_level and ACPI. debug_layer. If the debug parameter is enabled, ACPI can generate a lot of detailed running output. These outputs help us identify the cause of the error.

For debug_layer and debug_level, include/ACPI/acutput. h contains many values, which determine the details and content range of Linux/ACPI output information. ACPI. debug_level and ACPI. debug_layer are kernel parameters. You can also change these values when the system is running. They are/sys/module/ACPI/parameters/debug _ {level, layer }.

Note that the output information may soon run out of the ring buffer of the kernel. You may need to use log_buf_len = xy to increase the ring buffer size. Using the serial console (Documentation/serial-console.txt) is a good way to get the kernel output. If your laptop does not have a serial port, try netconsole (Documentation/networking/netconsole.txt ).

Use a custom dsdt

Dsdt (differentiated system description table) is a major ACPI table that contains a lot of AML code. These codes may be wrong due to BIOS bugs. A method provided by Linux allows you to use a customized dsdt table, which is helpful for debugging. Perform the following steps to use a custom dsdt for kernel:

First, obtain the original dsdt table (tools such as acpidump will be introduced later): $ acpidump> acpidump. out $ acpixtract dsdt acpidump> dsdt. in this way, we get the binary file of the dsdt table and decompile $ IASL-D dsdt. dat we will get an AML code file, you can modify it $ VI dsdt. DSL then re-compile $ IASL-TC dsdt. DSL copies it to the kernel source $ CP dsdt. hex $ src/include/

Add the following lines to your Kernel configuration file (. config ):

Config_standalone = n config_acpi_custom_dsdt = y config_acpi_custom_dsdt_file = "dsdt. HEX"

Compile the kernel and run it. Your dmesg should have the following output: Table [dsdt] replaced by host OS

With this method, you can fix the dsdt bug. This method brings about a useful Debug Method: Open the debug option of ACPI, and add a statement similar to the following in your dsdt: store ("Hello World !", Debug) store (local0, debug) stores a variable in a special target debug. When the function with such a statement is interpreted and executed by the kernel, you can see the following output: [ACPI debug] string: [0x0c] "Hello world !" [ACPI debug] INTEGER: 0 × 00000042 so that we can debug the code at the AML level.

Report ACPI bug

Linux/ACPICommunityUse kernel Bugzilla to track bugs. Http://bugzilla.kernel.org/enter_bug.cgi? Product = ACPI. This website is mainly used to track the bug of base kernel. If you have a bug in a specific release, do not send it to this website. Linux/ACPI has its own mail list (linux-acpi@vger.kernel.org) where you can also discuss the issue. In addition, Intel's Linux/ACPI group also has an e-mail address (acpi@linux.intel.com), if your problem is not public, you can send it here.

If you report a bug, submit the following information:

    1. Kernel version that generates the bug
    2. Is there such a bug in the previous kernel. If this is a regression, what is the kernel version that can be used recently. If you can use Git-bisect to find the patch that brings regression, the problem is basically solved.
    3. The error kernel and dmesg information of the latest working kernel. You may need to use the serial console to obtain this information.
    4. If this is a problem related to the interruption, provide/proc/interrupts output when the kernel fails and works. The outputs of/sbin/lspci-vvv and/sbin/lspci-xxx are also useful.
    5. Please provide acpidump output. Acpidump is a tool that can name the ACPI table in the system. You can find this tool at http://ftp.kernel.org/pub/linux/kernel/lele/lenb/acpi/utils. Note that acpidump outputs BIOS tables. Different BIOS versions may have different tables.
    6. If we find that there is a problem with bios, We can blacklist the system. In this case, we need to provide dmidecode (usually under/usr/sbin/) tool output.
    7. The Kernel configuration file that generates the bug
How to Use ACPI

Bytes. The procedure is as follows: export all tables, which are binary $ acpidump> acpidump. Out

The above output contains many ACPI tables. If you want to split them out, use $ acpixtract-A acpidump. Out

Disassemble a table $ IASL-D table. dat to obtain the AML code of class C.

References

ACPI in Linux-myths vs. Reality (OLS 2007) Paper: https://ols2006.108.redhat.com/2007/Reprints/brown_1-Reprint.pdf Presentation: http://ftp.kernel.org/pub/linux/kernel/people/lenb/acpi/doc/OLS2007-acpi-myths-web/

ACPI in Linux-architecture, advances, and challenges (OLS 2005) Paper: http://www.linuxsymposium.org/2005/linuxsymposium_procv1.pdf Presentation: http://ftp.kernel.org/pub/linux/kernel/people/lenb/acpi/doc/ACPI_OLS_2005.pdf

The state of ACPI in the Linux kernel (OLS 2004) http://ftp.kernel.org/pub/linux/kernel/people/lenb/acpi/doc/Reprint-Brown-OLS2004.pdf

Todo List
    1. Stability of suspend/resume. Suspend-to-Ram cannot work on many laptops. Many drivers do not implement the. Suspend/. Resume method or there is a problem with the implementation.
    2. Hotkey support. Many laptop manufacturers use different methods to support hotkey. Now Linux supports IBM, Asus, toshba, and so on. However, there are still many manufacturers that do not support it. Even the supported manufacturers do not support many laptop models.
    3. Device power management during running. Linux also lacks a framework to manage the power of the device when the system is running. For example, if a device is idle, It is disabled without affecting the operation of the entire system.
    4. Device model improvement. Linux still lacks a good mechanism to unify ACPI devices and their corresponding physical devices.
    5. There are many ACPI bugs on Bugzilla.

From: http://wiki.zh-kernel.org/project/linux-acpi

Read the full text

Category:View comments by default

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.