summaryrefslogtreecommitdiffstats
path: root/drivers/rpmsg/qcom_glink_native.c
diff options
context:
space:
mode:
authorChris Lew <clew@codeaurora.org>2017-10-27 00:28:56 +0200
committerBjorn Andersson <bjorn.andersson@linaro.org>2017-10-31 05:25:11 +0100
commit290318702bb2e7d74c24fbe52d8184fc79a17e93 (patch)
tree31423b6a9ae72a72196411bab846abc122e5bbd8 /drivers/rpmsg/qcom_glink_native.c
parentrpmsg: glink: Add support to preallocate intents (diff)
downloadlinux-290318702bb2e7d74c24fbe52d8184fc79a17e93.tar.xz
linux-290318702bb2e7d74c24fbe52d8184fc79a17e93.zip
rpmsg: glink: Use best fit intent during tx
Intents can vary in size, try to find the best fitting remote intent instead of first fit when sending a message to the remote proc. Signed-off-by: Chris Lew <clew@codeaurora.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Diffstat (limited to 'drivers/rpmsg/qcom_glink_native.c')
-rw-r--r--drivers/rpmsg/qcom_glink_native.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
index 2dff77882ced..80d9af307b40 100644
--- a/drivers/rpmsg/qcom_glink_native.c
+++ b/drivers/rpmsg/qcom_glink_native.c
@@ -1257,11 +1257,16 @@ static int __qcom_glink_send(struct glink_channel *channel,
spin_lock_irqsave(&channel->intent_lock, flags);
idr_for_each_entry(&channel->riids, tmp, iid) {
if (tmp->size >= len && !tmp->in_use) {
- tmp->in_use = true;
- intent = tmp;
- break;
+ if (!intent)
+ intent = tmp;
+ else if (intent->size > tmp->size)
+ intent = tmp;
+ if (intent->size == len)
+ break;
}
}
+ if (intent)
+ intent->in_use = true;
spin_unlock_irqrestore(&channel->intent_lock, flags);
/* We found an available intent */