Commit b4061c13 authored by Alex Elder's avatar Alex Elder Committed by David S. Miller

net: ipa: allocate transaction before pages when replenishing

A transaction failure only occurs if no more transactions are
available for an endpoint.  It's a very cheap test.

When replenishing an RX endpoint buffer, there's no point in
allocating pages if transactions are exhausted.  So don't bother
doing so unless the transaction allocation succeeds.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a9bec7ae
...@@ -1046,14 +1046,14 @@ static int ipa_endpoint_replenish_one(struct ipa_endpoint *endpoint) ...@@ -1046,14 +1046,14 @@ static int ipa_endpoint_replenish_one(struct ipa_endpoint *endpoint)
u32 len; u32 len;
int ret; int ret;
trans = ipa_endpoint_trans_alloc(endpoint, 1);
if (!trans)
return -ENOMEM;
buffer_size = endpoint->data->rx.buffer_size; buffer_size = endpoint->data->rx.buffer_size;
page = dev_alloc_pages(get_order(buffer_size)); page = dev_alloc_pages(get_order(buffer_size));
if (!page) if (!page)
return -ENOMEM; goto err_trans_free;
trans = ipa_endpoint_trans_alloc(endpoint, 1);
if (!trans)
goto err_free_pages;
/* Offset the buffer to make space for skb headroom */ /* Offset the buffer to make space for skb headroom */
offset = NET_SKB_PAD; offset = NET_SKB_PAD;
...@@ -1061,7 +1061,7 @@ static int ipa_endpoint_replenish_one(struct ipa_endpoint *endpoint) ...@@ -1061,7 +1061,7 @@ static int ipa_endpoint_replenish_one(struct ipa_endpoint *endpoint)
ret = gsi_trans_page_add(trans, page, len, offset); ret = gsi_trans_page_add(trans, page, len, offset);
if (ret) if (ret)
goto err_trans_free; goto err_free_pages;
trans->data = page; /* transaction owns page now */ trans->data = page; /* transaction owns page now */
if (++endpoint->replenish_ready == IPA_REPLENISH_BATCH) { if (++endpoint->replenish_ready == IPA_REPLENISH_BATCH) {
...@@ -1073,10 +1073,10 @@ static int ipa_endpoint_replenish_one(struct ipa_endpoint *endpoint) ...@@ -1073,10 +1073,10 @@ static int ipa_endpoint_replenish_one(struct ipa_endpoint *endpoint)
return 0; return 0;
err_trans_free:
gsi_trans_free(trans);
err_free_pages: err_free_pages:
__free_pages(page, get_order(buffer_size)); __free_pages(page, get_order(buffer_size));
err_trans_free:
gsi_trans_free(trans);
return -ENOMEM; return -ENOMEM;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment