<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"><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">- if (!amdgpu_dpm_set_powergating_by_smu(adev,
AMD_IP_BLOCK_TYPE_GFX, true))</span><br style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">
<span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">- adev->gfx.bin_off = true;</span><br style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">
<span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">+ schedule_delayed_work(&adev->gfx.delay_gfx_off_enable, GFX_OFF_DELAY_ENABLE);</span><br style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">
<span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;"> } else if (!enable && adev->gfx.bin_off) {</span><br style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">
<span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;"> if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, false))</span><br style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">
<span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;"> adev->gfx.bin_off = false;</span><br>
</p>
<p style="margin-top:0;margin-bottom:0"><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;"><br>
</span></p>
<p style="margin-top:0;margin-bottom:0"><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size: 14.6667px;">I think for disable gfxoff case, you need to use cancle_delayed_work_sync(<span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">(&adev->gfx.delay_gfx_off_enable).
E.g.</span></span></font></p>
<p style="margin-top:0;margin-bottom:0"><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size: 14.6667px;"><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;"><br>
</span></span></font></p>
<p style="margin-top:0;margin-bottom:0"><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size: 14.6667px;"><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">if
(!<span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">cancle_delayed_work_sync(</span><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">(&adev->gfx.delay_gfx_off_enable)
&& <span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, false)</span>)</span></span></span></font></p>
<p style="margin-top:0;margin-bottom:0"><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size: 14.6667px;"><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;"><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;"><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">
adev->gfx.bin_off = false;</span></span></span></span></font></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size: 14.6667px;"><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;"><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;"><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">Regards,</span></span></span></span></font></p>
<p style="margin-top:0;margin-bottom:0"><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size: 14.6667px;"><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;"><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;"><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">Evan</span></span></span></span></font></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> Sunday, July 29, 2018 7:35:48 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org<br>
<b>Cc:</b> Zhu, Rex<br>
<b>Subject:</b> [PATCH 2/4] drm/amdgpu: Put enable gfx off feature to a delay thread</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">delay to enable gfx off feature to avoid gfx on/off frequently<br>
<br>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 +<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 ++++++++++++++++<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 6 ++++--<br>
3 files changed, 21 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
index 318961d..b59ac02 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
@@ -993,6 +993,7 @@ struct amdgpu_gfx {<br>
bool bin_off;<br>
struct mutex gfx_off_ctrl_mutex;<br>
uint32_t disable_gfx_off_request;<br>
+ struct delayed_work delay_gfx_off_enable;<br>
/* pipe reservation */<br>
struct mutex pipe_reserve_mutex;<br>
DECLARE_BITMAP (pipe_reserve_bitmap, AMDGPU_MAX_COMPUTE_QUEUES);<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
index b40ce6f..9f8e267 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
@@ -1925,6 +1925,20 @@ static void amdgpu_device_ip_late_init_func_handler(struct work_struct *work)<br>
DRM_ERROR("ib ring test failed (%d).\n", r);<br>
}<br>
<br>
+static void amdgpu_device_delay_enable_gfx_off(struct work_struct *work)<br>
+{<br>
+ struct amdgpu_device *adev =<br>
+ container_of(work, struct amdgpu_device, gfx.delay_gfx_off_enable.work);<br>
+<br>
+ mutex_lock(&adev->gfx.gfx_off_ctrl_mutex);<br>
+ if (adev->gfx.bready_for_off && !adev->gfx.bin_off<br>
+ && adev->gfx.disable_gfx_off_request) {<br>
+ if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, true))<br>
+ adev->gfx.bin_off = true;<br>
+ }<br>
+ mutex_unlock(&adev->gfx.gfx_off_ctrl_mutex);<br>
+}<br>
+<br>
/**<br>
* amdgpu_device_ip_suspend_phase1 - run suspend for hardware IPs (phase 1)<br>
*<br>
@@ -2394,6 +2408,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,<br>
<br>
INIT_DELAYED_WORK(&adev->late_init_work,<br>
amdgpu_device_ip_late_init_func_handler);<br>
+ INIT_DELAYED_WORK(&adev->gfx.delay_gfx_off_enable,<br>
+ amdgpu_device_delay_enable_gfx_off);<br>
<br>
adev->pm.ac_power = power_supply_is_system_supplied() > 0 ? true : false;<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c<br>
index 68fe9c8..1ea1e8b 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c<br>
@@ -26,6 +26,9 @@<br>
#include "amdgpu.h"<br>
#include "amdgpu_gfx.h"<br>
<br>
+/* 0.5 second timeout */<br>
+#define GFX_OFF_DELAY_ENABLE msecs_to_jiffies(500)<br>
+<br>
/*<br>
* GPU scratch registers helpers function.<br>
*/<br>
@@ -384,8 +387,7 @@ void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, enum amd_ip_block_type clie<br>
*/<br>
if (adev->gfx.bready_for_off && !adev->gfx.bin_off<br>
&& !adev->gfx.disable_gfx_off_request) {<br>
- if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, true))<br>
- adev->gfx.bin_off = true;<br>
+ schedule_delayed_work(&adev->gfx.delay_gfx_off_enable, GFX_OFF_DELAY_ENABLE);<br>
} else if (!enable && adev->gfx.bin_off) {<br>
if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, false))<br>
adev->gfx.bin_off = false;<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>