Andrew Lewycky | f3a3981 | 2015-05-10 12:15:46 +0300 | [diff] [blame] | 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 | #ifndef KFD_EVENTS_H_INCLUDED |
| 24 | #define KFD_EVENTS_H_INCLUDED |
| 25 | |
| 26 | #include <linux/kernel.h> |
| 27 | #include <linux/hashtable.h> |
| 28 | #include <linux/types.h> |
| 29 | #include <linux/list.h> |
Felix Kuehling | 74e4071 | 2017-10-27 19:35:25 -0400 | [diff] [blame] | 30 | #include <linux/wait.h> |
Andrew Lewycky | f3a3981 | 2015-05-10 12:15:46 +0300 | [diff] [blame] | 31 | #include "kfd_priv.h" |
Alexey Skidanov | 59d3e8b | 2015-04-14 18:05:49 +0300 | [diff] [blame] | 32 | #include <uapi/linux/kfd_ioctl.h> |
Andrew Lewycky | f3a3981 | 2015-05-10 12:15:46 +0300 | [diff] [blame] | 33 | |
Felix Kuehling | 482f077 | 2017-10-27 19:35:27 -0400 | [diff] [blame] | 34 | /* |
| 35 | * IDR supports non-negative integer IDs. Small IDs are used for |
| 36 | * signal events to match their signal slot. Use the upper half of the |
| 37 | * ID space for non-signal events. |
| 38 | */ |
| 39 | #define KFD_FIRST_NONSIGNAL_EVENT_ID ((INT_MAX >> 1) + 1) |
| 40 | #define KFD_LAST_NONSIGNAL_EVENT_ID INT_MAX |
Andrew Lewycky | f3a3981 | 2015-05-10 12:15:46 +0300 | [diff] [blame] | 41 | |
| 42 | /* |
| 43 | * Written into kfd_signal_slot_t to indicate that the event is not signaled. |
| 44 | * Since the event protocol may need to write the event ID into memory, this |
| 45 | * must not be a valid event ID. |
| 46 | * For the sake of easy memset-ing, this must be a byte pattern. |
| 47 | */ |
| 48 | #define UNSIGNALED_EVENT_SLOT ((uint64_t)-1) |
| 49 | |
| 50 | struct kfd_event_waiter; |
| 51 | struct signal_page; |
| 52 | |
| 53 | struct kfd_event { |
Andrew Lewycky | f3a3981 | 2015-05-10 12:15:46 +0300 | [diff] [blame] | 54 | u32 event_id; |
| 55 | |
| 56 | bool signaled; |
| 57 | bool auto_reset; |
| 58 | |
| 59 | int type; |
| 60 | |
Felix Kuehling | 74e4071 | 2017-10-27 19:35:25 -0400 | [diff] [blame] | 61 | wait_queue_head_t wq; /* List of event waiters. */ |
Andrew Lewycky | f3a3981 | 2015-05-10 12:15:46 +0300 | [diff] [blame] | 62 | |
| 63 | /* Only for signal events. */ |
Andrew Lewycky | f3a3981 | 2015-05-10 12:15:46 +0300 | [diff] [blame] | 64 | uint64_t __user *user_signal_address; |
Alexey Skidanov | 59d3e8b | 2015-04-14 18:05:49 +0300 | [diff] [blame] | 65 | |
| 66 | /* type specific data */ |
| 67 | union { |
| 68 | struct kfd_hsa_memory_exception_data memory_exception_data; |
Shaoyun Liu | e42051d2 | 2018-07-11 22:32:56 -0400 | [diff] [blame] | 69 | struct kfd_hsa_hw_exception_data hw_exception_data; |
Alexey Skidanov | 59d3e8b | 2015-04-14 18:05:49 +0300 | [diff] [blame] | 70 | }; |
Andrew Lewycky | f3a3981 | 2015-05-10 12:15:46 +0300 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | #define KFD_EVENT_TIMEOUT_IMMEDIATE 0 |
| 74 | #define KFD_EVENT_TIMEOUT_INFINITE 0xFFFFFFFFu |
| 75 | |
| 76 | /* Matching HSA_EVENTTYPE */ |
| 77 | #define KFD_EVENT_TYPE_SIGNAL 0 |
Alexey Skidanov | 930c5ff | 2014-11-25 10:34:31 +0200 | [diff] [blame] | 78 | #define KFD_EVENT_TYPE_HW_EXCEPTION 3 |
Andrew Lewycky | f3a3981 | 2015-05-10 12:15:46 +0300 | [diff] [blame] | 79 | #define KFD_EVENT_TYPE_DEBUG 5 |
Alexey Skidanov | 59d3e8b | 2015-04-14 18:05:49 +0300 | [diff] [blame] | 80 | #define KFD_EVENT_TYPE_MEMORY 8 |
Andrew Lewycky | f3a3981 | 2015-05-10 12:15:46 +0300 | [diff] [blame] | 81 | |
Fenghua Yu | c7b6bac | 2020-09-15 09:30:05 -0700 | [diff] [blame] | 82 | extern void kfd_signal_event_interrupt(u32 pasid, uint32_t partial_id, |
| 83 | uint32_t valid_id_bits); |
Andrew Lewycky | f3a3981 | 2015-05-10 12:15:46 +0300 | [diff] [blame] | 84 | |
| 85 | #endif |