<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">Reviewed-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 Guttula, Suresh <Suresh.Guttula@amd.com><br>
<b>Sent:</b> Friday, November 16, 2018 1:50:37 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org<br>
<b>Cc:</b> Sharma, Deepak; Guttula, Suresh; Agrawal, Akshu<br>
<b>Subject:</b> [PATCH v2 3/3] drm/amd:Enable/Disable NBPSTATE on On/OFF of UVD</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">We observe black lines (underflow) on display when playing a<br>
4K video with UVD. On Disabling Low memory P state this issue is<br>
not seen.<br>
In this patch ,disabling low memory P state only when video<br>
size >= 4k.<br>
Multiple runs of power measurement shows no imapct<br>
<br>
Signed-off-by: suresh guttula <suresh.guttula@amd.com><br>
---<br>
v2: Enable/disable low memory pstate logic added to<br>
    amdgpu_dpm_enable_uvd() instead of parser function<br>
 <br>
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c  | 17 +++++++++++++++++<br>
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c |  2 ++<br>
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h |  2 ++<br>
 3 files changed, 21 insertions(+)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c<br>
index 7235cd0..66c0dbd 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c<br>
@@ -33,6 +33,8 @@<br>
 #include <linux/hwmon.h><br>
 #include <linux/hwmon-sysfs.h><br>
 #include <linux/nospec.h><br>
+#include "hwmgr.h"<br>
+#define WIDTH_4K 3840<br>
 <br>
 static int amdgpu_debugfs_pm_init(struct amdgpu_device *adev);<br>
 <br>
@@ -1956,6 +1958,21 @@ void amdgpu_dpm_enable_uvd(struct amdgpu_device *adev, bool enable)<br>
                 amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_UVD, !enable);<br>
                 mutex_unlock(&adev->pm.mutex);<br>
         }<br>
+       /* enable/disable Low Memory PState for UVD (4k videos) */<br>
+       if (adev->asic_type == CHIP_STONEY &&<br>
+               adev->uvd.decode_image_width >= WIDTH_4K) {<br>
+               struct pp_hwmgr *hwmgr;<br>
+               struct pp_instance *pp_handle =<br>
+                       (struct pp_instance *)adev->powerplay.pp_handle;<br>
+               if (pp_handle) {<br>
+                       hwmgr = pp_handle->hwmgr;<br>
+                       if (hwmgr && hwmgr->hwmgr_func &&<br>
+                               hwmgr->hwmgr_func->update_nbdpm_pstate)<br>
+                               hwmgr->hwmgr_func->update_nbdpm_pstate(hwmgr,<br>
+                                                                       !enable,<br>
+                                                                       true);<br>
+               }<br>
+       }<br>
 }<br>
 <br>
 void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable)<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c<br>
index 69896f4..4e5d13e4 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c<br>
@@ -692,6 +692,8 @@ static int amdgpu_uvd_cs_msg_decode(struct amdgpu_device *adev, uint32_t *msg,<br>
         buf_sizes[0x1] = dpb_size;<br>
         buf_sizes[0x2] = image_size;<br>
         buf_sizes[0x4] = min_ctx_size;<br>
+       /* store image width to adjust nb memory pstate */<br>
+       adev->uvd.decode_image_width = width;<br>
         return 0;<br>
 }<br>
 <br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h<br>
index a3ab1a4..5eb6328 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h<br>
@@ -65,6 +65,8 @@ struct amdgpu_uvd {<br>
         struct drm_sched_entity entity;<br>
         struct delayed_work     idle_work;<br>
         unsigned                harvest_config;<br>
+       /* store image width to adjust nb memory state */<br>
+       unsigned                decode_image_width;<br>
 };<br>
 <br>
 int amdgpu_uvd_sw_init(struct amdgpu_device *adev);<br>
-- <br>
2.7.4<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>