1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 /* 3 * 4 * (C) COPYRIGHT 2020-2022 ARM Limited. All rights reserved. 5 * 6 * This program is free software and is provided to you under the terms of the 7 * GNU General Public License version 2 as published by the Free Software 8 * Foundation, and any use by you of this program is subject to the terms 9 * of such GNU license. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, you can access it online at 18 * http://www.gnu.org/licenses/gpl-2.0.html. 19 * 20 */ 21 22 #ifndef _KUTF_CLK_RATE_TRACE_TEST_H_ 23 #define _KUTF_CLK_RATE_TRACE_TEST_H_ 24 25 #define CLK_RATE_TRACE_APP_NAME "clk_rate_trace" 26 #define CLK_RATE_TRACE_SUITE_NAME "rate_trace" 27 #define CLK_RATE_TRACE_PORTAL "portal" 28 29 /** 30 * enum kbasep_clk_rate_trace_req - request command to the clock rate trace 31 * service portal. 32 * 33 * @PORTAL_CMD_GET_PLATFORM: Request the platform that the tests are 34 * to be run on. 35 * @PORTAL_CMD_GET_CLK_RATE_MGR: Request the clock trace manager internal 36 * data record. On a positive acknowledgement 37 * the prevailing clock rates and the GPU idle 38 * condition flag are returned. 39 * @PORTAL_CMD_GET_CLK_RATE_TRACE: Request the clock trace portal to return its 40 * data record. On a positive acknowledgement 41 * the last trace recorded clock rates and the 42 * GPU idle condition flag are returned. 43 * @PORTAL_CMD_GET_TRACE_SNAPSHOT: Request the clock trace portal to return its 44 * current snapshot data record. On a positive 45 * acknowledgement the snapshot array matching 46 * the number of clocks are returned. It also 47 * starts a fresh snapshot inside the clock 48 * trace portal. 49 * @PORTAL_CMD_INC_PM_CTX_CNT: Request the clock trace portal to increase 50 * its internal PM_CTX_COUNT. If this increase 51 * yielded a count of 0 -> 1 change, the portal 52 * will initiate a PM_CTX_ACTIVE call to the 53 * Kbase power management. Futher increase 54 * requests will limit to only affect the 55 * portal internal count value. 56 * @PORTAL_CMD_DEC_PM_CTX_CNT: Request the clock trace portal to decrease 57 * its internal PM_CTX_COUNT. If this decrease 58 * yielded a count of 1 -> 0 change, the portal 59 * will initiate a PM_CTX_IDLE call to the 60 * Kbase power management. 61 * @PORTAL_CMD_CLOSE_PORTAL: Inform the clock trace portal service the 62 * client has completed its session. The portal 63 * will start the close down action. If no 64 * error has occurred during the dynamic 65 * interactive session, an inherent basic test 66 * carrying out some sanity check on the clock 67 * trace is undertaken. 68 * @PORTAL_CMD_INVOKE_NOTIFY_42KHZ: Invokes all clock rate trace manager callbacks 69 * for the top clock domain with a new GPU frequency 70 * set to 42 kHZ. 71 * @PORTAL_CMD_INVALID: Valid commands termination marker. Must be 72 * the highest enumeration value, as it 73 * represents valid command array size. 74 * @PORTAL_TOTAL_CMDS: Alias of PORTAL_CMD_INVALID. 75 */ 76 /* PORTAL_CMD_INVALID must be the last one, serving the size */ 77 enum kbasep_clk_rate_trace_req { 78 PORTAL_CMD_GET_PLATFORM, 79 PORTAL_CMD_GET_CLK_RATE_MGR, 80 PORTAL_CMD_GET_CLK_RATE_TRACE, 81 PORTAL_CMD_GET_TRACE_SNAPSHOT, 82 PORTAL_CMD_INC_PM_CTX_CNT, 83 PORTAL_CMD_DEC_PM_CTX_CNT, 84 PORTAL_CMD_CLOSE_PORTAL, 85 PORTAL_CMD_INVOKE_NOTIFY_42KHZ, 86 PORTAL_CMD_INVALID, 87 PORTAL_TOTAL_CMDS = PORTAL_CMD_INVALID, 88 }; 89 90 /** 91 * DOC: Portal service request command names. 92 * 93 * The portal request consists of a kutf named u64-value. 94 * For those above enumerated PORTAL_CMD, the names defined 95 * here are used to mark the name and then followed with a sequence number 96 * value. Example (manual script here for illustration): 97 * exec 5<>run # open the portal kutf run as fd-5 98 * echo GET_CLK_RATE_MGR=1 >&5 # send the cmd and sequence number 1 99 * head -n 1 <&5 # read back the 1-line server reseponse 100 * ACK="{SEQ:1, RATE:[0x1ad27480], GPU_IDLE:1}" # response string 101 * echo GET_TRACE_SNAPSHOT=1 >&5 # send the cmd and sequence number 1 102 * head -n 1 <&5 # read back the 1-line server reseponse 103 * ACK="{SEQ:1, SNAPSHOT_ARRAY:[(0x0, 0x1ad27480, 1, 0)]}" 104 * echo CLOSE_PORTAL=1 >&5 # close the portal 105 * cat <&5 # read back all the response lines 106 * ACK="{SEQ:1, PM_CTX_CNT:0}" # response to close command 107 * KUTF_RESULT_PASS:(explicit pass) # internal sanity test passed. 108 * exec 5>&- # close the service portal fd. 109 * 110 * Expected request command return format: 111 * GET_CLK_RATE_MGR: ACK="{SEQ:12, RATE:[1080, 1280], GPU_IDLE:1}" 112 * Note, the above contains 2-clock with rates in [], GPU idle 113 * GET_CLK_RATE_TRACE: ACK="{SEQ:6, RATE:[0x1ad27480], GPU_IDLE:0}" 114 * Note, 1-clock with rate in [], GPU not idle 115 * GET_TRACE_SNAPSHOT: ACK="{SEQ:8, SNAPSHOT_ARRAY:[(0x0, 0x1ad27480, 1, 0)]}" 116 * Note, 1-clock, (start_rate : 0, last_rate : 0x1ad27480, 117 * trace_rate_up_count: 1, trace_rate_down_count : 0) 118 * For the specific sample case here, there is a single rate_trace event 119 * that yielded a rate increase change. No rate drop event recorded in the 120 * reporting snapshot duration. 121 * INC_PM_CTX_CNT: ACK="{SEQ:1, PM_CTX_CNT:1}" 122 * Note, after the increment, M_CTX_CNT is 1. (i.e. 0 -> 1) 123 * DEC_PM_CTX_CNT: ACK="{SEQ:3, PM_CTX_CNT:0}" 124 * Note, after the decrement, PM_CTX_CNT is 0. (i.e. 1 -> 0) 125 * CLOSE_PORTAL: ACK="{SEQ:1, PM_CTX_CNT:1}" 126 * Note, at the close, PM_CTX_CNT is 1. The PM_CTX_CNT will internally be 127 * dropped down to 0 as part of the portal close clean up. 128 */ 129 #define GET_PLATFORM "GET_PLATFORM" 130 #define GET_CLK_RATE_MGR "GET_CLK_RATE_MGR" 131 #define GET_CLK_RATE_TRACE "GET_CLK_RATE_TRACE" 132 #define GET_TRACE_SNAPSHOT "GET_TRACE_SNAPSHOT" 133 #define INC_PM_CTX_CNT "INC_PM_CTX_CNT" 134 #define DEC_PM_CTX_CNT "DEC_PM_CTX_CNT" 135 #define CLOSE_PORTAL "CLOSE_PORTAL" 136 #define INVOKE_NOTIFY_42KHZ "INVOKE_NOTIFY_42KHZ" 137 138 /** 139 * DOC: Portal service response tag names. 140 * 141 * The response consists of a kutf named string-value. 142 * In case of a 'NACK' (negative acknowledgment), it can be one of the two formats: 143 * 1. NACK="{SEQ:2, MSG:xyzed}" # NACK on command with sequence tag-2. 144 * Note, the portal has received a valid name and valid sequence number 145 * but can't carry-out the request, reason in the MSG field. 146 * 2. NACK="Failing-message" 147 * Note, unable to parse a valid name or valid sequence number, 148 * or some internal error condition. Reason in the quoted string. 149 */ 150 #define ACK "ACK" 151 #define NACK "NACK" 152 #define MAX_REPLY_NAME_LEN 32 153 154 #endif /* _KUTF_CLK_RATE_TRACE_TEST_H_ */ 155