securemsm-kernel : Unload hdcp1 when all instances are closed

Unload hdcp1 TA when all client instances are closed.

Change-Id: I079021b1efadfdec3c0248f7c8ed79c686d6d1c5
Signed-off-by: Sheik Anwar Shabic Y <quic_sheikanw@quicinc.com>
This commit is contained in:
Sheik Anwar Shabic Y
2023-06-07 09:50:21 +05:30
committed by Gerrit - the friendly Code Review server
parent c9102b2761
commit 1f515ba432
3 changed files with 30 additions and 11 deletions

View File

@@ -82,26 +82,27 @@ static inline int32_t hdcp2p2_tx_deinit(struct Object self, uint32_t ctxhandle_v
static inline int32_t hdcp2p2_rcvd_msg( static inline int32_t hdcp2p2_rcvd_msg(
struct Object self, const void *reqMsg_ptr, size_t reqMsg_len, struct Object self, const void *reqMsg_ptr, size_t reqMsg_len,
uint32_t ctxhandle_val, void *resMsg_ptr, size_t resMsg_len, uint32_t ctxhandle_val, void *resMsg_ptr, size_t resMsg_len,
size_t *resMsg_lenout, uint32_t *timeout_ptr, uint32_t *flag_ptr) size_t *resMsg_lenout, uint32_t *timeout_ptr, uint32_t *flag_ptr, uint32_t *state_ptr)
{ {
union ObjectArg a[4] = {{{0, 0}}}; union ObjectArg a[4] = {{{0, 0}}};
int32_t result = 0; int32_t result = 0;
struct { struct {
uint32_t m_timeout; uint32_t m_timeout;
uint32_t m_flag; uint32_t m_flag;
uint32_t m_state;
} o; } o;
a[2].b = (struct ObjectBuf) {&o, 12};
a[2].b = (struct ObjectBuf) {&o, 8};
a[0].bi = (struct ObjectBufIn) {reqMsg_ptr, reqMsg_len * 1}; a[0].bi = (struct ObjectBufIn) {reqMsg_ptr, reqMsg_len * 1};
a[1].b = (struct ObjectBuf) {&ctxhandle_val, sizeof(uint32_t)}; a[1].b = (struct ObjectBuf) {&ctxhandle_val, sizeof(uint32_t)};
a[3].b = (struct ObjectBuf) {resMsg_ptr, resMsg_len * 1}; a[3].b = (struct ObjectBuf) {resMsg_ptr, resMsg_len * 1};
result = Object_invoke(self, HDCP2P2_RCVD_MSG, a, result = Object_invoke(self, HDCP2P2_RCVD_MSG, a,
ObjectCounts_pack(2, 2, 0, 0)); ObjectCounts_pack(2, 2, 0, 0));
*resMsg_lenout = a[3].b.size / 1; *resMsg_lenout = a[3].b.size / 1;
*timeout_ptr = o.m_timeout; *timeout_ptr = o.m_timeout;
*flag_ptr = o.m_flag; *flag_ptr = o.m_flag;
*state_ptr = o.m_state;
return result; return result;
} }

View File

@@ -20,7 +20,7 @@
#define hdcp2_app_init_var(x) \ #define hdcp2_app_init_var(x) \
struct hdcp_##x##_req *req_buf = NULL; \ struct hdcp_##x##_req *req_buf = NULL; \
struct hdcp_##x##_rsp *rsp_buf = NULL; \ struct hdcp_##x##_rsp *rsp_buf = NULL; \
if (!handle->qseecom_handle) { \ if (!handle || !handle->qseecom_handle) { \
pr_err("invalid qseecom_handle while processing %s\n", #x); \ pr_err("invalid qseecom_handle while processing %s\n", #x); \
rc = -EINVAL; \ rc = -EINVAL; \
goto error; \ goto error; \
@@ -212,12 +212,17 @@ static void hdcp1_app_unload(struct hdcp1_qsee_handle *handle)
pr_warn("%s app unload failed (%d)\n", HDCP1OPS_APP_NAME, rc); pr_warn("%s app unload failed (%d)\n", HDCP1OPS_APP_NAME, rc);
} }
hdcp1_app_started--;
if (!hdcp1_app_started) {
/* deallocate the resources for qseecom HDCP 1.x handle */ /* deallocate the resources for qseecom HDCP 1.x handle */
rc = qseecom_shutdown_app(&handle->qseecom_handle); rc = qseecom_shutdown_app(&hdcp1_qseecom_handle_g);
if (rc) { if (rc) {
pr_err("%s app unload failed (%d)\n", handle->app_name, rc); pr_err("%s app unload failed (%d)\n", handle->app_name, rc);
return; return;
}
hdcp1_qseecom_handle_g = NULL;
} }
handle->qseecom_handle = NULL;
handle->hdcp_state &= ~HDCP_STATE_APP_LOADED; handle->hdcp_state &= ~HDCP_STATE_APP_LOADED;
pr_debug("%s app unloaded\n", handle->app_name); pr_debug("%s app unloaded\n", handle->app_name);

View File

@@ -185,7 +185,7 @@ error:
static void hdcp1_app_unload(struct hdcp1_smcinvoke_handle *handle) static void hdcp1_app_unload(struct hdcp1_smcinvoke_handle *handle)
{ {
if (!handle || !!handle->hdcp1_app_obj.context) { if (!handle || !handle->hdcp1_app_obj.context) {
pr_err("invalid handle\n"); pr_err("invalid handle\n");
return; return;
} }
@@ -348,10 +348,22 @@ void hdcp1_stop_smcinvoke(void *data)
{ {
struct hdcp1_smcinvoke_handle *hdcp1_handle = data; struct hdcp1_smcinvoke_handle *hdcp1_handle = data;
if (!hdcp1_handle) {
pr_err("invalid HDCP 1.x handle\n");
return;
}
if (!(hdcp1_handle->hdcp_state & HDCP_STATE_APP_LOADED)) {
pr_err("hdcp1 app not loaded\n");
return;
}
Object_ASSIGN_NULL(hdcp1_handle->hdcp1_app_obj); Object_ASSIGN_NULL(hdcp1_handle->hdcp1_app_obj);
Object_ASSIGN_NULL(hdcp1_handle->hdcp1_appcontroller_obj); Object_ASSIGN_NULL(hdcp1_handle->hdcp1_appcontroller_obj);
Object_ASSIGN_NULL(hdcp1_handle->hdcp1ops_app_obj); Object_ASSIGN_NULL(hdcp1_handle->hdcp1ops_app_obj);
Object_ASSIGN_NULL(hdcp1_handle->hdcp1ops_appcontroller_obj); Object_ASSIGN_NULL(hdcp1_handle->hdcp1ops_appcontroller_obj);
hdcp1_handle->hdcp_state &= ~HDCP_STATE_APP_LOADED;
} }
void *hdcp2_init_smcinvoke(u32 device_type) void *hdcp2_init_smcinvoke(u32 device_type)
@@ -757,6 +769,7 @@ int hdcp2_app_process_msg_smcinvoke(void *ctx, uint32_t req_len)
size_t resMsgLen = 0; size_t resMsgLen = 0;
uint32_t timeout = 0; uint32_t timeout = 0;
uint32_t flag = 0; uint32_t flag = 0;
uint32_t state = 0;
uint8_t resMsg[MAX_TX_MESSAGE_SIZE] = {0}; uint8_t resMsg[MAX_TX_MESSAGE_SIZE] = {0};
@@ -779,7 +792,7 @@ int hdcp2_app_process_msg_smcinvoke(void *ctx, uint32_t req_len)
ret = hdcp2p2_rcvd_msg( ret = hdcp2p2_rcvd_msg(
handle->hdcp2_app_obj, handle->app_data.request.data, handle->hdcp2_app_obj, handle->app_data.request.data,
handle->app_data.request.length, handle->tz_ctxhandle, resMsg, handle->app_data.request.length, handle->tz_ctxhandle, resMsg,
MAX_TX_MESSAGE_SIZE, &resMsgLen, &timeout, &flag); MAX_TX_MESSAGE_SIZE, &resMsgLen, &timeout, &flag, &state);
if (ret) { if (ret) {
pr_err("hdcp2p2_rcvd_msg failed :%d\n", ret); pr_err("hdcp2p2_rcvd_msg failed :%d\n", ret);
goto error; goto error;