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

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

Merge "soc: qcom: glink_smd_xprt: Introduce receive command lock"

parents 0f8fbfe6 abee7be6
Loading
Loading
Loading
Loading
+42 −4
Original line number Diff line number Diff line
@@ -82,6 +82,8 @@ enum command_types {
 * @in_ssr_lock:	Lock to protect the @in_ssr.
 * @smd_ctl_ch_open:	Indicates that @smd_ch is fully open.
 * @work:		Work item for processing migration data.
 * @rx_cmd_lock:	The transport interface lock to notify about received
 *			commands in a sequential manner.
 *
 * Each transport registered with the core is represented by a single instance
 * of this structure which allows for complete management of the transport.
@@ -102,6 +104,7 @@ struct edge_info {
	struct mutex in_ssr_lock;
	bool smd_ctl_ch_open;
	struct work_struct work;
	struct mutex rx_cmd_lock;
};

/**
@@ -375,11 +378,13 @@ static void process_ctl_event(struct work_struct *work)
			}

			ch->rcid = cmd.id;
			mutex_lock(&einfo->rx_cmd_lock);
			einfo->xprt_if.glink_core_if_ptr->rx_cmd_ch_remote_open(
								&einfo->xprt_if,
								cmd.id,
								name,
								cmd.priority);
			mutex_unlock(&einfo->rx_cmd_lock);
		} else if (cmd.cmd == CMD_OPEN_ACK) {
			SMDXPRT_INFO("%s RX OPEN ACK lcid %u; xprt_req %u\n",
				__func__, cmd.id, cmd.priority);
@@ -398,10 +403,12 @@ static void process_ctl_event(struct work_struct *work)
			}

			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("%s RX REMOTE CLOSE rcid %u\n", __func__,
					cmd.id);
@@ -418,10 +425,12 @@ static void process_ctl_event(struct work_struct *work)
						__func__, cmd.id);

			if (found && !ch->remote_legacy) {
				mutex_lock(&einfo->rx_cmd_lock);
				einfo->xprt_if.glink_core_if_ptr->
							rx_cmd_ch_remote_close(
								&einfo->xprt_if,
								cmd.id);
				mutex_unlock(&einfo->rx_cmd_lock);
			} else {
				/* not found or a legacy channel */
				SMDXPRT_INFO("%s Sim RX CLOSE ACK lcid %u\n",
@@ -457,9 +466,11 @@ static void process_ctl_event(struct work_struct *work)
			rcu_id = srcu_read_lock(&einfo->ssr_sync);
			smd_data_ch_close(ch);
			srcu_read_unlock(&einfo->ssr_sync, rcu_id);
			mutex_lock(&einfo->rx_cmd_lock);
			einfo->xprt_if.glink_core_if_ptr->rx_cmd_ch_close_ack(
								&einfo->xprt_if,
								cmd.id);
			mutex_unlock(&einfo->rx_cmd_lock);
		}
	}
}
@@ -541,10 +552,12 @@ static void process_tx_done(struct work_struct *work)
	riid = ch_work->iid;
	einfo = ch->edge;
	kfree(ch_work);
	mutex_lock(&einfo->rx_cmd_lock);
	einfo->xprt_if.glink_core_if_ptr->rx_cmd_tx_done(&einfo->xprt_if,
								ch->rcid,
								riid,
								false);
	mutex_unlock(&einfo->rx_cmd_lock);
}

/**
@@ -572,11 +585,13 @@ static void process_open_event(struct work_struct *work)
	if (ch->remote_legacy || !ch->rcid) {
		ch->remote_legacy = true;
		ch->rcid = ch->lcid + LEGACY_RCID_CHANNEL_OFFSET;
		mutex_lock(&einfo->rx_cmd_lock);
		einfo->xprt_if.glink_core_if_ptr->rx_cmd_ch_remote_open(
							&einfo->xprt_if,
							ch->rcid,
							ch->name,
							SMD_TRANS_XPRT_ID);
		mutex_unlock(&einfo->rx_cmd_lock);
	}
	kfree(ch_work);
}
@@ -595,10 +610,13 @@ static void process_close_event(struct work_struct *work)
	ch = ch_work->ch;
	einfo = ch->edge;
	kfree(ch_work);
	if (ch->remote_legacy)
	if (ch->remote_legacy) {
		mutex_lock(&einfo->rx_cmd_lock);
		einfo->xprt_if.glink_core_if_ptr->rx_cmd_ch_remote_close(
								&einfo->xprt_if,
								ch->rcid);
		mutex_unlock(&einfo->rx_cmd_lock);
	}
	ch->rcid = 0;
}

@@ -632,9 +650,11 @@ static void process_status_event(struct work_struct *work)
	if (set & TIOCM_RI)
		sigs |= SMD_RI_SIG;

	mutex_lock(&einfo->rx_cmd_lock);
	einfo->xprt_if.glink_core_if_ptr->rx_cmd_remote_sigs(&einfo->xprt_if,
								ch->rcid,
								sigs);
	mutex_unlock(&einfo->rx_cmd_lock);
}

/**
@@ -651,14 +671,20 @@ static void process_reopen_event(struct work_struct *work)
	ch = ch_work->ch;
	einfo = ch->edge;
	kfree(ch_work);
	if (ch->remote_legacy)
	if (ch->remote_legacy) {
		mutex_lock(&einfo->rx_cmd_lock);
		einfo->xprt_if.glink_core_if_ptr->rx_cmd_ch_remote_close(
								&einfo->xprt_if,
								ch->rcid);
	if (ch->local_legacy)
		mutex_unlock(&einfo->rx_cmd_lock);
	}
	if (ch->local_legacy) {
		mutex_lock(&einfo->rx_cmd_lock);
		einfo->xprt_if.glink_core_if_ptr->rx_cmd_ch_close_ack(
								&einfo->xprt_if,
								ch->lcid);
		mutex_unlock(&einfo->rx_cmd_lock);
	}
}

/**
@@ -713,11 +739,13 @@ static void process_data_event(struct work_struct *work)
						__func__, "<SMDXPRT>", ch->name,
						ch->lcid, ch->rcid);
				ch->intent_req = true;
				mutex_lock(&einfo->rx_cmd_lock);
				einfo->xprt_if.glink_core_if_ptr->
						rx_cmd_remote_rx_intent_req(
								&einfo->xprt_if,
								ch->rcid,
								pkt_remaining);
				mutex_unlock(&einfo->rx_cmd_lock);
				return;
			}
		}
@@ -847,9 +875,11 @@ static void smd_data_ch_close(struct channel *ch)
		smd_close(ch->smd_ch);
		ch->smd_ch = NULL;
	} else if (ch->local_legacy) {
		mutex_lock(&ch->edge->rx_cmd_lock);
		ch->edge->xprt_if.glink_core_if_ptr->rx_cmd_ch_close_ack(
							&ch->edge->xprt_if,
							ch->lcid);
		mutex_unlock(&ch->edge->rx_cmd_lock);
	}

	ch->local_legacy = false;
@@ -1030,12 +1060,14 @@ static void tx_cmd_version(struct glink_transport_if *if_ptr, uint32_t version,
	struct edge_info *einfo;

	einfo = container_of(if_ptr, struct edge_info, xprt_if);
	mutex_lock(&einfo->rx_cmd_lock);
	einfo->xprt_if.glink_core_if_ptr->rx_cmd_version_ack(&einfo->xprt_if,
								version,
								features);
	einfo->xprt_if.glink_core_if_ptr->rx_cmd_version(&einfo->xprt_if,
								version,
								features);
	mutex_unlock(&einfo->rx_cmd_lock);
}

/**
@@ -1191,10 +1223,13 @@ static int tx_cmd_ch_open(struct glink_transport_if *if_ptr, uint32_t lcid,
		ch->local_legacy = true;
		ch->remote_legacy = true;
		ret = add_platform_driver(ch);
		if (!ret)
		if (!ret) {
			mutex_lock(&einfo->rx_cmd_lock);
			einfo->xprt_if.glink_core_if_ptr->rx_cmd_ch_open_ack(
						&einfo->xprt_if,
						ch->lcid, SMD_TRANS_XPRT_ID);
			mutex_unlock(&einfo->rx_cmd_lock);
		}
	}

	srcu_read_unlock(&einfo->ssr_sync, rcu_id);
@@ -1702,6 +1737,7 @@ static int tx_cmd_rx_intent_req(struct glink_transport_if *if_ptr,
			break;
	}
	spin_unlock_irqrestore(&einfo->channels_lock, flags);
	mutex_lock(&einfo->rx_cmd_lock);
	einfo->xprt_if.glink_core_if_ptr->rx_cmd_rx_intent_req_ack(
								&einfo->xprt_if,
								ch->rcid,
@@ -1711,6 +1747,7 @@ static int tx_cmd_rx_intent_req(struct glink_transport_if *if_ptr,
							ch->rcid,
							ch->next_intent_id++,
							size);
	mutex_unlock(&einfo->rx_cmd_lock);
	return 0;
}

@@ -1918,6 +1955,7 @@ static int __init glink_smd_xprt_init(void)
		init_srcu_struct(&einfo->ssr_sync);
		mutex_init(&einfo->smd_lock);
		mutex_init(&einfo->in_ssr_lock);
		mutex_init(&einfo->rx_cmd_lock);
		INIT_DELAYED_WORK(&einfo->ssr_work, ssr_work_func);
		INIT_WORK(&einfo->work, process_ctl_event);
		rc = glink_core_register_transport(&einfo->xprt_if,