<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<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">Thanks.  Will apply the patch to drm-next.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Best Regards</p>
<p style="margin-top:0;margin-bottom:0">Rex</p>
<br>
<div style="color: rgb(0, 0, 0);">
<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> Joe Perches <joe@perches.com><br>
<b>Sent:</b> Thursday, March 22, 2018 3:02 AM<br>
<b>To:</b> Colin King; Koenig, Christian; Zhou, David(ChunMing); David Airlie; Zhu, Rex; amd-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org<br>
<b>Cc:</b> kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org<br>
<b>Subject:</b> Re: [PATCH] drm/amd/pp: use mlck_table.count for array loop index limit</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">On Wed, 2018-03-21 at 18:26 +0000, Colin King wrote:<br>
> From: Colin Ian King <colin.king@canonical.com><br>
> <br>
> The for-loops process data in the mclk_table but use slck_table.count<br>
> as the loop index limit.  I believe these are cut-n-paste errors from<br>
> the previous almost identical loops as indicated by static analysis.<br>
> Fix these.<br>
<br>
Nice tool.<br>
<br>
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c<br>
[]<br>
> @@ -855,7 +855,7 @@ static int smu7_odn_initial_default_setting(struct pp_hwmgr *hwmgr)<br>
>  <br>
>        odn_table->odn_memory_clock_dpm_levels.num_of_pl =<br>
>                                                data->golden_dpm_table.mclk_table.count;<br>
> -     for (i=0; i<data->golden_dpm_table.sclk_table.count; i++) {<br>
> +     for (i=0; i<data->golden_dpm_table.mclk_table.count; i++) {<br>
>                odn_table->odn_memory_clock_dpm_levels.entries[i].clock =<br>
>                                        data->golden_dpm_table.mclk_table.dpm_levels[i].value;<br>
>                odn_table->odn_memory_clock_dpm_levels.entries[i].enabled = true;<br>
<br>
Probably more sensible to use temporaries too.<br>
Maybe something like the below (also trivially reduces object size)<br>
---<br>
 drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 19 ++++++++++---------<br>
 1 file changed, 10 insertions(+), 9 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c<br>
index df2a312ca6c9..339b897146af 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c<br>
@@ -834,6 +834,7 @@ static int smu7_odn_initial_default_setting(struct pp_hwmgr *hwmgr)<br>
 <br>
         struct phm_ppt_v1_clock_voltage_dependency_table *dep_sclk_table;<br>
         struct phm_ppt_v1_clock_voltage_dependency_table *dep_mclk_table;<br>
+       struct phm_odn_performance_level *entries;<br>
 <br>
         if (table_info == NULL)<br>
                 return -EINVAL;<br>
@@ -843,11 +844,11 @@ static int smu7_odn_initial_default_setting(struct pp_hwmgr *hwmgr)<br>
 <br>
         odn_table->odn_core_clock_dpm_levels.num_of_pl =<br>
                                                 data->golden_dpm_table.sclk_table.count;<br>
+       entries = odn_table->odn_core_clock_dpm_levels.entries;<br>
         for (i=0; i<data->golden_dpm_table.sclk_table.count; i++) {<br>
-               odn_table->odn_core_clock_dpm_levels.entries[i].clock =<br>
-                                       data->golden_dpm_table.sclk_table.dpm_levels[i].value;<br>
-               odn_table->odn_core_clock_dpm_levels.entries[i].enabled = true;<br>
-               odn_table->odn_core_clock_dpm_levels.entries[i].vddc = dep_sclk_table->entries[i].vddc;<br>
+               entries[i].clock = data->golden_dpm_table.sclk_table.dpm_levels[i].value;<br>
+               entries[i].enabled = true;<br>
+               entries[i].vddc = dep_sclk_table->entries[i].vddc;<br>
         }<br>
 <br>
         smu7_get_voltage_dependency_table(dep_sclk_table,<br>
@@ -855,11 +856,11 @@ static int smu7_odn_initial_default_setting(struct pp_hwmgr *hwmgr)<br>
 <br>
         odn_table->odn_memory_clock_dpm_levels.num_of_pl =<br>
                                                 data->golden_dpm_table.mclk_table.count;<br>
-       for (i=0; i<data->golden_dpm_table.sclk_table.count; i++) {<br>
-               odn_table->odn_memory_clock_dpm_levels.entries[i].clock =<br>
-                                       data->golden_dpm_table.mclk_table.dpm_levels[i].value;<br>
-               odn_table->odn_memory_clock_dpm_levels.entries[i].enabled = true;<br>
-               odn_table->odn_memory_clock_dpm_levels.entries[i].vddc = dep_mclk_table->entries[i].vddc;<br>
+       entries = odn_table->odn_memory_clock_dpm_levels.entries;<br>
+       for (i=0; i<data->golden_dpm_table.mclk_table.count; i++) {<br>
+               entries[i].clock = data->golden_dpm_table.mclk_table.dpm_levels[i].value;<br>
+               entries[i].enabled = true;<br>
+               entries[i].vddc = dep_mclk_table->entries[i].vddc;<br>
         }<br>
 <br>
         smu7_get_voltage_dependency_table(dep_mclk_table,<br>
</div>
</span></font></div>
</div>
</div>
</body>
</html>