| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #ifndef _KBASE_H_ |
| #define _KBASE_H_ |
| |
| #include <mali_malisw.h> |
| |
| #include <mali_kbase_debug.h> |
| |
| #include <asm/page.h> |
| |
| #include <linux/atomic.h> |
| #include <linux/highmem.h> |
| #include <linux/hrtimer.h> |
| #include <linux/ktime.h> |
| #include <linux/list.h> |
| #include <linux/mm_types.h> |
| #include <linux/mutex.h> |
| #include <linux/rwsem.h> |
| #include <linux/sched.h> |
| #include <linux/slab.h> |
| #include <linux/spinlock.h> |
| #include <linux/vmalloc.h> |
| #include <linux/wait.h> |
| #include <linux/workqueue.h> |
| #include <linux/sched/task_stack.h> |
| |
| #include "mali_base_kernel.h" |
| #include <mali_kbase_uku.h> |
| #include <mali_kbase_linux.h> |
| |
| |
| |
| |
| |
| #include "mali_kbase_defs.h" |
| |
| #include "mali_kbase_context.h" |
| #include "mali_kbase_strings.h" |
| #include "mali_kbase_mem_lowlevel.h" |
| #include "mali_kbase_trace_timeline.h" |
| #include "mali_kbase_js.h" |
| #include "mali_kbase_mem.h" |
| #include "mali_kbase_utility.h" |
| #include "mali_kbase_gpu_memory_debugfs.h" |
| #include "mali_kbase_mem_profile_debugfs.h" |
| #include "mali_kbase_debug_job_fault.h" |
| #include "mali_kbase_jd_debugfs.h" |
| #include "mali_kbase_gpuprops.h" |
| #include "mali_kbase_jm.h" |
| #include "mali_kbase_vinstr.h" |
| |
| #include "ipa/mali_kbase_ipa.h" |
| |
| #ifdef CONFIG_GPU_TRACEPOINTS |
| #include <trace/events/gpu.h> |
| #endif |
| |
| |
| |
| |
| |
| |
| |
| |
| struct kbase_device *kbase_device_alloc(void); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| const struct list_head *kbase_dev_list_get(void); |
| |
| void kbase_dev_list_put(const struct list_head *dev_list); |
| |
| int kbase_device_init(struct kbase_device * const kbdev); |
| void kbase_device_term(struct kbase_device *kbdev); |
| void kbase_device_free(struct kbase_device *kbdev); |
| int kbase_device_has_feature(struct kbase_device *kbdev, u32 feature); |
| |
| |
| struct kbase_device *kbase_find_device(int minor); |
| void kbase_release_device(struct kbase_device *kbdev); |
| |
| void kbase_set_profiling_control(struct kbase_device *kbdev, u32 control, u32 value); |
| |
| struct kbase_context * |
| kbase_create_context(struct kbase_device *kbdev, bool is_compat); |
| void kbase_destroy_context(struct kbase_context *kctx); |
| |
| int kbase_jd_init(struct kbase_context *kctx); |
| void kbase_jd_exit(struct kbase_context *kctx); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| int kbase_jd_submit(struct kbase_context *kctx, |
| <------><------>void __user *user_addr, u32 nr_atoms, u32 stride, |
| <------><------>bool uk6_atom); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| void kbase_jd_done_worker(struct work_struct *data); |
| |
| void kbase_jd_done(struct kbase_jd_atom *katom, int slot_nr, ktime_t *end_timestamp, |
| <------><------>kbasep_js_atom_done_code done_code); |
| void kbase_jd_cancel(struct kbase_device *kbdev, struct kbase_jd_atom *katom); |
| void kbase_jd_zap_context(struct kbase_context *kctx); |
| bool jd_done_nolock(struct kbase_jd_atom *katom, |
| <------><------>struct list_head *completed_jobs_ctx); |
| void kbase_jd_free_external_resources(struct kbase_jd_atom *katom); |
| bool jd_submit_atom(struct kbase_context *kctx, |
| <------><------><------> const struct base_jd_atom_v2 *user_atom, |
| <------><------><------> struct kbase_jd_atom *katom); |
| void kbase_jd_dep_clear_locked(struct kbase_jd_atom *katom); |
| |
| void kbase_job_done(struct kbase_device *kbdev, u32 done); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| void kbase_job_slot_ctx_priority_check_locked(struct kbase_context *kctx, |
| <------><------><------><------>struct kbase_jd_atom *katom); |
| |
| void kbase_job_slot_softstop(struct kbase_device *kbdev, int js, |
| <------><------>struct kbase_jd_atom *target_katom); |
| void kbase_job_slot_softstop_swflags(struct kbase_device *kbdev, int js, |
| <------><------>struct kbase_jd_atom *target_katom, u32 sw_flags); |
| void kbase_job_slot_hardstop(struct kbase_context *kctx, int js, |
| <------><------>struct kbase_jd_atom *target_katom); |
| void kbase_job_check_enter_disjoint(struct kbase_device *kbdev, u32 action, |
| <------><------>base_jd_core_req core_reqs, struct kbase_jd_atom *target_katom); |
| void kbase_job_check_leave_disjoint(struct kbase_device *kbdev, |
| <------><------>struct kbase_jd_atom *target_katom); |
| |
| void kbase_event_post(struct kbase_context *ctx, struct kbase_jd_atom *event); |
| int kbase_event_dequeue(struct kbase_context *ctx, struct base_jd_event_v2 *uevent); |
| int kbase_event_pending(struct kbase_context *ctx); |
| int kbase_event_init(struct kbase_context *kctx); |
| void kbase_event_close(struct kbase_context *kctx); |
| void kbase_event_cleanup(struct kbase_context *kctx); |
| void kbase_event_wakeup(struct kbase_context *kctx); |
| |
| int kbase_process_soft_job(struct kbase_jd_atom *katom); |
| int kbase_prepare_soft_job(struct kbase_jd_atom *katom); |
| void kbase_finish_soft_job(struct kbase_jd_atom *katom); |
| void kbase_cancel_soft_job(struct kbase_jd_atom *katom); |
| void kbase_resume_suspended_soft_jobs(struct kbase_device *kbdev); |
| void kbasep_remove_waiting_soft_job(struct kbase_jd_atom *katom); |
| #if defined(CONFIG_SYNC) || defined(CONFIG_SYNC_FILE) |
| void kbase_soft_event_wait_callback(struct kbase_jd_atom *katom); |
| #endif |
| int kbase_soft_event_update(struct kbase_context *kctx, |
| <------><------><------> u64 event, |
| <------><------><------> unsigned char new_status); |
| |
| bool kbase_replay_process(struct kbase_jd_atom *katom); |
| |
| void kbasep_soft_job_timeout_worker(struct timer_list *t); |
| void kbasep_complete_triggered_soft_events(struct kbase_context *kctx, u64 evt); |
| |
| |
| void kbase_device_trace_register_access(struct kbase_context *kctx, enum kbase_reg_access_type type, u16 reg_offset, u32 reg_value); |
| int kbase_device_trace_buffer_install( |
| <------><------>struct kbase_context *kctx, u32 *tb, size_t size); |
| void kbase_device_trace_buffer_uninstall(struct kbase_context *kctx); |
| |
| |
| void kbase_os_reg_write(struct kbase_device *kbdev, u16 offset, u32 value); |
| u32 kbase_os_reg_read(struct kbase_device *kbdev, u16 offset); |
| |
| void kbasep_as_do_poke(struct work_struct *work); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| const char *kbase_exception_name(struct kbase_device *kbdev, |
| <------><------>u32 exception_code); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| static inline bool kbase_pm_is_suspending(struct kbase_device *kbdev) |
| { |
| <------>return kbdev->pm.suspending; |
| } |
| |
| |
| |
| |
| |
| static inline int kbase_jd_atom_id(struct kbase_context *kctx, struct kbase_jd_atom *katom) |
| { |
| <------>int result; |
| |
| <------>KBASE_DEBUG_ASSERT(kctx); |
| <------>KBASE_DEBUG_ASSERT(katom); |
| <------>KBASE_DEBUG_ASSERT(katom->kctx == kctx); |
| |
| <------>result = katom - &kctx->jctx.atoms[0]; |
| <------>KBASE_DEBUG_ASSERT(result >= 0 && result <= BASE_JD_ATOM_COUNT); |
| <------>return result; |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| static inline struct kbase_jd_atom *kbase_jd_atom_from_id( |
| <------><------>struct kbase_context *kctx, int id) |
| { |
| <------>return &kctx->jctx.atoms[id]; |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| void kbase_disjoint_init(struct kbase_device *kbdev); |
| |
| |
| |
| |
| |
| |
| |
| void kbase_disjoint_event(struct kbase_device *kbdev); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| void kbase_disjoint_event_potential(struct kbase_device *kbdev); |
| |
| |
| |
| |
| |
| |
| |
| u32 kbase_disjoint_event_get(struct kbase_device *kbdev); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| void kbase_disjoint_state_up(struct kbase_device *kbdev); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| void kbase_disjoint_state_down(struct kbase_device *kbdev); |
| |
| |
| |
| |
| |
| #define KBASE_DISJOINT_STATE_INTERLEAVED_CONTEXT_COUNT_THRESHOLD 2 |
| |
| #if !defined(UINT64_MAX) |
| <------>#define UINT64_MAX ((uint64_t)0xFFFFFFFFFFFFFFFFULL) |
| #endif |
| |
| #if KBASE_TRACE_ENABLE |
| void kbasep_trace_debugfs_init(struct kbase_device *kbdev); |
| |
| #ifndef CONFIG_MALI_SYSTEM_TRACE |
| |
| |
| |
| |
| |
| |
| |
| |
| #define KBASE_TRACE_ADD_SLOT(kbdev, code, ctx, katom, gpu_addr, jobslot) \ |
| <------>kbasep_trace_add(kbdev, KBASE_TRACE_CODE(code), ctx, katom, gpu_addr, \ |
| <------><------><------>KBASE_TRACE_FLAG_JOBSLOT, 0, jobslot, 0) |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #define KBASE_TRACE_ADD_SLOT_INFO(kbdev, code, ctx, katom, gpu_addr, jobslot, info_val) \ |
| <------>kbasep_trace_add(kbdev, KBASE_TRACE_CODE(code), ctx, katom, gpu_addr, \ |
| <------><------><------>KBASE_TRACE_FLAG_JOBSLOT, 0, jobslot, info_val) |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #define KBASE_TRACE_ADD_REFCOUNT(kbdev, code, ctx, katom, gpu_addr, refcount) \ |
| <------>kbasep_trace_add(kbdev, KBASE_TRACE_CODE(code), ctx, katom, gpu_addr, \ |
| <------><------><------>KBASE_TRACE_FLAG_REFCOUNT, refcount, 0, 0) |
| |
| |
| |
| |
| |
| |
| |
| |
| #define KBASE_TRACE_ADD_REFCOUNT_INFO(kbdev, code, ctx, katom, gpu_addr, refcount, info_val) \ |
| <------>kbasep_trace_add(kbdev, KBASE_TRACE_CODE(code), ctx, katom, gpu_addr, \ |
| <------><------><------>KBASE_TRACE_FLAG_REFCOUNT, refcount, 0, info_val) |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #define KBASE_TRACE_ADD(kbdev, code, ctx, katom, gpu_addr, info_val) \ |
| <------>kbasep_trace_add(kbdev, KBASE_TRACE_CODE(code), ctx, katom, gpu_addr, \ |
| <------><------><------>0, 0, 0, info_val) |
| |
| |
| #define KBASE_TRACE_CLEAR(kbdev) \ |
| <------>kbasep_trace_clear(kbdev) |
| |
| |
| #define KBASE_TRACE_DUMP(kbdev) \ |
| <------>kbasep_trace_dump(kbdev) |
| |
| |
| void kbasep_trace_add(struct kbase_device *kbdev, enum kbase_trace_code code, void *ctx, struct kbase_jd_atom *katom, u64 gpu_addr, u8 flags, int refcount, int jobslot, unsigned long info_val); |
| |
| void kbasep_trace_clear(struct kbase_device *kbdev); |
| #else |
| |
| #include <mali_linux_kbase_trace.h> |
| #define KBASE_TRACE_ADD_SLOT(kbdev, code, ctx, katom, gpu_addr, jobslot)\ |
| <------>trace_mali_##code(jobslot, 0) |
| |
| #define KBASE_TRACE_ADD_SLOT_INFO(kbdev, code, ctx, katom, gpu_addr, jobslot, info_val)\ |
| <------>trace_mali_##code(jobslot, info_val) |
| |
| #define KBASE_TRACE_ADD_REFCOUNT(kbdev, code, ctx, katom, gpu_addr, refcount)\ |
| <------>trace_mali_##code(refcount, 0) |
| |
| #define KBASE_TRACE_ADD_REFCOUNT_INFO(kbdev, code, ctx, katom, gpu_addr, refcount, info_val)\ |
| <------>trace_mali_##code(refcount, info_val) |
| |
| #define KBASE_TRACE_ADD(kbdev, code, ctx, katom, gpu_addr, info_val)\ |
| <------>trace_mali_##code(gpu_addr, info_val) |
| |
| #define KBASE_TRACE_CLEAR(kbdev)\ |
| <------>do {\ |
| <------><------>CSTD_UNUSED(kbdev);\ |
| <------><------>CSTD_NOP(0);\ |
| <------>} while (0) |
| #define KBASE_TRACE_DUMP(kbdev)\ |
| <------>do {\ |
| <------><------>CSTD_UNUSED(kbdev);\ |
| <------><------>CSTD_NOP(0);\ |
| <------>} while (0) |
| |
| #endif |
| #else |
| #define KBASE_TRACE_ADD_SLOT(kbdev, code, ctx, katom, gpu_addr, jobslot)\ |
| <------>do {\ |
| <------><------>CSTD_UNUSED(kbdev);\ |
| <------><------>CSTD_NOP(code);\ |
| <------><------>CSTD_UNUSED(ctx);\ |
| <------><------>CSTD_UNUSED(katom);\ |
| <------><------>CSTD_UNUSED(gpu_addr);\ |
| <------><------>CSTD_UNUSED(jobslot);\ |
| <------>} while (0) |
| |
| #define KBASE_TRACE_ADD_SLOT_INFO(kbdev, code, ctx, katom, gpu_addr, jobslot, info_val)\ |
| <------>do {\ |
| <------><------>CSTD_UNUSED(kbdev);\ |
| <------><------>CSTD_NOP(code);\ |
| <------><------>CSTD_UNUSED(ctx);\ |
| <------><------>CSTD_UNUSED(katom);\ |
| <------><------>CSTD_UNUSED(gpu_addr);\ |
| <------><------>CSTD_UNUSED(jobslot);\ |
| <------><------>CSTD_UNUSED(info_val);\ |
| <------><------>CSTD_NOP(0);\ |
| <------>} while (0) |
| |
| #define KBASE_TRACE_ADD_REFCOUNT(kbdev, code, ctx, katom, gpu_addr, refcount)\ |
| <------>do {\ |
| <------><------>CSTD_UNUSED(kbdev);\ |
| <------><------>CSTD_NOP(code);\ |
| <------><------>CSTD_UNUSED(ctx);\ |
| <------><------>CSTD_UNUSED(katom);\ |
| <------><------>CSTD_UNUSED(gpu_addr);\ |
| <------><------>CSTD_UNUSED(refcount);\ |
| <------><------>CSTD_NOP(0);\ |
| <------>} while (0) |
| |
| #define KBASE_TRACE_ADD_REFCOUNT_INFO(kbdev, code, ctx, katom, gpu_addr, refcount, info_val)\ |
| <------>do {\ |
| <------><------>CSTD_UNUSED(kbdev);\ |
| <------><------>CSTD_NOP(code);\ |
| <------><------>CSTD_UNUSED(ctx);\ |
| <------><------>CSTD_UNUSED(katom);\ |
| <------><------>CSTD_UNUSED(gpu_addr);\ |
| <------><------>CSTD_UNUSED(info_val);\ |
| <------><------>CSTD_NOP(0);\ |
| <------>} while (0) |
| |
| #define KBASE_TRACE_ADD(kbdev, code, subcode, ctx, katom, val)\ |
| <------>do {\ |
| <------><------>CSTD_UNUSED(kbdev);\ |
| <------><------>CSTD_NOP(code);\ |
| <------><------>CSTD_UNUSED(subcode);\ |
| <------><------>CSTD_UNUSED(ctx);\ |
| <------><------>CSTD_UNUSED(katom);\ |
| <------><------>CSTD_UNUSED(val);\ |
| <------><------>CSTD_NOP(0);\ |
| <------>} while (0) |
| |
| #define KBASE_TRACE_CLEAR(kbdev)\ |
| <------>do {\ |
| <------><------>CSTD_UNUSED(kbdev);\ |
| <------><------>CSTD_NOP(0);\ |
| <------>} while (0) |
| #define KBASE_TRACE_DUMP(kbdev)\ |
| <------>do {\ |
| <------><------>CSTD_UNUSED(kbdev);\ |
| <------><------>CSTD_NOP(0);\ |
| <------>} while (0) |
| #endif |
| |
| void kbasep_trace_dump(struct kbase_device *kbdev); |
| |
| #ifdef CONFIG_MALI_DEBUG |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| void kbase_set_driver_inactive(struct kbase_device *kbdev, bool inactive); |
| #endif |
| |
| |
| #if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_MALI_NO_MALI) |
| |
| |
| |
| |
| |
| |
| |
| |
| int kbase_io_history_init(struct kbase_io_history *h, u16 n); |
| |
| |
| |
| |
| |
| void kbase_io_history_term(struct kbase_io_history *h); |
| |
| |
| |
| |
| |
| void kbase_io_history_dump(struct kbase_device *kbdev); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| int kbase_io_history_resize(struct kbase_io_history *h, u16 new_size); |
| |
| #else |
| |
| #define kbase_io_history_init(...) ((int)0) |
| |
| #define kbase_io_history_term CSTD_NOP |
| |
| #define kbase_io_history_dump CSTD_NOP |
| |
| #define kbase_io_history_resize CSTD_NOP |
| |
| #endif |
| |
| |
| #endif |
| |
| |
| |
| |