1b88baab8SDanilo Krummrich /* SPDX-License-Identifier: MIT */ 2b88baab8SDanilo Krummrich 3b88baab8SDanilo Krummrich #ifndef __NOUVEAU_EXEC_H__ 4b88baab8SDanilo Krummrich #define __NOUVEAU_EXEC_H__ 5b88baab8SDanilo Krummrich 6b88baab8SDanilo Krummrich #include "nouveau_drv.h" 7b88baab8SDanilo Krummrich #include "nouveau_sched.h" 8b88baab8SDanilo Krummrich 9b88baab8SDanilo Krummrich struct nouveau_exec_job_args { 10b88baab8SDanilo Krummrich struct drm_file *file_priv; 11*5f03a507SDanilo Krummrich struct nouveau_sched *sched; 12b88baab8SDanilo Krummrich struct nouveau_channel *chan; 13b88baab8SDanilo Krummrich 14b88baab8SDanilo Krummrich struct { 15b88baab8SDanilo Krummrich struct drm_nouveau_sync *s; 16b88baab8SDanilo Krummrich u32 count; 17b88baab8SDanilo Krummrich } in_sync; 18b88baab8SDanilo Krummrich 19b88baab8SDanilo Krummrich struct { 20b88baab8SDanilo Krummrich struct drm_nouveau_sync *s; 21b88baab8SDanilo Krummrich u32 count; 22b88baab8SDanilo Krummrich } out_sync; 23b88baab8SDanilo Krummrich 24b88baab8SDanilo Krummrich struct { 25b88baab8SDanilo Krummrich struct drm_nouveau_exec_push *s; 26b88baab8SDanilo Krummrich u32 count; 27b88baab8SDanilo Krummrich } push; 28b88baab8SDanilo Krummrich }; 29b88baab8SDanilo Krummrich 30b88baab8SDanilo Krummrich struct nouveau_exec_job { 31b88baab8SDanilo Krummrich struct nouveau_job base; 32b88baab8SDanilo Krummrich struct nouveau_fence *fence; 33b88baab8SDanilo Krummrich struct nouveau_channel *chan; 34b88baab8SDanilo Krummrich 35b88baab8SDanilo Krummrich struct { 36b88baab8SDanilo Krummrich struct drm_nouveau_exec_push *s; 37b88baab8SDanilo Krummrich u32 count; 38b88baab8SDanilo Krummrich } push; 39b88baab8SDanilo Krummrich }; 40b88baab8SDanilo Krummrich 41b88baab8SDanilo Krummrich #define to_nouveau_exec_job(job) \ 42b88baab8SDanilo Krummrich container_of((job), struct nouveau_exec_job, base) 43b88baab8SDanilo Krummrich 44b88baab8SDanilo Krummrich int nouveau_exec_job_init(struct nouveau_exec_job **job, 45b88baab8SDanilo Krummrich struct nouveau_exec_job_args *args); 46b88baab8SDanilo Krummrich 47e39701e3SDanilo Krummrich int nouveau_exec_ioctl_exec(struct drm_device *dev, void *data, 48b88baab8SDanilo Krummrich struct drm_file *file_priv); 49b88baab8SDanilo Krummrich 50d59e75eeSDanilo Krummrich static inline unsigned int nouveau_exec_push_max_from_ib_max(int ib_max)51d59e75eeSDanilo Krummrichnouveau_exec_push_max_from_ib_max(int ib_max) 52d59e75eeSDanilo Krummrich { 53d59e75eeSDanilo Krummrich /* Limit the number of IBs per job to half the size of the ring in order 54d59e75eeSDanilo Krummrich * to avoid the ring running dry between submissions and preserve one 55d59e75eeSDanilo Krummrich * more slot for the job's HW fence. 56d59e75eeSDanilo Krummrich */ 57d59e75eeSDanilo Krummrich return ib_max > 1 ? ib_max / 2 - 1 : 0; 58d59e75eeSDanilo Krummrich } 59d59e75eeSDanilo Krummrich 60b88baab8SDanilo Krummrich #endif 61