intel_guc.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Copyright © 2014-2017 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_uncore.h"
  27. #include "intel_guc_fw.h"
  28. #include "intel_guc_fwif.h"
  29. #include "intel_guc_ct.h"
  30. #include "intel_guc_log.h"
  31. #include "intel_guc_reg.h"
  32. #include "intel_uc_fw.h"
  33. #include "i915_vma.h"
  34. struct guc_preempt_work {
  35. struct work_struct work;
  36. struct intel_engine_cs *engine;
  37. };
  38. /*
  39. * Top level structure of GuC. It handles firmware loading and manages client
  40. * pool and doorbells. intel_guc owns a intel_guc_client to replace the legacy
  41. * ExecList submission.
  42. */
  43. struct intel_guc {
  44. struct intel_uc_fw fw;
  45. struct intel_guc_log log;
  46. struct intel_guc_ct ct;
  47. /* Log snapshot if GuC errors during load */
  48. struct drm_i915_gem_object *load_err_log;
  49. /* intel_guc_recv interrupt related state */
  50. bool interrupts_enabled;
  51. struct i915_vma *ads_vma;
  52. struct i915_vma *stage_desc_pool;
  53. void *stage_desc_pool_vaddr;
  54. struct ida stage_ids;
  55. struct i915_vma *shared_data;
  56. void *shared_data_vaddr;
  57. struct intel_guc_client *execbuf_client;
  58. struct intel_guc_client *preempt_client;
  59. struct guc_preempt_work preempt_work[I915_NUM_ENGINES];
  60. struct workqueue_struct *preempt_wq;
  61. DECLARE_BITMAP(doorbell_bitmap, GUC_NUM_DOORBELLS);
  62. /* Cyclic counter mod pagesize */
  63. u32 db_cacheline;
  64. /* GuC's FW specific registers used in MMIO send */
  65. struct {
  66. u32 base;
  67. unsigned int count;
  68. enum forcewake_domains fw_domains;
  69. } send_regs;
  70. /* To serialize the intel_guc_send actions */
  71. struct mutex send_mutex;
  72. /* GuC's FW specific send function */
  73. int (*send)(struct intel_guc *guc, const u32 *data, u32 len);
  74. /* GuC's FW specific notify function */
  75. void (*notify)(struct intel_guc *guc);
  76. };
  77. static
  78. inline int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len)
  79. {
  80. return guc->send(guc, action, len);
  81. }
  82. static inline void intel_guc_notify(struct intel_guc *guc)
  83. {
  84. guc->notify(guc);
  85. }
  86. /*
  87. * GuC does not allow any gfx GGTT address that falls into range [0, WOPCM_TOP),
  88. * which is reserved for Boot ROM, SRAM and WOPCM. Currently this top address is
  89. * 512K. In order to exclude 0-512K address space from GGTT, all gfx objects
  90. * used by GuC is pinned with PIN_OFFSET_BIAS along with size of WOPCM.
  91. */
  92. static inline u32 guc_ggtt_offset(struct i915_vma *vma)
  93. {
  94. u32 offset = i915_ggtt_offset(vma);
  95. GEM_BUG_ON(offset < GUC_WOPCM_TOP);
  96. GEM_BUG_ON(range_overflows_t(u64, offset, vma->size, GUC_GGTT_TOP));
  97. return offset;
  98. }
  99. void intel_guc_init_early(struct intel_guc *guc);
  100. void intel_guc_init_send_regs(struct intel_guc *guc);
  101. void intel_guc_init_params(struct intel_guc *guc);
  102. int intel_guc_init_wq(struct intel_guc *guc);
  103. void intel_guc_fini_wq(struct intel_guc *guc);
  104. int intel_guc_init(struct intel_guc *guc);
  105. void intel_guc_fini(struct intel_guc *guc);
  106. int intel_guc_send_nop(struct intel_guc *guc, const u32 *action, u32 len);
  107. int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len);
  108. int intel_guc_sample_forcewake(struct intel_guc *guc);
  109. int intel_guc_auth_huc(struct intel_guc *guc, u32 rsa_offset);
  110. int intel_guc_suspend(struct drm_i915_private *dev_priv);
  111. int intel_guc_resume(struct drm_i915_private *dev_priv);
  112. struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size);
  113. u32 intel_guc_wopcm_size(struct drm_i915_private *dev_priv);
  114. #endif