<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);">
We should probably also add the callbacks for set_mp1_state like we have for the older powerplay code so we properly send the SMU shutdown or reset message on GPU reset and driver unload.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Alex</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<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> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Quan, Evan <Evan.Quan@amd.com><br>
<b>Sent:</b> Monday, September 2, 2019 11:44 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Li, Candice <Candice.Li@amd.com>; Gui, Jack <Jack.Gui@amd.com>; Quan, Evan <Evan.Quan@amd.com><br>
<b>Subject:</b> [PATCH] drm/amd/powerplay: do proper cleanups on hw_fini</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">These are needed for smu_reset support.<br>
<br>
Change-Id: If29ede4b99758adb08fd4e16665f44fd893ec99b<br>
Signed-off-by: Evan Quan <evan.quan@amd.com><br>
---<br>
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 17 +++++++++++++++++<br>
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++<br>
drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 10 ++++++++++<br>
3 files changed, 30 insertions(+)<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c<br>
index d5ee13a78eb7..3cf8d944f890 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c<br>
@@ -1286,6 +1286,11 @@ static int smu_hw_init(void *handle)<br>
return ret;<br>
}<br>
<br>
+static int smu_stop_dpms(struct smu_context *smu)<br>
+{<br>
+ return smu_send_smc_msg(smu, SMU_MSG_DisableAllSmuFeatures);<br>
+}<br>
+<br>
static int smu_hw_fini(void *handle)<br>
{<br>
struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
@@ -1298,6 +1303,18 @@ static int smu_hw_fini(void *handle)<br>
smu_powergate_vcn(&adev->smu, true);<br>
}<br>
<br>
+ ret = smu_stop_thermal_control(smu);<br>
+ if (ret) {<br>
+ pr_warn("Fail to stop thermal control!\n");<br>
+ return ret;<br>
+ }<br>
+<br>
+ ret = smu_stop_dpms(smu);<br>
+ if (ret) {<br>
+ pr_warn("Fail to stop Dpms!\n");<br>
+ return ret;<br>
+ }<br>
+<br>
kfree(table_context->driver_pptable);<br>
table_context->driver_pptable = NULL;<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h<br>
index b19224cb6d6d..8e4b0ad24712 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h<br>
+++ b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h<br>
@@ -498,6 +498,7 @@ struct smu_funcs<br>
int (*get_current_clk_freq)(struct smu_context *smu, enum smu_clk_type clk_id, uint32_t *value);<br>
int (*init_max_sustainable_clocks)(struct smu_context *smu);<br>
int (*start_thermal_control)(struct smu_context *smu);<br>
+ int (*stop_thermal_control)(struct smu_context *smu);<br>
int (*read_sensor)(struct smu_context *smu, enum amd_pp_sensors sensor,<br>
void *data, uint32_t *size);<br>
int (*set_deep_sleep_dcefclk)(struct smu_context *smu, uint32_t clk);<br>
@@ -647,6 +648,8 @@ struct smu_funcs<br>
((smu)->ppt_funcs->set_thermal_fan_table ? (smu)->ppt_funcs->set_thermal_fan_table((smu)) : 0)<br>
#define smu_start_thermal_control(smu) \<br>
((smu)->funcs->start_thermal_control? (smu)->funcs->start_thermal_control((smu)) : 0)<br>
+#define smu_stop_thermal_control(smu) \<br>
+ ((smu)->funcs->stop_thermal_control? (smu)->funcs->stop_thermal_control((smu)) : 0)<br>
#define smu_read_sensor(smu, sensor, data, size) \<br>
((smu)->ppt_funcs->read_sensor? (smu)->ppt_funcs->read_sensor((smu), (sensor), (data), (size)) : 0)<br>
#define smu_smc_read_sensor(smu, sensor, data, size) \<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 db5e94ce54af..1a38af84394e 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c<br>
@@ -1209,6 +1209,15 @@ static int smu_v11_0_start_thermal_control(struct smu_context *smu)<br>
return ret;<br>
}<br>
<br>
+static int smu_v11_0_stop_thermal_control(struct smu_context *smu)<br>
+{<br>
+ struct amdgpu_device *adev = smu->adev;<br>
+<br>
+ WREG32_SOC15(THM, 0, mmTHM_THERMAL_INT_ENA, 0);<br>
+<br>
+ return 0;<br>
+}<br>
+<br>
static uint16_t convert_to_vddc(uint8_t vid)<br>
{<br>
return (uint16_t) ((6200 - (vid * 25)) / SMU11_VOLTAGE_SCALE);<br>
@@ -1783,6 +1792,7 @@ static const struct smu_funcs smu_v11_0_funcs = {<br>
.get_current_clk_freq = smu_v11_0_get_current_clk_freq,<br>
.init_max_sustainable_clocks = smu_v11_0_init_max_sustainable_clocks,<br>
.start_thermal_control = smu_v11_0_start_thermal_control,<br>
+ .stop_thermal_control = smu_v11_0_stop_thermal_control,<br>
.read_sensor = smu_v11_0_read_sensor,<br>
.set_deep_sleep_dcefclk = smu_v11_0_set_deep_sleep_dcefclk,<br>
.display_clock_voltage_request = smu_v11_0_display_clock_voltage_request,<br>
-- <br>
2.23.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></div>
</span></font></div>
</body>
</html>