intel_guc.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * Copyright © 2014 Intel Corporation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. * IN THE SOFTWARE.
  22. *
  23. */
  24. #ifndef _INTEL_GUC_H_
  25. #define _INTEL_GUC_H_
  26. #include "intel_guc_fwif.h"
  27. #include "i915_guc_reg.h"
  28. #include "intel_ringbuffer.h"
  29. struct drm_i915_gem_request;
  30. /*
  31. * This structure primarily describes the GEM object shared with the GuC.
  32. * The GEM object is held for the entire lifetime of our interaction with
  33. * the GuC, being allocated before the GuC is loaded with its firmware.
  34. * Because there's no way to update the address used by the GuC after
  35. * initialisation, the shared object must stay pinned into the GGTT as
  36. * long as the GuC is in use. We also keep the first page (only) mapped
  37. * into kernel address space, as it includes shared data that must be
  38. * updated on every request submission.
  39. *
  40. * The single GEM object described here is actually made up of several
  41. * separate areas, as far as the GuC is concerned. The first page (kept
  42. * kmap'd) includes the "process decriptor" which holds sequence data for
  43. * the doorbell, and one cacheline which actually *is* the doorbell; a
  44. * write to this will "ring the doorbell" (i.e. send an interrupt to the
  45. * GuC). The subsequent pages of the client object constitute the work
  46. * queue (a circular array of work items), again described in the process
  47. * descriptor. Work queue pages are mapped momentarily as required.
  48. *
  49. * We also keep a few statistics on failures. Ideally, these should all
  50. * be zero!
  51. * no_wq_space: times that the submission pre-check found no space was
  52. * available in the work queue (note, the queue is shared,
  53. * not per-engine). It is OK for this to be nonzero, but
  54. * it should not be huge!
  55. * q_fail: failed to enqueue a work item. This should never happen,
  56. * because we check for space beforehand.
  57. * b_fail: failed to ring the doorbell. This should never happen, unless
  58. * somehow the hardware misbehaves, or maybe if the GuC firmware
  59. * crashes? We probably need to reset the GPU to recover.
  60. * retcode: errno from last guc_submit()
  61. */
  62. struct i915_guc_client {
  63. struct i915_vma *vma;
  64. void *client_base; /* first page (only) of above */
  65. struct i915_gem_context *owner;
  66. struct intel_guc *guc;
  67. uint32_t engines; /* bitmap of (host) engine ids */
  68. uint32_t priority;
  69. uint32_t ctx_index;
  70. uint32_t proc_desc_offset;
  71. uint32_t doorbell_offset;
  72. uint32_t cookie;
  73. uint16_t doorbell_id;
  74. uint16_t padding[3]; /* Maintain alignment */
  75. spinlock_t wq_lock;
  76. uint32_t wq_offset;
  77. uint32_t wq_size;
  78. uint32_t wq_tail;
  79. uint32_t wq_rsvd;
  80. uint32_t no_wq_space;
  81. uint32_t b_fail;
  82. int retcode;
  83. /* Per-engine counts of GuC submissions */
  84. uint64_t submissions[I915_NUM_ENGINES];
  85. };
  86. enum intel_guc_fw_status {
  87. GUC_FIRMWARE_FAIL = -1,
  88. GUC_FIRMWARE_NONE = 0,
  89. GUC_FIRMWARE_PENDING,
  90. GUC_FIRMWARE_SUCCESS
  91. };
  92. /*
  93. * This structure encapsulates all the data needed during the process
  94. * of fetching, caching, and loading the firmware image into the GuC.
  95. */
  96. struct intel_guc_fw {
  97. struct drm_device * guc_dev;
  98. const char * guc_fw_path;
  99. size_t guc_fw_size;
  100. struct drm_i915_gem_object * guc_fw_obj;
  101. enum intel_guc_fw_status guc_fw_fetch_status;
  102. enum intel_guc_fw_status guc_fw_load_status;
  103. uint16_t guc_fw_major_wanted;
  104. uint16_t guc_fw_minor_wanted;
  105. uint16_t guc_fw_major_found;
  106. uint16_t guc_fw_minor_found;
  107. uint32_t header_size;
  108. uint32_t header_offset;
  109. uint32_t rsa_size;
  110. uint32_t rsa_offset;
  111. uint32_t ucode_size;
  112. uint32_t ucode_offset;
  113. };
  114. struct intel_guc {
  115. struct intel_guc_fw guc_fw;
  116. uint32_t log_flags;
  117. struct i915_vma *log_vma;
  118. struct i915_vma *ads_vma;
  119. struct i915_vma *ctx_pool_vma;
  120. struct ida ctx_ids;
  121. struct i915_guc_client *execbuf_client;
  122. DECLARE_BITMAP(doorbell_bitmap, GUC_MAX_DOORBELLS);
  123. uint32_t db_cacheline; /* Cyclic counter mod pagesize */
  124. /* Action status & statistics */
  125. uint64_t action_count; /* Total commands issued */
  126. uint32_t action_cmd; /* Last command word */
  127. uint32_t action_status; /* Last return status */
  128. uint32_t action_fail; /* Total number of failures */
  129. int32_t action_err; /* Last error code */
  130. uint64_t submissions[I915_NUM_ENGINES];
  131. uint32_t last_seqno[I915_NUM_ENGINES];
  132. };
  133. /* intel_guc_loader.c */
  134. extern void intel_guc_init(struct drm_device *dev);
  135. extern int intel_guc_setup(struct drm_device *dev);
  136. extern void intel_guc_fini(struct drm_device *dev);
  137. extern const char *intel_guc_fw_status_repr(enum intel_guc_fw_status status);
  138. extern int intel_guc_suspend(struct drm_device *dev);
  139. extern int intel_guc_resume(struct drm_device *dev);
  140. /* i915_guc_submission.c */
  141. int i915_guc_submission_init(struct drm_i915_private *dev_priv);
  142. int i915_guc_submission_enable(struct drm_i915_private *dev_priv);
  143. int i915_guc_wq_reserve(struct drm_i915_gem_request *rq);
  144. void i915_guc_wq_unreserve(struct drm_i915_gem_request *request);
  145. void i915_guc_submission_disable(struct drm_i915_private *dev_priv);
  146. void i915_guc_submission_fini(struct drm_i915_private *dev_priv);
  147. #endif