Commit 8c6a0234 authored by Wenjing Liu's avatar Wenjing Liu Committed by Alex Deucher
Browse files

drm/amd/display: add additional hdcp traces



[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: default avatarSung Lee <sung.lee@amd.com>
Signed-off-by: default avatarWenjing Liu <wenjing.liu@amd.com>
Signed-off-by: default avatarAurabindo Pillai <aurabindo.pillai@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent bf95cf7f
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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 */
+1 −1
Original line number Diff line number Diff line
@@ -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 */
+11 −2
Original line number Diff line number Diff line
@@ -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).
+16 −3
Original line number Diff line number Diff line
@@ -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). */
+6 −0
Original line number Diff line number Diff line
@@ -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) \
@@ -131,4 +132,9 @@
		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_
Loading