kfd_device_queue_manager.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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_DEVICE_QUEUE_MANAGER_H_
  24. #define KFD_DEVICE_QUEUE_MANAGER_H_
  25. #include <linux/rwsem.h>
  26. #include <linux/list.h>
  27. #include "kfd_priv.h"
  28. #include "kfd_mqd_manager.h"
  29. #define QUEUE_PREEMPT_DEFAULT_TIMEOUT_MS (500)
  30. #define QUEUES_PER_PIPE (8)
  31. #define PIPE_PER_ME_CP_SCHEDULING (3)
  32. #define CIK_VMID_NUM (8)
  33. #define KFD_VMID_START_OFFSET (8)
  34. #define VMID_PER_DEVICE CIK_VMID_NUM
  35. #define KFD_DQM_FIRST_PIPE (0)
  36. struct device_process_node {
  37. struct qcm_process_device *qpd;
  38. struct list_head list;
  39. };
  40. /**
  41. * struct device_queue_manager
  42. *
  43. * @create_queue: Queue creation routine.
  44. *
  45. * @destroy_queue: Queue destruction routine.
  46. *
  47. * @update_queue: Queue update routine.
  48. *
  49. * @get_mqd_manager: Returns the mqd manager according to the mqd type.
  50. *
  51. * @exeute_queues: Dispatches the queues list to the H/W.
  52. *
  53. * @register_process: This routine associates a specific process with device.
  54. *
  55. * @unregister_process: destroys the associations between process to device.
  56. *
  57. * @initialize: Initializes the pipelines and memory module for that device.
  58. *
  59. * @start: Initializes the resources/modules the the device needs for queues
  60. * execution. This function is called on device initialization and after the
  61. * system woke up after suspension.
  62. *
  63. * @stop: This routine stops execution of all the active queue running on the
  64. * H/W and basically this function called on system suspend.
  65. *
  66. * @uninitialize: Destroys all the device queue manager resources allocated in
  67. * initialize routine.
  68. *
  69. * @create_kernel_queue: Creates kernel queue. Used for debug queue.
  70. *
  71. * @destroy_kernel_queue: Destroys kernel queue. Used for debug queue.
  72. *
  73. * @set_cache_memory_policy: Sets memory policy (cached/ non cached) for the
  74. * memory apertures.
  75. *
  76. * This struct is a base class for the kfd queues scheduler in the
  77. * device level. The device base class should expose the basic operations
  78. * for queue creation and queue destruction. This base class hides the
  79. * scheduling mode of the driver and the specific implementation of the
  80. * concrete device. This class is the only class in the queues scheduler
  81. * that configures the H/W.
  82. */
  83. struct device_queue_manager {
  84. int (*create_queue)(struct device_queue_manager *dqm,
  85. struct queue *q,
  86. struct qcm_process_device *qpd,
  87. int *allocate_vmid);
  88. int (*destroy_queue)(struct device_queue_manager *dqm,
  89. struct qcm_process_device *qpd,
  90. struct queue *q);
  91. int (*update_queue)(struct device_queue_manager *dqm,
  92. struct queue *q);
  93. struct mqd_manager * (*get_mqd_manager)
  94. (struct device_queue_manager *dqm,
  95. enum KFD_MQD_TYPE type);
  96. int (*register_process)(struct device_queue_manager *dqm,
  97. struct qcm_process_device *qpd);
  98. int (*unregister_process)(struct device_queue_manager *dqm,
  99. struct qcm_process_device *qpd);
  100. int (*initialize)(struct device_queue_manager *dqm);
  101. int (*start)(struct device_queue_manager *dqm);
  102. int (*stop)(struct device_queue_manager *dqm);
  103. void (*uninitialize)(struct device_queue_manager *dqm);
  104. int (*create_kernel_queue)(struct device_queue_manager *dqm,
  105. struct kernel_queue *kq,
  106. struct qcm_process_device *qpd);
  107. void (*destroy_kernel_queue)(struct device_queue_manager *dqm,
  108. struct kernel_queue *kq,
  109. struct qcm_process_device *qpd);
  110. bool (*set_cache_memory_policy)(struct device_queue_manager *dqm,
  111. struct qcm_process_device *qpd,
  112. enum cache_policy default_policy,
  113. enum cache_policy alternate_policy,
  114. void __user *alternate_aperture_base,
  115. uint64_t alternate_aperture_size);
  116. struct mqd_manager *mqds[KFD_MQD_TYPE_MAX];
  117. struct packet_manager packets;
  118. struct kfd_dev *dev;
  119. struct mutex lock;
  120. struct list_head queues;
  121. unsigned int processes_count;
  122. unsigned int queue_count;
  123. unsigned int next_pipe_to_allocate;
  124. unsigned int *allocated_queues;
  125. unsigned int vmid_bitmap;
  126. uint64_t pipelines_addr;
  127. struct kfd_mem_obj *pipeline_mem;
  128. uint64_t fence_gpu_addr;
  129. unsigned int *fence_addr;
  130. struct kfd_mem_obj *fence_mem;
  131. bool active_runlist;
  132. };
  133. #endif /* KFD_DEVICE_QUEUE_MANAGER_H_ */