1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0 2*4882a593Smuzhiyun.. include:: <isonum.txt> 3*4882a593Smuzhiyun 4*4882a593Smuzhiyun===================== 5*4882a593SmuzhiyunACPICA Trace Facility 6*4882a593Smuzhiyun===================== 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun:Copyright: |copy| 2015, Intel Corporation 9*4882a593Smuzhiyun:Author: Lv Zheng <lv.zheng@intel.com> 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun 12*4882a593SmuzhiyunAbstract 13*4882a593Smuzhiyun======== 14*4882a593SmuzhiyunThis document describes the functions and the interfaces of the 15*4882a593Smuzhiyunmethod tracing facility. 16*4882a593Smuzhiyun 17*4882a593SmuzhiyunFunctionalities and usage examples 18*4882a593Smuzhiyun================================== 19*4882a593Smuzhiyun 20*4882a593SmuzhiyunACPICA provides method tracing capability. And two functions are 21*4882a593Smuzhiyuncurrently implemented using this capability. 22*4882a593Smuzhiyun 23*4882a593SmuzhiyunLog reducer 24*4882a593Smuzhiyun----------- 25*4882a593Smuzhiyun 26*4882a593SmuzhiyunACPICA subsystem provides debugging outputs when CONFIG_ACPI_DEBUG is 27*4882a593Smuzhiyunenabled. The debugging messages which are deployed via 28*4882a593SmuzhiyunACPI_DEBUG_PRINT() macro can be reduced at 2 levels - per-component 29*4882a593Smuzhiyunlevel (known as debug layer, configured via 30*4882a593Smuzhiyun/sys/module/acpi/parameters/debug_layer) and per-type level (known as 31*4882a593Smuzhiyundebug level, configured via /sys/module/acpi/parameters/debug_level). 32*4882a593Smuzhiyun 33*4882a593SmuzhiyunBut when the particular layer/level is applied to the control method 34*4882a593Smuzhiyunevaluations, the quantity of the debugging outputs may still be too 35*4882a593Smuzhiyunlarge to be put into the kernel log buffer. The idea thus is worked out 36*4882a593Smuzhiyunto only enable the particular debug layer/level (normally more detailed) 37*4882a593Smuzhiyunlogs when the control method evaluation is started, and disable the 38*4882a593Smuzhiyundetailed logging when the control method evaluation is stopped. 39*4882a593Smuzhiyun 40*4882a593SmuzhiyunThe following command examples illustrate the usage of the "log reducer" 41*4882a593Smuzhiyunfunctionality: 42*4882a593Smuzhiyun 43*4882a593Smuzhiyuna. Filter out the debug layer/level matched logs when control methods 44*4882a593Smuzhiyun are being evaluated:: 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun # cd /sys/module/acpi/parameters 47*4882a593Smuzhiyun # echo "0xXXXXXXXX" > trace_debug_layer 48*4882a593Smuzhiyun # echo "0xYYYYYYYY" > trace_debug_level 49*4882a593Smuzhiyun # echo "enable" > trace_state 50*4882a593Smuzhiyun 51*4882a593Smuzhiyunb. Filter out the debug layer/level matched logs when the specified 52*4882a593Smuzhiyun control method is being evaluated:: 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun # cd /sys/module/acpi/parameters 55*4882a593Smuzhiyun # echo "0xXXXXXXXX" > trace_debug_layer 56*4882a593Smuzhiyun # echo "0xYYYYYYYY" > trace_debug_level 57*4882a593Smuzhiyun # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name 58*4882a593Smuzhiyun # echo "method" > /sys/module/acpi/parameters/trace_state 59*4882a593Smuzhiyun 60*4882a593Smuzhiyunc. Filter out the debug layer/level matched logs when the specified 61*4882a593Smuzhiyun control method is being evaluated for the first time:: 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun # cd /sys/module/acpi/parameters 64*4882a593Smuzhiyun # echo "0xXXXXXXXX" > trace_debug_layer 65*4882a593Smuzhiyun # echo "0xYYYYYYYY" > trace_debug_level 66*4882a593Smuzhiyun # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name 67*4882a593Smuzhiyun # echo "method-once" > /sys/module/acpi/parameters/trace_state 68*4882a593Smuzhiyun 69*4882a593SmuzhiyunWhere: 70*4882a593Smuzhiyun 0xXXXXXXXX/0xYYYYYYYY 71*4882a593Smuzhiyun Refer to Documentation/firmware-guide/acpi/debug.rst for possible debug layer/level 72*4882a593Smuzhiyun masking values. 73*4882a593Smuzhiyun \PPPP.AAAA.TTTT.HHHH 74*4882a593Smuzhiyun Full path of a control method that can be found in the ACPI namespace. 75*4882a593Smuzhiyun It needn't be an entry of a control method evaluation. 76*4882a593Smuzhiyun 77*4882a593SmuzhiyunAML tracer 78*4882a593Smuzhiyun---------- 79*4882a593Smuzhiyun 80*4882a593SmuzhiyunThere are special log entries added by the method tracing facility at 81*4882a593Smuzhiyunthe "trace points" the AML interpreter starts/stops to execute a control 82*4882a593Smuzhiyunmethod, or an AML opcode. Note that the format of the log entries are 83*4882a593Smuzhiyunsubject to change:: 84*4882a593Smuzhiyun 85*4882a593Smuzhiyun [ 0.186427] exdebug-0398 ex_trace_point : Method Begin [0xf58394d8:\_SB.PCI0.LPCB.ECOK] execution. 86*4882a593Smuzhiyun [ 0.186630] exdebug-0398 ex_trace_point : Opcode Begin [0xf5905c88:If] execution. 87*4882a593Smuzhiyun [ 0.186820] exdebug-0398 ex_trace_point : Opcode Begin [0xf5905cc0:LEqual] execution. 88*4882a593Smuzhiyun [ 0.187010] exdebug-0398 ex_trace_point : Opcode Begin [0xf5905a20:-NamePath-] execution. 89*4882a593Smuzhiyun [ 0.187214] exdebug-0398 ex_trace_point : Opcode End [0xf5905a20:-NamePath-] execution. 90*4882a593Smuzhiyun [ 0.187407] exdebug-0398 ex_trace_point : Opcode Begin [0xf5905f60:One] execution. 91*4882a593Smuzhiyun [ 0.187594] exdebug-0398 ex_trace_point : Opcode End [0xf5905f60:One] execution. 92*4882a593Smuzhiyun [ 0.187789] exdebug-0398 ex_trace_point : Opcode End [0xf5905cc0:LEqual] execution. 93*4882a593Smuzhiyun [ 0.187980] exdebug-0398 ex_trace_point : Opcode Begin [0xf5905cc0:Return] execution. 94*4882a593Smuzhiyun [ 0.188146] exdebug-0398 ex_trace_point : Opcode Begin [0xf5905f60:One] execution. 95*4882a593Smuzhiyun [ 0.188334] exdebug-0398 ex_trace_point : Opcode End [0xf5905f60:One] execution. 96*4882a593Smuzhiyun [ 0.188524] exdebug-0398 ex_trace_point : Opcode End [0xf5905cc0:Return] execution. 97*4882a593Smuzhiyun [ 0.188712] exdebug-0398 ex_trace_point : Opcode End [0xf5905c88:If] execution. 98*4882a593Smuzhiyun [ 0.188903] exdebug-0398 ex_trace_point : Method End [0xf58394d8:\_SB.PCI0.LPCB.ECOK] execution. 99*4882a593Smuzhiyun 100*4882a593SmuzhiyunDevelopers can utilize these special log entries to track the AML 101*4882a593Smuzhiyuninterpretation, thus can aid issue debugging and performance tuning. Note 102*4882a593Smuzhiyunthat, as the "AML tracer" logs are implemented via ACPI_DEBUG_PRINT() 103*4882a593Smuzhiyunmacro, CONFIG_ACPI_DEBUG is also required to be enabled for enabling 104*4882a593Smuzhiyun"AML tracer" logs. 105*4882a593Smuzhiyun 106*4882a593SmuzhiyunThe following command examples illustrate the usage of the "AML tracer" 107*4882a593Smuzhiyunfunctionality: 108*4882a593Smuzhiyun 109*4882a593Smuzhiyuna. Filter out the method start/stop "AML tracer" logs when control 110*4882a593Smuzhiyun methods are being evaluated:: 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun # cd /sys/module/acpi/parameters 113*4882a593Smuzhiyun # echo "0x80" > trace_debug_layer 114*4882a593Smuzhiyun # echo "0x10" > trace_debug_level 115*4882a593Smuzhiyun # echo "enable" > trace_state 116*4882a593Smuzhiyun 117*4882a593Smuzhiyunb. Filter out the method start/stop "AML tracer" when the specified 118*4882a593Smuzhiyun control method is being evaluated:: 119*4882a593Smuzhiyun 120*4882a593Smuzhiyun # cd /sys/module/acpi/parameters 121*4882a593Smuzhiyun # echo "0x80" > trace_debug_layer 122*4882a593Smuzhiyun # echo "0x10" > trace_debug_level 123*4882a593Smuzhiyun # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name 124*4882a593Smuzhiyun # echo "method" > trace_state 125*4882a593Smuzhiyun 126*4882a593Smuzhiyunc. Filter out the method start/stop "AML tracer" logs when the specified 127*4882a593Smuzhiyun control method is being evaluated for the first time:: 128*4882a593Smuzhiyun 129*4882a593Smuzhiyun # cd /sys/module/acpi/parameters 130*4882a593Smuzhiyun # echo "0x80" > trace_debug_layer 131*4882a593Smuzhiyun # echo "0x10" > trace_debug_level 132*4882a593Smuzhiyun # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name 133*4882a593Smuzhiyun # echo "method-once" > trace_state 134*4882a593Smuzhiyun 135*4882a593Smuzhiyund. Filter out the method/opcode start/stop "AML tracer" when the 136*4882a593Smuzhiyun specified control method is being evaluated:: 137*4882a593Smuzhiyun 138*4882a593Smuzhiyun # cd /sys/module/acpi/parameters 139*4882a593Smuzhiyun # echo "0x80" > trace_debug_layer 140*4882a593Smuzhiyun # echo "0x10" > trace_debug_level 141*4882a593Smuzhiyun # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name 142*4882a593Smuzhiyun # echo "opcode" > trace_state 143*4882a593Smuzhiyun 144*4882a593Smuzhiyune. Filter out the method/opcode start/stop "AML tracer" when the 145*4882a593Smuzhiyun specified control method is being evaluated for the first time:: 146*4882a593Smuzhiyun 147*4882a593Smuzhiyun # cd /sys/module/acpi/parameters 148*4882a593Smuzhiyun # echo "0x80" > trace_debug_layer 149*4882a593Smuzhiyun # echo "0x10" > trace_debug_level 150*4882a593Smuzhiyun # echo "\PPPP.AAAA.TTTT.HHHH" > trace_method_name 151*4882a593Smuzhiyun # echo "opcode-opcode" > trace_state 152*4882a593Smuzhiyun 153*4882a593SmuzhiyunNote that all above method tracing facility related module parameters can 154*4882a593Smuzhiyunbe used as the boot parameters, for example:: 155*4882a593Smuzhiyun 156*4882a593Smuzhiyun acpi.trace_debug_layer=0x80 acpi.trace_debug_level=0x10 \ 157*4882a593Smuzhiyun acpi.trace_method_name=\_SB.LID0._LID acpi.trace_state=opcode-once 158*4882a593Smuzhiyun 159*4882a593Smuzhiyun 160*4882a593SmuzhiyunInterface descriptions 161*4882a593Smuzhiyun====================== 162*4882a593Smuzhiyun 163*4882a593SmuzhiyunAll method tracing functions can be configured via ACPI module 164*4882a593Smuzhiyunparameters that are accessible at /sys/module/acpi/parameters/: 165*4882a593Smuzhiyun 166*4882a593Smuzhiyuntrace_method_name 167*4882a593Smuzhiyun The full path of the AML method that the user wants to trace. 168*4882a593Smuzhiyun 169*4882a593Smuzhiyun Note that the full path shouldn't contain the trailing "_"s in its 170*4882a593Smuzhiyun name segments but may contain "\" to form an absolute path. 171*4882a593Smuzhiyun 172*4882a593Smuzhiyuntrace_debug_layer 173*4882a593Smuzhiyun The temporary debug_layer used when the tracing feature is enabled. 174*4882a593Smuzhiyun 175*4882a593Smuzhiyun Using ACPI_EXECUTER (0x80) by default, which is the debug_layer 176*4882a593Smuzhiyun used to match all "AML tracer" logs. 177*4882a593Smuzhiyun 178*4882a593Smuzhiyuntrace_debug_level 179*4882a593Smuzhiyun The temporary debug_level used when the tracing feature is enabled. 180*4882a593Smuzhiyun 181*4882a593Smuzhiyun Using ACPI_LV_TRACE_POINT (0x10) by default, which is the 182*4882a593Smuzhiyun debug_level used to match all "AML tracer" logs. 183*4882a593Smuzhiyun 184*4882a593Smuzhiyuntrace_state 185*4882a593Smuzhiyun The status of the tracing feature. 186*4882a593Smuzhiyun 187*4882a593Smuzhiyun Users can enable/disable this debug tracing feature by executing 188*4882a593Smuzhiyun the following command:: 189*4882a593Smuzhiyun 190*4882a593Smuzhiyun # echo string > /sys/module/acpi/parameters/trace_state 191*4882a593Smuzhiyun 192*4882a593SmuzhiyunWhere "string" should be one of the following: 193*4882a593Smuzhiyun 194*4882a593Smuzhiyun"disable" 195*4882a593Smuzhiyun Disable the method tracing feature. 196*4882a593Smuzhiyun 197*4882a593Smuzhiyun"enable" 198*4882a593Smuzhiyun Enable the method tracing feature. 199*4882a593Smuzhiyun 200*4882a593Smuzhiyun ACPICA debugging messages matching "trace_debug_layer/trace_debug_level" 201*4882a593Smuzhiyun during any method execution will be logged. 202*4882a593Smuzhiyun 203*4882a593Smuzhiyun"method" 204*4882a593Smuzhiyun Enable the method tracing feature. 205*4882a593Smuzhiyun 206*4882a593Smuzhiyun ACPICA debugging messages matching "trace_debug_layer/trace_debug_level" 207*4882a593Smuzhiyun during method execution of "trace_method_name" will be logged. 208*4882a593Smuzhiyun 209*4882a593Smuzhiyun"method-once" 210*4882a593Smuzhiyun Enable the method tracing feature. 211*4882a593Smuzhiyun 212*4882a593Smuzhiyun ACPICA debugging messages matching "trace_debug_layer/trace_debug_level" 213*4882a593Smuzhiyun during method execution of "trace_method_name" will be logged only once. 214*4882a593Smuzhiyun 215*4882a593Smuzhiyun"opcode" 216*4882a593Smuzhiyun Enable the method tracing feature. 217*4882a593Smuzhiyun 218*4882a593Smuzhiyun ACPICA debugging messages matching "trace_debug_layer/trace_debug_level" 219*4882a593Smuzhiyun during method/opcode execution of "trace_method_name" will be logged. 220*4882a593Smuzhiyun 221*4882a593Smuzhiyun"opcode-once" 222*4882a593Smuzhiyun Enable the method tracing feature. 223*4882a593Smuzhiyun 224*4882a593Smuzhiyun ACPICA debugging messages matching "trace_debug_layer/trace_debug_level" 225*4882a593Smuzhiyun during method/opcode execution of "trace_method_name" will be logged only 226*4882a593Smuzhiyun once. 227*4882a593Smuzhiyun 228*4882a593SmuzhiyunNote that, the difference between the "enable" and other feature 229*4882a593Smuzhiyunenabling options are: 230*4882a593Smuzhiyun 231*4882a593Smuzhiyun1. When "enable" is specified, since 232*4882a593Smuzhiyun "trace_debug_layer/trace_debug_level" shall apply to all control 233*4882a593Smuzhiyun method evaluations, after configuring "trace_state" to "enable", 234*4882a593Smuzhiyun "trace_method_name" will be reset to NULL. 235*4882a593Smuzhiyun2. When "method/opcode" is specified, if 236*4882a593Smuzhiyun "trace_method_name" is NULL when "trace_state" is configured to 237*4882a593Smuzhiyun these options, the "trace_debug_layer/trace_debug_level" will 238*4882a593Smuzhiyun apply to all control method evaluations. 239