3 * (C) COPYRIGHT ARM Limited. All rights reserved.
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
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.
21 * @file mali_kbase_js_ctx_attr.h
22 * Job Scheduler Context Attribute APIs
25 #ifndef _KBASE_JS_CTX_ATTR_H_
26 #define _KBASE_JS_CTX_ATTR_H_
29 * @addtogroup base_api
34 * @addtogroup base_kbase_api
39 * @addtogroup kbase_js
44 * Set the initial attributes of a context (when context create flags are set)
47 * - Hold the jsctx_mutex
49 void kbasep_js_ctx_attr_set_initial_attrs(kbase_device *kbdev, kbase_context *kctx);
52 * Retain all attributes of a context
54 * This occurs on scheduling in the context on the runpool (but after
55 * is_scheduled is set)
59 * - runpool_irq spinlock
60 * - ctx->is_scheduled is true
62 void kbasep_js_ctx_attr_runpool_retain_ctx(kbase_device *kbdev, kbase_context *kctx);
65 * Release all attributes of a context
67 * This occurs on scheduling out the context from the runpool (but before
68 * is_scheduled is cleared)
72 * - runpool_irq spinlock
73 * - ctx->is_scheduled is true
75 * @return MALI_TRUE indicates a change in ctx attributes state of the runpool.
76 * In this state, the scheduler might be able to submit more jobs than
77 * previously, and so the caller should ensure kbasep_js_try_run_next_job_nolock()
78 * or similar is called sometime later.
79 * @return MALI_FALSE indicates no change in ctx attributes state of the runpool.
81 mali_bool kbasep_js_ctx_attr_runpool_release_ctx(kbase_device *kbdev, kbase_context *kctx);
84 * Retain all attributes of an atom
86 * This occurs on adding an atom to a context
90 * - If the context is scheduled, then runpool_irq spinlock must also be held
92 void kbasep_js_ctx_attr_ctx_retain_atom(kbase_device *kbdev, kbase_context *kctx, kbase_jd_atom *katom);
95 * Release all attributes of an atom, given its retained state.
97 * This occurs after (permanently) removing an atom from a context
101 * - If the context is scheduled, then runpool_irq spinlock must also be held
103 * This is a no-op when \a katom_retained_state is invalid.
105 * @return MALI_TRUE indicates a change in ctx attributes state of the runpool.
106 * In this state, the scheduler might be able to submit more jobs than
107 * previously, and so the caller should ensure kbasep_js_try_run_next_job_nolock()
108 * or similar is called sometime later.
109 * @return MALI_FALSE indicates no change in ctx attributes state of the runpool.
111 mali_bool kbasep_js_ctx_attr_ctx_release_atom(kbase_device *kbdev, kbase_context *kctx, kbasep_js_atom_retained_state *katom_retained_state);
115 * - runpool_irq spinlock
117 static INLINE s8 kbasep_js_ctx_attr_count_on_runpool(kbase_device *kbdev, kbasep_js_ctx_attr attribute)
119 kbasep_js_device_data *js_devdata;
121 KBASE_DEBUG_ASSERT(kbdev != NULL);
122 KBASE_DEBUG_ASSERT(attribute < KBASEP_JS_CTX_ATTR_COUNT);
123 js_devdata = &kbdev->js_data;
125 return js_devdata->runpool_irq.ctx_attr_ref_count[attribute];
130 * - runpool_irq spinlock
132 static INLINE mali_bool kbasep_js_ctx_attr_is_attr_on_runpool(kbase_device *kbdev, kbasep_js_ctx_attr attribute)
134 /* In general, attributes are 'on' when they have a non-zero refcount (note: the refcount will never be < 0) */
135 return (mali_bool) kbasep_js_ctx_attr_count_on_runpool(kbdev, attribute);
142 static INLINE mali_bool kbasep_js_ctx_attr_is_attr_on_ctx(kbase_context *kctx, kbasep_js_ctx_attr attribute)
144 kbasep_js_kctx_info *js_kctx_info;
146 KBASE_DEBUG_ASSERT(kctx != NULL);
147 KBASE_DEBUG_ASSERT(attribute < KBASEP_JS_CTX_ATTR_COUNT);
148 js_kctx_info = &kctx->jctx.sched_info;
150 /* In general, attributes are 'on' when they have a refcount (which should never be < 0) */
151 return (mali_bool) (js_kctx_info->ctx.ctx_attr_ref_count[attribute]);
154 /** @} *//* end group kbase_js */
155 /** @} *//* end group base_kbase_api */
156 /** @} *//* end group base_api */
158 #endif /* _KBASE_JS_DEFS_H_ */