amdgpu_job.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright 2018 Advanced Micro Devices, Inc.
  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 shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. */
  23. #ifndef __AMDGPU_JOB_H__
  24. #define __AMDGPU_JOB_H__
  25. /* bit set means command submit involves a preamble IB */
  26. #define AMDGPU_PREAMBLE_IB_PRESENT (1 << 0)
  27. /* bit set means preamble IB is first presented in belonging context */
  28. #define AMDGPU_PREAMBLE_IB_PRESENT_FIRST (1 << 1)
  29. /* bit set means context switch occured */
  30. #define AMDGPU_HAVE_CTX_SWITCH (1 << 2)
  31. #define to_amdgpu_job(sched_job) \
  32. container_of((sched_job), struct amdgpu_job, base)
  33. struct amdgpu_fence;
  34. struct amdgpu_job {
  35. struct drm_sched_job base;
  36. struct amdgpu_vm *vm;
  37. struct amdgpu_sync sync;
  38. struct amdgpu_sync sched_sync;
  39. struct amdgpu_ib *ibs;
  40. struct dma_fence *fence; /* the hw fence */
  41. uint32_t preamble_status;
  42. uint32_t num_ibs;
  43. void *owner;
  44. bool vm_needs_flush;
  45. uint64_t vm_pd_addr;
  46. unsigned vmid;
  47. unsigned pasid;
  48. uint32_t gds_base, gds_size;
  49. uint32_t gws_base, gws_size;
  50. uint32_t oa_base, oa_size;
  51. uint32_t vram_lost_counter;
  52. /* user fence handling */
  53. uint64_t uf_addr;
  54. uint64_t uf_sequence;
  55. };
  56. int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs,
  57. struct amdgpu_job **job, struct amdgpu_vm *vm);
  58. int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev, unsigned size,
  59. struct amdgpu_job **job);
  60. void amdgpu_job_free_resources(struct amdgpu_job *job);
  61. void amdgpu_job_free(struct amdgpu_job *job);
  62. int amdgpu_job_submit(struct amdgpu_job *job, struct drm_sched_entity *entity,
  63. void *owner, struct dma_fence **f);
  64. int amdgpu_job_submit_direct(struct amdgpu_job *job, struct amdgpu_ring *ring,
  65. struct dma_fence **fence);
  66. #endif