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

Commit 8aca0ec6 authored by Dhoat Harpal's avatar Dhoat Harpal
Browse files

soc: qcom: glink_smd_xprt: Serialized open ack notify and signal event



SMD channel can get into OPENED state before even the G-Link channel
gets into OPENED/CONNECTED state. This can cause the SMD channel events
to get dropped.

Synchronize handling the SMD_OPEN_EVENT & subsequent events in an SMD
channel with the G-Link channel open operation.

CRs-Fixed: 997404
Change-Id: I4c44011b7fa3b59cbe70a125735e04a076c4d3ca
Signed-off-by: default avatarDhoat Harpal <hdhoat@codeaurora.org>
parent edf4d230
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <linux/srcu.h>
#include <linux/termios.h>
#include <linux/workqueue.h>
#include <linux/completion.h>
#include <soc/qcom/smd.h>
#include <soc/qcom/glink.h>
#include "glink_core_if.h"
@@ -162,6 +163,7 @@ struct channel {
	bool streaming_ch;
	bool tx_resume_needed;
	bool is_tasklet_enabled;
	struct completion open_notifier;
};

/**
@@ -328,6 +330,7 @@ static void process_ctl_event(struct work_struct *work)
				ch->edge = einfo;
				mutex_init(&ch->ch_probe_lock);
				mutex_init(&ch->ch_tasklet_lock);
				init_completion(&ch->open_notifier);
				INIT_LIST_HEAD(&ch->intents);
				INIT_LIST_HEAD(&ch->used_intents);
				spin_lock_init(&ch->intents_lock);
@@ -420,7 +423,7 @@ static void process_ctl_event(struct work_struct *work)
						__func__, cmd.id);
				continue;
			}

			reinit_completion(&ch->open_notifier);
			add_platform_driver(ch);
			mutex_lock(&einfo->rx_cmd_lock);
			einfo->xprt_if.glink_core_if_ptr->rx_cmd_ch_open_ack(
@@ -428,6 +431,7 @@ static void process_ctl_event(struct work_struct *work)
								cmd.id,
								cmd.priority);
			mutex_unlock(&einfo->rx_cmd_lock);
			complete_all(&ch->open_notifier);
		} else if (cmd.cmd == CMD_CLOSE) {
			SMDXPRT_INFO(einfo, "%s RX REMOTE CLOSE rcid %u\n",
					__func__, cmd.id);
@@ -618,6 +622,7 @@ static void process_open_event(struct work_struct *work)
		ch->is_tasklet_enabled = true;
	}
	mutex_unlock(&ch->ch_tasklet_lock);
	wait_for_completion(&ch->open_notifier);
	kfree(ch_work);
}

@@ -1215,6 +1220,7 @@ static int tx_cmd_ch_open(struct glink_transport_if *if_ptr, uint32_t lcid,
		ch->edge = einfo;
		mutex_init(&ch->ch_probe_lock);
		mutex_init(&ch->ch_tasklet_lock);
		init_completion(&ch->open_notifier);
		INIT_LIST_HEAD(&ch->intents);
		INIT_LIST_HEAD(&ch->used_intents);
		spin_lock_init(&ch->intents_lock);
@@ -1285,6 +1291,7 @@ static int tx_cmd_ch_open(struct glink_transport_if *if_ptr, uint32_t lcid,
		ch->rcid = lcid + LEGACY_RCID_CHANNEL_OFFSET;
		ch->local_legacy = true;
		ch->remote_legacy = true;
		reinit_completion(&ch->open_notifier);
		ret = add_platform_driver(ch);
		if (!ret) {
			mutex_lock(&einfo->rx_cmd_lock);
@@ -1293,6 +1300,7 @@ static int tx_cmd_ch_open(struct glink_transport_if *if_ptr, uint32_t lcid,
						ch->lcid, SMD_TRANS_XPRT_ID);
			mutex_unlock(&einfo->rx_cmd_lock);
		}
		complete_all(&ch->open_notifier);
	}

	srcu_read_unlock(&einfo->ssr_sync, rcu_id);