rpmsg: glink: Use best fit intent during tx
authorChris Lew <clew@codeaurora.org>
Thu, 26 Oct 2017 22:28:56 +0000 (15:28 -0700)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Tue, 31 Oct 2017 04:25:11 +0000 (21:25 -0700)
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>
drivers/rpmsg/qcom_glink_native.c

index 2dff77882ced41ae6393ec5c227a12f5c89a56a0..80d9af307b409c46e5f969660d7ecf9512284745 100644 (file)
@@ -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 */