drm/amdkfd: Fix TLB flushing in KFD SVM with no HWS
Subsystems (3)
PATCH 1/3 drm/amdkfd: Fix TLB flushing in KFD SVM with no HWS
With no HWS, TLB flushing will not work in SVM code. Fix this by calling kfd_flush_tlb() which works for both HWS and no HWS case.
--- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +6 -10
@@ -1229,15 +1229,14 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start,if (r)break ; } -amdgpu_amdkfd_flush_gpu_tlb_pasid (pdd->dev->adev, - p->pasid,TLB_FLUSH_HEAVYWEIGHT ); +kfd_flush_tlb (pdd,TLB_FLUSH_HEAVYWEIGHT ); }return r; }static int -svm_range_map_to_gpu (struct amdgpu_device *adev,struct amdgpu_vm *vm, +svm_range_map_to_gpu (struct amdgpu_device *adev,struct kfd_process_device *pdd,struct svm_range *prange,unsigned long offset,unsigned long npages,bool readonly,dma_addr_t *dma_addr,struct amdgpu_device *bo_adev,struct dma_fence **fence)
@@ -1248,6 +1247,7 @@ svm_range_map_to_gpu(struct amdgpu_device *adev, struct amdgpu_vm *vm,int last_domain;int r =0 ;int64_t i, j; +struct amdgpu_vm *vm =drm_priv_to_vm (pdd->drm_priv); last_start = prange->start + offset;
@@ -1305,12 +1305,8 @@ svm_range_map_to_gpu(struct amdgpu_device *adev, struct amdgpu_vm *vm,if (fence) *fence =dma_fence_get (vm->last_update); -if (table_freed) { -struct kfd_process *p; - - p = container_of(prange->svms, struct kfd_process, svms); -amdgpu_amdkfd_flush_gpu_tlb_pasid (adev, p->pasid,TLB_FLUSH_LEGACY ); - } +if (table_freed) +kfd_flush_tlb (pdd,TLB_FLUSH_LEGACY ); out:return r; }
@@ -1351,7 +1347,7 @@ svm_range_map_to_gpus(struct svm_range *prange, unsigned long offset,continue ; } - r =svm_range_map_to_gpu (pdd->dev->adev,drm_priv_to_vm (pdd->drm_priv), + r =svm_range_map_to_gpu (pdd->dev->adev, pdd, prange, offset, npages, readonly, prange->dma_addr[gpuidx], bo_adev, wait ? &fence :NULL );
Signature · 1 line
2.33.1
PATCH 2/3 drm/amdkfd: Remove unused old debugger implementation
Cleanup the kfd code by removing the unused old debugger implementation.
Only a small piece of resetting wavefronts is kept and is moved to kfd_device_queue_manager.c
--- drivers/gpu/drm/amd/amdkfd/Makefile | 2 - drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 282 +----- drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c | 845 ------------------ drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h | 230 ----- drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c | 158 ---- drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h | 293 ------ drivers/gpu/drm/amd/amdkfd/kfd_device.c | 2 - .../drm/amd/amdkfd/kfd_device_queue_manager.c | 59 ++ .../drm/amd/amdkfd/kfd_device_queue_manager.h | 35 + drivers/gpu/drm/amd/amdkfd/kfd_iommu.c | 12 - drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 5 - drivers/gpu/drm/amd/amdkfd/kfd_process.c | 19 - 12 files changed, 98 insertions(+), 1844 deletions(-) delete mode 100644 drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c delete mode 100644 drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h delete mode 100644 drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c delete mode 100644 drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
drivers/gpu/drm/amd/amdkfd/Makefile +0 -2
@@ -51,8 +51,6 @@ AMDKFD_FILES := $(AMDKFD_PATH)/kfd_module.o \ $(AMDKFD_PATH)/kfd_events.o \ $(AMDKFD_PATH)/cik_event_interrupt.o \ $(AMDKFD_PATH)/kfd_int_process_v9.o \ - $(AMDKFD_PATH)/kfd_dbgdev.o \ - $(AMDKFD_PATH)/kfd_dbgmgr.o \ $(AMDKFD_PATH)/kfd_smi_events.o \ $(AMDKFD_PATH)/kfd_crat.o
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +4 -278
310 lines not on this page · raw message
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0 -845
845 lines not on this page · raw message
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0 -230
230 lines not on this page · raw message
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0 -158
158 lines not on this page · raw message
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0 -293
293 lines not on this page · raw message
drivers/gpu/drm/amd/amdkfd/kfd_device.c +0 -2
@@ -575,8 +575,6 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,if (kfd_resume (kfd)) goto kfd_resume_error; - kfd->dbgmgr =NULL ; -if (kfd_topology_add_device (kfd)) {dev_err (kfd_device,"Error adding device to topology\n" ); goto kfd_topology_add_device_error;
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +59 -0
65 lines not on this page · raw message
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h +35 -0
@@ -39,6 +39,41 @@ struct device_process_node {struct list_head list; }; +union SQ_CMD_BITS { +struct { +uint32_t cmd:3 ; + uint32_t:1; +uint32_t mode:3 ; +uint32_t check_vmid:1 ; +uint32_t trap_id:3 ; + uint32_t:5; +uint32_t wave_id:4 ; +uint32_t simd_id:2 ; + uint32_t:2; +uint32_t queue_id:3 ; + uint32_t:1; +uint32_t vm_id:4 ; + } bitfields, bits; +uint32_t u32All; +signed int i32All; +float f32All; +}; + +union GRBM_GFX_INDEX_BITS { +struct { +uint32_t instance_index:8 ; +uint32_t sh_index:8 ; +uint32_t se_index:8 ; + uint32_t:5; +uint32_t sh_broadcast_writes:1 ; +uint32_t instance_broadcast_writes:1 ; +uint32_t se_broadcast_writes:1 ; + } bitfields, bits; +uint32_t u32All; +signed int i32All; +float f32All; +}; +/** * struct device_queue_manager_ops *
drivers/gpu/drm/amd/amdkfd/kfd_iommu.c +0 -12
@@ -30,7 +30,6 @@#include <linux/pci.h> #include <linux/amd-iommu.h> #include "kfd_priv.h" -#include "kfd_dbgmgr.h" #include "kfd_topology.h" #include "kfd_iommu.h"
@@ -163,17 +162,6 @@ static void iommu_pasid_shutdown_callback(struct pci_dev *pdev, u32 pasid)pr_debug ("Unbinding process 0x%x from IOMMU\n" , pasid); -mutex_lock (kfd_get_dbgmgr_mutex ()); - -if (dev->dbgmgr && dev->dbgmgr->pasid == p->pasid) { -if (!kfd_dbgmgr_unregister (dev->dbgmgr, p)) { -kfd_dbgmgr_destroy (dev->dbgmgr); - dev->dbgmgr =NULL ; - } - } - -mutex_unlock (kfd_get_dbgmgr_mutex ()); -mutex_lock (&p->mutex); pdd =kfd_get_process_device_data (dev, p);
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +0 -5
@@ -300,9 +300,6 @@ struct kfd_dev {*/ bool interrupts_active; -/* Debug manager */ -struct kfd_dbgmgr *dbgmgr; -/* Firmware versions */ uint16_t mec_fw_version;uint16_t mec2_fw_version;
@@ -1331,8 +1328,6 @@ void kfd_signal_poison_consumed_event(struct kfd_dev *dev, u32 pasid);void kfd_flush_tlb (struct kfd_process_device *pdd,enum TLB_FLUSH_TYPE type); -int dbgdev_wave_reset_wavefronts (struct kfd_dev *dev,struct kfd_process *p); -bool kfd_is_locked (void );/* Compute profile */
drivers/gpu/drm/amd/amdkfd/kfd_process.c +0 -19
@@ -40,7 +40,6 @@ struct mm_struct;#include "kfd_priv.h" #include "kfd_device_queue_manager.h" -#include "kfd_dbgmgr.h" #include "kfd_iommu.h" #include "kfd_svm.h"
@@ -1158,7 +1157,6 @@ static void kfd_process_notifier_release(struct mmu_notifier *mn, struct mm_struct *mm) {struct kfd_process *p; -int i;/* * The kfd_process structure can not be free because the
@@ -1178,23 +1176,6 @@ static void kfd_process_notifier_release(struct mmu_notifier *mn,mutex_lock (&p->mutex); -/* Iterate over all process device data structures and if the -* pdd is in debug mode, we should first force unregistration, -* then we will be able to destroy the queues -*/ -for (i =0 ; i < p->n_pdds; i++) { -struct kfd_dev *dev = p->pdds[i]->dev; - -mutex_lock (kfd_get_dbgmgr_mutex ()); -if (dev && dev->dbgmgr && dev->dbgmgr->pasid == p->pasid) { -if (!kfd_dbgmgr_unregister (dev->dbgmgr, p)) { -kfd_dbgmgr_destroy (dev->dbgmgr); - dev->dbgmgr =NULL ; - } - } -mutex_unlock (kfd_get_dbgmgr_mutex ()); - } -kfd_process_dequeue_from_all_devices (p);pqm_uninit (&p->pqm);
Signature · 1 line
2.33.1
Felix Kuehling
maintainerRe: [PATCH 2/3] drm/amdkfd: Remove unused old debugger implementation
Am 2022-02-04 um 18:45 schrieb Mukul Joshi:
Quoted 6 lines
Cleanup the kfd code by removing the unused old debugger implementation.
Only a small piece of resetting wavefronts is kept and is moved tokfd_device_queue_manager.cSigned-off-by Mukul Joshi <[email protected]>
We should update include/uapi/linux/kfd_ioctl.h as well to mark the ioctls as deprecated. Just rename the AMDKFD_IOC_DBG_* macros to AMDKFD_IOC_DBG_*_DEPRECATED. A corresponding update to the Thunk would be good as a follow up.
I think there is also some more code you can remove in amdgpu_amdkfd_gfx_v*.c and kgd_kfd_interface.h:
int (*address_watch_disable)(struct amdgpu_device *adev); int (*address_watch_execute)(struct amdgpu_device *adev, unsigned int watch_point_id, uint32_t cntl_val, uint32_t addr_hi, uint32_t addr_lo); uint32_t (*address_watch_get_offset)(struct amdgpu_device *adev, unsigned int watch_point_id, unsigned int reg_offset);
It seems wave_control_execute is still used in dbgdev_wave_reset_wavefronts.
Regards,
Felix
Quoted 2,124 lines
--- drivers/gpu/drm/amd/amdkfd/Makefile | 2 - drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 282 +----- drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c | 845 ------------------ drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h | 230 ----- drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c | 158 ---- drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h | 293 ------ drivers/gpu/drm/amd/amdkfd/kfd_device.c | 2 - .../drm/amd/amdkfd/kfd_device_queue_manager.c | 59 ++ .../drm/amd/amdkfd/kfd_device_queue_manager.h | 35 + drivers/gpu/drm/amd/amdkfd/kfd_iommu.c | 12 - drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 5 - drivers/gpu/drm/amd/amdkfd/kfd_process.c | 19 - 12 files changed, 98 insertions(+), 1844 deletions(-)delete mode 100644
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.cdelete mode 100644drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.hdelete mode 100644drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.cdelete mode 100644drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.hdrivers/gpu/drm/amd/amdkfd/Makefile +0
-2@@ -51,8 +51,6 @@ AMDKFD_FILES := $(AMDKFD_PATH)/kfd_module.o \ $(AMDKFD_PATH)/kfd_events.o \ $(AMDKFD_PATH)/cik_event_interrupt.o \ $(AMDKFD_PATH)/kfd_int_process_v9.o \ - $(AMDKFD_PATH)/kfd_dbgdev.o \ - $(AMDKFD_PATH)/kfd_dbgmgr.o \ $(AMDKFD_PATH)/kfd_smi_events.o \ $(AMDKFD_PATH)/kfd_crat.odrivers/gpu/drm/amd/amdkfd/kfd_chardev.c +4
-278@@ -39,7 +39,6 @@#include <asm/processor.h> #include "kfd_priv.h" #include "kfd_device_queue_manager.h" -#include "kfd_dbgmgr.h" #include "kfd_svm.h" #include "amdgpu_amdkfd.h" #include "kfd_smi_events.h" @@ -580,299 +579,26 @@ static int kfd_ioctl_set_trap_handler(struct file *filep,static int kfd_ioctl_dbg_register (struct file *filep,struct kfd_process *p,void *data) { -struct kfd_ioctl_dbg_register_args *args = data; -struct kfd_dev *dev; -struct kfd_dbgmgr *dbgmgr_ptr; -struct kfd_process_device *pdd; -bool create_ok; -long status =0 ; - -mutex_lock (&p->mutex); - pdd =kfd_process_device_data_by_id (p, args->gpu_id); -if (!pdd) { - status = -EINVAL ; - goto err_pdd; - } - dev = pdd->dev; - -if (dev->adev->asic_type ==CHIP_CARRIZO ) { -pr_debug ("kfd_ioctl_dbg_register not supported on CZ\n" ); - status = -EINVAL ; - goto err_chip_unsupp; - } - -mutex_lock (kfd_get_dbgmgr_mutex ()); - -/* -* make sure that we have pdd, if this the first queue created for -* this process -*/ - pdd =kfd_bind_process_to_device (dev, p); -if (IS_ERR (pdd)) { - status =PTR_ERR (pdd); - goto out; - } - -if (!dev->dbgmgr) { -/* In case of a legal call, we have no dbgmgr yet */ - create_ok =kfd_dbgmgr_create (&dbgmgr_ptr, dev); -if (create_ok) { - status =kfd_dbgmgr_register (dbgmgr_ptr, p); -if (status !=0 ) -kfd_dbgmgr_destroy (dbgmgr_ptr); -else - dev->dbgmgr = dbgmgr_ptr; - } - }else { -pr_debug ("debugger already registered\n" ); - status = -EINVAL ; - } - -out: -mutex_unlock (kfd_get_dbgmgr_mutex ()); -err_pdd: -err_chip_unsupp: -mutex_unlock (&p->mutex); - -return status; +return -EPERM ; }static int kfd_ioctl_dbg_unregister (struct file *filep,struct kfd_process *p,void *data) { -struct kfd_ioctl_dbg_unregister_args *args = data; -struct kfd_process_device *pdd; -struct kfd_dev *dev; -long status; - -mutex_lock (&p->mutex); - pdd =kfd_process_device_data_by_id (p, args->gpu_id); -mutex_unlock (&p->mutex); -if (!pdd || !pdd->dev->dbgmgr) -return -EINVAL ; - - dev = pdd->dev; - -if (dev->adev->asic_type ==CHIP_CARRIZO ) { -pr_debug ("kfd_ioctl_dbg_unregister not supported on CZ\n" ); -return -EINVAL ; - } - -mutex_lock (kfd_get_dbgmgr_mutex ()); - - status =kfd_dbgmgr_unregister (dev->dbgmgr, p); -if (!status) { -kfd_dbgmgr_destroy (dev->dbgmgr); - dev->dbgmgr =NULL ; - } - -mutex_unlock (kfd_get_dbgmgr_mutex ()); - -return status; +return -EPERM ; } -/* -* Parse and generate variable size data structure for address watch. -* Total size of the buffer and # watch points is limited in order -* to prevent kernel abuse. (no bearing to the much smaller HW limitation -* which is enforced by dbgdev module) -* please also note that the watch address itself are not "copied from user", -* since it be set into the HW in user mode values. -* -*/ static int kfd_ioctl_dbg_address_watch (struct file *filep,struct kfd_process *p,void *data) { -struct kfd_ioctl_dbg_address_watch_args *args = data; -struct kfd_dev *dev; -struct kfd_process_device *pdd; -struct dbg_address_watch_info aw_info; -unsigned char *args_buff; -long status; -void __user *cmd_from_user; -uint64_t watch_mask_value =0 ; -unsigned int args_idx =0 ; - -memset ((void *) &aw_info,0 ,sizeof (struct dbg_address_watch_info )); - -mutex_lock (&p->mutex); - pdd =kfd_process_device_data_by_id (p, args->gpu_id); -mutex_unlock (&p->mutex); -if (!pdd) { -pr_debug ("Could not find gpu id 0x%x\n" , args->gpu_id); -return -EINVAL ; - } - dev = pdd->dev; - -if (dev->adev->asic_type ==CHIP_CARRIZO ) { -pr_debug ("kfd_ioctl_dbg_wave_control not supported on CZ\n" ); -return -EINVAL ; - } - cmd_from_user = (void __user *) args->content_ptr; - -/* Validate arguments */ - -if ((args->buf_size_in_bytes >MAX_ALLOWED_AW_BUFF_SIZE ) || - (args->buf_size_in_bytes <=sizeof (*args) +sizeof (int ) *2 ) || - (cmd_from_user ==NULL )) -return -EINVAL ; - -/* this is the actual buffer to work with */ - args_buff =memdup_user (cmd_from_user, - args->buf_size_in_bytes -sizeof (*args)); -if (IS_ERR (args_buff)) -return PTR_ERR (args_buff); - - aw_info.process = p; - - aw_info.num_watch_points = *((uint32_t *)(&args_buff[args_idx])); - args_idx +=sizeof (aw_info.num_watch_points); - - aw_info.watch_mode = (enum HSA_DBG_WATCH_MODE *) &args_buff[args_idx]; - args_idx +=sizeof (enum HSA_DBG_WATCH_MODE ) * aw_info.num_watch_points; - -/* -* set watch address base pointer to point on the array base -* within args_buff -*/ - aw_info.watch_address = (uint64_t *) &args_buff[args_idx]; - -/* skip over the addresses buffer */ - args_idx +=sizeof (aw_info.watch_address) * aw_info.num_watch_points; - -if (args_idx >= args->buf_size_in_bytes -sizeof (*args)) { - status = -EINVAL ; - goto out; - } - - watch_mask_value = (uint64_t ) args_buff[args_idx]; - -if (watch_mask_value >0 ) { -/* -* There is an array of masks. -* set watch mask base pointer to point on the array base -* within args_buff -*/ - aw_info.watch_mask = (uint64_t *) &args_buff[args_idx]; - -/* skip over the masks buffer */ - args_idx +=sizeof (aw_info.watch_mask) * - aw_info.num_watch_points; - }else { -/* just the NULL mask, set to NULL and skip over it */ - aw_info.watch_mask =NULL ; - args_idx +=sizeof (aw_info.watch_mask); - } - -if (args_idx >= args->buf_size_in_bytes -sizeof (args)) { - status = -EINVAL ; - goto out; - } - -/* Currently HSA Event is not supported for DBG */ - aw_info.watch_event =NULL ; - -mutex_lock (kfd_get_dbgmgr_mutex ()); - - status =kfd_dbgmgr_address_watch (dev->dbgmgr, &aw_info); - -mutex_unlock (kfd_get_dbgmgr_mutex ()); - -out: -kfree (args_buff); - -return status; +return -EPERM ; }/* Parse and generate fixed size data structure for wave control */ static int kfd_ioctl_dbg_wave_control (struct file *filep,struct kfd_process *p,void *data) { -struct kfd_ioctl_dbg_wave_control_args *args = data; -struct kfd_dev *dev; -struct kfd_process_device *pdd; -struct dbg_wave_control_info wac_info; -unsigned char *args_buff; -uint32_t computed_buff_size; -long status; -void __user *cmd_from_user; -unsigned int args_idx =0 ; - -memset ((void *) &wac_info,0 ,sizeof (struct dbg_wave_control_info )); - -/* we use compact form, independent of the packing attribute value */ - computed_buff_size =sizeof (*args) + -sizeof (wac_info.mode) + -sizeof (wac_info.operand) + -sizeof (wac_info.dbgWave_msg.DbgWaveMsg) + -sizeof (wac_info.dbgWave_msg.MemoryVA) + -sizeof (wac_info.trapId); - -mutex_lock (&p->mutex); - pdd =kfd_process_device_data_by_id (p, args->gpu_id); -mutex_unlock (&p->mutex); -if (!pdd) { -pr_debug ("Could not find gpu id 0x%x\n" , args->gpu_id); -return -EINVAL ; - } - dev = pdd->dev; - -if (dev->adev->asic_type ==CHIP_CARRIZO ) { -pr_debug ("kfd_ioctl_dbg_wave_control not supported on CZ\n" ); -return -EINVAL ; - } - -/* input size must match the computed "compact" size */ -if (args->buf_size_in_bytes != computed_buff_size) { -pr_debug ("size mismatch, computed : actual %u : %u\n" , - args->buf_size_in_bytes, computed_buff_size); -return -EINVAL ; - } - - cmd_from_user = (void __user *) args->content_ptr; - -if (cmd_from_user ==NULL ) -return -EINVAL ; - -/* copy the entire buffer from user */ - - args_buff =memdup_user (cmd_from_user, - args->buf_size_in_bytes -sizeof (*args)); -if (IS_ERR (args_buff)) -return PTR_ERR (args_buff); - -/* move ptr to the start of the "pay-load" area */ - wac_info.process = p; - - wac_info.operand = *((enum HSA_DBG_WAVEOP *)(&args_buff[args_idx])); - args_idx +=sizeof (wac_info.operand); - - wac_info.mode = *((enum HSA_DBG_WAVEMODE *)(&args_buff[args_idx])); - args_idx +=sizeof (wac_info.mode); - - wac_info.trapId = *((uint32_t *)(&args_buff[args_idx])); - args_idx +=sizeof (wac_info.trapId); - - wac_info.dbgWave_msg.DbgWaveMsg.WaveMsgInfoGen2.Value = - *((uint32_t *)(&args_buff[args_idx])); - wac_info.dbgWave_msg.MemoryVA =NULL ; - -mutex_lock (kfd_get_dbgmgr_mutex ()); - -pr_debug ("Calling dbg manager process %p, operand %u, mode %u, trapId %u, message %u\n" , - wac_info.process, wac_info.operand, - wac_info.mode, wac_info.trapId, - wac_info.dbgWave_msg.DbgWaveMsg.WaveMsgInfoGen2.Value); - - status =kfd_dbgmgr_wave_control (dev->dbgmgr, &wac_info); - -pr_debug ("Returned status of dbg manager is %ld\n" , status); - -mutex_unlock (kfd_get_dbgmgr_mutex ()); - -kfree (args_buff); - -return status; +return -EPERM ; } static int kfd_ioctl_get_clock_counters(struct file *filep,drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-845@@ -1,845 +0,0 @@ -/* -* Copyright 2014 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR -* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -* OTHER DEALINGS IN THE SOFTWARE. -* -*/ - -#include <linux/types.h> -#include <linux/kernel.h> -#include <linux/log2.h> -#include <linux/sched.h> -#include <linux/slab.h> -#include <linux/mutex.h> -#include <linux/device.h> - -#include "kfd_pm4_headers.h" -#include "kfd_pm4_headers_diq.h" -#include "kfd_kernel_queue.h" -#include "kfd_priv.h" -#include "kfd_pm4_opcodes.h" -#include "cik_regs.h" -#include "kfd_dbgmgr.h" -#include "kfd_dbgdev.h" -#include "kfd_device_queue_manager.h" - -static void dbgdev_address_watch_disable_nodiq (struct kfd_dev *dev) -{ - dev->kfd2kgd->address_watch_disable (dev->adev); -} - -static int dbgdev_diq_submit_ib (struct kfd_dbgdev *dbgdev, -u32 pasid,uint64_t vmid0_address, -uint32_t *packet_buff,size_t size_in_bytes) -{ -struct pm4__release_mem *rm_packet; -struct pm4__indirect_buffer_pasid *ib_packet; -struct kfd_mem_obj *mem_obj; -size_t pq_packets_size_in_bytes; -union ULARGE_INTEGER *largep; -union ULARGE_INTEGER addr; -struct kernel_queue *kq; -uint64_t *rm_state; -unsigned int *ib_packet_buff; -int status; - -if (WARN_ON (!size_in_bytes)) -return -EINVAL ; - - kq = dbgdev->kq; - - pq_packets_size_in_bytes =sizeof (struct pm4__release_mem ) + -sizeof (struct pm4__indirect_buffer_pasid ); - -/* -* We acquire a buffer from DIQ -* The receive packet buff will be sitting on the Indirect Buffer -* and in the PQ we put the IB packet + sync packet(s). -*/ - status =kq_acquire_packet_buffer (kq, - pq_packets_size_in_bytes /sizeof (uint32_t ), - &ib_packet_buff); -if (status) { -pr_err ("kq_acquire_packet_buffer failed\n" ); -return status; - } - -memset (ib_packet_buff,0 , pq_packets_size_in_bytes); - - ib_packet = (struct pm4__indirect_buffer_pasid *) (ib_packet_buff); - - ib_packet->header.count =3 ; - ib_packet->header.opcode =IT_INDIRECT_BUFFER_PASID ; - ib_packet->header.type =PM4_TYPE_3 ; - - largep = (union ULARGE_INTEGER *) &vmid0_address; - - ib_packet->bitfields2.ib_base_lo = largep->u.low_part >>2 ; - ib_packet->bitfields3.ib_base_hi = largep->u.high_part; - - ib_packet->control = (1 <<23 ) | (1 <<31 ) | - ((size_in_bytes /4 ) &0xfffff ); - - ib_packet->bitfields5.pasid = pasid; - -/* -* for now we use release mem for GPU-CPU synchronization -* Consider WaitRegMem + WriteData as a better alternative -* we get a GART allocations ( gpu/cpu mapping), -* for the sync variable, and wait until: -* (a) Sync with HW -* (b) Sync var is written by CP to mem. -*/ - rm_packet = (struct pm4__release_mem *) (ib_packet_buff + - (sizeof (struct pm4__indirect_buffer_pasid ) / -sizeof (unsigned int ))); - - status =kfd_gtt_sa_allocate (dbgdev->dev,sizeof (uint64_t ), - &mem_obj); - -if (status) { -pr_err ("Failed to allocate GART memory\n" ); -kq_rollback_packet (kq); -return status; - } - - rm_state = (uint64_t *) mem_obj->cpu_ptr; - - *rm_state =QUEUESTATE__ACTIVE_COMPLETION_PENDING ; - - rm_packet->header.opcode =IT_RELEASE_MEM ; - rm_packet->header.type =PM4_TYPE_3 ; - rm_packet->header.count =sizeof (struct pm4__release_mem ) /4 -2 ; - - rm_packet->bitfields2.event_type =CACHE_FLUSH_AND_INV_TS_EVENT ; - rm_packet->bitfields2.event_index = - event_index___release_mem__end_of_pipe; - - rm_packet->bitfields2.cache_policy = cache_policy___release_mem__lru; - rm_packet->bitfields2.atc =0 ; - rm_packet->bitfields2.tc_wb_action_ena =1 ; - - addr.quad_part = mem_obj->gpu_addr; - - rm_packet->bitfields4.address_lo_32b = addr.u.low_part >>2 ; - rm_packet->address_hi = addr.u.high_part; - - rm_packet->bitfields3.data_sel = - data_sel___release_mem__send_64_bit_data; - - rm_packet->bitfields3.int_sel = - int_sel___release_mem__send_data_after_write_confirm; - - rm_packet->bitfields3.dst_sel = - dst_sel___release_mem__memory_controller; - - rm_packet->data_lo =QUEUESTATE__ACTIVE ; - -kq_submit_packet (kq); - -/* Wait till CP writes sync code: */ - status =amdkfd_fence_wait_timeout ( - rm_state, -QUEUESTATE__ACTIVE ,1500 ); - -kfd_gtt_sa_free (dbgdev->dev, mem_obj); - -return status; -} - -static int dbgdev_register_nodiq (struct kfd_dbgdev *dbgdev) -{ -/* -* no action is needed in this case, -* just make sure diq will not be used -*/ - - dbgdev->kq =NULL ; - -return 0 ; -} - -static int dbgdev_register_diq (struct kfd_dbgdev *dbgdev) -{ -struct queue_properties properties; -unsigned int qid; -struct kernel_queue *kq =NULL ; -int status; - - properties.type =KFD_QUEUE_TYPE_DIQ ; - - status =pqm_create_queue (dbgdev->pqm, dbgdev->dev,NULL , - &properties, &qid,NULL ,NULL ,NULL ,NULL ); - -if (status) { -pr_err ("Failed to create DIQ\n" ); -return status; - } - -pr_debug ("DIQ Created with queue id: %d\n" , qid); - - kq =pqm_get_kernel_queue (dbgdev->pqm, qid); - -if (!kq) { -pr_err ("Error getting DIQ\n" ); -pqm_destroy_queue (dbgdev->pqm, qid); -return -EFAULT ; - } - - dbgdev->kq = kq; - -return status; -} - -static int dbgdev_unregister_nodiq (struct kfd_dbgdev *dbgdev) -{ -/* disable watch address */ -dbgdev_address_watch_disable_nodiq (dbgdev->dev); -return 0 ; -} - -static int dbgdev_unregister_diq (struct kfd_dbgdev *dbgdev) -{ -/* todo - disable address watch */ -int status; - - status =pqm_destroy_queue (dbgdev->pqm, - dbgdev->kq->queue->properties.queue_id); - dbgdev->kq =NULL ; - -return status; -} - -static void dbgdev_address_watch_set_registers ( -const struct dbg_address_watch_info *adw_info, -union TCP_WATCH_ADDR_H_BITS *addrHi, -union TCP_WATCH_ADDR_L_BITS *addrLo, -union TCP_WATCH_CNTL_BITS *cntl, -unsigned int index,unsigned int vmid) -{ -union ULARGE_INTEGER addr; - - addr.quad_part =0 ; - addrHi->u32All =0 ; - addrLo->u32All =0 ; - cntl->u32All =0 ; - -if (adw_info->watch_mask) - cntl->bitfields.mask = - (uint32_t ) (adw_info->watch_mask[index] & -ADDRESS_WATCH_REG_CNTL_DEFAULT_MASK ); -else - cntl->bitfields.mask =ADDRESS_WATCH_REG_CNTL_DEFAULT_MASK ; - - addr.quad_part = (unsigned long long ) adw_info->watch_address[index]; - - addrHi->bitfields.addr = addr.u.high_part & -ADDRESS_WATCH_REG_ADDHIGH_MASK ; - addrLo->bitfields.addr = - (addr.u.low_part >>ADDRESS_WATCH_REG_ADDLOW_SHIFT ); - - cntl->bitfields.mode = adw_info->watch_mode[index]; - cntl->bitfields.vmid = (uint32_t ) vmid; -/* for now assume it is an ATC address */ - cntl->u32All |=ADDRESS_WATCH_REG_CNTL_ATC_BIT ; - -pr_debug ("\t\t%20s %08x\n" ,"set reg mask :" , cntl->bitfields.mask); -pr_debug ("\t\t%20s %08x\n" ,"set reg add high :" , - addrHi->bitfields.addr); -pr_debug ("\t\t%20s %08x\n" ,"set reg add low :" , - addrLo->bitfields.addr); -} - -static int dbgdev_address_watch_nodiq (struct kfd_dbgdev *dbgdev, -struct dbg_address_watch_info *adw_info) -{ -union TCP_WATCH_ADDR_H_BITS addrHi; -union TCP_WATCH_ADDR_L_BITS addrLo; -union TCP_WATCH_CNTL_BITS cntl; -struct kfd_process_device *pdd; -unsigned int i; - -/* taking the vmid for that process on the safe way using pdd */ - pdd =kfd_get_process_device_data (dbgdev->dev, - adw_info->process); -if (!pdd) { -pr_err ("Failed to get pdd for wave control no DIQ\n" ); -return -EFAULT ; - } - - addrHi.u32All =0 ; - addrLo.u32All =0 ; - cntl.u32All =0 ; - -if ((adw_info->num_watch_points >MAX_WATCH_ADDRESSES ) || - (adw_info->num_watch_points ==0 )) { -pr_err ("num_watch_points is invalid\n" ); -return -EINVAL ; - } - -if (!adw_info->watch_mode || !adw_info->watch_address) { -pr_err ("adw_info fields are not valid\n" ); -return -EINVAL ; - } - -for (i =0 ; i < adw_info->num_watch_points; i++) { -dbgdev_address_watch_set_registers (adw_info, &addrHi, &addrLo, - &cntl, i, pdd->qpd.vmid); - -pr_debug ("\t\t%30s\n" ,"* * * * * * * * * * * * * * * * * *" ); -pr_debug ("\t\t%20s %08x\n" ,"register index :" , i); -pr_debug ("\t\t%20s %08x\n" ,"vmid is :" , pdd->qpd.vmid); -pr_debug ("\t\t%20s %08x\n" ,"Address Low is :" , - addrLo.bitfields.addr); -pr_debug ("\t\t%20s %08x\n" ,"Address high is :" , - addrHi.bitfields.addr); -pr_debug ("\t\t%20s %08x\n" ,"Address high is :" , - addrHi.bitfields.addr); -pr_debug ("\t\t%20s %08x\n" ,"Control Mask is :" , - cntl.bitfields.mask); -pr_debug ("\t\t%20s %08x\n" ,"Control Mode is :" , - cntl.bitfields.mode); -pr_debug ("\t\t%20s %08x\n" ,"Control Vmid is :" , - cntl.bitfields.vmid); -pr_debug ("\t\t%20s %08x\n" ,"Control atc is :" , - cntl.bitfields.atc); -pr_debug ("\t\t%30s\n" ,"* * * * * * * * * * * * * * * * * *" ); - - pdd->dev->kfd2kgd->address_watch_execute ( - dbgdev->dev->adev, - i, - cntl.u32All, - addrHi.u32All, - addrLo.u32All); - } - -return 0 ; -} - -static int dbgdev_address_watch_diq (struct kfd_dbgdev *dbgdev, -struct dbg_address_watch_info *adw_info) -{ -struct pm4__set_config_reg *packets_vec; -union TCP_WATCH_ADDR_H_BITS addrHi; -union TCP_WATCH_ADDR_L_BITS addrLo; -union TCP_WATCH_CNTL_BITS cntl; -struct kfd_mem_obj *mem_obj; -unsigned int aw_reg_add_dword; -uint32_t *packet_buff_uint; -unsigned int i; -int status; -size_t ib_size =sizeof (struct pm4__set_config_reg ) *4 ; -/* we do not control the vmid in DIQ mode, just a place holder */ -unsigned int vmid =0 ; - - addrHi.u32All =0 ; - addrLo.u32All =0 ; - cntl.u32All =0 ; - -if ((adw_info->num_watch_points >MAX_WATCH_ADDRESSES ) || - (adw_info->num_watch_points ==0 )) { -pr_err ("num_watch_points is invalid\n" ); -return -EINVAL ; - } - -if (!adw_info->watch_mode || !adw_info->watch_address) { -pr_err ("adw_info fields are not valid\n" ); -return -EINVAL ; - } - - status =kfd_gtt_sa_allocate (dbgdev->dev, ib_size, &mem_obj); - -if (status) { -pr_err ("Failed to allocate GART memory\n" ); -return status; - } - - packet_buff_uint = mem_obj->cpu_ptr; - -memset (packet_buff_uint,0 , ib_size); - - packets_vec = (struct pm4__set_config_reg *) (packet_buff_uint); - - packets_vec[0 ].header.count =1 ; - packets_vec[0 ].header.opcode =IT_SET_CONFIG_REG ; - packets_vec[0 ].header.type =PM4_TYPE_3 ; - packets_vec[0 ].bitfields2.vmid_shift =ADDRESS_WATCH_CNTL_OFFSET ; - packets_vec[0 ].bitfields2.insert_vmid =1 ; - packets_vec[1 ].ordinal1 = packets_vec[0 ].ordinal1; - packets_vec[1 ].bitfields2.insert_vmid =0 ; - packets_vec[2 ].ordinal1 = packets_vec[0 ].ordinal1; - packets_vec[2 ].bitfields2.insert_vmid =0 ; - packets_vec[3 ].ordinal1 = packets_vec[0 ].ordinal1; - packets_vec[3 ].bitfields2.vmid_shift =ADDRESS_WATCH_CNTL_OFFSET ; - packets_vec[3 ].bitfields2.insert_vmid =1 ; - -for (i =0 ; i < adw_info->num_watch_points; i++) { -dbgdev_address_watch_set_registers (adw_info, - &addrHi, - &addrLo, - &cntl, - i, - vmid); - -pr_debug ("\t\t%30s\n" ,"* * * * * * * * * * * * * * * * * *" ); -pr_debug ("\t\t%20s %08x\n" ,"register index :" , i); -pr_debug ("\t\t%20s %08x\n" ,"vmid is :" , vmid); -pr_debug ("\t\t%20s %p\n" ,"Add ptr is :" , - adw_info->watch_address); -pr_debug ("\t\t%20s %08llx\n" ,"Add is :" , - adw_info->watch_address[i]); -pr_debug ("\t\t%20s %08x\n" ,"Address Low is :" , - addrLo.bitfields.addr); -pr_debug ("\t\t%20s %08x\n" ,"Address high is :" , - addrHi.bitfields.addr); -pr_debug ("\t\t%20s %08x\n" ,"Control Mask is :" , - cntl.bitfields.mask); -pr_debug ("\t\t%20s %08x\n" ,"Control Mode is :" , - cntl.bitfields.mode); -pr_debug ("\t\t%20s %08x\n" ,"Control Vmid is :" , - cntl.bitfields.vmid); -pr_debug ("\t\t%20s %08x\n" ,"Control atc is :" , - cntl.bitfields.atc); -pr_debug ("\t\t%30s\n" ,"* * * * * * * * * * * * * * * * * *" ); - - aw_reg_add_dword = - dbgdev->dev->kfd2kgd->address_watch_get_offset ( - dbgdev->dev->adev, - i, -ADDRESS_WATCH_REG_CNTL ); - - packets_vec[0 ].bitfields2.reg_offset = - aw_reg_add_dword -AMD_CONFIG_REG_BASE ; - - packets_vec[0 ].reg_data[0 ] = cntl.u32All; - - aw_reg_add_dword = - dbgdev->dev->kfd2kgd->address_watch_get_offset ( - dbgdev->dev->adev, - i, -ADDRESS_WATCH_REG_ADDR_HI ); - - packets_vec[1 ].bitfields2.reg_offset = - aw_reg_add_dword -AMD_CONFIG_REG_BASE ; - packets_vec[1 ].reg_data[0 ] = addrHi.u32All; - - aw_reg_add_dword = - dbgdev->dev->kfd2kgd->address_watch_get_offset ( - dbgdev->dev->adev, - i, -ADDRESS_WATCH_REG_ADDR_LO ); - - packets_vec[2 ].bitfields2.reg_offset = - aw_reg_add_dword -AMD_CONFIG_REG_BASE ; - packets_vec[2 ].reg_data[0 ] = addrLo.u32All; - -/* enable watch flag if address is not zero*/ -if (adw_info->watch_address[i] >0 ) - cntl.bitfields.valid =1 ; -else - cntl.bitfields.valid =0 ; - - aw_reg_add_dword = - dbgdev->dev->kfd2kgd->address_watch_get_offset ( - dbgdev->dev->adev, - i, -ADDRESS_WATCH_REG_CNTL ); - - packets_vec[3 ].bitfields2.reg_offset = - aw_reg_add_dword -AMD_CONFIG_REG_BASE ; - packets_vec[3 ].reg_data[0 ] = cntl.u32All; - - status =dbgdev_diq_submit_ib ( - dbgdev, - adw_info->process->pasid, - mem_obj->gpu_addr, - packet_buff_uint, - ib_size); - -if (status) { -pr_err ("Failed to submit IB to DIQ\n" ); -break ; - } - } - -kfd_gtt_sa_free (dbgdev->dev, mem_obj); -return status; -} - -static int dbgdev_wave_control_set_registers ( -struct dbg_wave_control_info *wac_info, -union SQ_CMD_BITS *in_reg_sq_cmd, -union GRBM_GFX_INDEX_BITS *in_reg_gfx_index) -{ -int status =0 ; -union SQ_CMD_BITS reg_sq_cmd; -union GRBM_GFX_INDEX_BITS reg_gfx_index; -struct HsaDbgWaveMsgAMDGen2 *pMsg; - - reg_sq_cmd.u32All =0 ; - reg_gfx_index.u32All =0 ; - pMsg = &wac_info->dbgWave_msg.DbgWaveMsg.WaveMsgInfoGen2; - -switch (wac_info->mode) { -/* Send command to single wave */ -case HSA_DBG_WAVEMODE_SINGLE : -/* -* Limit access to the process waves only, -* by setting vmid check -*/ - reg_sq_cmd.bits.check_vmid =1 ; - reg_sq_cmd.bits.simd_id = pMsg->ui32.SIMD; - reg_sq_cmd.bits.wave_id = pMsg->ui32.WaveId; - reg_sq_cmd.bits.mode =SQ_IND_CMD_MODE_SINGLE ; - - reg_gfx_index.bits.sh_index = pMsg->ui32.ShaderArray; - reg_gfx_index.bits.se_index = pMsg->ui32.ShaderEngine; - reg_gfx_index.bits.instance_index = pMsg->ui32.HSACU; - -break ; - -/* Send command to all waves with matching VMID */ -case HSA_DBG_WAVEMODE_BROADCAST_PROCESS : - - reg_gfx_index.bits.sh_broadcast_writes =1 ; - reg_gfx_index.bits.se_broadcast_writes =1 ; - reg_gfx_index.bits.instance_broadcast_writes =1 ; - - reg_sq_cmd.bits.mode =SQ_IND_CMD_MODE_BROADCAST ; - -break ; - -/* Send command to all CU waves with matching VMID */ -case HSA_DBG_WAVEMODE_BROADCAST_PROCESS_CU : - - reg_sq_cmd.bits.check_vmid =1 ; - reg_sq_cmd.bits.mode =SQ_IND_CMD_MODE_BROADCAST ; - - reg_gfx_index.bits.sh_index = pMsg->ui32.ShaderArray; - reg_gfx_index.bits.se_index = pMsg->ui32.ShaderEngine; - reg_gfx_index.bits.instance_index = pMsg->ui32.HSACU; - -break ; - -default : -return -EINVAL ; - } - -switch (wac_info->operand) { -case HSA_DBG_WAVEOP_HALT : - reg_sq_cmd.bits.cmd =SQ_IND_CMD_CMD_HALT ; -break ; - -case HSA_DBG_WAVEOP_RESUME : - reg_sq_cmd.bits.cmd =SQ_IND_CMD_CMD_RESUME ; -break ; - -case HSA_DBG_WAVEOP_KILL : - reg_sq_cmd.bits.cmd =SQ_IND_CMD_CMD_KILL ; -break ; - -case HSA_DBG_WAVEOP_DEBUG : - reg_sq_cmd.bits.cmd =SQ_IND_CMD_CMD_DEBUG ; -break ; - -case HSA_DBG_WAVEOP_TRAP : -if (wac_info->trapId <MAX_TRAPID ) { - reg_sq_cmd.bits.cmd =SQ_IND_CMD_CMD_TRAP ; - reg_sq_cmd.bits.trap_id = wac_info->trapId; - }else { - status = -EINVAL ; - } -break ; - -default : - status = -EINVAL ; -break ; - } - -if (status ==0 ) { - *in_reg_sq_cmd = reg_sq_cmd; - *in_reg_gfx_index = reg_gfx_index; - } - -return status; -} - -static int dbgdev_wave_control_diq (struct kfd_dbgdev *dbgdev, -struct dbg_wave_control_info *wac_info) -{ - -int status; -union SQ_CMD_BITS reg_sq_cmd; -union GRBM_GFX_INDEX_BITS reg_gfx_index; -struct kfd_mem_obj *mem_obj; -uint32_t *packet_buff_uint; -struct pm4__set_config_reg *packets_vec; -size_t ib_size =sizeof (struct pm4__set_config_reg ) *3 ; - - reg_sq_cmd.u32All =0 ; - - status =dbgdev_wave_control_set_registers (wac_info, ®_sq_cmd, - ®_gfx_index); -if (status) { -pr_err ("Failed to set wave control registers\n" ); -return status; - } - -/* we do not control the VMID in DIQ, so reset it to a known value */ - reg_sq_cmd.bits.vm_id =0 ; - -pr_debug ("\t\t %30s\n" ,"* * * * * * * * * * * * * * * * * *" ); - -pr_debug ("\t\t mode is: %u\n" , wac_info->mode); -pr_debug ("\t\t operand is: %u\n" , wac_info->operand); -pr_debug ("\t\t trap id is: %u\n" , wac_info->trapId); -pr_debug ("\t\t msg value is: %u\n" , - wac_info->dbgWave_msg.DbgWaveMsg.WaveMsgInfoGen2.Value); -pr_debug ("\t\t vmid is: N/A\n" ); - -pr_debug ("\t\t chk_vmid is : %u\n" , reg_sq_cmd.bitfields.check_vmid); -pr_debug ("\t\t command is : %u\n" , reg_sq_cmd.bitfields.cmd); -pr_debug ("\t\t queue id is : %u\n" , reg_sq_cmd.bitfields.queue_id); -pr_debug ("\t\t simd id is : %u\n" , reg_sq_cmd.bitfields.simd_id); -pr_debug ("\t\t mode is : %u\n" , reg_sq_cmd.bitfields.mode); -pr_debug ("\t\t vm_id is : %u\n" , reg_sq_cmd.bitfields.vm_id); -pr_debug ("\t\t wave_id is : %u\n" , reg_sq_cmd.bitfields.wave_id); - -pr_debug ("\t\t ibw is : %u\n" , - reg_gfx_index.bitfields.instance_broadcast_writes); -pr_debug ("\t\t ii is : %u\n" , - reg_gfx_index.bitfields.instance_index); -pr_debug ("\t\t sebw is : %u\n" , - reg_gfx_index.bitfields.se_broadcast_writes); -pr_debug ("\t\t se_ind is : %u\n" , reg_gfx_index.bitfields.se_index); -pr_debug ("\t\t sh_ind is : %u\n" , reg_gfx_index.bitfields.sh_index); -pr_debug ("\t\t sbw is : %u\n" , - reg_gfx_index.bitfields.sh_broadcast_writes); - -pr_debug ("\t\t %30s\n" ,"* * * * * * * * * * * * * * * * * *" ); - - status =kfd_gtt_sa_allocate (dbgdev->dev, ib_size, &mem_obj); - -if (status !=0 ) { -pr_err ("Failed to allocate GART memory\n" ); -return status; - } - - packet_buff_uint = mem_obj->cpu_ptr; - -memset (packet_buff_uint,0 , ib_size); - - packets_vec = (struct pm4__set_config_reg *) packet_buff_uint; - packets_vec[0 ].header.count =1 ; - packets_vec[0 ].header.opcode =IT_SET_UCONFIG_REG ; - packets_vec[0 ].header.type =PM4_TYPE_3 ; - packets_vec[0 ].bitfields2.reg_offset = -GRBM_GFX_INDEX /4 -USERCONFIG_REG_BASE ; - - packets_vec[0 ].bitfields2.insert_vmid =0 ; - packets_vec[0 ].reg_data[0 ] = reg_gfx_index.u32All; - - packets_vec[1 ].header.count =1 ; - packets_vec[1 ].header.opcode =IT_SET_CONFIG_REG ; - packets_vec[1 ].header.type =PM4_TYPE_3 ; - packets_vec[1 ].bitfields2.reg_offset =SQ_CMD /4 -AMD_CONFIG_REG_BASE ; - - packets_vec[1 ].bitfields2.vmid_shift =SQ_CMD_VMID_OFFSET ; - packets_vec[1 ].bitfields2.insert_vmid =1 ; - packets_vec[1 ].reg_data[0 ] = reg_sq_cmd.u32All; - -/* Restore the GRBM_GFX_INDEX register */ - - reg_gfx_index.u32All =0 ; - reg_gfx_index.bits.sh_broadcast_writes =1 ; - reg_gfx_index.bits.instance_broadcast_writes =1 ; - reg_gfx_index.bits.se_broadcast_writes =1 ; - - - packets_vec[2 ].ordinal1 = packets_vec[0 ].ordinal1; - packets_vec[2 ].bitfields2.reg_offset = -GRBM_GFX_INDEX /4 -USERCONFIG_REG_BASE ; - - packets_vec[2 ].bitfields2.insert_vmid =0 ; - packets_vec[2 ].reg_data[0 ] = reg_gfx_index.u32All; - - status =dbgdev_diq_submit_ib ( - dbgdev, - wac_info->process->pasid, - mem_obj->gpu_addr, - packet_buff_uint, - ib_size); - -if (status) -pr_err ("Failed to submit IB to DIQ\n" ); - -kfd_gtt_sa_free (dbgdev->dev, mem_obj); - -return status; -} - -static int dbgdev_wave_control_nodiq (struct kfd_dbgdev *dbgdev, -struct dbg_wave_control_info *wac_info) -{ -int status; -union SQ_CMD_BITS reg_sq_cmd; -union GRBM_GFX_INDEX_BITS reg_gfx_index; -struct kfd_process_device *pdd; - - reg_sq_cmd.u32All =0 ; - -/* taking the VMID for that process on the safe way using PDD */ - pdd =kfd_get_process_device_data (dbgdev->dev, wac_info->process); - -if (!pdd) { -pr_err ("Failed to get pdd for wave control no DIQ\n" ); -return -EFAULT ; - } - status =dbgdev_wave_control_set_registers (wac_info, ®_sq_cmd, - ®_gfx_index); -if (status) { -pr_err ("Failed to set wave control registers\n" ); -return status; - } - -/* for non DIQ we need to patch the VMID: */ - - reg_sq_cmd.bits.vm_id = pdd->qpd.vmid; - -pr_debug ("\t\t %30s\n" ,"* * * * * * * * * * * * * * * * * *" ); - -pr_debug ("\t\t mode is: %u\n" , wac_info->mode); -pr_debug ("\t\t operand is: %u\n" , wac_info->operand); -pr_debug ("\t\t trap id is: %u\n" , wac_info->trapId); -pr_debug ("\t\t msg value is: %u\n" , - wac_info->dbgWave_msg.DbgWaveMsg.WaveMsgInfoGen2.Value); -pr_debug ("\t\t vmid is: %u\n" , pdd->qpd.vmid); - -pr_debug ("\t\t chk_vmid is : %u\n" , reg_sq_cmd.bitfields.check_vmid); -pr_debug ("\t\t command is : %u\n" , reg_sq_cmd.bitfields.cmd); -pr_debug ("\t\t queue id is : %u\n" , reg_sq_cmd.bitfields.queue_id); -pr_debug ("\t\t simd id is : %u\n" , reg_sq_cmd.bitfields.simd_id); -pr_debug ("\t\t mode is : %u\n" , reg_sq_cmd.bitfields.mode); -pr_debug ("\t\t vm_id is : %u\n" , reg_sq_cmd.bitfields.vm_id); -pr_debug ("\t\t wave_id is : %u\n" , reg_sq_cmd.bitfields.wave_id); - -pr_debug ("\t\t ibw is : %u\n" , - reg_gfx_index.bitfields.instance_broadcast_writes); -pr_debug ("\t\t ii is : %u\n" , - reg_gfx_index.bitfields.instance_index); -pr_debug ("\t\t sebw is : %u\n" , - reg_gfx_index.bitfields.se_broadcast_writes); -pr_debug ("\t\t se_ind is : %u\n" , reg_gfx_index.bitfields.se_index); -pr_debug ("\t\t sh_ind is : %u\n" , reg_gfx_index.bitfields.sh_index); -pr_debug ("\t\t sbw is : %u\n" , - reg_gfx_index.bitfields.sh_broadcast_writes); - -pr_debug ("\t\t %30s\n" ,"* * * * * * * * * * * * * * * * * *" ); - -return dbgdev->dev->kfd2kgd->wave_control_execute (dbgdev->dev->adev, - reg_gfx_index.u32All, - reg_sq_cmd.u32All); -} - -int dbgdev_wave_reset_wavefronts (struct kfd_dev *dev,struct kfd_process *p) -{ -int status =0 ; -unsigned int vmid; -uint16_t queried_pasid; -union SQ_CMD_BITS reg_sq_cmd; -union GRBM_GFX_INDEX_BITS reg_gfx_index; -struct kfd_process_device *pdd; -struct dbg_wave_control_info wac_info; -int first_vmid_to_scan = dev->vm_info.first_vmid_kfd; -int last_vmid_to_scan = dev->vm_info.last_vmid_kfd; - - reg_sq_cmd.u32All =0 ; - status =0 ; - - wac_info.mode =HSA_DBG_WAVEMODE_BROADCAST_PROCESS ; - wac_info.operand =HSA_DBG_WAVEOP_KILL ; - -pr_debug ("Killing all process wavefronts\n" ); - -/* Scan all registers in the range ATC_VMID8_PASID_MAPPING .. -* ATC_VMID15_PASID_MAPPING -* to check which VMID the current process is mapped to. -*/ - -for (vmid = first_vmid_to_scan; vmid <= last_vmid_to_scan; vmid++) { - status = dev->kfd2kgd->get_atc_vmid_pasid_mapping_info - (dev->adev, vmid, &queried_pasid); - -if (status && queried_pasid == p->pasid) { -pr_debug ("Killing wave fronts of vmid %d and pasid 0x%x\n" , - vmid, p->pasid); -break ; - } - } - -if (vmid > last_vmid_to_scan) { -pr_err ("Didn't find vmid for pasid 0x%x\n" , p->pasid); -return -EFAULT ; - } - -/* taking the VMID for that process on the safe way using PDD */ - pdd =kfd_get_process_device_data (dev, p); -if (!pdd) -return -EFAULT ; - - status =dbgdev_wave_control_set_registers (&wac_info, ®_sq_cmd, - ®_gfx_index); -if (status !=0 ) -return -EINVAL ; - -/* for non DIQ we need to patch the VMID: */ - reg_sq_cmd.bits.vm_id = vmid; - - dev->kfd2kgd->wave_control_execute (dev->adev, - reg_gfx_index.u32All, - reg_sq_cmd.u32All); - -return 0 ; -} - -void kfd_dbgdev_init (struct kfd_dbgdev *pdbgdev,struct kfd_dev *pdev, -enum DBGDEV_TYPE type) -{ - pdbgdev->dev = pdev; - pdbgdev->kq =NULL ; - pdbgdev->type = type; - pdbgdev->pqm =NULL ; - -switch (type) { -case DBGDEV_TYPE_NODIQ : - pdbgdev->dbgdev_register = dbgdev_register_nodiq; - pdbgdev->dbgdev_unregister = dbgdev_unregister_nodiq; - pdbgdev->dbgdev_wave_control = dbgdev_wave_control_nodiq; - pdbgdev->dbgdev_address_watch = dbgdev_address_watch_nodiq; -break ; -case DBGDEV_TYPE_DIQ : -default : - pdbgdev->dbgdev_register = dbgdev_register_diq; - pdbgdev->dbgdev_unregister = dbgdev_unregister_diq; - pdbgdev->dbgdev_wave_control = dbgdev_wave_control_diq; - pdbgdev->dbgdev_address_watch = dbgdev_address_watch_diq; -break ; - } - -}drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-230@@ -1,230 +0,0 @@ -/* -* Copyright 2014 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR -* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -* OTHER DEALINGS IN THE SOFTWARE. -*/ - -#ifndef KFD_DBGDEV_H_ -#define KFD_DBGDEV_H_ - -enum { -SQ_CMD_VMID_OFFSET =28 , -ADDRESS_WATCH_CNTL_OFFSET =24 -}; - -enum { -PRIV_QUEUE_SYNC_TIME_MS =200 -}; - -/* CONTEXT reg space definition */ -enum { -CONTEXT_REG_BASE =0xA000 , -CONTEXT_REG_END =0xA400 , -CONTEXT_REG_SIZE =CONTEXT_REG_END -CONTEXT_REG_BASE -}; - -/* USER CONFIG reg space definition */ -enum { -USERCONFIG_REG_BASE =0xC000 , -USERCONFIG_REG_END =0x10000 , -USERCONFIG_REG_SIZE =USERCONFIG_REG_END -USERCONFIG_REG_BASE -}; - -/* CONFIG reg space definition */ -enum { -AMD_CONFIG_REG_BASE =0x2000 ,/* in dwords */ -AMD_CONFIG_REG_END =0x2B00 , -AMD_CONFIG_REG_SIZE =AMD_CONFIG_REG_END -AMD_CONFIG_REG_BASE -}; - -/* SH reg space definition */ -enum { -SH_REG_BASE =0x2C00 , -SH_REG_END =0x3000 , -SH_REG_SIZE =SH_REG_END -SH_REG_BASE -}; - -/* SQ_CMD definitions */ -#define SQ_CMD 0x8DEC - -enum SQ_IND_CMD_CMD { -SQ_IND_CMD_CMD_NULL =0x00000000 , -SQ_IND_CMD_CMD_HALT =0x00000001 , -SQ_IND_CMD_CMD_RESUME =0x00000002 , -SQ_IND_CMD_CMD_KILL =0x00000003 , -SQ_IND_CMD_CMD_DEBUG =0x00000004 , -SQ_IND_CMD_CMD_TRAP =0x00000005 , -}; - -enum SQ_IND_CMD_MODE { -SQ_IND_CMD_MODE_SINGLE =0x00000000 , -SQ_IND_CMD_MODE_BROADCAST =0x00000001 , -SQ_IND_CMD_MODE_BROADCAST_QUEUE =0x00000002 , -SQ_IND_CMD_MODE_BROADCAST_PIPE =0x00000003 , -SQ_IND_CMD_MODE_BROADCAST_ME =0x00000004 , -}; - -union SQ_IND_INDEX_BITS { -struct { -uint32_t wave_id:4 ; -uint32_t simd_id:2 ; -uint32_t thread_id:6 ; - uint32_t:1; -uint32_t force_read:1 ; -uint32_t read_timeout:1 ; -uint32_t unindexed:1 ; -uint32_t index:16 ; - - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -union SQ_IND_CMD_BITS { -struct { -uint32_t data:32 ; - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -union SQ_CMD_BITS { -struct { -uint32_t cmd:3 ; - uint32_t:1; -uint32_t mode:3 ; -uint32_t check_vmid:1 ; -uint32_t trap_id:3 ; - uint32_t:5; -uint32_t wave_id:4 ; -uint32_t simd_id:2 ; - uint32_t:2; -uint32_t queue_id:3 ; - uint32_t:1; -uint32_t vm_id:4 ; - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -union SQ_IND_DATA_BITS { -struct { -uint32_t data:32 ; - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -union GRBM_GFX_INDEX_BITS { -struct { -uint32_t instance_index:8 ; -uint32_t sh_index:8 ; -uint32_t se_index:8 ; - uint32_t:5; -uint32_t sh_broadcast_writes:1 ; -uint32_t instance_broadcast_writes:1 ; -uint32_t se_broadcast_writes:1 ; - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -union TCP_WATCH_ADDR_H_BITS { -struct { -uint32_t addr:16 ; - uint32_t:16; - - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -union TCP_WATCH_ADDR_L_BITS { -struct { - uint32_t:6; -uint32_t addr:26 ; - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -enum { -QUEUESTATE__INVALID =0 ,/* so by default we'll get invalid state */ -QUEUESTATE__ACTIVE_COMPLETION_PENDING , -QUEUESTATE__ACTIVE -}; - -union ULARGE_INTEGER { -struct { -uint32_t low_part; -uint32_t high_part; - } u; -unsigned long long quad_part; -}; - - -#define KFD_CIK_VMID_START_OFFSET (8) -#define KFD_CIK_VMID_END_OFFSET (KFD_CIK_VMID_START_OFFSET + (8)) - - -void kfd_dbgdev_init (struct kfd_dbgdev *pdbgdev,struct kfd_dev *pdev, -enum DBGDEV_TYPE type); - -union TCP_WATCH_CNTL_BITS { -struct { -uint32_t mask:24 ; -uint32_t vmid:4 ; -uint32_t atc:1 ; -uint32_t mode:2 ; -uint32_t valid:1 ; - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -enum { -ADDRESS_WATCH_REG_CNTL_ATC_BIT =0x10000000UL , -ADDRESS_WATCH_REG_CNTL_DEFAULT_MASK =0x00FFFFFF , -ADDRESS_WATCH_REG_ADDLOW_MASK_EXTENSION =0x03000000 , -/* extend the mask to 26 bits in order to match the low address field */ -ADDRESS_WATCH_REG_ADDLOW_SHIFT =6 , -ADDRESS_WATCH_REG_ADDHIGH_MASK =0xFFFF -}; - -enum { -MAX_TRAPID =8 ,/* 3 bits in the bitfield. */ -MAX_WATCH_ADDRESSES =4 -}; - -enum { -ADDRESS_WATCH_REG_ADDR_HI =0 , -ADDRESS_WATCH_REG_ADDR_LO , -ADDRESS_WATCH_REG_CNTL , -ADDRESS_WATCH_REG_MAX -}; - -#endif /* KFD_DBGDEV_H_ */ drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-158@@ -1,158 +0,0 @@ -/* -* Copyright 2014 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR -* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -* OTHER DEALINGS IN THE SOFTWARE. -* -*/ -#include <linux/types.h> -#include <linux/kernel.h> -#include <linux/log2.h> -#include <linux/sched.h> -#include <linux/slab.h> -#include <linux/device.h> - -#include "kfd_priv.h" -#include "cik_regs.h" -#include "kfd_pm4_headers.h" -#include "kfd_pm4_headers_diq.h" -#include "kfd_dbgmgr.h" -#include "kfd_dbgdev.h" -#include "kfd_device_queue_manager.h" - -static DEFINE_MUTEX (kfd_dbgmgr_mutex); - -struct mutex *kfd_get_dbgmgr_mutex (void ) -{ -return &kfd_dbgmgr_mutex; -} - - -static void kfd_dbgmgr_uninitialize (struct kfd_dbgmgr *pmgr) -{ -kfree (pmgr->dbgdev); - - pmgr->dbgdev =NULL ; - pmgr->pasid =0 ; - pmgr->dev =NULL ; -} - -void kfd_dbgmgr_destroy (struct kfd_dbgmgr *pmgr) -{ -if (pmgr) { -kfd_dbgmgr_uninitialize (pmgr); -kfree (pmgr); - } -} - -bool kfd_dbgmgr_create (struct kfd_dbgmgr **ppmgr,struct kfd_dev *pdev) -{ -enum DBGDEV_TYPE type =DBGDEV_TYPE_DIQ ; -struct kfd_dbgmgr *new_buff; - -if (WARN_ON (!pdev->init_complete)) -return false; - - new_buff =kfd_alloc_struct (new_buff); -if (!new_buff) { -pr_err ("Failed to allocate dbgmgr instance\n" ); -return false; - } - - new_buff->pasid =0 ; - new_buff->dev = pdev; - new_buff->dbgdev =kfd_alloc_struct (new_buff->dbgdev); -if (!new_buff->dbgdev) { -pr_err ("Failed to allocate dbgdev instance\n" ); -kfree (new_buff); -return false; - } - -/* get actual type of DBGDevice cpsch or not */ -if (pdev->dqm->sched_policy ==KFD_SCHED_POLICY_NO_HWS ) - type =DBGDEV_TYPE_NODIQ ; - -kfd_dbgdev_init (new_buff->dbgdev, pdev, type); - *ppmgr = new_buff; - -return true; -} - -long kfd_dbgmgr_register (struct kfd_dbgmgr *pmgr,struct kfd_process *p) -{ -if (pmgr->pasid !=0 ) { -pr_debug ("H/W debugger is already active using pasid 0x%x\n" , - pmgr->pasid); -return -EBUSY ; - } - -/* remember pasid */ - pmgr->pasid = p->pasid; - -/* provide the pqm for diq generation */ - pmgr->dbgdev->pqm = &p->pqm; - -/* activate the actual registering */ - pmgr->dbgdev->dbgdev_register (pmgr->dbgdev); - -return 0 ; -} - -long kfd_dbgmgr_unregister (struct kfd_dbgmgr *pmgr,struct kfd_process *p) -{ -/* Is the requests coming from the already registered process? */ -if (pmgr->pasid != p->pasid) { -pr_debug ("H/W debugger is not registered by calling pasid 0x%x\n" , - p->pasid); -return -EINVAL ; - } - - pmgr->dbgdev->dbgdev_unregister (pmgr->dbgdev); - - pmgr->pasid =0 ; - -return 0 ; -} - -long kfd_dbgmgr_wave_control (struct kfd_dbgmgr *pmgr, -struct dbg_wave_control_info *wac_info) -{ -/* Is the requests coming from the already registered process? */ -if (pmgr->pasid != wac_info->process->pasid) { -pr_debug ("H/W debugger support was not registered for requester pasid 0x%x\n" , - wac_info->process->pasid); -return -EINVAL ; - } - -return (long ) pmgr->dbgdev->dbgdev_wave_control (pmgr->dbgdev, wac_info); -} - -long kfd_dbgmgr_address_watch (struct kfd_dbgmgr *pmgr, -struct dbg_address_watch_info *adw_info) -{ -/* Is the requests coming from the already registered process? */ -if (pmgr->pasid != adw_info->process->pasid) { -pr_debug ("H/W debugger support was not registered for requester pasid 0x%x\n" , - adw_info->process->pasid); -return -EINVAL ; - } - -return (long ) pmgr->dbgdev->dbgdev_address_watch (pmgr->dbgdev, - adw_info); -} -drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-293@@ -1,293 +0,0 @@ -/* -* Copyright 2014 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR -* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -* OTHER DEALINGS IN THE SOFTWARE. -* -*/ - -#ifndef KFD_DBGMGR_H_ -#define KFD_DBGMGR_H_ - -#include "kfd_priv.h" - -/* must align with hsakmttypes definition */ -#pragma pack(push, 4) - -enum HSA_DBG_WAVEOP { -HSA_DBG_WAVEOP_HALT =1 ,/* Halts a wavefront */ -HSA_DBG_WAVEOP_RESUME =2 ,/* Resumes a wavefront */ -HSA_DBG_WAVEOP_KILL =3 ,/* Kills a wavefront */ -HSA_DBG_WAVEOP_DEBUG =4 ,/* Causes wavefront to enter dbg mode */ -HSA_DBG_WAVEOP_TRAP =5 ,/* Causes wavefront to take a trap */ -HSA_DBG_NUM_WAVEOP =5 , -HSA_DBG_MAX_WAVEOP =0xFFFFFFFF -}; - -enum HSA_DBG_WAVEMODE { -/* send command to a single wave */ -HSA_DBG_WAVEMODE_SINGLE =0 , -/* -* Broadcast to all wavefronts of all processes is not -* supported for HSA user mode -*/ - -/* send to waves within current process */ -HSA_DBG_WAVEMODE_BROADCAST_PROCESS =2 , -/* send to waves within current process on CU */ -HSA_DBG_WAVEMODE_BROADCAST_PROCESS_CU =3 , -HSA_DBG_NUM_WAVEMODE =3 , -HSA_DBG_MAX_WAVEMODE =0xFFFFFFFF -}; - -enum HSA_DBG_WAVEMSG_TYPE { -HSA_DBG_WAVEMSG_AUTO =0 , -HSA_DBG_WAVEMSG_USER =1 , -HSA_DBG_WAVEMSG_ERROR =2 , -HSA_DBG_NUM_WAVEMSG , -HSA_DBG_MAX_WAVEMSG =0xFFFFFFFF -}; - -enum HSA_DBG_WATCH_MODE { -HSA_DBG_WATCH_READ =0 ,/* Read operations only */ -HSA_DBG_WATCH_NONREAD =1 ,/* Write or Atomic operations only */ -HSA_DBG_WATCH_ATOMIC =2 ,/* Atomic Operations only */ -HSA_DBG_WATCH_ALL =3 ,/* Read, Write or Atomic operations */ -HSA_DBG_WATCH_NUM , -HSA_DBG_WATCH_SIZE =0xFFFFFFFF -}; - -/* This structure is hardware specific and may change in the future */ -struct HsaDbgWaveMsgAMDGen2 { -union { -struct ui32 { -uint32_t UserData:8 ;/* user data */ -uint32_t ShaderArray:1 ;/* Shader array */ -uint32_t Priv:1 ;/* Privileged */ -uint32_t Reserved0:4 ;/* Reserved, should be 0 */ -uint32_t WaveId:4 ;/* wave id */ -uint32_t SIMD:2 ;/* SIMD id */ -uint32_t HSACU:4 ;/* Compute unit */ -uint32_t ShaderEngine:2 ;/* Shader engine */ -uint32_t MessageType:2 ;/* see HSA_DBG_WAVEMSG_TYPE */ -uint32_t Reserved1:4 ;/* Reserved, should be 0 */ - } ui32; -uint32_t Value; - }; -uint32_t Reserved2; -}; - -union HsaDbgWaveMessageAMD { -struct HsaDbgWaveMsgAMDGen2 WaveMsgInfoGen2; -/* for future HsaDbgWaveMsgAMDGen3; */ -}; - -struct HsaDbgWaveMessage { -void *MemoryVA;/* ptr to associated host-accessible data */ -union HsaDbgWaveMessageAMD DbgWaveMsg; -}; - -/* -* TODO: This definitions to be MOVED to kfd_event, once it is implemented. -* -* HSA sync primitive, Event and HW Exception notification API definitions. -* The API functions allow the runtime to define a so-called sync-primitive, -* a SW object combining a user-mode provided "syncvar" and a scheduler event -* that can be signaled through a defined GPU interrupt. A syncvar is -* a process virtual memory location of a certain size that can be accessed -* by CPU and GPU shader code within the process to set and query the content -* within that memory. The definition of the content is determined by the HSA -* runtime and potentially GPU shader code interfacing with the HSA runtime. -* The syncvar values may be commonly written through an PM4 WRITE_DATA packet -* in the user mode instruction stream. The OS scheduler event is typically -* associated and signaled by an interrupt issued by the GPU, but other HSA -* system interrupt conditions from other HW (e.g. IOMMUv2) may be surfaced -* by the KFD by this mechanism, too. -*/ - -/* these are the new definitions for events */ -enum HSA_EVENTTYPE { -HSA_EVENTTYPE_SIGNAL =0 ,/* user-mode generated GPU signal */ -HSA_EVENTTYPE_NODECHANGE =1 ,/* HSA node change (attach/detach) */ -HSA_EVENTTYPE_DEVICESTATECHANGE =2 ,/* HSA device state change -* (start/stop) -*/ -HSA_EVENTTYPE_HW_EXCEPTION =3 ,/* GPU shader exception event */ -HSA_EVENTTYPE_SYSTEM_EVENT =4 ,/* GPU SYSCALL with parameter info */ -HSA_EVENTTYPE_DEBUG_EVENT =5 ,/* GPU signal for debugging */ -HSA_EVENTTYPE_PROFILE_EVENT =6 ,/* GPU signal for profiling */ -HSA_EVENTTYPE_QUEUE_EVENT =7 ,/* GPU signal queue idle state -* (EOP pm4) -*/ -/* ... */ -HSA_EVENTTYPE_MAXID , -HSA_EVENTTYPE_TYPE_SIZE =0xFFFFFFFF -}; - -/* Sub-definitions for various event types: Syncvar */ -struct HsaSyncVar { -union SyncVar { -void *UserData;/* pointer to user mode data */ -uint64_t UserDataPtrValue;/* 64bit compatibility of value */ - } SyncVar; -uint64_t SyncVarSize; -}; - -/* Sub-definitions for various event types: NodeChange */ - -enum HSA_EVENTTYPE_NODECHANGE_FLAGS { -HSA_EVENTTYPE_NODECHANGE_ADD =0 , -HSA_EVENTTYPE_NODECHANGE_REMOVE =1 , -HSA_EVENTTYPE_NODECHANGE_SIZE =0xFFFFFFFF -}; - -struct HsaNodeChange { -/* HSA node added/removed on the platform */ -enum HSA_EVENTTYPE_NODECHANGE_FLAGS Flags; -}; - -/* Sub-definitions for various event types: DeviceStateChange */ -enum HSA_EVENTTYPE_DEVICESTATECHANGE_FLAGS { -/* device started (and available) */ -HSA_EVENTTYPE_DEVICESTATUSCHANGE_START =0 , -/* device stopped (i.e. unavailable) */ -HSA_EVENTTYPE_DEVICESTATUSCHANGE_STOP =1 , -HSA_EVENTTYPE_DEVICESTATUSCHANGE_SIZE =0xFFFFFFFF -}; - -enum HSA_DEVICE { -HSA_DEVICE_CPU =0 , -HSA_DEVICE_GPU =1 , -MAX_HSA_DEVICE =2 -}; - -struct HsaDeviceStateChange { -uint32_t NodeId;/* F-NUMA node that contains the device */ -enum HSA_DEVICE Device;/* device type: GPU or CPU */ -enum HSA_EVENTTYPE_DEVICESTATECHANGE_FLAGS Flags;/* event flags */ -}; - -struct HsaEventData { -enum HSA_EVENTTYPE EventType;/* event type */ -union EventData { -/* -* return data associated with HSA_EVENTTYPE_SIGNAL -* and other events -*/ -struct HsaSyncVar SyncVar; - -/* data associated with HSA_EVENTTYPE_NODE_CHANGE */ -struct HsaNodeChange NodeChangeState; - -/* data associated with HSA_EVENTTYPE_DEVICE_STATE_CHANGE */ -struct HsaDeviceStateChange DeviceState; - } EventData; - -/* the following data entries are internal to the KFD & thunk itself */ - -/* internal thunk store for Event data (OsEventHandle) */ -uint64_t HWData1; -/* internal thunk store for Event data (HWAddress) */ -uint64_t HWData2; -/* internal thunk store for Event data (HWData) */ -uint32_t HWData3; -}; - -struct HsaEventDescriptor { -/* event type to allocate */ -enum HSA_EVENTTYPE EventType; -/* H-NUMA node containing GPU device that is event source */ -uint32_t NodeId; -/* pointer to user mode syncvar data, syncvar->UserDataPtrValue -* may be NULL -*/ -struct HsaSyncVar SyncVar; -}; - -struct HsaEvent { -uint32_t EventId; -struct HsaEventData EventData; -}; - -#pragma pack(pop) - -enum DBGDEV_TYPE { -DBGDEV_TYPE_ILLEGAL =0 , -DBGDEV_TYPE_NODIQ =1 , -DBGDEV_TYPE_DIQ =2 , -DBGDEV_TYPE_TEST =3 -}; - -struct dbg_address_watch_info { -struct kfd_process *process; -enum HSA_DBG_WATCH_MODE *watch_mode; -uint64_t *watch_address; -uint64_t *watch_mask; -struct HsaEvent *watch_event; -uint32_t num_watch_points; -}; - -struct dbg_wave_control_info { -struct kfd_process *process; -uint32_t trapId; -enum HSA_DBG_WAVEOP operand; -enum HSA_DBG_WAVEMODE mode; -struct HsaDbgWaveMessage dbgWave_msg; -}; - -struct kfd_dbgdev { - -/* The device that owns this data. */ -struct kfd_dev *dev; - -/* kernel queue for DIQ */ -struct kernel_queue *kq; - -/* a pointer to the pqm of the calling process */ -struct process_queue_manager *pqm; - -/* type of debug device ( DIQ, non DIQ, etc. ) */ -enum DBGDEV_TYPE type; - -/* virtualized function pointers to device dbg */ -int (*dbgdev_register)(struct kfd_dbgdev *dbgdev); -int (*dbgdev_unregister)(struct kfd_dbgdev *dbgdev); -int (*dbgdev_address_watch)(struct kfd_dbgdev *dbgdev, -struct dbg_address_watch_info *adw_info); -int (*dbgdev_wave_control)(struct kfd_dbgdev *dbgdev, -struct dbg_wave_control_info *wac_info); - -}; - -struct kfd_dbgmgr { -u32 pasid; -struct kfd_dev *dev; -struct kfd_dbgdev *dbgdev; -}; - -/* prototypes for debug manager functions */ -struct mutex *kfd_get_dbgmgr_mutex (void ); -void kfd_dbgmgr_destroy (struct kfd_dbgmgr *pmgr); -bool kfd_dbgmgr_create (struct kfd_dbgmgr **ppmgr,struct kfd_dev *pdev); -long kfd_dbgmgr_register (struct kfd_dbgmgr *pmgr,struct kfd_process *p); -long kfd_dbgmgr_unregister (struct kfd_dbgmgr *pmgr,struct kfd_process *p); -long kfd_dbgmgr_wave_control (struct kfd_dbgmgr *pmgr, -struct dbg_wave_control_info *wac_info); -long kfd_dbgmgr_address_watch (struct kfd_dbgmgr *pmgr, -struct dbg_address_watch_info *adw_info); -#endif /* KFD_DBGMGR_H_ */ drivers/gpu/drm/amd/amdkfd/kfd_device.c +0
-2@@ -575,8 +575,6 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,if (kfd_resume (kfd)) goto kfd_resume_error; - kfd->dbgmgr =NULL ; -if (kfd_topology_add_device (kfd)) {dev_err (kfd_device,"Error adding device to topology\n" ); goto kfd_topology_add_device_error;drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +59
-0@@ -480,6 +480,65 @@ static inline void deallocate_hqd(struct device_queue_manager *dqm, dqm->allocated_queues[q->pipe] |= (1 << q->queue); } +#define SQ_IND_CMD_CMD_KILL 0x00000003 +#define SQ_IND_CMD_MODE_BROADCAST 0x00000001 + +static int dbgdev_wave_reset_wavefronts (struct kfd_dev *dev,struct kfd_process *p) +{ +int status =0 ; +unsigned int vmid; +uint16_t queried_pasid; +union SQ_CMD_BITS reg_sq_cmd; +union GRBM_GFX_INDEX_BITS reg_gfx_index; +struct kfd_process_device *pdd; +int first_vmid_to_scan = dev->vm_info.first_vmid_kfd; +int last_vmid_to_scan = dev->vm_info.last_vmid_kfd; + + reg_sq_cmd.u32All =0 ; + reg_gfx_index.u32All =0 ; + +pr_debug ("Killing all process wavefronts\n" ); + +/* Scan all registers in the range ATC_VMID8_PASID_MAPPING .. +* ATC_VMID15_PASID_MAPPING +* to check which VMID the current process is mapped to. +*/ + +for (vmid = first_vmid_to_scan; vmid <= last_vmid_to_scan; vmid++) { + status = dev->kfd2kgd->get_atc_vmid_pasid_mapping_info + (dev->adev, vmid, &queried_pasid); + +if (status && queried_pasid == p->pasid) { +pr_debug ("Killing wave fronts of vmid %d and pasid 0x%x\n" , + vmid, p->pasid); +break ; + } + } + +if (vmid > last_vmid_to_scan) { +pr_err ("Didn't find vmid for pasid 0x%x\n" , p->pasid); +return -EFAULT ; + } + +/* taking the VMID for that process on the safe way using PDD */ + pdd =kfd_get_process_device_data (dev, p); +if (!pdd) +return -EFAULT ; + + reg_gfx_index.bits.sh_broadcast_writes =1 ; + reg_gfx_index.bits.se_broadcast_writes =1 ; + reg_gfx_index.bits.instance_broadcast_writes =1 ; + reg_sq_cmd.bits.mode =SQ_IND_CMD_MODE_BROADCAST ; + reg_sq_cmd.bits.cmd =SQ_IND_CMD_CMD_KILL ; + reg_sq_cmd.bits.vm_id = vmid; + + dev->kfd2kgd->wave_control_execute (dev->adev, + reg_gfx_index.u32All, + reg_sq_cmd.u32All); + +return 0 ; +} +/* Access to DQM has to be locked before calling destroy_queue_nocpsch_locked * to avoid asynchronized access */ drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h +35
-0@@ -39,6 +39,41 @@ struct device_process_node {struct list_head list; }; +union SQ_CMD_BITS { +struct { +uint32_t cmd:3 ; + uint32_t:1; +uint32_t mode:3 ; +uint32_t check_vmid:1 ; +uint32_t trap_id:3 ; + uint32_t:5; +uint32_t wave_id:4 ; +uint32_t simd_id:2 ; + uint32_t:2; +uint32_t queue_id:3 ; + uint32_t:1; +uint32_t vm_id:4 ; + } bitfields, bits; +uint32_t u32All; +signed int i32All; +float f32All; +}; + +union GRBM_GFX_INDEX_BITS { +struct { +uint32_t instance_index:8 ; +uint32_t sh_index:8 ; +uint32_t se_index:8 ; + uint32_t:5; +uint32_t sh_broadcast_writes:1 ; +uint32_t instance_broadcast_writes:1 ; +uint32_t se_broadcast_writes:1 ; + } bitfields, bits; +uint32_t u32All; +signed int i32All; +float f32All; +}; +/** * struct device_queue_manager_ops * drivers/gpu/drm/amd/amdkfd/kfd_iommu.c +0
-12@@ -30,7 +30,6 @@#include <linux/pci.h> #include <linux/amd-iommu.h> #include "kfd_priv.h" -#include "kfd_dbgmgr.h" #include "kfd_topology.h" #include "kfd_iommu.h" @@ -163,17 +162,6 @@ static void iommu_pasid_shutdown_callback(struct pci_dev *pdev, u32 pasid)pr_debug ("Unbinding process 0x%x from IOMMU\n" , pasid); -mutex_lock (kfd_get_dbgmgr_mutex ()); - -if (dev->dbgmgr && dev->dbgmgr->pasid == p->pasid) { -if (!kfd_dbgmgr_unregister (dev->dbgmgr, p)) { -kfd_dbgmgr_destroy (dev->dbgmgr); - dev->dbgmgr =NULL ; - } - } - -mutex_unlock (kfd_get_dbgmgr_mutex ()); -mutex_lock (&p->mutex); pdd =kfd_get_process_device_data (dev, p);drivers/gpu/drm/amd/amdkfd/kfd_priv.h +0
-5@@ -300,9 +300,6 @@ struct kfd_dev {*/ bool interrupts_active; -/* Debug manager */ -struct kfd_dbgmgr *dbgmgr; -/* Firmware versions */ uint16_t mec_fw_version;uint16_t mec2_fw_version;@@ -1331,8 +1328,6 @@ void kfd_signal_poison_consumed_event(struct kfd_dev *dev, u32 pasid);void kfd_flush_tlb (struct kfd_process_device *pdd,enum TLB_FLUSH_TYPE type); -int dbgdev_wave_reset_wavefronts (struct kfd_dev *dev,struct kfd_process *p); -bool kfd_is_locked (void );/* Compute profile */ drivers/gpu/drm/amd/amdkfd/kfd_process.c +0
-19@@ -40,7 +40,6 @@ struct mm_struct;#include "kfd_priv.h" #include "kfd_device_queue_manager.h" -#include "kfd_dbgmgr.h" #include "kfd_iommu.h" #include "kfd_svm.h" @@ -1158,7 +1157,6 @@ static void kfd_process_notifier_release(struct mmu_notifier *mn, struct mm_struct *mm) {struct kfd_process *p; -int i;/* * The kfd_process structure can not be free because the @@ -1178,23 +1176,6 @@ static void kfd_process_notifier_release(struct mmu_notifier *mn,mutex_lock (&p->mutex); -/* Iterate over all process device data structures and if the -* pdd is in debug mode, we should first force unregistration, -* then we will be able to destroy the queues -*/ -for (i =0 ; i < p->n_pdds; i++) { -struct kfd_dev *dev = p->pdds[i]->dev; - -mutex_lock (kfd_get_dbgmgr_mutex ()); -if (dev && dev->dbgmgr && dev->dbgmgr->pasid == p->pasid) { -if (!kfd_dbgmgr_unregister (dev->dbgmgr, p)) { -kfd_dbgmgr_destroy (dev->dbgmgr); - dev->dbgmgr =NULL ; - } - } -mutex_unlock (kfd_get_dbgmgr_mutex ()); - } -kfd_process_dequeue_from_all_devices (p);pqm_uninit (&p->pqm);
RE: [PATCH 2/3] drm/amdkfd: Remove unused old debugger implementation
[AMD Official Use Only]
Quoted 14 lines
-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Monday, February 7, 2022 10:33 AM
To: Joshi, Mukul <[email protected]>; [email protected]
Subject: Re: [PATCH 2/3] drm/amdkfd: Remove unused old debugger implementationAm 2022-02-04 um 18:45 schrieb Mukul Joshi:
Quoted 5 lines
Cleanup the kfd code by removing the unused old debugger implementation.
Only a small piece of resetting wavefronts is kept and is moved tokfd_device_queue_manager.c
Quoted 8 lines
Quoted 1 line
Signed-off-by Mukul Joshi <[email protected]>We should update
include/uapi/linux/kfd_ioctl.has well to mark the ioctls as deprecated. Just rename the AMDKFD_IOC_DBG_* macros to AMDKFD_IOC_DBG_*_DEPRECATED. A corresponding update to the Thunk would
be good as a follow up.
Would it require an update to the KFD ioctl minor version?
Wouldn't it be better to just increment the minor version for ioctl and say these aren't supported after this version instead of changing the name?
Regards,
Mukul
Quoted 2,254 lines
I think there is also some more code you can remove in amdgpu_amdkfd_gfx_v*.c and
kgd_kfd_interface.h:int (*address_watch_disable)(struct
amdgpu_device*adev); int (*address_watch_execute)(structamdgpu_device*adev, unsigned intwatch_point_id,uint32_tcntl_val,uint32_taddr_hi,uint32_taddr_lo);uint32_t(*address_watch_get_offset)(structamdgpu_device*adev, unsigned intwatch_point_id, unsigned intreg_offset);It seems
wave_control_executeis still used indbgdev_wave_reset_wavefronts.Regards,
FelixQuoted 14 lines
--- drivers/gpu/drm/amd/amdkfd/Makefile | 2 - drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 282 +----- drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c | 845 ------------------ drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h | 230 ----- drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c | 158 ---- drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h | 293 ------ drivers/gpu/drm/amd/amdkfd/kfd_device.c | 2 - .../drm/amd/amdkfd/kfd_device_queue_manager.c | 59 ++ .../drm/amd/amdkfd/kfd_device_queue_manager.h | 35 + drivers/gpu/drm/amd/amdkfd/kfd_iommu.c | 12 - drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 5 - drivers/gpu/drm/amd/amdkfd/kfd_process.c | 19 - 12 files changed, 98 insertions(+), 1844 deletions(-)Review
Quoted 6 lines
delete mode 100644
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.cdelete mode 100644drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.hdelete mode 100644drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.cdelete mode 100644drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h(quoted diff) +0
-0b/drivers/gpu/drm/amd/amdkfd/Makefile
Review
Quoted 13 lines
index
c4f3aff11072..19cfbf9577b4100644drivers/gpu/drm/amd/amdkfd/Makefile +0
-2@@ -51,8 +51,6 @@ AMDKFD_FILES := $(AMDKFD_PATH)/kfd_module.o \ $(AMDKFD_PATH)/kfd_events.o \ $(AMDKFD_PATH)/cik_event_interrupt.o \ $(AMDKFD_PATH)/kfd_int_process_v9.o \ - $(AMDKFD_PATH)/kfd_dbgdev.o \ - $(AMDKFD_PATH)/kfd_dbgmgr.o \ $(AMDKFD_PATH)/kfd_smi_events.o \ $(AMDKFD_PATH)/kfd_crat.o(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.cdrivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file
Quoted 12 lines
index
64e3b4e3a712..cfe12525165f100644drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-1@@ -39,7 +39,6 @@#include <asm/processor.h> #include "kfd_priv.h" #include "kfd_device_queue_manager.h" -#include "kfd_dbgmgr.h" #include "kfd_svm.h" #include "amdgpu_amdkfd.h" #include "kfd_smi_events.h" @@ -580,299 +579,26 @@ static int kfd_ioctl_set_trap_handler(struct file*filep,
Quoted 121 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2
-106static int kfd_ioctl_dbg_register (struct file *filep,struct kfd_process *p,void *data) { -struct kfd_ioctl_dbg_register_args *args = data; -struct kfd_dev *dev; -struct kfd_dbgmgr *dbgmgr_ptr; -struct kfd_process_device *pdd; -bool create_ok; -long status =0 ; - -mutex_lock (&p->mutex); - pdd =kfd_process_device_data_by_id (p, args->gpu_id); -if (!pdd) { - status = -EINVAL ; - goto err_pdd; - } - dev = pdd->dev; - -if (dev->adev->asic_type ==CHIP_CARRIZO ) { -pr_debug ("kfd_ioctl_dbg_register not supported on CZ\n" ); - status = -EINVAL ; - goto err_chip_unsupp; - } - -mutex_lock (kfd_get_dbgmgr_mutex ()); - -/* -* make sure that we have pdd, if this the first queue created for -* this process -*/ - pdd =kfd_bind_process_to_device (dev, p); -if (IS_ERR (pdd)) { - status =PTR_ERR (pdd); - goto out; - } - -if (!dev->dbgmgr) { -/* In case of a legal call, we have no dbgmgr yet */ - create_ok =kfd_dbgmgr_create (&dbgmgr_ptr, dev); -if (create_ok) { - status =kfd_dbgmgr_register (dbgmgr_ptr, p); -if (status !=0 ) -kfd_dbgmgr_destroy (dbgmgr_ptr); -else - dev->dbgmgr = dbgmgr_ptr; - } - }else { -pr_debug ("debugger already registered\n" ); - status = -EINVAL ; - } - -out: -mutex_unlock (kfd_get_dbgmgr_mutex ()); -err_pdd: -err_chip_unsupp: -mutex_unlock (&p->mutex); - -return status; +return -EPERM ; }static int kfd_ioctl_dbg_unregister (struct file *filep,struct kfd_process *p,void *data) { -struct kfd_ioctl_dbg_unregister_args *args = data; -struct kfd_process_device *pdd; -struct kfd_dev *dev; -long status; - -mutex_lock (&p->mutex); - pdd =kfd_process_device_data_by_id (p, args->gpu_id); -mutex_unlock (&p->mutex); -if (!pdd || !pdd->dev->dbgmgr) -return -EINVAL ; - - dev = pdd->dev; - -if (dev->adev->asic_type ==CHIP_CARRIZO ) { -pr_debug ("kfd_ioctl_dbg_unregister not supported on CZ\n" ); -return -EINVAL ; - } - -mutex_lock (kfd_get_dbgmgr_mutex ()); - - status =kfd_dbgmgr_unregister (dev->dbgmgr, p); -if (!status) { -kfd_dbgmgr_destroy (dev->dbgmgr); - dev->dbgmgr =NULL ; - } - -mutex_unlock (kfd_get_dbgmgr_mutex ()); - -return status; +return -EPERM ; } -/* -* Parse and generate variable size data structure for address watch. -* Total size of the buffer and # watch points is limited in order -* to prevent kernel abuse. (no bearing to the much smaller HW limitation -* which is enforced by dbgdev module) -* please also note that the watch address itself are not "copied from user", -* since it be set into the HW in user mode values. -* -*/ static int kfd_ioctl_dbg_address_watch (struct file *filep,struct kfd_process *p,void *data) { -struct kfd_ioctl_dbg_address_watch_args *args = data; -struct kfd_dev *dev; -struct kfd_process_device *pdd; -struct dbg_address_watch_info aw_info; -unsigned char *args_buff; -long status; -void __user *cmd_from_user; -uint64_t watch_mask_value =0 ; -unsigned int args_idx =0 ; - -memset ((void *) &aw_info,0 ,sizeof (struct dbg_address_watch_info )); - -mutex_lock (&p->mutex);drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file *filep,
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-10- pdd =kfd_process_device_data_by_id (p, args->gpu_id); -mutex_unlock (&p->mutex); -if (!pdd) { -pr_debug ("Could not find gpu id 0x%x\n" , args->gpu_id); -return -EINVAL ; - } - dev = pdd->dev; - -if (dev->adev->asic_type ==CHIP_CARRIZO ) { - pr_debug("kfd_ioctl_dbg_wave_control not supported onCZ\n");
Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-13-return -EINVAL ; - } - cmd_from_user = (void __user *) args->content_ptr; - -/* Validate arguments */ - -if ((args->buf_size_in_bytes >MAX_ALLOWED_AW_BUFF_SIZE ) || - (args->buf_size_in_bytes <=sizeof (*args) +sizeof (int ) *2 ) || - (cmd_from_user ==NULL )) -return -EINVAL ; - -/* this is the actual buffer to work with */ - args_buff = memdup_user(cmd_from_user,drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file *filep,
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-10- args->buf_size_in_bytes - sizeof(*args)); -if (IS_ERR (args_buff)) -return PTR_ERR (args_buff); - - aw_info.process = p; - - aw_info.num_watch_points = *((uint32_t *)(&args_buff[args_idx])); - args_idx +=sizeof (aw_info.num_watch_points); - - aw_info.watch_mode = (enum HSA_DBG_WATCH_MODE *)&args_buff[args_idx];
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file · line 732
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-1- args_idx += sizeof(enum HSA_DBG_WATCH_MODE) *aw_info.num_watch_points;
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file *filep,
Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-9- -/* -* set watch address base pointer to point on the array base -* within args_buff -*/ - aw_info.watch_address = (uint64_t *) &args_buff[args_idx]; - -/* skip over the addresses buffer */ - args_idx += sizeof(aw_info.watch_address) *aw_info.num_watch_points;
Quoted 57 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +1
-50- -if (args_idx >= args->buf_size_in_bytes -sizeof (*args)) { - status = -EINVAL ; - goto out; - } - - watch_mask_value = (uint64_t ) args_buff[args_idx]; - -if (watch_mask_value >0 ) { -/* -* There is an array of masks. -* set watch mask base pointer to point on the array base -* within args_buff -*/ - aw_info.watch_mask = (uint64_t *) &args_buff[args_idx]; - -/* skip over the masks buffer */ - args_idx +=sizeof (aw_info.watch_mask) * - aw_info.num_watch_points; - }else { -/* just the NULL mask, set to NULL and skip over it */ - aw_info.watch_mask =NULL ; - args_idx +=sizeof (aw_info.watch_mask); - } - -if (args_idx >= args->buf_size_in_bytes -sizeof (args)) { - status = -EINVAL ; - goto out; - } - -/* Currently HSA Event is not supported for DBG */ - aw_info.watch_event =NULL ; - -mutex_lock (kfd_get_dbgmgr_mutex ()); - - status =kfd_dbgmgr_address_watch (dev->dbgmgr, &aw_info); - -mutex_unlock (kfd_get_dbgmgr_mutex ()); - -out: -kfree (args_buff); - -return status; +return -EPERM ; }/* Parse and generate fixed size data structure for wave control */ static int kfd_ioctl_dbg_wave_control (struct file *filep,struct kfd_process *p,void *data) { -struct kfd_ioctl_dbg_wave_control_args *args = data; -struct kfd_dev *dev; -struct kfd_process_device *pdd; -struct dbg_wave_control_info wac_info; -unsigned char *args_buff; -uint32_t computed_buff_size; -long status;drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file *filep,
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-10-void __user *cmd_from_user; -unsigned int args_idx =0 ; - -memset ((void *) &wac_info,0 ,sizeof (struct dbg_wave_control_info )); - -/* we use compact form, independent of the packing attribute value */ - computed_buff_size =sizeof (*args) + -sizeof (wac_info.mode) + -sizeof (wac_info.operand) + -sizeof (wac_info.dbgWave_msg.DbgWaveMsg)+
Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-4-sizeof (wac_info.dbgWave_msg.MemoryVA) + -sizeof (wac_info.trapId); - -mutex_lock (&p->mutex);drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file *filep,
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-10- pdd =kfd_process_device_data_by_id (p, args->gpu_id); -mutex_unlock (&p->mutex); -if (!pdd) { -pr_debug ("Could not find gpu id 0x%x\n" , args->gpu_id); -return -EINVAL ; - } - dev = pdd->dev; - -if (dev->adev->asic_type ==CHIP_CARRIZO ) { - pr_debug("kfd_ioctl_dbg_wave_control not supported onCZ\n");
Quoted 16 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-16-return -EINVAL ; - } - -/* input size must match the computed "compact" size */ -if (args->buf_size_in_bytes != computed_buff_size) { -pr_debug ("size mismatch, computed : actual %u : %u\n" , - args->buf_size_in_bytes, computed_buff_size); -return -EINVAL ; - } - - cmd_from_user = (void __user *) args->content_ptr; - -if (cmd_from_user ==NULL ) -return -EINVAL ; - -/* copy the entire buffer from user */ drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file *filep,
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-10- - args_buff =memdup_user (cmd_from_user, - args->buf_size_in_bytes -sizeof (*args)); -if (IS_ERR (args_buff)) -return PTR_ERR (args_buff); - -/* move ptr to the start of the "pay-load" area */ - wac_info.process = p; - - wac_info.operand = *((enum HSA_DBG_WAVEOP*)(&args_buff[args_idx]));
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file *filep,
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-3- args_idx +=sizeof (wac_info.operand); - - wac_info.mode = *((enum HSA_DBG_WAVEMODE*)(&args_buff[args_idx]));
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file *filep,
Quoted 12 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-12- args_idx +=sizeof (wac_info.mode); - - wac_info.trapId = *((uint32_t *)(&args_buff[args_idx])); - args_idx +=sizeof (wac_info.trapId); - - wac_info.dbgWave_msg.DbgWaveMsg.WaveMsgInfoGen2.Value = - *((uint32_t *)(&args_buff[args_idx])); - wac_info.dbgWave_msg.MemoryVA =NULL ; - -mutex_lock (kfd_get_dbgmgr_mutex ()); - - pr_debug("Calling dbg manager process %p, operand %u, mode %u,trapId %u, message %u\n",
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file *filep, · line 866
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-3- wac_info.process, wac_info.operand, - wac_info.mode, wac_info.trapId, -wac_info.dbgWave_msg.DbgWaveMsg.WaveMsgInfoGen2.Value);Review
Quoted 15 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +1
-10- - status =kfd_dbgmgr_wave_control (dev->dbgmgr, &wac_info); - -pr_debug ("Returned status of dbg manager is %ld\n" , status); - -mutex_unlock (kfd_get_dbgmgr_mutex ()); - -kfree (args_buff); - -return status; +return -EPERM ; } static int kfd_ioctl_get_clock_counters(struct file *filep,(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.cQuoted 9 lines
deleted file mode 100644
index 8eca9ed3ab36..000000000000drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-4@@ -1,845 +0,0 @@ -/* -* Copyright 2014 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c line 14
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10-* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c line 15
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-1-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c line 16
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-1-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c line 17
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-1-* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c line 18
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-1-* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c line 19
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-1-* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
Quoted 101 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-101-* OTHER DEALINGS IN THE SOFTWARE. -* -*/ - -#include <linux/types.h> -#include <linux/kernel.h> -#include <linux/log2.h> -#include <linux/sched.h> -#include <linux/slab.h> -#include <linux/mutex.h> -#include <linux/device.h> - -#include "kfd_pm4_headers.h" -#include "kfd_pm4_headers_diq.h" -#include "kfd_kernel_queue.h" -#include "kfd_priv.h" -#include "kfd_pm4_opcodes.h" -#include "cik_regs.h" -#include "kfd_dbgmgr.h" -#include "kfd_dbgdev.h" -#include "kfd_device_queue_manager.h" - -static void dbgdev_address_watch_disable_nodiq (struct kfd_dev *dev) -{ - dev->kfd2kgd->address_watch_disable (dev->adev); -} - -static int dbgdev_diq_submit_ib (struct kfd_dbgdev *dbgdev, -u32 pasid,uint64_t vmid0_address, -uint32_t *packet_buff,size_t size_in_bytes) -{ -struct pm4__release_mem *rm_packet; -struct pm4__indirect_buffer_pasid *ib_packet; -struct kfd_mem_obj *mem_obj; -size_t pq_packets_size_in_bytes; -union ULARGE_INTEGER *largep; -union ULARGE_INTEGER addr; -struct kernel_queue *kq; -uint64_t *rm_state; -unsigned int *ib_packet_buff; -int status; - -if (WARN_ON (!size_in_bytes)) -return -EINVAL ; - - kq = dbgdev->kq; - - pq_packets_size_in_bytes =sizeof (struct pm4__release_mem ) + -sizeof (struct pm4__indirect_buffer_pasid ); - -/* -* We acquire a buffer from DIQ -* The receive packet buff will be sitting on the Indirect Buffer -* and in the PQ we put the IB packet + sync packet(s). -*/ - status =kq_acquire_packet_buffer (kq, - pq_packets_size_in_bytes /sizeof (uint32_t ), - &ib_packet_buff); -if (status) { -pr_err ("kq_acquire_packet_buffer failed\n" ); -return status; - } - -memset (ib_packet_buff,0 , pq_packets_size_in_bytes); - - ib_packet = (struct pm4__indirect_buffer_pasid *) (ib_packet_buff); - - ib_packet->header.count =3 ; - ib_packet->header.opcode =IT_INDIRECT_BUFFER_PASID ; - ib_packet->header.type =PM4_TYPE_3 ; - - largep = (union ULARGE_INTEGER *) &vmid0_address; - - ib_packet->bitfields2.ib_base_lo = largep->u.low_part >>2 ; - ib_packet->bitfields3.ib_base_hi = largep->u.high_part; - - ib_packet->control = (1 <<23 ) | (1 <<31 ) | - ((size_in_bytes /4 ) &0xfffff ); - - ib_packet->bitfields5.pasid = pasid; - -/* -* for now we use release mem for GPU-CPU synchronization -* Consider WaitRegMem + WriteData as a better alternative -* we get a GART allocations ( gpu/cpu mapping), -* for the sync variable, and wait until: -* (a) Sync with HW -* (b) Sync var is written by CP to mem. -*/ - rm_packet = (struct pm4__release_mem *) (ib_packet_buff + - (sizeof (struct pm4__indirect_buffer_pasid ) / -sizeof (unsigned int ))); - - status =kfd_gtt_sa_allocate (dbgdev->dev,sizeof (uint64_t ), - &mem_obj); - -if (status) { -pr_err ("Failed to allocate GART memory\n" ); -kq_rollback_packet (kq); -return status; - }drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10- - rm_state = (uint64_t *) mem_obj->cpu_ptr; - - *rm_state =QUEUESTATE__ACTIVE_COMPLETION_PENDING ; - - rm_packet->header.opcode =IT_RELEASE_MEM ; - rm_packet->header.type =PM4_TYPE_3 ; - rm_packet->header.count =sizeof (struct pm4__release_mem ) /4 -2 ; - - rm_packet->bitfields2.event_type =
CACHE_FLUSH_AND_INV_TS_EVENT;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-4- rm_packet->bitfields2.event_index = - event_index___release_mem__end_of_pipe; - - rm_packet->bitfields2.cache_policy =
cache_policy___release_mem__lru;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c line 148
Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-13- rm_packet->bitfields2.atc =0 ; - rm_packet->bitfields2.tc_wb_action_ena =1 ; - - addr.quad_part = mem_obj->gpu_addr; - - rm_packet->bitfields4.address_lo_32b = addr.u.low_part >>2 ; - rm_packet->address_hi = addr.u.high_part; - - rm_packet->bitfields3.data_sel = - data_sel___release_mem__send_64_bit_data; - - rm_packet->bitfields3.int_sel = -int_sel___release_mem__send_data_after_write_confirm;Quoted 89 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-89- - rm_packet->bitfields3.dst_sel = - dst_sel___release_mem__memory_controller; - - rm_packet->data_lo =QUEUESTATE__ACTIVE ; - -kq_submit_packet (kq); - -/* Wait till CP writes sync code: */ - status =amdkfd_fence_wait_timeout ( - rm_state, -QUEUESTATE__ACTIVE ,1500 ); - -kfd_gtt_sa_free (dbgdev->dev, mem_obj); - -return status; -} - -static int dbgdev_register_nodiq (struct kfd_dbgdev *dbgdev) -{ -/* -* no action is needed in this case, -* just make sure diq will not be used -*/ - - dbgdev->kq =NULL ; - -return 0 ; -} - -static int dbgdev_register_diq (struct kfd_dbgdev *dbgdev) -{ -struct queue_properties properties; -unsigned int qid; -struct kernel_queue *kq =NULL ; -int status; - - properties.type =KFD_QUEUE_TYPE_DIQ ; - - status =pqm_create_queue (dbgdev->pqm, dbgdev->dev,NULL , - &properties, &qid,NULL ,NULL ,NULL ,NULL ); - -if (status) { -pr_err ("Failed to create DIQ\n" ); -return status; - } - -pr_debug ("DIQ Created with queue id: %d\n" , qid); - - kq =pqm_get_kernel_queue (dbgdev->pqm, qid); - -if (!kq) { -pr_err ("Error getting DIQ\n" ); -pqm_destroy_queue (dbgdev->pqm, qid); -return -EFAULT ; - } - - dbgdev->kq = kq; - -return status; -} - -static int dbgdev_unregister_nodiq (struct kfd_dbgdev *dbgdev) -{ -/* disable watch address */ -dbgdev_address_watch_disable_nodiq (dbgdev->dev); -return 0 ; -} - -static int dbgdev_unregister_diq (struct kfd_dbgdev *dbgdev) -{ -/* todo - disable address watch */ -int status; - - status =pqm_destroy_queue (dbgdev->pqm, - dbgdev->kq->queue->properties.queue_id); - dbgdev->kq =NULL ; - -return status; -} - -static void dbgdev_address_watch_set_registers ( -const struct dbg_address_watch_info *adw_info, -union TCP_WATCH_ADDR_H_BITS *addrHi, -union TCP_WATCH_ADDR_L_BITS *addrLo, -union TCP_WATCH_CNTL_BITS *cntl, -unsigned int index,unsigned int vmid) -{ -union ULARGE_INTEGER addr;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c line 249
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10- - addr.quad_part =0 ; - addrHi->u32All =0 ; - addrLo->u32All =0 ; - cntl->u32All =0 ; - -if (adw_info->watch_mask) - cntl->bitfields.mask = - (uint32_t) (adw_info->watch_mask[index] & -ADDRESS_WATCH_REG_CNTL_DEFAULT_MASK);drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c line 248
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-2-else - cntl->bitfields.mask =
ADDRESS_WATCH_REG_CNTL_DEFAULT_MASK;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c line 256
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-2- - addr.quad_part = (unsigned long long) adw_info-watch_address[index];
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-3- - addrHi->bitfields.addr = addr.u.high_part & -ADDRESS_WATCH_REG_ADDHIGH_MASK;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-2- addrLo->bitfields.addr = - (addr.u.low_part >>
ADDRESS_WATCH_REG_ADDLOW_SHIFT);Quoted 37 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-37- - cntl->bitfields.mode = adw_info->watch_mode[index]; - cntl->bitfields.vmid = (uint32_t ) vmid; -/* for now assume it is an ATC address */ - cntl->u32All |=ADDRESS_WATCH_REG_CNTL_ATC_BIT ; - -pr_debug ("\t\t%20s %08x\n" ,"set reg mask :" , cntl->bitfields.mask); -pr_debug ("\t\t%20s %08x\n" ,"set reg add high :" , - addrHi->bitfields.addr); -pr_debug ("\t\t%20s %08x\n" ,"set reg add low :" , - addrLo->bitfields.addr); -} - -static int dbgdev_address_watch_nodiq (struct kfd_dbgdev *dbgdev, -struct dbg_address_watch_info *adw_info) -{ -union TCP_WATCH_ADDR_H_BITS addrHi; -union TCP_WATCH_ADDR_L_BITS addrLo; -union TCP_WATCH_CNTL_BITS cntl; -struct kfd_process_device *pdd; -unsigned int i; - -/* taking the vmid for that process on the safe way using pdd */ - pdd =kfd_get_process_device_data (dbgdev->dev, - adw_info->process); -if (!pdd) { -pr_err ("Failed to get pdd for wave control no DIQ\n" ); -return -EFAULT ; - } - - addrHi.u32All =0 ; - addrLo.u32All =0 ; - cntl.u32All =0 ; - -if ((adw_info->num_watch_points >MAX_WATCH_ADDRESSES ) || - (adw_info->num_watch_points ==0 )) { -pr_err ("num_watch_points is invalid\n" );drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10-return -EINVAL ; - } - -if (!adw_info->watch_mode || !adw_info->watch_address) { -pr_err ("adw_info fields are not valid\n" ); -return -EINVAL ; - } - -for (i =0 ; i < adw_info->num_watch_points; i++) { - dbgdev_address_watch_set_registers(adw_info, &addrHi,&addrLo,
Quoted 70 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-70- &cntl, i, pdd->qpd.vmid); - -pr_debug ("\t\t%30s\n" ,"* * * * * * * * * * * * * * * * * *" ); -pr_debug ("\t\t%20s %08x\n" ,"register index :" , i); -pr_debug ("\t\t%20s %08x\n" ,"vmid is :" , pdd->qpd.vmid); -pr_debug ("\t\t%20s %08x\n" ,"Address Low is :" , - addrLo.bitfields.addr); -pr_debug ("\t\t%20s %08x\n" ,"Address high is :" , - addrHi.bitfields.addr); -pr_debug ("\t\t%20s %08x\n" ,"Address high is :" , - addrHi.bitfields.addr); -pr_debug ("\t\t%20s %08x\n" ,"Control Mask is :" , - cntl.bitfields.mask); -pr_debug ("\t\t%20s %08x\n" ,"Control Mode is :" , - cntl.bitfields.mode); -pr_debug ("\t\t%20s %08x\n" ,"Control Vmid is :" , - cntl.bitfields.vmid); -pr_debug ("\t\t%20s %08x\n" ,"Control atc is :" , - cntl.bitfields.atc); -pr_debug ("\t\t%30s\n" ,"* * * * * * * * * * * * * * * * * *" ); - - pdd->dev->kfd2kgd->address_watch_execute ( - dbgdev->dev->adev, - i, - cntl.u32All, - addrHi.u32All, - addrLo.u32All); - } - -return 0 ; -} - -static int dbgdev_address_watch_diq (struct kfd_dbgdev *dbgdev, -struct dbg_address_watch_info *adw_info) -{ -struct pm4__set_config_reg *packets_vec; -union TCP_WATCH_ADDR_H_BITS addrHi; -union TCP_WATCH_ADDR_L_BITS addrLo; -union TCP_WATCH_CNTL_BITS cntl; -struct kfd_mem_obj *mem_obj; -unsigned int aw_reg_add_dword; -uint32_t *packet_buff_uint; -unsigned int i; -int status; -size_t ib_size =sizeof (struct pm4__set_config_reg ) *4 ; -/* we do not control the vmid in DIQ mode, just a place holder */ -unsigned int vmid =0 ; - - addrHi.u32All =0 ; - addrLo.u32All =0 ; - cntl.u32All =0 ; - -if ((adw_info->num_watch_points >MAX_WATCH_ADDRESSES ) || - (adw_info->num_watch_points ==0 )) { -pr_err ("num_watch_points is invalid\n" ); -return -EINVAL ; - } - -if (!adw_info->watch_mode || !adw_info->watch_address) { -pr_err ("adw_info fields are not valid\n" ); -return -EINVAL ; - } - - status =kfd_gtt_sa_allocate (dbgdev->dev, ib_size, &mem_obj); - -if (status) { -pr_err ("Failed to allocate GART memory\n" ); -return status; - } -drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10- packet_buff_uint = mem_obj->cpu_ptr; - -memset (packet_buff_uint,0 , ib_size); - - packets_vec = (struct pm4__set_config_reg *) (packet_buff_uint); - - packets_vec[0 ].header.count =1 ; - packets_vec[0 ].header.opcode =IT_SET_CONFIG_REG ; - packets_vec[0 ].header.type =PM4_TYPE_3 ; - packets_vec[0].bitfields2.vmid_shift =
ADDRESS_WATCH_CNTL_OFFSET;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-7- packets_vec[0 ].bitfields2.insert_vmid =1 ; - packets_vec[1 ].ordinal1 = packets_vec[0 ].ordinal1; - packets_vec[1 ].bitfields2.insert_vmid =0 ; - packets_vec[2 ].ordinal1 = packets_vec[0 ].ordinal1; - packets_vec[2 ].bitfields2.insert_vmid =0 ; - packets_vec[3 ].ordinal1 = packets_vec[0 ].ordinal1; - packets_vec[3].bitfields2.vmid_shift =
ADDRESS_WATCH_CNTL_OFFSET;Quoted 34 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-33- packets_vec[3 ].bitfields2.insert_vmid =1 ; - -for (i =0 ; i < adw_info->num_watch_points; i++) { -dbgdev_address_watch_set_registers (adw_info, - &addrHi, - &addrLo, - &cntl, - i, - vmid); - -pr_debug ("\t\t%30s\n" ,"* * * * * * * * * * * * * * * * * *" ); -pr_debug ("\t\t%20s %08x\n" ,"register index :" , i); -pr_debug ("\t\t%20s %08x\n" ,"vmid is :" , vmid); -pr_debug ("\t\t%20s %p\n" ,"Add ptr is :" , - adw_info->watch_address); -pr_debug ("\t\t%20s %08llx\n" ,"Add is :" , - adw_info->watch_address[i]); -pr_debug ("\t\t%20s %08x\n" ,"Address Low is :" , - addrLo.bitfields.addr); -pr_debug ("\t\t%20s %08x\n" ,"Address high is :" , - addrHi.bitfields.addr); -pr_debug ("\t\t%20s %08x\n" ,"Control Mask is :" , - cntl.bitfields.mask); -pr_debug ("\t\t%20s %08x\n" ,"Control Mode is :" , - cntl.bitfields.mode); -pr_debug ("\t\t%20s %08x\n" ,"Control Vmid is :" , - cntl.bitfields.vmid); -pr_debug ("\t\t%20s %08x\n" ,"Control atc is :" , - cntl.bitfields.atc); -pr_debug ("\t\t%30s\n" ,"* * * * * * * * * * * * * * * * * *" ); - - aw_reg_add_dword = - dbgdev->dev->kfd2kgd-address_watch_get_offset(
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-6- dbgdev->dev->adev, - i, - ADDRESS_WATCH_REG_CNTL); - - packets_vec[0 ].bitfields2.reg_offset = - aw_reg_add_dword -
AMD_CONFIG_REG_BASE;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 12 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-5- - packets_vec[0 ].reg_data[0 ] = cntl.u32All; - - aw_reg_add_dword = - dbgdev->dev->kfd2kgd-address_watch_get_offset(
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-6- dbgdev->dev->adev, - i, - ADDRESS_WATCH_REG_ADDR_HI); - - packets_vec[1 ].bitfields2.reg_offset = - aw_reg_add_dword -
AMD_CONFIG_REG_BASE;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 11 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-4- packets_vec[1 ].reg_data[0 ] = addrHi.u32All; - - aw_reg_add_dword = - dbgdev->dev->kfd2kgd-address_watch_get_offset(
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-6- dbgdev->dev->adev, - i, - ADDRESS_WATCH_REG_ADDR_LO); - - packets_vec[2 ].bitfields2.reg_offset = - aw_reg_add_dword -
AMD_CONFIG_REG_BASE;Quoted 11 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10- packets_vec[2 ].reg_data[0 ] = addrLo.u32All; - -/* enable watch flag if address is not zero*/ -if (adw_info->watch_address[i] >0 ) - cntl.bitfields.valid =1 ; -else - cntl.bitfields.valid =0 ; - - aw_reg_add_dword = - dbgdev->dev->kfd2kgd-address_watch_get_offset(
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-6- dbgdev->dev->adev, - i, - ADDRESS_WATCH_REG_CNTL); - - packets_vec[3 ].bitfields2.reg_offset = - aw_reg_add_dword -
AMD_CONFIG_REG_BASE;Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-13- packets_vec[3 ].reg_data[0 ] = cntl.u32All; - - status =dbgdev_diq_submit_ib ( - dbgdev, - adw_info->process->pasid, - mem_obj->gpu_addr, - packet_buff_uint, - ib_size); - -if (status) { -pr_err ("Failed to submit IB to DIQ\n" ); -break ; - }drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10- } - -kfd_gtt_sa_free (dbgdev->dev, mem_obj); -return status; -} - -static int dbgdev_wave_control_set_registers ( -struct dbg_wave_control_info *wac_info, -union SQ_CMD_BITS *in_reg_sq_cmd, - union GRBM_GFX_INDEX_BITS
*in_reg_gfx_index)Quoted 86 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-86-{ -int status =0 ; -union SQ_CMD_BITS reg_sq_cmd; -union GRBM_GFX_INDEX_BITS reg_gfx_index; -struct HsaDbgWaveMsgAMDGen2 *pMsg; - - reg_sq_cmd.u32All =0 ; - reg_gfx_index.u32All =0 ; - pMsg = &wac_info->dbgWave_msg.DbgWaveMsg.WaveMsgInfoGen2; - -switch (wac_info->mode) { -/* Send command to single wave */ -case HSA_DBG_WAVEMODE_SINGLE : -/* -* Limit access to the process waves only, -* by setting vmid check -*/ - reg_sq_cmd.bits.check_vmid =1 ; - reg_sq_cmd.bits.simd_id = pMsg->ui32.SIMD; - reg_sq_cmd.bits.wave_id = pMsg->ui32.WaveId; - reg_sq_cmd.bits.mode =SQ_IND_CMD_MODE_SINGLE ; - - reg_gfx_index.bits.sh_index = pMsg->ui32.ShaderArray; - reg_gfx_index.bits.se_index = pMsg->ui32.ShaderEngine; - reg_gfx_index.bits.instance_index = pMsg->ui32.HSACU; - -break ; - -/* Send command to all waves with matching VMID */ -case HSA_DBG_WAVEMODE_BROADCAST_PROCESS : - - reg_gfx_index.bits.sh_broadcast_writes =1 ; - reg_gfx_index.bits.se_broadcast_writes =1 ; - reg_gfx_index.bits.instance_broadcast_writes =1 ; - - reg_sq_cmd.bits.mode =SQ_IND_CMD_MODE_BROADCAST ; - -break ; - -/* Send command to all CU waves with matching VMID */ -case HSA_DBG_WAVEMODE_BROADCAST_PROCESS_CU : - - reg_sq_cmd.bits.check_vmid =1 ; - reg_sq_cmd.bits.mode =SQ_IND_CMD_MODE_BROADCAST ; - - reg_gfx_index.bits.sh_index = pMsg->ui32.ShaderArray; - reg_gfx_index.bits.se_index = pMsg->ui32.ShaderEngine; - reg_gfx_index.bits.instance_index = pMsg->ui32.HSACU; - -break ; - -default : -return -EINVAL ; - } - -switch (wac_info->operand) { -case HSA_DBG_WAVEOP_HALT : - reg_sq_cmd.bits.cmd =SQ_IND_CMD_CMD_HALT ; -break ; - -case HSA_DBG_WAVEOP_RESUME : - reg_sq_cmd.bits.cmd =SQ_IND_CMD_CMD_RESUME ; -break ; - -case HSA_DBG_WAVEOP_KILL : - reg_sq_cmd.bits.cmd =SQ_IND_CMD_CMD_KILL ; -break ; - -case HSA_DBG_WAVEOP_DEBUG : - reg_sq_cmd.bits.cmd =SQ_IND_CMD_CMD_DEBUG ; -break ; - -case HSA_DBG_WAVEOP_TRAP : -if (wac_info->trapId <MAX_TRAPID ) { - reg_sq_cmd.bits.cmd =SQ_IND_CMD_CMD_TRAP ; - reg_sq_cmd.bits.trap_id = wac_info->trapId; - }else { - status = -EINVAL ; - } -break ; - -default : - status = -EINVAL ; -break ; - } -drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10-if (status ==0 ) { - *in_reg_sq_cmd = reg_sq_cmd; - *in_reg_gfx_index = reg_gfx_index; - } - -return status; -} - -static int dbgdev_wave_control_diq (struct kfd_dbgdev *dbgdev, - struct dbg_wave_control_info
*wac_info)Quoted 68 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-29-{ - -int status; -union SQ_CMD_BITS reg_sq_cmd; -union GRBM_GFX_INDEX_BITS reg_gfx_index; -struct kfd_mem_obj *mem_obj; -uint32_t *packet_buff_uint; -struct pm4__set_config_reg *packets_vec; -size_t ib_size =sizeof (struct pm4__set_config_reg ) *3 ; - - reg_sq_cmd.u32All =0 ; - - status =dbgdev_wave_control_set_registers (wac_info, ®_sq_cmd, - ®_gfx_index); -if (status) { -pr_err ("Failed to set wave control registers\n" ); -return status; - } - -/* we do not control the VMID in DIQ, so reset it to a known value */ - reg_sq_cmd.bits.vm_id =0 ; - -pr_debug ("\t\t %30s\n" ,"* * * * * * * * * * * * * * * * * *" ); - -pr_debug ("\t\t mode is: %u\n" , wac_info->mode); -pr_debug ("\t\t operand is: %u\n" , wac_info->operand); -pr_debug ("\t\t trap id is: %u\n" , wac_info->trapId); - pr_debug("\t\t msg value is: %u\n", - wac_info-dbgWave_msg.DbgWaveMsg.WaveMsgInfoGen2.Value);
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-38-pr_debug ("\t\t vmid is: N/A\n" ); - -pr_debug ("\t\t chk_vmid is : %u\n" , reg_sq_cmd.bitfields.check_vmid); -pr_debug ("\t\t command is : %u\n" , reg_sq_cmd.bitfields.cmd); -pr_debug ("\t\t queue id is : %u\n" , reg_sq_cmd.bitfields.queue_id); -pr_debug ("\t\t simd id is : %u\n" , reg_sq_cmd.bitfields.simd_id); -pr_debug ("\t\t mode is : %u\n" , reg_sq_cmd.bitfields.mode); -pr_debug ("\t\t vm_id is : %u\n" , reg_sq_cmd.bitfields.vm_id); -pr_debug ("\t\t wave_id is : %u\n" , reg_sq_cmd.bitfields.wave_id); - -pr_debug ("\t\t ibw is : %u\n" , - reg_gfx_index.bitfields.instance_broadcast_writes); -pr_debug ("\t\t ii is : %u\n" , - reg_gfx_index.bitfields.instance_index); -pr_debug ("\t\t sebw is : %u\n" , - reg_gfx_index.bitfields.se_broadcast_writes); -pr_debug ("\t\t se_ind is : %u\n" , reg_gfx_index.bitfields.se_index); -pr_debug ("\t\t sh_ind is : %u\n" , reg_gfx_index.bitfields.sh_index); -pr_debug ("\t\t sbw is : %u\n" , - reg_gfx_index.bitfields.sh_broadcast_writes); - -pr_debug ("\t\t %30s\n" ,"* * * * * * * * * * * * * * * * * *" ); - - status =kfd_gtt_sa_allocate (dbgdev->dev, ib_size, &mem_obj); - -if (status !=0 ) { -pr_err ("Failed to allocate GART memory\n" ); -return status; - } - - packet_buff_uint = mem_obj->cpu_ptr; - -memset (packet_buff_uint,0 , ib_size); - - packets_vec = (struct pm4__set_config_reg *) packet_buff_uint; - packets_vec[0 ].header.count =1 ; - packets_vec[0 ].header.opcode =IT_SET_UCONFIG_REG ; - packets_vec[0 ].header.type =PM4_TYPE_3 ;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10- packets_vec[0 ].bitfields2.reg_offset = -GRBM_GFX_INDEX /4 -USERCONFIG_REG_BASE ; - - packets_vec[0 ].bitfields2.insert_vmid =0 ; - packets_vec[0 ].reg_data[0 ] = reg_gfx_index.u32All; - - packets_vec[1 ].header.count =1 ; - packets_vec[1 ].header.opcode =IT_SET_CONFIG_REG ; - packets_vec[1 ].header.type =PM4_TYPE_3 ; - packets_vec[1].bitfields2.reg_offset = SQ_CMD / 4 -
AMD_CONFIG_REG_BASE;Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-6- - packets_vec[1 ].bitfields2.vmid_shift =SQ_CMD_VMID_OFFSET ; - packets_vec[1 ].bitfields2.insert_vmid =1 ; - packets_vec[1 ].reg_data[0 ] = reg_sq_cmd.u32All; - -/* Restore the GRBM_GFX_INDEX register */ drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10- - reg_gfx_index.u32All =0 ; - reg_gfx_index.bits.sh_broadcast_writes =1 ; - reg_gfx_index.bits.instance_broadcast_writes =1 ; - reg_gfx_index.bits.se_broadcast_writes =1 ; - - - packets_vec[2 ].ordinal1 = packets_vec[0 ].ordinal1; - packets_vec[2 ].bitfields2.reg_offset = - GRBM_GFX_INDEX / 4 -
USERCONFIG_REG_BASE;Quoted 11 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-11- - packets_vec[2 ].bitfields2.insert_vmid =0 ; - packets_vec[2 ].reg_data[0 ] = reg_gfx_index.u32All; - - status =dbgdev_diq_submit_ib ( - dbgdev, - wac_info->process->pasid, - mem_obj->gpu_addr, - packet_buff_uint, - ib_size); -drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10-if (status) -pr_err ("Failed to submit IB to DIQ\n" ); - -kfd_gtt_sa_free (dbgdev->dev, mem_obj); - -return status; -} - -static int dbgdev_wave_control_nodiq (struct kfd_dbgdev *dbgdev, - struct dbg_wave_control_info
*wac_info)Quoted 59 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-33-{ -int status; -union SQ_CMD_BITS reg_sq_cmd; -union GRBM_GFX_INDEX_BITS reg_gfx_index; -struct kfd_process_device *pdd; - - reg_sq_cmd.u32All =0 ; - -/* taking the VMID for that process on the safe way using PDD */ - pdd =kfd_get_process_device_data (dbgdev->dev, wac_info->process); - -if (!pdd) { -pr_err ("Failed to get pdd for wave control no DIQ\n" ); -return -EFAULT ; - } - status =dbgdev_wave_control_set_registers (wac_info, ®_sq_cmd, - ®_gfx_index); -if (status) { -pr_err ("Failed to set wave control registers\n" ); -return status; - } - -/* for non DIQ we need to patch the VMID: */ - - reg_sq_cmd.bits.vm_id = pdd->qpd.vmid; - -pr_debug ("\t\t %30s\n" ,"* * * * * * * * * * * * * * * * * *" ); - -pr_debug ("\t\t mode is: %u\n" , wac_info->mode); -pr_debug ("\t\t operand is: %u\n" , wac_info->operand); -pr_debug ("\t\t trap id is: %u\n" , wac_info->trapId); - pr_debug("\t\t msg value is: %u\n", - wac_info-dbgWave_msg.DbgWaveMsg.WaveMsgInfoGen2.Value);
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-24-pr_debug ("\t\t vmid is: %u\n" , pdd->qpd.vmid); - -pr_debug ("\t\t chk_vmid is : %u\n" , reg_sq_cmd.bitfields.check_vmid); -pr_debug ("\t\t command is : %u\n" , reg_sq_cmd.bitfields.cmd); -pr_debug ("\t\t queue id is : %u\n" , reg_sq_cmd.bitfields.queue_id); -pr_debug ("\t\t simd id is : %u\n" , reg_sq_cmd.bitfields.simd_id); -pr_debug ("\t\t mode is : %u\n" , reg_sq_cmd.bitfields.mode); -pr_debug ("\t\t vm_id is : %u\n" , reg_sq_cmd.bitfields.vm_id); -pr_debug ("\t\t wave_id is : %u\n" , reg_sq_cmd.bitfields.wave_id); - -pr_debug ("\t\t ibw is : %u\n" , - reg_gfx_index.bitfields.instance_broadcast_writes); -pr_debug ("\t\t ii is : %u\n" , - reg_gfx_index.bitfields.instance_index); -pr_debug ("\t\t sebw is : %u\n" , - reg_gfx_index.bitfields.se_broadcast_writes); -pr_debug ("\t\t se_ind is : %u\n" , reg_gfx_index.bitfields.se_index); -pr_debug ("\t\t sh_ind is : %u\n" , reg_gfx_index.bitfields.sh_index); -pr_debug ("\t\t sbw is : %u\n" , - reg_gfx_index.bitfields.sh_broadcast_writes); - -pr_debug ("\t\t %30s\n" ,"* * * * * * * * * * * * * * * * * *" ); - - return dbgdev->dev->kfd2kgd->wave_control_execute(dbgdev->dev-adev,
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-5- reg_gfx_index.u32All, - reg_sq_cmd.u32All); -} - -int dbgdev_wave_reset_wavefronts(struct kfd_dev *dev, struct kfd_process*p)
Quoted 20 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-20-{ -int status =0 ; -unsigned int vmid; -uint16_t queried_pasid; -union SQ_CMD_BITS reg_sq_cmd; -union GRBM_GFX_INDEX_BITS reg_gfx_index; -struct kfd_process_device *pdd; -struct dbg_wave_control_info wac_info; -int first_vmid_to_scan = dev->vm_info.first_vmid_kfd; -int last_vmid_to_scan = dev->vm_info.last_vmid_kfd; - - reg_sq_cmd.u32All =0 ; - status =0 ; - - wac_info.mode =HSA_DBG_WAVEMODE_BROADCAST_PROCESS ; - wac_info.operand =HSA_DBG_WAVEOP_KILL ; - -pr_debug ("Killing all process wavefronts\n" ); - -/* Scan all registers in the range ATC_VMID8_PASID_MAPPING .. drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10-* ATC_VMID15_PASID_MAPPING -* to check which VMID the current process is mapped to. -*/ - -for (vmid = first_vmid_to_scan; vmid <= last_vmid_to_scan; vmid++) { - status = dev->kfd2kgd->get_atc_vmid_pasid_mapping_info - (dev->adev, vmid, &queried_pasid); - -if (status && queried_pasid == p->pasid) { - pr_debug("Killing wave fronts of vmid %d and pasid0x%x\n",
Quoted 33 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-33- vmid, p->pasid); -break ; - } - } - -if (vmid > last_vmid_to_scan) { -pr_err ("Didn't find vmid for pasid 0x%x\n" , p->pasid); -return -EFAULT ; - } - -/* taking the VMID for that process on the safe way using PDD */ - pdd =kfd_get_process_device_data (dev, p); -if (!pdd) -return -EFAULT ; - - status =dbgdev_wave_control_set_registers (&wac_info, ®_sq_cmd, - ®_gfx_index); -if (status !=0 ) -return -EINVAL ; - -/* for non DIQ we need to patch the VMID: */ - reg_sq_cmd.bits.vm_id = vmid; - - dev->kfd2kgd->wave_control_execute (dev->adev, - reg_gfx_index.u32All, - reg_sq_cmd.u32All); - -return 0 ; -} - -void kfd_dbgdev_init (struct kfd_dbgdev *pdbgdev,struct kfd_dev *pdev, -enum DBGDEV_TYPE type) -{drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10- pdbgdev->dev = pdev; - pdbgdev->kq =NULL ; - pdbgdev->type = type; - pdbgdev->pqm =NULL ; - -switch (type) { -case DBGDEV_TYPE_NODIQ : - pdbgdev->dbgdev_register = dbgdev_register_nodiq; - pdbgdev->dbgdev_unregister = dbgdev_unregister_nodiq; - pdbgdev->dbgdev_wave_control =
dbgdev_wave_control_nodiq;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-1- pdbgdev->dbgdev_address_watch =
dbgdev_address_watch_nodiq;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-7-break ; -case DBGDEV_TYPE_DIQ : -default : - pdbgdev->dbgdev_register = dbgdev_register_diq; - pdbgdev->dbgdev_unregister = dbgdev_unregister_diq; - pdbgdev->dbgdev_wave_control = dbgdev_wave_control_diq; - pdbgdev->dbgdev_address_watch =
dbgdev_address_watch_diq;Review
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-4-break ; - } - -}(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.hQuoted 9 lines
deleted file mode 100644
index 0619c777b47e..000000000000drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-4@@ -1,230 +0,0 @@ -/* -* Copyright 2014 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h line 14
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-10-* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h line 15
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-1-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h line 16
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-1-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h line 17
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-1-* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h line 18
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-1-* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h line 19
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-1-* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
Quoted 17 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-17-* OTHER DEALINGS IN THE SOFTWARE. -*/ - -#ifndef KFD_DBGDEV_H_ -#define KFD_DBGDEV_H_ - -enum { -SQ_CMD_VMID_OFFSET =28 , -ADDRESS_WATCH_CNTL_OFFSET =24 -}; - -enum { -PRIV_QUEUE_SYNC_TIME_MS =200 -}; - -/* CONTEXT reg space definition */ -enum {drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-10- CONTEXT_REG_BASE = 0xA000, - CONTEXT_REG_END = 0xA400, -CONTEXT_REG_SIZE =CONTEXT_REG_END -CONTEXT_REG_BASE -}; - -/* USER CONFIG reg space definition */ -enum { -USERCONFIG_REG_BASE =0xC000 , -USERCONFIG_REG_END =0x10000 , - USERCONFIG_REG_SIZE = USERCONFIG_REG_END -
USERCONFIG_REG_BASEdrivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-7-}; - -/* CONFIG reg space definition */ -enum { -AMD_CONFIG_REG_BASE =0x2000 ,/* in dwords */ -AMD_CONFIG_REG_END =0x2B00 , - AMD_CONFIG_REG_SIZE = AMD_CONFIG_REG_END -
AMD_CONFIG_REG_BASEReview
Quoted 178 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-177-}; - -/* SH reg space definition */ -enum { -SH_REG_BASE =0x2C00 , -SH_REG_END =0x3000 , -SH_REG_SIZE =SH_REG_END -SH_REG_BASE -}; - -/* SQ_CMD definitions */ -#define SQ_CMD 0x8DEC - -enum SQ_IND_CMD_CMD { -SQ_IND_CMD_CMD_NULL =0x00000000 , -SQ_IND_CMD_CMD_HALT =0x00000001 , -SQ_IND_CMD_CMD_RESUME =0x00000002 , -SQ_IND_CMD_CMD_KILL =0x00000003 , -SQ_IND_CMD_CMD_DEBUG =0x00000004 , -SQ_IND_CMD_CMD_TRAP =0x00000005 , -}; - -enum SQ_IND_CMD_MODE { -SQ_IND_CMD_MODE_SINGLE =0x00000000 , -SQ_IND_CMD_MODE_BROADCAST =0x00000001 , -SQ_IND_CMD_MODE_BROADCAST_QUEUE =0x00000002 , -SQ_IND_CMD_MODE_BROADCAST_PIPE =0x00000003 , -SQ_IND_CMD_MODE_BROADCAST_ME =0x00000004 , -}; - -union SQ_IND_INDEX_BITS { -struct { -uint32_t wave_id:4 ; -uint32_t simd_id:2 ; -uint32_t thread_id:6 ; - uint32_t:1; -uint32_t force_read:1 ; -uint32_t read_timeout:1 ; -uint32_t unindexed:1 ; -uint32_t index:16 ; - - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -union SQ_IND_CMD_BITS { -struct { -uint32_t data:32 ; - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -union SQ_CMD_BITS { -struct { -uint32_t cmd:3 ; - uint32_t:1; -uint32_t mode:3 ; -uint32_t check_vmid:1 ; -uint32_t trap_id:3 ; - uint32_t:5; -uint32_t wave_id:4 ; -uint32_t simd_id:2 ; - uint32_t:2; -uint32_t queue_id:3 ; - uint32_t:1; -uint32_t vm_id:4 ; - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -union SQ_IND_DATA_BITS { -struct { -uint32_t data:32 ; - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -union GRBM_GFX_INDEX_BITS { -struct { -uint32_t instance_index:8 ; -uint32_t sh_index:8 ; -uint32_t se_index:8 ; - uint32_t:5; -uint32_t sh_broadcast_writes:1 ; -uint32_t instance_broadcast_writes:1 ; -uint32_t se_broadcast_writes:1 ; - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -union TCP_WATCH_ADDR_H_BITS { -struct { -uint32_t addr:16 ; - uint32_t:16; - - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -union TCP_WATCH_ADDR_L_BITS { -struct { - uint32_t:6; -uint32_t addr:26 ; - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -enum { -QUEUESTATE__INVALID =0 ,/* so by default we'll get invalid state */ -QUEUESTATE__ACTIVE_COMPLETION_PENDING , -QUEUESTATE__ACTIVE -}; - -union ULARGE_INTEGER { -struct { -uint32_t low_part; -uint32_t high_part; - } u; -unsigned long long quad_part; -}; - - -#define KFD_CIK_VMID_START_OFFSET (8) -#define KFD_CIK_VMID_END_OFFSET (KFD_CIK_VMID_START_OFFSET + (8)) - - -void kfd_dbgdev_init (struct kfd_dbgdev *pdbgdev,struct kfd_dev *pdev, -enum DBGDEV_TYPE type); - -union TCP_WATCH_CNTL_BITS { -struct { -uint32_t mask:24 ; -uint32_t vmid:4 ; -uint32_t atc:1 ; -uint32_t mode:2 ; -uint32_t valid:1 ; - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -enum { -ADDRESS_WATCH_REG_CNTL_ATC_BIT =0x10000000UL , -ADDRESS_WATCH_REG_CNTL_DEFAULT_MASK =0x00FFFFFF , -ADDRESS_WATCH_REG_ADDLOW_MASK_EXTENSION =0x03000000 , -/* extend the mask to 26 bits in order to match the low address field */ -ADDRESS_WATCH_REG_ADDLOW_SHIFT =6 , -ADDRESS_WATCH_REG_ADDHIGH_MASK =0xFFFF -}; - -enum { -MAX_TRAPID =8 ,/* 3 bits in the bitfield. */ -MAX_WATCH_ADDRESSES =4 -}; - -enum { -ADDRESS_WATCH_REG_ADDR_HI =0 , -ADDRESS_WATCH_REG_ADDR_LO , -ADDRESS_WATCH_REG_CNTL , -ADDRESS_WATCH_REG_MAX -}; - -#endif /* KFD_DBGDEV_H_ */ (quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.cQuoted 9 lines
deleted file mode 100644
index 9bfa50633654..000000000000drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-4@@ -1,158 +0,0 @@ -/* -* Copyright 2014 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c line 14
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-10-* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c line 15
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-1-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c line 16
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-1-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c line 17
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-1-* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c line 18
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-1-* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c line 19
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-1-* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
Quoted 91 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-91-* OTHER DEALINGS IN THE SOFTWARE. -* -*/ -#include <linux/types.h> -#include <linux/kernel.h> -#include <linux/log2.h> -#include <linux/sched.h> -#include <linux/slab.h> -#include <linux/device.h> - -#include "kfd_priv.h" -#include "cik_regs.h" -#include "kfd_pm4_headers.h" -#include "kfd_pm4_headers_diq.h" -#include "kfd_dbgmgr.h" -#include "kfd_dbgdev.h" -#include "kfd_device_queue_manager.h" - -static DEFINE_MUTEX (kfd_dbgmgr_mutex); - -struct mutex *kfd_get_dbgmgr_mutex (void ) -{ -return &kfd_dbgmgr_mutex; -} - - -static void kfd_dbgmgr_uninitialize (struct kfd_dbgmgr *pmgr) -{ -kfree (pmgr->dbgdev); - - pmgr->dbgdev =NULL ; - pmgr->pasid =0 ; - pmgr->dev =NULL ; -} - -void kfd_dbgmgr_destroy (struct kfd_dbgmgr *pmgr) -{ -if (pmgr) { -kfd_dbgmgr_uninitialize (pmgr); -kfree (pmgr); - } -} - -bool kfd_dbgmgr_create (struct kfd_dbgmgr **ppmgr,struct kfd_dev *pdev) -{ -enum DBGDEV_TYPE type =DBGDEV_TYPE_DIQ ; -struct kfd_dbgmgr *new_buff; - -if (WARN_ON (!pdev->init_complete)) -return false; - - new_buff =kfd_alloc_struct (new_buff); -if (!new_buff) { -pr_err ("Failed to allocate dbgmgr instance\n" ); -return false; - } - - new_buff->pasid =0 ; - new_buff->dev = pdev; - new_buff->dbgdev =kfd_alloc_struct (new_buff->dbgdev); -if (!new_buff->dbgdev) { -pr_err ("Failed to allocate dbgdev instance\n" ); -kfree (new_buff); -return false; - } - -/* get actual type of DBGDevice cpsch or not */ -if (pdev->dqm->sched_policy ==KFD_SCHED_POLICY_NO_HWS ) - type =DBGDEV_TYPE_NODIQ ; - -kfd_dbgdev_init (new_buff->dbgdev, pdev, type); - *ppmgr = new_buff; - -return true; -} - -long kfd_dbgmgr_register (struct kfd_dbgmgr *pmgr,struct kfd_process *p) -{ -if (pmgr->pasid !=0 ) { -pr_debug ("H/W debugger is already active using pasid 0x%x\n" , - pmgr->pasid); -return -EBUSY ; - } - -/* remember pasid */ - pmgr->pasid = p->pasid; - -/* provide the pqm for diq generation */ - pmgr->dbgdev->pqm = &p->pqm; - -/* activate the actual registering */ drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-10- pmgr->dbgdev->dbgdev_register (pmgr->dbgdev); - -return 0 ; -} - -long kfd_dbgmgr_unregister (struct kfd_dbgmgr *pmgr,struct kfd_process *p) -{ -/* Is the requests coming from the already registered process? */ -if (pmgr->pasid != p->pasid) { - pr_debug("H/W debugger is not registered by calling pasid0x%x\n",
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-7- p->pasid); -return -EINVAL ; - } - - pmgr->dbgdev->dbgdev_unregister (pmgr->dbgdev); - - pmgr->pasid =0 ;drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-10- -return 0 ; -} - -long kfd_dbgmgr_wave_control (struct kfd_dbgmgr *pmgr, -struct dbg_wave_control_info *wac_info) -{ -/* Is the requests coming from the already registered process? */ -if (pmgr->pasid != wac_info->process->pasid) { - pr_debug("H/W debugger support was not registered forrequester pasid 0x%x\n",
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-5- wac_info->process->pasid); -return -EINVAL ; - } - - return (long) pmgr->dbgdev->dbgdev_wave_control(pmgr->dbgdev,
wac_info);drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-8-} - -long kfd_dbgmgr_address_watch (struct kfd_dbgmgr *pmgr, -struct dbg_address_watch_info *adw_info) -{ -/* Is the requests coming from the already registered process? */ -if (pmgr->pasid != adw_info->process->pasid) { - pr_debug("H/W debugger support was not registered forrequester pasid 0x%x\n",
Review
Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-8- adw_info->process->pasid); -return -EINVAL ; - } - -return (long ) pmgr->dbgdev->dbgdev_address_watch (pmgr->dbgdev, - adw_info); -} -(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.hQuoted 9 lines
deleted file mode 100644
index f9c6df1fdc5c..000000000000drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-4@@ -1,293 +0,0 @@ -/* -* Copyright 2014 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h line 14
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-10-* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h line 15
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-1-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h line 16
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-1-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h line 17
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-1-* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h line 18
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-1-* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h line 19
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-1-* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-7-* OTHER DEALINGS IN THE SOFTWARE. -* -*/ - -#ifndef KFD_DBGMGR_H_ -#define KFD_DBGMGR_H_ -drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-10-#include "kfd_priv.h" - -/* must align with hsakmttypes definition */ -#pragma pack(push, 4) - -enum HSA_DBG_WAVEOP { -HSA_DBG_WAVEOP_HALT =1 ,/* Halts a wavefront */ -HSA_DBG_WAVEOP_RESUME =2 ,/* Resumes a wavefront */ -HSA_DBG_WAVEOP_KILL =3 ,/* Kills a wavefront */ -HSA_DBG_WAVEOP_DEBUG =4 ,/* Causes wavefront to enter dbg mode */
Quoted 22 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-22-HSA_DBG_WAVEOP_TRAP =5 ,/* Causes wavefront to take a trap */ -HSA_DBG_NUM_WAVEOP =5 , -HSA_DBG_MAX_WAVEOP =0xFFFFFFFF -}; - -enum HSA_DBG_WAVEMODE { -/* send command to a single wave */ -HSA_DBG_WAVEMODE_SINGLE =0 , -/* -* Broadcast to all wavefronts of all processes is not -* supported for HSA user mode -*/ - -/* send to waves within current process */ -HSA_DBG_WAVEMODE_BROADCAST_PROCESS =2 , -/* send to waves within current process on CU */ -HSA_DBG_WAVEMODE_BROADCAST_PROCESS_CU =3 , -HSA_DBG_NUM_WAVEMODE =3 , -HSA_DBG_MAX_WAVEMODE =0xFFFFFFFF -}; - -enum HSA_DBG_WAVEMSG_TYPE {drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-10-HSA_DBG_WAVEMSG_AUTO =0 , -HSA_DBG_WAVEMSG_USER =1 , -HSA_DBG_WAVEMSG_ERROR =2 , -HSA_DBG_NUM_WAVEMSG , -HSA_DBG_MAX_WAVEMSG =0xFFFFFFFF -}; - -enum HSA_DBG_WATCH_MODE { -HSA_DBG_WATCH_READ =0 ,/* Read operations only */ -HSA_DBG_WATCH_NONREAD =1 ,/* Write or Atomic operations only */
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h line 70
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-2-HSA_DBG_WATCH_ATOMIC =2 ,/* Atomic Operations only */ - HSA_DBG_WATCH_ALL = 3, /* Read, Write or Atomicoperations */
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-7-HSA_DBG_WATCH_NUM , -HSA_DBG_WATCH_SIZE =0xFFFFFFFF -}; - -/* This structure is hardware specific and may change in the future */ -struct HsaDbgWaveMsgAMDGen2 { - union {drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-10-struct ui32 { -uint32_t UserData:8 ;/* user data */ -uint32_t ShaderArray:1 ;/* Shader array */ -uint32_t Priv:1 ;/* Privileged */ -uint32_t Reserved0:4 ;/* Reserved, should be 0 */ -uint32_t WaveId:4 ;/* wave id */ -uint32_t SIMD:2 ;/* SIMD id */ -uint32_t HSACU:4 ;/* Compute unit */ -uint32_t ShaderEngine:2 ;/* Shader engine */ -uint32_t MessageType:2 ;/* see
HSA_DBG_WAVEMSG_TYPE*/Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-4- uint32_t Reserved1:4; /* Reserved, should be 0 */ - } ui32; -uint32_t Value; - };drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-10-uint32_t Reserved2; -}; - -union HsaDbgWaveMessageAMD { -struct HsaDbgWaveMsgAMDGen2 WaveMsgInfoGen2; -/* for future HsaDbgWaveMsgAMDGen3; */ -}; - -struct HsaDbgWaveMessage { -void *MemoryVA;/* ptr to associated host-accessible data */
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-9-union HsaDbgWaveMessageAMD DbgWaveMsg; -}; - -/* -* TODO: This definitions to be MOVED to kfd_event, once it is implemented. -* -* HSA sync primitive, Event and HW Exception notification API definitions. -* The API functions allow the runtime to define a so-called sync-primitive, -* a SW object combining a user-mode provided "syncvar" and a scheduler event
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-3-* that can be signaled through a defined GPU interrupt. A syncvar is -* a process virtual memory location of a certain size that can be accessed -* by CPU and GPU shader code within the process to set and query the content
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-3-* within that memory. The definition of the content is determined by the HSA -* runtime and potentially GPU shader code interfacing with the HSA runtime. -* The syncvar values may be commonly written through an PM4
WRITE_DATApacketdrivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-3-* in the user mode instruction stream. The OS scheduler event is typically -* associated and signaled by an interrupt issued by the GPU, but other HSA -* system interrupt conditions from other HW (e.g. IOMMUv2) may be surfaced
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-7-* by the KFD by this mechanism, too. -*/ - -/* these are the new definitions for events */ -enum HSA_EVENTTYPE { -HSA_EVENTTYPE_SIGNAL =0 ,/* user-mode generated GPU signal */ -HSA_EVENTTYPE_NODECHANGE =1 ,/* HSA node change (attach/detach) */
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h line 127
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-1- HSA_EVENTTYPE_DEVICESTATECHANGE = 2, /* HSA device statechange
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-3-* (start/stop) -*/ - HSA_EVENTTYPE_HW_EXCEPTION = 3, /* GPU shader exception event*/
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h line 131
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-1- HSA_EVENTTYPE_SYSTEM_EVENT = 4, /* GPU SYSCALL withparameter info */
Quoted 41 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-41-HSA_EVENTTYPE_DEBUG_EVENT =5 ,/* GPU signal for debugging */ -HSA_EVENTTYPE_PROFILE_EVENT =6 ,/* GPU signal for profiling */ -HSA_EVENTTYPE_QUEUE_EVENT =7 ,/* GPU signal queue idle state -* (EOP pm4) -*/ -/* ... */ -HSA_EVENTTYPE_MAXID , - HSA_EVENTTYPE_TYPE_SIZE = 0xFFFFFFFF -}; - -/* Sub-definitions for various event types: Syncvar */ -struct HsaSyncVar { -union SyncVar { -void *UserData;/* pointer to user mode data */ -uint64_t UserDataPtrValue;/* 64bit compatibility of value */ - } SyncVar; -uint64_t SyncVarSize; -}; - -/* Sub-definitions for various event types: NodeChange */ - -enum HSA_EVENTTYPE_NODECHANGE_FLAGS { -HSA_EVENTTYPE_NODECHANGE_ADD =0 , -HSA_EVENTTYPE_NODECHANGE_REMOVE =1 , -HSA_EVENTTYPE_NODECHANGE_SIZE =0xFFFFFFFF -}; - -struct HsaNodeChange { -/* HSA node added/removed on the platform */ -enum HSA_EVENTTYPE_NODECHANGE_FLAGS Flags; -}; - -/* Sub-definitions for various event types: DeviceStateChange */ -enum HSA_EVENTTYPE_DEVICESTATECHANGE_FLAGS { -/* device started (and available) */ -HSA_EVENTTYPE_DEVICESTATUSCHANGE_START =0 , -/* device stopped (i.e. unavailable) */ -HSA_EVENTTYPE_DEVICESTATUSCHANGE_STOP =1 , -HSA_EVENTTYPE_DEVICESTATUSCHANGE_SIZE =0xFFFFFFFF -}; -drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-10-enum HSA_DEVICE { -HSA_DEVICE_CPU =0 , -HSA_DEVICE_GPU =1 , -MAX_HSA_DEVICE =2 -}; - -struct HsaDeviceStateChange { -uint32_t NodeId;/* F-NUMA node that contains the device */ -enum HSA_DEVICE Device;/* device type: GPU or CPU */ -enum HSA_EVENTTYPE_DEVICESTATECHANGE_FLAGS Flags;/* event flags */
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-5-}; - -struct HsaEventData { - enum HSA_EVENTTYPE EventType; /* event type */ - union EventData {drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-10-/* -* return data associated with HSA_EVENTTYPE_SIGNAL -* and other events -*/ -struct HsaSyncVar SyncVar; - -/* data associated with HSA_EVENTTYPE_NODE_CHANGE */ -struct HsaNodeChange NodeChangeState; - -/* data associated with
HSA_EVENTTYPE_DEVICE_STATE_CHANGE*/Quoted 81 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-81-struct HsaDeviceStateChange DeviceState; - } EventData; - -/* the following data entries are internal to the KFD & thunk itself */ - -/* internal thunk store for Event data (OsEventHandle) */ -uint64_t HWData1; -/* internal thunk store for Event data (HWAddress) */ -uint64_t HWData2; -/* internal thunk store for Event data (HWData) */ -uint32_t HWData3; -}; - -struct HsaEventDescriptor { -/* event type to allocate */ -enum HSA_EVENTTYPE EventType; -/* H-NUMA node containing GPU device that is event source */ -uint32_t NodeId; -/* pointer to user mode syncvar data, syncvar->UserDataPtrValue -* may be NULL -*/ -struct HsaSyncVar SyncVar; -}; - -struct HsaEvent { -uint32_t EventId; -struct HsaEventData EventData; -}; - -#pragma pack(pop) - -enum DBGDEV_TYPE { -DBGDEV_TYPE_ILLEGAL =0 , -DBGDEV_TYPE_NODIQ =1 , -DBGDEV_TYPE_DIQ =2 , -DBGDEV_TYPE_TEST =3 -}; - -struct dbg_address_watch_info { -struct kfd_process *process; -enum HSA_DBG_WATCH_MODE *watch_mode; -uint64_t *watch_address; -uint64_t *watch_mask; -struct HsaEvent *watch_event; -uint32_t num_watch_points; -}; - -struct dbg_wave_control_info { -struct kfd_process *process; -uint32_t trapId; -enum HSA_DBG_WAVEOP operand; -enum HSA_DBG_WAVEMODE mode; -struct HsaDbgWaveMessage dbgWave_msg; -}; - -struct kfd_dbgdev { - -/* The device that owns this data. */ -struct kfd_dev *dev; - -/* kernel queue for DIQ */ -struct kernel_queue *kq; - -/* a pointer to the pqm of the calling process */ -struct process_queue_manager *pqm; - -/* type of debug device ( DIQ, non DIQ, etc. ) */ -enum DBGDEV_TYPE type; - -/* virtualized function pointers to device dbg */ -int (*dbgdev_register)(struct kfd_dbgdev *dbgdev); -int (*dbgdev_unregister)(struct kfd_dbgdev *dbgdev); -int (*dbgdev_address_watch)(struct kfd_dbgdev *dbgdev, -struct dbg_address_watch_info *adw_info); -int (*dbgdev_wave_control)(struct kfd_dbgdev *dbgdev, -struct dbg_wave_control_info *wac_info); - -}; - -struct kfd_dbgmgr { -u32 pasid;drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-10-struct kfd_dev *dev; -struct kfd_dbgdev *dbgdev; -}; - -/* prototypes for debug manager functions */ -struct mutex *kfd_get_dbgmgr_mutex (void ); -void kfd_dbgmgr_destroy (struct kfd_dbgmgr *pmgr); -bool kfd_dbgmgr_create (struct kfd_dbgmgr **ppmgr,struct kfd_dev *pdev); -long kfd_dbgmgr_register (struct kfd_dbgmgr *pmgr,struct kfd_process *p); -long kfd_dbgmgr_unregister(struct kfd_dbgmgr *pmgr, struct kfd_process*p);
Review
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-5-long kfd_dbgmgr_wave_control (struct kfd_dbgmgr *pmgr, -struct dbg_wave_control_info *wac_info); -long kfd_dbgmgr_address_watch (struct kfd_dbgmgr *pmgr, -struct dbg_address_watch_info *adw_info); -#endif /* KFD_DBGMGR_H_ */ (quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_device.cReview
Quoted 13 lines
index
5a47f437b455..dbb877fba724100644drivers/gpu/drm/amd/amdkfd/kfd_device.c +0
-2@@ -575,8 +575,6 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,if (kfd_resume (kfd)) goto kfd_resume_error; - kfd->dbgmgr =NULL ; -if (kfd_topology_add_device (kfd)) {dev_err (kfd_device,"Error adding device to topology\n" ); goto kfd_topology_add_device_error;(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.cdrivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static inline void deallocate_hqd(struct
Quoted 4 lines
index
63b3c7af681b..f5d82f257dbb100644drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0@@ -480,6 +480,65 @@ static inline void deallocate_hqd(struct
device_queue_manager*dqm,drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static inline void deallocate_hqd(struct device_queue_manager *dqm,
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +4
-0dqm->allocated_queues[q->pipe] |= (1 << q->queue); } +#define SQ_IND_CMD_CMD_KILL 0x00000003 +#define SQ_IND_CMD_MODE_BROADCAST 0x00000001 + +static int dbgdev_wave_reset_wavefronts(struct kfd_dev *dev, struct
kfd_process*p)Quoted 16 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +16
-0+{ +int status =0 ; +unsigned int vmid; +uint16_t queried_pasid; +union SQ_CMD_BITS reg_sq_cmd; +union GRBM_GFX_INDEX_BITS reg_gfx_index; +struct kfd_process_device *pdd; +int first_vmid_to_scan = dev->vm_info.first_vmid_kfd; +int last_vmid_to_scan = dev->vm_info.last_vmid_kfd; + + reg_sq_cmd.u32All =0 ; + reg_gfx_index.u32All =0 ; + +pr_debug ("Killing all process wavefronts\n" ); + +/* Scan all registers in the range ATC_VMID8_PASID_MAPPING .. drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static inline void deallocate_hqd(struct device_queue_manager *dqm,
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +10
-0+* ATC_VMID15_PASID_MAPPING +* to check which VMID the current process is mapped to. +*/ + +for (vmid = first_vmid_to_scan; vmid <= last_vmid_to_scan; vmid++) { + status = dev->kfd2kgd->get_atc_vmid_pasid_mapping_info + (dev->adev, vmid, &queried_pasid); + +if (status && queried_pasid == p->pasid) { + pr_debug("Killing wave fronts of vmid %d and pasid0x%x\n",
Quoted 20 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +20
-0+ vmid, p->pasid); +break ; + } + } + +if (vmid > last_vmid_to_scan) { +pr_err ("Didn't find vmid for pasid 0x%x\n" , p->pasid); +return -EFAULT ; + } + +/* taking the VMID for that process on the safe way using PDD */ + pdd =kfd_get_process_device_data (dev, p); +if (!pdd) +return -EFAULT ; + + reg_gfx_index.bits.sh_broadcast_writes =1 ; + reg_gfx_index.bits.se_broadcast_writes =1 ; + reg_gfx_index.bits.instance_broadcast_writes =1 ; + reg_sq_cmd.bits.mode =SQ_IND_CMD_MODE_BROADCAST ; + reg_sq_cmd.bits.cmd =SQ_IND_CMD_CMD_KILL ;drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static inline void deallocate_hqd(struct device_queue_manager *dqm,
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +9
-0+ reg_sq_cmd.bits.vm_id = vmid; + + dev->kfd2kgd->wave_control_execute (dev->adev, + reg_gfx_index.u32All, + reg_sq_cmd.u32All); + +return 0 ; +} +/* Access to DQM has to be locked before calling
destroy_queue_nocpsch_lockedReview
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0* to avoid asynchronized access */ (quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.hReview
Quoted 46 lines
index
a7d2e3323977..05a9c17daa3e100644drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h +35
-0@@ -39,6 +39,41 @@ struct device_process_node {struct list_head list; }; +union SQ_CMD_BITS { +struct { +uint32_t cmd:3 ; + uint32_t:1; +uint32_t mode:3 ; +uint32_t check_vmid:1 ; +uint32_t trap_id:3 ; + uint32_t:5; +uint32_t wave_id:4 ; +uint32_t simd_id:2 ; + uint32_t:2; +uint32_t queue_id:3 ; + uint32_t:1; +uint32_t vm_id:4 ; + } bitfields, bits; +uint32_t u32All; +signed int i32All; +float f32All; +}; + +union GRBM_GFX_INDEX_BITS { +struct { +uint32_t instance_index:8 ; +uint32_t sh_index:8 ; +uint32_t se_index:8 ; + uint32_t:5; +uint32_t sh_broadcast_writes:1 ; +uint32_t instance_broadcast_writes:1 ; +uint32_t se_broadcast_writes:1 ; + } bitfields, bits; +uint32_t u32All; +signed int i32All; +float f32All; +}; +/** * struct device_queue_manager_ops * (quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_iommu.cdrivers/gpu/drm/amd/amdkfd/kfd_iommu.c static void iommu_pasid_shutdown_callback(struct
Quoted 12 lines
index
66ad8d0b8f7f..fe62407dacb2100644drivers/gpu/drm/amd/amdkfd/kfd_iommu.c +0
-1@@ -30,7 +30,6 @@#include <linux/pci.h> #include <linux/amd-iommu.h> #include "kfd_priv.h" -#include "kfd_dbgmgr.h" #include "kfd_topology.h" #include "kfd_iommu.h" @@ -163,17 +162,6 @@ static void iommu_pasid_shutdown_callback(struct
pci_dev*pdev, u32 pasid)Review
Quoted 18 lines
drivers/gpu/drm/amd/amdkfd/kfd_iommu.c +0
-11pr_debug ("Unbinding process 0x%x from IOMMU\n" , pasid); -mutex_lock (kfd_get_dbgmgr_mutex ()); - -if (dev->dbgmgr && dev->dbgmgr->pasid == p->pasid) { -if (!kfd_dbgmgr_unregister (dev->dbgmgr, p)) { -kfd_dbgmgr_destroy (dev->dbgmgr); - dev->dbgmgr =NULL ; - } - } - -mutex_unlock (kfd_get_dbgmgr_mutex ()); -mutex_lock (&p->mutex); pdd =kfd_get_process_device_data (dev, p);(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_priv.hdrivers/gpu/drm/amd/amdkfd/kfd_priv.h void kfd_signal_poison_consumed_event(struct
Quoted 14 lines
index
74ff4132a163..465aae8e5697100644drivers/gpu/drm/amd/amdkfd/kfd_priv.h +0
-3@@ -300,9 +300,6 @@ struct kfd_dev {*/ bool interrupts_active; -/* Debug manager */ -struct kfd_dbgmgr *dbgmgr; -/* Firmware versions */ uint16_t mec_fw_version;uint16_t mec2_fw_version;@@ -1331,8 +1328,6 @@ void kfd_signal_poison_consumed_event(struct
kfd_dev*dev, u32 pasid);drivers/gpu/drm/amd/amdkfd/kfd_priv.h void kfd_signal_poison_consumed_event(struct · line 1328
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +0
-0void kfd_flush_tlb(struct kfd_process_device *pdd, enum TLB_FLUSH_TYPEtype);
drivers/gpu/drm/amd/amdkfd/kfd_priv.h void kfd_signal_poison_consumed_event(struct · line 1332
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +0
-1-int dbgdev_wave_reset_wavefronts(struct kfd_dev *dev, struct kfd_process*p);
Review
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +0
-1-bool kfd_is_locked (void );/* Compute profile */ (quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_process.cdrivers/gpu/drm/amd/amdkfd/kfd_process.c static void kfd_process_notifier_release(struct
Quoted 12 lines
index
8e2780d2f735..8c6a48add76e100644drivers/gpu/drm/amd/amdkfd/kfd_process.c +0
-1@@ -40,7 +40,6 @@ struct mm_struct;#include "kfd_priv.h" #include "kfd_device_queue_manager.h" -#include "kfd_dbgmgr.h" #include "kfd_iommu.h" #include "kfd_svm.h" @@ -1158,7 +1157,6 @@ static void kfd_process_notifier_release(struct
mmu_notifier*mn,drivers/gpu/drm/amd/amdkfd/kfd_process.c static void kfd_process_notifier_release(struct
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +0
-1struct mm_struct *mm) {struct kfd_process *p; -int i;/* * The kfd_process structure can not be free because the @@ -1178,23 +1176,6 @@ static void kfd_process_notifier_release(struct
mmu_notifier*mn,Quoted 23 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +0
-17mutex_lock (&p->mutex); -/* Iterate over all process device data structures and if the -* pdd is in debug mode, we should first force unregistration, -* then we will be able to destroy the queues -*/ -for (i =0 ; i < p->n_pdds; i++) { -struct kfd_dev *dev = p->pdds[i]->dev; - -mutex_lock (kfd_get_dbgmgr_mutex ()); -if (dev && dev->dbgmgr && dev->dbgmgr->pasid == p->pasid) { -if (!kfd_dbgmgr_unregister (dev->dbgmgr, p)) { -kfd_dbgmgr_destroy (dev->dbgmgr); - dev->dbgmgr =NULL ; - } - } -mutex_unlock (kfd_get_dbgmgr_mutex ()); - } -kfd_process_dequeue_from_all_devices (p);pqm_uninit (&p->pqm);
Felix Kuehling
maintainerRe: [PATCH 2/3] drm/amdkfd: Remove unused old debugger implementation
Am 2022-02-07 um 12:10 schrieb Joshi, Mukul:
Quoted 25 lines
[AMD Official Use Only]
Quoted 14 lines
-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Monday, February 7, 2022 10:33 AM
To: Joshi, Mukul <[email protected]>; [email protected]
Subject: Re: [PATCH 2/3] drm/amdkfd: Remove unused old debugger implementationAm 2022-02-04 um 18:45 schrieb Mukul Joshi:
Quoted 5 lines
Cleanup the kfd code by removing the unused old debugger implementation.
Only a small piece of resetting wavefronts is kept and is moved tokfd_device_queue_manager.cQuoted 7 lines
Quoted 1 line
Signed-off-by Mukul Joshi <[email protected]>We should update
include/uapi/linux/kfd_ioctl.has well to mark the ioctls as deprecated. Just rename the AMDKFD_IOC_DBG_* macros to AMDKFD_IOC_DBG_*_DEPRECATED. A corresponding update to the Thunk would
be good as a follow up.
Quoted 3 lines
Would it require an update to the KFD ioctl minor version?
Wouldn't it be better to just increment the minor version for ioctl and say these aren't supported after this version instead of changing the name?
I don't think that would help anyone. If existing (really old) user mode was using it, they would not be checking the version number. All they get is -EPERM from the ioctls. And new user mode code will not be using these APIs and has no reason to check the version number.
Regards,
Felix
Quoted 2,254 lines
Regards,
MukulQuoted 2,250 lines
I think there is also some more code you can remove in amdgpu_amdkfd_gfx_v*.c and
kgd_kfd_interface.h:int (*address_watch_disable)(struct
amdgpu_device*adev); int (*address_watch_execute)(structamdgpu_device*adev, unsigned intwatch_point_id,uint32_tcntl_val,uint32_taddr_hi,uint32_taddr_lo);uint32_t(*address_watch_get_offset)(structamdgpu_device*adev, unsigned intwatch_point_id, unsigned intreg_offset);It seems
wave_control_executeis still used indbgdev_wave_reset_wavefronts.Regards,
FelixQuoted 14 lines
--- drivers/gpu/drm/amd/amdkfd/Makefile | 2 - drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 282 +----- drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c | 845 ------------------ drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h | 230 ----- drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c | 158 ---- drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h | 293 ------ drivers/gpu/drm/amd/amdkfd/kfd_device.c | 2 - .../drm/amd/amdkfd/kfd_device_queue_manager.c | 59 ++ .../drm/amd/amdkfd/kfd_device_queue_manager.h | 35 + drivers/gpu/drm/amd/amdkfd/kfd_iommu.c | 12 - drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 5 - drivers/gpu/drm/amd/amdkfd/kfd_process.c | 19 - 12 files changed, 98 insertions(+), 1844 deletions(-)Review
Quoted 6 lines
delete mode 100644
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.cdelete mode 100644drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.hdelete mode 100644drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.cdelete mode 100644drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h(quoted diff) +0
-0b/drivers/gpu/drm/amd/amdkfd/Makefile
Review
Quoted 13 lines
index
c4f3aff11072..19cfbf9577b4100644drivers/gpu/drm/amd/amdkfd/Makefile +0
-2@@ -51,8 +51,6 @@ AMDKFD_FILES := $(AMDKFD_PATH)/kfd_module.o \ $(AMDKFD_PATH)/kfd_events.o \ $(AMDKFD_PATH)/cik_event_interrupt.o \ $(AMDKFD_PATH)/kfd_int_process_v9.o \ - $(AMDKFD_PATH)/kfd_dbgdev.o \ - $(AMDKFD_PATH)/kfd_dbgmgr.o \ $(AMDKFD_PATH)/kfd_smi_events.o \ $(AMDKFD_PATH)/kfd_crat.o(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.cdrivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file
Quoted 12 lines
index
64e3b4e3a712..cfe12525165f100644drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-1@@ -39,7 +39,6 @@#include <asm/processor.h> #include "kfd_priv.h" #include "kfd_device_queue_manager.h" -#include "kfd_dbgmgr.h" #include "kfd_svm.h" #include "amdgpu_amdkfd.h" #include "kfd_smi_events.h" @@ -580,299 +579,26 @@ static int kfd_ioctl_set_trap_handler(struct file*filep,
Quoted 121 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2
-106static int kfd_ioctl_dbg_register (struct file *filep,struct kfd_process *p,void *data) { -struct kfd_ioctl_dbg_register_args *args = data; -struct kfd_dev *dev; -struct kfd_dbgmgr *dbgmgr_ptr; -struct kfd_process_device *pdd; -bool create_ok; -long status =0 ; - -mutex_lock (&p->mutex); - pdd =kfd_process_device_data_by_id (p, args->gpu_id); -if (!pdd) { - status = -EINVAL ; - goto err_pdd; - } - dev = pdd->dev; - -if (dev->adev->asic_type ==CHIP_CARRIZO ) { -pr_debug ("kfd_ioctl_dbg_register not supported on CZ\n" ); - status = -EINVAL ; - goto err_chip_unsupp; - } - -mutex_lock (kfd_get_dbgmgr_mutex ()); - -/* -* make sure that we have pdd, if this the first queue created for -* this process -*/ - pdd =kfd_bind_process_to_device (dev, p); -if (IS_ERR (pdd)) { - status =PTR_ERR (pdd); - goto out; - } - -if (!dev->dbgmgr) { -/* In case of a legal call, we have no dbgmgr yet */ - create_ok =kfd_dbgmgr_create (&dbgmgr_ptr, dev); -if (create_ok) { - status =kfd_dbgmgr_register (dbgmgr_ptr, p); -if (status !=0 ) -kfd_dbgmgr_destroy (dbgmgr_ptr); -else - dev->dbgmgr = dbgmgr_ptr; - } - }else { -pr_debug ("debugger already registered\n" ); - status = -EINVAL ; - } - -out: -mutex_unlock (kfd_get_dbgmgr_mutex ()); -err_pdd: -err_chip_unsupp: -mutex_unlock (&p->mutex); - -return status; +return -EPERM ; }static int kfd_ioctl_dbg_unregister (struct file *filep,struct kfd_process *p,void *data) { -struct kfd_ioctl_dbg_unregister_args *args = data; -struct kfd_process_device *pdd; -struct kfd_dev *dev; -long status; - -mutex_lock (&p->mutex); - pdd =kfd_process_device_data_by_id (p, args->gpu_id); -mutex_unlock (&p->mutex); -if (!pdd || !pdd->dev->dbgmgr) -return -EINVAL ; - - dev = pdd->dev; - -if (dev->adev->asic_type ==CHIP_CARRIZO ) { -pr_debug ("kfd_ioctl_dbg_unregister not supported on CZ\n" ); -return -EINVAL ; - } - -mutex_lock (kfd_get_dbgmgr_mutex ()); - - status =kfd_dbgmgr_unregister (dev->dbgmgr, p); -if (!status) { -kfd_dbgmgr_destroy (dev->dbgmgr); - dev->dbgmgr =NULL ; - } - -mutex_unlock (kfd_get_dbgmgr_mutex ()); - -return status; +return -EPERM ; } -/* -* Parse and generate variable size data structure for address watch. -* Total size of the buffer and # watch points is limited in order -* to prevent kernel abuse. (no bearing to the much smaller HW limitation -* which is enforced by dbgdev module) -* please also note that the watch address itself are not "copied from user", -* since it be set into the HW in user mode values. -* -*/ static int kfd_ioctl_dbg_address_watch (struct file *filep,struct kfd_process *p,void *data) { -struct kfd_ioctl_dbg_address_watch_args *args = data; -struct kfd_dev *dev; -struct kfd_process_device *pdd; -struct dbg_address_watch_info aw_info; -unsigned char *args_buff; -long status; -void __user *cmd_from_user; -uint64_t watch_mask_value =0 ; -unsigned int args_idx =0 ; - -memset ((void *) &aw_info,0 ,sizeof (struct dbg_address_watch_info )); - -mutex_lock (&p->mutex);drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file *filep,
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-10- pdd =kfd_process_device_data_by_id (p, args->gpu_id); -mutex_unlock (&p->mutex); -if (!pdd) { -pr_debug ("Could not find gpu id 0x%x\n" , args->gpu_id); -return -EINVAL ; - } - dev = pdd->dev; - -if (dev->adev->asic_type ==CHIP_CARRIZO ) { - pr_debug("kfd_ioctl_dbg_wave_control not supported onCZ\n");
Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-13-return -EINVAL ; - } - cmd_from_user = (void __user *) args->content_ptr; - -/* Validate arguments */ - -if ((args->buf_size_in_bytes >MAX_ALLOWED_AW_BUFF_SIZE ) || - (args->buf_size_in_bytes <=sizeof (*args) +sizeof (int ) *2 ) || - (cmd_from_user ==NULL )) -return -EINVAL ; - -/* this is the actual buffer to work with */ - args_buff = memdup_user(cmd_from_user,drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file *filep,
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-10- args->buf_size_in_bytes - sizeof(*args)); -if (IS_ERR (args_buff)) -return PTR_ERR (args_buff); - - aw_info.process = p; - - aw_info.num_watch_points = *((uint32_t *)(&args_buff[args_idx])); - args_idx +=sizeof (aw_info.num_watch_points); - - aw_info.watch_mode = (enum HSA_DBG_WATCH_MODE *)&args_buff[args_idx];
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file · line 732
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-1- args_idx += sizeof(enum HSA_DBG_WATCH_MODE) *aw_info.num_watch_points;
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file *filep,
Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-9- -/* -* set watch address base pointer to point on the array base -* within args_buff -*/ - aw_info.watch_address = (uint64_t *) &args_buff[args_idx]; - -/* skip over the addresses buffer */ - args_idx += sizeof(aw_info.watch_address) *aw_info.num_watch_points;
Quoted 57 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +1
-50- -if (args_idx >= args->buf_size_in_bytes -sizeof (*args)) { - status = -EINVAL ; - goto out; - } - - watch_mask_value = (uint64_t ) args_buff[args_idx]; - -if (watch_mask_value >0 ) { -/* -* There is an array of masks. -* set watch mask base pointer to point on the array base -* within args_buff -*/ - aw_info.watch_mask = (uint64_t *) &args_buff[args_idx]; - -/* skip over the masks buffer */ - args_idx +=sizeof (aw_info.watch_mask) * - aw_info.num_watch_points; - }else { -/* just the NULL mask, set to NULL and skip over it */ - aw_info.watch_mask =NULL ; - args_idx +=sizeof (aw_info.watch_mask); - } - -if (args_idx >= args->buf_size_in_bytes -sizeof (args)) { - status = -EINVAL ; - goto out; - } - -/* Currently HSA Event is not supported for DBG */ - aw_info.watch_event =NULL ; - -mutex_lock (kfd_get_dbgmgr_mutex ()); - - status =kfd_dbgmgr_address_watch (dev->dbgmgr, &aw_info); - -mutex_unlock (kfd_get_dbgmgr_mutex ()); - -out: -kfree (args_buff); - -return status; +return -EPERM ; }/* Parse and generate fixed size data structure for wave control */ static int kfd_ioctl_dbg_wave_control (struct file *filep,struct kfd_process *p,void *data) { -struct kfd_ioctl_dbg_wave_control_args *args = data; -struct kfd_dev *dev; -struct kfd_process_device *pdd; -struct dbg_wave_control_info wac_info; -unsigned char *args_buff; -uint32_t computed_buff_size; -long status;drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file *filep,
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-10-void __user *cmd_from_user; -unsigned int args_idx =0 ; - -memset ((void *) &wac_info,0 ,sizeof (struct dbg_wave_control_info )); - -/* we use compact form, independent of the packing attribute value */ - computed_buff_size =sizeof (*args) + -sizeof (wac_info.mode) + -sizeof (wac_info.operand) + -sizeof (wac_info.dbgWave_msg.DbgWaveMsg)+
Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-4-sizeof (wac_info.dbgWave_msg.MemoryVA) + -sizeof (wac_info.trapId); - -mutex_lock (&p->mutex);drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file *filep,
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-10- pdd =kfd_process_device_data_by_id (p, args->gpu_id); -mutex_unlock (&p->mutex); -if (!pdd) { -pr_debug ("Could not find gpu id 0x%x\n" , args->gpu_id); -return -EINVAL ; - } - dev = pdd->dev; - -if (dev->adev->asic_type ==CHIP_CARRIZO ) { - pr_debug("kfd_ioctl_dbg_wave_control not supported onCZ\n");
Quoted 16 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-16-return -EINVAL ; - } - -/* input size must match the computed "compact" size */ -if (args->buf_size_in_bytes != computed_buff_size) { -pr_debug ("size mismatch, computed : actual %u : %u\n" , - args->buf_size_in_bytes, computed_buff_size); -return -EINVAL ; - } - - cmd_from_user = (void __user *) args->content_ptr; - -if (cmd_from_user ==NULL ) -return -EINVAL ; - -/* copy the entire buffer from user */ drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file *filep,
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-10- - args_buff =memdup_user (cmd_from_user, - args->buf_size_in_bytes -sizeof (*args)); -if (IS_ERR (args_buff)) -return PTR_ERR (args_buff); - -/* move ptr to the start of the "pay-load" area */ - wac_info.process = p; - - wac_info.operand = *((enum HSA_DBG_WAVEOP*)(&args_buff[args_idx]));
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file *filep,
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-3- args_idx +=sizeof (wac_info.operand); - - wac_info.mode = *((enum HSA_DBG_WAVEMODE*)(&args_buff[args_idx]));
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file *filep,
Quoted 12 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-12- args_idx +=sizeof (wac_info.mode); - - wac_info.trapId = *((uint32_t *)(&args_buff[args_idx])); - args_idx +=sizeof (wac_info.trapId); - - wac_info.dbgWave_msg.DbgWaveMsg.WaveMsgInfoGen2.Value = - *((uint32_t *)(&args_buff[args_idx])); - wac_info.dbgWave_msg.MemoryVA =NULL ; - -mutex_lock (kfd_get_dbgmgr_mutex ()); - - pr_debug("Calling dbg manager process %p, operand %u, mode %u,trapId %u, message %u\n",
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int kfd_ioctl_set_trap_handler(struct file *filep, · line 866
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0
-3- wac_info.process, wac_info.operand, - wac_info.mode, wac_info.trapId, -wac_info.dbgWave_msg.DbgWaveMsg.WaveMsgInfoGen2.Value);Review
Quoted 15 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +1
-10- - status =kfd_dbgmgr_wave_control (dev->dbgmgr, &wac_info); - -pr_debug ("Returned status of dbg manager is %ld\n" , status); - -mutex_unlock (kfd_get_dbgmgr_mutex ()); - -kfree (args_buff); - -return status; +return -EPERM ; } static int kfd_ioctl_get_clock_counters(struct file *filep,(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.cQuoted 9 lines
deleted file mode 100644
index 8eca9ed3ab36..000000000000drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-4@@ -1,845 +0,0 @@ -/* -* Copyright 2014 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c line 14
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10-* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c line 15
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-1-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c line 16
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-1-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c line 17
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-1-* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c line 18
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-1-* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c line 19
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-1-* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
Quoted 101 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-101-* OTHER DEALINGS IN THE SOFTWARE. -* -*/ - -#include <linux/types.h> -#include <linux/kernel.h> -#include <linux/log2.h> -#include <linux/sched.h> -#include <linux/slab.h> -#include <linux/mutex.h> -#include <linux/device.h> - -#include "kfd_pm4_headers.h" -#include "kfd_pm4_headers_diq.h" -#include "kfd_kernel_queue.h" -#include "kfd_priv.h" -#include "kfd_pm4_opcodes.h" -#include "cik_regs.h" -#include "kfd_dbgmgr.h" -#include "kfd_dbgdev.h" -#include "kfd_device_queue_manager.h" - -static void dbgdev_address_watch_disable_nodiq (struct kfd_dev *dev) -{ - dev->kfd2kgd->address_watch_disable (dev->adev); -} - -static int dbgdev_diq_submit_ib (struct kfd_dbgdev *dbgdev, -u32 pasid,uint64_t vmid0_address, -uint32_t *packet_buff,size_t size_in_bytes) -{ -struct pm4__release_mem *rm_packet; -struct pm4__indirect_buffer_pasid *ib_packet; -struct kfd_mem_obj *mem_obj; -size_t pq_packets_size_in_bytes; -union ULARGE_INTEGER *largep; -union ULARGE_INTEGER addr; -struct kernel_queue *kq; -uint64_t *rm_state; -unsigned int *ib_packet_buff; -int status; - -if (WARN_ON (!size_in_bytes)) -return -EINVAL ; - - kq = dbgdev->kq; - - pq_packets_size_in_bytes =sizeof (struct pm4__release_mem ) + -sizeof (struct pm4__indirect_buffer_pasid ); - -/* -* We acquire a buffer from DIQ -* The receive packet buff will be sitting on the Indirect Buffer -* and in the PQ we put the IB packet + sync packet(s). -*/ - status =kq_acquire_packet_buffer (kq, - pq_packets_size_in_bytes /sizeof (uint32_t ), - &ib_packet_buff); -if (status) { -pr_err ("kq_acquire_packet_buffer failed\n" ); -return status; - } - -memset (ib_packet_buff,0 , pq_packets_size_in_bytes); - - ib_packet = (struct pm4__indirect_buffer_pasid *) (ib_packet_buff); - - ib_packet->header.count =3 ; - ib_packet->header.opcode =IT_INDIRECT_BUFFER_PASID ; - ib_packet->header.type =PM4_TYPE_3 ; - - largep = (union ULARGE_INTEGER *) &vmid0_address; - - ib_packet->bitfields2.ib_base_lo = largep->u.low_part >>2 ; - ib_packet->bitfields3.ib_base_hi = largep->u.high_part; - - ib_packet->control = (1 <<23 ) | (1 <<31 ) | - ((size_in_bytes /4 ) &0xfffff ); - - ib_packet->bitfields5.pasid = pasid; - -/* -* for now we use release mem for GPU-CPU synchronization -* Consider WaitRegMem + WriteData as a better alternative -* we get a GART allocations ( gpu/cpu mapping), -* for the sync variable, and wait until: -* (a) Sync with HW -* (b) Sync var is written by CP to mem. -*/ - rm_packet = (struct pm4__release_mem *) (ib_packet_buff + - (sizeof (struct pm4__indirect_buffer_pasid ) / -sizeof (unsigned int ))); - - status =kfd_gtt_sa_allocate (dbgdev->dev,sizeof (uint64_t ), - &mem_obj); - -if (status) { -pr_err ("Failed to allocate GART memory\n" ); -kq_rollback_packet (kq); -return status; - }drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10- - rm_state = (uint64_t *) mem_obj->cpu_ptr; - - *rm_state =QUEUESTATE__ACTIVE_COMPLETION_PENDING ; - - rm_packet->header.opcode =IT_RELEASE_MEM ; - rm_packet->header.type =PM4_TYPE_3 ; - rm_packet->header.count =sizeof (struct pm4__release_mem ) /4 -2 ; - - rm_packet->bitfields2.event_type =
CACHE_FLUSH_AND_INV_TS_EVENT;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-4- rm_packet->bitfields2.event_index = - event_index___release_mem__end_of_pipe; - - rm_packet->bitfields2.cache_policy =
cache_policy___release_mem__lru;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c line 148
Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-13- rm_packet->bitfields2.atc =0 ; - rm_packet->bitfields2.tc_wb_action_ena =1 ; - - addr.quad_part = mem_obj->gpu_addr; - - rm_packet->bitfields4.address_lo_32b = addr.u.low_part >>2 ; - rm_packet->address_hi = addr.u.high_part; - - rm_packet->bitfields3.data_sel = - data_sel___release_mem__send_64_bit_data; - - rm_packet->bitfields3.int_sel = -int_sel___release_mem__send_data_after_write_confirm;Quoted 89 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-89- - rm_packet->bitfields3.dst_sel = - dst_sel___release_mem__memory_controller; - - rm_packet->data_lo =QUEUESTATE__ACTIVE ; - -kq_submit_packet (kq); - -/* Wait till CP writes sync code: */ - status =amdkfd_fence_wait_timeout ( - rm_state, -QUEUESTATE__ACTIVE ,1500 ); - -kfd_gtt_sa_free (dbgdev->dev, mem_obj); - -return status; -} - -static int dbgdev_register_nodiq (struct kfd_dbgdev *dbgdev) -{ -/* -* no action is needed in this case, -* just make sure diq will not be used -*/ - - dbgdev->kq =NULL ; - -return 0 ; -} - -static int dbgdev_register_diq (struct kfd_dbgdev *dbgdev) -{ -struct queue_properties properties; -unsigned int qid; -struct kernel_queue *kq =NULL ; -int status; - - properties.type =KFD_QUEUE_TYPE_DIQ ; - - status =pqm_create_queue (dbgdev->pqm, dbgdev->dev,NULL , - &properties, &qid,NULL ,NULL ,NULL ,NULL ); - -if (status) { -pr_err ("Failed to create DIQ\n" ); -return status; - } - -pr_debug ("DIQ Created with queue id: %d\n" , qid); - - kq =pqm_get_kernel_queue (dbgdev->pqm, qid); - -if (!kq) { -pr_err ("Error getting DIQ\n" ); -pqm_destroy_queue (dbgdev->pqm, qid); -return -EFAULT ; - } - - dbgdev->kq = kq; - -return status; -} - -static int dbgdev_unregister_nodiq (struct kfd_dbgdev *dbgdev) -{ -/* disable watch address */ -dbgdev_address_watch_disable_nodiq (dbgdev->dev); -return 0 ; -} - -static int dbgdev_unregister_diq (struct kfd_dbgdev *dbgdev) -{ -/* todo - disable address watch */ -int status; - - status =pqm_destroy_queue (dbgdev->pqm, - dbgdev->kq->queue->properties.queue_id); - dbgdev->kq =NULL ; - -return status; -} - -static void dbgdev_address_watch_set_registers ( -const struct dbg_address_watch_info *adw_info, -union TCP_WATCH_ADDR_H_BITS *addrHi, -union TCP_WATCH_ADDR_L_BITS *addrLo, -union TCP_WATCH_CNTL_BITS *cntl, -unsigned int index,unsigned int vmid) -{ -union ULARGE_INTEGER addr;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c line 249
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10- - addr.quad_part =0 ; - addrHi->u32All =0 ; - addrLo->u32All =0 ; - cntl->u32All =0 ; - -if (adw_info->watch_mask) - cntl->bitfields.mask = - (uint32_t) (adw_info->watch_mask[index] & -ADDRESS_WATCH_REG_CNTL_DEFAULT_MASK);drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c line 248
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-2-else - cntl->bitfields.mask =
ADDRESS_WATCH_REG_CNTL_DEFAULT_MASK;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c line 256
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-2- - addr.quad_part = (unsigned long long) adw_info-watch_address[index];
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-3- - addrHi->bitfields.addr = addr.u.high_part & -ADDRESS_WATCH_REG_ADDHIGH_MASK;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-2- addrLo->bitfields.addr = - (addr.u.low_part >>
ADDRESS_WATCH_REG_ADDLOW_SHIFT);Quoted 37 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-37- - cntl->bitfields.mode = adw_info->watch_mode[index]; - cntl->bitfields.vmid = (uint32_t ) vmid; -/* for now assume it is an ATC address */ - cntl->u32All |=ADDRESS_WATCH_REG_CNTL_ATC_BIT ; - -pr_debug ("\t\t%20s %08x\n" ,"set reg mask :" , cntl->bitfields.mask); -pr_debug ("\t\t%20s %08x\n" ,"set reg add high :" , - addrHi->bitfields.addr); -pr_debug ("\t\t%20s %08x\n" ,"set reg add low :" , - addrLo->bitfields.addr); -} - -static int dbgdev_address_watch_nodiq (struct kfd_dbgdev *dbgdev, -struct dbg_address_watch_info *adw_info) -{ -union TCP_WATCH_ADDR_H_BITS addrHi; -union TCP_WATCH_ADDR_L_BITS addrLo; -union TCP_WATCH_CNTL_BITS cntl; -struct kfd_process_device *pdd; -unsigned int i; - -/* taking the vmid for that process on the safe way using pdd */ - pdd =kfd_get_process_device_data (dbgdev->dev, - adw_info->process); -if (!pdd) { -pr_err ("Failed to get pdd for wave control no DIQ\n" ); -return -EFAULT ; - } - - addrHi.u32All =0 ; - addrLo.u32All =0 ; - cntl.u32All =0 ; - -if ((adw_info->num_watch_points >MAX_WATCH_ADDRESSES ) || - (adw_info->num_watch_points ==0 )) { -pr_err ("num_watch_points is invalid\n" );drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10-return -EINVAL ; - } - -if (!adw_info->watch_mode || !adw_info->watch_address) { -pr_err ("adw_info fields are not valid\n" ); -return -EINVAL ; - } - -for (i =0 ; i < adw_info->num_watch_points; i++) { - dbgdev_address_watch_set_registers(adw_info, &addrHi,&addrLo,
Quoted 70 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-70- &cntl, i, pdd->qpd.vmid); - -pr_debug ("\t\t%30s\n" ,"* * * * * * * * * * * * * * * * * *" ); -pr_debug ("\t\t%20s %08x\n" ,"register index :" , i); -pr_debug ("\t\t%20s %08x\n" ,"vmid is :" , pdd->qpd.vmid); -pr_debug ("\t\t%20s %08x\n" ,"Address Low is :" , - addrLo.bitfields.addr); -pr_debug ("\t\t%20s %08x\n" ,"Address high is :" , - addrHi.bitfields.addr); -pr_debug ("\t\t%20s %08x\n" ,"Address high is :" , - addrHi.bitfields.addr); -pr_debug ("\t\t%20s %08x\n" ,"Control Mask is :" , - cntl.bitfields.mask); -pr_debug ("\t\t%20s %08x\n" ,"Control Mode is :" , - cntl.bitfields.mode); -pr_debug ("\t\t%20s %08x\n" ,"Control Vmid is :" , - cntl.bitfields.vmid); -pr_debug ("\t\t%20s %08x\n" ,"Control atc is :" , - cntl.bitfields.atc); -pr_debug ("\t\t%30s\n" ,"* * * * * * * * * * * * * * * * * *" ); - - pdd->dev->kfd2kgd->address_watch_execute ( - dbgdev->dev->adev, - i, - cntl.u32All, - addrHi.u32All, - addrLo.u32All); - } - -return 0 ; -} - -static int dbgdev_address_watch_diq (struct kfd_dbgdev *dbgdev, -struct dbg_address_watch_info *adw_info) -{ -struct pm4__set_config_reg *packets_vec; -union TCP_WATCH_ADDR_H_BITS addrHi; -union TCP_WATCH_ADDR_L_BITS addrLo; -union TCP_WATCH_CNTL_BITS cntl; -struct kfd_mem_obj *mem_obj; -unsigned int aw_reg_add_dword; -uint32_t *packet_buff_uint; -unsigned int i; -int status; -size_t ib_size =sizeof (struct pm4__set_config_reg ) *4 ; -/* we do not control the vmid in DIQ mode, just a place holder */ -unsigned int vmid =0 ; - - addrHi.u32All =0 ; - addrLo.u32All =0 ; - cntl.u32All =0 ; - -if ((adw_info->num_watch_points >MAX_WATCH_ADDRESSES ) || - (adw_info->num_watch_points ==0 )) { -pr_err ("num_watch_points is invalid\n" ); -return -EINVAL ; - } - -if (!adw_info->watch_mode || !adw_info->watch_address) { -pr_err ("adw_info fields are not valid\n" ); -return -EINVAL ; - } - - status =kfd_gtt_sa_allocate (dbgdev->dev, ib_size, &mem_obj); - -if (status) { -pr_err ("Failed to allocate GART memory\n" ); -return status; - } -drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10- packet_buff_uint = mem_obj->cpu_ptr; - -memset (packet_buff_uint,0 , ib_size); - - packets_vec = (struct pm4__set_config_reg *) (packet_buff_uint); - - packets_vec[0 ].header.count =1 ; - packets_vec[0 ].header.opcode =IT_SET_CONFIG_REG ; - packets_vec[0 ].header.type =PM4_TYPE_3 ; - packets_vec[0].bitfields2.vmid_shift =
ADDRESS_WATCH_CNTL_OFFSET;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-7- packets_vec[0 ].bitfields2.insert_vmid =1 ; - packets_vec[1 ].ordinal1 = packets_vec[0 ].ordinal1; - packets_vec[1 ].bitfields2.insert_vmid =0 ; - packets_vec[2 ].ordinal1 = packets_vec[0 ].ordinal1; - packets_vec[2 ].bitfields2.insert_vmid =0 ; - packets_vec[3 ].ordinal1 = packets_vec[0 ].ordinal1; - packets_vec[3].bitfields2.vmid_shift =
ADDRESS_WATCH_CNTL_OFFSET;Quoted 34 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-33- packets_vec[3 ].bitfields2.insert_vmid =1 ; - -for (i =0 ; i < adw_info->num_watch_points; i++) { -dbgdev_address_watch_set_registers (adw_info, - &addrHi, - &addrLo, - &cntl, - i, - vmid); - -pr_debug ("\t\t%30s\n" ,"* * * * * * * * * * * * * * * * * *" ); -pr_debug ("\t\t%20s %08x\n" ,"register index :" , i); -pr_debug ("\t\t%20s %08x\n" ,"vmid is :" , vmid); -pr_debug ("\t\t%20s %p\n" ,"Add ptr is :" , - adw_info->watch_address); -pr_debug ("\t\t%20s %08llx\n" ,"Add is :" , - adw_info->watch_address[i]); -pr_debug ("\t\t%20s %08x\n" ,"Address Low is :" , - addrLo.bitfields.addr); -pr_debug ("\t\t%20s %08x\n" ,"Address high is :" , - addrHi.bitfields.addr); -pr_debug ("\t\t%20s %08x\n" ,"Control Mask is :" , - cntl.bitfields.mask); -pr_debug ("\t\t%20s %08x\n" ,"Control Mode is :" , - cntl.bitfields.mode); -pr_debug ("\t\t%20s %08x\n" ,"Control Vmid is :" , - cntl.bitfields.vmid); -pr_debug ("\t\t%20s %08x\n" ,"Control atc is :" , - cntl.bitfields.atc); -pr_debug ("\t\t%30s\n" ,"* * * * * * * * * * * * * * * * * *" ); - - aw_reg_add_dword = - dbgdev->dev->kfd2kgd-address_watch_get_offset(
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-6- dbgdev->dev->adev, - i, - ADDRESS_WATCH_REG_CNTL); - - packets_vec[0 ].bitfields2.reg_offset = - aw_reg_add_dword -
AMD_CONFIG_REG_BASE;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 12 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-5- - packets_vec[0 ].reg_data[0 ] = cntl.u32All; - - aw_reg_add_dword = - dbgdev->dev->kfd2kgd-address_watch_get_offset(
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-6- dbgdev->dev->adev, - i, - ADDRESS_WATCH_REG_ADDR_HI); - - packets_vec[1 ].bitfields2.reg_offset = - aw_reg_add_dword -
AMD_CONFIG_REG_BASE;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 11 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-4- packets_vec[1 ].reg_data[0 ] = addrHi.u32All; - - aw_reg_add_dword = - dbgdev->dev->kfd2kgd-address_watch_get_offset(
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-6- dbgdev->dev->adev, - i, - ADDRESS_WATCH_REG_ADDR_LO); - - packets_vec[2 ].bitfields2.reg_offset = - aw_reg_add_dword -
AMD_CONFIG_REG_BASE;Quoted 11 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10- packets_vec[2 ].reg_data[0 ] = addrLo.u32All; - -/* enable watch flag if address is not zero*/ -if (adw_info->watch_address[i] >0 ) - cntl.bitfields.valid =1 ; -else - cntl.bitfields.valid =0 ; - - aw_reg_add_dword = - dbgdev->dev->kfd2kgd-address_watch_get_offset(
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-6- dbgdev->dev->adev, - i, - ADDRESS_WATCH_REG_CNTL); - - packets_vec[3 ].bitfields2.reg_offset = - aw_reg_add_dword -
AMD_CONFIG_REG_BASE;Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-13- packets_vec[3 ].reg_data[0 ] = cntl.u32All; - - status =dbgdev_diq_submit_ib ( - dbgdev, - adw_info->process->pasid, - mem_obj->gpu_addr, - packet_buff_uint, - ib_size); - -if (status) { -pr_err ("Failed to submit IB to DIQ\n" ); -break ; - }drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10- } - -kfd_gtt_sa_free (dbgdev->dev, mem_obj); -return status; -} - -static int dbgdev_wave_control_set_registers ( -struct dbg_wave_control_info *wac_info, -union SQ_CMD_BITS *in_reg_sq_cmd, - union GRBM_GFX_INDEX_BITS
*in_reg_gfx_index)Quoted 86 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-86-{ -int status =0 ; -union SQ_CMD_BITS reg_sq_cmd; -union GRBM_GFX_INDEX_BITS reg_gfx_index; -struct HsaDbgWaveMsgAMDGen2 *pMsg; - - reg_sq_cmd.u32All =0 ; - reg_gfx_index.u32All =0 ; - pMsg = &wac_info->dbgWave_msg.DbgWaveMsg.WaveMsgInfoGen2; - -switch (wac_info->mode) { -/* Send command to single wave */ -case HSA_DBG_WAVEMODE_SINGLE : -/* -* Limit access to the process waves only, -* by setting vmid check -*/ - reg_sq_cmd.bits.check_vmid =1 ; - reg_sq_cmd.bits.simd_id = pMsg->ui32.SIMD; - reg_sq_cmd.bits.wave_id = pMsg->ui32.WaveId; - reg_sq_cmd.bits.mode =SQ_IND_CMD_MODE_SINGLE ; - - reg_gfx_index.bits.sh_index = pMsg->ui32.ShaderArray; - reg_gfx_index.bits.se_index = pMsg->ui32.ShaderEngine; - reg_gfx_index.bits.instance_index = pMsg->ui32.HSACU; - -break ; - -/* Send command to all waves with matching VMID */ -case HSA_DBG_WAVEMODE_BROADCAST_PROCESS : - - reg_gfx_index.bits.sh_broadcast_writes =1 ; - reg_gfx_index.bits.se_broadcast_writes =1 ; - reg_gfx_index.bits.instance_broadcast_writes =1 ; - - reg_sq_cmd.bits.mode =SQ_IND_CMD_MODE_BROADCAST ; - -break ; - -/* Send command to all CU waves with matching VMID */ -case HSA_DBG_WAVEMODE_BROADCAST_PROCESS_CU : - - reg_sq_cmd.bits.check_vmid =1 ; - reg_sq_cmd.bits.mode =SQ_IND_CMD_MODE_BROADCAST ; - - reg_gfx_index.bits.sh_index = pMsg->ui32.ShaderArray; - reg_gfx_index.bits.se_index = pMsg->ui32.ShaderEngine; - reg_gfx_index.bits.instance_index = pMsg->ui32.HSACU; - -break ; - -default : -return -EINVAL ; - } - -switch (wac_info->operand) { -case HSA_DBG_WAVEOP_HALT : - reg_sq_cmd.bits.cmd =SQ_IND_CMD_CMD_HALT ; -break ; - -case HSA_DBG_WAVEOP_RESUME : - reg_sq_cmd.bits.cmd =SQ_IND_CMD_CMD_RESUME ; -break ; - -case HSA_DBG_WAVEOP_KILL : - reg_sq_cmd.bits.cmd =SQ_IND_CMD_CMD_KILL ; -break ; - -case HSA_DBG_WAVEOP_DEBUG : - reg_sq_cmd.bits.cmd =SQ_IND_CMD_CMD_DEBUG ; -break ; - -case HSA_DBG_WAVEOP_TRAP : -if (wac_info->trapId <MAX_TRAPID ) { - reg_sq_cmd.bits.cmd =SQ_IND_CMD_CMD_TRAP ; - reg_sq_cmd.bits.trap_id = wac_info->trapId; - }else { - status = -EINVAL ; - } -break ; - -default : - status = -EINVAL ; -break ; - } -drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10-if (status ==0 ) { - *in_reg_sq_cmd = reg_sq_cmd; - *in_reg_gfx_index = reg_gfx_index; - } - -return status; -} - -static int dbgdev_wave_control_diq (struct kfd_dbgdev *dbgdev, - struct dbg_wave_control_info
*wac_info)Quoted 68 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-29-{ - -int status; -union SQ_CMD_BITS reg_sq_cmd; -union GRBM_GFX_INDEX_BITS reg_gfx_index; -struct kfd_mem_obj *mem_obj; -uint32_t *packet_buff_uint; -struct pm4__set_config_reg *packets_vec; -size_t ib_size =sizeof (struct pm4__set_config_reg ) *3 ; - - reg_sq_cmd.u32All =0 ; - - status =dbgdev_wave_control_set_registers (wac_info, ®_sq_cmd, - ®_gfx_index); -if (status) { -pr_err ("Failed to set wave control registers\n" ); -return status; - } - -/* we do not control the VMID in DIQ, so reset it to a known value */ - reg_sq_cmd.bits.vm_id =0 ; - -pr_debug ("\t\t %30s\n" ,"* * * * * * * * * * * * * * * * * *" ); - -pr_debug ("\t\t mode is: %u\n" , wac_info->mode); -pr_debug ("\t\t operand is: %u\n" , wac_info->operand); -pr_debug ("\t\t trap id is: %u\n" , wac_info->trapId); - pr_debug("\t\t msg value is: %u\n", - wac_info-dbgWave_msg.DbgWaveMsg.WaveMsgInfoGen2.Value);
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-38-pr_debug ("\t\t vmid is: N/A\n" ); - -pr_debug ("\t\t chk_vmid is : %u\n" , reg_sq_cmd.bitfields.check_vmid); -pr_debug ("\t\t command is : %u\n" , reg_sq_cmd.bitfields.cmd); -pr_debug ("\t\t queue id is : %u\n" , reg_sq_cmd.bitfields.queue_id); -pr_debug ("\t\t simd id is : %u\n" , reg_sq_cmd.bitfields.simd_id); -pr_debug ("\t\t mode is : %u\n" , reg_sq_cmd.bitfields.mode); -pr_debug ("\t\t vm_id is : %u\n" , reg_sq_cmd.bitfields.vm_id); -pr_debug ("\t\t wave_id is : %u\n" , reg_sq_cmd.bitfields.wave_id); - -pr_debug ("\t\t ibw is : %u\n" , - reg_gfx_index.bitfields.instance_broadcast_writes); -pr_debug ("\t\t ii is : %u\n" , - reg_gfx_index.bitfields.instance_index); -pr_debug ("\t\t sebw is : %u\n" , - reg_gfx_index.bitfields.se_broadcast_writes); -pr_debug ("\t\t se_ind is : %u\n" , reg_gfx_index.bitfields.se_index); -pr_debug ("\t\t sh_ind is : %u\n" , reg_gfx_index.bitfields.sh_index); -pr_debug ("\t\t sbw is : %u\n" , - reg_gfx_index.bitfields.sh_broadcast_writes); - -pr_debug ("\t\t %30s\n" ,"* * * * * * * * * * * * * * * * * *" ); - - status =kfd_gtt_sa_allocate (dbgdev->dev, ib_size, &mem_obj); - -if (status !=0 ) { -pr_err ("Failed to allocate GART memory\n" ); -return status; - } - - packet_buff_uint = mem_obj->cpu_ptr; - -memset (packet_buff_uint,0 , ib_size); - - packets_vec = (struct pm4__set_config_reg *) packet_buff_uint; - packets_vec[0 ].header.count =1 ; - packets_vec[0 ].header.opcode =IT_SET_UCONFIG_REG ; - packets_vec[0 ].header.type =PM4_TYPE_3 ;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10- packets_vec[0 ].bitfields2.reg_offset = -GRBM_GFX_INDEX /4 -USERCONFIG_REG_BASE ; - - packets_vec[0 ].bitfields2.insert_vmid =0 ; - packets_vec[0 ].reg_data[0 ] = reg_gfx_index.u32All; - - packets_vec[1 ].header.count =1 ; - packets_vec[1 ].header.opcode =IT_SET_CONFIG_REG ; - packets_vec[1 ].header.type =PM4_TYPE_3 ; - packets_vec[1].bitfields2.reg_offset = SQ_CMD / 4 -
AMD_CONFIG_REG_BASE;Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-6- - packets_vec[1 ].bitfields2.vmid_shift =SQ_CMD_VMID_OFFSET ; - packets_vec[1 ].bitfields2.insert_vmid =1 ; - packets_vec[1 ].reg_data[0 ] = reg_sq_cmd.u32All; - -/* Restore the GRBM_GFX_INDEX register */ drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10- - reg_gfx_index.u32All =0 ; - reg_gfx_index.bits.sh_broadcast_writes =1 ; - reg_gfx_index.bits.instance_broadcast_writes =1 ; - reg_gfx_index.bits.se_broadcast_writes =1 ; - - - packets_vec[2 ].ordinal1 = packets_vec[0 ].ordinal1; - packets_vec[2 ].bitfields2.reg_offset = - GRBM_GFX_INDEX / 4 -
USERCONFIG_REG_BASE;Quoted 11 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-11- - packets_vec[2 ].bitfields2.insert_vmid =0 ; - packets_vec[2 ].reg_data[0 ] = reg_gfx_index.u32All; - - status =dbgdev_diq_submit_ib ( - dbgdev, - wac_info->process->pasid, - mem_obj->gpu_addr, - packet_buff_uint, - ib_size); -drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10-if (status) -pr_err ("Failed to submit IB to DIQ\n" ); - -kfd_gtt_sa_free (dbgdev->dev, mem_obj); - -return status; -} - -static int dbgdev_wave_control_nodiq (struct kfd_dbgdev *dbgdev, - struct dbg_wave_control_info
*wac_info)Quoted 59 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-33-{ -int status; -union SQ_CMD_BITS reg_sq_cmd; -union GRBM_GFX_INDEX_BITS reg_gfx_index; -struct kfd_process_device *pdd; - - reg_sq_cmd.u32All =0 ; - -/* taking the VMID for that process on the safe way using PDD */ - pdd =kfd_get_process_device_data (dbgdev->dev, wac_info->process); - -if (!pdd) { -pr_err ("Failed to get pdd for wave control no DIQ\n" ); -return -EFAULT ; - } - status =dbgdev_wave_control_set_registers (wac_info, ®_sq_cmd, - ®_gfx_index); -if (status) { -pr_err ("Failed to set wave control registers\n" ); -return status; - } - -/* for non DIQ we need to patch the VMID: */ - - reg_sq_cmd.bits.vm_id = pdd->qpd.vmid; - -pr_debug ("\t\t %30s\n" ,"* * * * * * * * * * * * * * * * * *" ); - -pr_debug ("\t\t mode is: %u\n" , wac_info->mode); -pr_debug ("\t\t operand is: %u\n" , wac_info->operand); -pr_debug ("\t\t trap id is: %u\n" , wac_info->trapId); - pr_debug("\t\t msg value is: %u\n", - wac_info-dbgWave_msg.DbgWaveMsg.WaveMsgInfoGen2.Value);
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-24-pr_debug ("\t\t vmid is: %u\n" , pdd->qpd.vmid); - -pr_debug ("\t\t chk_vmid is : %u\n" , reg_sq_cmd.bitfields.check_vmid); -pr_debug ("\t\t command is : %u\n" , reg_sq_cmd.bitfields.cmd); -pr_debug ("\t\t queue id is : %u\n" , reg_sq_cmd.bitfields.queue_id); -pr_debug ("\t\t simd id is : %u\n" , reg_sq_cmd.bitfields.simd_id); -pr_debug ("\t\t mode is : %u\n" , reg_sq_cmd.bitfields.mode); -pr_debug ("\t\t vm_id is : %u\n" , reg_sq_cmd.bitfields.vm_id); -pr_debug ("\t\t wave_id is : %u\n" , reg_sq_cmd.bitfields.wave_id); - -pr_debug ("\t\t ibw is : %u\n" , - reg_gfx_index.bitfields.instance_broadcast_writes); -pr_debug ("\t\t ii is : %u\n" , - reg_gfx_index.bitfields.instance_index); -pr_debug ("\t\t sebw is : %u\n" , - reg_gfx_index.bitfields.se_broadcast_writes); -pr_debug ("\t\t se_ind is : %u\n" , reg_gfx_index.bitfields.se_index); -pr_debug ("\t\t sh_ind is : %u\n" , reg_gfx_index.bitfields.sh_index); -pr_debug ("\t\t sbw is : %u\n" , - reg_gfx_index.bitfields.sh_broadcast_writes); - -pr_debug ("\t\t %30s\n" ,"* * * * * * * * * * * * * * * * * *" ); - - return dbgdev->dev->kfd2kgd->wave_control_execute(dbgdev->dev-adev,
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-5- reg_gfx_index.u32All, - reg_sq_cmd.u32All); -} - -int dbgdev_wave_reset_wavefronts(struct kfd_dev *dev, struct kfd_process*p)
Quoted 20 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-20-{ -int status =0 ; -unsigned int vmid; -uint16_t queried_pasid; -union SQ_CMD_BITS reg_sq_cmd; -union GRBM_GFX_INDEX_BITS reg_gfx_index; -struct kfd_process_device *pdd; -struct dbg_wave_control_info wac_info; -int first_vmid_to_scan = dev->vm_info.first_vmid_kfd; -int last_vmid_to_scan = dev->vm_info.last_vmid_kfd; - - reg_sq_cmd.u32All =0 ; - status =0 ; - - wac_info.mode =HSA_DBG_WAVEMODE_BROADCAST_PROCESS ; - wac_info.operand =HSA_DBG_WAVEOP_KILL ; - -pr_debug ("Killing all process wavefronts\n" ); - -/* Scan all registers in the range ATC_VMID8_PASID_MAPPING .. drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10-* ATC_VMID15_PASID_MAPPING -* to check which VMID the current process is mapped to. -*/ - -for (vmid = first_vmid_to_scan; vmid <= last_vmid_to_scan; vmid++) { - status = dev->kfd2kgd->get_atc_vmid_pasid_mapping_info - (dev->adev, vmid, &queried_pasid); - -if (status && queried_pasid == p->pasid) { - pr_debug("Killing wave fronts of vmid %d and pasid0x%x\n",
Quoted 33 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-33- vmid, p->pasid); -break ; - } - } - -if (vmid > last_vmid_to_scan) { -pr_err ("Didn't find vmid for pasid 0x%x\n" , p->pasid); -return -EFAULT ; - } - -/* taking the VMID for that process on the safe way using PDD */ - pdd =kfd_get_process_device_data (dev, p); -if (!pdd) -return -EFAULT ; - - status =dbgdev_wave_control_set_registers (&wac_info, ®_sq_cmd, - ®_gfx_index); -if (status !=0 ) -return -EINVAL ; - -/* for non DIQ we need to patch the VMID: */ - reg_sq_cmd.bits.vm_id = vmid; - - dev->kfd2kgd->wave_control_execute (dev->adev, - reg_gfx_index.u32All, - reg_sq_cmd.u32All); - -return 0 ; -} - -void kfd_dbgdev_init (struct kfd_dbgdev *pdbgdev,struct kfd_dev *pdev, -enum DBGDEV_TYPE type) -{drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-10- pdbgdev->dev = pdev; - pdbgdev->kq =NULL ; - pdbgdev->type = type; - pdbgdev->pqm =NULL ; - -switch (type) { -case DBGDEV_TYPE_NODIQ : - pdbgdev->dbgdev_register = dbgdev_register_nodiq; - pdbgdev->dbgdev_unregister = dbgdev_unregister_nodiq; - pdbgdev->dbgdev_wave_control =
dbgdev_wave_control_nodiq;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-1- pdbgdev->dbgdev_address_watch =
dbgdev_address_watch_nodiq;drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-7-break ; -case DBGDEV_TYPE_DIQ : -default : - pdbgdev->dbgdev_register = dbgdev_register_diq; - pdbgdev->dbgdev_unregister = dbgdev_unregister_diq; - pdbgdev->dbgdev_wave_control = dbgdev_wave_control_diq; - pdbgdev->dbgdev_address_watch =
dbgdev_address_watch_diq;Review
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c deleted +0
-4-break ; - } - -}(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.hQuoted 9 lines
deleted file mode 100644
index 0619c777b47e..000000000000drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-4@@ -1,230 +0,0 @@ -/* -* Copyright 2014 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h line 14
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-10-* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h line 15
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-1-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h line 16
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-1-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h line 17
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-1-* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h line 18
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-1-* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h line 19
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-1-* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
Quoted 17 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-17-* OTHER DEALINGS IN THE SOFTWARE. -*/ - -#ifndef KFD_DBGDEV_H_ -#define KFD_DBGDEV_H_ - -enum { -SQ_CMD_VMID_OFFSET =28 , -ADDRESS_WATCH_CNTL_OFFSET =24 -}; - -enum { -PRIV_QUEUE_SYNC_TIME_MS =200 -}; - -/* CONTEXT reg space definition */ -enum {drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-10- CONTEXT_REG_BASE = 0xA000, - CONTEXT_REG_END = 0xA400, -CONTEXT_REG_SIZE =CONTEXT_REG_END -CONTEXT_REG_BASE -}; - -/* USER CONFIG reg space definition */ -enum { -USERCONFIG_REG_BASE =0xC000 , -USERCONFIG_REG_END =0x10000 , - USERCONFIG_REG_SIZE = USERCONFIG_REG_END -
USERCONFIG_REG_BASEdrivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-7-}; - -/* CONFIG reg space definition */ -enum { -AMD_CONFIG_REG_BASE =0x2000 ,/* in dwords */ -AMD_CONFIG_REG_END =0x2B00 , - AMD_CONFIG_REG_SIZE = AMD_CONFIG_REG_END -
AMD_CONFIG_REG_BASEReview
Quoted 178 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.h deleted +0
-177-}; - -/* SH reg space definition */ -enum { -SH_REG_BASE =0x2C00 , -SH_REG_END =0x3000 , -SH_REG_SIZE =SH_REG_END -SH_REG_BASE -}; - -/* SQ_CMD definitions */ -#define SQ_CMD 0x8DEC - -enum SQ_IND_CMD_CMD { -SQ_IND_CMD_CMD_NULL =0x00000000 , -SQ_IND_CMD_CMD_HALT =0x00000001 , -SQ_IND_CMD_CMD_RESUME =0x00000002 , -SQ_IND_CMD_CMD_KILL =0x00000003 , -SQ_IND_CMD_CMD_DEBUG =0x00000004 , -SQ_IND_CMD_CMD_TRAP =0x00000005 , -}; - -enum SQ_IND_CMD_MODE { -SQ_IND_CMD_MODE_SINGLE =0x00000000 , -SQ_IND_CMD_MODE_BROADCAST =0x00000001 , -SQ_IND_CMD_MODE_BROADCAST_QUEUE =0x00000002 , -SQ_IND_CMD_MODE_BROADCAST_PIPE =0x00000003 , -SQ_IND_CMD_MODE_BROADCAST_ME =0x00000004 , -}; - -union SQ_IND_INDEX_BITS { -struct { -uint32_t wave_id:4 ; -uint32_t simd_id:2 ; -uint32_t thread_id:6 ; - uint32_t:1; -uint32_t force_read:1 ; -uint32_t read_timeout:1 ; -uint32_t unindexed:1 ; -uint32_t index:16 ; - - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -union SQ_IND_CMD_BITS { -struct { -uint32_t data:32 ; - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -union SQ_CMD_BITS { -struct { -uint32_t cmd:3 ; - uint32_t:1; -uint32_t mode:3 ; -uint32_t check_vmid:1 ; -uint32_t trap_id:3 ; - uint32_t:5; -uint32_t wave_id:4 ; -uint32_t simd_id:2 ; - uint32_t:2; -uint32_t queue_id:3 ; - uint32_t:1; -uint32_t vm_id:4 ; - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -union SQ_IND_DATA_BITS { -struct { -uint32_t data:32 ; - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -union GRBM_GFX_INDEX_BITS { -struct { -uint32_t instance_index:8 ; -uint32_t sh_index:8 ; -uint32_t se_index:8 ; - uint32_t:5; -uint32_t sh_broadcast_writes:1 ; -uint32_t instance_broadcast_writes:1 ; -uint32_t se_broadcast_writes:1 ; - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -union TCP_WATCH_ADDR_H_BITS { -struct { -uint32_t addr:16 ; - uint32_t:16; - - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -union TCP_WATCH_ADDR_L_BITS { -struct { - uint32_t:6; -uint32_t addr:26 ; - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -enum { -QUEUESTATE__INVALID =0 ,/* so by default we'll get invalid state */ -QUEUESTATE__ACTIVE_COMPLETION_PENDING , -QUEUESTATE__ACTIVE -}; - -union ULARGE_INTEGER { -struct { -uint32_t low_part; -uint32_t high_part; - } u; -unsigned long long quad_part; -}; - - -#define KFD_CIK_VMID_START_OFFSET (8) -#define KFD_CIK_VMID_END_OFFSET (KFD_CIK_VMID_START_OFFSET + (8)) - - -void kfd_dbgdev_init (struct kfd_dbgdev *pdbgdev,struct kfd_dev *pdev, -enum DBGDEV_TYPE type); - -union TCP_WATCH_CNTL_BITS { -struct { -uint32_t mask:24 ; -uint32_t vmid:4 ; -uint32_t atc:1 ; -uint32_t mode:2 ; -uint32_t valid:1 ; - } bitfields, bits; -uint32_t u32All; -signed int i32All; -float f32All; -}; - -enum { -ADDRESS_WATCH_REG_CNTL_ATC_BIT =0x10000000UL , -ADDRESS_WATCH_REG_CNTL_DEFAULT_MASK =0x00FFFFFF , -ADDRESS_WATCH_REG_ADDLOW_MASK_EXTENSION =0x03000000 , -/* extend the mask to 26 bits in order to match the low address field */ -ADDRESS_WATCH_REG_ADDLOW_SHIFT =6 , -ADDRESS_WATCH_REG_ADDHIGH_MASK =0xFFFF -}; - -enum { -MAX_TRAPID =8 ,/* 3 bits in the bitfield. */ -MAX_WATCH_ADDRESSES =4 -}; - -enum { -ADDRESS_WATCH_REG_ADDR_HI =0 , -ADDRESS_WATCH_REG_ADDR_LO , -ADDRESS_WATCH_REG_CNTL , -ADDRESS_WATCH_REG_MAX -}; - -#endif /* KFD_DBGDEV_H_ */ (quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.cQuoted 9 lines
deleted file mode 100644
index 9bfa50633654..000000000000drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-4@@ -1,158 +0,0 @@ -/* -* Copyright 2014 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c line 14
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-10-* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c line 15
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-1-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c line 16
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-1-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c line 17
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-1-* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c line 18
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-1-* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c line 19
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-1-* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
Quoted 91 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-91-* OTHER DEALINGS IN THE SOFTWARE. -* -*/ -#include <linux/types.h> -#include <linux/kernel.h> -#include <linux/log2.h> -#include <linux/sched.h> -#include <linux/slab.h> -#include <linux/device.h> - -#include "kfd_priv.h" -#include "cik_regs.h" -#include "kfd_pm4_headers.h" -#include "kfd_pm4_headers_diq.h" -#include "kfd_dbgmgr.h" -#include "kfd_dbgdev.h" -#include "kfd_device_queue_manager.h" - -static DEFINE_MUTEX (kfd_dbgmgr_mutex); - -struct mutex *kfd_get_dbgmgr_mutex (void ) -{ -return &kfd_dbgmgr_mutex; -} - - -static void kfd_dbgmgr_uninitialize (struct kfd_dbgmgr *pmgr) -{ -kfree (pmgr->dbgdev); - - pmgr->dbgdev =NULL ; - pmgr->pasid =0 ; - pmgr->dev =NULL ; -} - -void kfd_dbgmgr_destroy (struct kfd_dbgmgr *pmgr) -{ -if (pmgr) { -kfd_dbgmgr_uninitialize (pmgr); -kfree (pmgr); - } -} - -bool kfd_dbgmgr_create (struct kfd_dbgmgr **ppmgr,struct kfd_dev *pdev) -{ -enum DBGDEV_TYPE type =DBGDEV_TYPE_DIQ ; -struct kfd_dbgmgr *new_buff; - -if (WARN_ON (!pdev->init_complete)) -return false; - - new_buff =kfd_alloc_struct (new_buff); -if (!new_buff) { -pr_err ("Failed to allocate dbgmgr instance\n" ); -return false; - } - - new_buff->pasid =0 ; - new_buff->dev = pdev; - new_buff->dbgdev =kfd_alloc_struct (new_buff->dbgdev); -if (!new_buff->dbgdev) { -pr_err ("Failed to allocate dbgdev instance\n" ); -kfree (new_buff); -return false; - } - -/* get actual type of DBGDevice cpsch or not */ -if (pdev->dqm->sched_policy ==KFD_SCHED_POLICY_NO_HWS ) - type =DBGDEV_TYPE_NODIQ ; - -kfd_dbgdev_init (new_buff->dbgdev, pdev, type); - *ppmgr = new_buff; - -return true; -} - -long kfd_dbgmgr_register (struct kfd_dbgmgr *pmgr,struct kfd_process *p) -{ -if (pmgr->pasid !=0 ) { -pr_debug ("H/W debugger is already active using pasid 0x%x\n" , - pmgr->pasid); -return -EBUSY ; - } - -/* remember pasid */ - pmgr->pasid = p->pasid; - -/* provide the pqm for diq generation */ - pmgr->dbgdev->pqm = &p->pqm; - -/* activate the actual registering */ drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-10- pmgr->dbgdev->dbgdev_register (pmgr->dbgdev); - -return 0 ; -} - -long kfd_dbgmgr_unregister (struct kfd_dbgmgr *pmgr,struct kfd_process *p) -{ -/* Is the requests coming from the already registered process? */ -if (pmgr->pasid != p->pasid) { - pr_debug("H/W debugger is not registered by calling pasid0x%x\n",
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-7- p->pasid); -return -EINVAL ; - } - - pmgr->dbgdev->dbgdev_unregister (pmgr->dbgdev); - - pmgr->pasid =0 ;drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-10- -return 0 ; -} - -long kfd_dbgmgr_wave_control (struct kfd_dbgmgr *pmgr, -struct dbg_wave_control_info *wac_info) -{ -/* Is the requests coming from the already registered process? */ -if (pmgr->pasid != wac_info->process->pasid) { - pr_debug("H/W debugger support was not registered forrequester pasid 0x%x\n",
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-5- wac_info->process->pasid); -return -EINVAL ; - } - - return (long) pmgr->dbgdev->dbgdev_wave_control(pmgr->dbgdev,
wac_info);drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-8-} - -long kfd_dbgmgr_address_watch (struct kfd_dbgmgr *pmgr, -struct dbg_address_watch_info *adw_info) -{ -/* Is the requests coming from the already registered process? */ -if (pmgr->pasid != adw_info->process->pasid) { - pr_debug("H/W debugger support was not registered forrequester pasid 0x%x\n",
Review
Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.c deleted +0
-8- adw_info->process->pasid); -return -EINVAL ; - } - -return (long ) pmgr->dbgdev->dbgdev_address_watch (pmgr->dbgdev, - adw_info); -} -(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.hQuoted 9 lines
deleted file mode 100644
index f9c6df1fdc5c..000000000000drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-4@@ -1,293 +0,0 @@ -/* -* Copyright 2014 Advanced Micro Devices, Inc. -* -* Permission is hereby granted, free of charge, to any person obtaining a drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h line 14
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-10-* copy of this software and associated documentation files (the "Software"), -* to deal in the Software without restriction, including without limitation -* the rights to use, copy, modify, merge, publish, distribute, sublicense, -* and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h line 15
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-1-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h line 16
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-1-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h line 17
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-1-* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h line 18
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-1-* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h line 19
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-1-* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-7-* OTHER DEALINGS IN THE SOFTWARE. -* -*/ - -#ifndef KFD_DBGMGR_H_ -#define KFD_DBGMGR_H_ -drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-10-#include "kfd_priv.h" - -/* must align with hsakmttypes definition */ -#pragma pack(push, 4) - -enum HSA_DBG_WAVEOP { -HSA_DBG_WAVEOP_HALT =1 ,/* Halts a wavefront */ -HSA_DBG_WAVEOP_RESUME =2 ,/* Resumes a wavefront */ -HSA_DBG_WAVEOP_KILL =3 ,/* Kills a wavefront */ -HSA_DBG_WAVEOP_DEBUG =4 ,/* Causes wavefront to enter dbg mode */
Quoted 22 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-22-HSA_DBG_WAVEOP_TRAP =5 ,/* Causes wavefront to take a trap */ -HSA_DBG_NUM_WAVEOP =5 , -HSA_DBG_MAX_WAVEOP =0xFFFFFFFF -}; - -enum HSA_DBG_WAVEMODE { -/* send command to a single wave */ -HSA_DBG_WAVEMODE_SINGLE =0 , -/* -* Broadcast to all wavefronts of all processes is not -* supported for HSA user mode -*/ - -/* send to waves within current process */ -HSA_DBG_WAVEMODE_BROADCAST_PROCESS =2 , -/* send to waves within current process on CU */ -HSA_DBG_WAVEMODE_BROADCAST_PROCESS_CU =3 , -HSA_DBG_NUM_WAVEMODE =3 , -HSA_DBG_MAX_WAVEMODE =0xFFFFFFFF -}; - -enum HSA_DBG_WAVEMSG_TYPE {drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-10-HSA_DBG_WAVEMSG_AUTO =0 , -HSA_DBG_WAVEMSG_USER =1 , -HSA_DBG_WAVEMSG_ERROR =2 , -HSA_DBG_NUM_WAVEMSG , -HSA_DBG_MAX_WAVEMSG =0xFFFFFFFF -}; - -enum HSA_DBG_WATCH_MODE { -HSA_DBG_WATCH_READ =0 ,/* Read operations only */ -HSA_DBG_WATCH_NONREAD =1 ,/* Write or Atomic operations only */
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h line 70
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-2-HSA_DBG_WATCH_ATOMIC =2 ,/* Atomic Operations only */ - HSA_DBG_WATCH_ALL = 3, /* Read, Write or Atomicoperations */
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-7-HSA_DBG_WATCH_NUM , -HSA_DBG_WATCH_SIZE =0xFFFFFFFF -}; - -/* This structure is hardware specific and may change in the future */ -struct HsaDbgWaveMsgAMDGen2 { - union {drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-10-struct ui32 { -uint32_t UserData:8 ;/* user data */ -uint32_t ShaderArray:1 ;/* Shader array */ -uint32_t Priv:1 ;/* Privileged */ -uint32_t Reserved0:4 ;/* Reserved, should be 0 */ -uint32_t WaveId:4 ;/* wave id */ -uint32_t SIMD:2 ;/* SIMD id */ -uint32_t HSACU:4 ;/* Compute unit */ -uint32_t ShaderEngine:2 ;/* Shader engine */ -uint32_t MessageType:2 ;/* see
HSA_DBG_WAVEMSG_TYPE*/Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-4- uint32_t Reserved1:4; /* Reserved, should be 0 */ - } ui32; -uint32_t Value; - };drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-10-uint32_t Reserved2; -}; - -union HsaDbgWaveMessageAMD { -struct HsaDbgWaveMsgAMDGen2 WaveMsgInfoGen2; -/* for future HsaDbgWaveMsgAMDGen3; */ -}; - -struct HsaDbgWaveMessage { -void *MemoryVA;/* ptr to associated host-accessible data */
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-9-union HsaDbgWaveMessageAMD DbgWaveMsg; -}; - -/* -* TODO: This definitions to be MOVED to kfd_event, once it is implemented. -* -* HSA sync primitive, Event and HW Exception notification API definitions. -* The API functions allow the runtime to define a so-called sync-primitive, -* a SW object combining a user-mode provided "syncvar" and a scheduler event
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-3-* that can be signaled through a defined GPU interrupt. A syncvar is -* a process virtual memory location of a certain size that can be accessed -* by CPU and GPU shader code within the process to set and query the content
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-3-* within that memory. The definition of the content is determined by the HSA -* runtime and potentially GPU shader code interfacing with the HSA runtime. -* The syncvar values may be commonly written through an PM4
WRITE_DATApacketdrivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-3-* in the user mode instruction stream. The OS scheduler event is typically -* associated and signaled by an interrupt issued by the GPU, but other HSA -* system interrupt conditions from other HW (e.g. IOMMUv2) may be surfaced
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-7-* by the KFD by this mechanism, too. -*/ - -/* these are the new definitions for events */ -enum HSA_EVENTTYPE { -HSA_EVENTTYPE_SIGNAL =0 ,/* user-mode generated GPU signal */ -HSA_EVENTTYPE_NODECHANGE =1 ,/* HSA node change (attach/detach) */
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h line 127
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-1- HSA_EVENTTYPE_DEVICESTATECHANGE = 2, /* HSA device statechange
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-3-* (start/stop) -*/ - HSA_EVENTTYPE_HW_EXCEPTION = 3, /* GPU shader exception event*/
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h line 131
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-1- HSA_EVENTTYPE_SYSTEM_EVENT = 4, /* GPU SYSCALL withparameter info */
Quoted 41 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-41-HSA_EVENTTYPE_DEBUG_EVENT =5 ,/* GPU signal for debugging */ -HSA_EVENTTYPE_PROFILE_EVENT =6 ,/* GPU signal for profiling */ -HSA_EVENTTYPE_QUEUE_EVENT =7 ,/* GPU signal queue idle state -* (EOP pm4) -*/ -/* ... */ -HSA_EVENTTYPE_MAXID , - HSA_EVENTTYPE_TYPE_SIZE = 0xFFFFFFFF -}; - -/* Sub-definitions for various event types: Syncvar */ -struct HsaSyncVar { -union SyncVar { -void *UserData;/* pointer to user mode data */ -uint64_t UserDataPtrValue;/* 64bit compatibility of value */ - } SyncVar; -uint64_t SyncVarSize; -}; - -/* Sub-definitions for various event types: NodeChange */ - -enum HSA_EVENTTYPE_NODECHANGE_FLAGS { -HSA_EVENTTYPE_NODECHANGE_ADD =0 , -HSA_EVENTTYPE_NODECHANGE_REMOVE =1 , -HSA_EVENTTYPE_NODECHANGE_SIZE =0xFFFFFFFF -}; - -struct HsaNodeChange { -/* HSA node added/removed on the platform */ -enum HSA_EVENTTYPE_NODECHANGE_FLAGS Flags; -}; - -/* Sub-definitions for various event types: DeviceStateChange */ -enum HSA_EVENTTYPE_DEVICESTATECHANGE_FLAGS { -/* device started (and available) */ -HSA_EVENTTYPE_DEVICESTATUSCHANGE_START =0 , -/* device stopped (i.e. unavailable) */ -HSA_EVENTTYPE_DEVICESTATUSCHANGE_STOP =1 , -HSA_EVENTTYPE_DEVICESTATUSCHANGE_SIZE =0xFFFFFFFF -}; -drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-10-enum HSA_DEVICE { -HSA_DEVICE_CPU =0 , -HSA_DEVICE_GPU =1 , -MAX_HSA_DEVICE =2 -}; - -struct HsaDeviceStateChange { -uint32_t NodeId;/* F-NUMA node that contains the device */ -enum HSA_DEVICE Device;/* device type: GPU or CPU */ -enum HSA_EVENTTYPE_DEVICESTATECHANGE_FLAGS Flags;/* event flags */
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-5-}; - -struct HsaEventData { - enum HSA_EVENTTYPE EventType; /* event type */ - union EventData {drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-10-/* -* return data associated with HSA_EVENTTYPE_SIGNAL -* and other events -*/ -struct HsaSyncVar SyncVar; - -/* data associated with HSA_EVENTTYPE_NODE_CHANGE */ -struct HsaNodeChange NodeChangeState; - -/* data associated with
HSA_EVENTTYPE_DEVICE_STATE_CHANGE*/Quoted 81 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-81-struct HsaDeviceStateChange DeviceState; - } EventData; - -/* the following data entries are internal to the KFD & thunk itself */ - -/* internal thunk store for Event data (OsEventHandle) */ -uint64_t HWData1; -/* internal thunk store for Event data (HWAddress) */ -uint64_t HWData2; -/* internal thunk store for Event data (HWData) */ -uint32_t HWData3; -}; - -struct HsaEventDescriptor { -/* event type to allocate */ -enum HSA_EVENTTYPE EventType; -/* H-NUMA node containing GPU device that is event source */ -uint32_t NodeId; -/* pointer to user mode syncvar data, syncvar->UserDataPtrValue -* may be NULL -*/ -struct HsaSyncVar SyncVar; -}; - -struct HsaEvent { -uint32_t EventId; -struct HsaEventData EventData; -}; - -#pragma pack(pop) - -enum DBGDEV_TYPE { -DBGDEV_TYPE_ILLEGAL =0 , -DBGDEV_TYPE_NODIQ =1 , -DBGDEV_TYPE_DIQ =2 , -DBGDEV_TYPE_TEST =3 -}; - -struct dbg_address_watch_info { -struct kfd_process *process; -enum HSA_DBG_WATCH_MODE *watch_mode; -uint64_t *watch_address; -uint64_t *watch_mask; -struct HsaEvent *watch_event; -uint32_t num_watch_points; -}; - -struct dbg_wave_control_info { -struct kfd_process *process; -uint32_t trapId; -enum HSA_DBG_WAVEOP operand; -enum HSA_DBG_WAVEMODE mode; -struct HsaDbgWaveMessage dbgWave_msg; -}; - -struct kfd_dbgdev { - -/* The device that owns this data. */ -struct kfd_dev *dev; - -/* kernel queue for DIQ */ -struct kernel_queue *kq; - -/* a pointer to the pqm of the calling process */ -struct process_queue_manager *pqm; - -/* type of debug device ( DIQ, non DIQ, etc. ) */ -enum DBGDEV_TYPE type; - -/* virtualized function pointers to device dbg */ -int (*dbgdev_register)(struct kfd_dbgdev *dbgdev); -int (*dbgdev_unregister)(struct kfd_dbgdev *dbgdev); -int (*dbgdev_address_watch)(struct kfd_dbgdev *dbgdev, -struct dbg_address_watch_info *adw_info); -int (*dbgdev_wave_control)(struct kfd_dbgdev *dbgdev, -struct dbg_wave_control_info *wac_info); - -}; - -struct kfd_dbgmgr { -u32 pasid;drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-10-struct kfd_dev *dev; -struct kfd_dbgdev *dbgdev; -}; - -/* prototypes for debug manager functions */ -struct mutex *kfd_get_dbgmgr_mutex (void ); -void kfd_dbgmgr_destroy (struct kfd_dbgmgr *pmgr); -bool kfd_dbgmgr_create (struct kfd_dbgmgr **ppmgr,struct kfd_dev *pdev); -long kfd_dbgmgr_register (struct kfd_dbgmgr *pmgr,struct kfd_process *p); -long kfd_dbgmgr_unregister(struct kfd_dbgmgr *pmgr, struct kfd_process*p);
Review
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_dbgmgr.h deleted +0
-5-long kfd_dbgmgr_wave_control (struct kfd_dbgmgr *pmgr, -struct dbg_wave_control_info *wac_info); -long kfd_dbgmgr_address_watch (struct kfd_dbgmgr *pmgr, -struct dbg_address_watch_info *adw_info); -#endif /* KFD_DBGMGR_H_ */ (quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_device.cReview
Quoted 13 lines
index
5a47f437b455..dbb877fba724100644drivers/gpu/drm/amd/amdkfd/kfd_device.c +0
-2@@ -575,8 +575,6 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,if (kfd_resume (kfd)) goto kfd_resume_error; - kfd->dbgmgr =NULL ; -if (kfd_topology_add_device (kfd)) {dev_err (kfd_device,"Error adding device to topology\n" ); goto kfd_topology_add_device_error;(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.cdrivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static inline void deallocate_hqd(struct
Quoted 4 lines
index
63b3c7af681b..f5d82f257dbb100644drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0@@ -480,6 +480,65 @@ static inline void deallocate_hqd(struct
device_queue_manager*dqm,drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static inline void deallocate_hqd(struct device_queue_manager *dqm,
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +4
-0dqm->allocated_queues[q->pipe] |= (1 << q->queue); } +#define SQ_IND_CMD_CMD_KILL 0x00000003 +#define SQ_IND_CMD_MODE_BROADCAST 0x00000001 + +static int dbgdev_wave_reset_wavefronts(struct kfd_dev *dev, struct
kfd_process*p)Quoted 16 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +16
-0+{ +int status =0 ; +unsigned int vmid; +uint16_t queried_pasid; +union SQ_CMD_BITS reg_sq_cmd; +union GRBM_GFX_INDEX_BITS reg_gfx_index; +struct kfd_process_device *pdd; +int first_vmid_to_scan = dev->vm_info.first_vmid_kfd; +int last_vmid_to_scan = dev->vm_info.last_vmid_kfd; + + reg_sq_cmd.u32All =0 ; + reg_gfx_index.u32All =0 ; + +pr_debug ("Killing all process wavefronts\n" ); + +/* Scan all registers in the range ATC_VMID8_PASID_MAPPING .. drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static inline void deallocate_hqd(struct device_queue_manager *dqm,
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +10
-0+* ATC_VMID15_PASID_MAPPING +* to check which VMID the current process is mapped to. +*/ + +for (vmid = first_vmid_to_scan; vmid <= last_vmid_to_scan; vmid++) { + status = dev->kfd2kgd->get_atc_vmid_pasid_mapping_info + (dev->adev, vmid, &queried_pasid); + +if (status && queried_pasid == p->pasid) { + pr_debug("Killing wave fronts of vmid %d and pasid0x%x\n",
Quoted 20 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +20
-0+ vmid, p->pasid); +break ; + } + } + +if (vmid > last_vmid_to_scan) { +pr_err ("Didn't find vmid for pasid 0x%x\n" , p->pasid); +return -EFAULT ; + } + +/* taking the VMID for that process on the safe way using PDD */ + pdd =kfd_get_process_device_data (dev, p); +if (!pdd) +return -EFAULT ; + + reg_gfx_index.bits.sh_broadcast_writes =1 ; + reg_gfx_index.bits.se_broadcast_writes =1 ; + reg_gfx_index.bits.instance_broadcast_writes =1 ; + reg_sq_cmd.bits.mode =SQ_IND_CMD_MODE_BROADCAST ; + reg_sq_cmd.bits.cmd =SQ_IND_CMD_CMD_KILL ;drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static inline void deallocate_hqd(struct device_queue_manager *dqm,
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +9
-0+ reg_sq_cmd.bits.vm_id = vmid; + + dev->kfd2kgd->wave_control_execute (dev->adev, + reg_gfx_index.u32All, + reg_sq_cmd.u32All); + +return 0 ; +} +/* Access to DQM has to be locked before calling
destroy_queue_nocpsch_lockedReview
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0* to avoid asynchronized access */ (quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.hReview
Quoted 46 lines
index
a7d2e3323977..05a9c17daa3e100644drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h +35
-0@@ -39,6 +39,41 @@ struct device_process_node {struct list_head list; }; +union SQ_CMD_BITS { +struct { +uint32_t cmd:3 ; + uint32_t:1; +uint32_t mode:3 ; +uint32_t check_vmid:1 ; +uint32_t trap_id:3 ; + uint32_t:5; +uint32_t wave_id:4 ; +uint32_t simd_id:2 ; + uint32_t:2; +uint32_t queue_id:3 ; + uint32_t:1; +uint32_t vm_id:4 ; + } bitfields, bits; +uint32_t u32All; +signed int i32All; +float f32All; +}; + +union GRBM_GFX_INDEX_BITS { +struct { +uint32_t instance_index:8 ; +uint32_t sh_index:8 ; +uint32_t se_index:8 ; + uint32_t:5; +uint32_t sh_broadcast_writes:1 ; +uint32_t instance_broadcast_writes:1 ; +uint32_t se_broadcast_writes:1 ; + } bitfields, bits; +uint32_t u32All; +signed int i32All; +float f32All; +}; +/** * struct device_queue_manager_ops * (quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_iommu.cdrivers/gpu/drm/amd/amdkfd/kfd_iommu.c static void iommu_pasid_shutdown_callback(struct
Quoted 12 lines
index
66ad8d0b8f7f..fe62407dacb2100644drivers/gpu/drm/amd/amdkfd/kfd_iommu.c +0
-1@@ -30,7 +30,6 @@#include <linux/pci.h> #include <linux/amd-iommu.h> #include "kfd_priv.h" -#include "kfd_dbgmgr.h" #include "kfd_topology.h" #include "kfd_iommu.h" @@ -163,17 +162,6 @@ static void iommu_pasid_shutdown_callback(struct
pci_dev*pdev, u32 pasid)Review
Quoted 17 lines
drivers/gpu/drm/amd/amdkfd/kfd_iommu.c +0
-11pr_debug ("Unbinding process 0x%x from IOMMU\n" , pasid); -mutex_lock (kfd_get_dbgmgr_mutex ()); - -if (dev->dbgmgr && dev->dbgmgr->pasid == p->pasid) { -if (!kfd_dbgmgr_unregister (dev->dbgmgr, p)) { -kfd_dbgmgr_destroy (dev->dbgmgr); - dev->dbgmgr =NULL ; - } - } - -mutex_unlock (kfd_get_dbgmgr_mutex ()); -mutex_lock (&p->mutex); pdd =kfd_get_process_device_data (dev, p);(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_priv.hdrivers/gpu/drm/amd/amdkfd/kfd_priv.h void kfd_signal_poison_consumed_event(struct
Quoted 14 lines
index
74ff4132a163..465aae8e5697100644drivers/gpu/drm/amd/amdkfd/kfd_priv.h +0
-3@@ -300,9 +300,6 @@ struct kfd_dev {*/ bool interrupts_active; -/* Debug manager */ -struct kfd_dbgmgr *dbgmgr; -/* Firmware versions */ uint16_t mec_fw_version;uint16_t mec2_fw_version;@@ -1331,8 +1328,6 @@ void kfd_signal_poison_consumed_event(struct
kfd_dev*dev, u32 pasid);drivers/gpu/drm/amd/amdkfd/kfd_priv.h void kfd_signal_poison_consumed_event(struct · line 1328
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +0
-0void kfd_flush_tlb(struct kfd_process_device *pdd, enum TLB_FLUSH_TYPEtype);
drivers/gpu/drm/amd/amdkfd/kfd_priv.h void kfd_signal_poison_consumed_event(struct · line 1332
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +0
-1-int dbgdev_wave_reset_wavefronts(struct kfd_dev *dev, struct kfd_process*p);
Review
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +0
-1-bool kfd_is_locked (void );/* Compute profile */ (quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_process.cdrivers/gpu/drm/amd/amdkfd/kfd_process.c static void kfd_process_notifier_release(struct
Quoted 12 lines
index
8e2780d2f735..8c6a48add76e100644drivers/gpu/drm/amd/amdkfd/kfd_process.c +0
-1@@ -40,7 +40,6 @@ struct mm_struct;#include "kfd_priv.h" #include "kfd_device_queue_manager.h" -#include "kfd_dbgmgr.h" #include "kfd_iommu.h" #include "kfd_svm.h" @@ -1158,7 +1157,6 @@ static void kfd_process_notifier_release(struct
mmu_notifier*mn,drivers/gpu/drm/amd/amdkfd/kfd_process.c static void kfd_process_notifier_release(struct
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +0
-1struct mm_struct *mm) {struct kfd_process *p; -int i;/* * The kfd_process structure can not be free because the @@ -1178,23 +1176,6 @@ static void kfd_process_notifier_release(struct
mmu_notifier*mn,Quoted 22 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +0
-17mutex_lock (&p->mutex); -/* Iterate over all process device data structures and if the -* pdd is in debug mode, we should first force unregistration, -* then we will be able to destroy the queues -*/ -for (i =0 ; i < p->n_pdds; i++) { -struct kfd_dev *dev = p->pdds[i]->dev; - -mutex_lock (kfd_get_dbgmgr_mutex ()); -if (dev && dev->dbgmgr && dev->dbgmgr->pasid == p->pasid) { -if (!kfd_dbgmgr_unregister (dev->dbgmgr, p)) { -kfd_dbgmgr_destroy (dev->dbgmgr); - dev->dbgmgr =NULL ; - } - } -mutex_unlock (kfd_get_dbgmgr_mutex ()); - } -kfd_process_dequeue_from_all_devices (p);pqm_uninit (&p->pqm);
PATCH 3/3 drm/amdkfd: Consolidate MQD manager functions
In reply to Mukul JoshiA few MQD manager functions are duplicated for all versions of MQD manager. Remove this duplication by moving the common functions into kfd_mqd_manager.c file.
--- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c | 63 +++++++++++++++++ drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h | 27 ++++++++ .../gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c | 54 --------------- .../gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c | 61 ----------------- .../gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 68 ------------------- .../gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c | 53 --------------- 6 files changed, 90 insertions(+), 236 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +63 -0
@@ -173,3 +173,66 @@ void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm, } } } + +int hiq_load_mqd_kiq (struct mqd_manager *mm,void *mqd, +uint32_t pipe_id,uint32_t queue_id, +struct queue_properties *p,struct mm_struct *mms) +{ +return mm->dev->kfd2kgd->hiq_mqd_load (mm->dev->adev, mqd, pipe_id, + queue_id, p->doorbell_off); +} + +int destroy_mqd (struct mqd_manager *mm,void *mqd, +enum kfd_preempt_type type,unsigned int timeout, +uint32_t pipe_id,uint32_t queue_id) +{ +return mm->dev->kfd2kgd->hqd_destroy (mm->dev->adev, mqd, type, timeout, + pipe_id, queue_id); +} + +void free_mqd (struct mqd_manager *mm,void *mqd, +struct kfd_mem_obj *mqd_mem_obj) +{ +if (mqd_mem_obj->gtt_mem) { +amdgpu_amdkfd_free_gtt_mem (mm->dev->adev, mqd_mem_obj->gtt_mem); +kfree (mqd_mem_obj); + }else { +kfd_gtt_sa_free (mm->dev, mqd_mem_obj); + } +} + +bool is_occupied (struct mqd_manager *mm,void *mqd, +uint64_t queue_address,uint32_t pipe_id, +uint32_t queue_id) +{ +return mm->dev->kfd2kgd->hqd_is_occupied (mm->dev->adev, queue_address, + pipe_id, queue_id); +} + +int load_mqd_sdma (struct mqd_manager *mm,void *mqd, +uint32_t pipe_id,uint32_t queue_id, +struct queue_properties *p,struct mm_struct *mms) +{ +return mm->dev->kfd2kgd->hqd_sdma_load (mm->dev->adev, mqd, + (uint32_t __user *)p->write_ptr, + mms); +} + +/* +* preempt type here is ignored because there is only one way +* to preempt sdma queue +*/ +int destroy_mqd_sdma (struct mqd_manager *mm,void *mqd, +enum kfd_preempt_type type, +unsigned int timeout,uint32_t pipe_id, +uint32_t queue_id) +{ +return mm->dev->kfd2kgd->hqd_sdma_destroy (mm->dev->adev, mqd, timeout); +} + +bool is_occupied_sdma (struct mqd_manager *mm,void *mqd, +uint64_t queue_address,uint32_t pipe_id, +uint32_t queue_id) +{ +return mm->dev->kfd2kgd->hqd_sdma_is_occupied (mm->dev->adev, mqd); +}
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h +27 -0
@@ -136,4 +136,31 @@ void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm, const uint32_t *cu_mask, uint32_t cu_mask_count, uint32_t *se_mask); +int hiq_load_mqd_kiq (struct mqd_manager *mm,void *mqd, +uint32_t pipe_id,uint32_t queue_id, +struct queue_properties *p,struct mm_struct *mms); + +int destroy_mqd (struct mqd_manager *mm,void *mqd, +enum kfd_preempt_type type,unsigned int timeout, +uint32_t pipe_id,uint32_t queue_id); + +void free_mqd (struct mqd_manager *mm,void *mqd, +struct kfd_mem_obj *mqd_mem_obj); + +bool is_occupied (struct mqd_manager *mm,void *mqd, +uint64_t queue_address,uint32_t pipe_id, +uint32_t queue_id); + +int load_mqd_sdma (struct mqd_manager *mm,void *mqd, +uint32_t pipe_id,uint32_t queue_id, +struct queue_properties *p,struct mm_struct *mms); + +int destroy_mqd_sdma (struct mqd_manager *mm,void *mqd, +enum kfd_preempt_type type,unsigned int timeout, +uint32_t pipe_id,uint32_t queue_id); + +bool is_occupied_sdma (struct mqd_manager *mm,void *mqd, +uint64_t queue_address,uint32_t pipe_id, +uint32_t queue_id); +#endif /* KFD_MQD_MANAGER_H_ */
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0 -54
78 lines not on this page · raw message
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c +0 -61
85 lines not on this page · raw message
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0 -68
92 lines not on this page · raw message
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +0 -53
71 lines not on this page · raw message
Signature · 1 line
2.33.1
Felix Kuehling
maintainerRe: [PATCH 3/3] drm/amdkfd: Consolidate MQD manager functions
Am 2022-02-04 um 18:45 schrieb Mukul Joshi:
Quoted 19 lines
A few MQD manager functions are duplicated for all versions of MQD manager. Remove this duplication by moving the common functions into
kfd_mqd_manager.cfile.Signed-off-by Mukul Joshi <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c | 63 +++++++++++++++++ drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h | 27 ++++++++ .../gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c | 54 --------------- .../gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c | 61 ----------------- .../gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 68 ------------------- .../gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c | 53 --------------- 6 files changed, 90 insertions(+), 236 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +0
-0
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm, · line 179
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +4
-0@@ -173,3 +173,66 @@ void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm, } } } + +int hiq_load_mqd_kiq (struct mqd_manager *mm,void *mqd, +uint32_t pipe_id,uint32_t queue_id, +struct queue_properties *p,struct mm_struct *mms)
Since these functions are no longer static, they should get an appropriate name prefix to avoid future namespace collisions. Just a kfd_ prefix will do.
I think there are existing functions in this file that could use the same treatment (in a separate patch).
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm, · line 187
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +8
-0+{ +return mm->dev->kfd2kgd->hiq_mqd_load (mm->dev->adev, mqd, pipe_id, + queue_id, p->doorbell_off); +} + +int destroy_mqd (struct mqd_manager *mm,void *mqd, +enum kfd_preempt_type type,unsigned int timeout, +uint32_t pipe_id,uint32_t queue_id)
This function is only applicable to CP queues. Therefore I'd give it a more specific name, e.g. kfd_destroy_cp_mqd. Similar for the other non-SDMA functions below.
Regards,
Felix
Quoted 444 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +51
-0+{ +return mm->dev->kfd2kgd->hqd_destroy (mm->dev->adev, mqd, type, timeout, + pipe_id, queue_id); +} + +void free_mqd (struct mqd_manager *mm,void *mqd, +struct kfd_mem_obj *mqd_mem_obj) +{ +if (mqd_mem_obj->gtt_mem) { +amdgpu_amdkfd_free_gtt_mem (mm->dev->adev, mqd_mem_obj->gtt_mem); +kfree (mqd_mem_obj); + }else { +kfd_gtt_sa_free (mm->dev, mqd_mem_obj); + } +} + +bool is_occupied (struct mqd_manager *mm,void *mqd, +uint64_t queue_address,uint32_t pipe_id, +uint32_t queue_id) +{ +return mm->dev->kfd2kgd->hqd_is_occupied (mm->dev->adev, queue_address, + pipe_id, queue_id); +} + +int load_mqd_sdma (struct mqd_manager *mm,void *mqd, +uint32_t pipe_id,uint32_t queue_id, +struct queue_properties *p,struct mm_struct *mms) +{ +return mm->dev->kfd2kgd->hqd_sdma_load (mm->dev->adev, mqd, + (uint32_t __user *)p->write_ptr, + mms); +} + +/* +* preempt type here is ignored because there is only one way +* to preempt sdma queue +*/ +int destroy_mqd_sdma (struct mqd_manager *mm,void *mqd, +enum kfd_preempt_type type, +unsigned int timeout,uint32_t pipe_id, +uint32_t queue_id) +{ +return mm->dev->kfd2kgd->hqd_sdma_destroy (mm->dev->adev, mqd, timeout); +} + +bool is_occupied_sdma (struct mqd_manager *mm,void *mqd, +uint64_t queue_address,uint32_t pipe_id, +uint32_t queue_id) +{ +return mm->dev->kfd2kgd->hqd_sdma_is_occupied (mm->dev->adev, mqd); +}drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h +27
-0@@ -136,4 +136,31 @@ void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm, const uint32_t *cu_mask, uint32_t cu_mask_count, uint32_t *se_mask); +int hiq_load_mqd_kiq (struct mqd_manager *mm,void *mqd, +uint32_t pipe_id,uint32_t queue_id, +struct queue_properties *p,struct mm_struct *mms); + +int destroy_mqd (struct mqd_manager *mm,void *mqd, +enum kfd_preempt_type type,unsigned int timeout, +uint32_t pipe_id,uint32_t queue_id); + +void free_mqd (struct mqd_manager *mm,void *mqd, +struct kfd_mem_obj *mqd_mem_obj); + +bool is_occupied (struct mqd_manager *mm,void *mqd, +uint64_t queue_address,uint32_t pipe_id, +uint32_t queue_id); + +int load_mqd_sdma (struct mqd_manager *mm,void *mqd, +uint32_t pipe_id,uint32_t queue_id, +struct queue_properties *p,struct mm_struct *mms); + +int destroy_mqd_sdma (struct mqd_manager *mm,void *mqd, +enum kfd_preempt_type type,unsigned int timeout, +uint32_t pipe_id,uint32_t queue_id); + +bool is_occupied_sdma (struct mqd_manager *mm,void *mqd, +uint64_t queue_address,uint32_t pipe_id, +uint32_t queue_id); +#endif /* KFD_MQD_MANAGER_H_ */ drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-54@@ -156,13 +156,6 @@ static void init_mqd_sdma(struct mqd_manager *mm, void **mqd, mm->update_mqd (mm, m, q,NULL ); } -static void free_mqd (struct mqd_manager *mm,void *mqd, -struct kfd_mem_obj *mqd_mem_obj) -{ -kfd_gtt_sa_free (mm->dev, mqd_mem_obj); -} - -static int load_mqd (struct mqd_manager *mm,void *mqd,uint32_t pipe_id,uint32_t queue_id,struct queue_properties *p,struct mm_struct *mms)@@ -176,15 +169,6 @@ static int load_mqd(struct mqd_manager *mm, void *mqd, uint32_t pipe_id, wptr_shift, wptr_mask, mms); } -static int load_mqd_sdma (struct mqd_manager *mm,void *mqd, -uint32_t pipe_id,uint32_t queue_id, -struct queue_properties *p,struct mm_struct *mms) -{ -return mm->dev->kfd2kgd->hqd_sdma_load (mm->dev->adev, mqd, - (uint32_t __user *)p->write_ptr, - mms); -} -static void __update_mqd (struct mqd_manager *mm,void *mqd,struct queue_properties *q,struct mqd_update_info *minfo,unsigned int atc_bit)@@ -271,15 +255,6 @@ static void update_mqd_sdma(struct mqd_manager *mm, void *mqd, q->is_active =QUEUE_IS_ACTIVE (*q); } -static int destroy_mqd (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_destroy (mm->dev->adev, mqd, type, timeout, - pipe_id, queue_id); -} -static void checkpoint_mqd (struct mqd_manager *mm,void *mqd,void *mqd_dst,void *ctl_stack_dst) {struct cik_mqd *m;@@ -351,35 +326,6 @@ static void restore_mqd_sdma(struct mqd_manager *mm, void **mqd, qp->is_active =0 ; } -/* -* preempt type here is ignored because there is only one way -* to preempt sdma queue -*/ -static int destroy_mqd_sdma (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_sdma_destroy (mm->dev->adev, mqd, timeout); -} - -static bool is_occupied (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ - -return mm->dev->kfd2kgd->hqd_is_occupied (mm->dev->adev, queue_address, - pipe_id, queue_id); - -} - -static bool is_occupied_sdma (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_sdma_is_occupied (mm->dev->adev, mqd); -} -/* * HIQ MQD Implementation, concrete implementation for HIQ MQD implementation. * The HIQ queue in Kaveri is using the same MQD structure as all the user mode drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c +0
-61@@ -154,14 +154,6 @@ static int load_mqd(struct mqd_manager *mm, void *mqd,return r; } -static int hiq_load_mqd_kiq (struct mqd_manager *mm,void *mqd, -uint32_t pipe_id,uint32_t queue_id, -struct queue_properties *p,struct mm_struct *mms) -{ -return mm->dev->kfd2kgd->hiq_mqd_load (mm->dev->adev, mqd, pipe_id, - queue_id, p->doorbell_off); -} -static void update_mqd (struct mqd_manager *mm,void *mqd,struct queue_properties *q,struct mqd_update_info *minfo)@@ -233,31 +225,6 @@ static uint32_t read_doorbell_id(void *mqd)return m->queue_doorbell_id0; } -static int destroy_mqd (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_destroy - (mm->dev->adev, mqd, type, timeout, - pipe_id, queue_id); -} - -static void free_mqd (struct mqd_manager *mm,void *mqd, -struct kfd_mem_obj *mqd_mem_obj) -{ -kfd_gtt_sa_free (mm->dev, mqd_mem_obj); -} - -static bool is_occupied (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_is_occupied ( - mm->dev->adev, queue_address, - pipe_id, queue_id); -} - static int get_wave_state(struct mqd_manager *mm, void *mqd, void __user *ctl_stack, u32 *ctl_stack_used_size,@@ -352,15 +319,6 @@ static void init_mqd_sdma(struct mqd_manager *mm, void **mqd, mm->update_mqd (mm, m, q,NULL ); } -static int load_mqd_sdma (struct mqd_manager *mm,void *mqd, -uint32_t pipe_id,uint32_t queue_id, -struct queue_properties *p,struct mm_struct *mms) -{ -return mm->dev->kfd2kgd->hqd_sdma_load (mm->dev->adev, mqd, - (uint32_t __user *)p->write_ptr, - mms); -} -#define SDMA_RLC_DUMMY_DEFAULT 0xf static void update_mqd_sdma(struct mqd_manager *mm, void *mqd,@@ -390,25 +348,6 @@ static void update_mqd_sdma(struct mqd_manager *mm, void *mqd, q->is_active =QUEUE_IS_ACTIVE (*q); } -/* -* * preempt type here is ignored because there is only one way -* * to preempt sdma queue -*/ -static int destroy_mqd_sdma (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_sdma_destroy (mm->dev->adev, mqd, timeout); -} - -static bool is_occupied_sdma (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_sdma_is_occupied (mm->dev->adev, mqd); -} - static void checkpoint_mqd_sdma(struct mqd_manager *mm, void *mqd, void *mqd_dst,drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0
-68@@ -204,14 +204,6 @@ static int load_mqd(struct mqd_manager *mm, void *mqd, wptr_shift, 0, mms); } -static int hiq_load_mqd_kiq (struct mqd_manager *mm,void *mqd, -uint32_t pipe_id,uint32_t queue_id, -struct queue_properties *p,struct mm_struct *mms) -{ -return mm->dev->kfd2kgd->hiq_mqd_load (mm->dev->adev, mqd, pipe_id, - queue_id, p->doorbell_off); -} -static void update_mqd (struct mqd_manager *mm,void *mqd,struct queue_properties *q,struct mqd_update_info *minfo)@@ -285,38 +277,6 @@ static uint32_t read_doorbell_id(void *mqd)return m->queue_doorbell_id0; } -static int destroy_mqd (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_destroy - (mm->dev->adev, mqd, type, timeout, - pipe_id, queue_id); -} - -static void free_mqd (struct mqd_manager *mm,void *mqd, -struct kfd_mem_obj *mqd_mem_obj) -{ -struct kfd_dev *kfd = mm->dev; - -if (mqd_mem_obj->gtt_mem) { -amdgpu_amdkfd_free_gtt_mem (kfd->adev, mqd_mem_obj->gtt_mem); -kfree (mqd_mem_obj); - }else { -kfd_gtt_sa_free (mm->dev, mqd_mem_obj); - } -} - -static bool is_occupied (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_is_occupied ( - mm->dev->adev, queue_address, - pipe_id, queue_id); -} - static int get_wave_state(struct mqd_manager *mm, void *mqd, void __user *ctl_stack, u32 *ctl_stack_used_size,@@ -422,15 +382,6 @@ static void init_mqd_sdma(struct mqd_manager *mm, void **mqd, mm->update_mqd (mm, m, q,NULL ); } -static int load_mqd_sdma (struct mqd_manager *mm,void *mqd, -uint32_t pipe_id,uint32_t queue_id, -struct queue_properties *p,struct mm_struct *mms) -{ -return mm->dev->kfd2kgd->hqd_sdma_load (mm->dev->adev, mqd, - (uint32_t __user *)p->write_ptr, - mms); -} -#define SDMA_RLC_DUMMY_DEFAULT 0xf static void update_mqd_sdma(struct mqd_manager *mm, void *mqd,@@ -460,25 +411,6 @@ static void update_mqd_sdma(struct mqd_manager *mm, void *mqd, q->is_active =QUEUE_IS_ACTIVE (*q); } -/* -* * preempt type here is ignored because there is only one way -* * to preempt sdma queue -*/ -static int destroy_mqd_sdma (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_sdma_destroy (mm->dev->adev, mqd, timeout); -} - -static bool is_occupied_sdma (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_sdma_is_occupied (mm->dev->adev, mqd); -} - static void checkpoint_mqd_sdma(struct mqd_manager *mm, void *mqd, void *mqd_dst,drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +0
-53@@ -259,31 +259,6 @@ static void update_mqd_tonga(struct mqd_manager *mm, void *mqd,__update_mqd (mm, mqd, q, minfo,MTYPE_UC ,0 ); } -static int destroy_mqd (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_destroy - (mm->dev->adev, mqd, type, timeout, - pipe_id, queue_id); -} - -static void free_mqd (struct mqd_manager *mm,void *mqd, -struct kfd_mem_obj *mqd_mem_obj) -{ -kfd_gtt_sa_free (mm->dev, mqd_mem_obj); -} - -static bool is_occupied (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_is_occupied ( - mm->dev->adev, queue_address, - pipe_id, queue_id); -} - static int get_wave_state(struct mqd_manager *mm, void *mqd, void __user *ctl_stack, u32 *ctl_stack_used_size,@@ -385,15 +360,6 @@ static void init_mqd_sdma(struct mqd_manager *mm, void **mqd, mm->update_mqd (mm, m, q,NULL ); } -static int load_mqd_sdma (struct mqd_manager *mm,void *mqd, -uint32_t pipe_id,uint32_t queue_id, -struct queue_properties *p,struct mm_struct *mms) -{ -return mm->dev->kfd2kgd->hqd_sdma_load (mm->dev->adev, mqd, - (uint32_t __user *)p->write_ptr, - mms); -} -static void update_mqd_sdma (struct mqd_manager *mm,void *mqd,struct queue_properties *q,struct mqd_update_info *minfo)@@ -422,25 +388,6 @@ static void update_mqd_sdma(struct mqd_manager *mm, void *mqd, q->is_active =QUEUE_IS_ACTIVE (*q); } -/* -* * preempt type here is ignored because there is only one way -* * to preempt sdma queue -*/ -static int destroy_mqd_sdma (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_sdma_destroy (mm->dev->adev, mqd, timeout); -} - -static bool is_occupied_sdma (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_sdma_is_occupied (mm->dev->adev, mqd); -} - static void checkpoint_mqd_sdma(struct mqd_manager *mm, void *mqd, void *mqd_dst,
RE: [PATCH 3/3] drm/amdkfd: Consolidate MQD manager functions
[AMD Official Use Only]
Quoted 48 lines
-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Monday, February 7, 2022 10:43 AM
To: Joshi, Mukul <[email protected]>; [email protected]
Subject: Re: [PATCH 3/3] drm/amdkfd: Consolidate MQD manager functionsAm 2022-02-04 um 18:45 schrieb Mukul Joshi:
Quoted 7 lines
A few MQD manager functions are duplicated for all versions of MQD manager. Remove this duplication by moving the common functions into
kfd_mqd_manager.cfile.Signed-off-by Mukul Joshi <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c | 63+++++++++++++++++
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c void mqd_symmetrically_map_cu_mask(struct
Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h | 27 ++++++++ .../gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c | 54 --------------- .../gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c | 61 ----------------- .../gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 68 ------------------- .../gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c | 53 --------------- 6 files changed, 90 insertions(+), 236 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +0
-0@@ -173,3 +173,66 @@ void mqd_symmetrically_map_cu_mask(struct
mqd_manager*mm,drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm, · line 179
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +4
-0} } } + +int hiq_load_mqd_kiq (struct mqd_manager *mm,void *mqd, +uint32_t pipe_id,uint32_t queue_id, +struct queue_properties *p,struct mm_struct *mms)Since these functions are no longer static, they should get an appropriate name prefix to avoid future namespace collisions. Just a
kfd_prefix will do.I think there are existing functions in this file that could use the same treatment (in a separate patch).
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c void mqd_symmetrically_map_cu_mask(struct · line 181
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +2
-0+{ + return mm->dev->kfd2kgd->hiq_mqd_load(mm->dev->adev, mqd,
pipe_id,
Quoted 11 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm, · line 187
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +6
-0+ queue_id, p->doorbell_off); +} + +int destroy_mqd (struct mqd_manager *mm,void *mqd, +enum kfd_preempt_type type,unsigned int timeout, +uint32_t pipe_id,uint32_t queue_id)This function is only applicable to CP queues. Therefore I'd give it a more specific name, e.g.
kfd_destroy_cp_mqd. Similar for the other non-SDMA functions below.
We define destroy_hqd for HIQ (and DIQ ) also. Same for free_mqd and other functions. I guess that’s why we have _sdma for SDMA queues, and the rest use a generic name. Maybe leaving it without '_cp' is better here. What do you think?
Regards,
Mukul
Quoted 490 lines
Regards,
Felixdrivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c void mqd_symmetrically_map_cu_mask(struct · line 189
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +2
-0+{ + return mm->dev->kfd2kgd->hqd_destroy(mm->dev->adev, mqd, type,timeout,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm,
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +8
-0+ pipe_id, queue_id); +} + +void free_mqd (struct mqd_manager *mm,void *mqd, +struct kfd_mem_obj *mqd_mem_obj) +{ +if (mqd_mem_obj->gtt_mem) { + amdgpu_amdkfd_free_gtt_mem(mm->dev->adev,
mqd_mem_obj->gtt_mem);drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm,
Quoted 11 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +11
-0+kfree (mqd_mem_obj); + }else { +kfd_gtt_sa_free (mm->dev, mqd_mem_obj); + } +} + +bool is_occupied (struct mqd_manager *mm,void *mqd, +uint64_t queue_address,uint32_t pipe_id, +uint32_t queue_id) +{ + return mm->dev->kfd2kgd->hqd_is_occupied(mm->dev->adev,
queue_address,Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +9
-0+ pipe_id, queue_id); +} + +int load_mqd_sdma (struct mqd_manager *mm,void *mqd, +uint32_t pipe_id,uint32_t queue_id, +struct queue_properties *p,struct mm_struct *mms) +{ + return mm->dev->kfd2kgd->hqd_sdma_load(mm->dev->adev, mqd, + (uint32_t __user *)p-
write_ptr,drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +3
-0+ mms); +} +drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm,
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +10
-0+/* +* preempt type here is ignored because there is only one way +* to preempt sdma queue +*/ +int destroy_mqd_sdma (struct mqd_manager *mm,void *mqd, +enum kfd_preempt_type type, +unsigned int timeout,uint32_t pipe_id, +uint32_t queue_id) +{ + return mm->dev->kfd2kgd->hqd_sdma_destroy(mm->dev->adev, mqd,timeout);
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm,
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +7
-0+} + +bool is_occupied_sdma (struct mqd_manager *mm,void *mqd, +uint64_t queue_address,uint32_t pipe_id, +uint32_t queue_id) +{ + return mm->dev->kfd2kgd->hqd_sdma_is_occupied(mm->dev->adev,mqd);
Review
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +1
-0+}(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.hdrivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h void mqd_symmetrically_map_cu_mask(struct
Quoted 4 lines
index
23486a23df84..76f20637b938100644drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h +0
-0@@ -136,4 +136,31 @@ void mqd_symmetrically_map_cu_mask(struct
mqd_manager*mm,Review
Quoted 32 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h +27
-0const uint32_t *cu_mask, uint32_t cu_mask_count, uint32_t *se_mask); +int hiq_load_mqd_kiq (struct mqd_manager *mm,void *mqd, +uint32_t pipe_id,uint32_t queue_id, +struct queue_properties *p,struct mm_struct *mms); + +int destroy_mqd (struct mqd_manager *mm,void *mqd, +enum kfd_preempt_type type,unsigned int timeout, +uint32_t pipe_id,uint32_t queue_id); + +void free_mqd (struct mqd_manager *mm,void *mqd, +struct kfd_mem_obj *mqd_mem_obj); + +bool is_occupied (struct mqd_manager *mm,void *mqd, +uint64_t queue_address,uint32_t pipe_id, +uint32_t queue_id); + +int load_mqd_sdma (struct mqd_manager *mm,void *mqd, +uint32_t pipe_id,uint32_t queue_id, +struct queue_properties *p,struct mm_struct *mms); + +int destroy_mqd_sdma (struct mqd_manager *mm,void *mqd, +enum kfd_preempt_type type,unsigned int timeout, +uint32_t pipe_id,uint32_t queue_id); + +bool is_occupied_sdma (struct mqd_manager *mm,void *mqd, +uint64_t queue_address,uint32_t pipe_id, +uint32_t queue_id); +#endif /* KFD_MQD_MANAGER_H_ */ (quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.cdrivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static void init_mqd_sdma(struct mqd_manager
Quoted 4 lines
index
96e3303fa27c..81b6b3d5f2e7100644drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-0@@ -156,13 +156,6 @@ static void init_mqd_sdma(struct mqd_manager*mm, void **mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static int load_mqd(struct mqd_manager *mm, void
Quoted 14 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-7mm->update_mqd (mm, m, q,NULL ); } -static void free_mqd (struct mqd_manager *mm,void *mqd, -struct kfd_mem_obj *mqd_mem_obj) -{ -kfd_gtt_sa_free (mm->dev, mqd_mem_obj); -} - -static int load_mqd (struct mqd_manager *mm,void *mqd,uint32_t pipe_id,uint32_t queue_id,struct queue_properties *p,struct mm_struct *mms)@@ -176,15 +169,6 @@ static int load_mqd(struct mqd_manager *mm, void*mqd,
uint32_tpipe_id,Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-1wptr_shift, wptr_mask, mms); } -static int load_mqd_sdma(struct mqd_manager *mm, void *mqd,drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static int load_mqd(struct mqd_manager *mm, void *mqd, uint32_t pipe_id,
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-8- uint32_t pipe_id, uint32_t queue_id, - struct queue_properties *p, struct mm_struct *mms) -{ - return mm->dev->kfd2kgd->hqd_sdma_load(mm->dev->adev, mqd, - (uint32_t __user *)p->write_ptr, - mms); -} -static void __update_mqd (struct mqd_manager *mm,void *mqd, struct queue_properties *q, struct mqd_update_info*minfo,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static void update_mqd_sdma(struct mqd_manager
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-0unsigned int atc_bit)@@ -271,15 +255,6 @@ static void update_mqd_sdma(struct mqd_manager*mm, void *mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static void update_mqd_sdma(struct mqd_manager *mm, void *mqd,
Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-6q->is_active =QUEUE_IS_ACTIVE (*q); } -static int destroy_mqd (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ - return mm->dev->kfd2kgd->hqd_destroy(mm->dev->adev, mqd, type,timeout,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static void update_mqd_sdma(struct mqd_manager *mm, void *mqd,
Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-3- pipe_id, queue_id); -} - static void checkpoint_mqd(struct mqd_manager *mm, void *mqd, void
*mqd_dst, void*ctl_stack_dst)drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static void restore_mqd_sdma(struct mqd_manager
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-0{struct cik_mqd *m;@@ -351,35 +326,6 @@ static void restore_mqd_sdma(struct mqd_manager*mm, void **mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static void restore_mqd_sdma(struct mqd_manager *mm, void **mqd,
Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-10qp->is_active =0 ; } -/* -* preempt type here is ignored because there is only one way -* to preempt sdma queue -*/ -static int destroy_mqd_sdma (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ - return mm->dev->kfd2kgd->hqd_sdma_destroy(mm->dev->adev, mqd,timeout);
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static void restore_mqd_sdma(struct mqd_manager *mm, void **mqd,
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-8-} - -static bool is_occupied (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ - - return mm->dev->kfd2kgd->hqd_is_occupied(mm->dev->adev,
queue_address,drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static void restore_mqd_sdma(struct mqd_manager *mm, void **mqd,
Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-9- pipe_id, queue_id); - -} - -static bool is_occupied_sdma (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ - return mm->dev->kfd2kgd->hqd_sdma_is_occupied(mm->dev->adev,mqd);
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static void restore_mqd_sdma(struct mqd_manager *mm, void **mqd,
Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-2-} -/* * HIQ MQD Implementation, concrete implementation for HIQ MQD implementation.
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static void restore_mqd_sdma(struct mqd_manager · line 331
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-0* The HIQ queue in Kaveri is using the same MQD structure as all the user mode
Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.cdrivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c static int load_mqd(struct mqd_manager *mm, void
Quoted 4 lines
index
0cc8679c24fa..8324757a1cf5100644drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c +0
-0@@ -154,14 +154,6 @@ static int load_mqd(struct mqd_manager *mm, void*mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c static int load_mqd(struct mqd_manager *mm, void *mqd,
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c +0
-5return r; } -static int hiq_load_mqd_kiq (struct mqd_manager *mm,void *mqd, -uint32_t pipe_id,uint32_t queue_id, -struct queue_properties *p,struct mm_struct *mms) -{ - return mm->dev->kfd2kgd->hiq_mqd_load(mm->dev->adev, mqd,
pipe_id,drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c static void init_mqd_sdma(struct mqd_manager
Quoted 39 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c +0
-28- queue_id, p->doorbell_off); -} -static void update_mqd (struct mqd_manager *mm,void *mqd,struct queue_properties *q,struct mqd_update_info *minfo)@@ -233,31 +225,6 @@ static uint32_t read_doorbell_id(void *mqd)return m->queue_doorbell_id0; } -static int destroy_mqd (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_destroy - (mm->dev->adev, mqd, type, timeout, - pipe_id, queue_id); -} - -static void free_mqd (struct mqd_manager *mm,void *mqd, -struct kfd_mem_obj *mqd_mem_obj) -{ -kfd_gtt_sa_free (mm->dev, mqd_mem_obj); -} - -static bool is_occupied (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_is_occupied ( - mm->dev->adev, queue_address, - pipe_id, queue_id); -} - static int get_wave_state(struct mqd_manager *mm, void *mqd, void __user *ctl_stack, u32 *ctl_stack_used_size,@@ -352,15 +319,6 @@ static void init_mqd_sdma(struct mqd_manager*mm, void **mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c static void update_mqd_sdma(struct mqd_manager
Quoted 16 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c +0
-9mm->update_mqd (mm, m, q,NULL ); } -static int load_mqd_sdma (struct mqd_manager *mm,void *mqd, -uint32_t pipe_id,uint32_t queue_id, -struct queue_properties *p,struct mm_struct *mms) -{ -return mm->dev->kfd2kgd->hqd_sdma_load (mm->dev->adev, mqd, - (uint32_t __user *)p->write_ptr, - mms); -} -#define SDMA_RLC_DUMMY_DEFAULT 0xf static void update_mqd_sdma(struct mqd_manager *mm, void *mqd,@@ -390,25 +348,6 @@ static void update_mqd_sdma(struct mqd_manager*mm, void *mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c static void update_mqd_sdma(struct mqd_manager *mm, void *mqd,
Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c +0
-10q->is_active =QUEUE_IS_ACTIVE (*q); } -/* -* * preempt type here is ignored because there is only one way -* * to preempt sdma queue -*/ -static int destroy_mqd_sdma (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ - return mm->dev->kfd2kgd->hqd_sdma_destroy(mm->dev->adev, mqd,timeout);
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c static void update_mqd_sdma(struct mqd_manager · line 409
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c +0
-7-} - -static bool is_occupied_sdma (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ - return mm->dev->kfd2kgd->hqd_sdma_is_occupied(mm->dev->adev,mqd);
Review
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c +0
-2-} - static void checkpoint_mqd_sdma(struct mqd_manager *mm, void *mqd, void *mqd_dst,(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.cdrivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c static int load_mqd(struct mqd_manager *mm, void
Quoted 4 lines
index
87da4329dbf2..007886b2961e100644drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0
-0@@ -204,14 +204,6 @@ static int load_mqd(struct mqd_manager *mm, void*mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c static int load_mqd(struct mqd_manager *mm, void *mqd,
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0
-5wptr_shift, 0, mms); } -static int hiq_load_mqd_kiq (struct mqd_manager *mm,void *mqd, -uint32_t pipe_id,uint32_t queue_id, -struct queue_properties *p,struct mm_struct *mms) -{ - return mm->dev->kfd2kgd->hiq_mqd_load(mm->dev->adev, mqd,
pipe_id,drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c static void init_mqd_sdma(struct mqd_manager
Quoted 47 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0
-35- queue_id, p->doorbell_off); -} -static void update_mqd (struct mqd_manager *mm,void *mqd,struct queue_properties *q,struct mqd_update_info *minfo)@@ -285,38 +277,6 @@ static uint32_t read_doorbell_id(void *mqd)return m->queue_doorbell_id0; } -static int destroy_mqd (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_destroy - (mm->dev->adev, mqd, type, timeout, - pipe_id, queue_id); -} - -static void free_mqd (struct mqd_manager *mm,void *mqd, -struct kfd_mem_obj *mqd_mem_obj) -{ -struct kfd_dev *kfd = mm->dev; - -if (mqd_mem_obj->gtt_mem) { -amdgpu_amdkfd_free_gtt_mem (kfd->adev, mqd_mem_obj- gtt_mem); -kfree (mqd_mem_obj); - }else { -kfd_gtt_sa_free (mm->dev, mqd_mem_obj); - } -} - -static bool is_occupied (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_is_occupied ( - mm->dev->adev, queue_address, - pipe_id, queue_id); -} - static int get_wave_state(struct mqd_manager *mm, void *mqd, void __user *ctl_stack,u32
*ctl_stack_used_size,drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0
-0@@ -422,15 +382,6 @@ static void init_mqd_sdma(struct mqd_manager*mm, void **mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c static void update_mqd_sdma(struct mqd_manager
Quoted 16 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0
-9mm->update_mqd (mm, m, q,NULL ); } -static int load_mqd_sdma (struct mqd_manager *mm,void *mqd, -uint32_t pipe_id,uint32_t queue_id, -struct queue_properties *p,struct mm_struct *mms) -{ -return mm->dev->kfd2kgd->hqd_sdma_load (mm->dev->adev, mqd, - (uint32_t __user *)p->write_ptr, - mms); -} -#define SDMA_RLC_DUMMY_DEFAULT 0xf static void update_mqd_sdma(struct mqd_manager *mm, void *mqd,@@ -460,25 +411,6 @@ static void update_mqd_sdma(struct mqd_manager*mm, void *mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c static void update_mqd_sdma(struct mqd_manager · line 472
Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0
-10q->is_active =QUEUE_IS_ACTIVE (*q); } -/* -* * preempt type here is ignored because there is only one way -* * to preempt sdma queue -*/ -static int destroy_mqd_sdma (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ - return mm->dev->kfd2kgd->hqd_sdma_destroy(mm->dev->adev, mqd,timeout);
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c static void update_mqd_sdma(struct mqd_manager · line 479
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0
-7-} - -static bool is_occupied_sdma (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ - return mm->dev->kfd2kgd->hqd_sdma_is_occupied(mm->dev->adev,mqd);
Review
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0
-2-} - static void checkpoint_mqd_sdma(struct mqd_manager *mm, void *mqd, void *mqd_dst,(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.cdrivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c static void update_mqd_tonga(struct mqd_manager
Quoted 4 lines
index
137b208135a0..c0405bbe8e36100644drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +0
-0@@ -259,31 +259,6 @@ static void update_mqd_tonga(struct mqd_manager*mm, void *mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c static void init_mqd_sdma(struct mqd_manager
Quoted 32 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +0
-25__update_mqd (mm, mqd, q, minfo,MTYPE_UC ,0 ); } -static int destroy_mqd (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_destroy - (mm->dev->adev, mqd, type, timeout, - pipe_id, queue_id); -} - -static void free_mqd (struct mqd_manager *mm,void *mqd, -struct kfd_mem_obj *mqd_mem_obj) -{ -kfd_gtt_sa_free (mm->dev, mqd_mem_obj); -} - -static bool is_occupied (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_is_occupied ( - mm->dev->adev, queue_address, - pipe_id, queue_id); -} - static int get_wave_state(struct mqd_manager *mm, void *mqd, void __user *ctl_stack, u32 *ctl_stack_used_size,@@ -385,15 +360,6 @@ static void init_mqd_sdma(struct mqd_manager*mm, void **mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c static void update_mqd_sdma(struct mqd_manager
Quoted 16 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +0
-9mm->update_mqd (mm, m, q,NULL ); } -static int load_mqd_sdma (struct mqd_manager *mm,void *mqd, -uint32_t pipe_id,uint32_t queue_id, -struct queue_properties *p,struct mm_struct *mms) -{ -return mm->dev->kfd2kgd->hqd_sdma_load (mm->dev->adev, mqd, - (uint32_t __user *)p->write_ptr, - mms); -} -static void update_mqd_sdma (struct mqd_manager *mm,void *mqd,struct queue_properties *q,struct mqd_update_info *minfo)@@ -422,25 +388,6 @@ static void update_mqd_sdma(struct mqd_manager*mm, void *mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c static void update_mqd_sdma(struct mqd_manager · line 434
Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +0
-10q->is_active =QUEUE_IS_ACTIVE (*q); } -/* -* * preempt type here is ignored because there is only one way -* * to preempt sdma queue -*/ -static int destroy_mqd_sdma (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ - return mm->dev->kfd2kgd->hqd_sdma_destroy(mm->dev->adev, mqd,timeout);
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c static void update_mqd_sdma(struct mqd_manager · line 441
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +0
-7-} - -static bool is_occupied_sdma (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ - return mm->dev->kfd2kgd->hqd_sdma_is_occupied(mm->dev->adev,mqd);
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +0
-2-} - static void checkpoint_mqd_sdma(struct mqd_manager *mm, void *mqd, void *mqd_dst,
Felix Kuehling
maintainerRe: [PATCH 3/3] drm/amdkfd: Consolidate MQD manager functions
Am 2022-02-07 um 12:50 schrieb Joshi, Mukul:
Quoted 61 lines
[AMD Official Use Only]
Quoted 47 lines
-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Monday, February 7, 2022 10:43 AM
To: Joshi, Mukul <[email protected]>; [email protected]
Subject: Re: [PATCH 3/3] drm/amdkfd: Consolidate MQD manager functionsAm 2022-02-04 um 18:45 schrieb Mukul Joshi:
Quoted 7 lines
A few MQD manager functions are duplicated for all versions of MQD manager. Remove this duplication by moving the common functions into
kfd_mqd_manager.cfile.Signed-off-by Mukul Joshi <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c | 63+++++++++++++++++
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c void mqd_symmetrically_map_cu_mask(struct
Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h | 27 ++++++++ .../gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c | 54 --------------- .../gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c | 61 ----------------- .../gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 68 ------------------- .../gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c | 53 --------------- 6 files changed, 90 insertions(+), 236 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +0
-0@@ -173,3 +173,66 @@ void mqd_symmetrically_map_cu_mask(struct
mqd_manager*mm,drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm, · line 179
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +4
-0} } } + +int hiq_load_mqd_kiq (struct mqd_manager *mm,void *mqd, +uint32_t pipe_id,uint32_t queue_id, +struct queue_properties *p,struct mm_struct *mms)Since these functions are no longer static, they should get an appropriate name prefix to avoid future namespace collisions. Just a
kfd_prefix will do.I think there are existing functions in this file that could use the same treatment (in a separate patch).
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c void mqd_symmetrically_map_cu_mask(struct · line 181
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +2
-0+{ + return mm->dev->kfd2kgd->hiq_mqd_load(mm->dev->adev, mqd,
pipe_id,Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm, · line 187
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +6
-0+ queue_id, p->doorbell_off); +} + +int destroy_mqd (struct mqd_manager *mm,void *mqd, +enum kfd_preempt_type type,unsigned int timeout, +uint32_t pipe_id,uint32_t queue_id)This function is only applicable to CP queues. Therefore I'd give it a more specific name, e.g.
kfd_destroy_cp_mqd. Similar for the other non-SDMA functions below.
Quoted 3 lines
We define
destroy_hqdfor HIQ (and DIQ ) also. Same forfree_mqdand other functions. I guess that’s why we have_sdmafor SDMA queues, and the rest use a generic name. Maybe leaving it without '_cp' is better here. What do you think?
I still think calling out the queue type in the function name makes sense, if the function is not applicable to all queue types. In some cases there is overlap. For example HIQ and DIQ would use destroy_hqd_cp. But HIQ uses free_mqd_hiq_sdma.
I guess it still leaves some ambiguity because CP is used as superset of CP, HIQ and DIQ in some cases, but only CP compute queues in others. If you want, you could use "CP" to mean the superset and "compute" for CP compute queues only.
Regards,
Felix
Quoted 494 lines
Regards,
MukulQuoted 490 lines
Regards,
Felixdrivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c void mqd_symmetrically_map_cu_mask(struct · line 189
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +2
-0+{ + return mm->dev->kfd2kgd->hqd_destroy(mm->dev->adev, mqd, type,timeout,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm,
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +8
-0+ pipe_id, queue_id); +} + +void free_mqd (struct mqd_manager *mm,void *mqd, +struct kfd_mem_obj *mqd_mem_obj) +{ +if (mqd_mem_obj->gtt_mem) { + amdgpu_amdkfd_free_gtt_mem(mm->dev->adev,
mqd_mem_obj->gtt_mem);drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm,
Quoted 11 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +11
-0+kfree (mqd_mem_obj); + }else { +kfd_gtt_sa_free (mm->dev, mqd_mem_obj); + } +} + +bool is_occupied (struct mqd_manager *mm,void *mqd, +uint64_t queue_address,uint32_t pipe_id, +uint32_t queue_id) +{ + return mm->dev->kfd2kgd->hqd_is_occupied(mm->dev->adev,
queue_address,Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +9
-0+ pipe_id, queue_id); +} + +int load_mqd_sdma (struct mqd_manager *mm,void *mqd, +uint32_t pipe_id,uint32_t queue_id, +struct queue_properties *p,struct mm_struct *mms) +{ + return mm->dev->kfd2kgd->hqd_sdma_load(mm->dev->adev, mqd, + (uint32_t __user *)p-
write_ptr,drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +3
-0+ mms); +} +drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm,
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +10
-0+/* +* preempt type here is ignored because there is only one way +* to preempt sdma queue +*/ +int destroy_mqd_sdma (struct mqd_manager *mm,void *mqd, +enum kfd_preempt_type type, +unsigned int timeout,uint32_t pipe_id, +uint32_t queue_id) +{ + return mm->dev->kfd2kgd->hqd_sdma_destroy(mm->dev->adev, mqd,timeout);
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c void mqd_symmetrically_map_cu_mask(struct mqd_manager *mm,
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +7
-0+} + +bool is_occupied_sdma (struct mqd_manager *mm,void *mqd, +uint64_t queue_address,uint32_t pipe_id, +uint32_t queue_id) +{ + return mm->dev->kfd2kgd->hqd_sdma_is_occupied(mm->dev->adev,mqd);
Review
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c +1
-0+}(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.hdrivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h void mqd_symmetrically_map_cu_mask(struct
Quoted 4 lines
index
23486a23df84..76f20637b938100644drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h +0
-0@@ -136,4 +136,31 @@ void mqd_symmetrically_map_cu_mask(struct
mqd_manager*mm,Review
Quoted 32 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.h +27
-0const uint32_t *cu_mask, uint32_t cu_mask_count, uint32_t *se_mask); +int hiq_load_mqd_kiq (struct mqd_manager *mm,void *mqd, +uint32_t pipe_id,uint32_t queue_id, +struct queue_properties *p,struct mm_struct *mms); + +int destroy_mqd (struct mqd_manager *mm,void *mqd, +enum kfd_preempt_type type,unsigned int timeout, +uint32_t pipe_id,uint32_t queue_id); + +void free_mqd (struct mqd_manager *mm,void *mqd, +struct kfd_mem_obj *mqd_mem_obj); + +bool is_occupied (struct mqd_manager *mm,void *mqd, +uint64_t queue_address,uint32_t pipe_id, +uint32_t queue_id); + +int load_mqd_sdma (struct mqd_manager *mm,void *mqd, +uint32_t pipe_id,uint32_t queue_id, +struct queue_properties *p,struct mm_struct *mms); + +int destroy_mqd_sdma (struct mqd_manager *mm,void *mqd, +enum kfd_preempt_type type,unsigned int timeout, +uint32_t pipe_id,uint32_t queue_id); + +bool is_occupied_sdma (struct mqd_manager *mm,void *mqd, +uint64_t queue_address,uint32_t pipe_id, +uint32_t queue_id); +#endif /* KFD_MQD_MANAGER_H_ */ (quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.cdrivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static void init_mqd_sdma(struct mqd_manager
Quoted 4 lines
index
96e3303fa27c..81b6b3d5f2e7100644drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-0@@ -156,13 +156,6 @@ static void init_mqd_sdma(struct mqd_manager*mm, void **mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static int load_mqd(struct mqd_manager *mm, void
Quoted 14 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-7mm->update_mqd (mm, m, q,NULL ); } -static void free_mqd (struct mqd_manager *mm,void *mqd, -struct kfd_mem_obj *mqd_mem_obj) -{ -kfd_gtt_sa_free (mm->dev, mqd_mem_obj); -} - -static int load_mqd (struct mqd_manager *mm,void *mqd,uint32_t pipe_id,uint32_t queue_id,struct queue_properties *p,struct mm_struct *mms)@@ -176,15 +169,6 @@ static int load_mqd(struct mqd_manager *mm, void*mqd,
uint32_tpipe_id,Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-1wptr_shift, wptr_mask, mms); } -static int load_mqd_sdma(struct mqd_manager *mm, void *mqd,drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static int load_mqd(struct mqd_manager *mm, void *mqd, uint32_t pipe_id,
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-8- uint32_t pipe_id, uint32_t queue_id, - struct queue_properties *p, struct mm_struct *mms) -{ - return mm->dev->kfd2kgd->hqd_sdma_load(mm->dev->adev, mqd, - (uint32_t __user *)p->write_ptr, - mms); -} -static void __update_mqd (struct mqd_manager *mm,void *mqd, struct queue_properties *q, struct mqd_update_info*minfo,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static void update_mqd_sdma(struct mqd_manager
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-0unsigned int atc_bit)@@ -271,15 +255,6 @@ static void update_mqd_sdma(struct mqd_manager*mm, void *mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static void update_mqd_sdma(struct mqd_manager *mm, void *mqd,
Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-6q->is_active =QUEUE_IS_ACTIVE (*q); } -static int destroy_mqd (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ - return mm->dev->kfd2kgd->hqd_destroy(mm->dev->adev, mqd, type,timeout,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static void update_mqd_sdma(struct mqd_manager *mm, void *mqd,
Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-3- pipe_id, queue_id); -} - static void checkpoint_mqd(struct mqd_manager *mm, void *mqd, void
*mqd_dst, void*ctl_stack_dst)drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static void restore_mqd_sdma(struct mqd_manager
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-0{struct cik_mqd *m;@@ -351,35 +326,6 @@ static void restore_mqd_sdma(struct mqd_manager*mm, void **mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static void restore_mqd_sdma(struct mqd_manager *mm, void **mqd,
Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-10qp->is_active =0 ; } -/* -* preempt type here is ignored because there is only one way -* to preempt sdma queue -*/ -static int destroy_mqd_sdma (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ - return mm->dev->kfd2kgd->hqd_sdma_destroy(mm->dev->adev, mqd,timeout);
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static void restore_mqd_sdma(struct mqd_manager *mm, void **mqd,
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-8-} - -static bool is_occupied (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ - - return mm->dev->kfd2kgd->hqd_is_occupied(mm->dev->adev,
queue_address,drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static void restore_mqd_sdma(struct mqd_manager *mm, void **mqd,
Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-9- pipe_id, queue_id); - -} - -static bool is_occupied_sdma (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ - return mm->dev->kfd2kgd->hqd_sdma_is_occupied(mm->dev->adev,mqd);
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static void restore_mqd_sdma(struct mqd_manager *mm, void **mqd,
Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-2-} -/* * HIQ MQD Implementation, concrete implementation for HIQ MQD implementation.
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c static void restore_mqd_sdma(struct mqd_manager · line 331
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_cik.c +0
-0* The HIQ queue in Kaveri is using the same MQD structure as all the user mode
Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.cdrivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c static int load_mqd(struct mqd_manager *mm, void
Quoted 4 lines
index
0cc8679c24fa..8324757a1cf5100644drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c +0
-0@@ -154,14 +154,6 @@ static int load_mqd(struct mqd_manager *mm, void*mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c static int load_mqd(struct mqd_manager *mm, void *mqd,
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c +0
-5return r; } -static int hiq_load_mqd_kiq (struct mqd_manager *mm,void *mqd, -uint32_t pipe_id,uint32_t queue_id, -struct queue_properties *p,struct mm_struct *mms) -{ - return mm->dev->kfd2kgd->hiq_mqd_load(mm->dev->adev, mqd,
pipe_id,drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c static void init_mqd_sdma(struct mqd_manager
Quoted 39 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c +0
-28- queue_id, p->doorbell_off); -} -static void update_mqd (struct mqd_manager *mm,void *mqd,struct queue_properties *q,struct mqd_update_info *minfo)@@ -233,31 +225,6 @@ static uint32_t read_doorbell_id(void *mqd)return m->queue_doorbell_id0; } -static int destroy_mqd (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_destroy - (mm->dev->adev, mqd, type, timeout, - pipe_id, queue_id); -} - -static void free_mqd (struct mqd_manager *mm,void *mqd, -struct kfd_mem_obj *mqd_mem_obj) -{ -kfd_gtt_sa_free (mm->dev, mqd_mem_obj); -} - -static bool is_occupied (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_is_occupied ( - mm->dev->adev, queue_address, - pipe_id, queue_id); -} - static int get_wave_state(struct mqd_manager *mm, void *mqd, void __user *ctl_stack, u32 *ctl_stack_used_size,@@ -352,15 +319,6 @@ static void init_mqd_sdma(struct mqd_manager*mm, void **mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c static void update_mqd_sdma(struct mqd_manager
Quoted 16 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c +0
-9mm->update_mqd (mm, m, q,NULL ); } -static int load_mqd_sdma (struct mqd_manager *mm,void *mqd, -uint32_t pipe_id,uint32_t queue_id, -struct queue_properties *p,struct mm_struct *mms) -{ -return mm->dev->kfd2kgd->hqd_sdma_load (mm->dev->adev, mqd, - (uint32_t __user *)p->write_ptr, - mms); -} -#define SDMA_RLC_DUMMY_DEFAULT 0xf static void update_mqd_sdma(struct mqd_manager *mm, void *mqd,@@ -390,25 +348,6 @@ static void update_mqd_sdma(struct mqd_manager*mm, void *mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c static void update_mqd_sdma(struct mqd_manager *mm, void *mqd,
Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c +0
-10q->is_active =QUEUE_IS_ACTIVE (*q); } -/* -* * preempt type here is ignored because there is only one way -* * to preempt sdma queue -*/ -static int destroy_mqd_sdma (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ - return mm->dev->kfd2kgd->hqd_sdma_destroy(mm->dev->adev, mqd,timeout);
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c static void update_mqd_sdma(struct mqd_manager · line 409
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c +0
-7-} - -static bool is_occupied_sdma (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ - return mm->dev->kfd2kgd->hqd_sdma_is_occupied(mm->dev->adev,mqd);
Review
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c +0
-2-} - static void checkpoint_mqd_sdma(struct mqd_manager *mm, void *mqd, void *mqd_dst,(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.cdrivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c static int load_mqd(struct mqd_manager *mm, void
Quoted 4 lines
index
87da4329dbf2..007886b2961e100644drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0
-0@@ -204,14 +204,6 @@ static int load_mqd(struct mqd_manager *mm, void*mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c static int load_mqd(struct mqd_manager *mm, void *mqd,
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0
-5wptr_shift, 0, mms); } -static int hiq_load_mqd_kiq (struct mqd_manager *mm,void *mqd, -uint32_t pipe_id,uint32_t queue_id, -struct queue_properties *p,struct mm_struct *mms) -{ - return mm->dev->kfd2kgd->hiq_mqd_load(mm->dev->adev, mqd,
pipe_id,drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c static void init_mqd_sdma(struct mqd_manager
Quoted 47 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0
-35- queue_id, p->doorbell_off); -} -static void update_mqd (struct mqd_manager *mm,void *mqd,struct queue_properties *q,struct mqd_update_info *minfo)@@ -285,38 +277,6 @@ static uint32_t read_doorbell_id(void *mqd)return m->queue_doorbell_id0; } -static int destroy_mqd (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_destroy - (mm->dev->adev, mqd, type, timeout, - pipe_id, queue_id); -} - -static void free_mqd (struct mqd_manager *mm,void *mqd, -struct kfd_mem_obj *mqd_mem_obj) -{ -struct kfd_dev *kfd = mm->dev; - -if (mqd_mem_obj->gtt_mem) { -amdgpu_amdkfd_free_gtt_mem (kfd->adev, mqd_mem_obj- gtt_mem); -kfree (mqd_mem_obj); - }else { -kfd_gtt_sa_free (mm->dev, mqd_mem_obj); - } -} - -static bool is_occupied (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_is_occupied ( - mm->dev->adev, queue_address, - pipe_id, queue_id); -} - static int get_wave_state(struct mqd_manager *mm, void *mqd, void __user *ctl_stack,u32 *ctl_stack_used_size,drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0
-0@@ -422,15 +382,6 @@ static void init_mqd_sdma(struct mqd_manager*mm, void **mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c static void update_mqd_sdma(struct mqd_manager
Quoted 16 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0
-9mm->update_mqd (mm, m, q,NULL ); } -static int load_mqd_sdma (struct mqd_manager *mm,void *mqd, -uint32_t pipe_id,uint32_t queue_id, -struct queue_properties *p,struct mm_struct *mms) -{ -return mm->dev->kfd2kgd->hqd_sdma_load (mm->dev->adev, mqd, - (uint32_t __user *)p->write_ptr, - mms); -} -#define SDMA_RLC_DUMMY_DEFAULT 0xf static void update_mqd_sdma(struct mqd_manager *mm, void *mqd,@@ -460,25 +411,6 @@ static void update_mqd_sdma(struct mqd_manager*mm, void *mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c static void update_mqd_sdma(struct mqd_manager · line 472
Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0
-10q->is_active =QUEUE_IS_ACTIVE (*q); } -/* -* * preempt type here is ignored because there is only one way -* * to preempt sdma queue -*/ -static int destroy_mqd_sdma (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ - return mm->dev->kfd2kgd->hqd_sdma_destroy(mm->dev->adev, mqd,timeout);
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c static void update_mqd_sdma(struct mqd_manager · line 479
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0
-7-} - -static bool is_occupied_sdma (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ - return mm->dev->kfd2kgd->hqd_sdma_is_occupied(mm->dev->adev,mqd);
Review
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +0
-2-} - static void checkpoint_mqd_sdma(struct mqd_manager *mm, void *mqd, void *mqd_dst,(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.cdrivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c static void update_mqd_tonga(struct mqd_manager
Quoted 4 lines
index
137b208135a0..c0405bbe8e36100644drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +0
-0@@ -259,31 +259,6 @@ static void update_mqd_tonga(struct mqd_manager*mm, void *mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c static void init_mqd_sdma(struct mqd_manager
Quoted 32 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +0
-25__update_mqd (mm, mqd, q, minfo,MTYPE_UC ,0 ); } -static int destroy_mqd (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_destroy - (mm->dev->adev, mqd, type, timeout, - pipe_id, queue_id); -} - -static void free_mqd (struct mqd_manager *mm,void *mqd, -struct kfd_mem_obj *mqd_mem_obj) -{ -kfd_gtt_sa_free (mm->dev, mqd_mem_obj); -} - -static bool is_occupied (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ -return mm->dev->kfd2kgd->hqd_is_occupied ( - mm->dev->adev, queue_address, - pipe_id, queue_id); -} - static int get_wave_state(struct mqd_manager *mm, void *mqd, void __user *ctl_stack, u32 *ctl_stack_used_size,@@ -385,15 +360,6 @@ static void init_mqd_sdma(struct mqd_manager*mm, void **mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c static void update_mqd_sdma(struct mqd_manager
Quoted 16 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +0
-9mm->update_mqd (mm, m, q,NULL ); } -static int load_mqd_sdma (struct mqd_manager *mm,void *mqd, -uint32_t pipe_id,uint32_t queue_id, -struct queue_properties *p,struct mm_struct *mms) -{ -return mm->dev->kfd2kgd->hqd_sdma_load (mm->dev->adev, mqd, - (uint32_t __user *)p->write_ptr, - mms); -} -static void update_mqd_sdma (struct mqd_manager *mm,void *mqd,struct queue_properties *q,struct mqd_update_info *minfo)@@ -422,25 +388,6 @@ static void update_mqd_sdma(struct mqd_manager*mm, void *mqd,
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c static void update_mqd_sdma(struct mqd_manager · line 434
Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +0
-10q->is_active =QUEUE_IS_ACTIVE (*q); } -/* -* * preempt type here is ignored because there is only one way -* * to preempt sdma queue -*/ -static int destroy_mqd_sdma (struct mqd_manager *mm,void *mqd, -enum kfd_preempt_type type, -unsigned int timeout,uint32_t pipe_id, -uint32_t queue_id) -{ - return mm->dev->kfd2kgd->hqd_sdma_destroy(mm->dev->adev, mqd,timeout);
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c static void update_mqd_sdma(struct mqd_manager · line 441
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +0
-7-} - -static bool is_occupied_sdma (struct mqd_manager *mm,void *mqd, -uint64_t queue_address,uint32_t pipe_id, -uint32_t queue_id) -{ - return mm->dev->kfd2kgd->hqd_sdma_is_occupied(mm->dev->adev,mqd);
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c +0
-2-} - static void checkpoint_mqd_sdma(struct mqd_manager *mm, void *mqd, void *mqd_dst,
On 2022-02-04 6:45 p.m., Mukul Joshi wrote:
With no HWS, TLB flushing will not work in SVM code. Fix this by calling kfd_flush_tlb() which works for both HWS and no HWS case. Signed-off-by: Mukul Joshi <[email protected]> With below change to remove one extra calling parameter, this patch is
--- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c index 41f03d165bad..b1315c97b952 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c @@ -1229,15 +1229,14 @@ svm_range_unmap_from_gpus(struct svm_range *prange, unsigned long start, if (r) break; } - amdgpu_amdkfd_flush_gpu_tlb_pasid(pdd->dev->adev, - p->pasid, TLB_FLUSH_HEAVYWEIGHT); + kfd_flush_tlb(pdd, TLB_FLUSH_HEAVYWEIGHT); } return r; } static int -svm_range_map_to_gpu(struct amdgpu_device *adev, struct amdgpu_vm *vm, +svm_range_map_to_gpu(struct amdgpu_device *adev, struct kfd_process_device *pdd, svm_range_map_to_gpu(struct kfd_process_device *pdd, struct svm_range *prange,
struct svm_range *prange, unsigned long offset, unsigned long npages, bool readonly, dma_addr_t *dma_addr, struct amdgpu_device *bo_adev, struct dma_fence **fence) @@ -1248,6 +1247,7 @@ svm_range_map_to_gpu(struct amdgpu_device *adev, struct amdgpu_vm *vm, struct amdgpu_vm *vm = drm_priv_to_vm(pdd->drm_priv); struct amdgpu_device adev = pdd->dev->adev; int last_domain; int r = 0; int64_t i, j; + struct amdgpu_vm *vm = drm_priv_to_vm(pdd->drm_priv); last_start = prange->start + offset; @@ -1305,12 +1305,8 @@ svm_range_map_to_gpu(struct amdgpu_device *adev, struct amdgpu_vm *vm, if (fence) *fence = dma_fence_get(vm->last_update); - if (table_freed) { - struct kfd_process *p; - - p = container_of(prange->svms, struct kfd_process, svms); - amdgpu_amdkfd_flush_gpu_tlb_pasid(adev, p->pasid, TLB_FLUSH_LEGACY); - } + if (table_freed) + kfd_flush_tlb(pdd, TLB_FLUSH_LEGACY); out: return r; } @@ -1351,7 +1347,7 @@ svm_range_map_to_gpus(struct svm_range *prange, unsigned long offset, continue; } - r = svm_range_map_to_gpu(pdd->dev->adev, drm_priv_to_vm(pdd->drm_priv), + r = svm_range_map_to_gpu(pdd->dev->adev, pdd, svm_range_map_to_gpu(pdd, prange, offset, npages prange, offset, npages, readonly, prange->dma_addr[gpuidx], bo_adev, wait ? &fence : NULL);