Path: blob/master/drivers/gpu/drm/amd/amdkfd/kfd_debug.h
26516 views
/*1* Copyright 2023 Advanced Micro Devices, Inc.2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice shall be included in11* all copies or substantial portions of the Software.12*13* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL16* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR17* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,18* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR19* OTHER DEALINGS IN THE SOFTWARE.20*/2122#ifndef KFD_DEBUG_EVENTS_H_INCLUDED23#define KFD_DEBUG_EVENTS_H_INCLUDED2425#include "kfd_priv.h"2627void kfd_dbg_trap_deactivate(struct kfd_process *target, bool unwind, int unwind_count);28int kfd_dbg_trap_activate(struct kfd_process *target);29int kfd_dbg_ev_query_debug_event(struct kfd_process *process,30unsigned int *queue_id,31unsigned int *gpu_id,32uint64_t exception_clear_mask,33uint64_t *event_status);34bool kfd_set_dbg_ev_from_interrupt(struct kfd_node *dev,35unsigned int pasid,36uint32_t doorbell_id,37uint64_t trap_mask,38void *exception_data,39size_t exception_data_size);40bool kfd_dbg_ev_raise(uint64_t event_mask,41struct kfd_process *process, struct kfd_node *dev,42unsigned int source_id, bool use_worker,43void *exception_data,44size_t exception_data_size);45int kfd_dbg_trap_disable(struct kfd_process *target);46int kfd_dbg_trap_enable(struct kfd_process *target, uint32_t fd,47void __user *runtime_info,48uint32_t *runtime_info_size);49int kfd_dbg_trap_set_wave_launch_override(struct kfd_process *target,50uint32_t trap_override,51uint32_t trap_mask_bits,52uint32_t trap_mask_request,53uint32_t *trap_mask_prev,54uint32_t *trap_mask_supported);55int kfd_dbg_trap_set_wave_launch_mode(struct kfd_process *target,56uint8_t wave_launch_mode);57int kfd_dbg_trap_clear_dev_address_watch(struct kfd_process_device *pdd,58uint32_t watch_id);59int kfd_dbg_trap_set_dev_address_watch(struct kfd_process_device *pdd,60uint64_t watch_address,61uint32_t watch_address_mask,62uint32_t *watch_id,63uint32_t watch_mode);64int kfd_dbg_trap_set_flags(struct kfd_process *target, uint32_t *flags);65int kfd_dbg_trap_query_exception_info(struct kfd_process *target,66uint32_t source_id,67uint32_t exception_code,68bool clear_exception,69void __user *info,70uint32_t *info_size);71int kfd_dbg_send_exception_to_runtime(struct kfd_process *p,72unsigned int dev_id,73unsigned int queue_id,74uint64_t error_reason);7576static inline bool kfd_dbg_is_per_vmid_supported(struct kfd_node *dev)77{78return (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) ||79KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 3) ||80KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 4) ||81KFD_GC_VERSION(dev) == IP_VERSION(9, 5, 0) ||82KFD_GC_VERSION(dev) >= IP_VERSION(11, 0, 0));83}8485void debug_event_write_work_handler(struct work_struct *work);86int kfd_dbg_trap_device_snapshot(struct kfd_process *target,87uint64_t exception_clear_mask,88void __user *user_info,89uint32_t *number_of_device_infos,90uint32_t *entry_size);9192void kfd_dbg_set_enabled_debug_exception_mask(struct kfd_process *target,93uint64_t exception_set_mask);94/*95* If GFX off is enabled, chips that do not support RLC restore for the debug96* registers will disable GFX off temporarily for the entire debug session.97* See disable_on_trap_action_entry and enable_on_trap_action_exit for details.98*/99static inline bool kfd_dbg_is_rlc_restore_supported(struct kfd_node *dev)100{101return !(KFD_GC_VERSION(dev) == IP_VERSION(10, 1, 10) ||102KFD_GC_VERSION(dev) == IP_VERSION(10, 1, 1));103}104105static inline bool kfd_dbg_has_cwsr_workaround(struct kfd_node *dev)106{107return KFD_GC_VERSION(dev) >= IP_VERSION(11, 0, 0) &&108KFD_GC_VERSION(dev) <= IP_VERSION(11, 0, 3);109}110111static inline bool kfd_dbg_has_gws_support(struct kfd_node *dev)112{113if ((KFD_GC_VERSION(dev) == IP_VERSION(9, 0, 1)114&& dev->kfd->mec2_fw_version < 0x81b6) ||115(KFD_GC_VERSION(dev) >= IP_VERSION(9, 1, 0)116&& KFD_GC_VERSION(dev) <= IP_VERSION(9, 2, 2)117&& dev->kfd->mec2_fw_version < 0x1b6) ||118(KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 0)119&& dev->kfd->mec2_fw_version < 0x1b6) ||120(KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 1)121&& dev->kfd->mec2_fw_version < 0x30) ||122(KFD_GC_VERSION(dev) >= IP_VERSION(11, 0, 0) &&123KFD_GC_VERSION(dev) < IP_VERSION(12, 0, 0)))124return false;125126/* Assume debugging and cooperative launch supported otherwise. */127return true;128}129130int kfd_dbg_set_mes_debug_mode(struct kfd_process_device *pdd, bool sq_trap_en);131132static inline bool kfd_dbg_has_ttmps_always_setup(struct kfd_node *dev)133{134return (KFD_GC_VERSION(dev) < IP_VERSION(11, 0, 0) &&135KFD_GC_VERSION(dev) != IP_VERSION(9, 4, 2)) ||136(KFD_GC_VERSION(dev) >= IP_VERSION(11, 0, 0) &&137KFD_GC_VERSION(dev) < IP_VERSION(12, 0, 0) &&138(dev->adev->mes.sched_version & AMDGPU_MES_VERSION_MASK) >= 70) ||139(KFD_GC_VERSION(dev) >= IP_VERSION(12, 0, 0));140}141#endif142143144