1 /* 2 * 3 * (C) COPYRIGHT 2015-2016 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_VINSTR_H_ 19 #define _KBASE_VINSTR_H_ 20 21 #include <mali_kbase.h> 22 #include <mali_kbase_hwcnt_reader.h> 23 24 /*****************************************************************************/ 25 26 struct kbase_vinstr_context; 27 struct kbase_vinstr_client; 28 29 /*****************************************************************************/ 30 31 /** 32 * kbase_vinstr_init() - initialize the vinstr core 33 * @kbdev: kbase device 34 * 35 * Return: pointer to the vinstr context on success or NULL on failure 36 */ 37 struct kbase_vinstr_context *kbase_vinstr_init(struct kbase_device *kbdev); 38 39 /** 40 * kbase_vinstr_term() - terminate the vinstr core 41 * @vinstr_ctx: vinstr context 42 */ 43 void kbase_vinstr_term(struct kbase_vinstr_context *vinstr_ctx); 44 45 /** 46 * kbase_vinstr_hwcnt_reader_setup - configure hw counters reader 47 * @vinstr_ctx: vinstr context 48 * @setup: reader's configuration 49 * 50 * Return: zero on success 51 */ 52 int kbase_vinstr_hwcnt_reader_setup( 53 struct kbase_vinstr_context *vinstr_ctx, 54 struct kbase_uk_hwcnt_reader_setup *setup); 55 56 /** 57 * kbase_vinstr_legacy_hwc_setup - configure hw counters for dumping 58 * @vinstr_ctx: vinstr context 59 * @cli: pointer where to store pointer to new vinstr client structure 60 * @setup: hwc configuration 61 * 62 * Return: zero on success 63 */ 64 int kbase_vinstr_legacy_hwc_setup( 65 struct kbase_vinstr_context *vinstr_ctx, 66 struct kbase_vinstr_client **cli, 67 struct kbase_uk_hwcnt_setup *setup); 68 69 /** 70 * kbase_vinstr_hwcnt_kernel_setup - configure hw counters for kernel side 71 * client 72 * @vinstr_ctx: vinstr context 73 * @setup: reader's configuration 74 * @kernel_buffer: pointer to dump buffer 75 * 76 * setup->buffer_count and setup->fd are not used for kernel side clients. 77 * 78 * Return: pointer to client structure, or NULL on failure 79 */ 80 struct kbase_vinstr_client *kbase_vinstr_hwcnt_kernel_setup( 81 struct kbase_vinstr_context *vinstr_ctx, 82 struct kbase_uk_hwcnt_reader_setup *setup, 83 void *kernel_buffer); 84 85 /** 86 * kbase_vinstr_hwc_dump - issue counter dump for vinstr client 87 * @cli: pointer to vinstr client 88 * @event_id: id of event that triggered hwcnt dump 89 * 90 * Return: zero on success 91 */ 92 int kbase_vinstr_hwc_dump( 93 struct kbase_vinstr_client *cli, 94 enum base_hwcnt_reader_event event_id); 95 96 /** 97 * kbase_vinstr_hwc_clear - performs a reset of the hardware counters for 98 * a given kbase context 99 * @cli: pointer to vinstr client 100 * 101 * Return: zero on success 102 */ 103 int kbase_vinstr_hwc_clear(struct kbase_vinstr_client *cli); 104 105 /** 106 * kbase_vinstr_try_suspend - try suspending operation of a given vinstr context 107 * @vinstr_ctx: vinstr context 108 * 109 * Return: 0 on success, or negative if state change is in progress 110 * 111 * Warning: This API call is non-generic. It is meant to be used only by 112 * job scheduler state machine. 113 * 114 * Function initiates vinstr switch to suspended state. Once it was called 115 * vinstr enters suspending state. If function return non-zero value, it 116 * indicates that state switch is not complete and function must be called 117 * again. On state switch vinstr will trigger job scheduler state machine 118 * cycle. 119 */ 120 int kbase_vinstr_try_suspend(struct kbase_vinstr_context *vinstr_ctx); 121 122 /** 123 * kbase_vinstr_suspend - suspends operation of a given vinstr context 124 * @vinstr_ctx: vinstr context 125 * 126 * Function initiates vinstr switch to suspended state. Then it blocks until 127 * operation is completed. 128 */ 129 void kbase_vinstr_suspend(struct kbase_vinstr_context *vinstr_ctx); 130 131 /** 132 * kbase_vinstr_resume - resumes operation of a given vinstr context 133 * @vinstr_ctx: vinstr context 134 * 135 * Function can be called only if it was preceded by a successful call 136 * to kbase_vinstr_suspend. 137 */ 138 void kbase_vinstr_resume(struct kbase_vinstr_context *vinstr_ctx); 139 140 /** 141 * kbase_vinstr_dump_size - Return required size of dump buffer 142 * @kbdev: device pointer 143 * 144 * Return : buffer size in bytes 145 */ 146 size_t kbase_vinstr_dump_size(struct kbase_device *kbdev); 147 148 /** 149 * kbase_vinstr_detach_client - Detach a client from the vinstr core 150 * @cli: pointer to vinstr client 151 */ 152 void kbase_vinstr_detach_client(struct kbase_vinstr_client *cli); 153 154 #endif /* _KBASE_VINSTR_H_ */ 155 156