<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">
<p style="font-family:Arial;font-size:11pt;color:#0078D7;margin:5pt;" align="Left">
[AMD Official Use Only - Internal Distribution Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Thank you very much for the review!<br>
</div>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
--</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);">
Thanks & Regards,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Aurabindo Pillai<br>
</div>
</div>
</div>
</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> Kazlauskas, Nicholas <Nicholas.Kazlauskas@amd.com><br>
<b>Sent:</b> Friday, November 27, 2020 10:44 AM<br>
<b>To:</b> Pillai, Aurabindo <Aurabindo.Pillai@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Wentland, Harry <Harry.Wentland@amd.com>; Lakha, Bhawanpreet <Bhawanpreet.Lakha@amd.com>; Brol, Eryk <Eryk.Brol@amd.com><br>
<b>Subject:</b> Re: [PATCH v3] drm/amd/display: turn DPMS off on mst connector unplug</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">On 2020-11-26 7:18 p.m., Aurabindo Pillai wrote:<br>
> [Why&How]<br>
> <br>
> Set dpms off on the MST connector that was unplugged, for the side effect of<br>
> releasing some references held through deallocation of mst payload.<br>
<br>
Applies to non-MST now too, so the description and title should be updated.<br>
<br>
> <br>
> Signed-off-by: Aurabindo Pillai <aurabindo.pillai@amd.com><br>
> Signed-off-by: Eryk Brol <eryk.brol@amd.com><br>
> ---<br>
> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 31 ++++++++++++++++++-<br>
> drivers/gpu/drm/amd/display/dc/core/dc.c | 13 ++++++++<br>
> drivers/gpu/drm/amd/display/dc/dc_stream.h | 1 +<br>
> 3 files changed, 44 insertions(+), 1 deletion(-)<br>
> <br>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
> index e213246e3f04..9966679d29e7 100644<br>
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
> @@ -1984,6 +1984,32 @@ static void dm_gpureset_commit_state(struct dc_state *dc_state,<br>
> return;<br>
> }<br>
> <br>
> +static void dm_set_dpms_off(struct dc_link *link)<br>
> +{<br>
> + struct dc_stream_state *stream_state;<br>
> + struct amdgpu_dm_connector *aconnector = link->priv;<br>
> + struct amdgpu_device *adev = drm_to_adev(aconnector->base.dev);<br>
> + struct dc_stream_update stream_update = {0};<br>
<br>
Please use a memset instead of a zero initializer here. Some compilers <br>
complain about that.<br>
<br>
> + bool dpms_off = true;<br>
> +<br>
> + stream_update.dpms_off = &dpms_off;<br>
> +<br>
> + mutex_lock(&adev->dm.dc_lock);<br>
> + stream_state = dc_stream_find_from_link(link);<br>
> +<br>
> + if (stream_state == NULL) {<br>
> + dm_error("Error finding stream state associated with link!\n");<br>
<br>
This shouldn't be using a dm_error print here. a DRM_DEBUG_DRIVER would <br>
be better suited.<br>
<br>
With these three items fixed the v4 of this patch will be:<br>
<br>
Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com><br>
<br>
Regards,<br>
Nicholas Kazlauskas<br>
<br>
> + mutex_unlock(&adev->dm.dc_lock);<br>
> + return;<br>
> + }<br>
> +<br>
> + stream_update.stream = stream_state;<br>
> + dc_commit_updates_for_stream(stream_state->ctx->dc, NULL, 0,<br>
> + stream_state, &stream_update,<br>
> + stream_state->ctx->dc->current_state);<br>
> + mutex_unlock(&adev->dm.dc_lock);<br>
> +}<br>
> +<br>
> static int dm_resume(void *handle)<br>
> {<br>
> struct amdgpu_device *adev = handle;<br>
> @@ -2434,8 +2460,11 @@ static void handle_hpd_irq(void *param)<br>
> drm_kms_helper_hotplug_event(dev);<br>
> <br>
> } else if (dc_link_detect(aconnector->dc_link, DETECT_REASON_HPD)) {<br>
> - amdgpu_dm_update_connector_after_detect(aconnector);<br>
> + if (new_connection_type == dc_connection_none &&<br>
> + aconnector->dc_link->type == dc_connection_none)<br>
> + dm_set_dpms_off(aconnector->dc_link);<br>
> <br>
> + amdgpu_dm_update_connector_after_detect(aconnector);<br>
> <br>
> drm_modeset_lock_all(dev);<br>
> dm_restore_drm_connector_state(dev, connector);<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c<br>
> index 903353389edb..58eb0d69873a 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/core/dc.c<br>
> +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c<br>
> @@ -2798,6 +2798,19 @@ struct dc_stream_state *dc_get_stream_at_index(struct dc *dc, uint8_t i)<br>
> return NULL;<br>
> }<br>
> <br>
> +struct dc_stream_state *dc_stream_find_from_link(const struct dc_link *link)<br>
> +{<br>
> + uint8_t i;<br>
> + struct dc_context *ctx = link->ctx;<br>
> +<br>
> + for (i = 0; i < ctx->dc->current_state->stream_count; i++) {<br>
> + if (ctx->dc->current_state->streams[i]->link == link)<br>
> + return ctx->dc->current_state->streams[i];<br>
> + }<br>
> +<br>
> + return NULL;<br>
> +}<br>
> +<br>
> enum dc_irq_source dc_interrupt_to_irq_source(<br>
> struct dc *dc,<br>
> uint32_t src_id,<br>
> diff --git a/drivers/gpu/drm/amd/display/dc/dc_stream.h b/drivers/gpu/drm/amd/display/dc/dc_stream.h<br>
> index bf090afc2f70..b7910976b81a 100644<br>
> --- a/drivers/gpu/drm/amd/display/dc/dc_stream.h<br>
> +++ b/drivers/gpu/drm/amd/display/dc/dc_stream.h<br>
> @@ -292,6 +292,7 @@ void dc_stream_log(const struct dc *dc, const struct dc_stream_state *stream);<br>
> <br>
> uint8_t dc_get_current_stream_count(struct dc *dc);<br>
> struct dc_stream_state *dc_get_stream_at_index(struct dc *dc, uint8_t i);<br>
> +struct dc_stream_state *dc_stream_find_from_link(const struct dc_link *link);<br>
> <br>
> /*<br>
> * Return the current frame counter.<br>
> <br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>