<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Arial" size="2"><span style="font-size:10pt;">
<div style="padding-right:5pt;padding-left:5pt;"><font color="blue">[AMD Official Use Only - General]<br>
</font></div>
<div style="margin-top:5pt;"><font face="Times New Roman" size="3"><span style="font-size:12pt;"><br>
</span></font></div>
<a name="_MailEndCompose"></a>
<div><font face="DengXian" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="DengXian" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="DengXian" size="2"><span style="font-size:11pt;">-----------------</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">Best Regards,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">Thomas</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="DengXian" size="2"><span style="font-size:11pt;">_____________________________________________<br>
<b>From:</b> Zhang, Hawking <Hawking.Zhang@amd.com> <br>
<b>Sent:</b> Wednesday, January 17, 2024 7:54 PM<br>
<b>To:</b> Chai, Thomas <YiPeng.Chai@amd.com>; amd-gfx@lists.freedesktop.org<br>
<b>Cc:</b> Zhou1, Tao <Tao.Zhou1@amd.com>; Li, Candice <Candice.Li@amd.com>; Wang, Yang(Kevin) <KevinYang.Wang@amd.com>; Yang, Stanley <Stanley.Yang@amd.com><br>
<b>Subject:</b> RE: [PATCH 3/5] drm/amdgpu: Use asynchronous polling to handle umc_v12_0 poisoning</span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div style="padding-right:5pt;padding-left:5pt;"><font face="Arial" color="blue">[AMD Official Use Only - General]<br>
</font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"><br>
</span></font></div>
<div><font face="Calibri" size="2" color="#2F5496"><span style="font-size:11pt;">Please check my comments inline</span></font></div>
<div><font face="Calibri" size="2" color="#2F5496"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2" color="#2F5496"><span style="font-size:11pt;">Regards,<br>
Hawking</span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">-----Original Message-----<br>
From: Chai, Thomas <<a href="mailto:YiPeng.Chai@amd.com"><font color="#0563C1"><u>YiPeng.Chai@amd.com</u></font></a>>
<br>
Sent: Tuesday, January 16, 2024 16:21<br>
To: <a href="mailto:amd-gfx@lists.freedesktop.org"><font color="#0563C1"><u>amd-gfx@lists.freedesktop.org</u></font></a><br>
Cc: Chai, Thomas <<a href="mailto:YiPeng.Chai@amd.com"><font color="#0563C1"><u>YiPeng.Chai@amd.com</u></font></a>>; Zhang, Hawking <<a href="mailto:Hawking.Zhang@amd.com"><font color="#0563C1"><u>Hawking.Zhang@amd.com</u></font></a>>; Zhou1, Tao <<a href="mailto:Tao.Zhou1@amd.com"><font color="#0563C1"><u>Tao.Zhou1@amd.com</u></font></a>>;
Li, Candice <<a href="mailto:Candice.Li@amd.com"><font color="#0563C1"><u>Candice.Li@amd.com</u></font></a>>; Wang, Yang(Kevin) <<a href="mailto:KevinYang.Wang@amd.com"><font color="#0563C1"><u>KevinYang.Wang@amd.com</u></font></a>>; Yang, Stanley <<a href="mailto:Stanley.Yang@amd.com"><font color="#0563C1"><u>Stanley.Yang@amd.com</u></font></a>>;
Chai, Thomas <<a href="mailto:YiPeng.Chai@amd.com"><font color="#0563C1"><u>YiPeng.Chai@amd.com</u></font></a>><br>
Subject: [PATCH 3/5] drm/amdgpu: Use asynchronous polling to handle umc_v12_0 poisoning</span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">Use asynchronous polling to handle umc_v12_0 poisoning.</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">Signed-off-by: YiPeng Chai <<a href="mailto:YiPeng.Chai@amd.com">YiPeng.Chai@amd.com</a>></span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">---</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 5 +</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c | 143 +++++++++++++++++++-----</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h | 3 +</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> 3 files changed, 120 insertions(+), 31 deletions(-)</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">index 856206e95842..44929281840e 100644</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">@@ -118,6 +118,8 @@ const char *get_ras_block_str(struct ras_common_if *ras_block)</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> /* typical ECC bad page rate is 1 bad page per 100MB VRAM */</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> #define RAS_BAD_PAGE_COVER (100 * 1024 * 1024ULL)</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+#define MAX_UMC_POISON_POLLING_TIME_ASYNC 100 //ms</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> enum amdgpu_ras_retire_page_reservation {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> AMDGPU_RAS_RETIRE_PAGE_RESERVED,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> AMDGPU_RAS_RETIRE_PAGE_PENDING,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">@@ -2670,6 +2672,9 @@ static int amdgpu_ras_page_retirement_thread(void *param)</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> atomic_read(&con->page_retirement_req_cnt));</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> atomic_dec(&con->page_retirement_req_cnt);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ amdgpu_umc_poison_retire_page_polling_timeout(adev,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ false, MAX_UMC_POISON_POLLING_TIME_ASYNC);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> }</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> return 0;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">index 9d1cf41cf483..2dde29cb807d 100644</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">@@ -23,6 +23,7 @@</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> #include "amdgpu.h"</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> #include "umc_v6_7.h"</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+#define MAX_UMC_POISON_POLLING_TIME_SYNC 20 //ms</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> static int amdgpu_umc_convert_error_address(struct amdgpu_device *adev,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> struct ras_err_data *err_data, uint64_t err_addr, @@ -85,17 +86,14 @@ int amdgpu_umc_page_retirement_mca(struct amdgpu_device *adev,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> return ret;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> }</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">-static int amdgpu_umc_do_page_retirement(struct amdgpu_device *adev,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- void *ras_error_status,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- struct amdgpu_iv_entry *entry,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- bool reset)</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+static void amdgpu_umc_handle_bad_pages(struct amdgpu_device *adev,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ void *ras_error_status)</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> struct amdgpu_ras *con = amdgpu_ras_get_context(adev);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> int ret = 0;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> unsigned long err_count;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">-</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- kgd2kfd_set_sram_ecc_flag(adev->kfd.dev);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ mutex_lock(&con->page_retirement_lock);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> ret = amdgpu_dpm_get_ecc_info(adev, (void *)&(con->umc_ecc));</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> if (ret == -EOPNOTSUPP) {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> if (adev->umc.ras && adev->umc.ras->ras_block.hw_ops && @@ -163,19 +161,86 @@ static int amdgpu_umc_do_page_retirement(struct amdgpu_device *adev,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> con->update_channel_flag = false;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> }</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> }</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">-</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- if (reset) {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- /* use mode-2 reset for poison consumption */</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- if (!entry)</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- con->gpu_reset_flags |= AMDGPU_RAS_GPU_RESET_MODE2_RESET;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- amdgpu_ras_reset_gpu(adev);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- }</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> }</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> kfree(err_data->err_addr);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ mutex_unlock(&con->page_retirement_lock);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+}</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+static int amdgpu_umc_do_page_retirement(struct amdgpu_device *adev,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ void *ras_error_status,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ struct amdgpu_iv_entry *entry,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ bool reset)</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+{</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ struct amdgpu_ras *con = amdgpu_ras_get_context(adev);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ kgd2kfd_set_sram_ecc_flag(adev->kfd.dev);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ amdgpu_umc_handle_bad_pages(adev, ras_error_status);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ if (err_data->ue_count && reset) {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ /* use mode-2 reset for poison consumption */</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ if (!entry)</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ con->gpu_reset_flags |= AMDGPU_RAS_GPU_RESET_MODE2_RESET;</span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">><font color="#2F5496">[Hawking]: Shall we do further check on con->poison_supported flag to decide issuing mode-2 or mode-1.</font></span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">[thomas] This “gpu reset” code is not belong to page retirement range, but reuse old code. About how to reset gpu<font face="DengXian">,</font> we can do it with another patch in future.</span></font></div>
<div><font face="Times New Roman" size="2" color="#2F5496"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ amdgpu_ras_reset_gpu(adev);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ }</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> return AMDGPU_RAS_SUCCESS;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> }</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+int amdgpu_umc_poison_retire_page_polling_timeout(struct amdgpu_device *adev,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ bool reset, uint32_t timeout_ms)</span></font></div>
<div><font face="Calibri" size="2" color="#2F5496"><span style="font-size:11pt;">[Hawking] int amdgpu_umc_bad_page_polling_timeout(struct amdgpu_device *adev, boot reset, uint32_t timeout_ms)</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">[thomas] OK</span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+{</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ struct ras_err_data err_data;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ struct ras_common_if head = {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ .block = AMDGPU_RAS_BLOCK__UMC,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ };</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ struct ras_manager *obj = amdgpu_ras_find_obj(adev, &head);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ uint32_t timeout = timeout_ms;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ memset(&err_data, 0, sizeof(err_data));</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ amdgpu_ras_error_data_init(&err_data);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ do {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ amdgpu_umc_handle_bad_pages(adev, &err_data);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ if (timeout && !err_data.de_count) {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ msleep(1);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ timeout--;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ }</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ } while (timeout && !err_data.de_count);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ if (!timeout)</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ dev_warn(adev->dev, "Page retirment executed, but did not find bad </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+pages\n");</span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2" color="#2F5496"><span style="font-size:11pt;">[Hawking] dev_warn (adev->dev, “can’t find bad pages\n”);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">[thomas] OK</span></font></div>
<div><font face="Times New Roman" size="2" color="#2F5496"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ if (err_data.de_count)</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ dev_info(adev->dev, "Page retirment: ue:%ld, ce:%ld, de:%ld\n",</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ err_data.ue_count, err_data.ce_count, err_data.de_count);</span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2" color="#2F5496"><span style="font-size:11pt;">[Hawking] dev_info(adev->dev, “%ld new deferred hardware errors detected\n”, err_data.de_count)</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">[thomas] OK</span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ if (obj) {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ obj->err_data.ue_count += err_data.ue_count;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ obj->err_data.ce_count += err_data.ce_count;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ obj->err_data.de_count += err_data.de_count;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ }</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ amdgpu_ras_error_data_fini(&err_data);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ kgd2kfd_set_sram_ecc_flag(adev->kfd.dev);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ if (reset) {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ struct amdgpu_ras *con = amdgpu_ras_get_context(adev);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ /* use mode-2 reset for poison consumption */</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ con->gpu_reset_flags |= AMDGPU_RAS_GPU_RESET_MODE2_RESET;</span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2" color="#2F5496"><span style="font-size:11pt;">[Hawking]: Shall we do further check on con->poison_supported flag to decide issuing mode-2 or mode-1.</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">[thomas] This “gpu reset” code is not belong to page retirement range<font face="DengXian">,</font> but reuse old code. About how to reset gpu<font face="DengXian">,</font> we can do it with
another patch in future.</span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ amdgpu_ras_reset_gpu(adev);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ }</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ return 0;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+}</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> int amdgpu_umc_poison_handler(struct amdgpu_device *adev, bool reset) {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> int ret = AMDGPU_RAS_SUCCESS;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">@@ -193,25 +258,41 @@ int amdgpu_umc_poison_handler(struct amdgpu_device *adev, bool reset)</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> }</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> if (!amdgpu_sriov_vf(adev)) {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- struct ras_err_data err_data;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- struct ras_common_if head = {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- .block = AMDGPU_RAS_BLOCK__UMC,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- };</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- struct ras_manager *obj = amdgpu_ras_find_obj(adev, &head);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">-</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- ret = amdgpu_ras_error_data_init(&err_data);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- if (ret)</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- return ret;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">-</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- ret = amdgpu_umc_do_page_retirement(adev, &err_data, NULL, reset);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">-</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- if (ret == AMDGPU_RAS_SUCCESS && obj) {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- obj->err_data.ue_count += err_data.ue_count;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- obj->err_data.ce_count += err_data.ce_count;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- obj->err_data.de_count += err_data.de_count;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- }</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ if (amdgpu_ip_version(adev, UMC_HWIP, 0) != IP_VERSION(12, 0, 0)) {</span></font></div>
<div><font face="Calibri" size="2" color="#2F5496"><span style="font-size:11pt;">[Hawking]: if (amdgpu_ip_version(adev, UMC_HWIP, 0) < IP_VERSION(12, 0, 0)) {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">[thomas] OK</span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ struct ras_err_data err_data;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ struct ras_common_if head = {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ .block = AMDGPU_RAS_BLOCK__UMC,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ };</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ struct ras_manager *obj = amdgpu_ras_find_obj(adev, &head);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ ret = amdgpu_ras_error_data_init(&err_data);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ if (ret)</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ return ret;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ ret = amdgpu_umc_do_page_retirement(adev, &err_data, NULL, reset);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">- amdgpu_ras_error_data_fini(&err_data);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ if (ret == AMDGPU_RAS_SUCCESS && obj) {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ obj->err_data.ue_count += err_data.ue_count;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ obj->err_data.ce_count += err_data.ce_count;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ obj->err_data.de_count += err_data.de_count;</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ }</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ amdgpu_ras_error_data_fini(&err_data);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ } else {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ if (reset) {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ amdgpu_umc_poison_retire_page_polling_timeout(adev,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ reset, MAX_UMC_POISON_POLLING_TIME_SYNC);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ } else {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ struct amdgpu_ras *con = amdgpu_ras_get_context(adev);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ dev_info(adev->dev, "Page retirement pending request count: %d\n",</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ atomic_read(&con->page_retirement_req_cnt));</span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2" color="#2F5496"><span style="font-size:11pt;">[Hawking]: might remove the printed message here.</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">[thomas] OK</span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ atomic_inc(&con->page_retirement_req_cnt);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ wake_up(&con->page_retirement_wq);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ }</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ }</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> } else {</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> if (adev->virt.ops && adev->virt.ops->ras_poison_handler)</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> adev->virt.ops->ras_poison_handler(adev);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">index 417a6726c71b..ee487adce7e4 100644</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">@@ -118,4 +118,7 @@ int amdgpu_umc_page_retirement_mca(struct amdgpu_device *adev,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> int amdgpu_umc_loop_channels(struct amdgpu_device *adev,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> umc_func func, void *data);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+int amdgpu_umc_poison_retire_page_polling_timeout(struct amdgpu_device *adev,</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">+ bool reset, uint32_t timeout_ms);</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;"> #endif</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">--</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">2.34.1</span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
</span></font>
</body>
</html>