linux/drivers/gpu/drm/amd/amdkfd/kfd_events.h
<<
>>
Prefs
   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>
  30#include <linux/wait.h>
  31#include "kfd_priv.h"
  32#include <uapi/linux/kfd_ioctl.h>
  33
  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
  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
  50struct kfd_event_waiter;
  51struct signal_page;
  52
  53struct kfd_event {
  54        u32 event_id;
  55
  56        bool signaled;
  57        bool auto_reset;
  58
  59        int type;
  60
  61        wait_queue_head_t wq; /* List of event waiters. */
  62
  63        /* Only for signal events. */
  64        uint64_t __user *user_signal_address;
  65
  66        /* type specific data */
  67        union {
  68                struct kfd_hsa_memory_exception_data memory_exception_data;
  69                struct kfd_hsa_hw_exception_data hw_exception_data;
  70        };
  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
  78#define KFD_EVENT_TYPE_HW_EXCEPTION 3
  79#define KFD_EVENT_TYPE_DEBUG 5
  80#define KFD_EVENT_TYPE_MEMORY 8
  81
  82extern void kfd_signal_event_interrupt(u32 pasid, uint32_t partial_id,
  83                                       uint32_t valid_id_bits);
  84
  85#endif
  86