Home | History | Annotate | Line # | Download | only in amdkfd
kfd_events.h revision 1.2
      1 /*	$NetBSD: kfd_events.h,v 1.2 2018/08/27 04:58:20 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 "kfd_priv.h"
     33 #include <uapi/linux/kfd_ioctl.h>
     34 
     35 #define KFD_EVENT_ID_NONSIGNAL_MASK 0x80000000U
     36 #define KFD_FIRST_NONSIGNAL_EVENT_ID KFD_EVENT_ID_NONSIGNAL_MASK
     37 #define KFD_LAST_NONSIGNAL_EVENT_ID UINT_MAX
     38 
     39 /*
     40  * Written into kfd_signal_slot_t to indicate that the event is not signaled.
     41  * Since the event protocol may need to write the event ID into memory, this
     42  * must not be a valid event ID.
     43  * For the sake of easy memset-ing, this must be a byte pattern.
     44  */
     45 #define UNSIGNALED_EVENT_SLOT ((uint64_t)-1)
     46 
     47 struct kfd_event_waiter;
     48 struct signal_page;
     49 
     50 struct kfd_event {
     51 	/* All events in process, rooted at kfd_process.events. */
     52 	struct hlist_node events;
     53 
     54 	u32 event_id;
     55 
     56 	bool signaled;
     57 	bool auto_reset;
     58 
     59 	int type;
     60 
     61 	struct list_head waiters; /* List of kfd_event_waiter by waiters. */
     62 
     63 	/* Only for signal events. */
     64 	struct signal_page *signal_page;
     65 	unsigned int signal_slot_index;
     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 	};
     72 };
     73 
     74 #define KFD_EVENT_TIMEOUT_IMMEDIATE 0
     75 #define KFD_EVENT_TIMEOUT_INFINITE 0xFFFFFFFFu
     76 
     77 /* Matching HSA_EVENTTYPE */
     78 #define KFD_EVENT_TYPE_SIGNAL 0
     79 #define KFD_EVENT_TYPE_HW_EXCEPTION 3
     80 #define KFD_EVENT_TYPE_DEBUG 5
     81 #define KFD_EVENT_TYPE_MEMORY 8
     82 
     83 extern void kfd_signal_event_interrupt(unsigned int pasid, uint32_t partial_id,
     84 					uint32_t valid_id_bits);
     85 
     86 #endif
     87