1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0 2*4882a593Smuzhiyun.. include:: <isonum.txt> 3*4882a593Smuzhiyun 4*4882a593Smuzhiyun============================================================ 5*4882a593SmuzhiyunLinuxized ACPICA - Introduction to ACPICA Release Automation 6*4882a593Smuzhiyun============================================================ 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun:Copyright: |copy| 2013-2016, Intel Corporation 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun:Author: Lv Zheng <lv.zheng@intel.com> 11*4882a593Smuzhiyun 12*4882a593Smuzhiyun 13*4882a593SmuzhiyunAbstract 14*4882a593Smuzhiyun======== 15*4882a593SmuzhiyunThis document describes the ACPICA project and the relationship between 16*4882a593SmuzhiyunACPICA and Linux. It also describes how ACPICA code in drivers/acpi/acpica, 17*4882a593Smuzhiyuninclude/acpi and tools/power/acpi is automatically updated to follow the 18*4882a593Smuzhiyunupstream. 19*4882a593Smuzhiyun 20*4882a593SmuzhiyunACPICA Project 21*4882a593Smuzhiyun============== 22*4882a593Smuzhiyun 23*4882a593SmuzhiyunThe ACPI Component Architecture (ACPICA) project provides an operating 24*4882a593Smuzhiyunsystem (OS)-independent reference implementation of the Advanced 25*4882a593SmuzhiyunConfiguration and Power Interface Specification (ACPI). It has been 26*4882a593Smuzhiyunadapted by various host OSes. By directly integrating ACPICA, Linux can 27*4882a593Smuzhiyunalso benefit from the application experiences of ACPICA from other host 28*4882a593SmuzhiyunOSes. 29*4882a593Smuzhiyun 30*4882a593SmuzhiyunThe homepage of ACPICA project is: www.acpica.org, it is maintained and 31*4882a593Smuzhiyunsupported by Intel Corporation. 32*4882a593Smuzhiyun 33*4882a593SmuzhiyunThe following figure depicts the Linux ACPI subsystem where the ACPICA 34*4882a593Smuzhiyunadaptation is included:: 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun +---------------------------------------------------------+ 37*4882a593Smuzhiyun | | 38*4882a593Smuzhiyun | +---------------------------------------------------+ | 39*4882a593Smuzhiyun | | +------------------+ | | 40*4882a593Smuzhiyun | | | Table Management | | | 41*4882a593Smuzhiyun | | +------------------+ | | 42*4882a593Smuzhiyun | | +----------------------+ | | 43*4882a593Smuzhiyun | | | Namespace Management | | | 44*4882a593Smuzhiyun | | +----------------------+ | | 45*4882a593Smuzhiyun | | +------------------+ ACPICA Components | | 46*4882a593Smuzhiyun | | | Event Management | | | 47*4882a593Smuzhiyun | | +------------------+ | | 48*4882a593Smuzhiyun | | +---------------------+ | | 49*4882a593Smuzhiyun | | | Resource Management | | | 50*4882a593Smuzhiyun | | +---------------------+ | | 51*4882a593Smuzhiyun | | +---------------------+ | | 52*4882a593Smuzhiyun | | | Hardware Management | | | 53*4882a593Smuzhiyun | | +---------------------+ | | 54*4882a593Smuzhiyun | +---------------------------------------------------+ | | 55*4882a593Smuzhiyun | | | +------------------+ | | | 56*4882a593Smuzhiyun | | | | OS Service Layer | | | | 57*4882a593Smuzhiyun | | | +------------------+ | | | 58*4882a593Smuzhiyun | | +-------------------------------------------------|-+ | 59*4882a593Smuzhiyun | | +--------------------+ | | 60*4882a593Smuzhiyun | | | Device Enumeration | | | 61*4882a593Smuzhiyun | | +--------------------+ | | 62*4882a593Smuzhiyun | | +------------------+ | | 63*4882a593Smuzhiyun | | | Power Management | | | 64*4882a593Smuzhiyun | | +------------------+ Linux/ACPI Components | | 65*4882a593Smuzhiyun | | +--------------------+ | | 66*4882a593Smuzhiyun | | | Thermal Management | | | 67*4882a593Smuzhiyun | | +--------------------+ | | 68*4882a593Smuzhiyun | | +--------------------------+ | | 69*4882a593Smuzhiyun | | | Drivers for ACPI Devices | | | 70*4882a593Smuzhiyun | | +--------------------------+ | | 71*4882a593Smuzhiyun | | +--------+ | | 72*4882a593Smuzhiyun | | | ...... | | | 73*4882a593Smuzhiyun | | +--------+ | | 74*4882a593Smuzhiyun | +---------------------------------------------------+ | 75*4882a593Smuzhiyun | | 76*4882a593Smuzhiyun +---------------------------------------------------------+ 77*4882a593Smuzhiyun 78*4882a593Smuzhiyun Figure 1. Linux ACPI Software Components 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun.. note:: 81*4882a593Smuzhiyun A. OS Service Layer - Provided by Linux to offer OS dependent 82*4882a593Smuzhiyun implementation of the predefined ACPICA interfaces (acpi_os_*). 83*4882a593Smuzhiyun :: 84*4882a593Smuzhiyun 85*4882a593Smuzhiyun include/acpi/acpiosxf.h 86*4882a593Smuzhiyun drivers/acpi/osl.c 87*4882a593Smuzhiyun include/acpi/platform 88*4882a593Smuzhiyun include/asm/acenv.h 89*4882a593Smuzhiyun B. ACPICA Functionality - Released from ACPICA code base to offer 90*4882a593Smuzhiyun OS independent implementation of the ACPICA interfaces (acpi_*). 91*4882a593Smuzhiyun :: 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun drivers/acpi/acpica 94*4882a593Smuzhiyun include/acpi/ac*.h 95*4882a593Smuzhiyun tools/power/acpi 96*4882a593Smuzhiyun C. Linux/ACPI Functionality - Providing Linux specific ACPI 97*4882a593Smuzhiyun functionality to the other Linux kernel subsystems and user space 98*4882a593Smuzhiyun programs. 99*4882a593Smuzhiyun :: 100*4882a593Smuzhiyun 101*4882a593Smuzhiyun drivers/acpi 102*4882a593Smuzhiyun include/linux/acpi.h 103*4882a593Smuzhiyun include/linux/acpi*.h 104*4882a593Smuzhiyun include/acpi 105*4882a593Smuzhiyun tools/power/acpi 106*4882a593Smuzhiyun D. Architecture Specific ACPICA/ACPI Functionalities - Provided by the 107*4882a593Smuzhiyun ACPI subsystem to offer architecture specific implementation of the 108*4882a593Smuzhiyun ACPI interfaces. They are Linux specific components and are out of 109*4882a593Smuzhiyun the scope of this document. 110*4882a593Smuzhiyun :: 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun include/asm/acpi.h 113*4882a593Smuzhiyun include/asm/acpi*.h 114*4882a593Smuzhiyun arch/*/acpi 115*4882a593Smuzhiyun 116*4882a593SmuzhiyunACPICA Release 117*4882a593Smuzhiyun============== 118*4882a593Smuzhiyun 119*4882a593SmuzhiyunThe ACPICA project maintains its code base at the following repository URL: 120*4882a593Smuzhiyunhttps://github.com/acpica/acpica.git. As a rule, a release is made every 121*4882a593Smuzhiyunmonth. 122*4882a593Smuzhiyun 123*4882a593SmuzhiyunAs the coding style adopted by the ACPICA project is not acceptable by 124*4882a593SmuzhiyunLinux, there is a release process to convert the ACPICA git commits into 125*4882a593SmuzhiyunLinux patches. The patches generated by this process are referred to as 126*4882a593Smuzhiyun"linuxized ACPICA patches". The release process is carried out on a local 127*4882a593Smuzhiyuncopy the ACPICA git repository. Each commit in the monthly release is 128*4882a593Smuzhiyunconverted into a linuxized ACPICA patch. Together, they form the monthly 129*4882a593SmuzhiyunACPICA release patchset for the Linux ACPI community. This process is 130*4882a593Smuzhiyunillustrated in the following figure:: 131*4882a593Smuzhiyun 132*4882a593Smuzhiyun +-----------------------------+ 133*4882a593Smuzhiyun | acpica / master (-) commits | 134*4882a593Smuzhiyun +-----------------------------+ 135*4882a593Smuzhiyun /|\ | 136*4882a593Smuzhiyun | \|/ 137*4882a593Smuzhiyun | /---------------------\ +----------------------+ 138*4882a593Smuzhiyun | < Linuxize repo Utility >-->| old linuxized acpica |--+ 139*4882a593Smuzhiyun | \---------------------/ +----------------------+ | 140*4882a593Smuzhiyun | | 141*4882a593Smuzhiyun /---------\ | 142*4882a593Smuzhiyun < git reset > \ 143*4882a593Smuzhiyun \---------/ \ 144*4882a593Smuzhiyun /|\ /+-+ 145*4882a593Smuzhiyun | / | 146*4882a593Smuzhiyun +-----------------------------+ | | 147*4882a593Smuzhiyun | acpica / master (+) commits | | | 148*4882a593Smuzhiyun +-----------------------------+ | | 149*4882a593Smuzhiyun | | | 150*4882a593Smuzhiyun \|/ | | 151*4882a593Smuzhiyun /-----------------------\ +----------------------+ | | 152*4882a593Smuzhiyun < Linuxize repo Utilities >-->| new linuxized acpica |--+ | 153*4882a593Smuzhiyun \-----------------------/ +----------------------+ | 154*4882a593Smuzhiyun \|/ 155*4882a593Smuzhiyun +--------------------------+ /----------------------\ 156*4882a593Smuzhiyun | Linuxized ACPICA Patches |<----------------< Linuxize patch Utility > 157*4882a593Smuzhiyun +--------------------------+ \----------------------/ 158*4882a593Smuzhiyun | 159*4882a593Smuzhiyun \|/ 160*4882a593Smuzhiyun /---------------------------\ 161*4882a593Smuzhiyun < Linux ACPI Community Review > 162*4882a593Smuzhiyun \---------------------------/ 163*4882a593Smuzhiyun | 164*4882a593Smuzhiyun \|/ 165*4882a593Smuzhiyun +-----------------------+ /------------------\ +----------------+ 166*4882a593Smuzhiyun | linux-pm / linux-next |-->< Linux Merge Window >-->| linux / master | 167*4882a593Smuzhiyun +-----------------------+ \------------------/ +----------------+ 168*4882a593Smuzhiyun 169*4882a593Smuzhiyun Figure 2. ACPICA -> Linux Upstream Process 170*4882a593Smuzhiyun 171*4882a593Smuzhiyun.. note:: 172*4882a593Smuzhiyun A. Linuxize Utilities - Provided by the ACPICA repository, including a 173*4882a593Smuzhiyun utility located in source/tools/acpisrc folder and a number of 174*4882a593Smuzhiyun scripts located in generate/linux folder. 175*4882a593Smuzhiyun B. acpica / master - "master" branch of the git repository at 176*4882a593Smuzhiyun <https://github.com/acpica/acpica.git>. 177*4882a593Smuzhiyun C. linux-pm / linux-next - "linux-next" branch of the git repository at 178*4882a593Smuzhiyun <https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git>. 179*4882a593Smuzhiyun D. linux / master - "master" branch of the git repository at 180*4882a593Smuzhiyun <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git>. 181*4882a593Smuzhiyun 182*4882a593Smuzhiyun Before the linuxized ACPICA patches are sent to the Linux ACPI community 183*4882a593Smuzhiyun for review, there is a quality assurance build test process to reduce 184*4882a593Smuzhiyun porting issues. Currently this build process only takes care of the 185*4882a593Smuzhiyun following kernel configuration options: 186*4882a593Smuzhiyun CONFIG_ACPI/CONFIG_ACPI_DEBUG/CONFIG_ACPI_DEBUGGER 187*4882a593Smuzhiyun 188*4882a593SmuzhiyunACPICA Divergences 189*4882a593Smuzhiyun================== 190*4882a593Smuzhiyun 191*4882a593SmuzhiyunIdeally, all of the ACPICA commits should be converted into Linux patches 192*4882a593Smuzhiyunautomatically without manual modifications, the "linux / master" tree should 193*4882a593Smuzhiyuncontain the ACPICA code that exactly corresponds to the ACPICA code 194*4882a593Smuzhiyuncontained in "new linuxized acpica" tree and it should be possible to run 195*4882a593Smuzhiyunthe release process fully automatically. 196*4882a593Smuzhiyun 197*4882a593SmuzhiyunAs a matter of fact, however, there are source code differences between 198*4882a593Smuzhiyunthe ACPICA code in Linux and the upstream ACPICA code, referred to as 199*4882a593Smuzhiyun"ACPICA Divergences". 200*4882a593Smuzhiyun 201*4882a593SmuzhiyunThe various sources of ACPICA divergences include: 202*4882a593Smuzhiyun 1. Legacy divergences - Before the current ACPICA release process was 203*4882a593Smuzhiyun established, there already had been divergences between Linux and 204*4882a593Smuzhiyun ACPICA. Over the past several years those divergences have been greatly 205*4882a593Smuzhiyun reduced, but there still are several ones and it takes time to figure 206*4882a593Smuzhiyun out the underlying reasons for their existence. 207*4882a593Smuzhiyun 2. Manual modifications - Any manual modification (eg. coding style fixes) 208*4882a593Smuzhiyun made directly in the Linux sources obviously hurts the ACPICA release 209*4882a593Smuzhiyun automation. Thus it is recommended to fix such issues in the ACPICA 210*4882a593Smuzhiyun upstream source code and generate the linuxized fix using the ACPICA 211*4882a593Smuzhiyun release utilities (please refer to Section 4 below for the details). 212*4882a593Smuzhiyun 3. Linux specific features - Sometimes it's impossible to use the 213*4882a593Smuzhiyun current ACPICA APIs to implement features required by the Linux kernel, 214*4882a593Smuzhiyun so Linux developers occasionally have to change ACPICA code directly. 215*4882a593Smuzhiyun Those changes may not be acceptable by ACPICA upstream and in such cases 216*4882a593Smuzhiyun they are left as committed ACPICA divergences unless the ACPICA side can 217*4882a593Smuzhiyun implement new mechanisms as replacements for them. 218*4882a593Smuzhiyun 4. ACPICA release fixups - ACPICA only tests commits using a set of the 219*4882a593Smuzhiyun user space simulation utilities, thus the linuxized ACPICA patches may 220*4882a593Smuzhiyun break the Linux kernel, leaving us build/boot failures. In order to 221*4882a593Smuzhiyun avoid breaking Linux bisection, fixes are applied directly to the 222*4882a593Smuzhiyun linuxized ACPICA patches during the release process. When the release 223*4882a593Smuzhiyun fixups are backported to the upstream ACPICA sources, they must follow 224*4882a593Smuzhiyun the upstream ACPICA rules and so further modifications may appear. 225*4882a593Smuzhiyun That may result in the appearance of new divergences. 226*4882a593Smuzhiyun 5. Fast tracking of ACPICA commits - Some ACPICA commits are regression 227*4882a593Smuzhiyun fixes or stable-candidate material, so they are applied in advance with 228*4882a593Smuzhiyun respect to the ACPICA release process. If such commits are reverted or 229*4882a593Smuzhiyun rebased on the ACPICA side in order to offer better solutions, new ACPICA 230*4882a593Smuzhiyun divergences are generated. 231*4882a593Smuzhiyun 232*4882a593SmuzhiyunACPICA Development 233*4882a593Smuzhiyun================== 234*4882a593Smuzhiyun 235*4882a593SmuzhiyunThis paragraph guides Linux developers to use the ACPICA upstream release 236*4882a593Smuzhiyunutilities to obtain Linux patches corresponding to upstream ACPICA commits 237*4882a593Smuzhiyunbefore they become available from the ACPICA release process. 238*4882a593Smuzhiyun 239*4882a593Smuzhiyun 1. Cherry-pick an ACPICA commit 240*4882a593Smuzhiyun 241*4882a593Smuzhiyun First you need to git clone the ACPICA repository and the ACPICA change 242*4882a593Smuzhiyun you want to cherry pick must be committed into the local repository. 243*4882a593Smuzhiyun 244*4882a593Smuzhiyun Then the gen-patch.sh command can help to cherry-pick an ACPICA commit 245*4882a593Smuzhiyun from the ACPICA local repository:: 246*4882a593Smuzhiyun 247*4882a593Smuzhiyun $ git clone https://github.com/acpica/acpica 248*4882a593Smuzhiyun $ cd acpica 249*4882a593Smuzhiyun $ generate/linux/gen-patch.sh -u [commit ID] 250*4882a593Smuzhiyun 251*4882a593Smuzhiyun Here the commit ID is the ACPICA local repository commit ID you want to 252*4882a593Smuzhiyun cherry pick. It can be omitted if the commit is "HEAD". 253*4882a593Smuzhiyun 254*4882a593Smuzhiyun 2. Cherry-pick recent ACPICA commits 255*4882a593Smuzhiyun 256*4882a593Smuzhiyun Sometimes you need to rebase your code on top of the most recent ACPICA 257*4882a593Smuzhiyun changes that haven't been applied to Linux yet. 258*4882a593Smuzhiyun 259*4882a593Smuzhiyun You can generate the ACPICA release series yourself and rebase your code on 260*4882a593Smuzhiyun top of the generated ACPICA release patches:: 261*4882a593Smuzhiyun 262*4882a593Smuzhiyun $ git clone https://github.com/acpica/acpica 263*4882a593Smuzhiyun $ cd acpica 264*4882a593Smuzhiyun $ generate/linux/make-patches.sh -u [commit ID] 265*4882a593Smuzhiyun 266*4882a593Smuzhiyun The commit ID should be the last ACPICA commit accepted by Linux. Usually, 267*4882a593Smuzhiyun it is the commit modifying ACPI_CA_VERSION. It can be found by executing 268*4882a593Smuzhiyun "git blame source/include/acpixf.h" and referencing the line that contains 269*4882a593Smuzhiyun "ACPI_CA_VERSION". 270*4882a593Smuzhiyun 271*4882a593Smuzhiyun 3. Inspect the current divergences 272*4882a593Smuzhiyun 273*4882a593Smuzhiyun If you have local copies of both Linux and upstream ACPICA, you can generate 274*4882a593Smuzhiyun a diff file indicating the state of the current divergences:: 275*4882a593Smuzhiyun 276*4882a593Smuzhiyun # git clone https://github.com/acpica/acpica 277*4882a593Smuzhiyun # git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 278*4882a593Smuzhiyun # cd acpica 279*4882a593Smuzhiyun # generate/linux/divergences.sh -s ../linux 280