1*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note 2*4882a593Smuzhiyun# 3*4882a593Smuzhiyun# (C) COPYRIGHT 2022 ARM Limited. All rights reserved. 4*4882a593Smuzhiyun# 5*4882a593Smuzhiyun# This program is free software and is provided to you under the terms of the 6*4882a593Smuzhiyun# GNU General Public License version 2 as published by the Free Software 7*4882a593Smuzhiyun# Foundation, and any use by you of this program is subject to the terms 8*4882a593Smuzhiyun# of such GNU license. 9*4882a593Smuzhiyun# 10*4882a593Smuzhiyun# This program is distributed in the hope that it will be useful, 11*4882a593Smuzhiyun# but WITHOUT ANY WARRANTY; without even the implied warranty of 12*4882a593Smuzhiyun# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13*4882a593Smuzhiyun# GNU General Public License for more details. 14*4882a593Smuzhiyun# 15*4882a593Smuzhiyun# You should have received a copy of the GNU General Public License 16*4882a593Smuzhiyun# along with this program; if not, you can access it online at 17*4882a593Smuzhiyun# http://www.gnu.org/licenses/gpl-2.0.html. 18*4882a593Smuzhiyun# 19*4882a593Smuzhiyun# 20*4882a593Smuzhiyun 21*4882a593SmuzhiyunDebugFS interface: 22*4882a593Smuzhiyun------------------ 23*4882a593Smuzhiyun 24*4882a593SmuzhiyunA new per-kbase-context debugfs file called csf_sync has been implemented 25*4882a593Smuzhiyunwhich captures the current KCPU & GPU queue state of the not-yet-completed 26*4882a593Smuzhiyunoperations and displayed through the debugfs file. 27*4882a593SmuzhiyunThis file is at: 28*4882a593Smuzhiyun======================================================= 29*4882a593Smuzhiyun/sys/kernel/debug/mali0/ctx/<pid>_<context id>/csf_sync 30*4882a593Smuzhiyun======================================================= 31*4882a593Smuzhiyun 32*4882a593SmuzhiyunOutput Format: 33*4882a593Smuzhiyun---------------- 34*4882a593Smuzhiyun 35*4882a593SmuzhiyunThe csf_sync file contains important data for the currently active queues. 36*4882a593SmuzhiyunThis data is formatted into two segments, which are separated by a 37*4882a593Smuzhiyunpipe character: the common properties and the operation-specific properties. 38*4882a593Smuzhiyun 39*4882a593SmuzhiyunCommon Properties: 40*4882a593Smuzhiyun------------------ 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun* Queue type: GPU or KCPU. 43*4882a593Smuzhiyun* kbase context id and the queue id. 44*4882a593Smuzhiyun* If the queue type is a GPU queue then the group handle is also noted, 45*4882a593Smuzhiyunin the middle of the other two IDs. The slot value is also dumped. 46*4882a593Smuzhiyun* Execution status, which can either be 'P' for pending or 'S' for started. 47*4882a593Smuzhiyun* Command type is then output which indicates the type of dependency 48*4882a593Smuzhiyun(i.e. wait or signal). 49*4882a593Smuzhiyun* Object address which is a pointer to the sync object that the 50*4882a593Smuzhiyuncommand operates on. 51*4882a593Smuzhiyun* The live value, which is the value of the synchronization object 52*4882a593Smuzhiyunat the time of dumping. This could help to determine why wait 53*4882a593Smuzhiyunoperations might be blocked. 54*4882a593Smuzhiyun 55*4882a593SmuzhiyunOperation-Specific Properties: 56*4882a593Smuzhiyun------------------------------ 57*4882a593Smuzhiyun 58*4882a593SmuzhiyunThe operation-specific values for KCPU queue fence operations 59*4882a593Smuzhiyunare as follows: a unique timeline name, timeline context, and a fence 60*4882a593Smuzhiyunsequence number. The CQS WAIT and CQS SET are denoted in the sync dump 61*4882a593Smuzhiyunas their OPERATION counterparts, and therefore show the same operation 62*4882a593Smuzhiyunspecific values; the argument value to wait on or set to, and operation type, 63*4882a593Smuzhiyunbeing (by definition) op:gt and op:set for CQS_WAIT and CQS_SET respectively. 64*4882a593Smuzhiyun 65*4882a593SmuzhiyunThere are only two operation-specific values for operations in GPU queues 66*4882a593Smuzhiyunwhich are always shown; the argument value to wait on or set/add to, 67*4882a593Smuzhiyunand the operation type (set/add) or wait condition (e.g. LE, GT, GE). 68*4882a593Smuzhiyun 69*4882a593SmuzhiyunExamples 70*4882a593Smuzhiyun-------- 71*4882a593SmuzhiyunGPU Queue Example 72*4882a593Smuzhiyun------------------ 73*4882a593Smuzhiyun 74*4882a593SmuzhiyunThe following output is of a GPU queue, from a process that has a KCTX ID of 52, 75*4882a593Smuzhiyunis in Queue Group (CSG) 0, and has Queue ID 0. It has started and is waiting on 76*4882a593Smuzhiyunthe object at address 0x0000007f81ffc800. The live value is 0, 77*4882a593Smuzhiyunas is the arg value. However, the operation "op" is GT, indicating it's waiting 78*4882a593Smuzhiyunfor the live value to surpass the arg value: 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun====================================================================================================================================== 81*4882a593Smuzhiyunqueue:GPU-52-0-0 exec:S cmd:SYNC_WAIT slot:4 obj:0x0000007f81ffc800 live_value:0x0000000000000000 | op:gt arg_value:0x0000000000000000 82*4882a593Smuzhiyun====================================================================================================================================== 83*4882a593Smuzhiyun 84*4882a593SmuzhiyunThe following is an example of GPU queue dump, where the SYNC SET operation 85*4882a593Smuzhiyunis blocked by the preceding SYNC WAIT operation. This shows two GPU queues, 86*4882a593Smuzhiyunwith the same KCTX ID of 8, Queue Group (CSG) 0, and Queue ID 0. The SYNC WAIT 87*4882a593Smuzhiyunoperation has started, while the SYNC SET is pending, blocked by the SYNC WAIT. 88*4882a593SmuzhiyunBoth operations are on the same slot, 2 and have live value of 0. The SYNC WAIT 89*4882a593Smuzhiyunis waiting on the object at address 0x0000007f81ffc800, while the SYNC SET will 90*4882a593Smuzhiyunset the object at address 0x00000000a3bad4fb when it is unblocked. 91*4882a593SmuzhiyunThe operation "op" is GT for the SYNC WAIT, indicating it's waiting for the 92*4882a593Smuzhiyunlive value to surpass the arg value, while the operation and arg value for the 93*4882a593SmuzhiyunSYNC SET is "set" and "1" respectively: 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun====================================================================================================================================== 96*4882a593Smuzhiyunqueue:GPU-8-0-0 exec:S cmd:SYNC_WAIT slot:2 obj:0x0000007f81ffc800 live_value:0x0000000000000000 | op:gt arg_value:0x0000000000000000 97*4882a593Smuzhiyunqueue:GPU-8-0-0 exec:P cmd:SYNC_SET slot:2 obj:0x00000000a3bad4fb live_value:0x0000000000000000 | op:set arg_value:0x0000000000000001 98*4882a593Smuzhiyun====================================================================================================================================== 99*4882a593Smuzhiyun 100*4882a593SmuzhiyunKCPU Queue Example 101*4882a593Smuzhiyun------------------ 102*4882a593Smuzhiyun 103*4882a593SmuzhiyunThe following is an example of a KCPU queue, from a process that has 104*4882a593Smuzhiyuna KCTX ID of 0 and has Queue ID 1. It has started and is waiting on the 105*4882a593Smuzhiyunobject at address 0x0000007fbf6f2ff8. The live value is currently 0 with 106*4882a593Smuzhiyunthe "op" being GT indicating it is waiting on the live value to 107*4882a593Smuzhiyunsurpass the arg value. 108*4882a593Smuzhiyun 109*4882a593Smuzhiyun=============================================================================================================================== 110*4882a593Smuzhiyunqueue:KCPU-0-1 exec:S cmd:CQS_WAIT_OPERATION obj:0x0000007fbf6f2ff8 live_value:0x0000000000000000 | op:gt arg_value: 0x00000000 111*4882a593Smuzhiyun=============================================================================================================================== 112