intel_lrc.h 5.0 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
  21. * DEALINGS IN THE SOFTWARE.
  22. */
  23. #ifndef _INTEL_LRC_H_
  24. #define _INTEL_LRC_H_
  25. #define GEN8_LR_CONTEXT_ALIGN 4096
  26. /* Execlists regs */
  27. #define RING_ELSP(ring) _MMIO((ring)->mmio_base + 0x230)
  28. #define RING_EXECLIST_STATUS_LO(ring) _MMIO((ring)->mmio_base + 0x234)
  29. #define RING_EXECLIST_STATUS_HI(ring) _MMIO((ring)->mmio_base + 0x234 + 4)
  30. #define RING_CONTEXT_CONTROL(ring) _MMIO((ring)->mmio_base + 0x244)
  31. #define CTX_CTRL_INHIBIT_SYN_CTX_SWITCH (1 << 3)
  32. #define CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT (1 << 0)
  33. #define CTX_CTRL_RS_CTX_ENABLE (1 << 1)
  34. #define RING_CONTEXT_STATUS_BUF_LO(ring, i) _MMIO((ring)->mmio_base + 0x370 + (i) * 8)
  35. #define RING_CONTEXT_STATUS_BUF_HI(ring, i) _MMIO((ring)->mmio_base + 0x370 + (i) * 8 + 4)
  36. #define RING_CONTEXT_STATUS_PTR(ring) _MMIO((ring)->mmio_base + 0x3a0)
  37. /* The docs specify that the write pointer wraps around after 5h, "After status
  38. * is written out to the last available status QW at offset 5h, this pointer
  39. * wraps to 0."
  40. *
  41. * Therefore, one must infer than even though there are 3 bits available, 6 and
  42. * 7 appear to be * reserved.
  43. */
  44. #define GEN8_CSB_ENTRIES 6
  45. #define GEN8_CSB_PTR_MASK 0x7
  46. #define GEN8_CSB_READ_PTR_MASK (GEN8_CSB_PTR_MASK << 8)
  47. #define GEN8_CSB_WRITE_PTR_MASK (GEN8_CSB_PTR_MASK << 0)
  48. #define GEN8_CSB_WRITE_PTR(csb_status) \
  49. (((csb_status) & GEN8_CSB_WRITE_PTR_MASK) >> 0)
  50. #define GEN8_CSB_READ_PTR(csb_status) \
  51. (((csb_status) & GEN8_CSB_READ_PTR_MASK) >> 8)
  52. /* Logical Rings */
  53. int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request *request);
  54. int intel_logical_ring_reserve_space(struct drm_i915_gem_request *request);
  55. void intel_logical_ring_stop(struct intel_engine_cs *ring);
  56. void intel_logical_ring_cleanup(struct intel_engine_cs *ring);
  57. int intel_logical_rings_init(struct drm_device *dev);
  58. int intel_logical_ring_begin(struct drm_i915_gem_request *req, int num_dwords);
  59. int logical_ring_flush_all_caches(struct drm_i915_gem_request *req);
  60. /**
  61. * intel_logical_ring_advance() - advance the ringbuffer tail
  62. * @ringbuf: Ringbuffer to advance.
  63. *
  64. * The tail is only updated in our logical ringbuffer struct.
  65. */
  66. static inline void intel_logical_ring_advance(struct intel_ringbuffer *ringbuf)
  67. {
  68. ringbuf->tail &= ringbuf->size - 1;
  69. }
  70. /**
  71. * intel_logical_ring_emit() - write a DWORD to the ringbuffer.
  72. * @ringbuf: Ringbuffer to write to.
  73. * @data: DWORD to write.
  74. */
  75. static inline void intel_logical_ring_emit(struct intel_ringbuffer *ringbuf,
  76. u32 data)
  77. {
  78. iowrite32(data, ringbuf->virtual_start + ringbuf->tail);
  79. ringbuf->tail += 4;
  80. }
  81. static inline void intel_logical_ring_emit_reg(struct intel_ringbuffer *ringbuf,
  82. i915_reg_t reg)
  83. {
  84. intel_logical_ring_emit(ringbuf, i915_mmio_reg_offset(reg));
  85. }
  86. /* Logical Ring Contexts */
  87. /* One extra page is added before LRC for GuC as shared data */
  88. #define LRC_GUCSHR_PN (0)
  89. #define LRC_PPHWSP_PN (LRC_GUCSHR_PN + 1)
  90. #define LRC_STATE_PN (LRC_PPHWSP_PN + 1)
  91. void intel_lr_context_free(struct intel_context *ctx);
  92. uint32_t intel_lr_context_size(struct intel_engine_cs *ring);
  93. int intel_lr_context_deferred_alloc(struct intel_context *ctx,
  94. struct intel_engine_cs *ring);
  95. void intel_lr_context_unpin(struct intel_context *ctx,
  96. struct intel_engine_cs *engine);
  97. void intel_lr_context_reset(struct drm_device *dev,
  98. struct intel_context *ctx);
  99. uint64_t intel_lr_context_descriptor(struct intel_context *ctx,
  100. struct intel_engine_cs *ring);
  101. u32 intel_execlists_ctx_id(struct intel_context *ctx,
  102. struct intel_engine_cs *ring);
  103. /* Execlists */
  104. int intel_sanitize_enable_execlists(struct drm_device *dev, int enable_execlists);
  105. struct i915_execbuffer_params;
  106. int intel_execlists_submission(struct i915_execbuffer_params *params,
  107. struct drm_i915_gem_execbuffer2 *args,
  108. struct list_head *vmas);
  109. void intel_lrc_irq_handler(struct intel_engine_cs *ring);
  110. void intel_execlists_retire_requests(struct intel_engine_cs *ring);
  111. #endif /* _INTEL_LRC_H_ */