kfd_mqd_manager.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 KFD_MQD_MANAGER_H_
  24. #define KFD_MQD_MANAGER_H_
  25. #include "kfd_priv.h"
  26. /**
  27. * struct mqd_manager
  28. *
  29. * @init_mqd: Allocates the mqd buffer on local gpu memory and initialize it.
  30. *
  31. * @load_mqd: Loads the mqd to a concrete hqd slot. Used only for no cp
  32. * scheduling mode.
  33. *
  34. * @update_mqd: Handles a update call for the MQD
  35. *
  36. * @destroy_mqd: Destroys the HQD slot and by that preempt the relevant queue.
  37. * Used only for no cp scheduling.
  38. *
  39. * @uninit_mqd: Releases the mqd buffer from local gpu memory.
  40. *
  41. * @is_occupied: Checks if the relevant HQD slot is occupied.
  42. *
  43. * @mqd_mutex: Mqd manager mutex.
  44. *
  45. * @dev: The kfd device structure coupled with this module.
  46. *
  47. * MQD stands for Memory Queue Descriptor which represents the current queue
  48. * state in the memory and initiate the HQD (Hardware Queue Descriptor) state.
  49. * This structure is actually a base class for the different types of MQDs
  50. * structures for the variant ASICs that should be supported in the future.
  51. * This base class is also contains all the MQD specific operations.
  52. * Another important thing to mention is that each queue has a MQD that keeps
  53. * his state (or context) after each preemption or reassignment.
  54. * Basically there are a instances of the mqd manager class per MQD type per
  55. * ASIC. Currently the kfd driver supports only Kaveri so there are instances
  56. * per KFD_MQD_TYPE for each device.
  57. *
  58. */
  59. struct mqd_manager {
  60. int (*init_mqd)(struct mqd_manager *mm, void **mqd,
  61. struct kfd_mem_obj **mqd_mem_obj, uint64_t *gart_addr,
  62. struct queue_properties *q);
  63. int (*load_mqd)(struct mqd_manager *mm, void *mqd,
  64. uint32_t pipe_id, uint32_t queue_id,
  65. struct queue_properties *p,
  66. struct mm_struct *mms);
  67. int (*update_mqd)(struct mqd_manager *mm, void *mqd,
  68. struct queue_properties *q);
  69. int (*destroy_mqd)(struct mqd_manager *mm, void *mqd,
  70. enum kfd_preempt_type type,
  71. unsigned int timeout, uint32_t pipe_id,
  72. uint32_t queue_id);
  73. void (*uninit_mqd)(struct mqd_manager *mm, void *mqd,
  74. struct kfd_mem_obj *mqd_mem_obj);
  75. bool (*is_occupied)(struct mqd_manager *mm, void *mqd,
  76. uint64_t queue_address, uint32_t pipe_id,
  77. uint32_t queue_id);
  78. #if defined(CONFIG_DEBUG_FS)
  79. int (*debugfs_show_mqd)(struct seq_file *m, void *data);
  80. #endif
  81. struct mutex mqd_mutex;
  82. struct kfd_dev *dev;
  83. };
  84. void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm,
  85. const uint32_t *cu_mask, uint32_t cu_mask_count,
  86. uint32_t *se_mask);
  87. #endif /* KFD_MQD_MANAGER_H_ */