<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Series is:</p>
<p style="margin-top:0;margin-bottom:0">Acked-by: Alex Deucher <alexander.deucher@amd.com><br>
</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Rex Zhu <Rex.Zhu@amd.com><br>
<b>Sent:</b> Thursday, September 20, 2018 6:07:28 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org; Zhou, Hang<br>
<b>Cc:</b> Zhu, Rex<br>
<b>Subject:</b> [PATCH 1/4] drm/amdgpu: Halt rlc/cp in rlc_safe_mode</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">before halt rlc/cp, need to<br>
1. enter rlc safe mode<br>
2. wait rlc/cp idle<br>
<br>
Signed-off-by: Hang Zhou <hang.zhou@amd.com><br>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com><br>
---<br>
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 86 ++++++++++++++++++++++++-----------<br>
1 file changed, 59 insertions(+), 27 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c<br>
index 05b5bba..93d7fe5 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c<br>
@@ -5080,6 +5080,55 @@ static int gfx_v8_0_kcq_disable(struct amdgpu_device *adev)<br>
return r;<br>
}<br>
<br>
+static bool gfx_v8_0_is_idle(void *handle)<br>
+{<br>
+ struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
+<br>
+ if (REG_GET_FIELD(RREG32(mmGRBM_STATUS), GRBM_STATUS, GUI_ACTIVE)<br>
+ || RREG32(mmGRBM_STATUS2) != 0x8)<br>
+ return false;<br>
+ else<br>
+ return true;<br>
+}<br>
+<br>
+static bool gfx_v8_0_rlc_is_idle(void *handle)<br>
+{<br>
+ struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
+<br>
+ if (RREG32(mmGRBM_STATUS2) != 0x8)<br>
+ return false;<br>
+ else<br>
+ return true;<br>
+}<br>
+<br>
+static int gfx_v8_0_wait_for_rlc_idle(void *handle)<br>
+{<br>
+ unsigned int i;<br>
+ struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
+<br>
+ for (i = 0; i < adev->usec_timeout; i++) {<br>
+ if (gfx_v8_0_rlc_is_idle(handle))<br>
+ return 0;<br>
+<br>
+ udelay(1);<br>
+ }<br>
+ return -ETIMEDOUT;<br>
+}<br>
+<br>
+static int gfx_v8_0_wait_for_idle(void *handle)<br>
+{<br>
+ unsigned int i;<br>
+ struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
+<br>
+ for (i = 0; i < adev->usec_timeout; i++) {<br>
+ if (gfx_v8_0_is_idle(handle))<br>
+ return 0;<br>
+<br>
+ udelay(1);<br>
+ }<br>
+ return -ETIMEDOUT;<br>
+}<br>
+<br>
static int gfx_v8_0_hw_fini(void *handle)<br>
{<br>
struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
@@ -5098,9 +5147,16 @@ static int gfx_v8_0_hw_fini(void *handle)<br>
pr_debug("For SRIOV client, shouldn't do anything.\n");<br>
return 0;<br>
}<br>
- gfx_v8_0_cp_enable(adev, false);<br>
- gfx_v8_0_rlc_stop(adev);<br>
-<br>
+ adev->gfx.rlc.funcs->enter_safe_mode(adev);<br>
+ if (!gfx_v8_0_wait_for_idle(adev))<br>
+ gfx_v8_0_cp_enable(adev, false);<br>
+ else<br>
+ pr_err("cp is busy, skip halt cp\n");<br>
+ if (!gfx_v8_0_wait_for_rlc_idle(adev))<br>
+ gfx_v8_0_rlc_stop(adev);<br>
+ else<br>
+ pr_err("rlc is busy, skip halt rlc\n");<br>
+ adev->gfx.rlc.funcs->exit_safe_mode(adev);<br>
return 0;<br>
}<br>
<br>
@@ -5121,30 +5177,6 @@ static int gfx_v8_0_resume(void *handle)<br>
return r;<br>
}<br>
<br>
-static bool gfx_v8_0_is_idle(void *handle)<br>
-{<br>
- struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
-<br>
- if (REG_GET_FIELD(RREG32(mmGRBM_STATUS), GRBM_STATUS, GUI_ACTIVE))<br>
- return false;<br>
- else<br>
- return true;<br>
-}<br>
-<br>
-static int gfx_v8_0_wait_for_idle(void *handle)<br>
-{<br>
- unsigned i;<br>
- struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
-<br>
- for (i = 0; i < adev->usec_timeout; i++) {<br>
- if (gfx_v8_0_is_idle(handle))<br>
- return 0;<br>
-<br>
- udelay(1);<br>
- }<br>
- return -ETIMEDOUT;<br>
-}<br>
-<br>
static bool gfx_v8_0_check_soft_reset(void *handle)<br>
{<br>
struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
-- <br>
1.9.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
</div>
</span></font></div>
</body>
</html>