summaryrefslogtreecommitdiffstats
path: root/Documentation/firmware-guide/acpi/method-tracing.rst
blob: d0b077b73f5f21f5707d41f18e2b33fd56684686 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
.. SPDX-License-Identifier: GPL-2.0
.. include:: <isonum.txt>

=====================
ACPICA Trace Facility
=====================

:Copyright: |copy| 2015, Intel Corporation
:Author: Lv Zheng <lv.zheng@intel.com>


Abstract
========
This document describes the functions and the interfaces of the
method tracing facility.

Functionalities and usage examples
==================================

ACPICA provides method tracing capability. And two functions are
currently implemented using this capability.

Log reducer
-----------

ACPICA subsystem provides debugging outputs when CONFIG_ACPI_DEBUG is
enabled. The debugging messages which are deployed via
ACPI_DEBUG_PRINT() macro can be reduced at 2 levels - per-component
level (known as debug layer, configured via
/sys/module/acpi/parameters/debug_layer) and per-type level (known as
debug level, configured via /sys/module/acpi/parameters/debug_level).

But when the particular layer/level is applied to the control method
evaluations, the quantity of the debugging outputs may still be too
large to be put into the kernel log buffer. The idea thus is worked out
to only enable the particular debug layer/level (normally more detailed)
logs when the control method evaluation is started, and disable the
detailed logging when the control method evaluation is stopped.

The following command examples illustrate the usage of the "log reducer"
functionality:

a. Filter out the debug layer/level matched logs when control methods
   are being evaluated::

      # cd /sys/module/acpi/parameters
      # echo "0xXXXXXXXX" > trace_debug_layer
      # echo "0xYYYYYYYY" > trace_debug_level
      # echo "enable" > trace_state

b. Filter out the debug layer/level matched logs when the specified
   control method is being evaluated::

      # cd /sys/module/acpi/parameters
      # echo "0xXXXXXXXX" > trace_debug_layer
      # echo "0xYYYYYYYY" > trace_debug_level
      # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name
      # echo "method" > /sys/module/acpi/parameters/trace_state

c. Filter out the debug layer/level matched logs when the specified
   control method is being evaluated for the first time::

      # cd /sys/module/acpi/parameters
      # echo "0xXXXXXXXX" > trace_debug_layer
      # echo "0xYYYYYYYY" > trace_debug_level
      # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name
      # echo "method-once" > /sys/module/acpi/parameters/trace_state

Where:
   0xXXXXXXXX/0xYYYYYYYY
     Refer to Documentation/acpi/debug.txt for possible debug layer/level
     masking values.
   \PPPP.AAAA.TTTT.HHHH
     Full path of a control method that can be found in the ACPI namespace.
     It needn't be an entry of a control method evaluation.

AML tracer
----------

There are special log entries added by the method tracing facility at
the "trace points" the AML interpreter starts/stops to execute a control
method, or an AML opcode. Note that the format of the log entries are
subject to change::

   [    0.186427]   exdebug-0398 ex_trace_point        : Method Begin [0xf58394d8:\_SB.PCI0.LPCB.ECOK] execution.
   [    0.186630]   exdebug-0398 ex_trace_point        : Opcode Begin [0xf5905c88:If] execution.
   [    0.186820]   exdebug-0398 ex_trace_point        : Opcode Begin [0xf5905cc0:LEqual] execution.
   [    0.187010]   exdebug-0398 ex_trace_point        : Opcode Begin [0xf5905a20:-NamePath-] execution.
   [    0.187214]   exdebug-0398 ex_trace_point        : Opcode End [0xf5905a20:-NamePath-] execution.
   [    0.187407]   exdebug-0398 ex_trace_point        : Opcode Begin [0xf5905f60:One] execution.
   [    0.187594]   exdebug-0398 ex_trace_point        : Opcode End [0xf5905f60:One] execution.
   [    0.187789]   exdebug-0398 ex_trace_point        : Opcode End [0xf5905cc0:LEqual] execution.
   [    0.187980]   exdebug-0398 ex_trace_point        : Opcode Begin [0xf5905cc0:Return] execution.
   [    0.188146]   exdebug-0398 ex_trace_point        : Opcode Begin [0xf5905f60:One] execution.
   [    0.188334]   exdebug-0398 ex_trace_point        : Opcode End [0xf5905f60:One] execution.
   [    0.188524]   exdebug-0398 ex_trace_point        : Opcode End [0xf5905cc0:Return] execution.
   [    0.188712]   exdebug-0398 ex_trace_point        : Opcode End [0xf5905c88:If] execution.
   [    0.188903]   exdebug-0398 ex_trace_point        : Method End [0xf58394d8:\_SB.PCI0.LPCB.ECOK] execution.

Developers can utilize these special log entries to track the AML
interpretion, thus can aid issue debugging and performance tuning. Note
that, as the "AML tracer" logs are implemented via ACPI_DEBUG_PRINT()
macro, CONFIG_ACPI_DEBUG is also required to be enabled for enabling
"AML tracer" logs.

The following command examples illustrate the usage of the "AML tracer"
functionality:

a. Filter out the method start/stop "AML tracer" logs when control
   methods are being evaluated::

      # cd /sys/module/acpi/parameters
      # echo "0x80" > trace_debug_layer
      # echo "0x10" > trace_debug_level
      # echo "enable" > trace_state

b. Filter out the method start/stop "AML tracer" when the specified
   control method is being evaluated::

      # cd /sys/module/acpi/parameters
      # echo "0x80" > trace_debug_layer
      # echo "0x10" > trace_debug_level
      # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name
      # echo "method" > trace_state

c. Filter out the method start/stop "AML tracer" logs when the specified
   control method is being evaluated for the first time::

      # cd /sys/module/acpi/parameters
      # echo "0x80" > trace_debug_layer
      # echo "0x10" > trace_debug_level
      # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name
      # echo "method-once" > trace_state

d. Filter out the method/opcode start/stop "AML tracer" when the
   specified control method is being evaluated::

      # cd /sys/module/acpi/parameters
      # echo "0x80" > trace_debug_layer
      # echo "0x10" > trace_debug_level
      # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name
      # echo "opcode" > trace_state

e. Filter out the method/opcode start/stop "AML tracer" when the
   specified control method is being evaluated for the first time::

      # cd /sys/module/acpi/parameters
      # echo "0x80" > trace_debug_layer
      # echo "0x10" > trace_debug_level
      # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name
      # echo "opcode-opcode" > trace_state

Note that all above method tracing facility related module parameters can
be used as the boot parameters, for example::

   acpi.trace_debug_layer=0x80 acpi.trace_debug_level=0x10 \
   acpi.trace_method_name=\_SB.LID0._LID acpi.trace_state=opcode-once


Interface descriptions
======================

All method tracing functions can be configured via ACPI module
parameters that are accessible at /sys/module/acpi/parameters/:

trace_method_name
  The full path of the AML method that the user wants to trace.

  Note that the full path shouldn't contain the trailing "_"s in its
  name segments but may contain "\" to form an absolute path.

trace_debug_layer
  The temporary debug_layer used when the tracing feature is enabled.

  Using ACPI_EXECUTER (0x80) by default, which is the debug_layer
  used to match all "AML tracer" logs.

trace_debug_level
  The temporary debug_level used when the tracing feature is enabled.

  Using ACPI_LV_TRACE_POINT (0x10) by default, which is the
  debug_level used to match all "AML tracer" logs.

trace_state
  The status of the tracing feature.

  Users can enable/disable this debug tracing feature by executing
  the following command::

   # echo string > /sys/module/acpi/parameters/trace_state

Where "string" should be one of the following:

"disable"
  Disable the method tracing feature.

"enable"
  Enable the method tracing feature.
  
  ACPICA debugging messages matching "trace_debug_layer/trace_debug_level"
  during any method execution will be logged.

"method"
  Enable the method tracing feature.

  ACPICA debugging messages matching "trace_debug_layer/trace_debug_level"
  during method execution of "trace_method_name" will be logged.

"method-once"
  Enable the method tracing feature.

  ACPICA debugging messages matching "trace_debug_layer/trace_debug_level"
  during method execution of "trace_method_name" will be logged only once.

"opcode"
  Enable the method tracing feature.

  ACPICA debugging messages matching "trace_debug_layer/trace_debug_level"
  during method/opcode execution of "trace_method_name" will be logged.

"opcode-once"
  Enable the method tracing feature.

  ACPICA debugging messages matching "trace_debug_layer/trace_debug_level"
  during method/opcode execution of "trace_method_name" will be logged only
  once.

Note that, the difference between the "enable" and other feature
enabling options are:

1. When "enable" is specified, since
   "trace_debug_layer/trace_debug_level" shall apply to all control
   method evaluations, after configuring "trace_state" to "enable",
   "trace_method_name" will be reset to NULL.
2. When "method/opcode" is specified, if
   "trace_method_name" is NULL when "trace_state" is configured to
   these options, the "trace_debug_layer/trace_debug_level" will
   apply to all control method evaluations.