<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"><a class="mention ms-bgc-nlr ms-fcl-b" id="OWAAM172094" href="mailto:Evan.Quan@amd.com">@Quan, Evan</a></p>
<p style="margin-top:0;margin-bottom:0">I remake a new patch v2 to fix it, please help me review it.</p>
<p style="margin-top:0;margin-bottom:0">Thanks.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Best Regards,<br>
Kevin</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> Quan, Evan<br>
<b>Sent:</b> Tuesday, April 9, 2019 9:33:06 AM<br>
<b>To:</b> Wang, Kevin(Yang); amd-gfx@lists.freedesktop.org<br>
<b>Cc:</b> Huang, Ray; Feng, Kenneth; Wang, Kevin(Yang)<br>
<b>Subject:</b> RE: [PATCH 2/2] drm/amd/powerplay: simplify the code of [get|set]_activity_monitor_coeff</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Comment inline<br>
<br>
> -----Original Message-----<br>
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of<br>
> Wang, Kevin(Yang)<br>
> Sent: Monday, April 08, 2019 4:43 PM<br>
> To: amd-gfx@lists.freedesktop.org<br>
> Cc: Huang, Ray <Ray.Huang@amd.com>; Feng, Kenneth<br>
> <Kenneth.Feng@amd.com>; Wang, Kevin(Yang) <Kevin1.Wang@amd.com><br>
> Subject: [PATCH 2/2] drm/amd/powerplay: simplify the code of<br>
> [get|set]_activity_monitor_coeff<br>
> <br>
> use smu_update_table_with_arg to replace old code logic<br>
> <br>
> Signed-off-by: Kevin Wang <kevin1.wang@amd.com><br>
> ---<br>
>  .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h    |  6 --<br>
>  drivers/gpu/drm/amd/powerplay/smu_v11_0.c     | 75 ++-----------------<br>
>  2 files changed, 7 insertions(+), 74 deletions(-)<br>
> <br>
> diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h<br>
> b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h<br>
> index c146b5e884f8..26a7d2c7f4fa 100644<br>
> --- a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h<br>
> +++ b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h<br>
> @@ -524,12 +524,6 @@ struct smu_funcs<br>
>                                               struct<br>
> dm_pp_wm_sets_with_clock_ranges_soc15 *clock_ranges);<br>
>        int (*set_od8_default_settings)(struct smu_context *smu,<br>
>                                        bool initialize);<br>
> -     int (*get_activity_monitor_coeff)(struct smu_context *smu,<br>
> -                                   uint8_t *table,<br>
> -                                   uint16_t workload_type);<br>
> -     int (*set_activity_monitor_coeff)(struct smu_context *smu,<br>
> -                                   uint8_t *table,<br>
> -                                   uint16_t workload_type);<br>
>        int (*conv_power_profile_to_pplib_workload)(int power_profile);<br>
>        int (*get_power_profile_mode)(struct smu_context *smu, char<br>
> *buf);<br>
>        int (*set_power_profile_mode)(struct smu_context *smu, long<br>
> *input, uint32_t size); diff --git<br>
> a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c<br>
> b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c<br>
> index 0e4b4b88af24..435cb606d7eb 100644<br>
> --- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c<br>
> +++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c<br>
> @@ -1460,62 +1460,6 @@ static int<br>
> smu_v11_0_set_od8_default_settings(struct smu_context *smu,<br>
>        return 0;<br>
>  }<br>
> <br>
> -static int smu_v11_0_set_activity_monitor_coeff(struct smu_context *smu,<br>
> -                                   uint8_t *table, uint16_t workload_type)<br>
> -{<br>
> -     int ret = 0;<br>
> -     memcpy(smu-<br>
> >smu_table.tables[TABLE_ACTIVITY_MONITOR_COEFF].cpu_addr,<br>
> -            table, smu-<br>
> >smu_table.tables[TABLE_ACTIVITY_MONITOR_COEFF].size);<br>
> -     ret = smu_send_smc_msg_with_param(smu,<br>
> SMU_MSG_SetDriverDramAddrHigh,<br>
> -                                       upper_32_bits(smu-<br>
> >smu_table.tables[TABLE_ACTIVITY_MONITOR_COEFF].mc_address));<br>
> -     if (ret) {<br>
> -             pr_err("[%s] Attempt to Set Dram Addr High Failed!",<br>
> __func__);<br>
> -             return ret;<br>
> -     }<br>
> -     ret = smu_send_smc_msg_with_param(smu,<br>
> SMU_MSG_SetDriverDramAddrLow,<br>
> -                                       lower_32_bits(smu-<br>
> >smu_table.tables[TABLE_ACTIVITY_MONITOR_COEFF].mc_address));<br>
> -     if (ret) {<br>
> -             pr_err("[%s] Attempt to Set Dram Addr Low Failed!",<br>
> __func__);<br>
> -             return ret;<br>
> -     }<br>
> -     ret = smu_send_smc_msg_with_param(smu,<br>
> SMU_MSG_TransferTableSmu2Dram,<br>
> -                                       TABLE_ACTIVITY_MONITOR_COEFF<br>
> | (workload_type << 16));<br>
> -     if (ret) {<br>
> -             pr_err("[%s] Attempt to Transfer Table From SMU Failed!",<br>
> __func__);<br>
> -             return ret;<br>
> -     }<br>
> -<br>
> -     return ret;<br>
> -}<br>
> -<br>
> -static int smu_v11_0_get_activity_monitor_coeff(struct smu_context *smu,<br>
> -                                   uint8_t *table, uint16_t workload_type)<br>
> -{<br>
> -     int ret = 0;<br>
> -     ret = smu_send_smc_msg_with_param(smu,<br>
> SMU_MSG_SetDriverDramAddrHigh,<br>
> -                                       upper_32_bits(smu-<br>
> >smu_table.tables[TABLE_ACTIVITY_MONITOR_COEFF].mc_address));<br>
> -     if (ret) {<br>
> -             pr_err("[%s] Attempt to Set Dram Addr High Failed!",<br>
> __func__);<br>
> -             return ret;<br>
> -     }<br>
> -<br>
> -     ret = smu_send_smc_msg_with_param(smu,<br>
> SMU_MSG_SetDriverDramAddrLow,<br>
> -                                       lower_32_bits(smu-<br>
> >smu_table.tables[TABLE_ACTIVITY_MONITOR_COEFF].mc_address));<br>
> -     if (ret) {<br>
> -             pr_err("[%s] Attempt to Set Dram Addr Low Failed!",<br>
> __func__);<br>
> -             return ret;<br>
> -     }<br>
> -<br>
> -     ret = smu_send_smc_msg_with_param(smu,<br>
> SMU_MSG_TransferTableSmu2Dram,<br>
> -                                       TABLE_ACTIVITY_MONITOR_COEFF<br>
> | (workload_type << 16));<br>
> -     if (ret) {<br>
> -             pr_err("[%s] Attempt to Transfer Table From SMU Failed!",<br>
> __func__);<br>
> -             return ret;<br>
> -     }<br>
> -<br>
> -     return ret;<br>
> -}<br>
> -<br>
>  static int smu_v11_0_conv_power_profile_to_pplib_workload(int<br>
> power_profile)  {<br>
>        int pplib_workload = 0;<br>
> @@ -1584,9 +1528,8 @@ static int<br>
> smu_v11_0_get_power_profile_mode(struct smu_context *smu, char *buf)<br>
>        for (i = 0; i <= PP_SMC_POWER_PROFILE_CUSTOM; i++) {<br>
>                /* conv PP_SMC_POWER_PROFILE* to<br>
> WORKLOAD_PPLIB_*_BIT */<br>
>                workload_type =<br>
> smu_v11_0_conv_power_profile_to_pplib_workload(i);<br>
> -             result = smu_v11_0_get_activity_monitor_coeff(smu,<br>
> -                                                           (uint8_t<br>
> *)(&activity_monitor),<br>
> -                                                           workload_type);<br>
> +             result = smu_update_table_with_arg(smu,<br>
> TABLE_ACTIVITY_MONITOR_COEFF,<br>
> +                                                workload_type,<br>
> &activity_monitor, false);<br>
>                if (result) {<br>
>                        pr_err("[%s] Failed to get activity monitor!",<br>
> __func__);<br>
>                        return result;<br>
> @@ -1658,7 +1601,7 @@ static int<br>
> smu_v11_0_get_power_profile_mode(struct smu_context *smu, char *buf)<br>
> static int smu_v11_0_set_power_profile_mode(struct smu_context *smu,<br>
> long *input, uint32_t size)  {<br>
>        DpmActivityMonitorCoeffInt_t activity_monitor;<br>
> -     int workload_type, ret = 0;<br>
> +     int workload_type = 0, ret = 0;<br>
> <br>
>        smu->power_profile_mode = input[size];<br>
> <br>
> @@ -1668,9 +1611,8 @@ static int<br>
> smu_v11_0_set_power_profile_mode(struct smu_context *smu, long<br>
> *input<br>
>        }<br>
> <br>
>        if (smu->power_profile_mode ==<br>
> PP_SMC_POWER_PROFILE_CUSTOM) {<br>
> -             ret = smu_v11_0_get_activity_monitor_coeff(smu,<br>
> -                                                        (uint8_t<br>
> *)(&activity_monitor),<br>
> -<br>
> WORKLOAD_PPLIB_CUSTOM_BIT);<br>
> +             ret = smu_update_table_with_arg(smu,<br>
> TABLE_ACTIVITY_MONITOR_COEFF,<br>
> +                                             workload_type,<br>
[Quan, Evan] workload_type seems not initialzed as WORKLOAD_PPLIB_CUSTOM_BIT before use. Can you confirm that?<br>
> &activity_monitor, false);<br>
>                if (ret) {<br>
>                        pr_err("[%s] Failed to get activity monitor!",<br>
> __func__);<br>
>                        return ret;<br>
> @@ -1723,9 +1665,8 @@ static int<br>
> smu_v11_0_set_power_profile_mode(struct smu_context *smu, long<br>
> *input<br>
>                        break;<br>
>                }<br>
> <br>
> -             ret = smu_v11_0_set_activity_monitor_coeff(smu,<br>
> -                                                        (uint8_t<br>
> *)(&activity_monitor),<br>
> -<br>
> WORKLOAD_PPLIB_CUSTOM_BIT);<br>
> +             ret = smu_update_table_with_arg(smu,<br>
> TABLE_ACTIVITY_MONITOR_COEFF,<br>
> +<br>
>        WORKLOAD_PPLIB_COMPUTE_BIT, &activity_monitor, true);<br>
>                if (ret) {<br>
>                        pr_err("[%s] Failed to set activity monitor!",<br>
> __func__);<br>
>                        return ret;<br>
> @@ -1994,8 +1935,6 @@ static const struct smu_funcs smu_v11_0_funcs = {<br>
>        .get_sclk = smu_v11_0_dpm_get_sclk,<br>
>        .get_mclk = smu_v11_0_dpm_get_mclk,<br>
>        .set_od8_default_settings = smu_v11_0_set_od8_default_settings,<br>
> -     .get_activity_monitor_coeff =<br>
> smu_v11_0_get_activity_monitor_coeff,<br>
> -     .set_activity_monitor_coeff =<br>
> smu_v11_0_set_activity_monitor_coeff,<br>
>        .conv_power_profile_to_pplib_workload =<br>
> smu_v11_0_conv_power_profile_to_pplib_workload,<br>
>        .get_power_profile_mode = smu_v11_0_get_power_profile_mode,<br>
>        .set_power_profile_mode = smu_v11_0_set_power_profile_mode,<br>
> --<br>
> 2.21.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>