job.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * Tegra host1x Job
  3. *
  4. * Copyright (c) 2011-2013, NVIDIA Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef __HOST1X_JOB_H
  19. #define __HOST1X_JOB_H
  20. struct host1x_job_gather {
  21. u32 words;
  22. dma_addr_t base;
  23. struct host1x_bo *bo;
  24. int offset;
  25. bool handled;
  26. };
  27. struct host1x_cmdbuf {
  28. u32 handle;
  29. u32 offset;
  30. u32 words;
  31. u32 pad;
  32. };
  33. struct host1x_reloc {
  34. struct host1x_bo *cmdbuf;
  35. u32 cmdbuf_offset;
  36. struct host1x_bo *target;
  37. u32 target_offset;
  38. u32 shift;
  39. u32 pad;
  40. };
  41. struct host1x_waitchk {
  42. struct host1x_bo *bo;
  43. u32 offset;
  44. u32 syncpt_id;
  45. u32 thresh;
  46. };
  47. struct host1x_job_unpin_data {
  48. struct host1x_bo *bo;
  49. struct sg_table *sgt;
  50. };
  51. /*
  52. * Each submit is tracked as a host1x_job.
  53. */
  54. struct host1x_job {
  55. /* When refcount goes to zero, job can be freed */
  56. struct kref ref;
  57. /* List entry */
  58. struct list_head list;
  59. /* Channel where job is submitted to */
  60. struct host1x_channel *channel;
  61. u32 client;
  62. /* Gathers and their memory */
  63. struct host1x_job_gather *gathers;
  64. unsigned int num_gathers;
  65. /* Wait checks to be processed at submit time */
  66. struct host1x_waitchk *waitchk;
  67. unsigned int num_waitchk;
  68. u32 waitchk_mask;
  69. /* Array of handles to be pinned & unpinned */
  70. struct host1x_reloc *relocarray;
  71. unsigned int num_relocs;
  72. struct host1x_job_unpin_data *unpins;
  73. unsigned int num_unpins;
  74. dma_addr_t *addr_phys;
  75. dma_addr_t *gather_addr_phys;
  76. dma_addr_t *reloc_addr_phys;
  77. /* Sync point id, number of increments and end related to the submit */
  78. u32 syncpt_id;
  79. u32 syncpt_incrs;
  80. u32 syncpt_end;
  81. /* Maximum time to wait for this job */
  82. unsigned int timeout;
  83. /* Index and number of slots used in the push buffer */
  84. unsigned int first_get;
  85. unsigned int num_slots;
  86. /* Copy of gathers */
  87. size_t gather_copy_size;
  88. dma_addr_t gather_copy;
  89. u8 *gather_copy_mapped;
  90. /* Check if register is marked as an address reg */
  91. int (*is_addr_reg)(struct device *dev, u32 reg, u32 class);
  92. /* Request a SETCLASS to this class */
  93. u32 class;
  94. /* Add a channel wait for previous ops to complete */
  95. bool serialize;
  96. };
  97. /*
  98. * Allocate memory for a job. Just enough memory will be allocated to
  99. * accomodate the submit.
  100. */
  101. struct host1x_job *host1x_job_alloc(struct host1x_channel *ch,
  102. u32 num_cmdbufs, u32 num_relocs,
  103. u32 num_waitchks);
  104. /*
  105. * Add a gather to a job.
  106. */
  107. void host1x_job_add_gather(struct host1x_job *job, struct host1x_bo *mem_id,
  108. u32 words, u32 offset);
  109. /*
  110. * Increment reference going to host1x_job.
  111. */
  112. struct host1x_job *host1x_job_get(struct host1x_job *job);
  113. /*
  114. * Decrement reference job, free if goes to zero.
  115. */
  116. void host1x_job_put(struct host1x_job *job);
  117. /*
  118. * Pin memory related to job. This handles relocation of addresses to the
  119. * host1x address space. Handles both the gather memory and any other memory
  120. * referred to from the gather buffers.
  121. *
  122. * Handles also patching out host waits that would wait for an expired sync
  123. * point value.
  124. */
  125. int host1x_job_pin(struct host1x_job *job, struct device *dev);
  126. /*
  127. * Unpin memory related to job.
  128. */
  129. void host1x_job_unpin(struct host1x_job *job);
  130. /*
  131. * Dump contents of job to debug output.
  132. */
  133. void host1x_job_dump(struct device *dev, struct host1x_job *job);
  134. #endif