aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/marvell/mvpp2.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/marvell/mvpp2.c')
-rw-r--r--drivers/net/ethernet/marvell/mvpp2.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index da61d51df067..3193a7de7197 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -3385,17 +3385,12 @@ static void mvpp2_bm_pool_bufsize_set(struct mvpp2 *priv,
3385 mvpp2_write(priv, MVPP2_POOL_BUF_SIZE_REG(bm_pool->id), val); 3385 mvpp2_write(priv, MVPP2_POOL_BUF_SIZE_REG(bm_pool->id), val);
3386} 3386}
3387 3387
3388/* Free "num" buffers from the pool */ 3388/* Free all buffers from the pool */
3389static int mvpp2_bm_bufs_free(struct mvpp2 *priv, 3389static void mvpp2_bm_bufs_free(struct mvpp2 *priv, struct mvpp2_bm_pool *bm_pool)
3390 struct mvpp2_bm_pool *bm_pool, int num)
3391{ 3390{
3392 int i; 3391 int i;
3393 3392
3394 if (num >= bm_pool->buf_num) 3393 for (i = 0; i < bm_pool->buf_num; i++) {
3395 /* Free all buffers from the pool */
3396 num = bm_pool->buf_num;
3397
3398 for (i = 0; i < num; i++) {
3399 u32 vaddr; 3394 u32 vaddr;
3400 3395
3401 /* Get buffer virtual adress (indirect access) */ 3396 /* Get buffer virtual adress (indirect access) */
@@ -3408,7 +3403,6 @@ static int mvpp2_bm_bufs_free(struct mvpp2 *priv,
3408 3403
3409 /* Update BM driver with number of buffers removed from pool */ 3404 /* Update BM driver with number of buffers removed from pool */
3410 bm_pool->buf_num -= i; 3405 bm_pool->buf_num -= i;
3411 return i;
3412} 3406}
3413 3407
3414/* Cleanup pool */ 3408/* Cleanup pool */
@@ -3416,10 +3410,9 @@ static int mvpp2_bm_pool_destroy(struct platform_device *pdev,
3416 struct mvpp2 *priv, 3410 struct mvpp2 *priv,
3417 struct mvpp2_bm_pool *bm_pool) 3411 struct mvpp2_bm_pool *bm_pool)
3418{ 3412{
3419 int num;
3420 u32 val; 3413 u32 val;
3421 3414
3422 num = mvpp2_bm_bufs_free(priv, bm_pool, bm_pool->buf_num); 3415 mvpp2_bm_bufs_free(priv, bm_pool);
3423 if (bm_pool->buf_num) { 3416 if (bm_pool->buf_num) {
3424 WARN(1, "cannot free all buffers in pool %d\n", bm_pool->id); 3417 WARN(1, "cannot free all buffers in pool %d\n", bm_pool->id);
3425 return 0; 3418 return 0;
@@ -3675,7 +3668,7 @@ mvpp2_bm_pool_use(struct mvpp2_port *port, int pool, enum mvpp2_bm_type type,
3675 MVPP2_BM_LONG_BUF_NUM : 3668 MVPP2_BM_LONG_BUF_NUM :
3676 MVPP2_BM_SHORT_BUF_NUM; 3669 MVPP2_BM_SHORT_BUF_NUM;
3677 else 3670 else
3678 mvpp2_bm_bufs_free(port->priv, new_pool, pkts_num); 3671 mvpp2_bm_bufs_free(port->priv, new_pool);
3679 3672
3680 new_pool->pkt_size = pkt_size; 3673 new_pool->pkt_size = pkt_size;
3681 3674
@@ -3748,7 +3741,7 @@ static int mvpp2_bm_update_mtu(struct net_device *dev, int mtu)
3748 int pkt_size = MVPP2_RX_PKT_SIZE(mtu); 3741 int pkt_size = MVPP2_RX_PKT_SIZE(mtu);
3749 3742
3750 /* Update BM pool with new buffer size */ 3743 /* Update BM pool with new buffer size */
3751 mvpp2_bm_bufs_free(port->priv, port_pool, pkts_num); 3744 mvpp2_bm_bufs_free(port->priv, port_pool);
3752 if (port_pool->buf_num) { 3745 if (port_pool->buf_num) {
3753 WARN(1, "cannot free all buffers in pool %d\n", port_pool->id); 3746 WARN(1, "cannot free all buffers in pool %d\n", port_pool->id);
3754 return -EIO; 3747 return -EIO;