<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#0078D7;margin:15pt;" align="Left">
[AMD Official Use Only - Internal Distribution Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<font size="2"><span style="font-size:11pt">mod_hdcp_hdcp2_get_link_encryption_status</span></font>() isn't being used, should probably remove it in a followup patch<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Kazlauskas, Nicholas <Nicholas.Kazlauskas@amd.com><br>
<b>Sent:</b> March 31, 2020 2:03 PM<br>
<b>To:</b> Alex Deucher <alexdeucher@gmail.com>; Lakha, Bhawanpreet <Bhawanpreet.Lakha@amd.com><br>
<b>Cc:</b> Deucher, Alexander <Alexander.Deucher@amd.com>; amd-gfx list <amd-gfx@lists.freedesktop.org>; Zhang, Hawking <Hawking.Zhang@amd.com><br>
<b>Subject:</b> Re: [PATCH] drm/amd/display: Guard calls to hdcp_ta and dtm_ta</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">On 2020-03-31 1:37 p.m., Alex Deucher wrote:<br>
> On Mon, Mar 30, 2020 at 6:36 PM Bhawanpreet Lakha<br>
> <Bhawanpreet.Lakha@amd.com> wrote:<br>
>><br>
>> [Why]<br>
>> The buffer used when calling psp is a shared buffer. If we have multiple calls<br>
>> at the same time we can overwrite the buffer.<br>
>><br>
>> [How]<br>
>> Add mutex to guard the shared buffer.<br>
>><br>
>> Signed-off-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com><br>
> <br>
> Acked-by: Alex Deucher <alexander.deucher@amd.com><br>
<br>
One comment inline:<br>
<br>
> <br>
>> ---<br>
>> drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 2 +<br>
>> drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 2 +<br>
>> .../drm/amd/display/modules/hdcp/hdcp_psp.c | 420 +++++++++++-------<br>
>> 3 files changed, 257 insertions(+), 167 deletions(-)<br>
>><br>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
>> index dbaeffc4431e..9d587bc27663 100644<br>
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
>> @@ -888,6 +888,7 @@ static int psp_hdcp_load(struct psp_context *psp)<br>
>> if (!ret) {<br>
>> psp->hdcp_context.hdcp_initialized = true;<br>
>> psp->hdcp_context.session_id = cmd->resp.session_id;<br>
>> + mutex_init(&psp->hdcp_context.mutex);<br>
>> }<br>
>><br>
>> kfree(cmd);<br>
>> @@ -1033,6 +1034,7 @@ static int psp_dtm_load(struct psp_context *psp)<br>
>> if (!ret) {<br>
>> psp->dtm_context.dtm_initialized = true;<br>
>> psp->dtm_context.session_id = cmd->resp.session_id;<br>
>> + mutex_init(&psp->dtm_context.mutex);<br>
>> }<br>
>><br>
>> kfree(cmd);<br>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h<br>
>> index 297435c0c7c1..6a717fd5efc7 100644<br>
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h<br>
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h<br>
>> @@ -161,6 +161,7 @@ struct psp_hdcp_context {<br>
>> struct amdgpu_bo *hdcp_shared_bo;<br>
>> uint64_t hdcp_shared_mc_addr;<br>
>> void *hdcp_shared_buf;<br>
>> + struct mutex mutex;<br>
>> };<br>
>><br>
>> struct psp_dtm_context {<br>
>> @@ -169,6 +170,7 @@ struct psp_dtm_context {<br>
>> struct amdgpu_bo *dtm_shared_bo;<br>
>> uint64_t dtm_shared_mc_addr;<br>
>> void *dtm_shared_buf;<br>
>> + struct mutex mutex;<br>
>> };<br>
>><br>
>> #define MEM_TRAIN_SYSTEM_SIGNATURE 0x54534942<br>
>> diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c<br>
>> index c2929815c3ee..aa147e171557 100644<br>
>> --- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c<br>
>> +++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c<br>
>> @@ -51,12 +51,15 @@ enum mod_hdcp_status mod_hdcp_remove_display_from_topology(<br>
>> struct ta_dtm_shared_memory *dtm_cmd;<br>
>> struct mod_hdcp_display *display =<br>
>> get_active_display_at_index(hdcp, index);<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>><br>
>> dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.dtm_shared_buf;<br>
>><br>
>> if (!display || !is_display_added(display))<br>
>> return MOD_HDCP_STATUS_DISPLAY_NOT_FOUND;<br>
>><br>
>> + mutex_lock(&psp->dtm_context.mutex);<br>
>> +<br>
>> memset(dtm_cmd, 0, sizeof(struct ta_dtm_shared_memory));<br>
>><br>
>> dtm_cmd->cmd_id = TA_DTM_COMMAND__TOPOLOGY_UPDATE_V2;<br>
>> @@ -66,14 +69,15 @@ enum mod_hdcp_status mod_hdcp_remove_display_from_topology(<br>
>><br>
>> psp_dtm_invoke(psp, dtm_cmd->cmd_id);<br>
>><br>
>> - if (dtm_cmd->dtm_status != TA_DTM_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_UPDATE_TOPOLOGY_FAILURE;<br>
>> + if (dtm_cmd->dtm_status != TA_DTM_STATUS__SUCCESS) {<br>
>> + status = MOD_HDCP_STATUS_UPDATE_TOPOLOGY_FAILURE;<br>
>> + } else {<br>
>> + display->state = MOD_HDCP_DISPLAY_ACTIVE;<br>
>> + HDCP_TOP_REMOVE_DISPLAY_TRACE(hdcp, display->index);<br>
>> + }<br>
>><br>
>> - display->state = MOD_HDCP_DISPLAY_ACTIVE;<br>
>> - HDCP_TOP_REMOVE_DISPLAY_TRACE(hdcp, display->index);<br>
>> -<br>
>> - return MOD_HDCP_STATUS_SUCCESS;<br>
>> -<br>
>> + mutex_unlock(&psp->dtm_context.mutex);<br>
>> + return status;<br>
>> }<br>
>> enum mod_hdcp_status mod_hdcp_add_display_to_topology(struct mod_hdcp *hdcp,<br>
>> uint8_t index)<br>
>> @@ -83,6 +87,7 @@ enum mod_hdcp_status mod_hdcp_add_display_to_topology(struct mod_hdcp *hdcp,<br>
>> struct mod_hdcp_display *display =<br>
>> get_active_display_at_index(hdcp, index);<br>
>> struct mod_hdcp_link *link = &hdcp->connection.link;<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>><br>
>> if (!psp->dtm_context.dtm_initialized) {<br>
>> DRM_ERROR("Failed to add display topology, DTM TA is not initialized.");<br>
>> @@ -94,6 +99,7 @@ enum mod_hdcp_status mod_hdcp_add_display_to_topology(struct mod_hdcp *hdcp,<br>
>><br>
>> dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.dtm_shared_buf;<br>
>><br>
>> + mutex_lock(&psp->dtm_context.mutex);<br>
>> memset(dtm_cmd, 0, sizeof(struct ta_dtm_shared_memory));<br>
>><br>
>> dtm_cmd->cmd_id = TA_DTM_COMMAND__TOPOLOGY_UPDATE_V2;<br>
>> @@ -113,13 +119,15 @@ enum mod_hdcp_status mod_hdcp_add_display_to_topology(struct mod_hdcp *hdcp,<br>
>><br>
>> psp_dtm_invoke(psp, dtm_cmd->cmd_id);<br>
>><br>
>> - if (dtm_cmd->dtm_status != TA_DTM_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_UPDATE_TOPOLOGY_FAILURE;<br>
>> -<br>
>> - display->state = MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED;<br>
>> - HDCP_TOP_ADD_DISPLAY_TRACE(hdcp, display->index);<br>
>> + if (dtm_cmd->dtm_status != TA_DTM_STATUS__SUCCESS) {<br>
>> + status = MOD_HDCP_STATUS_UPDATE_TOPOLOGY_FAILURE;<br>
>> + } else {<br>
>> + display->state = MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED;<br>
>> + HDCP_TOP_ADD_DISPLAY_TRACE(hdcp, display->index);<br>
>> + }<br>
>><br>
>> - return MOD_HDCP_STATUS_SUCCESS;<br>
>> + mutex_unlock(&psp->dtm_context.mutex);<br>
>> + return status;<br>
>> }<br>
>><br>
>> enum mod_hdcp_status mod_hdcp_hdcp1_create_session(struct mod_hdcp *hdcp)<br>
>> @@ -128,6 +136,7 @@ enum mod_hdcp_status mod_hdcp_hdcp1_create_session(struct mod_hdcp *hdcp)<br>
>> struct psp_context *psp = hdcp->config.psp.handle;<br>
>> struct mod_hdcp_display *display = get_first_added_display(hdcp);<br>
>> struct ta_hdcp_shared_memory *hdcp_cmd;<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>><br>
>> if (!psp->hdcp_context.hdcp_initialized) {<br>
>> DRM_ERROR("Failed to create hdcp session. HDCP TA is not initialized.");<br>
>> @@ -135,6 +144,8 @@ enum mod_hdcp_status mod_hdcp_hdcp1_create_session(struct mod_hdcp *hdcp)<br>
>> }<br>
>><br>
>> hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>> +<br>
>> + mutex_lock(&psp->hdcp_context.mutex);<br>
>> memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>><br>
>> hdcp_cmd->in_msg.hdcp1_create_session.display_handle = display->index;<br>
>> @@ -144,16 +155,18 @@ enum mod_hdcp_status mod_hdcp_hdcp1_create_session(struct mod_hdcp *hdcp)<br>
>><br>
>> hdcp->auth.id = hdcp_cmd->out_msg.hdcp1_create_session.session_handle;<br>
>><br>
>> - if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_HDCP1_CREATE_SESSION_FAILURE;<br>
>> -<br>
>> - hdcp->auth.msg.hdcp1.ainfo = hdcp_cmd->out_msg.hdcp1_create_session.ainfo_primary;<br>
>> - memcpy(hdcp->auth.msg.hdcp1.aksv, hdcp_cmd->out_msg.hdcp1_create_session.aksv_primary,<br>
>> - sizeof(hdcp->auth.msg.hdcp1.aksv));<br>
>> - memcpy(hdcp->auth.msg.hdcp1.an, hdcp_cmd->out_msg.hdcp1_create_session.an_primary,<br>
>> - sizeof(hdcp->auth.msg.hdcp1.an));<br>
>> + if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) {<br>
>> + status = MOD_HDCP_STATUS_HDCP1_CREATE_SESSION_FAILURE;<br>
>> + } else {<br>
>> + hdcp->auth.msg.hdcp1.ainfo = hdcp_cmd->out_msg.hdcp1_create_session.ainfo_primary;<br>
>> + memcpy(hdcp->auth.msg.hdcp1.aksv, hdcp_cmd->out_msg.hdcp1_create_session.aksv_primary,<br>
>> + sizeof(hdcp->auth.msg.hdcp1.aksv));<br>
>> + memcpy(hdcp->auth.msg.hdcp1.an, hdcp_cmd->out_msg.hdcp1_create_session.an_primary,<br>
>> + sizeof(hdcp->auth.msg.hdcp1.an));<br>
>> + }<br>
>><br>
>> - return MOD_HDCP_STATUS_SUCCESS;<br>
>> + mutex_unlock(&psp->hdcp_context.mutex);<br>
>> + return status;<br>
>> }<br>
>><br>
>> enum mod_hdcp_status mod_hdcp_hdcp1_destroy_session(struct mod_hdcp *hdcp)<br>
>> @@ -162,7 +175,9 @@ enum mod_hdcp_status mod_hdcp_hdcp1_destroy_session(struct mod_hdcp *hdcp)<br>
>> struct psp_context *psp = hdcp->config.psp.handle;<br>
>> struct ta_hdcp_shared_memory *hdcp_cmd;<br>
>> uint8_t i = 0;<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>><br>
>> + mutex_lock(&psp->hdcp_context.mutex);<br>
>> hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>> memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>><br>
>> @@ -171,27 +186,30 @@ enum mod_hdcp_status mod_hdcp_hdcp1_destroy_session(struct mod_hdcp *hdcp)<br>
>><br>
>> psp_hdcp_invoke(psp, hdcp_cmd->cmd_id);<br>
>><br>
>> - if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_HDCP1_DESTROY_SESSION_FAILURE;<br>
>> -<br>
>> - HDCP_TOP_HDCP1_DESTROY_SESSION_TRACE(hdcp);<br>
>> - for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)<br>
>> - if (is_display_encryption_enabled(<br>
>> - &hdcp->displays[i])) {<br>
>> - hdcp->displays[i].state =<br>
>> + if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) {<br>
>> + status = MOD_HDCP_STATUS_HDCP1_DESTROY_SESSION_FAILURE;<br>
>> + } else {<br>
>> + HDCP_TOP_HDCP1_DESTROY_SESSION_TRACE(hdcp);<br>
>> + for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)<br>
>> + if (is_display_encryption_enabled(&hdcp->displays[i])) {<br>
>> + hdcp->displays[i].state =<br>
>> MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED;<br>
>> - HDCP_HDCP1_DISABLED_TRACE(hdcp,<br>
>> - hdcp->displays[i].index);<br>
>> - }<br>
>> + HDCP_HDCP1_DISABLED_TRACE(<br>
>> + hdcp, hdcp->displays[i].index);<br>
>> + }<br>
>> + }<br>
>><br>
>> - return MOD_HDCP_STATUS_SUCCESS;<br>
>> + mutex_unlock(&psp->hdcp_context.mutex);<br>
>> + return status;<br>
>> }<br>
>><br>
>> enum mod_hdcp_status mod_hdcp_hdcp1_validate_rx(struct mod_hdcp *hdcp)<br>
>> {<br>
>> struct psp_context *psp = hdcp->config.psp.handle;<br>
>> struct ta_hdcp_shared_memory *hdcp_cmd;<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>><br>
>> + mutex_lock(&psp->hdcp_context.mutex);<br>
>> hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>> memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>><br>
>> @@ -206,10 +224,9 @@ enum mod_hdcp_status mod_hdcp_hdcp1_validate_rx(struct mod_hdcp *hdcp)<br>
>><br>
>> psp_hdcp_invoke(psp, hdcp_cmd->cmd_id);<br>
>><br>
>> - if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_HDCP1_VALIDATE_RX_FAILURE;<br>
>> -<br>
>> - if (hdcp_cmd->out_msg.hdcp1_first_part_authentication.authentication_status ==<br>
>> + if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) {<br>
>> + status = MOD_HDCP_STATUS_HDCP1_VALIDATE_RX_FAILURE;<br>
>> + } else if (hdcp_cmd->out_msg.hdcp1_first_part_authentication.authentication_status ==<br>
>> TA_HDCP_AUTHENTICATION_STATUS__HDCP1_FIRST_PART_COMPLETE) {<br>
>> /* needs second part of authentication */<br>
>> hdcp->connection.is_repeater = 1;<br>
>> @@ -219,12 +236,12 @@ enum mod_hdcp_status mod_hdcp_hdcp1_validate_rx(struct mod_hdcp *hdcp)<br>
>> } else if (hdcp_cmd->out_msg.hdcp1_first_part_authentication.authentication_status ==<br>
>> TA_HDCP_AUTHENTICATION_STATUS__HDCP1_KSV_REVOKED) {<br>
>> hdcp->connection.is_hdcp1_revoked = 1;<br>
>> - return MOD_HDCP_STATUS_HDCP1_BKSV_REVOKED;<br>
>> + status = MOD_HDCP_STATUS_HDCP1_BKSV_REVOKED;<br>
>> } else<br>
>> - return MOD_HDCP_STATUS_HDCP1_VALIDATE_RX_FAILURE;<br>
>> -<br>
>> + status = MOD_HDCP_STATUS_HDCP1_VALIDATE_RX_FAILURE;<br>
>><br>
>> - return MOD_HDCP_STATUS_SUCCESS;<br>
>> + mutex_unlock(&psp->hdcp_context.mutex);<br>
>> + return status;<br>
>> }<br>
>><br>
>> enum mod_hdcp_status mod_hdcp_hdcp1_enable_encryption(struct mod_hdcp *hdcp)<br>
>> @@ -232,7 +249,9 @@ enum mod_hdcp_status mod_hdcp_hdcp1_enable_encryption(struct mod_hdcp *hdcp)<br>
>> struct psp_context *psp = hdcp->config.psp.handle;<br>
>> struct ta_hdcp_shared_memory *hdcp_cmd;<br>
>> struct mod_hdcp_display *display = get_first_added_display(hdcp);<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>><br>
>> + mutex_lock(&psp->hdcp_context.mutex);<br>
>> hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>> memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>><br>
>> @@ -241,14 +260,15 @@ enum mod_hdcp_status mod_hdcp_hdcp1_enable_encryption(struct mod_hdcp *hdcp)<br>
>><br>
>> psp_hdcp_invoke(psp, hdcp_cmd->cmd_id);<br>
>><br>
>> - if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_HDCP1_ENABLE_ENCRYPTION;<br>
>> -<br>
>> - if (!is_dp_mst_hdcp(hdcp)) {<br>
>> + if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) {<br>
>> + status = MOD_HDCP_STATUS_HDCP1_ENABLE_ENCRYPTION;<br>
>> + } else if (!is_dp_mst_hdcp(hdcp)) {<br>
>> display->state = MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED;<br>
>> HDCP_HDCP1_ENABLED_TRACE(hdcp, display->index);<br>
>> }<br>
>> - return MOD_HDCP_STATUS_SUCCESS;<br>
>> +<br>
>> + mutex_unlock(&psp->hdcp_context.mutex);<br>
>> + return status;<br>
>> }<br>
>><br>
>> enum mod_hdcp_status mod_hdcp_hdcp1_validate_ksvlist_vp(struct mod_hdcp *hdcp)<br>
>> @@ -257,6 +277,7 @@ enum mod_hdcp_status mod_hdcp_hdcp1_validate_ksvlist_vp(struct mod_hdcp *hdcp)<br>
>> struct ta_hdcp_shared_memory *hdcp_cmd;<br>
>> enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>><br>
>> + mutex_lock(&psp->hdcp_context.mutex);<br>
>> hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>> memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>><br>
>> @@ -287,6 +308,7 @@ enum mod_hdcp_status mod_hdcp_hdcp1_validate_ksvlist_vp(struct mod_hdcp *hdcp)<br>
>> status = MOD_HDCP_STATUS_HDCP1_VALIDATE_KSV_LIST_FAILURE;<br>
>> }<br>
>><br>
>> + mutex_unlock(&psp->hdcp_context.mutex);<br>
>> return status;<br>
>> }<br>
>><br>
>> @@ -296,7 +318,9 @@ enum mod_hdcp_status mod_hdcp_hdcp1_enable_dp_stream_encryption(struct mod_hdcp<br>
>> struct psp_context *psp = hdcp->config.psp.handle;<br>
>> struct ta_hdcp_shared_memory *hdcp_cmd;<br>
>> int i = 0;<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>><br>
>> + mutex_lock(&psp->hdcp_context.mutex);<br>
>> hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>><br>
>> for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) {<br>
>> @@ -313,21 +337,26 @@ enum mod_hdcp_status mod_hdcp_hdcp1_enable_dp_stream_encryption(struct mod_hdcp<br>
>><br>
>> psp_hdcp_invoke(psp, hdcp_cmd->cmd_id);<br>
>><br>
>> - if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_HDCP1_ENABLE_STREAM_ENCRYPTION_FAILURE;<br>
>> + if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) {<br>
>> + status = MOD_HDCP_STATUS_HDCP1_ENABLE_STREAM_ENCRYPTION_FAILURE;<br>
>> + break;<br>
>> + }<br>
>><br>
>> hdcp->displays[i].state = MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED;<br>
>> HDCP_HDCP1_ENABLED_TRACE(hdcp, hdcp->displays[i].index);<br>
>> }<br>
>><br>
>> - return MOD_HDCP_STATUS_SUCCESS;<br>
>> + mutex_unlock(&psp->hdcp_context.mutex);<br>
>> + return status;<br>
>> }<br>
>><br>
>> enum mod_hdcp_status mod_hdcp_hdcp1_link_maintenance(struct mod_hdcp *hdcp)<br>
>> {<br>
>> struct psp_context *psp = hdcp->config.psp.handle;<br>
>> struct ta_hdcp_shared_memory *hdcp_cmd;<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>><br>
>> + mutex_lock(&psp->hdcp_context.mutex);<br>
>> hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>><br>
>> memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>> @@ -339,12 +368,12 @@ enum mod_hdcp_status mod_hdcp_hdcp1_link_maintenance(struct mod_hdcp *hdcp)<br>
>><br>
>> psp_hdcp_invoke(psp, hdcp_cmd->cmd_id);<br>
>><br>
>> - if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_HDCP1_LINK_MAINTENANCE_FAILURE;<br>
>> + if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS ||<br>
>> + hdcp_cmd->out_msg.hdcp1_get_encryption_status.protection_level != 1)<br>
>> + status = MOD_HDCP_STATUS_HDCP1_LINK_MAINTENANCE_FAILURE;<br>
>><br>
>> - return (hdcp_cmd->out_msg.hdcp1_get_encryption_status.protection_level == 1)<br>
>> - ? MOD_HDCP_STATUS_SUCCESS<br>
>> - : MOD_HDCP_STATUS_HDCP1_LINK_MAINTENANCE_FAILURE;<br>
>> + mutex_unlock(&psp->hdcp_context.mutex);<br>
>> + return status;<br>
>> }<br>
>><br>
>> enum mod_hdcp_status mod_hdcp_hdcp1_get_link_encryption_status(struct mod_hdcp *hdcp,<br>
>> @@ -365,18 +394,22 @@ enum mod_hdcp_status mod_hdcp_hdcp2_create_session(struct mod_hdcp *hdcp)<br>
>> struct psp_context *psp = hdcp->config.psp.handle;<br>
>> struct ta_hdcp_shared_memory *hdcp_cmd;<br>
>> struct mod_hdcp_display *display = get_first_added_display(hdcp);<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>> +<br>
>><br>
>> if (!psp->hdcp_context.hdcp_initialized) {<br>
>> DRM_ERROR("Failed to create hdcp session, HDCP TA is not initialized");<br>
>> return MOD_HDCP_STATUS_FAILURE;<br>
>> }<br>
>><br>
>> - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>> - memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>> -<br>
>> if (!display)<br>
>> return MOD_HDCP_STATUS_DISPLAY_NOT_FOUND;<br>
>><br>
>> + mutex_lock(&psp->hdcp_context.mutex);<br>
>> +<br>
>> + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>> + memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>> +<br>
>> hdcp_cmd->in_msg.hdcp2_create_session_v2.display_handle = display->index;<br>
>><br>
>> if (hdcp->connection.link.adjust.hdcp2.force_type == MOD_HDCP_FORCE_TYPE_0)<br>
>> @@ -393,12 +426,14 @@ enum mod_hdcp_status mod_hdcp_hdcp2_create_session(struct mod_hdcp *hdcp)<br>
>><br>
>> psp_hdcp_invoke(psp, hdcp_cmd->cmd_id);<br>
>><br>
>> - if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_HDCP2_CREATE_SESSION_FAILURE;<br>
>><br>
>> - hdcp->auth.id = hdcp_cmd->out_msg.hdcp2_create_session_v2.session_handle;<br>
>> + if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)<br>
>> + status = MOD_HDCP_STATUS_HDCP2_CREATE_SESSION_FAILURE;<br>
>> + else<br>
>> + hdcp->auth.id = hdcp_cmd->out_msg.hdcp2_create_session_v2.session_handle;<br>
>><br>
>> - return MOD_HDCP_STATUS_SUCCESS;<br>
>> + mutex_unlock(&psp->hdcp_context.mutex);<br>
>> + return status;<br>
>> }<br>
>><br>
>> enum mod_hdcp_status mod_hdcp_hdcp2_destroy_session(struct mod_hdcp *hdcp)<br>
>> @@ -406,7 +441,9 @@ enum mod_hdcp_status mod_hdcp_hdcp2_destroy_session(struct mod_hdcp *hdcp)<br>
>> struct psp_context *psp = hdcp->config.psp.handle;<br>
>> struct ta_hdcp_shared_memory *hdcp_cmd;<br>
>> uint8_t i = 0;<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>><br>
>> + mutex_lock(&psp->hdcp_context.mutex);<br>
>> hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>> memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>><br>
>> @@ -415,20 +452,21 @@ enum mod_hdcp_status mod_hdcp_hdcp2_destroy_session(struct mod_hdcp *hdcp)<br>
>><br>
>> psp_hdcp_invoke(psp, hdcp_cmd->cmd_id);<br>
>><br>
>> - if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_HDCP2_DESTROY_SESSION_FAILURE;<br>
>> -<br>
>> - HDCP_TOP_HDCP2_DESTROY_SESSION_TRACE(hdcp);<br>
>> - for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)<br>
>> - if (is_display_encryption_enabled(<br>
>> - &hdcp->displays[i])) {<br>
>> - hdcp->displays[i].state =<br>
>> + if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) {<br>
>> + status = MOD_HDCP_STATUS_HDCP2_DESTROY_SESSION_FAILURE;<br>
>> + } else {<br>
>> + HDCP_TOP_HDCP2_DESTROY_SESSION_TRACE(hdcp);<br>
>> + for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)<br>
>> + if (is_display_encryption_enabled(&hdcp->displays[i])) {<br>
>> + hdcp->displays[i].state =<br>
>> MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED;<br>
>> - HDCP_HDCP2_DISABLED_TRACE(hdcp,<br>
>> - hdcp->displays[i].index);<br>
>> - }<br>
>> + HDCP_HDCP2_DISABLED_TRACE(<br>
>> + hdcp, hdcp->displays[i].index);<br>
>> + }<br>
>> + }<br>
>><br>
>> - return MOD_HDCP_STATUS_SUCCESS;<br>
>> + mutex_unlock(&psp->hdcp_context.mutex);<br>
>> + return status;<br>
>> }<br>
>><br>
>> enum mod_hdcp_status mod_hdcp_hdcp2_prepare_ake_init(struct mod_hdcp *hdcp)<br>
>> @@ -437,7 +475,9 @@ enum mod_hdcp_status mod_hdcp_hdcp2_prepare_ake_init(struct mod_hdcp *hdcp)<br>
>> struct ta_hdcp_shared_memory *hdcp_cmd;<br>
>> struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in;<br>
>> struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out;<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>><br>
>> + mutex_lock(&psp->hdcp_context.mutex);<br>
>> hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>> memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>><br>
>> @@ -452,12 +492,13 @@ enum mod_hdcp_status mod_hdcp_hdcp2_prepare_ake_init(struct mod_hdcp *hdcp)<br>
>> psp_hdcp_invoke(psp, hdcp_cmd->cmd_id);<br>
>><br>
>> if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_HDCP2_PREP_AKE_INIT_FAILURE;<br>
>> -<br>
>> - memcpy(&hdcp->auth.msg.hdcp2.ake_init[0], &msg_out->prepare.transmitter_message[0],<br>
>> - sizeof(hdcp->auth.msg.hdcp2.ake_init));<br>
>> + status = MOD_HDCP_STATUS_HDCP2_PREP_AKE_INIT_FAILURE;<br>
>> + else<br>
>> + memcpy(&hdcp->auth.msg.hdcp2.ake_init[0], &msg_out->prepare.transmitter_message[0],<br>
>> + sizeof(hdcp->auth.msg.hdcp2.ake_init));<br>
>><br>
>> - return MOD_HDCP_STATUS_SUCCESS;<br>
>> + mutex_unlock(&psp->hdcp_context.mutex);<br>
>> + return status;<br>
>> }<br>
>><br>
>> enum mod_hdcp_status mod_hdcp_hdcp2_validate_ake_cert(struct mod_hdcp *hdcp)<br>
>> @@ -466,7 +507,9 @@ enum mod_hdcp_status mod_hdcp_hdcp2_validate_ake_cert(struct mod_hdcp *hdcp)<br>
>> struct ta_hdcp_shared_memory *hdcp_cmd;<br>
>> struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in;<br>
>> struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out;<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>><br>
>> + mutex_lock(&psp->hdcp_context.mutex);<br>
>> hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>> memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>><br>
>> @@ -488,26 +531,32 @@ enum mod_hdcp_status mod_hdcp_hdcp2_validate_ake_cert(struct mod_hdcp *hdcp)<br>
>><br>
>> psp_hdcp_invoke(psp, hdcp_cmd->cmd_id);<br>
>><br>
>> - if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_HDCP2_VALIDATE_AKE_CERT_FAILURE;<br>
>> -<br>
>> - memcpy(hdcp->auth.msg.hdcp2.ake_no_stored_km, &msg_out->prepare.transmitter_message[0],<br>
>> - sizeof(hdcp->auth.msg.hdcp2.ake_no_stored_km));<br>
>> -<br>
>> - memcpy(hdcp->auth.msg.hdcp2.ake_stored_km,<br>
>> - &msg_out->prepare.transmitter_message[sizeof(hdcp->auth.msg.hdcp2.ake_no_stored_km)],<br>
>> - sizeof(hdcp->auth.msg.hdcp2.ake_stored_km));<br>
>> -<br>
>> - if (msg_out->process.msg1_status == TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS) {<br>
>> - hdcp->connection.is_km_stored = msg_out->process.is_km_stored ? 1 : 0;<br>
>> - hdcp->connection.is_repeater = msg_out->process.is_repeater ? 1 : 0;<br>
>> - return MOD_HDCP_STATUS_SUCCESS;<br>
>> - } else if (msg_out->process.msg1_status == TA_HDCP2_MSG_AUTHENTICATION_STATUS__RECEIVERID_REVOKED) {<br>
>> - hdcp->connection.is_hdcp2_revoked = 1;<br>
>> - return MOD_HDCP_STATUS_HDCP2_AKE_CERT_REVOKED;<br>
>> + if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) {<br>
>> + status = MOD_HDCP_STATUS_HDCP2_VALIDATE_AKE_CERT_FAILURE;<br>
>> + } else {<br>
>> + memcpy(hdcp->auth.msg.hdcp2.ake_no_stored_km,<br>
>> + &msg_out->prepare.transmitter_message[0],<br>
>> + sizeof(hdcp->auth.msg.hdcp2.ake_no_stored_km));<br>
>> +<br>
>> + memcpy(hdcp->auth.msg.hdcp2.ake_stored_km,<br>
>> + &msg_out->prepare.transmitter_message[sizeof(hdcp->auth.msg.hdcp2.ake_no_stored_km)],<br>
>> + sizeof(hdcp->auth.msg.hdcp2.ake_stored_km));<br>
>> +<br>
>> + if (msg_out->process.msg1_status ==<br>
>> + TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS) {<br>
>> + hdcp->connection.is_km_stored =<br>
>> + msg_out->process.is_km_stored ? 1 : 0;<br>
>> + hdcp->connection.is_repeater =<br>
>> + msg_out->process.is_repeater ? 1 : 0;<br>
>> + status = MOD_HDCP_STATUS_SUCCESS;<br>
>> + } else if (msg_out->process.msg1_status ==<br>
>> + TA_HDCP2_MSG_AUTHENTICATION_STATUS__RECEIVERID_REVOKED) {<br>
>> + hdcp->connection.is_hdcp2_revoked = 1;<br>
>> + status = MOD_HDCP_STATUS_HDCP2_AKE_CERT_REVOKED;<br>
>> + }<br>
>> }<br>
>> -<br>
>> - return MOD_HDCP_STATUS_HDCP2_VALIDATE_AKE_CERT_FAILURE;<br>
>> + mutex_unlock(&psp->hdcp_context.mutex);<br>
>> + return status;<br>
>> }<br>
>><br>
>> enum mod_hdcp_status mod_hdcp_hdcp2_validate_h_prime(struct mod_hdcp *hdcp)<br>
>> @@ -516,7 +565,9 @@ enum mod_hdcp_status mod_hdcp_hdcp2_validate_h_prime(struct mod_hdcp *hdcp)<br>
>> struct ta_hdcp_shared_memory *hdcp_cmd;<br>
>> struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in;<br>
>> struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out;<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>><br>
>> + mutex_lock(&psp->hdcp_context.mutex);<br>
>> hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>> memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>><br>
>> @@ -543,16 +594,15 @@ enum mod_hdcp_status mod_hdcp_hdcp2_validate_h_prime(struct mod_hdcp *hdcp)<br>
>> psp_hdcp_invoke(psp, hdcp_cmd->cmd_id);<br>
>><br>
>> if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_HDCP2_VALIDATE_H_PRIME_FAILURE;<br>
>> -<br>
>> - if (msg_out->process.msg1_status != TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_HDCP2_VALIDATE_H_PRIME_FAILURE;<br>
>> + status = MOD_HDCP_STATUS_HDCP2_VALIDATE_H_PRIME_FAILURE;<br>
>> + else if (msg_out->process.msg1_status != TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS)<br>
>> + status = MOD_HDCP_STATUS_HDCP2_VALIDATE_H_PRIME_FAILURE;<br>
>> else if (!hdcp->connection.is_km_stored &&<br>
>> - msg_out->process.msg2_status != TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_HDCP2_VALIDATE_PAIRING_INFO_FAILURE;<br>
>> -<br>
>> + msg_out->process.msg2_status != TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS)<br>
>> + status = MOD_HDCP_STATUS_HDCP2_VALIDATE_PAIRING_INFO_FAILURE;<br>
>><br>
>> - return MOD_HDCP_STATUS_SUCCESS;<br>
>> + mutex_unlock(&psp->hdcp_context.mutex);<br>
>> + return status;<br>
>> }<br>
>><br>
>> enum mod_hdcp_status mod_hdcp_hdcp2_prepare_lc_init(struct mod_hdcp *hdcp)<br>
>> @@ -561,7 +611,9 @@ enum mod_hdcp_status mod_hdcp_hdcp2_prepare_lc_init(struct mod_hdcp *hdcp)<br>
>> struct ta_hdcp_shared_memory *hdcp_cmd;<br>
>> struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in;<br>
>> struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out;<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>><br>
>> + mutex_lock(&psp->hdcp_context.mutex);<br>
>> hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>> memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>><br>
>> @@ -577,12 +629,13 @@ enum mod_hdcp_status mod_hdcp_hdcp2_prepare_lc_init(struct mod_hdcp *hdcp)<br>
>> psp_hdcp_invoke(psp, hdcp_cmd->cmd_id);<br>
>><br>
>> if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_HDCP2_PREP_LC_INIT_FAILURE;<br>
>> -<br>
>> - memcpy(hdcp->auth.msg.hdcp2.lc_init, &msg_out->prepare.transmitter_message[0],<br>
>> - sizeof(hdcp->auth.msg.hdcp2.lc_init));<br>
>> + status = MOD_HDCP_STATUS_HDCP2_PREP_LC_INIT_FAILURE;<br>
>> + else<br>
>> + memcpy(hdcp->auth.msg.hdcp2.lc_init, &msg_out->prepare.transmitter_message[0],<br>
>> + sizeof(hdcp->auth.msg.hdcp2.lc_init));<br>
>><br>
>> - return MOD_HDCP_STATUS_SUCCESS;<br>
>> + mutex_unlock(&psp->hdcp_context.mutex);<br>
>> + return status;<br>
>> }<br>
>><br>
>> enum mod_hdcp_status mod_hdcp_hdcp2_validate_l_prime(struct mod_hdcp *hdcp)<br>
>> @@ -591,7 +644,9 @@ enum mod_hdcp_status mod_hdcp_hdcp2_validate_l_prime(struct mod_hdcp *hdcp)<br>
>> struct ta_hdcp_shared_memory *hdcp_cmd;<br>
>> struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in;<br>
>> struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out;<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>><br>
>> + mutex_lock(&psp->hdcp_context.mutex);<br>
>> hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>> memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>><br>
>> @@ -610,13 +665,12 @@ enum mod_hdcp_status mod_hdcp_hdcp2_validate_l_prime(struct mod_hdcp *hdcp)<br>
>><br>
>> psp_hdcp_invoke(psp, hdcp_cmd->cmd_id);<br>
>><br>
>> - if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_HDCP2_VALIDATE_L_PRIME_FAILURE;<br>
>> -<br>
>> - if (msg_out->process.msg1_status != TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_HDCP2_VALIDATE_L_PRIME_FAILURE;<br>
>> + if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS ||<br>
>> + msg_out->process.msg1_status != TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS)<br>
>> + status = MOD_HDCP_STATUS_HDCP2_VALIDATE_L_PRIME_FAILURE;<br>
>><br>
>> - return MOD_HDCP_STATUS_SUCCESS;<br>
>> + mutex_unlock(&psp->hdcp_context.mutex);<br>
>> + return status;<br>
>> }<br>
>><br>
>> enum mod_hdcp_status mod_hdcp_hdcp2_prepare_eks(struct mod_hdcp *hdcp)<br>
>> @@ -625,7 +679,9 @@ enum mod_hdcp_status mod_hdcp_hdcp2_prepare_eks(struct mod_hdcp *hdcp)<br>
>> struct ta_hdcp_shared_memory *hdcp_cmd;<br>
>> struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in;<br>
>> struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out;<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>><br>
>> + mutex_lock(&psp->hdcp_context.mutex);<br>
>> hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>> memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>><br>
>> @@ -642,20 +698,24 @@ enum mod_hdcp_status mod_hdcp_hdcp2_prepare_eks(struct mod_hdcp *hdcp)<br>
>> hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_PREPARE_PROCESS_AUTHENTICATION_MSG_V2;<br>
>> psp_hdcp_invoke(psp, hdcp_cmd->cmd_id);<br>
>><br>
>> - if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_HDCP2_PREP_EKS_FAILURE;<br>
>> -<br>
>> - memcpy(hdcp->auth.msg.hdcp2.ske_eks, &msg_out->prepare.transmitter_message[0],<br>
>> - sizeof(hdcp->auth.msg.hdcp2.ske_eks));<br>
>> - msg_out->prepare.msg1_desc.msg_size = sizeof(hdcp->auth.msg.hdcp2.ske_eks);<br>
>> -<br>
>> - if (is_dp_hdcp(hdcp)) {<br>
>> - memcpy(hdcp->auth.msg.hdcp2.content_stream_type_dp,<br>
>> - &msg_out->prepare.transmitter_message[sizeof(hdcp->auth.msg.hdcp2.ske_eks)],<br>
>> - sizeof(hdcp->auth.msg.hdcp2.content_stream_type_dp));<br>
>> + if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) {<br>
>> + status = MOD_HDCP_STATUS_HDCP2_PREP_EKS_FAILURE;<br>
>> + } else {<br>
>> + memcpy(hdcp->auth.msg.hdcp2.ske_eks,<br>
>> + &msg_out->prepare.transmitter_message[0],<br>
>> + sizeof(hdcp->auth.msg.hdcp2.ske_eks));<br>
>> + msg_out->prepare.msg1_desc.msg_size =<br>
>> + sizeof(hdcp->auth.msg.hdcp2.ske_eks);<br>
>> +<br>
>> + if (is_dp_hdcp(hdcp)) {<br>
>> + memcpy(hdcp->auth.msg.hdcp2.content_stream_type_dp,<br>
>> + &msg_out->prepare.transmitter_message[sizeof(hdcp->auth.msg.hdcp2.ske_eks)],<br>
>> + sizeof(hdcp->auth.msg.hdcp2.content_stream_type_dp));<br>
>> + }<br>
>> }<br>
>> + mutex_unlock(&psp->hdcp_context.mutex);<br>
>><br>
>> - return MOD_HDCP_STATUS_SUCCESS;<br>
>> + return status;<br>
>> }<br>
>><br>
>> enum mod_hdcp_status mod_hdcp_hdcp2_enable_encryption(struct mod_hdcp *hdcp)<br>
>> @@ -663,27 +723,30 @@ enum mod_hdcp_status mod_hdcp_hdcp2_enable_encryption(struct mod_hdcp *hdcp)<br>
>> struct psp_context *psp = hdcp->config.psp.handle;<br>
>> struct ta_hdcp_shared_memory *hdcp_cmd;<br>
>> struct mod_hdcp_display *display = get_first_added_display(hdcp);<br>
>> -<br>
>> - hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>> - memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>><br>
>> if (!display)<br>
>> return MOD_HDCP_STATUS_DISPLAY_NOT_FOUND;<br>
>><br>
>> + mutex_lock(&psp->hdcp_context.mutex);<br>
>> +<br>
>> + hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>> + memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>> +<br>
>> hdcp_cmd->in_msg.hdcp2_set_encryption.session_handle = hdcp->auth.id;<br>
>><br>
>> hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_SET_ENCRYPTION;<br>
>> psp_hdcp_invoke(psp, hdcp_cmd->cmd_id);<br>
>><br>
>> - if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_HDCP2_ENABLE_ENCRYPTION_FAILURE;<br>
>> -<br>
>> - if (!is_dp_mst_hdcp(hdcp)) {<br>
>> + if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) {<br>
>> + status = MOD_HDCP_STATUS_HDCP2_ENABLE_ENCRYPTION_FAILURE;<br>
>> + } else if (!is_dp_mst_hdcp(hdcp)) {<br>
>> display->state = MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED;<br>
>> HDCP_HDCP2_ENABLED_TRACE(hdcp, display->index);<br>
>> }<br>
>><br>
>> - return MOD_HDCP_STATUS_SUCCESS;<br>
>> + mutex_unlock(&psp->hdcp_context.mutex);<br>
>> + return status;<br>
>> }<br>
>><br>
>> enum mod_hdcp_status mod_hdcp_hdcp2_validate_rx_id_list(struct mod_hdcp *hdcp)<br>
>> @@ -692,6 +755,9 @@ enum mod_hdcp_status mod_hdcp_hdcp2_validate_rx_id_list(struct mod_hdcp *hdcp)<br>
>> struct ta_hdcp_shared_memory *hdcp_cmd;<br>
>> struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in;<br>
>> struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out;<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>> +<br>
>> + mutex_lock(&psp->hdcp_context.mutex);<br>
>><br>
>> hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>> memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>> @@ -712,23 +778,26 @@ enum mod_hdcp_status mod_hdcp_hdcp2_validate_rx_id_list(struct mod_hdcp *hdcp)<br>
>><br>
>> psp_hdcp_invoke(psp, hdcp_cmd->cmd_id);<br>
>><br>
>> - if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_HDCP2_VALIDATE_RX_ID_LIST_FAILURE;<br>
>> -<br>
>> - memcpy(hdcp->auth.msg.hdcp2.repeater_auth_ack, &msg_out->prepare.transmitter_message[0],<br>
>> - sizeof(hdcp->auth.msg.hdcp2.repeater_auth_ack));<br>
>> -<br>
>> - if (msg_out->process.msg1_status == TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS) {<br>
>> - hdcp->connection.is_km_stored = msg_out->process.is_km_stored ? 1 : 0;<br>
>> - hdcp->connection.is_repeater = msg_out->process.is_repeater ? 1 : 0;<br>
>> - return MOD_HDCP_STATUS_SUCCESS;<br>
>> - } else if (msg_out->process.msg1_status == TA_HDCP2_MSG_AUTHENTICATION_STATUS__RECEIVERID_REVOKED) {<br>
>> - hdcp->connection.is_hdcp2_revoked = 1;<br>
>> - return MOD_HDCP_STATUS_HDCP2_RX_ID_LIST_REVOKED;<br>
>> + if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) {<br>
>> + status = MOD_HDCP_STATUS_HDCP2_VALIDATE_RX_ID_LIST_FAILURE;<br>
>> + } else {<br>
>> + memcpy(hdcp->auth.msg.hdcp2.repeater_auth_ack,<br>
>> + &msg_out->prepare.transmitter_message[0],<br>
>> + sizeof(hdcp->auth.msg.hdcp2.repeater_auth_ack));<br>
>> +<br>
>> + if (msg_out->process.msg1_status ==<br>
>> + TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS) {<br>
>> + hdcp->connection.is_km_stored = msg_out->process.is_km_stored ? 1 : 0;<br>
>> + hdcp->connection.is_repeater = msg_out->process.is_repeater ? 1 : 0;<br>
>> + status = MOD_HDCP_STATUS_SUCCESS;<br>
>> + } else if (msg_out->process.msg1_status ==<br>
>> + TA_HDCP2_MSG_AUTHENTICATION_STATUS__RECEIVERID_REVOKED) {<br>
>> + hdcp->connection.is_hdcp2_revoked = 1;<br>
>> + status = MOD_HDCP_STATUS_HDCP2_RX_ID_LIST_REVOKED;<br>
>> + }<br>
>> }<br>
>> -<br>
>> -<br>
>> - return MOD_HDCP_STATUS_HDCP2_VALIDATE_RX_ID_LIST_FAILURE;<br>
>> + mutex_unlock(&psp->hdcp_context.mutex);<br>
>> + return status;<br>
>> }<br>
>><br>
>> enum mod_hdcp_status mod_hdcp_hdcp2_enable_dp_stream_encryption(struct mod_hdcp *hdcp)<br>
>> @@ -737,7 +806,9 @@ enum mod_hdcp_status mod_hdcp_hdcp2_enable_dp_stream_encryption(struct mod_hdcp<br>
>> struct ta_hdcp_shared_memory *hdcp_cmd;<br>
>> struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in;<br>
>> uint8_t i;<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>><br>
>> + mutex_lock(&psp->hdcp_context.mutex);<br>
>> hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>> memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>><br>
>> @@ -763,8 +834,13 @@ enum mod_hdcp_status mod_hdcp_hdcp2_enable_dp_stream_encryption(struct mod_hdcp<br>
>> HDCP_HDCP2_ENABLED_TRACE(hdcp, hdcp->displays[i].index);<br>
>> }<br>
>><br>
>> - return (hdcp_cmd->hdcp_status == TA_HDCP_STATUS__SUCCESS) ? MOD_HDCP_STATUS_SUCCESS<br>
>> - : MOD_HDCP_STATUS_HDCP2_ENABLE_STREAM_ENCRYPTION;<br>
>> + if (hdcp_cmd->hdcp_status == TA_HDCP_STATUS__SUCCESS)<br>
>> + status = MOD_HDCP_STATUS_SUCCESS;<br>
>> + else<br>
>> + status = MOD_HDCP_STATUS_HDCP2_ENABLE_STREAM_ENCRYPTION;<br>
>> +<br>
>> + mutex_unlock(&psp->hdcp_context.mutex);<br>
>> + return status;<br>
>> }<br>
>><br>
>> enum mod_hdcp_status mod_hdcp_hdcp2_prepare_stream_management(struct mod_hdcp *hdcp)<br>
>> @@ -774,7 +850,9 @@ enum mod_hdcp_status mod_hdcp_hdcp2_prepare_stream_management(struct mod_hdcp *h<br>
>> struct ta_hdcp_shared_memory *hdcp_cmd;<br>
>> struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in;<br>
>> struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out;<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>><br>
>> + mutex_lock(&psp->hdcp_context.mutex);<br>
>> hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>> memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>><br>
>> @@ -789,15 +867,17 @@ enum mod_hdcp_status mod_hdcp_hdcp2_prepare_stream_management(struct mod_hdcp *h<br>
>> hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_PREPARE_PROCESS_AUTHENTICATION_MSG_V2;<br>
>> psp_hdcp_invoke(psp, hdcp_cmd->cmd_id);<br>
>><br>
>> - if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)<br>
>> - return MOD_HDCP_STATUS_HDCP2_PREPARE_STREAM_MANAGEMENT_FAILURE;<br>
>> -<br>
>> - hdcp->auth.msg.hdcp2.stream_manage_size = msg_out->prepare.msg1_desc.msg_size;<br>
>> -<br>
>> - memcpy(hdcp->auth.msg.hdcp2.repeater_auth_stream_manage, &msg_out->prepare.transmitter_message[0],<br>
>> - sizeof(hdcp->auth.msg.hdcp2.repeater_auth_stream_manage));<br>
>> + if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS) {<br>
>> + status = MOD_HDCP_STATUS_HDCP2_PREPARE_STREAM_MANAGEMENT_FAILURE;<br>
>> + } else {<br>
>> + hdcp->auth.msg.hdcp2.stream_manage_size = msg_out->prepare.msg1_desc.msg_size;<br>
>><br>
>> - return MOD_HDCP_STATUS_SUCCESS;<br>
>> + memcpy(hdcp->auth.msg.hdcp2.repeater_auth_stream_manage,<br>
>> + &msg_out->prepare.transmitter_message[0],<br>
>> + sizeof(hdcp->auth.msg.hdcp2.repeater_auth_stream_manage));<br>
>> + }<br>
>> + mutex_unlock(&psp->hdcp_context.mutex);<br>
>> + return status;<br>
>> }<br>
>><br>
>> enum mod_hdcp_status mod_hdcp_hdcp2_validate_stream_ready(struct mod_hdcp *hdcp)<br>
>> @@ -806,7 +886,9 @@ enum mod_hdcp_status mod_hdcp_hdcp2_validate_stream_ready(struct mod_hdcp *hdcp)<br>
>> struct ta_hdcp_shared_memory *hdcp_cmd;<br>
>> struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *msg_in;<br>
>> struct ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_output_v2 *msg_out;<br>
>> + enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;<br>
>><br>
>> + mutex_lock(&psp->hdcp_context.mutex);<br>
>> hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;<br>
>> memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));<br>
>><br>
>> @@ -825,10 +907,14 @@ enum mod_hdcp_status mod_hdcp_hdcp2_validate_stream_ready(struct mod_hdcp *hdcp)<br>
>> hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP2_PREPARE_PROCESS_AUTHENTICATION_MSG_V2;<br>
>> psp_hdcp_invoke(psp, hdcp_cmd->cmd_id);<br>
>><br>
>> - return (hdcp_cmd->hdcp_status == TA_HDCP_STATUS__SUCCESS) &&<br>
>> - (msg_out->process.msg1_status == TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS)<br>
>> - ? MOD_HDCP_STATUS_SUCCESS<br>
>> - : MOD_HDCP_STATUS_HDCP2_VALIDATE_STREAM_READY_FAILURE;<br>
>> + if (hdcp_cmd->hdcp_status == TA_HDCP_STATUS__SUCCESS &&<br>
>> + msg_out->process.msg1_status == TA_HDCP2_MSG_AUTHENTICATION_STATUS__SUCCESS)<br>
>> + status = MOD_HDCP_STATUS_SUCCESS;<br>
>> + else<br>
>> + status = MOD_HDCP_STATUS_HDCP2_VALIDATE_STREAM_READY_FAILURE;<br>
>> +<br>
>> + mutex_unlock(&psp->hdcp_context.mutex);<br>
>> + return status;<br>
>> }<br>
>><br>
>> enum mod_hdcp_status mod_hdcp_hdcp2_get_link_encryption_status(struct mod_hdcp *hdcp,<br>
<br>
Looks like you're missing a mutex in this function ^<br>
<br>
mod_hdcp_hdcp2_get_link_encryption_status<br>
<br>
Which touches hdcp_shared_buf.<br>
<br>
Nicholas Kazlauskas<br>
<br>
>> --<br>
>> 2.17.1<br>
>><br>
>> _______________________________________________<br>
>> amd-gfx mailing list<br>
>> amd-gfx@lists.freedesktop.org<br>
>> <a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
> _______________________________________________<br>
> amd-gfx mailing list<br>
> amd-gfx@lists.freedesktop.org<br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
> <br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>