<div dir="auto"><div>Hi, see inline comment below.<br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Den tis 25 aug. 2020 21:12Mukul Joshi <<a href="mailto:mukul.joshi@amd.com">mukul.joshi@amd.com</a>> skrev:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Add support for reporting GPU reset events through SMI. KFD<br>
would report both pre and post GPU reset events.<br>
<br>
Signed-off-by: Mukul Joshi <<a href="mailto:mukul.joshi@amd.com" target="_blank" rel="noreferrer">mukul.joshi@amd.com</a>><br>
---<br>
 drivers/gpu/drm/amd/amdkfd/kfd_device.c     |  4 +++<br>
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h       |  2 ++<br>
 drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c | 30 +++++++++++++++++++++<br>
 drivers/gpu/drm/amd/amdkfd/kfd_smi_events.h |  1 +<br>
 include/uapi/linux/kfd_ioctl.h              |  2 ++<br>
 5 files changed, 39 insertions(+)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c<br>
index e1cd6599529f..aad1ecfa1239 100644<br>
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c<br>
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c<br>
@@ -812,6 +812,8 @@ int kgd2kfd_pre_reset(struct kfd_dev *kfd)<br>
        if (!kfd->init_complete)<br>
                return 0;<br>
<br>
+       kfd_smi_event_update_gpu_reset(kfd, false);<br>
+<br>
        kfd->dqm->ops.pre_reset(kfd->dqm);<br>
<br>
        kgd2kfd_suspend(kfd, false);<br>
@@ -833,6 +835,8 @@ int kgd2kfd_post_reset(struct kfd_dev *kfd)<br>
        if (!kfd->init_complete)<br>
                return 0;<br>
<br>
+       kfd_smi_event_update_gpu_reset(kfd, true);<br>
+<br>
        ret = kfd_resume(kfd);<br>
        if (ret)<br>
                return ret;<br>
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h<br>
index 18bc711f97ae..b1a2979e086f 100644<br>
--- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h<br>
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h<br>
@@ -312,6 +312,8 @@ struct kfd_dev {<br>
        /* Clients watching SMI events */<br>
        struct list_head smi_clients;<br>
        spinlock_t smi_lock;<br>
+<br>
+       uint64_t reset_seq_num;<br>
 };<br>
<br>
 enum kfd_mempool {<br>
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c b/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c<br>
index 4d4b6e3ab697..448abfdde230 100644<br>
--- a/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c<br>
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c<br>
@@ -174,6 +174,36 @@ static void add_event_to_kfifo(struct kfd_dev *dev, unsigned int smi_event,<br>
        rcu_read_unlock();<br>
 }<br>
<br>
+void kfd_smi_event_update_gpu_reset(struct kfd_dev *dev, bool post_reset)<br>
+{<br>
+       /*<br>
+        * GpuReset msg = Reset seq number (incremented for<br>
+        * every reset message sent before GPU reset).<br>
+        * 1 byte event + 1 byte space + 16 bytes seq num +<br>
+        * 1 byte \n + 1 byte \0 = 20<br>
+        */<br>
+       char fifo_in[20];<br>
+       int len;<br>
+       unsigned int event;<br>
+<br>
+       if (list_empty(&dev->smi_clients)) {<br>
+               return;<br>
+       }<br>
+<br>
+       memset(fifo_in, 0x0, sizeof(fifo_in));<br>
+<br>
+       if (post_reset) {<br>
+               event = KFD_SMI_EVENT_GPU_POST_RESET;<br>
+       } else {<br>
+               event = KFD_SMI_EVENT_GPU_PRE_RESET;<br>
+               ++(dev->reset_seq_num);<br>
+       }<br>
+<br>
+       len = snprintf(fifo_in, 4, "%x %llx\n", event, dev->reset_seq_num);<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">I think the 4 will cause truncation of the message here.</div><div dir="auto"><br></div><div dir="auto">Regards</div><div dir="auto">Nils</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+       add_event_to_kfifo(dev, event, fifo_in, len);<br>
+}<br>
+<br>
 void kfd_smi_event_update_thermal_throttling(struct kfd_dev *dev,<br>
                                             uint32_t throttle_bitmask)<br>
 {<br>
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.h b/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.h<br>
index 15537b2cccb5..b9b0438202e2 100644<br>
--- a/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.h<br>
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.h<br>
@@ -27,5 +27,6 @@ int kfd_smi_event_open(struct kfd_dev *dev, uint32_t *fd);<br>
 void kfd_smi_event_update_vmfault(struct kfd_dev *dev, uint16_t pasid);<br>
 void kfd_smi_event_update_thermal_throttling(struct kfd_dev *dev,<br>
                                             uint32_t throttle_bitmask);<br>
+void kfd_smi_event_update_gpu_reset(struct kfd_dev *dev, bool post_reset);<br>
<br>
 #endif<br>
diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h<br>
index cb1f963a84e0..8b7368bfbd84 100644<br>
--- a/include/uapi/linux/kfd_ioctl.h<br>
+++ b/include/uapi/linux/kfd_ioctl.h<br>
@@ -453,6 +453,8 @@ enum kfd_smi_event {<br>
         KFD_SMI_EVENT_NONE = 0, /* not used */<br>
         KFD_SMI_EVENT_VMFAULT = 1, /* event start counting at 1 */<br>
         KFD_SMI_EVENT_THERMAL_THROTTLE = 2,<br>
+       KFD_SMI_EVENT_GPU_PRE_RESET = 3,<br>
+       KFD_SMI_EVENT_GPU_POST_RESET = 4,<br>
 };<br>
<br>
 #define KFD_SMI_EVENT_MASK_FROM_INDEX(i) (1ULL << ((i) - 1))<br>
-- <br>
2.17.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
<a href="mailto:amd-gfx@lists.freedesktop.org" target="_blank" rel="noreferrer">amd-gfx@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" rel="noreferrer noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
</blockquote></div></div></div>