162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci.. include:: <isonum.txt>
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci============================================================
562306a36Sopenharmony_ciLinuxized ACPICA - Introduction to ACPICA Release Automation
662306a36Sopenharmony_ci============================================================
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci:Copyright: |copy| 2013-2016, Intel Corporation
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci:Author: Lv Zheng <lv.zheng@intel.com>
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ciAbstract
1462306a36Sopenharmony_ci========
1562306a36Sopenharmony_ciThis document describes the ACPICA project and the relationship between
1662306a36Sopenharmony_ciACPICA and Linux.  It also describes how ACPICA code in drivers/acpi/acpica,
1762306a36Sopenharmony_ciinclude/acpi and tools/power/acpi is automatically updated to follow the
1862306a36Sopenharmony_ciupstream.
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ciACPICA Project
2162306a36Sopenharmony_ci==============
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ciThe ACPI Component Architecture (ACPICA) project provides an operating
2462306a36Sopenharmony_cisystem (OS)-independent reference implementation of the Advanced
2562306a36Sopenharmony_ciConfiguration and Power Interface Specification (ACPI).  It has been
2662306a36Sopenharmony_ciadapted by various host OSes.  By directly integrating ACPICA, Linux can
2762306a36Sopenharmony_cialso benefit from the application experiences of ACPICA from other host
2862306a36Sopenharmony_ciOSes.
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ciThe homepage of ACPICA project is: www.acpica.org, it is maintained and
3162306a36Sopenharmony_cisupported by Intel Corporation.
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ciThe following figure depicts the Linux ACPI subsystem where the ACPICA
3462306a36Sopenharmony_ciadaptation is included::
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci      +---------------------------------------------------------+
3762306a36Sopenharmony_ci      |                                                         |
3862306a36Sopenharmony_ci      |   +---------------------------------------------------+ |
3962306a36Sopenharmony_ci      |   | +------------------+                              | |
4062306a36Sopenharmony_ci      |   | | Table Management |                              | |
4162306a36Sopenharmony_ci      |   | +------------------+                              | |
4262306a36Sopenharmony_ci      |   | +----------------------+                          | |
4362306a36Sopenharmony_ci      |   | | Namespace Management |                          | |
4462306a36Sopenharmony_ci      |   | +----------------------+                          | |
4562306a36Sopenharmony_ci      |   | +------------------+       ACPICA Components      | |
4662306a36Sopenharmony_ci      |   | | Event Management |                              | |
4762306a36Sopenharmony_ci      |   | +------------------+                              | |
4862306a36Sopenharmony_ci      |   | +---------------------+                           | |
4962306a36Sopenharmony_ci      |   | | Resource Management |                           | |
5062306a36Sopenharmony_ci      |   | +---------------------+                           | |
5162306a36Sopenharmony_ci      |   | +---------------------+                           | |
5262306a36Sopenharmony_ci      |   | | Hardware Management |                           | |
5362306a36Sopenharmony_ci      |   | +---------------------+                           | |
5462306a36Sopenharmony_ci      | +---------------------------------------------------+ | |
5562306a36Sopenharmony_ci      | | |                            +------------------+ | | |
5662306a36Sopenharmony_ci      | | |                            | OS Service Layer | | | |
5762306a36Sopenharmony_ci      | | |                            +------------------+ | | |
5862306a36Sopenharmony_ci      | | +-------------------------------------------------|-+ |
5962306a36Sopenharmony_ci      | |   +--------------------+                          |   |
6062306a36Sopenharmony_ci      | |   | Device Enumeration |                          |   |
6162306a36Sopenharmony_ci      | |   +--------------------+                          |   |
6262306a36Sopenharmony_ci      | |   +------------------+                            |   |
6362306a36Sopenharmony_ci      | |   | Power Management |                            |   |
6462306a36Sopenharmony_ci      | |   +------------------+     Linux/ACPI Components  |   |
6562306a36Sopenharmony_ci      | |   +--------------------+                          |   |
6662306a36Sopenharmony_ci      | |   | Thermal Management |                          |   |
6762306a36Sopenharmony_ci      | |   +--------------------+                          |   |
6862306a36Sopenharmony_ci      | |   +--------------------------+                    |   |
6962306a36Sopenharmony_ci      | |   | Drivers for ACPI Devices |                    |   |
7062306a36Sopenharmony_ci      | |   +--------------------------+                    |   |
7162306a36Sopenharmony_ci      | |   +--------+                                      |   |
7262306a36Sopenharmony_ci      | |   | ...... |                                      |   |
7362306a36Sopenharmony_ci      | |   +--------+                                      |   |
7462306a36Sopenharmony_ci      | +---------------------------------------------------+   |
7562306a36Sopenharmony_ci      |                                                         |
7662306a36Sopenharmony_ci      +---------------------------------------------------------+
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci                 Figure 1. Linux ACPI Software Components
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci.. note::
8162306a36Sopenharmony_ci    A. OS Service Layer - Provided by Linux to offer OS dependent
8262306a36Sopenharmony_ci       implementation of the predefined ACPICA interfaces (acpi_os_*).
8362306a36Sopenharmony_ci       ::
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci         include/acpi/acpiosxf.h
8662306a36Sopenharmony_ci         drivers/acpi/osl.c
8762306a36Sopenharmony_ci         include/acpi/platform
8862306a36Sopenharmony_ci         include/asm/acenv.h
8962306a36Sopenharmony_ci    B. ACPICA Functionality - Released from ACPICA code base to offer
9062306a36Sopenharmony_ci       OS independent implementation of the ACPICA interfaces (acpi_*).
9162306a36Sopenharmony_ci       ::
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci         drivers/acpi/acpica
9462306a36Sopenharmony_ci         include/acpi/ac*.h
9562306a36Sopenharmony_ci         tools/power/acpi
9662306a36Sopenharmony_ci    C. Linux/ACPI Functionality - Providing Linux specific ACPI
9762306a36Sopenharmony_ci       functionality to the other Linux kernel subsystems and user space
9862306a36Sopenharmony_ci       programs.
9962306a36Sopenharmony_ci       ::
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci         drivers/acpi
10262306a36Sopenharmony_ci         include/linux/acpi.h
10362306a36Sopenharmony_ci         include/linux/acpi*.h
10462306a36Sopenharmony_ci         include/acpi
10562306a36Sopenharmony_ci         tools/power/acpi
10662306a36Sopenharmony_ci    D. Architecture Specific ACPICA/ACPI Functionalities - Provided by the
10762306a36Sopenharmony_ci       ACPI subsystem to offer architecture specific implementation of the
10862306a36Sopenharmony_ci       ACPI interfaces.  They are Linux specific components and are out of
10962306a36Sopenharmony_ci       the scope of this document.
11062306a36Sopenharmony_ci       ::
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci         include/asm/acpi.h
11362306a36Sopenharmony_ci         include/asm/acpi*.h
11462306a36Sopenharmony_ci         arch/*/acpi
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ciACPICA Release
11762306a36Sopenharmony_ci==============
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ciThe ACPICA project maintains its code base at the following repository URL:
12062306a36Sopenharmony_cihttps://github.com/acpica/acpica.git. As a rule, a release is made every
12162306a36Sopenharmony_cimonth.
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ciAs the coding style adopted by the ACPICA project is not acceptable by
12462306a36Sopenharmony_ciLinux, there is a release process to convert the ACPICA git commits into
12562306a36Sopenharmony_ciLinux patches.  The patches generated by this process are referred to as
12662306a36Sopenharmony_ci"linuxized ACPICA patches".  The release process is carried out on a local
12762306a36Sopenharmony_cicopy the ACPICA git repository.  Each commit in the monthly release is
12862306a36Sopenharmony_ciconverted into a linuxized ACPICA patch.  Together, they form the monthly
12962306a36Sopenharmony_ciACPICA release patchset for the Linux ACPI community.  This process is
13062306a36Sopenharmony_ciillustrated in the following figure::
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ci    +-----------------------------+
13362306a36Sopenharmony_ci    | acpica / master (-) commits |
13462306a36Sopenharmony_ci    +-----------------------------+
13562306a36Sopenharmony_ci       /|\         |
13662306a36Sopenharmony_ci        |         \|/
13762306a36Sopenharmony_ci        |  /---------------------\    +----------------------+
13862306a36Sopenharmony_ci        | < Linuxize repo Utility >-->| old linuxized acpica |--+
13962306a36Sopenharmony_ci        |  \---------------------/    +----------------------+  |
14062306a36Sopenharmony_ci        |                                                       |
14162306a36Sopenharmony_ci     /---------\                                                |
14262306a36Sopenharmony_ci    < git reset >                                                \
14362306a36Sopenharmony_ci     \---------/                                                  \
14462306a36Sopenharmony_ci       /|\                                                        /+-+
14562306a36Sopenharmony_ci        |                                                        /   |
14662306a36Sopenharmony_ci    +-----------------------------+                             |    |
14762306a36Sopenharmony_ci    | acpica / master (+) commits |                             |    |
14862306a36Sopenharmony_ci    +-----------------------------+                             |    |
14962306a36Sopenharmony_ci                   |                                            |    |
15062306a36Sopenharmony_ci                  \|/                                           |    |
15162306a36Sopenharmony_ci         /-----------------------\    +----------------------+  |    |
15262306a36Sopenharmony_ci        < Linuxize repo Utilities >-->| new linuxized acpica |--+    |
15362306a36Sopenharmony_ci         \-----------------------/    +----------------------+       |
15462306a36Sopenharmony_ci                                                                    \|/
15562306a36Sopenharmony_ci    +--------------------------+                  /----------------------\
15662306a36Sopenharmony_ci    | Linuxized ACPICA Patches |<----------------< Linuxize patch Utility >
15762306a36Sopenharmony_ci    +--------------------------+                  \----------------------/
15862306a36Sopenharmony_ci                   |
15962306a36Sopenharmony_ci                  \|/
16062306a36Sopenharmony_ci     /---------------------------\
16162306a36Sopenharmony_ci    < Linux ACPI Community Review >
16262306a36Sopenharmony_ci     \---------------------------/
16362306a36Sopenharmony_ci                   |
16462306a36Sopenharmony_ci                  \|/
16562306a36Sopenharmony_ci    +-----------------------+    /------------------\    +----------------+
16662306a36Sopenharmony_ci    | linux-pm / linux-next |-->< Linux Merge Window >-->| linux / master |
16762306a36Sopenharmony_ci    +-----------------------+    \------------------/    +----------------+
16862306a36Sopenharmony_ci
16962306a36Sopenharmony_ci                Figure 2. ACPICA -> Linux Upstream Process
17062306a36Sopenharmony_ci
17162306a36Sopenharmony_ci.. note::
17262306a36Sopenharmony_ci    A. Linuxize Utilities - Provided by the ACPICA repository, including a
17362306a36Sopenharmony_ci       utility located in source/tools/acpisrc folder and a number of
17462306a36Sopenharmony_ci       scripts located in generate/linux folder.
17562306a36Sopenharmony_ci    B. acpica / master - "master" branch of the git repository at
17662306a36Sopenharmony_ci       <https://github.com/acpica/acpica.git>.
17762306a36Sopenharmony_ci    C. linux-pm / linux-next - "linux-next" branch of the git repository at
17862306a36Sopenharmony_ci       <https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git>.
17962306a36Sopenharmony_ci    D. linux / master - "master" branch of the git repository at
18062306a36Sopenharmony_ci       <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git>.
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_ci   Before the linuxized ACPICA patches are sent to the Linux ACPI community
18362306a36Sopenharmony_ci   for review, there is a quality assurance build test process to reduce
18462306a36Sopenharmony_ci   porting issues.  Currently this build process only takes care of the
18562306a36Sopenharmony_ci   following kernel configuration options:
18662306a36Sopenharmony_ci   CONFIG_ACPI/CONFIG_ACPI_DEBUG/CONFIG_ACPI_DEBUGGER
18762306a36Sopenharmony_ci
18862306a36Sopenharmony_ciACPICA Divergences
18962306a36Sopenharmony_ci==================
19062306a36Sopenharmony_ci
19162306a36Sopenharmony_ciIdeally, all of the ACPICA commits should be converted into Linux patches
19262306a36Sopenharmony_ciautomatically without manual modifications, the "linux / master" tree should
19362306a36Sopenharmony_cicontain the ACPICA code that exactly corresponds to the ACPICA code
19462306a36Sopenharmony_cicontained in "new linuxized acpica" tree and it should be possible to run
19562306a36Sopenharmony_cithe release process fully automatically.
19662306a36Sopenharmony_ci
19762306a36Sopenharmony_ciAs a matter of fact, however, there are source code differences between
19862306a36Sopenharmony_cithe ACPICA code in Linux and the upstream ACPICA code, referred to as
19962306a36Sopenharmony_ci"ACPICA Divergences".
20062306a36Sopenharmony_ci
20162306a36Sopenharmony_ciThe various sources of ACPICA divergences include:
20262306a36Sopenharmony_ci   1. Legacy divergences - Before the current ACPICA release process was
20362306a36Sopenharmony_ci      established, there already had been divergences between Linux and
20462306a36Sopenharmony_ci      ACPICA. Over the past several years those divergences have been greatly
20562306a36Sopenharmony_ci      reduced, but there still are several ones and it takes time to figure
20662306a36Sopenharmony_ci      out the underlying reasons for their existence.
20762306a36Sopenharmony_ci   2. Manual modifications - Any manual modification (eg. coding style fixes)
20862306a36Sopenharmony_ci      made directly in the Linux sources obviously hurts the ACPICA release
20962306a36Sopenharmony_ci      automation.  Thus it is recommended to fix such issues in the ACPICA
21062306a36Sopenharmony_ci      upstream source code and generate the linuxized fix using the ACPICA
21162306a36Sopenharmony_ci      release utilities (please refer to Section 4 below for the details).
21262306a36Sopenharmony_ci   3. Linux specific features - Sometimes it's impossible to use the
21362306a36Sopenharmony_ci      current ACPICA APIs to implement features required by the Linux kernel,
21462306a36Sopenharmony_ci      so Linux developers occasionally have to change ACPICA code directly.
21562306a36Sopenharmony_ci      Those changes may not be acceptable by ACPICA upstream and in such cases
21662306a36Sopenharmony_ci      they are left as committed ACPICA divergences unless the ACPICA side can
21762306a36Sopenharmony_ci      implement new mechanisms as replacements for them.
21862306a36Sopenharmony_ci   4. ACPICA release fixups - ACPICA only tests commits using a set of the
21962306a36Sopenharmony_ci      user space simulation utilities, thus the linuxized ACPICA patches may
22062306a36Sopenharmony_ci      break the Linux kernel, leaving us build/boot failures.  In order to
22162306a36Sopenharmony_ci      avoid breaking Linux bisection, fixes are applied directly to the
22262306a36Sopenharmony_ci      linuxized ACPICA patches during the release process.  When the release
22362306a36Sopenharmony_ci      fixups are backported to the upstream ACPICA sources, they must follow
22462306a36Sopenharmony_ci      the upstream ACPICA rules and so further modifications may appear.
22562306a36Sopenharmony_ci      That may result in the appearance of new divergences.
22662306a36Sopenharmony_ci   5. Fast tracking of ACPICA commits - Some ACPICA commits are regression
22762306a36Sopenharmony_ci      fixes or stable-candidate material, so they are applied in advance with
22862306a36Sopenharmony_ci      respect to the ACPICA release process.  If such commits are reverted or
22962306a36Sopenharmony_ci      rebased on the ACPICA side in order to offer better solutions, new ACPICA
23062306a36Sopenharmony_ci      divergences are generated.
23162306a36Sopenharmony_ci
23262306a36Sopenharmony_ciACPICA Development
23362306a36Sopenharmony_ci==================
23462306a36Sopenharmony_ci
23562306a36Sopenharmony_ciThis paragraph guides Linux developers to use the ACPICA upstream release
23662306a36Sopenharmony_ciutilities to obtain Linux patches corresponding to upstream ACPICA commits
23762306a36Sopenharmony_cibefore they become available from the ACPICA release process.
23862306a36Sopenharmony_ci
23962306a36Sopenharmony_ci   1. Cherry-pick an ACPICA commit
24062306a36Sopenharmony_ci
24162306a36Sopenharmony_ci   First you need to git clone the ACPICA repository and the ACPICA change
24262306a36Sopenharmony_ci   you want to cherry pick must be committed into the local repository.
24362306a36Sopenharmony_ci
24462306a36Sopenharmony_ci   Then the gen-patch.sh command can help to cherry-pick an ACPICA commit
24562306a36Sopenharmony_ci   from the ACPICA local repository::
24662306a36Sopenharmony_ci
24762306a36Sopenharmony_ci   $ git clone https://github.com/acpica/acpica
24862306a36Sopenharmony_ci   $ cd acpica
24962306a36Sopenharmony_ci   $ generate/linux/gen-patch.sh -u [commit ID]
25062306a36Sopenharmony_ci
25162306a36Sopenharmony_ci   Here the commit ID is the ACPICA local repository commit ID you want to
25262306a36Sopenharmony_ci   cherry pick.  It can be omitted if the commit is "HEAD".
25362306a36Sopenharmony_ci
25462306a36Sopenharmony_ci   2. Cherry-pick recent ACPICA commits
25562306a36Sopenharmony_ci
25662306a36Sopenharmony_ci   Sometimes you need to rebase your code on top of the most recent ACPICA
25762306a36Sopenharmony_ci   changes that haven't been applied to Linux yet.
25862306a36Sopenharmony_ci
25962306a36Sopenharmony_ci   You can generate the ACPICA release series yourself and rebase your code on
26062306a36Sopenharmony_ci   top of the generated ACPICA release patches::
26162306a36Sopenharmony_ci
26262306a36Sopenharmony_ci   $ git clone https://github.com/acpica/acpica
26362306a36Sopenharmony_ci   $ cd acpica
26462306a36Sopenharmony_ci   $ generate/linux/make-patches.sh -u [commit ID]
26562306a36Sopenharmony_ci
26662306a36Sopenharmony_ci   The commit ID should be the last ACPICA commit accepted by Linux.  Usually,
26762306a36Sopenharmony_ci   it is the commit modifying ACPI_CA_VERSION.  It can be found by executing
26862306a36Sopenharmony_ci   "git blame source/include/acpixf.h" and referencing the line that contains
26962306a36Sopenharmony_ci   "ACPI_CA_VERSION".
27062306a36Sopenharmony_ci
27162306a36Sopenharmony_ci   3. Inspect the current divergences
27262306a36Sopenharmony_ci
27362306a36Sopenharmony_ci   If you have local copies of both Linux and upstream ACPICA, you can generate
27462306a36Sopenharmony_ci   a diff file indicating the state of the current divergences::
27562306a36Sopenharmony_ci
27662306a36Sopenharmony_ci   # git clone https://github.com/acpica/acpica
27762306a36Sopenharmony_ci   # git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
27862306a36Sopenharmony_ci   # cd acpica
27962306a36Sopenharmony_ci   # generate/linux/divergence.sh -s ../linux
280