1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 /* 3 * 4 * (C) COPYRIGHT 2012-2016, 2018, 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 _KBASE_DEBUG_JOB_FAULT_H 23 #define _KBASE_DEBUG_JOB_FAULT_H 24 25 #include <linux/debugfs.h> 26 #include <linux/seq_file.h> 27 28 #define REGISTER_DUMP_TERMINATION_FLAG 0xFFFFFFFF 29 30 /** 31 * kbase_debug_job_fault_dev_init - Create the fault event wait queue 32 * per device and initialize the required lists. 33 * @kbdev: Device pointer 34 * 35 * Return: Zero on success or a negative error code. 36 */ 37 int kbase_debug_job_fault_dev_init(struct kbase_device *kbdev); 38 39 /** 40 * kbase_debug_job_fault_debugfs_init - Initialize job fault debug sysfs 41 * @kbdev: Device pointer 42 */ 43 void kbase_debug_job_fault_debugfs_init(struct kbase_device *kbdev); 44 45 /** 46 * kbase_debug_job_fault_dev_term - Clean up resources created in 47 * kbase_debug_job_fault_dev_init. 48 * @kbdev: Device pointer 49 */ 50 void kbase_debug_job_fault_dev_term(struct kbase_device *kbdev); 51 52 /** 53 * kbase_debug_job_fault_context_init - Initialize the relevant 54 * data structure per context 55 * @kctx: KBase context pointer 56 * Return: 0 on success 57 */ 58 int kbase_debug_job_fault_context_init(struct kbase_context *kctx); 59 60 /** 61 * kbase_debug_job_fault_context_term - Release the relevant 62 * resource per context 63 * @kctx: KBase context pointer 64 */ 65 void kbase_debug_job_fault_context_term(struct kbase_context *kctx); 66 67 /** 68 * kbase_debug_job_fault_kctx_unblock - Unblock the atoms blocked on job fault 69 * dumping on context termination. 70 * 71 * @kctx: KBase context pointer 72 * 73 * This function is called during context termination to unblock the atom for 74 * which the job fault occurred and also the atoms following it. This is needed 75 * otherwise the wait for zero jobs could timeout (leading to an assertion 76 * failure, kernel panic in debug builds) in the pathological case where 77 * although the thread/daemon capturing the job fault events is running, 78 * but for some reasons has stopped consuming the events. 79 */ 80 void kbase_debug_job_fault_kctx_unblock(struct kbase_context *kctx); 81 82 /** 83 * kbase_debug_job_fault_process - Process the failed job. 84 * 85 * @katom: The failed atom pointer 86 * @completion_code: the job status 87 * 88 * It will send a event and wake up the job fault waiting queue 89 * Then create a work queue to wait for job dump finish 90 * This function should be called in the interrupt handler and before 91 * jd_done that make sure the jd_done_worker will be delayed until the 92 * job dump finish 93 * 94 * Return: true if dump is going on 95 */ 96 bool kbase_debug_job_fault_process(struct kbase_jd_atom *katom, 97 u32 completion_code); 98 99 /** 100 * kbase_debug_job_fault_reg_snapshot_init - Set the interested registers 101 * address during the job fault process, the relevant registers will 102 * be saved when a job fault happen 103 * @kctx: KBase context pointer 104 * @reg_range: Maximum register address space 105 * 106 * Return: true if initializing successfully 107 */ 108 bool kbase_debug_job_fault_reg_snapshot_init(struct kbase_context *kctx, 109 int reg_range); 110 111 /** 112 * kbase_job_fault_get_reg_snapshot - Read the interested registers for 113 * failed job dump 114 * 115 * @kctx: KBase context pointer 116 * 117 * Return: true if getting registers successfully 118 */ 119 bool kbase_job_fault_get_reg_snapshot(struct kbase_context *kctx); 120 121 #endif /*_KBASE_DEBUG_JOB_FAULT_H*/ 122