[AMD Official Use Only - Internal Distribution Only]


This patch introduces a null pointer deref on MST hotplug, so this shall be dropped.

--

Thanks & Regards,
Aurabindo Pillai

From: Aurabindo Pillai <aurabindo.pillai@amd.com>
Sent: Friday, April 16, 2021 10:34 AM
To: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>
Cc: Wentland, Harry <Harry.Wentland@amd.com>; Li, Sun peng (Leo) <Sunpeng.Li@amd.com>; Lakha, Bhawanpreet <Bhawanpreet.Lakha@amd.com>; Siqueira, Rodrigo <Rodrigo.Siqueira@amd.com>; Pillai, Aurabindo <Aurabindo.Pillai@amd.com>; Zhuo, Qingqing <Qingqing.Zhuo@amd.com>; Brol, Eryk <Eryk.Brol@amd.com>; R, Bindu <Bindu.R@amd.com>; Jacob, Anson <Anson.Jacob@amd.com>; Zhang, Dingchen (David) <Dingchen.Zhang@amd.com>; Zhang, Dingchen (David) <Dingchen.Zhang@amd.com>
Subject: [PATCH 13/19] drm/amd/display: force CP to DESIRED when removing display.
 
From: "Dingchen (David) Zhang" <dingchen.zhang@amd.com>

[why]
It is possible that the commit from userspace to cause link stream
disable and hdcp auth reset when the HDCP has been enabled at the
moment. We'd expect the CP prop back to DESIRED from ENABLED.

[how]
In the helper of hdcp display removal, we check and change the CP prop
to DESIRED if at the moment CP is ENABLED before the auth reset and
removal of linked list element.

Signed-off-by: Dingchen (David) Zhang <dingchen.zhang@amd.com>
Reviewed-by: Dingchen Zhang <Dingchen.Zhang@amd.com>
Acked-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c  | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
index 616f5b1ea3a8..50f6b3a86931 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
@@ -160,6 +160,7 @@ static void link_lock(struct hdcp_workqueue *work, bool lock)
                         mutex_unlock(&work[i].mutex);
         }
 }
+
 void hdcp_update_display(struct hdcp_workqueue *hdcp_work,
                          unsigned int link_index,
                          struct amdgpu_dm_connector *aconnector,
@@ -222,10 +223,22 @@ static void hdcp_remove_display(struct hdcp_workqueue *hdcp_work,
                          struct amdgpu_dm_connector *aconnector)
 {
         struct hdcp_workqueue *hdcp_w = &hdcp_work[link_index];
+       struct drm_connector_state *conn_state = aconnector->base.state;
 
         mutex_lock(&hdcp_w->mutex);
         hdcp_w->aconnector = aconnector;
 
+       /* the removal of display will invoke auth reset -> hdcp destroy and
+        * we'd expect the CP prop changed back to DESIRED if at the time ENABLED.
+        * the CP prop change should occur before the element removed from linked list.
+        */
+       if (conn_state && conn_state->content_protection == DRM_MODE_CONTENT_PROTECTION_ENABLED) {
+               conn_state->content_protection = DRM_MODE_CONTENT_PROTECTION_DESIRED;
+
+               pr_debug("[HDCP_DM] display %d, CP 2 -> 1, type %u, DPMS %u\n",
+                        aconnector->base.index, conn_state->hdcp_content_type, aconnector->base.dpms);
+       }
+
         mod_hdcp_remove_display(&hdcp_w->hdcp, aconnector->base.index, &hdcp_w->output);
 
         process_output(hdcp_w);
--
2.31.1