diff options
author | Dhoat Harpal <hdhoat@codeaurora.org> | 2016-03-28 19:25:27 +0530 |
---|---|---|
committer | Dhoat Harpal <hdhoat@codeaurora.org> | 2016-08-24 17:47:16 +0530 |
commit | 4669c62339c7986e2987a9f42172cb6e0207a4c5 (patch) | |
tree | 344f85f4add3bc8edddfaf34baf6eba7d1288d30 /drivers/soc | |
parent | c605e110ab18604981481a7b502da54640b620bc (diff) |
soc: qcom: glink: Best Fit approach to find intent
Using first fit algorithm to select the remote rx intent from the
list is not optimal way.
Optimize the selection of intent from list using the best fit algorithm.
CRs-Fixed: 1058750
Change-Id: I7b2a70188975b75a0fbcd2a6cb26f28cc0258532
Signed-off-by: Dhoat Harpal <hdhoat@codeaurora.org>
Diffstat (limited to 'drivers/soc')
-rw-r--r-- | drivers/soc/qcom/glink.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/drivers/soc/qcom/glink.c b/drivers/soc/qcom/glink.c index 57e58a57fab7..f54d9c3f4f3d 100644 --- a/drivers/soc/qcom/glink.c +++ b/drivers/soc/qcom/glink.c @@ -1148,6 +1148,7 @@ int ch_pop_remote_rx_intent(struct channel_ctx *ctx, size_t size, { struct glink_core_rx_intent *intent; struct glink_core_rx_intent *intent_tmp; + struct glink_core_rx_intent *best_intent = NULL; unsigned long flags; if (GLINK_MAX_PKT_SIZE < size) { @@ -1170,21 +1171,29 @@ int ch_pop_remote_rx_intent(struct channel_ctx *ctx, size_t size, list_for_each_entry_safe(intent, intent_tmp, &ctx->rmt_rx_intent_list, list) { if (intent->intent_size >= size) { - list_del(&intent->list); - GLINK_DBG_CH(ctx, - "%s: R[%u]:%zu Removed remote intent\n", - __func__, - intent->id, - intent->intent_size); - *riid_ptr = intent->id; - *intent_size = intent->intent_size; - *cookie = intent->cookie; - kfree(intent); - spin_unlock_irqrestore( - &ctx->rmt_rx_intent_lst_lock_lhc2, flags); - return 0; + if (!best_intent) + best_intent = intent; + else if (best_intent->intent_size > intent->intent_size) + best_intent = intent; + if (best_intent->intent_size == size) + break; } } + if (best_intent) { + list_del(&best_intent->list); + GLINK_DBG_CH(ctx, + "%s: R[%u]:%zu Removed remote intent\n", + __func__, + best_intent->id, + best_intent->intent_size); + *riid_ptr = best_intent->id; + *intent_size = best_intent->intent_size; + *cookie = best_intent->cookie; + kfree(best_intent); + spin_unlock_irqrestore( + &ctx->rmt_rx_intent_lst_lock_lhc2, flags); + return 0; + } spin_unlock_irqrestore(&ctx->rmt_rx_intent_lst_lock_lhc2, flags); return -EAGAIN; } |