xref: /linux/Documentation/driver-api/acpi/linuxized-acpica.rst (revision 93431e0607e58a3c997a134adc0fad4fdc147dab)
125710e23SChangbin Du.. SPDX-License-Identifier: GPL-2.0
225710e23SChangbin Du.. include:: <isonum.txt>
325710e23SChangbin Du
425710e23SChangbin Du============================================================
525710e23SChangbin DuLinuxized ACPICA - Introduction to ACPICA Release Automation
625710e23SChangbin Du============================================================
725710e23SChangbin Du
825710e23SChangbin Du:Copyright: |copy| 2013-2016, Intel Corporation
925710e23SChangbin Du
1025710e23SChangbin Du:Author: Lv Zheng <lv.zheng@intel.com>
1125710e23SChangbin Du
1225710e23SChangbin Du
1325710e23SChangbin DuAbstract
1425710e23SChangbin Du========
1525710e23SChangbin DuThis document describes the ACPICA project and the relationship between
1625710e23SChangbin DuACPICA and Linux.  It also describes how ACPICA code in drivers/acpi/acpica,
1725710e23SChangbin Duinclude/acpi and tools/power/acpi is automatically updated to follow the
1825710e23SChangbin Duupstream.
1925710e23SChangbin Du
2025710e23SChangbin DuACPICA Project
2125710e23SChangbin Du==============
2225710e23SChangbin Du
2325710e23SChangbin DuThe ACPI Component Architecture (ACPICA) project provides an operating
2425710e23SChangbin Dusystem (OS)-independent reference implementation of the Advanced
2525710e23SChangbin DuConfiguration and Power Interface Specification (ACPI).  It has been
2625710e23SChangbin Duadapted by various host OSes.  By directly integrating ACPICA, Linux can
2725710e23SChangbin Dualso benefit from the application experiences of ACPICA from other host
2825710e23SChangbin DuOSes.
2925710e23SChangbin Du
3025710e23SChangbin DuThe homepage of ACPICA project is: www.acpica.org, it is maintained and
3125710e23SChangbin Dusupported by Intel Corporation.
3225710e23SChangbin Du
3325710e23SChangbin DuThe following figure depicts the Linux ACPI subsystem where the ACPICA
3425710e23SChangbin Duadaptation is included::
3525710e23SChangbin Du
3625710e23SChangbin Du      +---------------------------------------------------------+
3725710e23SChangbin Du      |                                                         |
3825710e23SChangbin Du      |   +---------------------------------------------------+ |
3925710e23SChangbin Du      |   | +------------------+                              | |
4025710e23SChangbin Du      |   | | Table Management |                              | |
4125710e23SChangbin Du      |   | +------------------+                              | |
4225710e23SChangbin Du      |   | +----------------------+                          | |
4325710e23SChangbin Du      |   | | Namespace Management |                          | |
4425710e23SChangbin Du      |   | +----------------------+                          | |
4525710e23SChangbin Du      |   | +------------------+       ACPICA Components      | |
4625710e23SChangbin Du      |   | | Event Management |                              | |
4725710e23SChangbin Du      |   | +------------------+                              | |
4825710e23SChangbin Du      |   | +---------------------+                           | |
4925710e23SChangbin Du      |   | | Resource Management |                           | |
5025710e23SChangbin Du      |   | +---------------------+                           | |
5125710e23SChangbin Du      |   | +---------------------+                           | |
5225710e23SChangbin Du      |   | | Hardware Management |                           | |
5325710e23SChangbin Du      |   | +---------------------+                           | |
5425710e23SChangbin Du      | +---------------------------------------------------+ | |
5525710e23SChangbin Du      | | |                            +------------------+ | | |
5625710e23SChangbin Du      | | |                            | OS Service Layer | | | |
5725710e23SChangbin Du      | | |                            +------------------+ | | |
5825710e23SChangbin Du      | | +-------------------------------------------------|-+ |
5925710e23SChangbin Du      | |   +--------------------+                          |   |
6025710e23SChangbin Du      | |   | Device Enumeration |                          |   |
6125710e23SChangbin Du      | |   +--------------------+                          |   |
6225710e23SChangbin Du      | |   +------------------+                            |   |
6325710e23SChangbin Du      | |   | Power Management |                            |   |
6425710e23SChangbin Du      | |   +------------------+     Linux/ACPI Components  |   |
6525710e23SChangbin Du      | |   +--------------------+                          |   |
6625710e23SChangbin Du      | |   | Thermal Management |                          |   |
6725710e23SChangbin Du      | |   +--------------------+                          |   |
6825710e23SChangbin Du      | |   +--------------------------+                    |   |
6925710e23SChangbin Du      | |   | Drivers for ACPI Devices |                    |   |
7025710e23SChangbin Du      | |   +--------------------------+                    |   |
7125710e23SChangbin Du      | |   +--------+                                      |   |
7225710e23SChangbin Du      | |   | ...... |                                      |   |
7325710e23SChangbin Du      | |   +--------+                                      |   |
7425710e23SChangbin Du      | +---------------------------------------------------+   |
7525710e23SChangbin Du      |                                                         |
7625710e23SChangbin Du      +---------------------------------------------------------+
7725710e23SChangbin Du
7825710e23SChangbin Du                 Figure 1. Linux ACPI Software Components
7925710e23SChangbin Du
8025710e23SChangbin Du.. note::
8125710e23SChangbin Du    A. OS Service Layer - Provided by Linux to offer OS dependent
8225710e23SChangbin Du       implementation of the predefined ACPICA interfaces (acpi_os_*).
8325710e23SChangbin Du       ::
8425710e23SChangbin Du
8525710e23SChangbin Du         include/acpi/acpiosxf.h
8625710e23SChangbin Du         drivers/acpi/osl.c
8725710e23SChangbin Du         include/acpi/platform
8825710e23SChangbin Du         include/asm/acenv.h
8925710e23SChangbin Du    B. ACPICA Functionality - Released from ACPICA code base to offer
9025710e23SChangbin Du       OS independent implementation of the ACPICA interfaces (acpi_*).
9125710e23SChangbin Du       ::
9225710e23SChangbin Du
9325710e23SChangbin Du         drivers/acpi/acpica
9425710e23SChangbin Du         include/acpi/ac*.h
9525710e23SChangbin Du         tools/power/acpi
9625710e23SChangbin Du    C. Linux/ACPI Functionality - Providing Linux specific ACPI
9725710e23SChangbin Du       functionality to the other Linux kernel subsystems and user space
9825710e23SChangbin Du       programs.
9925710e23SChangbin Du       ::
10025710e23SChangbin Du
10125710e23SChangbin Du         drivers/acpi
10225710e23SChangbin Du         include/linux/acpi.h
10325710e23SChangbin Du         include/linux/acpi*.h
10425710e23SChangbin Du         include/acpi
10525710e23SChangbin Du         tools/power/acpi
10625710e23SChangbin Du    D. Architecture Specific ACPICA/ACPI Functionalities - Provided by the
10725710e23SChangbin Du       ACPI subsystem to offer architecture specific implementation of the
10825710e23SChangbin Du       ACPI interfaces.  They are Linux specific components and are out of
10925710e23SChangbin Du       the scope of this document.
11025710e23SChangbin Du       ::
11125710e23SChangbin Du
11225710e23SChangbin Du         include/asm/acpi.h
11325710e23SChangbin Du         include/asm/acpi*.h
11425710e23SChangbin Du         arch/*/acpi
11525710e23SChangbin Du
11625710e23SChangbin DuACPICA Release
11725710e23SChangbin Du==============
11825710e23SChangbin Du
11925710e23SChangbin DuThe ACPICA project maintains its code base at the following repository URL:
12025710e23SChangbin Duhttps://github.com/acpica/acpica.git. As a rule, a release is made every
12125710e23SChangbin Dumonth.
12225710e23SChangbin Du
12325710e23SChangbin DuAs the coding style adopted by the ACPICA project is not acceptable by
12425710e23SChangbin DuLinux, there is a release process to convert the ACPICA git commits into
12525710e23SChangbin DuLinux patches.  The patches generated by this process are referred to as
12625710e23SChangbin Du"linuxized ACPICA patches".  The release process is carried out on a local
12725710e23SChangbin Ducopy the ACPICA git repository.  Each commit in the monthly release is
12825710e23SChangbin Duconverted into a linuxized ACPICA patch.  Together, they form the monthly
12925710e23SChangbin DuACPICA release patchset for the Linux ACPI community.  This process is
13025710e23SChangbin Duillustrated in the following figure::
13125710e23SChangbin Du
13225710e23SChangbin Du    +-----------------------------+
13325710e23SChangbin Du    | acpica / master (-) commits |
13425710e23SChangbin Du    +-----------------------------+
13525710e23SChangbin Du       /|\         |
13625710e23SChangbin Du        |         \|/
13725710e23SChangbin Du        |  /---------------------\    +----------------------+
13825710e23SChangbin Du        | < Linuxize repo Utility >-->| old linuxized acpica |--+
13925710e23SChangbin Du        |  \---------------------/    +----------------------+  |
14025710e23SChangbin Du        |                                                       |
14125710e23SChangbin Du     /---------\                                                |
14225710e23SChangbin Du    < git reset >                                                \
14325710e23SChangbin Du     \---------/                                                  \
14425710e23SChangbin Du       /|\                                                        /+-+
14525710e23SChangbin Du        |                                                        /   |
14625710e23SChangbin Du    +-----------------------------+                             |    |
14725710e23SChangbin Du    | acpica / master (+) commits |                             |    |
14825710e23SChangbin Du    +-----------------------------+                             |    |
14925710e23SChangbin Du                   |                                            |    |
15025710e23SChangbin Du                  \|/                                           |    |
15125710e23SChangbin Du         /-----------------------\    +----------------------+  |    |
15225710e23SChangbin Du        < Linuxize repo Utilities >-->| new linuxized acpica |--+    |
15325710e23SChangbin Du         \-----------------------/    +----------------------+       |
15425710e23SChangbin Du                                                                    \|/
15525710e23SChangbin Du    +--------------------------+                  /----------------------\
15625710e23SChangbin Du    | Linuxized ACPICA Patches |<----------------< Linuxize patch Utility >
15725710e23SChangbin Du    +--------------------------+                  \----------------------/
15825710e23SChangbin Du                   |
15925710e23SChangbin Du                  \|/
16025710e23SChangbin Du     /---------------------------\
16125710e23SChangbin Du    < Linux ACPI Community Review >
16225710e23SChangbin Du     \---------------------------/
16325710e23SChangbin Du                   |
16425710e23SChangbin Du                  \|/
16525710e23SChangbin Du    +-----------------------+    /------------------\    +----------------+
16625710e23SChangbin Du    | linux-pm / linux-next |-->< Linux Merge Window >-->| linux / master |
16725710e23SChangbin Du    +-----------------------+    \------------------/    +----------------+
16825710e23SChangbin Du
16925710e23SChangbin Du                Figure 2. ACPICA -> Linux Upstream Process
17025710e23SChangbin Du
17125710e23SChangbin Du.. note::
17225710e23SChangbin Du    A. Linuxize Utilities - Provided by the ACPICA repository, including a
17325710e23SChangbin Du       utility located in source/tools/acpisrc folder and a number of
17425710e23SChangbin Du       scripts located in generate/linux folder.
17525710e23SChangbin Du    B. acpica / master - "master" branch of the git repository at
17625710e23SChangbin Du       <https://github.com/acpica/acpica.git>.
17725710e23SChangbin Du    C. linux-pm / linux-next - "linux-next" branch of the git repository at
178*93431e06SAlexander A. Klimov       <https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git>.
17925710e23SChangbin Du    D. linux / master - "master" branch of the git repository at
180*93431e06SAlexander A. Klimov       <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git>.
18125710e23SChangbin Du
18225710e23SChangbin Du   Before the linuxized ACPICA patches are sent to the Linux ACPI community
18325710e23SChangbin Du   for review, there is a quality assurance build test process to reduce
18425710e23SChangbin Du   porting issues.  Currently this build process only takes care of the
18525710e23SChangbin Du   following kernel configuration options:
18625710e23SChangbin Du   CONFIG_ACPI/CONFIG_ACPI_DEBUG/CONFIG_ACPI_DEBUGGER
18725710e23SChangbin Du
18825710e23SChangbin DuACPICA Divergences
18925710e23SChangbin Du==================
19025710e23SChangbin Du
19125710e23SChangbin DuIdeally, all of the ACPICA commits should be converted into Linux patches
19225710e23SChangbin Duautomatically without manual modifications, the "linux / master" tree should
19325710e23SChangbin Ducontain the ACPICA code that exactly corresponds to the ACPICA code
19425710e23SChangbin Ducontained in "new linuxized acpica" tree and it should be possible to run
19525710e23SChangbin Duthe release process fully automatically.
19625710e23SChangbin Du
19725710e23SChangbin DuAs a matter of fact, however, there are source code differences between
19825710e23SChangbin Duthe ACPICA code in Linux and the upstream ACPICA code, referred to as
19925710e23SChangbin Du"ACPICA Divergences".
20025710e23SChangbin Du
20125710e23SChangbin DuThe various sources of ACPICA divergences include:
20225710e23SChangbin Du   1. Legacy divergences - Before the current ACPICA release process was
20325710e23SChangbin Du      established, there already had been divergences between Linux and
20425710e23SChangbin Du      ACPICA. Over the past several years those divergences have been greatly
20525710e23SChangbin Du      reduced, but there still are several ones and it takes time to figure
20625710e23SChangbin Du      out the underlying reasons for their existence.
20725710e23SChangbin Du   2. Manual modifications - Any manual modification (eg. coding style fixes)
20825710e23SChangbin Du      made directly in the Linux sources obviously hurts the ACPICA release
20925710e23SChangbin Du      automation.  Thus it is recommended to fix such issues in the ACPICA
21025710e23SChangbin Du      upstream source code and generate the linuxized fix using the ACPICA
21125710e23SChangbin Du      release utilities (please refer to Section 4 below for the details).
21225710e23SChangbin Du   3. Linux specific features - Sometimes it's impossible to use the
21325710e23SChangbin Du      current ACPICA APIs to implement features required by the Linux kernel,
21425710e23SChangbin Du      so Linux developers occasionally have to change ACPICA code directly.
21525710e23SChangbin Du      Those changes may not be acceptable by ACPICA upstream and in such cases
21625710e23SChangbin Du      they are left as committed ACPICA divergences unless the ACPICA side can
21725710e23SChangbin Du      implement new mechanisms as replacements for them.
21825710e23SChangbin Du   4. ACPICA release fixups - ACPICA only tests commits using a set of the
21925710e23SChangbin Du      user space simulation utilities, thus the linuxized ACPICA patches may
22025710e23SChangbin Du      break the Linux kernel, leaving us build/boot failures.  In order to
22125710e23SChangbin Du      avoid breaking Linux bisection, fixes are applied directly to the
22225710e23SChangbin Du      linuxized ACPICA patches during the release process.  When the release
22325710e23SChangbin Du      fixups are backported to the upstream ACPICA sources, they must follow
22425710e23SChangbin Du      the upstream ACPICA rules and so further modifications may appear.
22525710e23SChangbin Du      That may result in the appearance of new divergences.
22625710e23SChangbin Du   5. Fast tracking of ACPICA commits - Some ACPICA commits are regression
22725710e23SChangbin Du      fixes or stable-candidate material, so they are applied in advance with
22825710e23SChangbin Du      respect to the ACPICA release process.  If such commits are reverted or
22925710e23SChangbin Du      rebased on the ACPICA side in order to offer better solutions, new ACPICA
23025710e23SChangbin Du      divergences are generated.
23125710e23SChangbin Du
23225710e23SChangbin DuACPICA Development
23325710e23SChangbin Du==================
23425710e23SChangbin Du
23525710e23SChangbin DuThis paragraph guides Linux developers to use the ACPICA upstream release
23625710e23SChangbin Duutilities to obtain Linux patches corresponding to upstream ACPICA commits
23725710e23SChangbin Dubefore they become available from the ACPICA release process.
23825710e23SChangbin Du
23925710e23SChangbin Du   1. Cherry-pick an ACPICA commit
24025710e23SChangbin Du
24125710e23SChangbin Du   First you need to git clone the ACPICA repository and the ACPICA change
24225710e23SChangbin Du   you want to cherry pick must be committed into the local repository.
24325710e23SChangbin Du
24425710e23SChangbin Du   Then the gen-patch.sh command can help to cherry-pick an ACPICA commit
24525710e23SChangbin Du   from the ACPICA local repository::
24625710e23SChangbin Du
24725710e23SChangbin Du   $ git clone https://github.com/acpica/acpica
24825710e23SChangbin Du   $ cd acpica
24925710e23SChangbin Du   $ generate/linux/gen-patch.sh -u [commit ID]
25025710e23SChangbin Du
25125710e23SChangbin Du   Here the commit ID is the ACPICA local repository commit ID you want to
25225710e23SChangbin Du   cherry pick.  It can be omitted if the commit is "HEAD".
25325710e23SChangbin Du
25425710e23SChangbin Du   2. Cherry-pick recent ACPICA commits
25525710e23SChangbin Du
25625710e23SChangbin Du   Sometimes you need to rebase your code on top of the most recent ACPICA
25725710e23SChangbin Du   changes that haven't been applied to Linux yet.
25825710e23SChangbin Du
25925710e23SChangbin Du   You can generate the ACPICA release series yourself and rebase your code on
26025710e23SChangbin Du   top of the generated ACPICA release patches::
26125710e23SChangbin Du
26225710e23SChangbin Du   $ git clone https://github.com/acpica/acpica
26325710e23SChangbin Du   $ cd acpica
26425710e23SChangbin Du   $ generate/linux/make-patches.sh -u [commit ID]
26525710e23SChangbin Du
26625710e23SChangbin Du   The commit ID should be the last ACPICA commit accepted by Linux.  Usually,
26725710e23SChangbin Du   it is the commit modifying ACPI_CA_VERSION.  It can be found by executing
26825710e23SChangbin Du   "git blame source/include/acpixf.h" and referencing the line that contains
26925710e23SChangbin Du   "ACPI_CA_VERSION".
27025710e23SChangbin Du
27125710e23SChangbin Du   3. Inspect the current divergences
27225710e23SChangbin Du
27325710e23SChangbin Du   If you have local copies of both Linux and upstream ACPICA, you can generate
27425710e23SChangbin Du   a diff file indicating the state of the current divergences::
27525710e23SChangbin Du
27625710e23SChangbin Du   # git clone https://github.com/acpica/acpica
277*93431e06SAlexander A. Klimov   # git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
27825710e23SChangbin Du   # cd acpica
27925710e23SChangbin Du   # generate/linux/divergences.sh -s ../linux
280