Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e2831fb2 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "qseecom: check if listener is not ready to receive request"

parents eee5e921 25731112
Loading
Loading
Loading
Loading
+37 −1
Original line number Diff line number Diff line
@@ -1639,6 +1639,23 @@ static void __qseecom_clean_listener_sglistinfo(
	}
}

/* wake up listener receive request wq retry delay (ms) and max attemp count */
#define QSEECOM_WAKE_LISTENER_RCVWQ_DELAY          10
#define QSEECOM_WAKE_LISTENER_RCVWQ_MAX_ATTEMP     3

static int __qseecom_retry_wake_up_listener_rcv_wq(
			struct qseecom_registered_listener_list *ptr_svc)
{
	int retry = 0;

	while (ptr_svc->rcv_req_flag == 1 &&
		retry++ < QSEECOM_WAKE_LISTENER_RCVWQ_MAX_ATTEMP) {
		wake_up_interruptible(&ptr_svc->rcv_req_wq);
		msleep(QSEECOM_WAKE_LISTENER_RCVWQ_DELAY);
	}
	return ptr_svc->rcv_req_flag == 1;
}

static int __qseecom_process_incomplete_cmd(struct qseecom_dev_handle *data,
					struct qseecom_command_scm_resp *resp)
{
@@ -1706,6 +1723,15 @@ static int __qseecom_process_incomplete_cmd(struct qseecom_dev_handle *data,
			status = QSEOS_RESULT_FAILURE;
			goto err_resp;
		}

		if (ptr_svc->rcv_req_flag == 1 &&
			__qseecom_retry_wake_up_listener_rcv_wq(ptr_svc)) {
			pr_err("Service %d is not ready to receive request\n",
					lstnr);
			rc = -ENOENT;
			status = QSEOS_RESULT_FAILURE;
			goto err_resp;
		}
		pr_debug("waking up rcv_req_wq and waiting for send_resp_wq\n");

		/* initialize the new signal mask with all signals*/
@@ -2017,6 +2043,15 @@ static int __qseecom_reentrancy_process_incomplete_cmd(
			status = QSEOS_RESULT_FAILURE;
			goto err_resp;
		}

		if (ptr_svc->rcv_req_flag == 1 &&
			__qseecom_retry_wake_up_listener_rcv_wq(ptr_svc)) {
			pr_err("Service %d is not ready to receive request\n",
					lstnr);
			rc = -ENOENT;
			status = QSEOS_RESULT_FAILURE;
			goto err_resp;
		}
		pr_debug("waking up rcv_req_wq and waiting for send_resp_wq\n");

		/* initialize the new signal mask with all signals*/
@@ -3843,7 +3878,7 @@ static int qseecom_receive_req(struct qseecom_dev_handle *data)
		if (wait_event_freezable(this_lstnr->rcv_req_wq,
				__qseecom_listener_has_rcvd_req(data,
				this_lstnr))) {
			pr_debug("Interrupted: exiting Listener Service = %d\n",
			pr_warn("Interrupted: exiting Listener Service = %d\n",
						(uint32_t)data->listener.id);
			/* woken up for different reason */
			return -ERESTARTSYS;
@@ -7686,6 +7721,7 @@ static int qseecom_release(struct inode *inode, struct file *file)
			data->type, data->mode, data);
		switch (data->type) {
		case QSEECOM_LISTENER_SERVICE:
			pr_warn("release lsnr svc %d\n", data->listener.id);
			__qseecom_listener_abort_all(1);
			mutex_lock(&app_access_lock);
			ret = qseecom_unregister_listener(data);