intel_guc.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. struct drm_i915_gem_request;
  29. /*
  30. * This structure primarily describes the GEM object shared with the GuC.
  31. * The GEM object is held for the entire lifetime of our interaction with
  32. * the GuC, being allocated before the GuC is loaded with its firmware.
  33. * Because there's no way to update the address used by the GuC after
  34. * initialisation, the shared object must stay pinned into the GGTT as
  35. * long as the GuC is in use. We also keep the first page (only) mapped
  36. * into kernel address space, as it includes shared data that must be
  37. * updated on every request submission.
  38. *
  39. * The single GEM object described here is actually made up of several
  40. * separate areas, as far as the GuC is concerned. The first page (kept
  41. * kmap'd) includes the "process decriptor" which holds sequence data for
  42. * the doorbell, and one cacheline which actually *is* the doorbell; a
  43. * write to this will "ring the doorbell" (i.e. send an interrupt to the
  44. * GuC). The subsequent pages of the client object constitute the work
  45. * queue (a circular array of work items), again described in the process
  46. * descriptor. Work queue pages are mapped momentarily as required.
  47. *
  48. * We also keep a few statistics on failures. Ideally, these should all
  49. * be zero!
  50. * no_wq_space: times that the submission pre-check found no space was
  51. * available in the work queue (note, the queue is shared,
  52. * not per-engine). It is OK for this to be nonzero, but
  53. * it should not be huge!
  54. * q_fail: failed to enqueue a work item. This should never happen,
  55. * because we check for space beforehand.
  56. * b_fail: failed to ring the doorbell. This should never happen, unless
  57. * somehow the hardware misbehaves, or maybe if the GuC firmware
  58. * crashes? We probably need to reset the GPU to recover.
  59. * retcode: errno from last guc_submit()
  60. */
  61. struct i915_guc_client {
  62. struct drm_i915_gem_object *client_obj;
  63. void *client_base; /* first page (only) of above */
  64. struct i915_gem_context *owner;
  65. struct intel_guc *guc;
  66. uint32_t priority;
  67. uint32_t ctx_index;
  68. uint32_t proc_desc_offset;
  69. uint32_t doorbell_offset;
  70. uint32_t cookie;
  71. uint16_t doorbell_id;
  72. uint16_t padding; /* Maintain alignment */
  73. uint32_t wq_offset;
  74. uint32_t wq_size;
  75. uint32_t wq_tail;
  76. uint32_t unused; /* Was 'wq_head' */
  77. uint32_t no_wq_space;
  78. uint32_t q_fail; /* No longer used */
  79. uint32_t b_fail;
  80. int retcode;
  81. /* Per-engine counts of GuC submissions */
  82. uint64_t submissions[GUC_MAX_ENGINES_NUM];
  83. };
  84. enum intel_guc_fw_status {
  85. GUC_FIRMWARE_FAIL = -1,
  86. GUC_FIRMWARE_NONE = 0,
  87. GUC_FIRMWARE_PENDING,
  88. GUC_FIRMWARE_SUCCESS
  89. };
  90. /*
  91. * This structure encapsulates all the data needed during the process
  92. * of fetching, caching, and loading the firmware image into the GuC.
  93. */
  94. struct intel_guc_fw {
  95. struct drm_device * guc_dev;
  96. const char * guc_fw_path;
  97. size_t guc_fw_size;
  98. struct drm_i915_gem_object * guc_fw_obj;
  99. enum intel_guc_fw_status guc_fw_fetch_status;
  100. enum intel_guc_fw_status guc_fw_load_status;
  101. uint16_t guc_fw_major_wanted;
  102. uint16_t guc_fw_minor_wanted;
  103. uint16_t guc_fw_major_found;
  104. uint16_t guc_fw_minor_found;
  105. uint32_t header_size;
  106. uint32_t header_offset;
  107. uint32_t rsa_size;
  108. uint32_t rsa_offset;
  109. uint32_t ucode_size;
  110. uint32_t ucode_offset;
  111. };
  112. struct intel_guc {
  113. struct intel_guc_fw guc_fw;
  114. uint32_t log_flags;
  115. struct drm_i915_gem_object *log_obj;
  116. struct drm_i915_gem_object *ads_obj;
  117. struct drm_i915_gem_object *ctx_pool_obj;
  118. struct ida ctx_ids;
  119. struct i915_guc_client *execbuf_client;
  120. DECLARE_BITMAP(doorbell_bitmap, GUC_MAX_DOORBELLS);
  121. uint32_t db_cacheline; /* Cyclic counter mod pagesize */
  122. /* Action status & statistics */
  123. uint64_t action_count; /* Total commands issued */
  124. uint32_t action_cmd; /* Last command word */
  125. uint32_t action_status; /* Last return status */
  126. uint32_t action_fail; /* Total number of failures */
  127. int32_t action_err; /* Last error code */
  128. uint64_t submissions[GUC_MAX_ENGINES_NUM];
  129. uint32_t last_seqno[GUC_MAX_ENGINES_NUM];
  130. };
  131. /* intel_guc_loader.c */
  132. extern void intel_guc_init(struct drm_device *dev);
  133. extern int intel_guc_setup(struct drm_device *dev);
  134. extern void intel_guc_fini(struct drm_device *dev);
  135. extern const char *intel_guc_fw_status_repr(enum intel_guc_fw_status status);
  136. extern int intel_guc_suspend(struct drm_device *dev);
  137. extern int intel_guc_resume(struct drm_device *dev);
  138. /* i915_guc_submission.c */
  139. int i915_guc_submission_init(struct drm_device *dev);
  140. int i915_guc_submission_enable(struct drm_device *dev);
  141. int i915_guc_wq_check_space(struct drm_i915_gem_request *rq);
  142. int i915_guc_submit(struct drm_i915_gem_request *rq);
  143. void i915_guc_submission_disable(struct drm_device *dev);
  144. void i915_guc_submission_fini(struct drm_device *dev);
  145. #endif