kfd_events.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #ifndef KFD_EVENTS_H_INCLUDED
  23. #define KFD_EVENTS_H_INCLUDED
  24. #include <linux/kernel.h>
  25. #include <linux/hashtable.h>
  26. #include <linux/types.h>
  27. #include <linux/list.h>
  28. #include <linux/wait.h>
  29. #include "kfd_priv.h"
  30. #include <uapi/linux/kfd_ioctl.h>
  31. /*
  32. * IDR supports non-negative integer IDs. Small IDs are used for
  33. * signal events to match their signal slot. Use the upper half of the
  34. * ID space for non-signal events.
  35. */
  36. #define KFD_FIRST_NONSIGNAL_EVENT_ID ((INT_MAX >> 1) + 1)
  37. #define KFD_LAST_NONSIGNAL_EVENT_ID INT_MAX
  38. /*
  39. * Written into kfd_signal_slot_t to indicate that the event is not signaled.
  40. * Since the event protocol may need to write the event ID into memory, this
  41. * must not be a valid event ID.
  42. * For the sake of easy memset-ing, this must be a byte pattern.
  43. */
  44. #define UNSIGNALED_EVENT_SLOT ((uint64_t)-1)
  45. struct kfd_event_waiter;
  46. struct signal_page;
  47. struct kfd_event {
  48. u32 event_id;
  49. bool signaled;
  50. bool auto_reset;
  51. int type;
  52. wait_queue_head_t wq; /* List of event waiters. */
  53. /* Only for signal events. */
  54. uint64_t __user *user_signal_address;
  55. /* type specific data */
  56. union {
  57. struct kfd_hsa_memory_exception_data memory_exception_data;
  58. struct kfd_hsa_hw_exception_data hw_exception_data;
  59. };
  60. };
  61. #define KFD_EVENT_TIMEOUT_IMMEDIATE 0
  62. #define KFD_EVENT_TIMEOUT_INFINITE 0xFFFFFFFFu
  63. /* Matching HSA_EVENTTYPE */
  64. #define KFD_EVENT_TYPE_SIGNAL 0
  65. #define KFD_EVENT_TYPE_HW_EXCEPTION 3
  66. #define KFD_EVENT_TYPE_DEBUG 5
  67. #define KFD_EVENT_TYPE_MEMORY 8
  68. extern void kfd_signal_event_interrupt(unsigned int pasid, uint32_t partial_id,
  69. uint32_t valid_id_bits);
  70. #endif