drm/amdkfd: Add bad opcode exception handling
authorAlexey Skidanov <alexey.skidanov@gmail.com>
Tue, 25 Nov 2014 08:34:31 +0000 (10:34 +0200)
committerOded Gabbay <oded.gabbay@gmail.com>
Tue, 19 May 2015 10:02:28 +0000 (13:02 +0300)
Signed-off-by: Alexey Skidanov <alexey.skidanov@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
drivers/gpu/drm/amd/amdkfd/cik_event_interrupt.c
drivers/gpu/drm/amd/amdkfd/cik_int.h
drivers/gpu/drm/amd/amdkfd/kfd_events.c
drivers/gpu/drm/amd/amdkfd/kfd_events.h
drivers/gpu/drm/amd/amdkfd/kfd_priv.h

index 629510ac16bcc04aef9f73b066fd8496122dfef7..211fc48697fa4b2be84e81e31b2e1c9a33fa975c 100644 (file)
@@ -36,7 +36,8 @@ static bool cik_event_interrupt_isr(struct kfd_dev *dev,
        /* Do not process in ISR, just request it to be forwarded to WQ. */
        return (pasid != 0) &&
                (ihre->source_id == CIK_INTSRC_CP_END_OF_PIPE ||
-               ihre->source_id == CIK_INTSRC_SQ_INTERRUPT_MSG);
+               ihre->source_id == CIK_INTSRC_SQ_INTERRUPT_MSG ||
+               ihre->source_id == CIK_INTSRC_CP_BAD_OPCODE);
 }
 
 static void cik_event_interrupt_wq(struct kfd_dev *dev,
@@ -55,6 +56,8 @@ static void cik_event_interrupt_wq(struct kfd_dev *dev,
                kfd_signal_event_interrupt(pasid, 0, 0);
        else if (ihre->source_id == CIK_INTSRC_SQ_INTERRUPT_MSG)
                kfd_signal_event_interrupt(pasid, ihre->data & 0xFF, 8);
+       else if (ihre->source_id == CIK_INTSRC_CP_BAD_OPCODE)
+               kfd_signal_hw_exception_event(pasid);
 }
 
 const struct kfd_event_interrupt_class event_interrupt_class_cik = {
index bbef9e23ab193afa98d8fb9ee49498efebb6988e..79a16d24c1b866cfa0d63d3bea3179a52770a148 100644 (file)
@@ -34,6 +34,7 @@ struct cik_ih_ring_entry {
 
 #define CIK_INTSRC_DEQUEUE_COMPLETE    0xC6
 #define CIK_INTSRC_CP_END_OF_PIPE      0xB5
+#define CIK_INTSRC_CP_BAD_OPCODE       0xB7
 #define CIK_INTSRC_SQ_INTERRUPT_MSG    0xEF
 
 #endif
index fa13d3efc616901a8504f5cf157f10596183d540..5c3a81e667a80ec403ae7734403dec12b423c24c 100644 (file)
@@ -936,3 +936,24 @@ void kfd_signal_iommu_event(struct kfd_dev *dev, unsigned int pasid,
        mutex_unlock(&p->event_mutex);
        mutex_unlock(&p->mutex);
 }
+
+void kfd_signal_hw_exception_event(unsigned int pasid)
+{
+       /*
+        * Because we are called from arbitrary context (workqueue) as opposed
+        * to process context, kfd_process could attempt to exit while we are
+        * running so the lookup function returns a locked process.
+        */
+       struct kfd_process *p = kfd_lookup_process_by_pasid(pasid);
+
+       if (!p)
+               return; /* Presumably process exited. */
+
+       mutex_lock(&p->event_mutex);
+
+       /* Lookup events by type and signal them */
+       lookup_events_by_type_and_signal(p, KFD_EVENT_TYPE_HW_EXCEPTION, NULL);
+
+       mutex_unlock(&p->event_mutex);
+       mutex_unlock(&p->mutex);
+}
index 691cf8573dc1f7a44459d5c11c88ee31c8d0fb26..28f6838b1f4cedb9a19616befd5688d7289c4b8c 100644 (file)
@@ -74,6 +74,7 @@ struct kfd_event {
 
 /* Matching HSA_EVENTTYPE */
 #define KFD_EVENT_TYPE_SIGNAL 0
+#define KFD_EVENT_TYPE_HW_EXCEPTION 3
 #define KFD_EVENT_TYPE_DEBUG 5
 #define KFD_EVENT_TYPE_MEMORY 8
 
index 35945032fff9e90fb1faab51a3bf6632d8644233..9383494b429ed9df391df8227a197ea587ce3d87 100644 (file)
@@ -682,6 +682,7 @@ phys_addr_t kfd_get_process_doorbells(struct kfd_dev *dev,
 
 /* Events */
 extern const struct kfd_event_interrupt_class event_interrupt_class_cik;
+extern const struct kfd_device_global_init_class device_global_init_class_cik;
 
 enum kfd_event_wait_result {
        KFD_WAIT_COMPLETE,
@@ -701,6 +702,7 @@ void kfd_signal_event_interrupt(unsigned int pasid, uint32_t partial_id,
 void kfd_signal_iommu_event(struct kfd_dev *dev,
                unsigned int pasid, unsigned long address,
                bool is_write_requested, bool is_execute_requested);
+void kfd_signal_hw_exception_event(unsigned int pasid);
 int kfd_set_event(struct kfd_process *p, uint32_t event_id);
 int kfd_reset_event(struct kfd_process *p, uint32_t event_id);
 int kfd_event_create(struct file *devkfd, struct kfd_process *p,
This page took 0.031568 seconds and 5 git commands to generate.