1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 /* 3 * 4 * (C) COPYRIGHT 2020-2021 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 _KBASE_CSF_CPU_QUEUE_DEBUGFS_H_ 23 #define _KBASE_CSF_CPU_QUEUE_DEBUGFS_H_ 24 25 #include <asm/atomic.h> 26 #include <linux/types.h> 27 28 #include "mali_kbase.h" 29 30 /* Forward declaration */ 31 struct base_csf_notification; 32 33 #define MALI_CSF_CPU_QUEUE_DEBUGFS_VERSION 0 34 35 /* CPU queue dump status */ 36 /* Dumping is done or no dumping is in progress. */ 37 #define BASE_CSF_CPU_QUEUE_DUMP_COMPLETE 0 38 /* Dumping request is pending. */ 39 #define BASE_CSF_CPU_QUEUE_DUMP_PENDING 1 40 /* Dumping request is issued to Userspace */ 41 #define BASE_CSF_CPU_QUEUE_DUMP_ISSUED 2 42 43 44 /** 45 * kbase_csf_cpu_queue_debugfs_init() - Create a debugfs entry for per context cpu queue(s) 46 * 47 * @kctx: The kbase_context for which to create the debugfs entry 48 */ 49 void kbase_csf_cpu_queue_debugfs_init(struct kbase_context *kctx); 50 51 /** 52 * kbase_csf_cpu_queue_read_dump_req - Read cpu queue dump request event 53 * 54 * @kctx: The kbase_context which cpu queue dumpped belongs to 55 * @req: Notification with cpu queue dump request. 56 * 57 * Return: true if needs CPU queue dump, or false otherwise. 58 */ 59 bool kbase_csf_cpu_queue_read_dump_req(struct kbase_context *kctx, 60 struct base_csf_notification *req); 61 62 /** 63 * kbase_csf_cpu_queue_dump_needed - Check the requirement for cpu queue dump 64 * 65 * @kctx: The kbase_context which cpu queue dumpped belongs to 66 * 67 * Return: true if it needs cpu queue dump, or false otherwise. 68 */ kbase_csf_cpu_queue_dump_needed(struct kbase_context * kctx)69static inline bool kbase_csf_cpu_queue_dump_needed(struct kbase_context *kctx) 70 { 71 #if IS_ENABLED(CONFIG_DEBUG_FS) 72 return (atomic_read(&kctx->csf.cpu_queue.dump_req_status) == 73 BASE_CSF_CPU_QUEUE_DUMP_ISSUED); 74 #else 75 return false; 76 #endif 77 } 78 79 /** 80 * kbase_csf_cpu_queue_dump - dump buffer containing cpu queue information to debugfs 81 * 82 * @kctx: The kbase_context which cpu queue dumpped belongs to 83 * @buffer: Buffer containing the cpu queue information. 84 * @buf_size: Buffer size. 85 * 86 * Return: Return 0 for dump successfully, or error code. 87 */ 88 int kbase_csf_cpu_queue_dump(struct kbase_context *kctx, 89 u64 buffer, size_t buf_size); 90 #endif /* _KBASE_CSF_CPU_QUEUE_DEBUGFS_H_ */ 91