drm/amd/display: Move mod_hdcp_displays to mod_hdcp struct
authorIsabel Zhang <isabel.zhang@amd.com>
Fri, 14 Feb 2020 21:32:35 +0000 (16:32 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 5 Mar 2020 05:28:50 +0000 (00:28 -0500)
[Why]
Reset connection is called before remove display in mod_hdcp. When
remove display is called, the display structure has been zeroed from
reset connection. Since no displays can be found, remove display does
not properly reset the hardware. This causes validation errors when
another display is plugged into a different port afterwards.

[How]
Moved displays structure out of connections structure. Displays
structure is now directly within mod_hdcp. Displays is no longer zeroed
when reset connection is called.

Signed-off-by: Isabel Zhang <isabel.zhang@amd.com>
Reviewed-by: Wenjing Liu <Wenjing.Liu@amd.com>
Acked-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Acked-by: Tony Cheng <Tony.Cheng@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/modules/hdcp/hdcp.c
drivers/gpu/drm/amd/display/modules/hdcp/hdcp.h
drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c

index 83eaec4c6ad71fbd2999add781db63d9c5e3fd49..bcba93d3b195d066c8339d53f4ee09eb1fd7a520 100644 (file)
@@ -52,8 +52,8 @@ static uint8_t is_cp_desired_hdcp1(struct mod_hdcp *hdcp)
         * hdcp is not desired
         */
        for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) {
-               if (hdcp->connection.displays[i].state != MOD_HDCP_DISPLAY_INACTIVE &&
-                               !hdcp->connection.displays[i].adjust.disable) {
+               if (hdcp->displays[i].state != MOD_HDCP_DISPLAY_INACTIVE &&
+                               !hdcp->displays[i].adjust.disable) {
                        is_auth_needed = 1;
                        break;
                }
@@ -73,8 +73,8 @@ static uint8_t is_cp_desired_hdcp2(struct mod_hdcp *hdcp)
         * hdcp is not desired
         */
        for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) {
-               if (hdcp->connection.displays[i].state != MOD_HDCP_DISPLAY_INACTIVE &&
-                               !hdcp->connection.displays[i].adjust.disable) {
+               if (hdcp->displays[i].state != MOD_HDCP_DISPLAY_INACTIVE &&
+                               !hdcp->displays[i].adjust.disable) {
                        is_auth_needed = 1;
                        break;
                }
@@ -373,8 +373,8 @@ enum mod_hdcp_status mod_hdcp_remove_display(struct mod_hdcp *hdcp,
                goto out;
        display->state = MOD_HDCP_DISPLAY_INACTIVE;
 
-       /* request authentication for remaining displays*/
-       if (get_active_display_count(hdcp) > 0)
+       /* request authentication when connection is not reset */
+       if (current_state(hdcp) != HDCP_UNINITIALIZED)
                callback_in_ms(hdcp->connection.link.adjust.auth_delay * 1000,
                                output);
 out:
index b09d2f5502b38af1a30ac5c18c1aa2a87c0093e3..77fdcec4263e9984f4f3abffa64ad7985d2a10a0 100644 (file)
@@ -165,7 +165,6 @@ struct mod_hdcp_auth_counters {
 /* contains values per connection */
 struct mod_hdcp_connection {
        struct mod_hdcp_link link;
-       struct mod_hdcp_display displays[MAX_NUM_OF_DISPLAYS];
        uint8_t is_repeater;
        uint8_t is_km_stored;
        uint8_t is_hdcp1_revoked;
@@ -201,6 +200,8 @@ struct mod_hdcp {
        struct mod_hdcp_config config;
        /* per connection */
        struct mod_hdcp_connection connection;
+       /* per displays */
+       struct mod_hdcp_display displays[MAX_NUM_OF_DISPLAYS];
        /* per authentication attempt */
        struct mod_hdcp_authentication auth;
        /* per state in an authentication */
@@ -518,7 +519,7 @@ static inline uint8_t get_active_display_count(struct mod_hdcp *hdcp)
        uint8_t i;
 
        for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)
-               if (is_display_active(&hdcp->connection.displays[i]))
+               if (is_display_active(&hdcp->displays[i]))
                        added_count++;
        return added_count;
 }
@@ -529,7 +530,7 @@ static inline uint8_t get_added_display_count(struct mod_hdcp *hdcp)
        uint8_t i;
 
        for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)
-               if (is_display_added(&hdcp->connection.displays[i]))
+               if (is_display_added(&hdcp->displays[i]))
                        added_count++;
        return added_count;
 }
@@ -541,8 +542,8 @@ static inline struct mod_hdcp_display *get_first_added_display(
        struct mod_hdcp_display *display = NULL;
 
        for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)
-               if (is_display_added(&hdcp->connection.displays[i])) {
-                       display = &hdcp->connection.displays[i];
+               if (is_display_added(&hdcp->displays[i])) {
+                       display = &hdcp->displays[i];
                        break;
                }
        return display;
@@ -555,9 +556,9 @@ static inline struct mod_hdcp_display *get_active_display_at_index(
        struct mod_hdcp_display *display = NULL;
 
        for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)
-               if (hdcp->connection.displays[i].index == index &&
-                               is_display_active(&hdcp->connection.displays[i])) {
-                       display = &hdcp->connection.displays[i];
+               if (hdcp->displays[i].index == index &&
+                               is_display_active(&hdcp->displays[i])) {
+                       display = &hdcp->displays[i];
                        break;
                }
        return display;
@@ -570,8 +571,8 @@ static inline struct mod_hdcp_display *get_empty_display_container(
        struct mod_hdcp_display *display = NULL;
 
        for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)
-               if (!is_display_active(&hdcp->connection.displays[i])) {
-                       display = &hdcp->connection.displays[i];
+               if (!is_display_active(&hdcp->displays[i])) {
+                       display = &hdcp->displays[i];
                        break;
                }
        return display;
index d9cb2383d6de7cdce593753cdc6742ac08bd483a..b87e9d2862bc71840b2abaee8338e99cd4216b3b 100644 (file)
@@ -177,11 +177,11 @@ enum mod_hdcp_status mod_hdcp_hdcp1_destroy_session(struct mod_hdcp *hdcp)
        HDCP_TOP_HDCP1_DESTROY_SESSION_TRACE(hdcp);
        for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)
                if (is_display_encryption_enabled(
-                               &hdcp->connection.displays[i])) {
-                       hdcp->connection.displays[i].state =
+                               &hdcp->displays[i])) {
+                       hdcp->displays[i].state =
                                        MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED;
                        HDCP_HDCP1_DISABLED_TRACE(hdcp,
-                                       hdcp->connection.displays[i].index);
+                                       hdcp->displays[i].index);
                }
 
        return MOD_HDCP_STATUS_SUCCESS;
@@ -301,14 +301,14 @@ enum mod_hdcp_status mod_hdcp_hdcp1_enable_dp_stream_encryption(struct mod_hdcp
 
        for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) {
 
-               if (hdcp->connection.displays[i].state != MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED ||
-                   hdcp->connection.displays[i].adjust.disable)
+               if (hdcp->displays[i].state != MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED ||
+                   hdcp->displays[i].adjust.disable)
                        continue;
 
                memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));
 
                hdcp_cmd->in_msg.hdcp1_enable_dp_stream_encryption.session_handle = hdcp->auth.id;
-               hdcp_cmd->in_msg.hdcp1_enable_dp_stream_encryption.display_handle = hdcp->connection.displays[i].index;
+               hdcp_cmd->in_msg.hdcp1_enable_dp_stream_encryption.display_handle = hdcp->displays[i].index;
                hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP1_ENABLE_DP_STREAM_ENCRYPTION;
 
                psp_hdcp_invoke(psp, hdcp_cmd->cmd_id);
@@ -316,8 +316,8 @@ enum mod_hdcp_status mod_hdcp_hdcp1_enable_dp_stream_encryption(struct mod_hdcp
                if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)
                        return MOD_HDCP_STATUS_HDCP1_ENABLE_STREAM_ENCRYPTION_FAILURE;
 
-               hdcp->connection.displays[i].state = MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED;
-               HDCP_HDCP1_ENABLED_TRACE(hdcp, hdcp->connection.displays[i].index);
+               hdcp->displays[i].state = MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED;
+               HDCP_HDCP1_ENABLED_TRACE(hdcp, hdcp->displays[i].index);
        }
 
        return MOD_HDCP_STATUS_SUCCESS;
@@ -421,11 +421,11 @@ enum mod_hdcp_status mod_hdcp_hdcp2_destroy_session(struct mod_hdcp *hdcp)
        HDCP_TOP_HDCP2_DESTROY_SESSION_TRACE(hdcp);
        for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)
                if (is_display_encryption_enabled(
-                               &hdcp->connection.displays[i])) {
-                       hdcp->connection.displays[i].state =
+                               &hdcp->displays[i])) {
+                       hdcp->displays[i].state =
                                        MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED;
                        HDCP_HDCP2_DISABLED_TRACE(hdcp,
-                                       hdcp->connection.displays[i].index);
+                                       hdcp->displays[i].index);
                }
 
        return MOD_HDCP_STATUS_SUCCESS;
@@ -747,10 +747,10 @@ enum mod_hdcp_status mod_hdcp_hdcp2_enable_dp_stream_encryption(struct mod_hdcp
 
 
        for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) {
-               if (hdcp->connection.displays[i].state != MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED ||
-                   hdcp->connection.displays[i].adjust.disable)
+               if (hdcp->displays[i].state != MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED ||
+                   hdcp->displays[i].adjust.disable)
                        continue;
-               hdcp_cmd->in_msg.hdcp2_enable_dp_stream_encryption.display_handle = hdcp->connection.displays[i].index;
+               hdcp_cmd->in_msg.hdcp2_enable_dp_stream_encryption.display_handle = hdcp->displays[i].index;
                hdcp_cmd->in_msg.hdcp2_enable_dp_stream_encryption.session_handle = hdcp->auth.id;
 
                hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_ENABLE_DP_STREAM_ENCRYPTION;
@@ -759,8 +759,8 @@ enum mod_hdcp_status mod_hdcp_hdcp2_enable_dp_stream_encryption(struct mod_hdcp
                if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)
                        break;
 
-               hdcp->connection.displays[i].state = MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED;
-               HDCP_HDCP2_ENABLED_TRACE(hdcp, hdcp->connection.displays[i].index);
+               hdcp->displays[i].state = MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED;
+               HDCP_HDCP2_ENABLED_TRACE(hdcp, hdcp->displays[i].index);
        }
 
        return (hdcp_cmd->hdcp_status == TA_HDCP_STATUS__SUCCESS) ? MOD_HDCP_STATUS_SUCCESS