diff options
author | Bogdan Hamciuc <bogdan.hamciuc@freescale.com> | 2013-06-07 12:06:49 (GMT) |
---|---|---|
committer | Fleming Andrew-AFLEMING <AFLEMING@freescale.com> | 2013-07-22 21:34:27 (GMT) |
commit | 97b79471912e3befcbd3eee5fe4fe6100e7b05da (patch) | |
tree | 452e169c34f1c3b0f85987b1db365f59881fa465 /drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c | |
parent | b5d1c9489b05431b8ce043895e27f9a7f013afaf (diff) | |
download | linux-fsl-qoriq-97b79471912e3befcbd3eee5fe4fe6100e7b05da.tar.xz |
dpaa_eth: Fix endless loop in case of memory depletion
Check the return value from the buffer-allocating function, in order to
prevent looping forever if memory depletes.
Signed-off-by: Bogdan Hamciuc <bogdan.hamciuc@freescale.com>
Change-Id: If817c367a39a47322dc3e55d6d133d500b324b3b
Reviewed-on: http://git.am.freescale.net:8181/3331
Reviewed-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Tested-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Diffstat (limited to 'drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c')
-rw-r--r-- | drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c b/drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c index ad03b6c..9b96f85 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c @@ -129,7 +129,9 @@ release_bufs: return i; bail_out: - dev_err(dpa_bp->dev, "dpa_bp_add_8_pages() failed\n"); + net_err_ratelimited("dpa_bp_add_8_pages() failed\n"); + WARN_ONCE(1, "Memory allocation failure on Rx\n"); + bm_buffer_set64(&bmb[i], 0); /* * Avoid releasing a completely null buffer; bman_release() requires @@ -178,10 +180,20 @@ void dpaa_eth_refill_bpools(struct dpa_percpu_priv_s *percpu_priv) int *countptr = percpu_priv->dpa_bp_count; int count = *countptr; const struct dpa_bp *dpa_bp = percpu_priv->dpa_bp; + int new_pages; /* Add pages to the buffer pool */ - while (count < CONFIG_FSL_DPAA_ETH_MAX_BUF_COUNT) - count += _dpa_bp_add_8_pages(dpa_bp); + while (count < CONFIG_FSL_DPAA_ETH_MAX_BUF_COUNT) { + new_pages = _dpa_bp_add_8_pages(dpa_bp); + if (unlikely(!new_pages)) { + /* Avoid looping forever if we've temporarily + * run out of memory. We'll try again at the next + * NAPI cycle. + */ + break; + } + count += new_pages; + } *countptr = count; } |