<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><span>Reviewed-by:</span> Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com></span><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 Jerry (Fangzhi) Zuo <Jerry.Zuo@amd.com><br>
<b>Sent:</b> November 27, 2018 1:45:54 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org; Wentland, Harry; Lakha, Bhawanpreet<br>
<b>Cc:</b> Zuo, Jerry<br>
<b>Subject:</b> [PATCH] drm/amd/display: Fix NULL ptr when calculating refresh rate</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Calculate preferred refresh rate only when preferred mode exists.<br>
<br>
Signed-off-by: Jerry (Fangzhi) Zuo <Jerry.Zuo@amd.com><br>
---<br>
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 ++---<br>
 1 file changed, 2 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
index 27df3ae945be..3039faf004a8 100644<br>
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
@@ -2835,7 +2835,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,<br>
         bool native_mode_found = false;<br>
         bool scale = dm_state ? (dm_state->scaling != RMX_OFF) : false;<br>
         int mode_refresh;<br>
-       int preferred_refresh;<br>
+       int preferred_refresh = 0;<br>
 <br>
         struct dc_sink *sink = NULL;<br>
         if (aconnector == NULL) {<br>
@@ -2889,13 +2889,12 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,<br>
                 decide_crtc_timing_for_drm_display_mode(<br>
                                 &mode, preferred_mode,<br>
                                 dm_state ? (dm_state->scaling != RMX_OFF) : false);<br>
+               preferred_refresh = drm_mode_vrefresh(preferred_mode);<br>
         }<br>
 <br>
         if (!dm_state)<br>
                 drm_mode_set_crtcinfo(&mode, 0);<br>
 <br>
-       preferred_refresh = drm_mode_vrefresh(preferred_mode);<br>
-<br>
         /*<br>
         * If scaling is enabled and refresh rate didn't change<br>
         * we copy the vic and polarities of the old timings<br>
-- <br>
2.14.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>