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

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

Merge "rpmsg: glink: Use spinlock in tx path"

parents 54289995 9f1263b4
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@ struct qcom_glink {
	spinlock_t rx_lock;
	struct list_head rx_queue;

	struct mutex tx_lock;
	spinlock_t tx_lock;

	spinlock_t idr_lock;
	struct idr lcids;
@@ -298,15 +298,14 @@ static int qcom_glink_tx(struct qcom_glink *glink,
			 const void *data, size_t dlen, bool wait)
{
	unsigned int tlen = hlen + dlen;
	int ret;
	unsigned long flags;
	int ret = 0;

	/* Reject packets that are too big */
	if (tlen >= glink->tx_pipe->length)
		return -EINVAL;

	ret = mutex_lock_interruptible(&glink->tx_lock);
	if (ret)
		return ret;
	spin_lock_irqsave(&glink->tx_lock, flags);

	while (qcom_glink_tx_avail(glink) < tlen) {
		if (!wait) {
@@ -314,7 +313,12 @@ static int qcom_glink_tx(struct qcom_glink *glink,
			goto out;
		}

		/* Wait without holding the tx_lock */
		spin_unlock_irqrestore(&glink->tx_lock, flags);

		usleep_range(10000, 15000);

		spin_lock_irqsave(&glink->tx_lock, flags);
	}

	qcom_glink_tx_write(glink, hdr, hlen, data, dlen);
@@ -323,7 +327,7 @@ static int qcom_glink_tx(struct qcom_glink *glink,
	mbox_client_txdone(glink->mbox_chan, 0);

out:
	mutex_unlock(&glink->tx_lock);
	spin_unlock_irqrestore(&glink->tx_lock, flags);

	return ret;
}
@@ -1623,7 +1627,7 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev,
	glink->features = features;
	glink->intentless = intentless;

	mutex_init(&glink->tx_lock);
	spin_lock_init(&glink->tx_lock);
	spin_lock_init(&glink->rx_lock);
	INIT_LIST_HEAD(&glink->rx_queue);
	INIT_WORK(&glink->rx_work, qcom_glink_work);