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

Commit 347fe47c authored by Dhoat Harpal's avatar Dhoat Harpal
Browse files

soc: qcom: glink_smd_xprt: Fix race condition of open ack



Open ack is received in separate work queue than process_open_event.
It causes race condition since process_open_event and process_status_event
might get scheduled before glink is notified about open ack.

Glink will be notified about ack in process_open_event.

CRs-Fixed: 974508
Change-Id: Ie03a4914c2655ae5140a740cde73b06bb6d43291
Signed-off-by: default avatarDhoat Harpal <hdhoat@codeaurora.org>
parent 1c10389d
Loading
Loading
Loading
Loading
+14 −7
Original line number Diff line number Diff line
@@ -157,6 +157,8 @@ struct channel {
	bool remote_legacy;
	size_t intent_req_size;
	spinlock_t rx_data_lock;
	uint32_t priority;
	bool open_ack_received;
	bool streaming_ch;
	bool tx_resume_needed;
};
@@ -411,13 +413,9 @@ static void process_ctl_event(struct work_struct *work)
				continue;
			}

			ch->open_ack_received = true;
			ch->priority = cmd.priority;
			add_platform_driver(ch);
			mutex_lock(&einfo->rx_cmd_lock);
			einfo->xprt_if.glink_core_if_ptr->rx_cmd_ch_open_ack(
								&einfo->xprt_if,
								cmd.id,
								cmd.priority);
			mutex_unlock(&einfo->rx_cmd_lock);
		} else if (cmd.cmd == CMD_CLOSE) {
			SMDXPRT_INFO(einfo, "%s RX REMOTE CLOSE rcid %u\n",
					__func__, cmd.id);
@@ -601,6 +599,15 @@ static void process_open_event(struct work_struct *work)
							ch->name,
							SMD_TRANS_XPRT_ID);
		mutex_unlock(&einfo->rx_cmd_lock);
	} else if (ch->open_ack_received) {
		SMDXPRT_INFO(einfo, "%s RX OPEN ACK lcid %u; xprt_req %u\n",
			__func__, ch->lcid, ch->priority);
		mutex_lock(&einfo->rx_cmd_lock);
		einfo->xprt_if.glink_core_if_ptr->rx_cmd_ch_open_ack(
			&einfo->xprt_if,
			ch->lcid,
			ch->priority);
		mutex_unlock(&einfo->rx_cmd_lock);
	}
	kfree(ch_work);
}
@@ -1227,7 +1234,7 @@ static int tx_cmd_ch_open(struct glink_transport_if *if_ptr, uint32_t lcid,

	ch->tx_resume_needed = false;
	ch->lcid = lcid;

	ch->open_ack_received = false;
	if (einfo->smd_ctl_ch_open) {
		SMDXPRT_INFO(einfo, "%s TX OPEN '%s' lcid %u reqxprt %u\n",
				__func__, name, lcid, req_xprt);