<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;">Hi Alex,</span></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"><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;">>What about the min/max sclk? Do the curve values take
 that into</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;">>account?  What about max mclk?</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;">Voltage curve does not take these into consideration. And
 the max sclk and mclk can be set through existing sysfs interface <span>pp_sclk_od and <span>pp_mclk_od. For min sclk, as i know there is no interface to get it set.</span></span></span></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;"><span><span><br>
</span></span></span></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;"><span><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;">> Are
 negative offsets supported?</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;">
Sure.</span></span></span></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;"><span><span><br>
</span></span></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;">Regards,</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;">Evan</span></font></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;"><span><span><br>
</span></span></span></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> Alex Deucher <alexdeucher@gmail.com><br>
<b>Sent:</b> Thursday, August 30, 2018 12:25:35 AM<br>
<b>To:</b> Quan, Evan<br>
<b>Cc:</b> amd-gfx list; Deucher, Alexander; Zhu, Rex<br>
<b>Subject:</b> Re: [PATCH] drm/amd/powerplay: added vega20 overdrive support</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">On Wed, Aug 29, 2018 at 5:13 AM Evan Quan <evan.quan@amd.com> wrote:<br>
><br>
> Vega20 supports only sclk voltage overdrive. And user can<br>
> only tell three groups of <frequency, voltage_offset>. SMU<br>
> firmware will recalculate the frequency/voltage curve. Other<br>
> intermediate levles will be stretched/shrunk accordingly.<br>
><br>
<br>
What about the min/max sclk? Do the curve values take that into<br>
account?  What about max mclk?<br>
<br>
> Change-Id: I403cb38a95863db664cf06d030ac42a19bff6b33<br>
> Signed-off-by: Evan Quan <evan.quan@amd.com><br>
> ---<br>
>  drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c        |  26 +++<br>
>  .../drm/amd/powerplay/hwmgr/vega20_hwmgr.c    | 165 +++++++++++++++++-<br>
>  .../drm/amd/powerplay/hwmgr/vega20_hwmgr.h    |   2 +<br>
>  3 files changed, 192 insertions(+), 1 deletion(-)<br>
><br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c<br>
> index e2577518b9c6..6e0c8f583521 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c<br>
> @@ -474,6 +474,8 @@ static ssize_t amdgpu_set_pp_table(struct device *dev,<br>
>   * in each power level within a power state.  The pp_od_clk_voltage is used for<br>
>   * this.<br>
>   *<br>
> + * < For Vega10 and previous ASICs ><br>
> + *<br>
>   * Reading the file will display:<br>
>   *<br>
>   * - a list of engine clock levels and voltages labeled OD_SCLK<br>
> @@ -491,6 +493,30 @@ static ssize_t amdgpu_set_pp_table(struct device *dev,<br>
>   * "c" (commit) to the file to commit your changes.  If you want to reset to the<br>
>   * default power levels, write "r" (reset) to the file to reset them.<br>
>   *<br>
> + *<br>
> + * < For Vega20 ><br>
> + *<br>
> + * Reading the file will display:<br>
> + *<br>
> + * - three groups of engine clock and voltage offset labeled OD_SCLK<br>
> + *<br>
> + * - a list of valid ranges for above three groups of sclk and voltage offset<br>
> + *   labeled OD_RANGE<br>
> + *<br>
> + * To manually adjust these settings:<br>
> + *<br>
> + * - First select manual using power_dpm_force_performance_level<br>
> + *<br>
> + * - Enter a new value for each group by writing a string that contains<br>
> + *   "s group_index clock voltage_offset" to the file.  E.g., "s 0 500 20"<br>
> + *   will update group1 sclk to be 500 MHz with voltage increased 20mV<br>
> + *<br>
<br>
Are negative offsets supported?<br>
<br>
Alex<br>
<br>
> + * - When you have edited all of the states as needed, write "c" (commit)<br>
> + *   to the file to commit your changes<br>
> + *<br>
> + * - If you want to reset to the default power levels, write "r" (reset)<br>
> + *   to the file to reset them<br>
> + *<br>
>   */<br>
><br>
>  static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev,<br>
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c<br>
> index ececa2f7fe5f..9f6e070a76e0 100644<br>
> --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c<br>
> +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c<br>
> @@ -1096,6 +1096,13 @@ static int vega20_od8_initialize_default_settings(<br>
>                 }<br>
>         }<br>
><br>
> +       ret = vega20_copy_table_from_smc(hwmgr,<br>
> +                       (uint8_t *)(&data->od_table),<br>
> +                       TABLE_OVERDRIVE);<br>
> +       PP_ASSERT_WITH_CODE(!ret,<br>
> +                       "Failed to export over drive table!",<br>
> +                       return ret);<br>
> +<br>
>         return 0;<br>
>  }<br>
><br>
> @@ -2506,11 +2513,112 @@ static int vega20_set_watermarks_for_clocks_ranges(struct pp_hwmgr *hwmgr,<br>
>         return 0;<br>
>  }<br>
><br>
> +static int vega20_odn_edit_dpm_table(struct pp_hwmgr *hwmgr,<br>
> +                                       enum PP_OD_DPM_TABLE_COMMAND type,<br>
> +                                       long *input, uint32_t size)<br>
> +{<br>
> +       struct vega20_hwmgr *data =<br>
> +                       (struct vega20_hwmgr *)(hwmgr->backend);<br>
> +       struct vega20_od8_single_setting *od8_settings =<br>
> +                       data->od8_settings.od8_settings_array;<br>
> +       OverDriveTable_t od_table;<br>
> +       int32_t input_index, input_clk, input_vol, i;<br>
> +       int ret = 0;<br>
> +<br>
> +       PP_ASSERT_WITH_CODE(input, "NULL user input for clock and voltage",<br>
> +                               return -EINVAL);<br>
> +<br>
> +       switch (type) {<br>
> +       case PP_OD_EDIT_SCLK_VDDC_TABLE:<br>
> +               if (!(od8_settings[OD8_SETTING_GFXCLK_FREQ1].feature_id &&<br>
> +                   od8_settings[OD8_SETTING_GFXCLK_FREQ2].feature_id &&<br>
> +                   od8_settings[OD8_SETTING_GFXCLK_FREQ3].feature_id &&<br>
> +                   od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].feature_id &&<br>
> +                   od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].feature_id &&<br>
> +                   od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].feature_id)) {<br>
> +                       pr_info("Sclk voltage overdrive not supported\n");<br>
> +                       return 0;<br>
> +               }<br>
> +<br>
> +               for (i = 0; i < size; i += 3) {<br>
> +                       if (i + 3 > size) {<br>
> +                               pr_info("invalid clock voltage input\n");<br>
> +                               return 0;<br>
> +                       }<br>
> +<br>
> +                       input_index = input[i];<br>
> +                       input_clk = input[i + 1];<br>
> +                       input_vol = input[i + 2];<br>
> +                       if (input_index > 2 ||<br>
> +                           input_clk < od8_settings[OD8_SETTING_GFXCLK_FREQ1 + input_index * 2].min_value ||<br>
> +                           input_clk > od8_settings[OD8_SETTING_GFXCLK_FREQ1 + input_index * 2].max_value ||<br>
> +                           input_vol < od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1 + input_index * 2].min_value ||<br>
> +                           input_vol > od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1 + input_index * 2].max_value) {<br>
> +                               pr_info("input argument is not within allowed range\n");<br>
> +                               return -EINVAL;<br>
> +                       }<br>
> +<br>
> +                       switch (input_index) {<br>
> +                       case 0:<br>
> +                               data->od_table.GfxclkFreq1 = input_clk;<br>
> +                               data->od_table.GfxclkOffsetVolt1 = input_vol;<br>
> +                               break;<br>
> +                       case 1:<br>
> +                               data->od_table.GfxclkFreq2 = input_clk;<br>
> +                               data->od_table.GfxclkOffsetVolt2 = input_vol;<br>
> +                               break;<br>
> +                       case 2:<br>
> +                               data->od_table.GfxclkFreq3 = input_clk;<br>
> +                               data->od_table.GfxclkOffsetVolt3 = input_vol;<br>
> +                               break;<br>
> +                       }<br>
> +               }<br>
> +               break;<br>
> +<br>
> +       case PP_OD_EDIT_MCLK_VDDC_TABLE:<br>
> +               pr_info("Mclk voltage overdrive not supported!\n");<br>
> +               break;<br>
> +<br>
> +       case PP_OD_RESTORE_DEFAULT_TABLE:<br>
> +               ret = vega20_copy_table_from_smc(hwmgr,<br>
> +                               (uint8_t *)(&od_table),<br>
> +                               TABLE_OVERDRIVE);<br>
> +               PP_ASSERT_WITH_CODE(!ret,<br>
> +                               "Failed to export over drive table!",<br>
> +                               return ret);<br>
> +<br>
> +               memcpy(&data->od_table, &od_table, sizeof(od_table));<br>
> +               break;<br>
> +<br>
> +       case PP_OD_COMMIT_DPM_TABLE:<br>
> +               memcpy(&od_table, &data->od_table, sizeof(od_table));<br>
> +<br>
> +               ret = vega20_copy_table_to_smc(hwmgr,<br>
> +                               (uint8_t *)(&od_table),<br>
> +                               TABLE_OVERDRIVE);<br>
> +               PP_ASSERT_WITH_CODE(!ret,<br>
> +                               "Failed to import over drive table!",<br>
> +                               return ret);<br>
> +<br>
> +               break;<br>
> +<br>
> +       default:<br>
> +               return -EINVAL;<br>
> +       }<br>
> +<br>
> +       return 0;<br>
> +}<br>
> +<br>
>  static int vega20_print_clock_levels(struct pp_hwmgr *hwmgr,<br>
>                 enum pp_clock_type type, char *buf)<br>
>  {<br>
> -       int i, now, size = 0;<br>
> +       struct vega20_hwmgr *data =<br>
> +                       (struct vega20_hwmgr *)(hwmgr->backend);<br>
> +       struct vega20_od8_single_setting *od8_settings =<br>
> +                       data->od8_settings.od8_settings_array;<br>
> +       OverDriveTable_t *od_table = &data->od_table;<br>
>         struct pp_clock_levels_with_latency clocks;<br>
> +       int i, now, size = 0;<br>
>         int ret = 0;<br>
><br>
>         switch (type) {<br>
> @@ -2551,6 +2659,59 @@ static int vega20_print_clock_levels(struct pp_hwmgr *hwmgr,<br>
>         case PP_PCIE:<br>
>                 break;<br>
><br>
> +       case OD_SCLK:<br>
> +               if (od8_settings[OD8_SETTING_GFXCLK_FREQ1].feature_id &&<br>
> +                   od8_settings[OD8_SETTING_GFXCLK_FREQ2].feature_id &&<br>
> +                   od8_settings[OD8_SETTING_GFXCLK_FREQ3].feature_id &&<br>
> +                   od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].feature_id &&<br>
> +                   od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].feature_id &&<br>
> +                   od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].feature_id) {<br>
> +<br>
> +                       size = sprintf(buf, "%s:\n", "OD_SCLK");<br>
> +                       size += sprintf(buf + size, "0: %10uMhz %10dmV\n",<br>
> +                               od_table->GfxclkFreq1,<br>
> +                               od_table->GfxclkOffsetVolt1);<br>
> +                       size += sprintf(buf + size, "1: %10uMhz %10dmV\n",<br>
> +                               od_table->GfxclkFreq2,<br>
> +                               od_table->GfxclkOffsetVolt2);<br>
> +                       size += sprintf(buf + size, "2: %10uMhz %10dmV\n",<br>
> +                               od_table->GfxclkFreq3,<br>
> +                               od_table->GfxclkOffsetVolt3);<br>
> +               }<br>
> +               break;<br>
> +<br>
> +       case OD_MCLK:<br>
> +               break;<br>
> +<br>
> +       case OD_RANGE:<br>
> +               if (od8_settings[OD8_SETTING_GFXCLK_FREQ1].feature_id &&<br>
> +                   od8_settings[OD8_SETTING_GFXCLK_FREQ2].feature_id &&<br>
> +                   od8_settings[OD8_SETTING_GFXCLK_FREQ3].feature_id &&<br>
> +                   od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].feature_id &&<br>
> +                   od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].feature_id &&<br>
> +                   od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].feature_id) {<br>
> +<br>
> +                       size = sprintf(buf, "%s:\n", "OD_RANGE");<br>
> +                       size += sprintf(buf + size, "SCLK[0]: %7uMhz %10uMhz\n",<br>
> +                               od8_settings[OD8_SETTING_GFXCLK_FREQ1].min_value,<br>
> +                               od8_settings[OD8_SETTING_GFXCLK_FREQ1].max_value);<br>
> +                       size += sprintf(buf + size, "VDDC[0]: %7dmV %11dmV\n",<br>
> +                               od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].min_value,<br>
> +                               od8_settings[OD8_SETTING_GFXCLK_VOLTAGE1].max_value);<br>
> +                       size += sprintf(buf + size, "SCLK[1]: %7uMhz %10uMhz\n",<br>
> +                               od8_settings[OD8_SETTING_GFXCLK_FREQ2].min_value,<br>
> +                               od8_settings[OD8_SETTING_GFXCLK_FREQ2].max_value);<br>
> +                       size += sprintf(buf + size, "VDDC[1]: %7dmV %11dmV\n",<br>
> +                               od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].min_value,<br>
> +                               od8_settings[OD8_SETTING_GFXCLK_VOLTAGE2].max_value);<br>
> +                       size += sprintf(buf + size, "SCLK[2]: %7uMhz %10uMhz\n",<br>
> +                               od8_settings[OD8_SETTING_GFXCLK_FREQ3].min_value,<br>
> +                               od8_settings[OD8_SETTING_GFXCLK_FREQ3].max_value);<br>
> +                       size += sprintf(buf + size, "VDDC[2]: %7dmV %11dmV\n",<br>
> +                               od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].min_value,<br>
> +                               od8_settings[OD8_SETTING_GFXCLK_VOLTAGE3].max_value);<br>
> +               }<br>
> +               break;<br>
>         default:<br>
>                 break;<br>
>         }<br>
> @@ -3162,6 +3323,8 @@ static const struct pp_hwmgr_func vega20_hwmgr_funcs = {<br>
>                 vega20_get_mclk_od,<br>
>         .set_mclk_od =<br>
>                 vega20_set_mclk_od,<br>
> +       .odn_edit_dpm_table =<br>
> +               vega20_odn_edit_dpm_table,<br>
>         /* for sysfs to retrive/set gfxclk/memclk */<br>
>         .force_clock_level =<br>
>                 vega20_force_clock_level,<br>
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.h b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.h<br>
> index 72e4f2a55641..8bb90e22efb6 100644<br>
> --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.h<br>
> +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.h<br>
> @@ -513,6 +513,8 @@ struct vega20_hwmgr {<br>
>         /* ---- Gfxoff ---- */<br>
>         bool                           gfxoff_allowed;<br>
>         uint32_t                       counter_gfxoff;<br>
> +<br>
> +       OverDriveTable_t               od_table;<br>
>  };<br>
><br>
>  #define VEGA20_DPM2_NEAR_TDP_DEC                      10<br>
> --<br>
> 2.18.0<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>