adreno_a6xx_hwsched_hfi.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef _ADRENO_A6XX_HWSCHED_HFI_H_
  7. #define _ADRENO_A6XX_HWSCHED_HFI_H_
  8. struct a6xx_hwsched_hfi {
  9. struct hfi_mem_alloc_entry mem_alloc_table[32];
  10. u32 mem_alloc_entries;
  11. /** @irq_mask: Store the hfi interrupt mask */
  12. u32 irq_mask;
  13. /** @msglock: To protect the list of un-ACKed hfi packets */
  14. rwlock_t msglock;
  15. /** @msglist: List of un-ACKed hfi packets */
  16. struct list_head msglist;
  17. /** @f2h_task: Task for processing gmu fw to host packets */
  18. struct task_struct *f2h_task;
  19. /** @f2h_wq: Waitqueue for the f2h_task */
  20. wait_queue_head_t f2h_wq;
  21. /** @big_ib: GMU buffer to hold big IBs */
  22. struct kgsl_memdesc *big_ib;
  23. /** @big_ib_recurring: GMU buffer to hold big recurring IBs */
  24. struct kgsl_memdesc *big_ib_recurring;
  25. /** @perfctr_scratch: Buffer to hold perfcounter PM4 commands */
  26. struct kgsl_memdesc *perfctr_scratch;
  27. /** @msg_mutex: Mutex for accessing the msgq */
  28. struct mutex msgq_mutex;
  29. };
  30. struct kgsl_drawobj_cmd;
  31. /**
  32. * a6xx_hwsched_hfi_probe - Probe hwsched hfi resources
  33. * @adreno_dev: Pointer to adreno device structure
  34. *
  35. * Return: 0 on success and negative error on failure.
  36. */
  37. int a6xx_hwsched_hfi_probe(struct adreno_device *adreno_dev);
  38. /**
  39. * a6xx_hwsched_hfi_remove - Release hwsched hfi resources
  40. * @adreno_dev: Pointer to adreno device structure
  41. */
  42. void a6xx_hwsched_hfi_remove(struct adreno_device *adreno_dev);
  43. /**
  44. * a6xx_hwsched_hfi_init - Initialize hfi resources
  45. * @adreno_dev: Pointer to adreno device structure
  46. *
  47. * This function is used to initialize hfi resources
  48. * once before the very first gmu boot
  49. *
  50. * Return: 0 on success and negative error on failure.
  51. */
  52. int a6xx_hwsched_hfi_init(struct adreno_device *adreno_dev);
  53. /**
  54. * a6xx_hwsched_hfi_start - Start hfi resources
  55. * @adreno_dev: Pointer to adreno device structure
  56. *
  57. * Send the various hfi packets before booting the gpu
  58. *
  59. * Return: 0 on success and negative error on failure.
  60. */
  61. int a6xx_hwsched_hfi_start(struct adreno_device *adreno_dev);
  62. /**
  63. * a6xx_hwsched_hfi_stop - Stop the hfi resources
  64. * @adreno_dev: Pointer to the adreno device
  65. *
  66. * This function does the hfi cleanup when powering down the gmu
  67. */
  68. void a6xx_hwsched_hfi_stop(struct adreno_device *adreno_dev);
  69. /**
  70. * a6xx_hwched_cp_init - Send CP_INIT via HFI
  71. * @adreno_dev: Pointer to adreno device structure
  72. *
  73. * This function is used to send CP INIT packet and bring
  74. * GPU out of secure mode using hfi raw packets.
  75. *
  76. * Return: 0 on success and negative error on failure.
  77. */
  78. int a6xx_hwsched_cp_init(struct adreno_device *adreno_dev);
  79. /**
  80. * a6xx_hwsched_counter_inline_enable - Configure a performance counter for a countable
  81. * @adreno_dev - Adreno device to configure
  82. * @group - Desired performance counter group
  83. * @counter - Desired performance counter in the group
  84. * @countable - Desired countable
  85. *
  86. * Physically set up a counter within a group with the desired countable
  87. * Return 0 on success or negative error on failure.
  88. */
  89. int a6xx_hwsched_counter_inline_enable(struct adreno_device *adreno_dev,
  90. const struct adreno_perfcount_group *group,
  91. u32 counter, u32 countable);
  92. /**
  93. * a6xx_hfi_send_cmd_async - Send an hfi packet
  94. * @adreno_dev: Pointer to adreno device structure
  95. * @data: Data to be sent in the hfi packet
  96. * @size_bytes: Size of the packet in bytes
  97. *
  98. * Send data in the form of an HFI packet to gmu and wait for
  99. * it's ack asynchronously
  100. *
  101. * Return: 0 on success and negative error on failure.
  102. */
  103. int a6xx_hfi_send_cmd_async(struct adreno_device *adreno_dev, void *data, u32 size_bytes);
  104. /**
  105. * a6xx_hwsched_submit_drawobj - Dispatch IBs to dispatch queues
  106. * @adreno_dev: Pointer to adreno device structure
  107. * @drawobj: The command draw object which needs to be submitted
  108. *
  109. * This function is used to register the context if needed and submit
  110. * IBs to the hfi dispatch queues.
  111. * Return: 0 on success and negative error on failure
  112. */
  113. int a6xx_hwsched_submit_drawobj(struct adreno_device *adreno_dev,
  114. struct kgsl_drawobj *drawobj);
  115. /**
  116. * a6xx_hwsched_context_detach - Unregister a context with GMU
  117. * @drawctxt: Pointer to the adreno context
  118. *
  119. * This function sends context unregister HFI and waits for the ack
  120. * to ensure all submissions from this context have retired
  121. */
  122. void a6xx_hwsched_context_detach(struct adreno_context *drawctxt);
  123. /* Helper function to get to a6xx hwsched hfi device from adreno device */
  124. struct a6xx_hwsched_hfi *to_a6xx_hwsched_hfi(struct adreno_device *adreno_dev);
  125. /**
  126. * a6xx_hwsched_preempt_count_get - Get preemption count from GMU
  127. * @adreno_dev: Pointer to adreno device
  128. *
  129. * This function sends a GET_VALUE HFI packet to get the number of
  130. * preemptions completed since last SLUMBER exit.
  131. *
  132. * Return: Preemption count
  133. */
  134. u32 a6xx_hwsched_preempt_count_get(struct adreno_device *adreno_dev);
  135. #endif