<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:宋体;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:DengXian;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@宋体";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"\@等线";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:12.0pt;
        font-family:宋体;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:DengXian;
        color:windowtext;}
span.searchhighlight
        {mso-style-name:searchhighlight;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="ZH-CN" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;" align="Left">
[AMD Official Use Only - General]<br>
</p>
<br>
<div>
<div class="WordSection1">
<p class="MsoNormal"><span class="searchhighlight"><span lang="EN-US" style="font-size:11.0pt;font-family:"Times New Roman",serif;color:#070706;background:#FFEE94">Reviewed-by</span></span><span lang="EN-US" style="font-size:11.0pt;font-family:"Times New Roman",serif;color:black">:
 Kenneth Feng <</span><span lang="EN-US" style="color:black"><a href="mailto:kenneth.feng@amd.com" title="mailto:kenneth.feng@amd.com"><span style="font-size:11.0pt;font-family:"Times New Roman",serif;color:#0078D4">kenneth.feng@amd.com</span></a></span><span lang="EN-US" style="font-size:11.0pt;font-family:"Times New Roman",serif;color:black">></span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:DengXian"><o:p> </o:p></span></p>
<div>
<div>
<div>
<p class="MsoNormal"><span lang="EN-US">Best wishes<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Kenneth Feng <o:p></o:p></span></p>
</div>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:DengXian"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:DengXian"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="color:black">发件人</span></b><b><span lang="EN-US" style="font-family:"Calibri",sans-serif;color:black">:</span></b><span lang="EN-US" style="font-family:"Calibri",sans-serif;color:black"> amd-gfx
 <amd-gfx-bounces@lists.freedesktop.org> </span><span style="color:black">代表</span><span lang="EN-US" style="font-family:"Calibri",sans-serif;color:black"> Yang Wang <KevinYang.Wang@amd.com><br>
</span><b><span style="color:black">日期</span></b><b><span lang="EN-US" style="font-family:"Calibri",sans-serif;color:black">:</span></b><span lang="EN-US" style="font-family:"Calibri",sans-serif;color:black">
</span><span style="color:black">星期三</span><span lang="EN-US" style="font-family:"Calibri",sans-serif;color:black">, 2022</span><span style="color:black">年</span><span lang="EN-US" style="font-family:"Calibri",sans-serif;color:black">5</span><span style="color:black">月</span><span lang="EN-US" style="font-family:"Calibri",sans-serif;color:black">11</span><span style="color:black">日</span><span lang="EN-US" style="font-family:"Calibri",sans-serif;color:black">
 15:01<br>
</span><b><span style="color:black">收件人</span></b><b><span lang="EN-US" style="font-family:"Calibri",sans-serif;color:black">:</span></b><span lang="EN-US" style="font-family:"Calibri",sans-serif;color:black"> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
</span><b><span style="color:black">抄送</span></b><b><span lang="EN-US" style="font-family:"Calibri",sans-serif;color:black">:</span></b><span lang="EN-US" style="font-family:"Calibri",sans-serif;color:black"> Wang, Yang(Kevin) <KevinYang.Wang@amd.com><br>
</span><b><span style="color:black">主题</span></b><b><span lang="EN-US" style="font-family:"Calibri",sans-serif;color:black">:</span></b><span lang="EN-US" style="font-family:"Calibri",sans-serif;color:black"> [PATCH] drm/amd/pm: add smu power_limit callback
 for smu_v13_0_7<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span lang="EN-US" style="font-size:11.0pt">[CAUTION: External Email]<br>
<br>
- get_power_limit<br>
- set_power_limit<br>
<br>
add above callback functions to enable power_cap hwmon node.<br>
<br>
Signed-off-by: Yang Wang <KevinYang.Wang@amd.com><br>
---<br>
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c  | 39 +++++++++++++++++++<br>
 1 file changed, 39 insertions(+)<br>
<br>
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c<br>
index 7c9e0ba7ab50..4e1861fb2c6a 100644<br>
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c<br>
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c<br>
@@ -1367,6 +1367,43 @@ static int smu_v13_0_7_enable_mgpu_fan_boost(struct smu_context *smu)<br>
                                               NULL);<br>
 }<br>
<br>
+static int smu_v13_0_7_get_power_limit(struct smu_context *smu,<br>
+                                      uint32_t *current_power_limit,<br>
+                                      uint32_t *default_power_limit,<br>
+                                      uint32_t *max_power_limit)<br>
+{<br>
+       struct smu_table_context *table_context = &smu->smu_table;<br>
+       struct smu_13_0_7_powerplay_table *powerplay_table =<br>
+               (struct smu_13_0_7_powerplay_table *)table_context->power_play_table;<br>
+       PPTable_t *pptable = table_context->driver_pptable;<br>
+       SkuTable_t *skutable = &pptable->SkuTable;<br>
+       uint32_t power_limit, od_percent;<br>
+<br>
+       if (smu_v13_0_get_current_power_limit(smu, &power_limit))<br>
+               power_limit = smu->adev->pm.ac_power ?<br>
+                             skutable->SocketPowerLimitAc[PPT_THROTTLER_PPT0] :<br>
+                             skutable->SocketPowerLimitDc[PPT_THROTTLER_PPT0];<br>
+<br>
+       if (current_power_limit)<br>
+               *current_power_limit = power_limit;<br>
+       if (default_power_limit)<br>
+               *default_power_limit = power_limit;<br>
+<br>
+       if (max_power_limit) {<br>
+               if (smu->od_enabled) {<br>
+                       od_percent = le32_to_cpu(powerplay_table->overdrive_table.max[SMU_13_0_7_ODSETTING_POWERPERCENTAGE]);<br>
+<br>
+                       dev_dbg(smu->adev->dev, "ODSETTING_POWERPERCENTAGE: %d (default: %d)\n", od_percent, power_limit);<br>
+<br>
+                       power_limit *= (100 + od_percent);<br>
+                       power_limit /= 100;<br>
+               }<br>
+               *max_power_limit = power_limit;<br>
+       }<br>
+<br>
+       return 0;<br>
+}<br>
+<br>
 static int smu_v13_0_7_get_power_profile_mode(struct smu_context *smu, char *buf)<br>
 {<br>
        DpmActivityMonitorCoeffIntExternal_t activity_monitor_external[PP_SMC_POWER_PROFILE_COUNT];<br>
@@ -1539,6 +1576,8 @@ static const struct pptable_funcs smu_v13_0_7_ppt_funcs = {<br>
        .get_fan_control_mode = smu_v13_0_get_fan_control_mode,<br>
        .set_fan_control_mode = smu_v13_0_set_fan_control_mode,<br>
        .enable_mgpu_fan_boost = smu_v13_0_7_enable_mgpu_fan_boost,<br>
+       .get_power_limit = smu_v13_0_7_get_power_limit,<br>
+       .set_power_limit = smu_v13_0_set_power_limit,<br>
        .get_power_profile_mode = smu_v13_0_7_get_power_profile_mode,<br>
        .set_power_profile_mode = smu_v13_0_7_set_power_profile_mode,<br>
        .set_tool_table_location = smu_v13_0_set_tool_table_location,<br>
--<br>
2.25.1<o:p></o:p></span></p>
</div>
</div>
</div>
</body>
</html>