intel_guc_submission.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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_SUBMISSION_H_
  25. #define _INTEL_GUC_SUBMISSION_H_
  26. #include <linux/spinlock.h>
  27. #include "i915_gem.h"
  28. #include "i915_selftest.h"
  29. struct drm_i915_private;
  30. /*
  31. * This structure primarily describes the GEM object shared with the GuC.
  32. * The specs sometimes refer to this object as a "GuC context", but we use
  33. * the term "client" to avoid confusion with hardware contexts. This
  34. * GEM object is held for the entire lifetime of our interaction with
  35. * the GuC, being allocated before the GuC is loaded with its firmware.
  36. * Because there's no way to update the address used by the GuC after
  37. * initialisation, the shared object must stay pinned into the GGTT as
  38. * long as the GuC is in use. We also keep the first page (only) mapped
  39. * into kernel address space, as it includes shared data that must be
  40. * updated on every request submission.
  41. *
  42. * The single GEM object described here is actually made up of several
  43. * separate areas, as far as the GuC is concerned. The first page (kept
  44. * kmap'd) includes the "process descriptor" which holds sequence data for
  45. * the doorbell, and one cacheline which actually *is* the doorbell; a
  46. * write to this will "ring the doorbell" (i.e. send an interrupt to the
  47. * GuC). The subsequent pages of the client object constitute the work
  48. * queue (a circular array of work items), again described in the process
  49. * descriptor. Work queue pages are mapped momentarily as required.
  50. */
  51. struct intel_guc_client {
  52. struct i915_vma *vma;
  53. void *vaddr;
  54. struct i915_gem_context *owner;
  55. struct intel_guc *guc;
  56. /* bitmap of (host) engine ids */
  57. u32 engines;
  58. u32 priority;
  59. u32 stage_id;
  60. u32 proc_desc_offset;
  61. u16 doorbell_id;
  62. unsigned long doorbell_offset;
  63. /* Protects GuC client's WQ access */
  64. spinlock_t wq_lock;
  65. /* Per-engine counts of GuC submissions */
  66. u64 submissions[I915_NUM_ENGINES];
  67. /* For testing purposes, use nop WQ items instead of real ones */
  68. I915_SELFTEST_DECLARE(bool use_nop_wqi);
  69. };
  70. int intel_guc_submission_init(struct intel_guc *guc);
  71. int intel_guc_submission_enable(struct intel_guc *guc);
  72. void intel_guc_submission_disable(struct intel_guc *guc);
  73. void intel_guc_submission_fini(struct intel_guc *guc);
  74. int intel_guc_preempt_work_create(struct intel_guc *guc);
  75. void intel_guc_preempt_work_destroy(struct intel_guc *guc);
  76. #endif