kfd_kernel_queue.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* SPDX-License-Identifier: GPL-2.0 OR MIT */
  2. /*
  3. * Copyright 2014-2022 Advanced Micro Devices, Inc.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a
  6. * copy of this software and associated documentation files (the "Software"),
  7. * to deal in the Software without restriction, including without limitation
  8. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. * and/or sell copies of the Software, and to permit persons to whom the
  10. * Software is furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in
  13. * all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  19. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  20. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  21. * OTHER DEALINGS IN THE SOFTWARE.
  22. *
  23. */
  24. #ifndef KFD_KERNEL_QUEUE_H_
  25. #define KFD_KERNEL_QUEUE_H_
  26. #include <linux/list.h>
  27. #include <linux/types.h>
  28. #include "kfd_priv.h"
  29. /**
  30. * kq_acquire_packet_buffer: Returns a pointer to the location in the kernel
  31. * queue ring buffer where the calling function can write its packet. It is
  32. * Guaranteed that there is enough space for that packet. It also updates the
  33. * pending write pointer to that location so subsequent calls to
  34. * acquire_packet_buffer will get a correct write pointer
  35. *
  36. * kq_submit_packet: Update the write pointer and doorbell of a kernel queue.
  37. *
  38. * kq_rollback_packet: This routine is called if we failed to build an acquired
  39. * packet for some reason. It just overwrites the pending wptr with the current
  40. * one
  41. *
  42. */
  43. int kq_acquire_packet_buffer(struct kernel_queue *kq,
  44. size_t packet_size_in_dwords,
  45. unsigned int **buffer_ptr);
  46. int kq_submit_packet(struct kernel_queue *kq);
  47. void kq_rollback_packet(struct kernel_queue *kq);
  48. struct kernel_queue {
  49. /* data */
  50. struct kfd_node *dev;
  51. struct mqd_manager *mqd_mgr;
  52. struct queue *queue;
  53. uint64_t pending_wptr64;
  54. uint32_t pending_wptr;
  55. unsigned int nop_packet;
  56. struct kfd_mem_obj *rptr_mem;
  57. uint32_t *rptr_kernel;
  58. uint64_t rptr_gpu_addr;
  59. struct kfd_mem_obj *wptr_mem;
  60. union {
  61. uint64_t *wptr64_kernel;
  62. uint32_t *wptr_kernel;
  63. };
  64. uint64_t wptr_gpu_addr;
  65. struct kfd_mem_obj *pq;
  66. uint64_t pq_gpu_addr;
  67. uint32_t *pq_kernel_addr;
  68. struct kfd_mem_obj *eop_mem;
  69. uint64_t eop_gpu_addr;
  70. uint32_t *eop_kernel_addr;
  71. struct kfd_mem_obj *fence_mem_obj;
  72. uint64_t fence_gpu_addr;
  73. void *fence_kernel_address;
  74. struct list_head list;
  75. };
  76. #endif /* KFD_KERNEL_QUEUE_H_ */