<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Reviewed-by: Ken Wang<Qingqing.Wang@amd.com></p>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Rex Zhu <Rex.Zhu@amd.com><br>
<b>Sent:</b> Monday, June 19, 2017 6:05:16 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org<br>
<b>Cc:</b> Zhu, Rex<br>
<b>Subject:</b> [PATCH] drm/amd/powerplay: add support for ATOM GFXCLK table v2.</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">Change-Id: I42e3d7b684ee903ce3ced6135f954cea0d113503<br>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com><br>
---<br>
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c | 14 +++++---<br>
.../gpu/drm/amd/powerplay/hwmgr/vega10_pptable.h | 9 +++++<br>
.../amd/powerplay/hwmgr/vega10_processpptables.c | 42 +++++++++++++++++-----<br>
3 files changed, 51 insertions(+), 14 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c<br>
index d9744b6..e2e2822 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c<br>
@@ -2864,6 +2864,7 @@ static int vega10_get_pp_table_entry_callback_func(struct pp_hwmgr *hwmgr,<br>
void *state, struct pp_power_state *power_state,<br>
void *pp_table, uint32_t classification_flag)<br>
{<br>
+ ATOM_Vega10_GFXCLK_Dependency_Record_V2 *patom_record_V2;<br>
struct vega10_power_state *vega10_power_state =<br>
cast_phw_vega10_power_state(&(power_state->hardware));<br>
struct vega10_performance_level *performance_level;<br>
@@ -2940,11 +2941,16 @@ static int vega10_get_pp_table_entry_callback_func(struct pp_hwmgr *hwmgr,<br>
<br>
performance_level = &(vega10_power_state->performance_levels<br>
[vega10_power_state->performance_level_count++]);<br>
-<br>
performance_level->soc_clock = socclk_dep_table->entries<br>
- [state_entry->ucSocClockIndexHigh].ulClk;<br>
- performance_level->gfx_clock = gfxclk_dep_table->entries<br>
+ [state_entry->ucSocClockIndexHigh].ulClk;<br>
+ if (gfxclk_dep_table->ucRevId == 0) {<br>
+ performance_level->gfx_clock = gfxclk_dep_table->entries<br>
[state_entry->ucGfxClockIndexHigh].ulClk;<br>
+ } else if (gfxclk_dep_table->ucRevId == 1) {<br>
+ patom_record_V2 = (ATOM_Vega10_GFXCLK_Dependency_Record_V2 *)gfxclk_dep_table->entries;<br>
+ performance_level->gfx_clock = patom_record_V2[state_entry->ucGfxClockIndexHigh].ulClk;<br>
+ }<br>
+<br>
performance_level->mem_clock = mclk_dep_table->entries<br>
[state_entry->ucMemClockIndexHigh].ulMemClk;<br>
return 0;<br>
@@ -3348,7 +3354,6 @@ static int vega10_populate_and_upload_sclk_mclk_dpm_levels(<br>
dpm_table-><br>
gfx_table.dpm_levels[dpm_table->gfx_table.count - 1].<br>
value = sclk;<br>
-<br>
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,<br>
PHM_PlatformCaps_OD6PlusinACSupport) ||<br>
phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,<br>
@@ -3471,7 +3476,6 @@ static int vega10_populate_and_upload_sclk_mclk_dpm_levels(<br>
return result);<br>
}<br>
}<br>
-<br>
return result;<br>
}<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_pptable.h b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_pptable.h<br>
index 52beea3..b3e6300 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_pptable.h<br>
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_pptable.h<br>
@@ -144,6 +144,15 @@<br>
USHORT usAVFSOffset; /* AVFS Voltage offset */<br>
} ATOM_Vega10_GFXCLK_Dependency_Record;<br>
<br>
+typedef struct _ATOM_Vega10_GFXCLK_Dependency_Record_V2 {<br>
+ ULONG ulClk;<br>
+ UCHAR ucVddInd;<br>
+ USHORT usCKSVOffsetandDisable;<br>
+ USHORT usAVFSOffset;<br>
+ UCHAR ucACGEnable;<br>
+ UCHAR ucReserved[3];<br>
+} ATOM_Vega10_GFXCLK_Dependency_Record_V2;<br>
+<br>
typedef struct _ATOM_Vega10_MCLK_Dependency_Record {<br>
ULONG ulMemClk; /* Clock Frequency */<br>
UCHAR ucVddInd; /* SOC_VDD index */<br>
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c<br>
index 2b892e4..1623644 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c<br>
@@ -585,6 +585,7 @@ static int get_gfxclk_voltage_dependency_table(<br>
uint32_t table_size, i;<br>
struct phm_ppt_v1_clock_voltage_dependency_table<br>
*clk_table;<br>
+ ATOM_Vega10_GFXCLK_Dependency_Record_V2 *patom_record_v2;<br>
<br>
PP_ASSERT_WITH_CODE((clk_dep_table->ucNumEntries != 0),<br>
"Invalid PowerPlay Table!", return -1);<br>
@@ -601,18 +602,41 @@ static int get_gfxclk_voltage_dependency_table(<br>
<br>
clk_table->count = clk_dep_table->ucNumEntries;<br>
<br>
- for (i = 0; i < clk_table->count; i++) {<br>
- clk_table->entries[i].vddInd =<br>
+ if (clk_dep_table->ucRevId == 0) {<br>
+ for (i = 0; i < clk_table->count; i++) {<br>
+ clk_table->entries[i].vddInd =<br>
clk_dep_table->entries[i].ucVddInd;<br>
- clk_table->entries[i].clk =<br>
+ clk_table->entries[i].clk =<br>
le32_to_cpu(clk_dep_table->entries[i].ulClk);<br>
- clk_table->entries[i].cks_enable =<br>
- (((clk_dep_table->entries[i].usCKSVOffsetandDisable & 0x8000)<br>
+ clk_table->entries[i].cks_enable =<br>
+ (((le16_to_cpu(clk_dep_table->entries[i].usCKSVOffsetandDisable) & 0x8000)<br>
>> 15) == 0) ? 1 : 0;<br>
- clk_table->entries[i].cks_voffset =<br>
- (clk_dep_table->entries[i].usCKSVOffsetandDisable & 0x7F);<br>
- clk_table->entries[i].sclk_offset =<br>
- clk_dep_table->entries[i].usAVFSOffset;<br>
+ clk_table->entries[i].cks_voffset =<br>
+ le16_to_cpu(clk_dep_table->entries[i].usCKSVOffsetandDisable) & 0x7F;<br>
+ clk_table->entries[i].sclk_offset =<br>
+ le16_to_cpu(clk_dep_table->entries[i].usAVFSOffset);<br>
+ }<br>
+ } else if (clk_dep_table->ucRevId == 1) {<br>
+ patom_record_v2 = (ATOM_Vega10_GFXCLK_Dependency_Record_V2 *)clk_dep_table->entries;<br>
+ for (i = 0; i < clk_table->count; i++) {<br>
+ clk_table->entries[i].vddInd =<br>
+ patom_record_v2->ucVddInd;<br>
+ clk_table->entries[i].clk =<br>
+ le32_to_cpu(patom_record_v2->ulClk);<br>
+ clk_table->entries[i].cks_enable =<br>
+ (((le16_to_cpu(patom_record_v2->usCKSVOffsetandDisable) & 0x8000)<br>
+ >> 15) == 0) ? 1 : 0;<br>
+ clk_table->entries[i].cks_voffset =<br>
+ le16_to_cpu(patom_record_v2->usCKSVOffsetandDisable) & 0x7F;<br>
+ clk_table->entries[i].sclk_offset =<br>
+ le16_to_cpu(patom_record_v2->usAVFSOffset);<br>
+ patom_record_v2++;<br>
+ }<br>
+ } else {<br>
+ kfree(clk_table);<br>
+ PP_ASSERT_WITH_CODE(false,<br>
+ "Unsupported GFXClockDependencyTable Revision!",<br>
+ return -EINVAL);<br>
}<br>
<br>
*pp_vega10_clk_dep_table = clk_table;<br>
-- <br>
1.9.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>
</body>
</html>