Path: blob/master/drivers/gpu/drm/amd/amdkfd/kfd_events.h
26516 views
/* SPDX-License-Identifier: GPL-2.0 OR MIT */1/*2* Copyright 2014-2022 Advanced Micro Devices, Inc.3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* the rights to use, copy, modify, merge, publish, distribute, sublicense,8* and/or sell copies of the Software, and to permit persons to whom the9* Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice shall be included in12* all copies or substantial portions of the Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR18* 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 OR20* OTHER DEALINGS IN THE SOFTWARE.21*/2223#ifndef KFD_EVENTS_H_INCLUDED24#define KFD_EVENTS_H_INCLUDED2526#include <linux/kernel.h>27#include <linux/hashtable.h>28#include <linux/types.h>29#include <linux/list.h>30#include <linux/wait.h>31#include "kfd_priv.h"32#include <uapi/linux/kfd_ioctl.h>3334/*35* IDR supports non-negative integer IDs. Small IDs are used for36* signal events to match their signal slot. Use the upper half of the37* 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_MAX4142/*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, this45* 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)4950struct kfd_event_waiter;51struct signal_page;5253struct kfd_event {54u32 event_id;55u64 event_age;5657bool signaled;58bool auto_reset;5960int type;6162spinlock_t lock;63wait_queue_head_t wq; /* List of event waiters. */6465/* Only for signal events. */66uint64_t __user *user_signal_address;6768/* type specific data */69union {70struct kfd_hsa_memory_exception_data memory_exception_data;71struct kfd_hsa_hw_exception_data hw_exception_data;72};7374struct rcu_head rcu; /* for asynchronous kfree_rcu */75};7677#define KFD_EVENT_TIMEOUT_IMMEDIATE 078#define KFD_EVENT_TIMEOUT_INFINITE 0xFFFFFFFFu7980/* Matching HSA_EVENTTYPE */81#define KFD_EVENT_TYPE_SIGNAL 082#define KFD_EVENT_TYPE_HW_EXCEPTION 383#define KFD_EVENT_TYPE_DEBUG 584#define KFD_EVENT_TYPE_MEMORY 88586extern void kfd_signal_event_interrupt(u32 pasid, uint32_t partial_id,87uint32_t valid_id_bits);8889#endif909192