]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/display: add additional hdcp traces
authorWenjing Liu <wenjing.liu@amd.com>
Thu, 2 Oct 2025 15:02:39 +0000 (11:02 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 20 Oct 2025 22:24:53 +0000 (18:24 -0400)
[why]
Current hdcp trace only tracks hdcp errors. We need to expand the trace
structure for more tracing information.

[how]
Add following traces for hdcp1:
- attempt_count
- downstream_device_count
Add following traces for hdcp2:
- attempt_count
- downstream_device_count
- hdcp1_device_downstream
- hdcp2_legacy_device_downstream

Reviewed-by: Sung Lee <sung.lee@amd.com>
Signed-off-by: Wenjing Liu <wenjing.liu@amd.com>
Signed-off-by: Aurabindo Pillai <aurabindo.pillai@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/hdcp1_execution.c
drivers/gpu/drm/amd/display/modules/hdcp/hdcp2_execution.c
drivers/gpu/drm/amd/display/modules/hdcp/hdcp_log.h
drivers/gpu/drm/amd/display/modules/inc/mod_hdcp.h

index c760216a6240506c6f0605d107ada067df766df5..ca402ddcdacc821fb4dfabc2dcbdd7120e646866 100644 (file)
@@ -354,7 +354,7 @@ enum mod_hdcp_status mod_hdcp_add_display(struct mod_hdcp *hdcp,
        /* reset retry counters */
        reset_retry_counts(hdcp);
 
-       /* reset error trace */
+       /* reset trace */
        memset(&hdcp->connection.trace, 0, sizeof(hdcp->connection.trace));
 
        /* add display to connection */
@@ -400,7 +400,7 @@ enum mod_hdcp_status mod_hdcp_remove_display(struct mod_hdcp *hdcp,
        /* clear retry counters */
        reset_retry_counts(hdcp);
 
-       /* reset error trace */
+       /* reset trace */
        memset(&hdcp->connection.trace, 0, sizeof(hdcp->connection.trace));
 
        /* remove display */
@@ -464,7 +464,7 @@ enum mod_hdcp_status mod_hdcp_update_display(struct mod_hdcp *hdcp,
        /* clear retry counters */
        reset_retry_counts(hdcp);
 
-       /* reset error trace */
+       /* reset trace */
        memset(&hdcp->connection.trace, 0, sizeof(hdcp->connection.trace));
 
        /* set new adjustment */
index a37634942b075a58ee0f5b23860efb671501d12a..b883d626f1c372377341eba0b19c1b47873797cf 100644 (file)
@@ -508,7 +508,7 @@ static inline void set_auth_complete(struct mod_hdcp *hdcp,
                struct mod_hdcp_output *output)
 {
        output->auth_complete = 1;
-       mod_hdcp_log_ddc_trace(hdcp);
+       HDCP_AUTH_COMPLETE_TRACE(hdcp);
 }
 
 /* connection topology helpers */
index 8bc377560787bf8dd7291452f5622f1a7f0000be..1bbd728d4345f2d1daf419efb9ac943cab9c02c2 100644 (file)
@@ -29,6 +29,7 @@ static inline enum mod_hdcp_status validate_bksv(struct mod_hdcp *hdcp)
 {
        uint64_t n = 0;
        uint8_t count = 0;
+       enum mod_hdcp_status status;
        u8 bksv[sizeof(n)] = { };
 
        memcpy(bksv, hdcp->auth.msg.hdcp1.bksv, sizeof(hdcp->auth.msg.hdcp1.bksv));
@@ -38,8 +39,14 @@ static inline enum mod_hdcp_status validate_bksv(struct mod_hdcp *hdcp)
                count++;
                n &= (n - 1);
        }
-       return (count == 20) ? MOD_HDCP_STATUS_SUCCESS :
-                       MOD_HDCP_STATUS_HDCP1_INVALID_BKSV;
+
+       if (count == 20) {
+               hdcp->connection.trace.hdcp1.attempt_count++;
+               status = MOD_HDCP_STATUS_SUCCESS;
+       } else {
+               status = MOD_HDCP_STATUS_HDCP1_INVALID_BKSV;
+       }
+       return status;
 }
 
 static inline enum mod_hdcp_status check_ksv_ready(struct mod_hdcp *hdcp)
@@ -135,6 +142,8 @@ static inline enum mod_hdcp_status check_device_count(struct mod_hdcp *hdcp)
        if (get_device_count(hdcp) == 0)
                return MOD_HDCP_STATUS_HDCP1_DEVICE_COUNT_MISMATCH_FAILURE;
 
+       hdcp->connection.trace.hdcp1.downstream_device_count = get_device_count(hdcp);
+
        /* Some MST display may choose to report the internal panel as an HDCP RX.
         * To update this condition with 1(because the immediate repeater's internal
         * panel is possibly not included in DEVICE_COUNT) + get_device_count(hdcp).
index bb8ae80b37f850cc4c9102ce253a4bfdd74bda86..5628f0ef73fd1edd79f06fa526ceed36d3499673 100644 (file)
@@ -48,6 +48,7 @@ static inline enum mod_hdcp_status check_receiver_id_list_ready(struct mod_hdcp
 static inline enum mod_hdcp_status check_hdcp2_capable(struct mod_hdcp *hdcp)
 {
        enum mod_hdcp_status status;
+       struct mod_hdcp_trace *trace = &hdcp->connection.trace;
 
        if (is_dp_hdcp(hdcp))
                status = (hdcp->auth.msg.hdcp2.rxcaps_dp[0] == HDCP_2_2_RX_CAPS_VERSION_VAL) &&
@@ -55,9 +56,14 @@ static inline enum mod_hdcp_status check_hdcp2_capable(struct mod_hdcp *hdcp)
                                MOD_HDCP_STATUS_SUCCESS :
                                MOD_HDCP_STATUS_HDCP2_NOT_CAPABLE;
        else
-               status = (hdcp->auth.msg.hdcp2.hdcp2version_hdmi & HDCP_2_2_HDMI_SUPPORT_MASK) ?
-                               MOD_HDCP_STATUS_SUCCESS :
-                               MOD_HDCP_STATUS_HDCP2_NOT_CAPABLE;
+               status = (hdcp->auth.msg.hdcp2.hdcp2version_hdmi
+                                & HDCP_2_2_HDMI_SUPPORT_MASK)
+                               ? MOD_HDCP_STATUS_SUCCESS
+                               : MOD_HDCP_STATUS_HDCP2_NOT_CAPABLE;
+
+       if (status == MOD_HDCP_STATUS_SUCCESS)
+               trace->hdcp2.attempt_count++;
+
        return status;
 }
 
@@ -201,10 +207,17 @@ static inline uint8_t get_device_count(struct mod_hdcp *hdcp)
 
 static enum mod_hdcp_status check_device_count(struct mod_hdcp *hdcp)
 {
+       struct mod_hdcp_trace *trace = &hdcp->connection.trace;
+
        /* Avoid device count == 0 to do authentication */
        if (get_device_count(hdcp) == 0)
                return MOD_HDCP_STATUS_HDCP1_DEVICE_COUNT_MISMATCH_FAILURE;
 
+       trace->hdcp2.downstream_device_count = get_device_count(hdcp);
+       trace->hdcp2.hdcp1_device_downstream =
+                       HDCP_2_2_HDCP1_DEVICE_CONNECTED(hdcp->auth.msg.hdcp2.rx_id_list[2]);
+       trace->hdcp2.hdcp2_legacy_device_downstream =
+                       HDCP_2_2_HDCP_2_0_REP_CONNECTED(hdcp->auth.msg.hdcp2.rx_id_list[2]);
        /* Some MST display may choose to report the internal panel as an HDCP RX.   */
        /* To update this condition with 1(because the immediate repeater's internal */
        /* panel is possibly not included in DEVICE_COUNT) + get_device_count(hdcp). */
index 1d83c1b9da10461b3f44b06608ceb1f07638669f..26553aa4c5cae2f5184fe6094aa8ca10367a2983 100644 (file)
@@ -31,6 +31,7 @@
 #define HDCP_LOG_FSM(hdcp, ...) DRM_DEBUG_KMS(__VA_ARGS__)
 #define HDCP_LOG_TOP(hdcp, ...) pr_debug("[HDCP_TOP]:"__VA_ARGS__)
 #define HDCP_LOG_DDC(hdcp, ...) pr_debug("[HDCP_DDC]:"__VA_ARGS__)
+#define HDCP_LOG_TRA(hdcp) do {} while (0)
 
 /* default logs */
 #define HDCP_ERROR_TRACE(hdcp, status) \
                HDCP_LOG_TOP(hdcp, "[Link %d] %s display %d", hdcp->config.index, __func__, i); \
 } while (0)
 
+#define HDCP_AUTH_COMPLETE_TRACE(hdcp) do { \
+               mod_hdcp_log_ddc_trace(hdcp); \
+               HDCP_LOG_TRA(hdcp); \
+} while (0)
+
 #endif // MOD_HDCP_LOG_H_
index b51ddf2846df8e2ccb9fac10ad1cb627fd7ae718..46e52fb3a1180913897888cf3a36675b94da6de5 100644 (file)
@@ -230,9 +230,23 @@ struct mod_hdcp_error {
        uint8_t state_id;
 };
 
+struct mod_hdcp1_trace {
+       uint8_t attempt_count;
+       uint8_t downstream_device_count;
+};
+
+struct mod_hdcp2_trace {
+       uint8_t attempt_count;
+       uint8_t downstream_device_count;
+       uint8_t hdcp1_device_downstream;
+       uint8_t hdcp2_legacy_device_downstream;
+};
+
 struct mod_hdcp_trace {
        struct mod_hdcp_error errors[MAX_NUM_OF_ERROR_TRACE];
        uint8_t error_count;
+       struct mod_hdcp1_trace hdcp1;
+       struct mod_hdcp2_trace hdcp2;
 };
 
 enum mod_hdcp_encryption_status {