intel_guc.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 i915_guc_client {
  29. struct drm_i915_gem_object *client_obj;
  30. struct intel_context *owner;
  31. struct intel_guc *guc;
  32. uint32_t priority;
  33. uint32_t ctx_index;
  34. uint32_t proc_desc_offset;
  35. uint32_t doorbell_offset;
  36. uint32_t cookie;
  37. uint16_t doorbell_id;
  38. uint16_t padding; /* Maintain alignment */
  39. uint32_t wq_offset;
  40. uint32_t wq_size;
  41. spinlock_t wq_lock; /* Protects all data below */
  42. uint32_t wq_tail;
  43. /* GuC submission statistics & status */
  44. uint64_t submissions[I915_NUM_RINGS];
  45. uint32_t q_fail;
  46. uint32_t b_fail;
  47. int retcode;
  48. };
  49. enum intel_guc_fw_status {
  50. GUC_FIRMWARE_FAIL = -1,
  51. GUC_FIRMWARE_NONE = 0,
  52. GUC_FIRMWARE_PENDING,
  53. GUC_FIRMWARE_SUCCESS
  54. };
  55. /*
  56. * This structure encapsulates all the data needed during the process
  57. * of fetching, caching, and loading the firmware image into the GuC.
  58. */
  59. struct intel_guc_fw {
  60. struct drm_device * guc_dev;
  61. const char * guc_fw_path;
  62. size_t guc_fw_size;
  63. struct drm_i915_gem_object * guc_fw_obj;
  64. enum intel_guc_fw_status guc_fw_fetch_status;
  65. enum intel_guc_fw_status guc_fw_load_status;
  66. uint16_t guc_fw_major_wanted;
  67. uint16_t guc_fw_minor_wanted;
  68. uint16_t guc_fw_major_found;
  69. uint16_t guc_fw_minor_found;
  70. };
  71. struct intel_guc {
  72. struct intel_guc_fw guc_fw;
  73. uint32_t log_flags;
  74. struct drm_i915_gem_object *log_obj;
  75. struct drm_i915_gem_object *ctx_pool_obj;
  76. struct ida ctx_ids;
  77. struct i915_guc_client *execbuf_client;
  78. spinlock_t host2guc_lock; /* Protects all data below */
  79. DECLARE_BITMAP(doorbell_bitmap, GUC_MAX_DOORBELLS);
  80. uint32_t db_cacheline; /* Cyclic counter mod pagesize */
  81. /* Action status & statistics */
  82. uint64_t action_count; /* Total commands issued */
  83. uint32_t action_cmd; /* Last command word */
  84. uint32_t action_status; /* Last return status */
  85. uint32_t action_fail; /* Total number of failures */
  86. int32_t action_err; /* Last error code */
  87. uint64_t submissions[I915_NUM_RINGS];
  88. uint32_t last_seqno[I915_NUM_RINGS];
  89. };
  90. /* intel_guc_loader.c */
  91. extern void intel_guc_ucode_init(struct drm_device *dev);
  92. extern int intel_guc_ucode_load(struct drm_device *dev);
  93. extern void intel_guc_ucode_fini(struct drm_device *dev);
  94. extern const char *intel_guc_fw_status_repr(enum intel_guc_fw_status status);
  95. extern int intel_guc_suspend(struct drm_device *dev);
  96. extern int intel_guc_resume(struct drm_device *dev);
  97. /* i915_guc_submission.c */
  98. int i915_guc_submission_init(struct drm_device *dev);
  99. int i915_guc_submission_enable(struct drm_device *dev);
  100. int i915_guc_submit(struct i915_guc_client *client,
  101. struct drm_i915_gem_request *rq);
  102. void i915_guc_submission_disable(struct drm_device *dev);
  103. void i915_guc_submission_fini(struct drm_device *dev);
  104. #endif