0930f905e4efcaeb37a12f16e1a7bbdc2b8b335a
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / midgard_for_linux / mali_kbase_debug_job_fault.h
1 /*
2  *
3  * (C) COPYRIGHT 2012-2015 ARM Limited. All rights reserved.
4  *
5  * This program is free software and is provided to you under the terms of the
6  * GNU General Public License version 2 as published by the Free Software
7  * Foundation, and any use by you of this program is subject to the terms
8  * of such GNU licence.
9  *
10  * A copy of the licence is included with the program, and can also be obtained
11  * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
12  * Boston, MA  02110-1301, USA.
13  *
14  */
15
16
17
18 #ifndef _KBASE_DEBUG_JOB_FAULT_H
19 #define _KBASE_DEBUG_JOB_FAULT_H
20
21 #include <mali_kbase.h>
22 #include <linux/debugfs.h>
23 #include <linux/seq_file.h>
24
25 #define REGISTER_DUMP_TERMINATION_FLAG 0xFFFFFFFF
26
27 /**
28  * kbase_debug_job_fault_dev_init - Create the fault event wait queue
29  *              per device and initialize the required lists.
30  * @kbdev:      Device pointer
31  *
32  * Return: Zero on success or a negative error code.
33  */
34 int kbase_debug_job_fault_dev_init(struct kbase_device *kbdev);
35
36 /**
37  * kbase_debug_job_fault_debugfs_init - Initialize job fault debug sysfs
38  * @kbdev:      Device pointer
39  */
40 void kbase_debug_job_fault_debugfs_init(struct kbase_device *kbdev);
41
42 /**
43  * kbase_debug_job_fault_dev_term - Clean up resources created in
44  *              kbase_debug_job_fault_dev_init.
45  * @kbdev:      Device pointer
46  */
47 void kbase_debug_job_fault_dev_term(struct kbase_device *kbdev);
48
49 /**
50  * kbase_debug_job_fault_context_init - Initialize the relevant
51  *              data structure per context
52  * @kctx: KBase context pointer
53  */
54 void kbase_debug_job_fault_context_init(struct kbase_context *kctx);
55
56 /**
57  * kbase_debug_job_fault_context_term - Release the relevant
58  *              resource per context
59  * @kctx: KBase context pointer
60  */
61 void kbase_debug_job_fault_context_term(struct kbase_context *kctx);
62
63 /**
64  * kbase_debug_job_fault_process - Process the failed job.
65  *      It will send a event and wake up the job fault waiting queue
66  *      Then create a work queue to wait for job dump finish
67  *      This function should be called in the interrupt handler and before
68  *      jd_done that make sure the jd_done_worker will be delayed until the
69  *      job dump finish
70  * @katom: The failed atom pointer
71  * @completion_code: the job status
72  * @return true if dump is going on
73  */
74 bool kbase_debug_job_fault_process(struct kbase_jd_atom *katom,
75                 u32 completion_code);
76
77
78 /**
79  * kbase_debug_job_fault_reg_snapshot_init - Set the interested registers
80  *      address during the job fault process, the relevant registers will
81  *      be saved when a job fault happen
82  * @kctx: KBase context pointer
83  * @reg_range: Maximum register address space
84  * @return true if initializing successfully
85  */
86 bool kbase_debug_job_fault_reg_snapshot_init(struct kbase_context *kctx,
87                 int reg_range);
88
89 /**
90  * kbase_job_fault_get_reg_snapshot - Read the interested registers for
91  *      failed job dump
92  * @kctx: KBase context pointer
93  * @return true if getting registers successfully
94  */
95 bool kbase_job_fault_get_reg_snapshot(struct kbase_context *kctx);
96
97 #endif  /*_KBASE_DEBUG_JOB_FAULT_H*/