1 /* $NetBSD: kfd_events.h,v 1.3 2021/12/18 23:44:59 riastradh Exp $ */ 2 3 /* 4 * Copyright 2014 Advanced Micro Devices, Inc. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the "Software"), 8 * to deal in the Software without restriction, including without limitation 9 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 * and/or sell copies of the Software, and to permit persons to whom the 11 * Software is furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 * OTHER DEALINGS IN THE SOFTWARE. 23 */ 24 25 #ifndef KFD_EVENTS_H_INCLUDED 26 #define KFD_EVENTS_H_INCLUDED 27 28 #include <linux/kernel.h> 29 #include <linux/hashtable.h> 30 #include <linux/types.h> 31 #include <linux/list.h> 32 #include <linux/wait.h> 33 #include "kfd_priv.h" 34 #include <uapi/linux/kfd_ioctl.h> 35 36 /* 37 * IDR supports non-negative integer IDs. Small IDs are used for 38 * signal events to match their signal slot. Use the upper half of the 39 * ID space for non-signal events. 40 */ 41 #define KFD_FIRST_NONSIGNAL_EVENT_ID ((INT_MAX >> 1) + 1) 42 #define KFD_LAST_NONSIGNAL_EVENT_ID INT_MAX 43 44 /* 45 * Written into kfd_signal_slot_t to indicate that the event is not signaled. 46 * Since the event protocol may need to write the event ID into memory, this 47 * must not be a valid event ID. 48 * For the sake of easy memset-ing, this must be a byte pattern. 49 */ 50 #define UNSIGNALED_EVENT_SLOT ((uint64_t)-1) 51 52 struct kfd_event_waiter; 53 struct signal_page; 54 55 struct kfd_event { 56 u32 event_id; 57 58 bool signaled; 59 bool auto_reset; 60 61 int type; 62 63 wait_queue_head_t wq; /* List of event waiters. */ 64 65 /* Only for signal events. */ 66 uint64_t __user *user_signal_address; 67 68 /* type specific data */ 69 union { 70 struct kfd_hsa_memory_exception_data memory_exception_data; 71 struct kfd_hsa_hw_exception_data hw_exception_data; 72 }; 73 }; 74 75 #define KFD_EVENT_TIMEOUT_IMMEDIATE 0 76 #define KFD_EVENT_TIMEOUT_INFINITE 0xFFFFFFFFu 77 78 /* Matching HSA_EVENTTYPE */ 79 #define KFD_EVENT_TYPE_SIGNAL 0 80 #define KFD_EVENT_TYPE_HW_EXCEPTION 3 81 #define KFD_EVENT_TYPE_DEBUG 5 82 #define KFD_EVENT_TYPE_MEMORY 8 83 84 extern void kfd_signal_event_interrupt(unsigned int pasid, uint32_t partial_id, 85 uint32_t valid_id_bits); 86 87 #endif 88