#include <drm/drm_drv.h>
#include <drm/drm_exec.h>
#include <drm/drm_gem_shmem_helper.h>
#include <drm/drm_managed.h>
#include <drm/gpu_scheduler.h>
#include <drm/panthor_drm.h>
#include <linux/build_bug.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/dma-mapping.h>
#include <linux/dma-resv.h>
#include <linux/firmware.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/iosys-map.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include "panthor_devfreq.h"
#include "panthor_device.h"
#include "panthor_fw.h"
#include "panthor_gem.h"
#include "panthor_gpu.h"
#include "panthor_heap.h"
#include "panthor_mmu.h"
#include "panthor_regs.h"
#include "panthor_sched.h"
#define JOB_TIMEOUT_MS …
#define MIN_CS_PER_CSG …
#define MIN_CSGS …
#define MAX_CSG_PRIO …
struct panthor_group;
struct panthor_csg_slot { … };
enum panthor_csg_priority { … };
struct panthor_scheduler { … };
struct panthor_syncobj_32b { … };
struct panthor_syncobj_64b { … };
struct panthor_queue { … };
enum panthor_group_state { … };
struct panthor_group { … };
#define group_queue_work(group, wname) …
#define sched_queue_work(sched, wname) …
#define sched_queue_delayed_work(sched, wname, delay) …
#define MAX_GROUPS_PER_POOL …
struct panthor_group_pool { … };
struct panthor_job { … };
static void
panthor_queue_put_syncwait_obj(struct panthor_queue *queue)
{ … }
static void *
panthor_queue_get_syncwait_obj(struct panthor_group *group, struct panthor_queue *queue)
{ … }
static void group_free_queue(struct panthor_group *group, struct panthor_queue *queue)
{ … }
static void group_release_work(struct work_struct *work)
{ … }
static void group_release(struct kref *kref)
{ … }
static void group_put(struct panthor_group *group)
{ … }
static struct panthor_group *
group_get(struct panthor_group *group)
{ … }
static int
group_bind_locked(struct panthor_group *group, u32 csg_id)
{ … }
static int
group_unbind_locked(struct panthor_group *group)
{ … }
static void
cs_slot_prog_locked(struct panthor_device *ptdev, u32 csg_id, u32 cs_id)
{ … }
static int
cs_slot_reset_locked(struct panthor_device *ptdev, u32 csg_id, u32 cs_id)
{ … }
static void
csg_slot_sync_priority_locked(struct panthor_device *ptdev, u32 csg_id)
{ … }
static void
cs_slot_sync_queue_state_locked(struct panthor_device *ptdev, u32 csg_id, u32 cs_id)
{ … }
static void
csg_slot_sync_queues_state_locked(struct panthor_device *ptdev, u32 csg_id)
{ … }
static void
csg_slot_sync_state_locked(struct panthor_device *ptdev, u32 csg_id)
{ … }
static int
csg_slot_prog_locked(struct panthor_device *ptdev, u32 csg_id, u32 priority)
{ … }
static void
cs_slot_process_fatal_event_locked(struct panthor_device *ptdev,
u32 csg_id, u32 cs_id)
{ … }
static void
cs_slot_process_fault_event_locked(struct panthor_device *ptdev,
u32 csg_id, u32 cs_id)
{ … }
static int group_process_tiler_oom(struct panthor_group *group, u32 cs_id)
{ … }
static void group_tiler_oom_work(struct work_struct *work)
{ … }
static void
cs_slot_process_tiler_oom_event_locked(struct panthor_device *ptdev,
u32 csg_id, u32 cs_id)
{ … }
static bool cs_slot_process_irq_locked(struct panthor_device *ptdev,
u32 csg_id, u32 cs_id)
{ … }
static void csg_slot_sync_idle_state_locked(struct panthor_device *ptdev, u32 csg_id)
{ … }
static void csg_slot_process_idle_event_locked(struct panthor_device *ptdev, u32 csg_id)
{ … }
static void csg_slot_sync_update_locked(struct panthor_device *ptdev,
u32 csg_id)
{ … }
static void
csg_slot_process_progress_timer_event_locked(struct panthor_device *ptdev, u32 csg_id)
{ … }
static void sched_process_csg_irq_locked(struct panthor_device *ptdev, u32 csg_id)
{ … }
static void sched_process_idle_event_locked(struct panthor_device *ptdev)
{ … }
static void sched_process_global_irq_locked(struct panthor_device *ptdev)
{ … }
static void process_fw_events_work(struct work_struct *work)
{ … }
void panthor_sched_report_fw_events(struct panthor_device *ptdev, u32 events)
{ … }
static const char *fence_get_driver_name(struct dma_fence *fence)
{ … }
static const char *queue_fence_get_timeline_name(struct dma_fence *fence)
{ … }
static const struct dma_fence_ops panthor_queue_fence_ops = …;
struct panthor_csg_slots_upd_ctx { … };
static void csgs_upd_ctx_init(struct panthor_csg_slots_upd_ctx *ctx)
{ … }
static void csgs_upd_ctx_queue_reqs(struct panthor_device *ptdev,
struct panthor_csg_slots_upd_ctx *ctx,
u32 csg_id, u32 value, u32 mask)
{ … }
static int csgs_upd_ctx_apply_locked(struct panthor_device *ptdev,
struct panthor_csg_slots_upd_ctx *ctx)
{ … }
struct panthor_sched_tick_ctx { … };
static bool
tick_ctx_is_full(const struct panthor_scheduler *sched,
const struct panthor_sched_tick_ctx *ctx)
{ … }
static bool
group_is_idle(struct panthor_group *group)
{ … }
static bool
group_can_run(struct panthor_group *group)
{ … }
static void
tick_ctx_pick_groups_from_list(const struct panthor_scheduler *sched,
struct panthor_sched_tick_ctx *ctx,
struct list_head *queue,
bool skip_idle_groups,
bool owned_by_tick_ctx)
{ … }
static void
tick_ctx_insert_old_group(struct panthor_scheduler *sched,
struct panthor_sched_tick_ctx *ctx,
struct panthor_group *group,
bool full_tick)
{ … }
static void
tick_ctx_init(struct panthor_scheduler *sched,
struct panthor_sched_tick_ctx *ctx,
bool full_tick)
{ … }
#define NUM_INSTRS_PER_SLOT …
static void
group_term_post_processing(struct panthor_group *group)
{ … }
static void group_term_work(struct work_struct *work)
{ … }
static void
tick_ctx_cleanup(struct panthor_scheduler *sched,
struct panthor_sched_tick_ctx *ctx)
{ … }
static void
tick_ctx_apply(struct panthor_scheduler *sched, struct panthor_sched_tick_ctx *ctx)
{ … }
static u64
tick_ctx_update_resched_target(struct panthor_scheduler *sched,
const struct panthor_sched_tick_ctx *ctx)
{ … }
static void tick_work(struct work_struct *work)
{ … }
static int panthor_queue_eval_syncwait(struct panthor_group *group, u8 queue_idx)
{ … }
static void sync_upd_work(struct work_struct *work)
{ … }
static void group_schedule_locked(struct panthor_group *group, u32 queue_mask)
{ … }
static void queue_stop(struct panthor_queue *queue,
struct panthor_job *bad_job)
{ … }
static void queue_start(struct panthor_queue *queue)
{ … }
static void panthor_group_stop(struct panthor_group *group)
{ … }
static void panthor_group_start(struct panthor_group *group)
{ … }
static void panthor_sched_immediate_tick(struct panthor_device *ptdev)
{ … }
void panthor_sched_report_mmu_fault(struct panthor_device *ptdev)
{ … }
void panthor_sched_resume(struct panthor_device *ptdev)
{ … }
void panthor_sched_suspend(struct panthor_device *ptdev)
{ … }
void panthor_sched_pre_reset(struct panthor_device *ptdev)
{ … }
void panthor_sched_post_reset(struct panthor_device *ptdev, bool reset_failed)
{ … }
static void group_sync_upd_work(struct work_struct *work)
{ … }
static struct dma_fence *
queue_run_job(struct drm_sched_job *sched_job)
{ … }
static enum drm_gpu_sched_stat
queue_timedout_job(struct drm_sched_job *sched_job)
{ … }
static void queue_free_job(struct drm_sched_job *sched_job)
{ … }
static const struct drm_sched_backend_ops panthor_queue_sched_ops = …;
static struct panthor_queue *
group_create_queue(struct panthor_group *group,
const struct drm_panthor_queue_create *args)
{ … }
#define MAX_GROUPS_PER_POOL …
int panthor_group_create(struct panthor_file *pfile,
const struct drm_panthor_group_create *group_args,
const struct drm_panthor_queue_create *queue_args)
{ … }
int panthor_group_destroy(struct panthor_file *pfile, u32 group_handle)
{ … }
int panthor_group_get_state(struct panthor_file *pfile,
struct drm_panthor_group_get_state *get_state)
{ … }
int panthor_group_pool_create(struct panthor_file *pfile)
{ … }
void panthor_group_pool_destroy(struct panthor_file *pfile)
{ … }
static void job_release(struct kref *ref)
{ … }
struct drm_sched_job *panthor_job_get(struct drm_sched_job *sched_job)
{ … }
void panthor_job_put(struct drm_sched_job *sched_job)
{ … }
struct panthor_vm *panthor_job_vm(struct drm_sched_job *sched_job)
{ … }
struct drm_sched_job *
panthor_job_create(struct panthor_file *pfile,
u16 group_handle,
const struct drm_panthor_queue_submit *qsubmit)
{ … }
void panthor_job_update_resvs(struct drm_exec *exec, struct drm_sched_job *sched_job)
{ … }
void panthor_sched_unplug(struct panthor_device *ptdev)
{ … }
static void panthor_sched_fini(struct drm_device *ddev, void *res)
{ … }
int panthor_sched_init(struct panthor_device *ptdev)
{ … }