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

Commit 3865afec authored by Zhen Kong's avatar Zhen Kong Committed by Ashwini Muduganti
Browse files

qseecom: set rcv_req_flag to 0 when listener is just registered



Only set rcv_req_flag to 0 when listener is just registered, as
if a client thread first sets rcv_req_flag to 1 when getting a new
listener request, and later on qseecomd calls qseecom_receive_req,
this flag will be overwritten to 0 and listener recv_req thread can
not be waken up. Also remove retry logic to wait for listener ready
and just return error response to TZ.

Change-Id: I35f4bcf3832d7cc987f7e0027a5cb25abd05d5b5
Signed-off-by: default avatarZhen Kong <zkong@codeaurora.org>
parent da7470df
Loading
Loading
Loading
Loading
+14 −15
Original line number Diff line number Diff line
@@ -1772,19 +1772,9 @@ static void __qseecom_clean_listener_sglistinfo(
	}
}

/* wait listener retry delay (ms) and max attemp count */
#define QSEECOM_WAIT_LISTENER_DELAY          10
#define QSEECOM_WAIT_LISTENER_MAX_ATTEMP     3

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

	while (ptr_svc->rcv_req_flag == -1 &&
		retry++ < QSEECOM_WAIT_LISTENER_MAX_ATTEMP) {
		msleep(QSEECOM_WAIT_LISTENER_DELAY);
	}
	return ptr_svc->rcv_req_flag == -1;
}

@@ -1805,6 +1795,7 @@ static int __qseecom_process_incomplete_cmd(struct qseecom_dev_handle *data,
	void *cmd_buf = NULL;
	size_t cmd_len;
	struct sglist_info *table = NULL;
	bool not_ready = false;

	while (resp->result == QSEOS_RESULT_INCOMPLETE) {
		lstnr = resp->data;
@@ -1816,8 +1807,10 @@ static int __qseecom_process_incomplete_cmd(struct qseecom_dev_handle *data,
		list_for_each_entry(ptr_svc,
				&qseecom.registered_listener_list_head, list) {
			if (ptr_svc->svc.listener_id == lstnr) {
				if (__is_listener_rcv_wq_not_ready(ptr_svc))
				if (__is_listener_rcv_wq_not_ready(ptr_svc)) {
					not_ready = true;
					break;
				}
				ptr_svc->listener_in_use = true;
				ptr_svc->rcv_req_flag = 1;
				wake_up_interruptible(&ptr_svc->rcv_req_wq);
@@ -1858,7 +1851,7 @@ static int __qseecom_process_incomplete_cmd(struct qseecom_dev_handle *data,
			goto err_resp;
		}

		if (ptr_svc->rcv_req_flag == -1) {
		if (not_ready) {
			pr_err("Service %d is not ready to receive request\n",
					lstnr);
			rc = -ENOENT;
@@ -2137,6 +2130,7 @@ static int __qseecom_reentrancy_process_incomplete_cmd(
	void *cmd_buf = NULL;
	size_t cmd_len;
	struct sglist_info *table = NULL;
	bool not_ready = false;

	while (ret == 0 && resp->result == QSEOS_RESULT_INCOMPLETE) {
		lstnr = resp->data;
@@ -2148,8 +2142,10 @@ static int __qseecom_reentrancy_process_incomplete_cmd(
		list_for_each_entry(ptr_svc,
				&qseecom.registered_listener_list_head, list) {
			if (ptr_svc->svc.listener_id == lstnr) {
				if (__is_listener_rcv_wq_not_ready(ptr_svc))
				if (__is_listener_rcv_wq_not_ready(ptr_svc)) {
					not_ready = true;
					break;
				}
				ptr_svc->listener_in_use = true;
				ptr_svc->rcv_req_flag = 1;
				wake_up_interruptible(&ptr_svc->rcv_req_wq);
@@ -2190,7 +2186,7 @@ static int __qseecom_reentrancy_process_incomplete_cmd(
			goto err_resp;
		}

		if (ptr_svc->rcv_req_flag == -1) {
		if (not_ready) {
			pr_err("Service %d is not ready to receive request\n",
					lstnr);
			rc = -ENOENT;
@@ -3998,6 +3994,8 @@ static int qseecom_receive_req(struct qseecom_dev_handle *data)
		pr_err("Invalid listener ID\n");
		return -ENODATA;
	}

	if (this_lstnr->rcv_req_flag == -1)
		this_lstnr->rcv_req_flag = 0;

	while (1) {
@@ -4007,6 +4005,7 @@ static int qseecom_receive_req(struct qseecom_dev_handle *data)
			pr_debug("Interrupted: exiting Listener Service = %d\n",
						(uint32_t)data->listener.id);
			/* woken up for different reason */
			this_lstnr->rcv_req_flag = -1;
			return -ERESTARTSYS;
		}