<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 style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Series is:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Reviewed-by: Alex Deucher <alexander.deucher@amd.com><br>
</div>
<div id="appendonsend"></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 <Evan.Quan@amd.com><br>
<b>Sent:</b> Thursday, October 31, 2019 3:22 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Kim, Jonathan <Jonathan.Kim@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Quan, Evan <Evan.Quan@amd.com><br>
<b>Subject:</b> [PATCH 3/3] drm/amd/powerplay: support xgmi pstate setting on powerplay routine V2</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Add xgmi pstate setting on powerplay routine.<br>
<br>
Change-Id: If1a49aa14c16f133e43ac1298c6b14eaeb44d79d<br>
Signed-off-by: Evan Quan <evan.quan@amd.com><br>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com><br>
<br>
V2: split the change of is_support_sw_smu_xgmi into a separate patch<br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 5 +++++<br>
drivers/gpu/drm/amd/include/kgd_pp_interface.h | 4 ++++<br>
drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 18 ++++++++++++++++++<br>
.../gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 15 +++++++++++++++<br>
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 1 +<br>
drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 5 +----<br>
6 files changed, 44 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c<br>
index 00371713c671..167d9fbd2c4f 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c<br>
@@ -285,6 +285,11 @@ int amdgpu_xgmi_set_pstate(struct amdgpu_device *adev, int pstate)<br>
<br>
if (is_support_sw_smu_xgmi(adev))<br>
ret = smu_set_xgmi_pstate(&adev->smu, pstate);<br>
+ else if (adev->powerplay.pp_funcs &&<br>
+ adev->powerplay.pp_funcs->set_xgmi_pstate)<br>
+ ret = adev->powerplay.pp_funcs->set_xgmi_pstate(adev->powerplay.pp_handle,<br>
+ pstate);<br>
+<br>
if (ret)<br>
dev_err(adev->dev,<br>
"XGMI: Set pstate failure on device %llx, hive %llx, ret %d",<br>
diff --git a/drivers/gpu/drm/amd/include/kgd_pp_interface.h b/drivers/gpu/drm/amd/include/kgd_pp_interface.h<br>
index 5902f80d1fce..a7f92d0b3a90 100644<br>
--- a/drivers/gpu/drm/amd/include/kgd_pp_interface.h<br>
+++ b/drivers/gpu/drm/amd/include/kgd_pp_interface.h<br>
@@ -220,6 +220,9 @@ enum pp_df_cstate {<br>
((group) << PP_GROUP_SHIFT | (block) << PP_BLOCK_SHIFT | \<br>
(support) << PP_STATE_SUPPORT_SHIFT | (state) << PP_STATE_SHIFT)<br>
<br>
+#define XGMI_MODE_PSTATE_D3 0<br>
+#define XGMI_MODE_PSTATE_D0 1<br>
+<br>
struct seq_file;<br>
enum amd_pp_clock_type;<br>
struct amd_pp_simple_clock_info;<br>
@@ -318,6 +321,7 @@ struct amd_pm_funcs {<br>
int (*set_ppfeature_status)(void *handle, uint64_t ppfeature_masks);<br>
int (*asic_reset_mode_2)(void *handle);<br>
int (*set_df_cstate)(void *handle, enum pp_df_cstate state);<br>
+ int (*set_xgmi_pstate)(void *handle, uint32_t pstate);<br>
};<br>
<br>
#endif<br>
diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c<br>
index f4ff15378e61..031447675203 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c<br>
@@ -1566,6 +1566,23 @@ static int pp_set_df_cstate(void *handle, enum pp_df_cstate state)<br>
return 0;<br>
}<br>
<br>
+static int pp_set_xgmi_pstate(void *handle, uint32_t pstate)<br>
+{<br>
+ struct pp_hwmgr *hwmgr = handle;<br>
+<br>
+ if (!hwmgr)<br>
+ return -EINVAL;<br>
+<br>
+ if (!hwmgr->pm_en || !hwmgr->hwmgr_func->set_xgmi_pstate)<br>
+ return 0;<br>
+<br>
+ mutex_lock(&hwmgr->smu_lock);<br>
+ hwmgr->hwmgr_func->set_xgmi_pstate(hwmgr, pstate);<br>
+ mutex_unlock(&hwmgr->smu_lock);<br>
+<br>
+ return 0;<br>
+}<br>
+<br>
static const struct amd_pm_funcs pp_dpm_funcs = {<br>
.load_firmware = pp_dpm_load_fw,<br>
.wait_for_fw_loading_complete = pp_dpm_fw_loading_complete,<br>
@@ -1625,4 +1642,5 @@ static const struct amd_pm_funcs pp_dpm_funcs = {<br>
.asic_reset_mode_2 = pp_asic_reset_mode_2,<br>
.smu_i2c_bus_access = pp_smu_i2c_bus_access,<br>
.set_df_cstate = pp_set_df_cstate,<br>
+ .set_xgmi_pstate = pp_set_xgmi_pstate,<br>
};<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 9295bd90b792..5bcf0d684151 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c<br>
@@ -4176,6 +4176,20 @@ static int vega20_set_df_cstate(struct pp_hwmgr *hwmgr,<br>
return ret;<br>
}<br>
<br>
+static int vega20_set_xgmi_pstate(struct pp_hwmgr *hwmgr,<br>
+ uint32_t pstate)<br>
+{<br>
+ int ret;<br>
+<br>
+ ret = smum_send_msg_to_smc_with_parameter(hwmgr,<br>
+ PPSMC_MSG_SetXgmiMode,<br>
+ pstate ? XGMI_MODE_PSTATE_D0 : XGMI_MODE_PSTATE_D3);<br>
+ if (ret)<br>
+ pr_err("SetXgmiPstate failed!\n");<br>
+<br>
+ return ret;<br>
+}<br>
+<br>
static const struct pp_hwmgr_func vega20_hwmgr_funcs = {<br>
/* init/fini related */<br>
.backend_init = vega20_hwmgr_backend_init,<br>
@@ -4245,6 +4259,7 @@ static const struct pp_hwmgr_func vega20_hwmgr_funcs = {<br>
.set_mp1_state = vega20_set_mp1_state,<br>
.smu_i2c_bus_access = vega20_smu_i2c_bus_access,<br>
.set_df_cstate = vega20_set_df_cstate,<br>
+ .set_xgmi_pstate = vega20_set_xgmi_pstate,<br>
};<br>
<br>
int vega20_hwmgr_init(struct pp_hwmgr *hwmgr)<br>
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h<br>
index bd8c922dfd3e..40403bc76f1b 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h<br>
+++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h<br>
@@ -356,6 +356,7 @@ struct pp_hwmgr_func {<br>
int (*asic_reset)(struct pp_hwmgr *hwmgr, enum SMU_ASIC_RESET_MODE mode);<br>
int (*smu_i2c_bus_access)(struct pp_hwmgr *hwmgr, bool aquire);<br>
int (*set_df_cstate)(struct pp_hwmgr *hwmgr, enum pp_df_cstate state);<br>
+ int (*set_xgmi_pstate)(struct pp_hwmgr *hwmgr, uint32_t pstate);<br>
};<br>
<br>
struct pp_table_func {<br>
diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c<br>
index 7e882999abad..5877857760be 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c<br>
@@ -1463,16 +1463,13 @@ int smu_v11_0_set_fan_speed_rpm(struct smu_context *smu,<br>
return ret;<br>
}<br>
<br>
-#define XGMI_STATE_D0 1<br>
-#define XGMI_STATE_D3 0<br>
-<br>
int smu_v11_0_set_xgmi_pstate(struct smu_context *smu,<br>
uint32_t pstate)<br>
{<br>
int ret = 0;<br>
ret = smu_send_smc_msg_with_param(smu,<br>
SMU_MSG_SetXgmiMode,<br>
- pstate ? XGMI_STATE_D0 : XGMI_STATE_D3);<br>
+ pstate ? XGMI_MODE_PSTATE_D0 : XGMI_MODE_PSTATE_D3);<br>
return ret;<br>
}<br>
<br>
-- <br>
2.23.0<br>
<br>
</div>
</span></font></div>
</body>
</html>