linuxized-acpica.rst 13 KB

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