xref: /linux/Documentation/firmware-guide/acpi/method-tracing.rst (revision cdd38c5f1ce4398ec58fec95904b75824daab7b5)
13c03a1bdSChangbin Du.. SPDX-License-Identifier: GPL-2.0
23c03a1bdSChangbin Du.. include:: <isonum.txt>
33c03a1bdSChangbin Du
43c03a1bdSChangbin Du=====================
53c03a1bdSChangbin DuACPICA Trace Facility
63c03a1bdSChangbin Du=====================
73c03a1bdSChangbin Du
83c03a1bdSChangbin Du:Copyright: |copy| 2015, Intel Corporation
93c03a1bdSChangbin Du:Author: Lv Zheng <lv.zheng@intel.com>
103c03a1bdSChangbin Du
113c03a1bdSChangbin Du
123c03a1bdSChangbin DuAbstract
133c03a1bdSChangbin Du========
143c03a1bdSChangbin DuThis document describes the functions and the interfaces of the
153c03a1bdSChangbin Dumethod tracing facility.
163c03a1bdSChangbin Du
173c03a1bdSChangbin DuFunctionalities and usage examples
183c03a1bdSChangbin Du==================================
193c03a1bdSChangbin Du
203c03a1bdSChangbin DuACPICA provides method tracing capability. And two functions are
213c03a1bdSChangbin Ducurrently implemented using this capability.
223c03a1bdSChangbin Du
233c03a1bdSChangbin DuLog reducer
243c03a1bdSChangbin Du-----------
253c03a1bdSChangbin Du
263c03a1bdSChangbin DuACPICA subsystem provides debugging outputs when CONFIG_ACPI_DEBUG is
273c03a1bdSChangbin Duenabled. The debugging messages which are deployed via
283c03a1bdSChangbin DuACPI_DEBUG_PRINT() macro can be reduced at 2 levels - per-component
293c03a1bdSChangbin Dulevel (known as debug layer, configured via
303c03a1bdSChangbin Du/sys/module/acpi/parameters/debug_layer) and per-type level (known as
313c03a1bdSChangbin Dudebug level, configured via /sys/module/acpi/parameters/debug_level).
323c03a1bdSChangbin Du
333c03a1bdSChangbin DuBut when the particular layer/level is applied to the control method
343c03a1bdSChangbin Duevaluations, the quantity of the debugging outputs may still be too
353c03a1bdSChangbin Dularge to be put into the kernel log buffer. The idea thus is worked out
363c03a1bdSChangbin Duto only enable the particular debug layer/level (normally more detailed)
373c03a1bdSChangbin Dulogs when the control method evaluation is started, and disable the
383c03a1bdSChangbin Dudetailed logging when the control method evaluation is stopped.
393c03a1bdSChangbin Du
403c03a1bdSChangbin DuThe following command examples illustrate the usage of the "log reducer"
413c03a1bdSChangbin Dufunctionality:
423c03a1bdSChangbin Du
433c03a1bdSChangbin Dua. Filter out the debug layer/level matched logs when control methods
443c03a1bdSChangbin Du   are being evaluated::
453c03a1bdSChangbin Du
463c03a1bdSChangbin Du      # cd /sys/module/acpi/parameters
473c03a1bdSChangbin Du      # echo "0xXXXXXXXX" > trace_debug_layer
483c03a1bdSChangbin Du      # echo "0xYYYYYYYY" > trace_debug_level
493c03a1bdSChangbin Du      # echo "enable" > trace_state
503c03a1bdSChangbin Du
513c03a1bdSChangbin Dub. Filter out the debug layer/level matched logs when the specified
523c03a1bdSChangbin Du   control method is being evaluated::
533c03a1bdSChangbin Du
543c03a1bdSChangbin Du      # cd /sys/module/acpi/parameters
553c03a1bdSChangbin Du      # echo "0xXXXXXXXX" > trace_debug_layer
563c03a1bdSChangbin Du      # echo "0xYYYYYYYY" > trace_debug_level
573c03a1bdSChangbin Du      # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name
583c03a1bdSChangbin Du      # echo "method" > /sys/module/acpi/parameters/trace_state
593c03a1bdSChangbin Du
603c03a1bdSChangbin Duc. Filter out the debug layer/level matched logs when the specified
613c03a1bdSChangbin Du   control method is being evaluated for the first time::
623c03a1bdSChangbin Du
633c03a1bdSChangbin Du      # cd /sys/module/acpi/parameters
643c03a1bdSChangbin Du      # echo "0xXXXXXXXX" > trace_debug_layer
653c03a1bdSChangbin Du      # echo "0xYYYYYYYY" > trace_debug_level
663c03a1bdSChangbin Du      # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name
673c03a1bdSChangbin Du      # echo "method-once" > /sys/module/acpi/parameters/trace_state
683c03a1bdSChangbin Du
693c03a1bdSChangbin DuWhere:
703c03a1bdSChangbin Du   0xXXXXXXXX/0xYYYYYYYY
71cb1aaebeSMauro Carvalho Chehab     Refer to Documentation/firmware-guide/acpi/debug.rst for possible debug layer/level
723c03a1bdSChangbin Du     masking values.
733c03a1bdSChangbin Du   \PPPP.AAAA.TTTT.HHHH
743c03a1bdSChangbin Du     Full path of a control method that can be found in the ACPI namespace.
753c03a1bdSChangbin Du     It needn't be an entry of a control method evaluation.
763c03a1bdSChangbin Du
773c03a1bdSChangbin DuAML tracer
783c03a1bdSChangbin Du----------
793c03a1bdSChangbin Du
803c03a1bdSChangbin DuThere are special log entries added by the method tracing facility at
813c03a1bdSChangbin Duthe "trace points" the AML interpreter starts/stops to execute a control
823c03a1bdSChangbin Dumethod, or an AML opcode. Note that the format of the log entries are
833c03a1bdSChangbin Dusubject to change::
843c03a1bdSChangbin Du
853c03a1bdSChangbin Du   [    0.186427]   exdebug-0398 ex_trace_point        : Method Begin [0xf58394d8:\_SB.PCI0.LPCB.ECOK] execution.
863c03a1bdSChangbin Du   [    0.186630]   exdebug-0398 ex_trace_point        : Opcode Begin [0xf5905c88:If] execution.
873c03a1bdSChangbin Du   [    0.186820]   exdebug-0398 ex_trace_point        : Opcode Begin [0xf5905cc0:LEqual] execution.
883c03a1bdSChangbin Du   [    0.187010]   exdebug-0398 ex_trace_point        : Opcode Begin [0xf5905a20:-NamePath-] execution.
893c03a1bdSChangbin Du   [    0.187214]   exdebug-0398 ex_trace_point        : Opcode End [0xf5905a20:-NamePath-] execution.
903c03a1bdSChangbin Du   [    0.187407]   exdebug-0398 ex_trace_point        : Opcode Begin [0xf5905f60:One] execution.
913c03a1bdSChangbin Du   [    0.187594]   exdebug-0398 ex_trace_point        : Opcode End [0xf5905f60:One] execution.
923c03a1bdSChangbin Du   [    0.187789]   exdebug-0398 ex_trace_point        : Opcode End [0xf5905cc0:LEqual] execution.
933c03a1bdSChangbin Du   [    0.187980]   exdebug-0398 ex_trace_point        : Opcode Begin [0xf5905cc0:Return] execution.
943c03a1bdSChangbin Du   [    0.188146]   exdebug-0398 ex_trace_point        : Opcode Begin [0xf5905f60:One] execution.
953c03a1bdSChangbin Du   [    0.188334]   exdebug-0398 ex_trace_point        : Opcode End [0xf5905f60:One] execution.
963c03a1bdSChangbin Du   [    0.188524]   exdebug-0398 ex_trace_point        : Opcode End [0xf5905cc0:Return] execution.
973c03a1bdSChangbin Du   [    0.188712]   exdebug-0398 ex_trace_point        : Opcode End [0xf5905c88:If] execution.
983c03a1bdSChangbin Du   [    0.188903]   exdebug-0398 ex_trace_point        : Method End [0xf58394d8:\_SB.PCI0.LPCB.ECOK] execution.
993c03a1bdSChangbin Du
1003c03a1bdSChangbin DuDevelopers can utilize these special log entries to track the AML
101*8d936bb1SFlavio Suligoiinterpretation, thus can aid issue debugging and performance tuning. Note
1023c03a1bdSChangbin Duthat, as the "AML tracer" logs are implemented via ACPI_DEBUG_PRINT()
1033c03a1bdSChangbin Dumacro, CONFIG_ACPI_DEBUG is also required to be enabled for enabling
1043c03a1bdSChangbin Du"AML tracer" logs.
1053c03a1bdSChangbin Du
1063c03a1bdSChangbin DuThe following command examples illustrate the usage of the "AML tracer"
1073c03a1bdSChangbin Dufunctionality:
1083c03a1bdSChangbin Du
1093c03a1bdSChangbin Dua. Filter out the method start/stop "AML tracer" logs when control
1103c03a1bdSChangbin Du   methods are being evaluated::
1113c03a1bdSChangbin Du
1123c03a1bdSChangbin Du      # cd /sys/module/acpi/parameters
1133c03a1bdSChangbin Du      # echo "0x80" > trace_debug_layer
1143c03a1bdSChangbin Du      # echo "0x10" > trace_debug_level
1153c03a1bdSChangbin Du      # echo "enable" > trace_state
1163c03a1bdSChangbin Du
1173c03a1bdSChangbin Dub. Filter out the method start/stop "AML tracer" when the specified
1183c03a1bdSChangbin Du   control method is being evaluated::
1193c03a1bdSChangbin Du
1203c03a1bdSChangbin Du      # cd /sys/module/acpi/parameters
1213c03a1bdSChangbin Du      # echo "0x80" > trace_debug_layer
1223c03a1bdSChangbin Du      # echo "0x10" > trace_debug_level
1233c03a1bdSChangbin Du      # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name
1243c03a1bdSChangbin Du      # echo "method" > trace_state
1253c03a1bdSChangbin Du
1263c03a1bdSChangbin Duc. Filter out the method start/stop "AML tracer" logs when the specified
1273c03a1bdSChangbin Du   control method is being evaluated for the first time::
1283c03a1bdSChangbin Du
1293c03a1bdSChangbin Du      # cd /sys/module/acpi/parameters
1303c03a1bdSChangbin Du      # echo "0x80" > trace_debug_layer
1313c03a1bdSChangbin Du      # echo "0x10" > trace_debug_level
1323c03a1bdSChangbin Du      # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name
1333c03a1bdSChangbin Du      # echo "method-once" > trace_state
1343c03a1bdSChangbin Du
1353c03a1bdSChangbin Dud. Filter out the method/opcode start/stop "AML tracer" when the
1363c03a1bdSChangbin Du   specified control method is being evaluated::
1373c03a1bdSChangbin Du
1383c03a1bdSChangbin Du      # cd /sys/module/acpi/parameters
1393c03a1bdSChangbin Du      # echo "0x80" > trace_debug_layer
1403c03a1bdSChangbin Du      # echo "0x10" > trace_debug_level
1413c03a1bdSChangbin Du      # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name
1423c03a1bdSChangbin Du      # echo "opcode" > trace_state
1433c03a1bdSChangbin Du
1443c03a1bdSChangbin Due. Filter out the method/opcode start/stop "AML tracer" when the
1453c03a1bdSChangbin Du   specified control method is being evaluated for the first time::
1463c03a1bdSChangbin Du
1473c03a1bdSChangbin Du      # cd /sys/module/acpi/parameters
1483c03a1bdSChangbin Du      # echo "0x80" > trace_debug_layer
1493c03a1bdSChangbin Du      # echo "0x10" > trace_debug_level
1503c03a1bdSChangbin Du      # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name
1513c03a1bdSChangbin Du      # echo "opcode-opcode" > trace_state
1523c03a1bdSChangbin Du
1533c03a1bdSChangbin DuNote that all above method tracing facility related module parameters can
1543c03a1bdSChangbin Dube used as the boot parameters, for example::
1553c03a1bdSChangbin Du
1563c03a1bdSChangbin Du   acpi.trace_debug_layer=0x80 acpi.trace_debug_level=0x10 \
1573c03a1bdSChangbin Du   acpi.trace_method_name=\_SB.LID0._LID acpi.trace_state=opcode-once
1583c03a1bdSChangbin Du
1593c03a1bdSChangbin Du
1603c03a1bdSChangbin DuInterface descriptions
1613c03a1bdSChangbin Du======================
1623c03a1bdSChangbin Du
1633c03a1bdSChangbin DuAll method tracing functions can be configured via ACPI module
1643c03a1bdSChangbin Duparameters that are accessible at /sys/module/acpi/parameters/:
1653c03a1bdSChangbin Du
1663c03a1bdSChangbin Dutrace_method_name
1673c03a1bdSChangbin Du  The full path of the AML method that the user wants to trace.
1683c03a1bdSChangbin Du
1693c03a1bdSChangbin Du  Note that the full path shouldn't contain the trailing "_"s in its
1703c03a1bdSChangbin Du  name segments but may contain "\" to form an absolute path.
1713c03a1bdSChangbin Du
1723c03a1bdSChangbin Dutrace_debug_layer
1733c03a1bdSChangbin Du  The temporary debug_layer used when the tracing feature is enabled.
1743c03a1bdSChangbin Du
1753c03a1bdSChangbin Du  Using ACPI_EXECUTER (0x80) by default, which is the debug_layer
1763c03a1bdSChangbin Du  used to match all "AML tracer" logs.
1773c03a1bdSChangbin Du
1783c03a1bdSChangbin Dutrace_debug_level
1793c03a1bdSChangbin Du  The temporary debug_level used when the tracing feature is enabled.
1803c03a1bdSChangbin Du
1813c03a1bdSChangbin Du  Using ACPI_LV_TRACE_POINT (0x10) by default, which is the
1823c03a1bdSChangbin Du  debug_level used to match all "AML tracer" logs.
1833c03a1bdSChangbin Du
1843c03a1bdSChangbin Dutrace_state
1853c03a1bdSChangbin Du  The status of the tracing feature.
1863c03a1bdSChangbin Du
1873c03a1bdSChangbin Du  Users can enable/disable this debug tracing feature by executing
1883c03a1bdSChangbin Du  the following command::
1893c03a1bdSChangbin Du
1903c03a1bdSChangbin Du   # echo string > /sys/module/acpi/parameters/trace_state
1913c03a1bdSChangbin Du
1923c03a1bdSChangbin DuWhere "string" should be one of the following:
1933c03a1bdSChangbin Du
1943c03a1bdSChangbin Du"disable"
1953c03a1bdSChangbin Du  Disable the method tracing feature.
1963c03a1bdSChangbin Du
1973c03a1bdSChangbin Du"enable"
1983c03a1bdSChangbin Du  Enable the method tracing feature.
1993c03a1bdSChangbin Du
2003c03a1bdSChangbin Du  ACPICA debugging messages matching "trace_debug_layer/trace_debug_level"
2013c03a1bdSChangbin Du  during any method execution will be logged.
2023c03a1bdSChangbin Du
2033c03a1bdSChangbin Du"method"
2043c03a1bdSChangbin Du  Enable the method tracing feature.
2053c03a1bdSChangbin Du
2063c03a1bdSChangbin Du  ACPICA debugging messages matching "trace_debug_layer/trace_debug_level"
2073c03a1bdSChangbin Du  during method execution of "trace_method_name" will be logged.
2083c03a1bdSChangbin Du
2093c03a1bdSChangbin Du"method-once"
2103c03a1bdSChangbin Du  Enable the method tracing feature.
2113c03a1bdSChangbin Du
2123c03a1bdSChangbin Du  ACPICA debugging messages matching "trace_debug_layer/trace_debug_level"
2133c03a1bdSChangbin Du  during method execution of "trace_method_name" will be logged only once.
2143c03a1bdSChangbin Du
2153c03a1bdSChangbin Du"opcode"
2163c03a1bdSChangbin Du  Enable the method tracing feature.
2173c03a1bdSChangbin Du
2183c03a1bdSChangbin Du  ACPICA debugging messages matching "trace_debug_layer/trace_debug_level"
2193c03a1bdSChangbin Du  during method/opcode execution of "trace_method_name" will be logged.
2203c03a1bdSChangbin Du
2213c03a1bdSChangbin Du"opcode-once"
2223c03a1bdSChangbin Du  Enable the method tracing feature.
2233c03a1bdSChangbin Du
2243c03a1bdSChangbin Du  ACPICA debugging messages matching "trace_debug_layer/trace_debug_level"
2253c03a1bdSChangbin Du  during method/opcode execution of "trace_method_name" will be logged only
2263c03a1bdSChangbin Du  once.
2273c03a1bdSChangbin Du
2283c03a1bdSChangbin DuNote that, the difference between the "enable" and other feature
2293c03a1bdSChangbin Duenabling options are:
2303c03a1bdSChangbin Du
2313c03a1bdSChangbin Du1. When "enable" is specified, since
2323c03a1bdSChangbin Du   "trace_debug_layer/trace_debug_level" shall apply to all control
2333c03a1bdSChangbin Du   method evaluations, after configuring "trace_state" to "enable",
2343c03a1bdSChangbin Du   "trace_method_name" will be reset to NULL.
2353c03a1bdSChangbin Du2. When "method/opcode" is specified, if
2363c03a1bdSChangbin Du   "trace_method_name" is NULL when "trace_state" is configured to
2373c03a1bdSChangbin Du   these options, the "trace_debug_layer/trace_debug_level" will
2383c03a1bdSChangbin Du   apply to all control method evaluations.
239