浏览代码

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>
Chris Lew 7 年之前
父节点
当前提交
290318702b
共有 1 个文件被更改,包括 8 次插入3 次删除
  1. 8 3
      drivers/rpmsg/qcom_glink_native.c

+ 8 - 3
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);
 			spin_lock_irqsave(&channel->intent_lock, flags);
 			idr_for_each_entry(&channel->riids, tmp, iid) {
 			idr_for_each_entry(&channel->riids, tmp, iid) {
 				if (tmp->size >= len && !tmp->in_use) {
 				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);
 			spin_unlock_irqrestore(&channel->intent_lock, flags);
 
 
 			/* We found an available intent */
 			/* We found an available intent */