kfd_queue.c 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #include <linux/slab.h>
  24. #include "kfd_priv.h"
  25. void print_queue_properties(struct queue_properties *q)
  26. {
  27. if (!q)
  28. return;
  29. pr_debug("Printing queue properties:\n");
  30. pr_debug("Queue Type: %u\n", q->type);
  31. pr_debug("Queue Size: %llu\n", q->queue_size);
  32. pr_debug("Queue percent: %u\n", q->queue_percent);
  33. pr_debug("Queue Address: 0x%llX\n", q->queue_address);
  34. pr_debug("Queue Id: %u\n", q->queue_id);
  35. pr_debug("Queue Process Vmid: %u\n", q->vmid);
  36. pr_debug("Queue Read Pointer: 0x%p\n", q->read_ptr);
  37. pr_debug("Queue Write Pointer: 0x%p\n", q->write_ptr);
  38. pr_debug("Queue Doorbell Pointer: 0x%p\n", q->doorbell_ptr);
  39. pr_debug("Queue Doorbell Offset: %u\n", q->doorbell_off);
  40. }
  41. void print_queue(struct queue *q)
  42. {
  43. if (!q)
  44. return;
  45. pr_debug("Printing queue:\n");
  46. pr_debug("Queue Type: %u\n", q->properties.type);
  47. pr_debug("Queue Size: %llu\n", q->properties.queue_size);
  48. pr_debug("Queue percent: %u\n", q->properties.queue_percent);
  49. pr_debug("Queue Address: 0x%llX\n", q->properties.queue_address);
  50. pr_debug("Queue Id: %u\n", q->properties.queue_id);
  51. pr_debug("Queue Process Vmid: %u\n", q->properties.vmid);
  52. pr_debug("Queue Read Pointer: 0x%p\n", q->properties.read_ptr);
  53. pr_debug("Queue Write Pointer: 0x%p\n", q->properties.write_ptr);
  54. pr_debug("Queue Doorbell Pointer: 0x%p\n", q->properties.doorbell_ptr);
  55. pr_debug("Queue Doorbell Offset: %u\n", q->properties.doorbell_off);
  56. pr_debug("Queue MQD Address: 0x%p\n", q->mqd);
  57. pr_debug("Queue MQD Gart: 0x%llX\n", q->gart_mqd_addr);
  58. pr_debug("Queue Process Address: 0x%p\n", q->process);
  59. pr_debug("Queue Device Address: 0x%p\n", q->device);
  60. }
  61. int init_queue(struct queue **q, struct queue_properties properties)
  62. {
  63. struct queue *tmp;
  64. BUG_ON(!q);
  65. tmp = kzalloc(sizeof(struct queue), GFP_KERNEL);
  66. if (!tmp)
  67. return -ENOMEM;
  68. memcpy(&tmp->properties, &properties, sizeof(struct queue_properties));
  69. *q = tmp;
  70. return 0;
  71. }
  72. void uninit_queue(struct queue *q)
  73. {
  74. kfree(q);
  75. }