<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
p.msipheadera92e061b, li.msipheadera92e061b, div.msipheadera92e061b
{mso-style-name:msipheadera92e061b;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="msipheadera92e061b" style="margin:0in"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#0078D7">[AMD Official Use Only - Internal Distribution Only]</span><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Sorry I missed that. Thanks for pointing it out.<o:p></o:p></p>
<p class="MsoNormal">I will send out an updated patch.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal">Mukul<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Nils Wallménius <nils.wallmenius@gmail.com> <br>
<b>Sent:</b> Wednesday, August 26, 2020 4:30 AM<br>
<b>To:</b> Joshi, Mukul <Mukul.Joshi@amd.com><br>
<b>Cc:</b> amd-gfx@lists.freedesktop.org; Kuehling, Felix <Felix.Kuehling@amd.com><br>
<b>Subject:</b> Re: [PATCH] drm/amdkfd: Add GPU reset SMI event<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">[CAUTION: External Email] <o:p></o:p></p>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hi, see inline comment below.<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal">Den tis 25 aug. 2020 21:12Mukul Joshi <<a href="mailto:mukul.joshi@amd.com">mukul.joshi@amd.com</a>> skrev:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<p class="MsoNormal">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">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);<o:p></o:p></p>
</blockquote>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I think the 4 will cause truncation of the message here.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Regards<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Nils<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<p class="MsoNormal">+<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">amd-gfx@lists.freedesktop.org</a><br>
<a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Cmukul.joshi%40amd.com%7Cf1f1b5a522714387b43808d8499a2fd6%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637340273862855741&sdata=S9Ch%2BXajhfEnZ7pn2DV%2F1Pb9%2FCSZfujBkxIw9INjvEg%3D&reserved=0" target="_blank">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</body>
</html>