1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
4 #ifndef __LIMA_SCHED_H__
5 #define __LIMA_SCHED_H__
7 #include <drm/gpu_scheduler.h>
11 struct lima_sched_task {
12 struct drm_sched_job base;
18 unsigned long last_dep;
27 struct dma_fence *fence;
30 struct lima_sched_context {
31 struct drm_sched_entity base;
34 #define LIMA_SCHED_PIPE_MAX_MMU 8
35 #define LIMA_SCHED_PIPE_MAX_L2_CACHE 2
36 #define LIMA_SCHED_PIPE_MAX_PROCESSOR 8
40 struct lima_sched_pipe {
41 struct drm_gpu_scheduler base;
45 spinlock_t fence_lock;
47 struct lima_sched_task *current_task;
48 struct lima_vm *current_vm;
50 struct lima_ip *mmu[LIMA_SCHED_PIPE_MAX_MMU];
53 struct lima_ip *l2_cache[LIMA_SCHED_PIPE_MAX_L2_CACHE];
56 struct lima_ip *processor[LIMA_SCHED_PIPE_MAX_PROCESSOR];
59 struct lima_ip *bcast_processor;
60 struct lima_ip *bcast_mmu;
67 struct kmem_cache *task_slab;
69 int (*task_validate)(struct lima_sched_pipe *pipe, struct lima_sched_task *task);
70 void (*task_run)(struct lima_sched_pipe *pipe, struct lima_sched_task *task);
71 void (*task_fini)(struct lima_sched_pipe *pipe);
72 void (*task_error)(struct lima_sched_pipe *pipe);
73 void (*task_mmu_error)(struct lima_sched_pipe *pipe);
74 int (*task_recover)(struct lima_sched_pipe *pipe);
76 struct work_struct recover_work;
79 int lima_sched_task_init(struct lima_sched_task *task,
80 struct lima_sched_context *context,
81 struct lima_bo **bos, int num_bos,
83 void lima_sched_task_fini(struct lima_sched_task *task);
85 int lima_sched_context_init(struct lima_sched_pipe *pipe,
86 struct lima_sched_context *context,
88 void lima_sched_context_fini(struct lima_sched_pipe *pipe,
89 struct lima_sched_context *context);
90 struct dma_fence *lima_sched_context_queue_task(struct lima_sched_context *context,
91 struct lima_sched_task *task);
93 int lima_sched_pipe_init(struct lima_sched_pipe *pipe, const char *name);
94 void lima_sched_pipe_fini(struct lima_sched_pipe *pipe);
95 void lima_sched_pipe_task_done(struct lima_sched_pipe *pipe);
97 static inline void lima_sched_pipe_mmu_error(struct lima_sched_pipe *pipe)
100 pipe->task_mmu_error(pipe);
103 int lima_sched_slab_init(void);
104 void lima_sched_slab_fini(void);