18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci.. include:: <isonum.txt>
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci=====================
58c2ecf20Sopenharmony_ciACPICA Trace Facility
68c2ecf20Sopenharmony_ci=====================
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci:Copyright: |copy| 2015, Intel Corporation
98c2ecf20Sopenharmony_ci:Author: Lv Zheng <lv.zheng@intel.com>
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ciAbstract
138c2ecf20Sopenharmony_ci========
148c2ecf20Sopenharmony_ciThis document describes the functions and the interfaces of the
158c2ecf20Sopenharmony_cimethod tracing facility.
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ciFunctionalities and usage examples
188c2ecf20Sopenharmony_ci==================================
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ciACPICA provides method tracing capability. And two functions are
218c2ecf20Sopenharmony_cicurrently implemented using this capability.
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ciLog reducer
248c2ecf20Sopenharmony_ci-----------
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ciACPICA subsystem provides debugging outputs when CONFIG_ACPI_DEBUG is
278c2ecf20Sopenharmony_cienabled. The debugging messages which are deployed via
288c2ecf20Sopenharmony_ciACPI_DEBUG_PRINT() macro can be reduced at 2 levels - per-component
298c2ecf20Sopenharmony_cilevel (known as debug layer, configured via
308c2ecf20Sopenharmony_ci/sys/module/acpi/parameters/debug_layer) and per-type level (known as
318c2ecf20Sopenharmony_cidebug level, configured via /sys/module/acpi/parameters/debug_level).
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ciBut when the particular layer/level is applied to the control method
348c2ecf20Sopenharmony_cievaluations, the quantity of the debugging outputs may still be too
358c2ecf20Sopenharmony_cilarge to be put into the kernel log buffer. The idea thus is worked out
368c2ecf20Sopenharmony_cito only enable the particular debug layer/level (normally more detailed)
378c2ecf20Sopenharmony_cilogs when the control method evaluation is started, and disable the
388c2ecf20Sopenharmony_cidetailed logging when the control method evaluation is stopped.
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ciThe following command examples illustrate the usage of the "log reducer"
418c2ecf20Sopenharmony_cifunctionality:
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_cia. Filter out the debug layer/level matched logs when control methods
448c2ecf20Sopenharmony_ci   are being evaluated::
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci      # cd /sys/module/acpi/parameters
478c2ecf20Sopenharmony_ci      # echo "0xXXXXXXXX" > trace_debug_layer
488c2ecf20Sopenharmony_ci      # echo "0xYYYYYYYY" > trace_debug_level
498c2ecf20Sopenharmony_ci      # echo "enable" > trace_state
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_cib. Filter out the debug layer/level matched logs when the specified
528c2ecf20Sopenharmony_ci   control method is being evaluated::
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci      # cd /sys/module/acpi/parameters
558c2ecf20Sopenharmony_ci      # echo "0xXXXXXXXX" > trace_debug_layer
568c2ecf20Sopenharmony_ci      # echo "0xYYYYYYYY" > trace_debug_level
578c2ecf20Sopenharmony_ci      # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name
588c2ecf20Sopenharmony_ci      # echo "method" > /sys/module/acpi/parameters/trace_state
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_cic. Filter out the debug layer/level matched logs when the specified
618c2ecf20Sopenharmony_ci   control method is being evaluated for the first time::
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci      # cd /sys/module/acpi/parameters
648c2ecf20Sopenharmony_ci      # echo "0xXXXXXXXX" > trace_debug_layer
658c2ecf20Sopenharmony_ci      # echo "0xYYYYYYYY" > trace_debug_level
668c2ecf20Sopenharmony_ci      # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name
678c2ecf20Sopenharmony_ci      # echo "method-once" > /sys/module/acpi/parameters/trace_state
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ciWhere:
708c2ecf20Sopenharmony_ci   0xXXXXXXXX/0xYYYYYYYY
718c2ecf20Sopenharmony_ci     Refer to Documentation/firmware-guide/acpi/debug.rst for possible debug layer/level
728c2ecf20Sopenharmony_ci     masking values.
738c2ecf20Sopenharmony_ci   \PPPP.AAAA.TTTT.HHHH
748c2ecf20Sopenharmony_ci     Full path of a control method that can be found in the ACPI namespace.
758c2ecf20Sopenharmony_ci     It needn't be an entry of a control method evaluation.
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ciAML tracer
788c2ecf20Sopenharmony_ci----------
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ciThere are special log entries added by the method tracing facility at
818c2ecf20Sopenharmony_cithe "trace points" the AML interpreter starts/stops to execute a control
828c2ecf20Sopenharmony_cimethod, or an AML opcode. Note that the format of the log entries are
838c2ecf20Sopenharmony_cisubject to change::
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci   [    0.186427]   exdebug-0398 ex_trace_point        : Method Begin [0xf58394d8:\_SB.PCI0.LPCB.ECOK] execution.
868c2ecf20Sopenharmony_ci   [    0.186630]   exdebug-0398 ex_trace_point        : Opcode Begin [0xf5905c88:If] execution.
878c2ecf20Sopenharmony_ci   [    0.186820]   exdebug-0398 ex_trace_point        : Opcode Begin [0xf5905cc0:LEqual] execution.
888c2ecf20Sopenharmony_ci   [    0.187010]   exdebug-0398 ex_trace_point        : Opcode Begin [0xf5905a20:-NamePath-] execution.
898c2ecf20Sopenharmony_ci   [    0.187214]   exdebug-0398 ex_trace_point        : Opcode End [0xf5905a20:-NamePath-] execution.
908c2ecf20Sopenharmony_ci   [    0.187407]   exdebug-0398 ex_trace_point        : Opcode Begin [0xf5905f60:One] execution.
918c2ecf20Sopenharmony_ci   [    0.187594]   exdebug-0398 ex_trace_point        : Opcode End [0xf5905f60:One] execution.
928c2ecf20Sopenharmony_ci   [    0.187789]   exdebug-0398 ex_trace_point        : Opcode End [0xf5905cc0:LEqual] execution.
938c2ecf20Sopenharmony_ci   [    0.187980]   exdebug-0398 ex_trace_point        : Opcode Begin [0xf5905cc0:Return] execution.
948c2ecf20Sopenharmony_ci   [    0.188146]   exdebug-0398 ex_trace_point        : Opcode Begin [0xf5905f60:One] execution.
958c2ecf20Sopenharmony_ci   [    0.188334]   exdebug-0398 ex_trace_point        : Opcode End [0xf5905f60:One] execution.
968c2ecf20Sopenharmony_ci   [    0.188524]   exdebug-0398 ex_trace_point        : Opcode End [0xf5905cc0:Return] execution.
978c2ecf20Sopenharmony_ci   [    0.188712]   exdebug-0398 ex_trace_point        : Opcode End [0xf5905c88:If] execution.
988c2ecf20Sopenharmony_ci   [    0.188903]   exdebug-0398 ex_trace_point        : Method End [0xf58394d8:\_SB.PCI0.LPCB.ECOK] execution.
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ciDevelopers can utilize these special log entries to track the AML
1018c2ecf20Sopenharmony_ciinterpretation, thus can aid issue debugging and performance tuning. Note
1028c2ecf20Sopenharmony_cithat, as the "AML tracer" logs are implemented via ACPI_DEBUG_PRINT()
1038c2ecf20Sopenharmony_cimacro, CONFIG_ACPI_DEBUG is also required to be enabled for enabling
1048c2ecf20Sopenharmony_ci"AML tracer" logs.
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ciThe following command examples illustrate the usage of the "AML tracer"
1078c2ecf20Sopenharmony_cifunctionality:
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_cia. Filter out the method start/stop "AML tracer" logs when control
1108c2ecf20Sopenharmony_ci   methods are being evaluated::
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci      # cd /sys/module/acpi/parameters
1138c2ecf20Sopenharmony_ci      # echo "0x80" > trace_debug_layer
1148c2ecf20Sopenharmony_ci      # echo "0x10" > trace_debug_level
1158c2ecf20Sopenharmony_ci      # echo "enable" > trace_state
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_cib. Filter out the method start/stop "AML tracer" when the specified
1188c2ecf20Sopenharmony_ci   control method is being evaluated::
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci      # cd /sys/module/acpi/parameters
1218c2ecf20Sopenharmony_ci      # echo "0x80" > trace_debug_layer
1228c2ecf20Sopenharmony_ci      # echo "0x10" > trace_debug_level
1238c2ecf20Sopenharmony_ci      # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name
1248c2ecf20Sopenharmony_ci      # echo "method" > trace_state
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_cic. Filter out the method start/stop "AML tracer" logs when the specified
1278c2ecf20Sopenharmony_ci   control method is being evaluated for the first time::
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci      # cd /sys/module/acpi/parameters
1308c2ecf20Sopenharmony_ci      # echo "0x80" > trace_debug_layer
1318c2ecf20Sopenharmony_ci      # echo "0x10" > trace_debug_level
1328c2ecf20Sopenharmony_ci      # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name
1338c2ecf20Sopenharmony_ci      # echo "method-once" > trace_state
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_cid. Filter out the method/opcode start/stop "AML tracer" when the
1368c2ecf20Sopenharmony_ci   specified control method is being evaluated::
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci      # cd /sys/module/acpi/parameters
1398c2ecf20Sopenharmony_ci      # echo "0x80" > trace_debug_layer
1408c2ecf20Sopenharmony_ci      # echo "0x10" > trace_debug_level
1418c2ecf20Sopenharmony_ci      # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name
1428c2ecf20Sopenharmony_ci      # echo "opcode" > trace_state
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_cie. Filter out the method/opcode start/stop "AML tracer" when the
1458c2ecf20Sopenharmony_ci   specified control method is being evaluated for the first time::
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci      # cd /sys/module/acpi/parameters
1488c2ecf20Sopenharmony_ci      # echo "0x80" > trace_debug_layer
1498c2ecf20Sopenharmony_ci      # echo "0x10" > trace_debug_level
1508c2ecf20Sopenharmony_ci      # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name
1518c2ecf20Sopenharmony_ci      # echo "opcode-opcode" > trace_state
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ciNote that all above method tracing facility related module parameters can
1548c2ecf20Sopenharmony_cibe used as the boot parameters, for example::
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci   acpi.trace_debug_layer=0x80 acpi.trace_debug_level=0x10 \
1578c2ecf20Sopenharmony_ci   acpi.trace_method_name=\_SB.LID0._LID acpi.trace_state=opcode-once
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ciInterface descriptions
1618c2ecf20Sopenharmony_ci======================
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ciAll method tracing functions can be configured via ACPI module
1648c2ecf20Sopenharmony_ciparameters that are accessible at /sys/module/acpi/parameters/:
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_citrace_method_name
1678c2ecf20Sopenharmony_ci  The full path of the AML method that the user wants to trace.
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci  Note that the full path shouldn't contain the trailing "_"s in its
1708c2ecf20Sopenharmony_ci  name segments but may contain "\" to form an absolute path.
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_citrace_debug_layer
1738c2ecf20Sopenharmony_ci  The temporary debug_layer used when the tracing feature is enabled.
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci  Using ACPI_EXECUTER (0x80) by default, which is the debug_layer
1768c2ecf20Sopenharmony_ci  used to match all "AML tracer" logs.
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_citrace_debug_level
1798c2ecf20Sopenharmony_ci  The temporary debug_level used when the tracing feature is enabled.
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_ci  Using ACPI_LV_TRACE_POINT (0x10) by default, which is the
1828c2ecf20Sopenharmony_ci  debug_level used to match all "AML tracer" logs.
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_citrace_state
1858c2ecf20Sopenharmony_ci  The status of the tracing feature.
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci  Users can enable/disable this debug tracing feature by executing
1888c2ecf20Sopenharmony_ci  the following command::
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ci   # echo string > /sys/module/acpi/parameters/trace_state
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ciWhere "string" should be one of the following:
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci"disable"
1958c2ecf20Sopenharmony_ci  Disable the method tracing feature.
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci"enable"
1988c2ecf20Sopenharmony_ci  Enable the method tracing feature.
1998c2ecf20Sopenharmony_ci  
2008c2ecf20Sopenharmony_ci  ACPICA debugging messages matching "trace_debug_layer/trace_debug_level"
2018c2ecf20Sopenharmony_ci  during any method execution will be logged.
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci"method"
2048c2ecf20Sopenharmony_ci  Enable the method tracing feature.
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_ci  ACPICA debugging messages matching "trace_debug_layer/trace_debug_level"
2078c2ecf20Sopenharmony_ci  during method execution of "trace_method_name" will be logged.
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci"method-once"
2108c2ecf20Sopenharmony_ci  Enable the method tracing feature.
2118c2ecf20Sopenharmony_ci
2128c2ecf20Sopenharmony_ci  ACPICA debugging messages matching "trace_debug_layer/trace_debug_level"
2138c2ecf20Sopenharmony_ci  during method execution of "trace_method_name" will be logged only once.
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci"opcode"
2168c2ecf20Sopenharmony_ci  Enable the method tracing feature.
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci  ACPICA debugging messages matching "trace_debug_layer/trace_debug_level"
2198c2ecf20Sopenharmony_ci  during method/opcode execution of "trace_method_name" will be logged.
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ci"opcode-once"
2228c2ecf20Sopenharmony_ci  Enable the method tracing feature.
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci  ACPICA debugging messages matching "trace_debug_layer/trace_debug_level"
2258c2ecf20Sopenharmony_ci  during method/opcode execution of "trace_method_name" will be logged only
2268c2ecf20Sopenharmony_ci  once.
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_ciNote that, the difference between the "enable" and other feature
2298c2ecf20Sopenharmony_cienabling options are:
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci1. When "enable" is specified, since
2328c2ecf20Sopenharmony_ci   "trace_debug_layer/trace_debug_level" shall apply to all control
2338c2ecf20Sopenharmony_ci   method evaluations, after configuring "trace_state" to "enable",
2348c2ecf20Sopenharmony_ci   "trace_method_name" will be reset to NULL.
2358c2ecf20Sopenharmony_ci2. When "method/opcode" is specified, if
2368c2ecf20Sopenharmony_ci   "trace_method_name" is NULL when "trace_state" is configured to
2378c2ecf20Sopenharmony_ci   these options, the "trace_debug_layer/trace_debug_level" will
2388c2ecf20Sopenharmony_ci   apply to all control method evaluations.
239