lima_sched.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* SPDX-License-Identifier: GPL-2.0 OR MIT */
  2. /* Copyright 2017-2019 Qiang Yu <yuq825@gmail.com> */
  3. #ifndef __LIMA_SCHED_H__
  4. #define __LIMA_SCHED_H__
  5. #include <drm/gpu_scheduler.h>
  6. #include <linux/list.h>
  7. #include <linux/xarray.h>
  8. struct lima_device;
  9. struct lima_vm;
  10. struct lima_sched_error_task {
  11. struct list_head list;
  12. void *data;
  13. u32 size;
  14. };
  15. struct lima_sched_task {
  16. struct drm_sched_job base;
  17. struct lima_vm *vm;
  18. void *frame;
  19. struct xarray deps;
  20. unsigned long last_dep;
  21. struct lima_bo **bos;
  22. int num_bos;
  23. bool recoverable;
  24. struct lima_bo *heap;
  25. /* pipe fence */
  26. struct dma_fence *fence;
  27. };
  28. struct lima_sched_context {
  29. struct drm_sched_entity base;
  30. };
  31. #define LIMA_SCHED_PIPE_MAX_MMU 8
  32. #define LIMA_SCHED_PIPE_MAX_L2_CACHE 2
  33. #define LIMA_SCHED_PIPE_MAX_PROCESSOR 8
  34. struct lima_ip;
  35. struct lima_sched_pipe {
  36. struct drm_gpu_scheduler base;
  37. u64 fence_context;
  38. u32 fence_seqno;
  39. spinlock_t fence_lock;
  40. struct lima_device *ldev;
  41. struct lima_sched_task *current_task;
  42. struct lima_vm *current_vm;
  43. struct lima_ip *mmu[LIMA_SCHED_PIPE_MAX_MMU];
  44. int num_mmu;
  45. struct lima_ip *l2_cache[LIMA_SCHED_PIPE_MAX_L2_CACHE];
  46. int num_l2_cache;
  47. struct lima_ip *processor[LIMA_SCHED_PIPE_MAX_PROCESSOR];
  48. int num_processor;
  49. struct lima_ip *bcast_processor;
  50. struct lima_ip *bcast_mmu;
  51. u32 done;
  52. bool error;
  53. atomic_t task;
  54. int frame_size;
  55. struct kmem_cache *task_slab;
  56. int (*task_validate)(struct lima_sched_pipe *pipe, struct lima_sched_task *task);
  57. void (*task_run)(struct lima_sched_pipe *pipe, struct lima_sched_task *task);
  58. void (*task_fini)(struct lima_sched_pipe *pipe);
  59. void (*task_error)(struct lima_sched_pipe *pipe);
  60. void (*task_mmu_error)(struct lima_sched_pipe *pipe);
  61. int (*task_recover)(struct lima_sched_pipe *pipe);
  62. struct work_struct recover_work;
  63. };
  64. int lima_sched_task_init(struct lima_sched_task *task,
  65. struct lima_sched_context *context,
  66. struct lima_bo **bos, int num_bos,
  67. struct lima_vm *vm);
  68. void lima_sched_task_fini(struct lima_sched_task *task);
  69. int lima_sched_context_init(struct lima_sched_pipe *pipe,
  70. struct lima_sched_context *context,
  71. atomic_t *guilty);
  72. void lima_sched_context_fini(struct lima_sched_pipe *pipe,
  73. struct lima_sched_context *context);
  74. struct dma_fence *lima_sched_context_queue_task(struct lima_sched_context *context,
  75. struct lima_sched_task *task);
  76. int lima_sched_pipe_init(struct lima_sched_pipe *pipe, const char *name);
  77. void lima_sched_pipe_fini(struct lima_sched_pipe *pipe);
  78. void lima_sched_pipe_task_done(struct lima_sched_pipe *pipe);
  79. static inline void lima_sched_pipe_mmu_error(struct lima_sched_pipe *pipe)
  80. {
  81. pipe->error = true;
  82. pipe->task_mmu_error(pipe);
  83. }
  84. int lima_sched_slab_init(void);
  85. void lima_sched_slab_fini(void);
  86. #endif