drm/amdkfd: add debug set exceptions enabled operation
authorJonathan Kim <jonathan.kim@amd.com>
Wed, 27 Apr 2022 14:24:37 +0000 (10:24 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 9 Jun 2023 16:36:21 +0000 (12:36 -0400)
The debugger subscibes to nofication for requested exceptions on attach.
Allow the debugger to change its subsciption later on.

Signed-off-by: Jonathan Kim <jonathan.kim@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
drivers/gpu/drm/amd/amdkfd/kfd_debug.c
drivers/gpu/drm/amd/amdkfd/kfd_debug.h

index 615fa9ab36b7eff32873552571e67bbb9f447792..dcf4b5f3886e3c1d80b08632ee480678be03f144 100644 (file)
@@ -2980,6 +2980,9 @@ static int kfd_ioctl_set_debug_trap(struct file *filep, struct kfd_process *p, v
                                args->send_runtime_event.exception_mask);
                break;
        case KFD_IOC_DBG_TRAP_SET_EXCEPTIONS_ENABLED:
+               kfd_dbg_set_enabled_debug_exception_mask(target,
+                               args->set_exceptions_enabled.exception_mask);
+               break;
        case KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_OVERRIDE:
        case KFD_IOC_DBG_TRAP_SET_WAVE_LAUNCH_MODE:
        case KFD_IOC_DBG_TRAP_SUSPEND_QUEUES:
index 68b657398d417f6e032ab739833f04b89e6b9de8..48a4e3cc2234374ee43a4904f506a6b091156d01 100644 (file)
@@ -521,3 +521,39 @@ int kfd_dbg_trap_enable(struct kfd_process *target, uint32_t fd,
 
        return r;
 }
+
+void kfd_dbg_set_enabled_debug_exception_mask(struct kfd_process *target,
+                                       uint64_t exception_set_mask)
+{
+       uint64_t found_mask = 0;
+       struct process_queue_manager *pqm;
+       struct process_queue_node *pqn;
+       static const char write_data = '.';
+       loff_t pos = 0;
+       int i;
+
+       mutex_lock(&target->event_mutex);
+
+       found_mask |= target->exception_status;
+
+       pqm = &target->pqm;
+       list_for_each_entry(pqn, &pqm->queues, process_queue_list) {
+               if (!pqn)
+                       continue;
+
+               found_mask |= pqn->q->properties.exception_status;
+       }
+
+       for (i = 0; i < target->n_pdds; i++) {
+               struct kfd_process_device *pdd = target->pdds[i];
+
+               found_mask |= pdd->exception_status;
+       }
+
+       if (exception_set_mask & found_mask)
+               kernel_write(target->dbg_ev_file, &write_data, 1, &pos);
+
+       target->exception_enable_mask = exception_set_mask;
+
+       mutex_unlock(&target->event_mutex);
+}
index 5153ccbd7fd17532d2bb4201171889fd3bbc97a3..6c1054a08872394283e3fbcbd432229e2ca8bac5 100644 (file)
@@ -56,6 +56,8 @@ static inline bool kfd_dbg_is_per_vmid_supported(struct kfd_node *dev)
 
 void debug_event_write_work_handler(struct work_struct *work);
 
+void kfd_dbg_set_enabled_debug_exception_mask(struct kfd_process *target,
+                                       uint64_t exception_set_mask);
 /*
  * If GFX off is enabled, chips that do not support RLC restore for the debug
  * registers will disable GFX off temporarily for the entire debug session.