amdgpu_gfx.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright 2014 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_GFX_H__
  24. #define __AMDGPU_GFX_H__
  25. int amdgpu_gfx_scratch_get(struct amdgpu_device *adev, uint32_t *reg);
  26. void amdgpu_gfx_scratch_free(struct amdgpu_device *adev, uint32_t reg);
  27. void amdgpu_gfx_parse_disable_cu(unsigned *mask, unsigned max_se,
  28. unsigned max_sh);
  29. void amdgpu_gfx_compute_queue_acquire(struct amdgpu_device *adev);
  30. int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev,
  31. struct amdgpu_ring *ring,
  32. struct amdgpu_irq_src *irq);
  33. void amdgpu_gfx_kiq_free_ring(struct amdgpu_ring *ring,
  34. struct amdgpu_irq_src *irq);
  35. void amdgpu_gfx_kiq_fini(struct amdgpu_device *adev);
  36. int amdgpu_gfx_kiq_init(struct amdgpu_device *adev,
  37. unsigned hpd_size);
  38. int amdgpu_gfx_compute_mqd_sw_init(struct amdgpu_device *adev,
  39. unsigned mqd_size);
  40. void amdgpu_gfx_compute_mqd_sw_fini(struct amdgpu_device *adev);
  41. /**
  42. * amdgpu_gfx_create_bitmask - create a bitmask
  43. *
  44. * @bit_width: length of the mask
  45. *
  46. * create a variable length bit mask.
  47. * Returns the bitmask.
  48. */
  49. static inline u32 amdgpu_gfx_create_bitmask(u32 bit_width)
  50. {
  51. return (u32)((1ULL << bit_width) - 1);
  52. }
  53. static inline int amdgpu_gfx_queue_to_bit(struct amdgpu_device *adev,
  54. int mec, int pipe, int queue)
  55. {
  56. int bit = 0;
  57. bit += mec * adev->gfx.mec.num_pipe_per_mec
  58. * adev->gfx.mec.num_queue_per_pipe;
  59. bit += pipe * adev->gfx.mec.num_queue_per_pipe;
  60. bit += queue;
  61. return bit;
  62. }
  63. static inline void amdgpu_gfx_bit_to_queue(struct amdgpu_device *adev, int bit,
  64. int *mec, int *pipe, int *queue)
  65. {
  66. *queue = bit % adev->gfx.mec.num_queue_per_pipe;
  67. *pipe = (bit / adev->gfx.mec.num_queue_per_pipe)
  68. % adev->gfx.mec.num_pipe_per_mec;
  69. *mec = (bit / adev->gfx.mec.num_queue_per_pipe)
  70. / adev->gfx.mec.num_pipe_per_mec;
  71. }
  72. static inline bool amdgpu_gfx_is_mec_queue_enabled(struct amdgpu_device *adev,
  73. int mec, int pipe, int queue)
  74. {
  75. return test_bit(amdgpu_gfx_queue_to_bit(adev, mec, pipe, queue),
  76. adev->gfx.mec.queue_bitmap);
  77. }
  78. #endif