Skip to content

Commit 989cf9a

Browse files
anshuma1jnikula
authored andcommitted
drm/i915/hdcp: Add DP HDCP2.2 timeout to read entire msg
As documented in HDCP 2.2 DP Errata spec transmitter should abort the authentication protocol in case transmitter has not received the entire {AKE_Send_Cert, AKE_Send_H_prime, AKE_Send_Paring_Info} msg within {110,7,5} miliseconds. Adding above msg timeout values and aborting the HDCP authentication in case it timedout to read entire msg. https://www.digital-cp.com/sites/default/files/HDCP%202_2_DisplayPort_Errata_v3_0.pdf v2: - Removed redundant variable msg_can_timedout. [Ankit] Cc: Ramalingam C <[email protected]> Signed-off-by: Anshuman Gupta <[email protected]> Reviewed-by: Ankit Nautiyal <[email protected]> Acked-by: Maxime Ripard <[email protected]> Signed-off-by: Jani Nikula <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 04b6603 commit 989cf9a

File tree

2 files changed

+35
-13
lines changed

2 files changed

+35
-13
lines changed

drivers/gpu/drm/i915/display/intel_dp_hdcp.c

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -294,37 +294,39 @@ struct hdcp2_dp_msg_data {
294294
bool msg_detectable;
295295
u32 timeout;
296296
u32 timeout2; /* Added for non_paired situation */
297+
/* Timeout to read entire msg */
298+
u32 msg_read_timeout;
297299
};
298300

299301
static const struct hdcp2_dp_msg_data hdcp2_dp_msg_data[] = {
300-
{ HDCP_2_2_AKE_INIT, DP_HDCP_2_2_AKE_INIT_OFFSET, false, 0, 0 },
302+
{ HDCP_2_2_AKE_INIT, DP_HDCP_2_2_AKE_INIT_OFFSET, false, 0, 0, 0},
301303
{ HDCP_2_2_AKE_SEND_CERT, DP_HDCP_2_2_AKE_SEND_CERT_OFFSET,
302-
false, HDCP_2_2_CERT_TIMEOUT_MS, 0 },
304+
false, HDCP_2_2_CERT_TIMEOUT_MS, 0, HDCP_2_2_DP_CERT_READ_TIMEOUT_MS},
303305
{ HDCP_2_2_AKE_NO_STORED_KM, DP_HDCP_2_2_AKE_NO_STORED_KM_OFFSET,
304-
false, 0, 0 },
306+
false, 0, 0, 0 },
305307
{ HDCP_2_2_AKE_STORED_KM, DP_HDCP_2_2_AKE_STORED_KM_OFFSET,
306-
false, 0, 0 },
308+
false, 0, 0, 0 },
307309
{ HDCP_2_2_AKE_SEND_HPRIME, DP_HDCP_2_2_AKE_SEND_HPRIME_OFFSET,
308310
true, HDCP_2_2_HPRIME_PAIRED_TIMEOUT_MS,
309-
HDCP_2_2_HPRIME_NO_PAIRED_TIMEOUT_MS },
311+
HDCP_2_2_HPRIME_NO_PAIRED_TIMEOUT_MS, HDCP_2_2_DP_HPRIME_READ_TIMEOUT_MS},
310312
{ HDCP_2_2_AKE_SEND_PAIRING_INFO,
311313
DP_HDCP_2_2_AKE_SEND_PAIRING_INFO_OFFSET, true,
312-
HDCP_2_2_PAIRING_TIMEOUT_MS, 0 },
313-
{ HDCP_2_2_LC_INIT, DP_HDCP_2_2_LC_INIT_OFFSET, false, 0, 0 },
314+
HDCP_2_2_PAIRING_TIMEOUT_MS, 0, HDCP_2_2_DP_PAIRING_READ_TIMEOUT_MS },
315+
{ HDCP_2_2_LC_INIT, DP_HDCP_2_2_LC_INIT_OFFSET, false, 0, 0, 0 },
314316
{ HDCP_2_2_LC_SEND_LPRIME, DP_HDCP_2_2_LC_SEND_LPRIME_OFFSET,
315-
false, HDCP_2_2_DP_LPRIME_TIMEOUT_MS, 0 },
317+
false, HDCP_2_2_DP_LPRIME_TIMEOUT_MS, 0, 0 },
316318
{ HDCP_2_2_SKE_SEND_EKS, DP_HDCP_2_2_SKE_SEND_EKS_OFFSET, false,
317-
0, 0 },
319+
0, 0, 0 },
318320
{ HDCP_2_2_REP_SEND_RECVID_LIST,
319321
DP_HDCP_2_2_REP_SEND_RECVID_LIST_OFFSET, true,
320-
HDCP_2_2_RECVID_LIST_TIMEOUT_MS, 0 },
322+
HDCP_2_2_RECVID_LIST_TIMEOUT_MS, 0, 0 },
321323
{ HDCP_2_2_REP_SEND_ACK, DP_HDCP_2_2_REP_SEND_ACK_OFFSET, false,
322-
0, 0 },
324+
0, 0, 0 },
323325
{ HDCP_2_2_REP_STREAM_MANAGE,
324326
DP_HDCP_2_2_REP_STREAM_MANAGE_OFFSET, false,
325-
0, 0 },
327+
0, 0, 0},
326328
{ HDCP_2_2_REP_STREAM_READY, DP_HDCP_2_2_REP_STREAM_READY_OFFSET,
327-
false, HDCP_2_2_STREAM_READY_TIMEOUT_MS, 0 },
329+
false, HDCP_2_2_STREAM_READY_TIMEOUT_MS, 0, 0 },
328330
/* local define to shovel this through the write_2_2 interface */
329331
#define HDCP_2_2_ERRATA_DP_STREAM_TYPE 50
330332
{ HDCP_2_2_ERRATA_DP_STREAM_TYPE,
@@ -530,6 +532,8 @@ int intel_dp_hdcp2_read_msg(struct intel_digital_port *dig_port,
530532
u8 *byte = buf;
531533
ssize_t ret, bytes_to_recv, len;
532534
const struct hdcp2_dp_msg_data *hdcp2_msg_data;
535+
ktime_t msg_end;
536+
bool msg_expired;
533537

534538
hdcp2_msg_data = get_hdcp2_dp_msg_data(msg_id);
535539
if (!hdcp2_msg_data)
@@ -556,6 +560,11 @@ int intel_dp_hdcp2_read_msg(struct intel_digital_port *dig_port,
556560
len = bytes_to_recv > DP_AUX_MAX_PAYLOAD_BYTES ?
557561
DP_AUX_MAX_PAYLOAD_BYTES : bytes_to_recv;
558562

563+
/* Entire msg read timeout since initiate of msg read */
564+
if (bytes_to_recv == size - 1 && hdcp2_msg_data->msg_read_timeout > 0)
565+
msg_end = ktime_add_ms(ktime_get_raw(),
566+
hdcp2_msg_data->msg_read_timeout);
567+
559568
ret = drm_dp_dpcd_read(&dig_port->dp.aux, offset,
560569
(void *)byte, len);
561570
if (ret < 0) {
@@ -568,6 +577,16 @@ int intel_dp_hdcp2_read_msg(struct intel_digital_port *dig_port,
568577
byte += ret;
569578
offset += ret;
570579
}
580+
581+
if (hdcp2_msg_data->msg_read_timeout > 0) {
582+
msg_expired = ktime_after(ktime_get_raw(), msg_end);
583+
if (msg_expired) {
584+
drm_dbg_kms(&i915->drm, "msg_id %d, entire msg read timeout(mSec): %d\n",
585+
msg_id, hdcp2_msg_data->msg_read_timeout);
586+
return -ETIMEDOUT;
587+
}
588+
}
589+
571590
byte = buf;
572591
*byte = msg_id;
573592

include/drm/drm_hdcp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,12 @@ struct hdcp2_rep_stream_ready {
224224

225225
/* HDCP2.2 TIMEOUTs in mSec */
226226
#define HDCP_2_2_CERT_TIMEOUT_MS 100
227+
#define HDCP_2_2_DP_CERT_READ_TIMEOUT_MS 110
227228
#define HDCP_2_2_HPRIME_NO_PAIRED_TIMEOUT_MS 1000
228229
#define HDCP_2_2_HPRIME_PAIRED_TIMEOUT_MS 200
230+
#define HDCP_2_2_DP_HPRIME_READ_TIMEOUT_MS 7
229231
#define HDCP_2_2_PAIRING_TIMEOUT_MS 200
232+
#define HDCP_2_2_DP_PAIRING_READ_TIMEOUT_MS 5
230233
#define HDCP_2_2_HDMI_LPRIME_TIMEOUT_MS 20
231234
#define HDCP_2_2_DP_LPRIME_TIMEOUT_MS 7
232235
#define HDCP_2_2_RECVID_LIST_TIMEOUT_MS 3000

0 commit comments

Comments
 (0)