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

Commit 21ceab94 authored by Chris Lew's avatar Chris Lew
Browse files

rpmsg: glink: Try to send rx done in irq



Some remote processors and usecases such as audio playback are
sensitive to the response time of rx done. Try to send the rx done cmd
from irq context. If trysend fails, defer the rx done work like before.

Change-Id: I862349b20f4ade11fa62f91c9c409f9b1b79d478
Signed-off-by: default avatarChris Lew <clew@codeaurora.org>
parent 4ae7b668
Loading
Loading
Loading
Loading
+42 −22
Original line number Diff line number Diff line
@@ -512,40 +512,54 @@ static void qcom_glink_send_close_ack(struct qcom_glink *glink,
	qcom_glink_tx(glink, &req, sizeof(req), NULL, 0, true);
}

static void qcom_glink_rx_done_work(struct kthread_work *work)

static int __qcom_glink_rx_done(struct qcom_glink *glink,
				struct glink_channel *channel,
				struct glink_core_rx_intent *intent,
				bool wait)
{
	struct glink_channel *channel = container_of(work, struct glink_channel,
						     intent_work);
	struct qcom_glink *glink = channel->glink;
	struct glink_core_rx_intent *intent, *tmp;
	struct {
		u16 id;
		u16 lcid;
		u32 liid;
	} __packed cmd;

	unsigned int cid = channel->lcid;
	unsigned int iid;
	bool reuse;
	unsigned long flags;

	spin_lock_irqsave(&channel->intent_lock, flags);
	list_for_each_entry_safe(intent, tmp, &channel->done_intents, node) {
		list_del(&intent->node);
		spin_unlock_irqrestore(&channel->intent_lock, flags);
		iid = intent->id;
		reuse = intent->reuse;
	unsigned int iid = intent->id;
	bool reuse = intent->reuse;
	int ret;

	cmd.id = reuse ? RPM_CMD_RX_DONE_W_REUSE : RPM_CMD_RX_DONE;
	cmd.lcid = cid;
	cmd.liid = iid;

		CH_INFO(channel, "reuse:%d liid:%d", reuse, iid);
		qcom_glink_tx(glink, &cmd, sizeof(cmd), NULL, 0, true);
	ret = qcom_glink_tx(glink, &cmd, sizeof(cmd), NULL, 0, wait);
	if (ret)
		return ret;

	if (!reuse) {
		kfree(intent->data);
		kfree(intent);
	}

	CH_INFO(channel, "reuse:%d liid:%d", reuse, iid);
	return 0;
}

static void qcom_glink_rx_done_work(struct kthread_work *work)
{
	struct glink_channel *channel = container_of(work, struct glink_channel,
						     intent_work);
	struct qcom_glink *glink = channel->glink;
	struct glink_core_rx_intent *intent, *tmp;
	unsigned long flags;

	spin_lock_irqsave(&channel->intent_lock, flags);
	list_for_each_entry_safe(intent, tmp, &channel->done_intents, node) {
		list_del(&intent->node);
		spin_unlock_irqrestore(&channel->intent_lock, flags);

		__qcom_glink_rx_done(glink, channel, intent, true);

		spin_lock_irqsave(&channel->intent_lock, flags);
	}
	spin_unlock_irqrestore(&channel->intent_lock, flags);
@@ -555,6 +569,8 @@ static void qcom_glink_rx_done(struct qcom_glink *glink,
			       struct glink_channel *channel,
			       struct glink_core_rx_intent *intent)
{
	int ret = -EAGAIN;

	/* We don't send RX_DONE to intentless systems */
	if (glink->intentless) {
		kfree(intent->data);
@@ -571,11 +587,15 @@ static void qcom_glink_rx_done(struct qcom_glink *glink,

	/* Schedule the sending of a rx_done indication */
	spin_lock(&channel->intent_lock);
	list_add_tail(&intent->node, &channel->done_intents);
	spin_unlock(&channel->intent_lock);
	if (list_empty(&channel->done_intents))
		ret = __qcom_glink_rx_done(glink, channel, intent, false);

	if (ret) {
		list_add_tail(&intent->node, &channel->done_intents);
		kthread_queue_work(&glink->kworker, &channel->intent_work);
	}
	spin_unlock(&channel->intent_lock);
}

/**
 * qcom_glink_receive_version() - receive version/features from remote system