kfd_events.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 "kfd_priv.h"
  29. #include <uapi/linux/kfd_ioctl.h>
  30. #define KFD_EVENT_ID_NONSIGNAL_MASK 0x80000000U
  31. #define KFD_FIRST_NONSIGNAL_EVENT_ID KFD_EVENT_ID_NONSIGNAL_MASK
  32. #define KFD_LAST_NONSIGNAL_EVENT_ID UINT_MAX
  33. /*
  34. * Written into kfd_signal_slot_t to indicate that the event is not signaled.
  35. * Since the event protocol may need to write the event ID into memory, this
  36. * must not be a valid event ID.
  37. * For the sake of easy memset-ing, this must be a byte pattern.
  38. */
  39. #define UNSIGNALED_EVENT_SLOT ((uint64_t)-1)
  40. struct kfd_event_waiter;
  41. struct signal_page;
  42. struct kfd_event {
  43. /* All events in process, rooted at kfd_process.events. */
  44. struct hlist_node events;
  45. u32 event_id;
  46. bool signaled;
  47. bool auto_reset;
  48. int type;
  49. struct list_head waiters; /* List of kfd_event_waiter by waiters. */
  50. /* Only for signal events. */
  51. struct signal_page *signal_page;
  52. unsigned int signal_slot_index;
  53. uint64_t __user *user_signal_address;
  54. /* type specific data */
  55. union {
  56. struct kfd_hsa_memory_exception_data memory_exception_data;
  57. };
  58. };
  59. #define KFD_EVENT_TIMEOUT_IMMEDIATE 0
  60. #define KFD_EVENT_TIMEOUT_INFINITE 0xFFFFFFFFu
  61. /* Matching HSA_EVENTTYPE */
  62. #define KFD_EVENT_TYPE_SIGNAL 0
  63. #define KFD_EVENT_TYPE_HW_EXCEPTION 3
  64. #define KFD_EVENT_TYPE_DEBUG 5
  65. #define KFD_EVENT_TYPE_MEMORY 8
  66. extern void kfd_signal_event_interrupt(unsigned int pasid, uint32_t partial_id,
  67. uint32_t valid_id_bits);
  68. #endif