adreno_dispatch.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2008-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef ____ADRENO_DISPATCHER_H
  6. #define ____ADRENO_DISPATCHER_H
  7. #include <linux/kobject.h>
  8. #include <linux/kthread.h>
  9. #include <linux/llist.h>
  10. extern unsigned int adreno_drawobj_timeout;
  11. /*
  12. * Maximum size of the dispatcher ringbuffer - the actual inflight size will be
  13. * smaller then this but this size will allow for a larger range of inflight
  14. * sizes that can be chosen at runtime
  15. */
  16. #define ADRENO_DISPATCH_DRAWQUEUE_SIZE 128
  17. #define DRAWQUEUE_NEXT(_i, _s) (((_i) + 1) % (_s))
  18. /**
  19. * struct adreno_dispatcher_drawqueue - List of commands for a RB level
  20. * @cmd_q: List of command obj's submitted to dispatcher
  21. * @inflight: Number of commands inflight in this q
  22. * @head: Head pointer to the q
  23. * @tail: Queues tail pointer
  24. * @active_context_count: Number of active contexts seen in this rb drawqueue
  25. * @expires: The jiffies value at which this drawqueue has run too long
  26. */
  27. struct adreno_dispatcher_drawqueue {
  28. struct kgsl_drawobj_cmd *cmd_q[ADRENO_DISPATCH_DRAWQUEUE_SIZE];
  29. unsigned int inflight;
  30. unsigned int head;
  31. unsigned int tail;
  32. int active_context_count;
  33. unsigned long expires;
  34. };
  35. /**
  36. * struct adreno_dispatch_job - An instance of work for the dispatcher
  37. * @node: llist node for the list of jobs
  38. * @drawctxt: A pointer to an adreno draw context
  39. *
  40. * This struct defines work for the dispatcher. When a drawctxt is ready to send
  41. * commands it will attach itself to the appropriate list for it's priority.
  42. * The dispatcher will process all jobs on each priority every time it goes
  43. * through a dispatch cycle
  44. */
  45. struct adreno_dispatch_job {
  46. struct llist_node node;
  47. struct adreno_context *drawctxt;
  48. };
  49. /**
  50. * struct adreno_dispatcher - container for the adreno GPU dispatcher
  51. * @mutex: Mutex to protect the structure
  52. * @state: Current state of the dispatcher (active or paused)
  53. * @timer: Timer to monitor the progress of the drawobjs
  54. * @inflight: Number of drawobj operations pending in the ringbuffer
  55. * @fault: Non-zero if a fault was detected.
  56. * @pending: Priority list of contexts waiting to submit drawobjs
  57. * @work: work_struct to put the dispatcher in a work queue
  58. * @kobj: kobject for the dispatcher directory in the device sysfs node
  59. * @idle_gate: Gate to wait on for dispatcher to idle
  60. */
  61. struct adreno_dispatcher {
  62. struct mutex mutex;
  63. unsigned long priv;
  64. struct timer_list timer;
  65. struct timer_list fault_timer;
  66. unsigned int inflight;
  67. atomic_t fault;
  68. /** @jobs - Array of dispatch job lists for each priority level */
  69. struct llist_head jobs[16];
  70. /** @requeue - Array of lists for dispatch jobs that got requeued */
  71. struct llist_head requeue[16];
  72. struct kthread_work work;
  73. struct kobject kobj;
  74. struct completion idle_gate;
  75. struct kthread_worker *worker;
  76. };
  77. enum adreno_dispatcher_flags {
  78. ADRENO_DISPATCHER_POWER = 0,
  79. ADRENO_DISPATCHER_ACTIVE,
  80. ADRENO_DISPATCHER_INIT,
  81. };
  82. struct adreno_device;
  83. struct kgsl_device;
  84. void adreno_dispatcher_start(struct kgsl_device *device);
  85. int adreno_dispatcher_init(struct adreno_device *adreno_dev);
  86. int adreno_dispatcher_idle(struct adreno_device *adreno_dev);
  87. void adreno_dispatcher_stop(struct adreno_device *adreno_dev);
  88. void adreno_dispatcher_start_fault_timer(struct adreno_device *adreno_dev);
  89. void adreno_dispatcher_stop_fault_timer(struct kgsl_device *device);
  90. void adreno_dispatcher_schedule(struct kgsl_device *device);
  91. /**
  92. * adreno_dispatcher_fault - Set dispatcher fault to request recovery
  93. * @adreno_dev: A handle to adreno device
  94. * @fault: The type of fault
  95. */
  96. void adreno_dispatcher_fault(struct adreno_device *adreno_dev, u32 fault);
  97. #endif /* __ADRENO_DISPATCHER_H */