1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
2 /* Copyright 2017-2019 Qiang Yu <yuq825@gmail.com> */
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;
17 struct dma_fence **dep;
25 struct dma_fence *fence;
28 struct lima_sched_context {
29 struct drm_sched_entity base;
32 #define LIMA_SCHED_PIPE_MAX_MMU 8
33 #define LIMA_SCHED_PIPE_MAX_L2_CACHE 2
34 #define LIMA_SCHED_PIPE_MAX_PROCESSOR 8
38 struct lima_sched_pipe {
39 struct drm_gpu_scheduler base;
43 spinlock_t fence_lock;
45 struct lima_sched_task *current_task;
46 struct lima_vm *current_vm;
48 struct lima_ip *mmu[LIMA_SCHED_PIPE_MAX_MMU];
51 struct lima_ip *l2_cache[LIMA_SCHED_PIPE_MAX_L2_CACHE];
54 struct lima_ip *processor[LIMA_SCHED_PIPE_MAX_PROCESSOR];
57 struct lima_ip *bcast_processor;
58 struct lima_ip *bcast_mmu;
65 struct kmem_cache *task_slab;
67 int (*task_validate)(struct lima_sched_pipe *pipe, struct lima_sched_task *task);
68 void (*task_run)(struct lima_sched_pipe *pipe, struct lima_sched_task *task);
69 void (*task_fini)(struct lima_sched_pipe *pipe);
70 void (*task_error)(struct lima_sched_pipe *pipe);
71 void (*task_mmu_error)(struct lima_sched_pipe *pipe);
73 struct work_struct error_work;
76 int lima_sched_task_init(struct lima_sched_task *task,
77 struct lima_sched_context *context,
78 struct lima_bo **bos, int num_bos,
80 void lima_sched_task_fini(struct lima_sched_task *task);
81 int lima_sched_task_add_dep(struct lima_sched_task *task, struct dma_fence *fence);
83 int lima_sched_context_init(struct lima_sched_pipe *pipe,
84 struct lima_sched_context *context,
86 void lima_sched_context_fini(struct lima_sched_pipe *pipe,
87 struct lima_sched_context *context);
88 struct dma_fence *lima_sched_context_queue_task(struct lima_sched_context *context,
89 struct lima_sched_task *task);
91 int lima_sched_pipe_init(struct lima_sched_pipe *pipe, const char *name);
92 void lima_sched_pipe_fini(struct lima_sched_pipe *pipe);
93 void lima_sched_pipe_task_done(struct lima_sched_pipe *pipe);
95 static inline void lima_sched_pipe_mmu_error(struct lima_sched_pipe *pipe)
98 pipe->task_mmu_error(pipe);
101 int lima_sched_slab_init(void);
102 void lima_sched_slab_fini(void);