linuxized-acpica.txt 13 KB

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