From 03c90850fa449a69b40dbac597e3c971829ea4c1 Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Thu, 23 Mar 2006 01:12:38 -0800 Subject: [PATCH] --- yaml --- r: 23167 b: refs/heads/master c: 0f31f99446270e66c6f18c7d87aadd7db1dad214 h: refs/heads/master i: 23165: ab77a8c7ed82b3d49e6da584342ead8e6c035525 23163: 59f9a4a71ceebf8a7df8811139966093d2773e41 23159: 6e097a7fbf10b057bb47b48122b9f1fc0d50e894 23151: 08866f3dff9ec550e349938c0eca76ddfab02944 23135: 920fefc811b4a99f8313b47e10d4cb97e78f672b 23103: 668d3244dd23dc28fb4dfe36ecb1c03c84b24660 23039: 54509ae5d15bb48f20658f569eb330bc5cc85e27 v: v3 --- [refs] | 2 +- trunk/drivers/net/bnx2.c | 34 +++++++++++++++------------------- trunk/drivers/net/bnx2.h | 2 ++ 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/[refs] b/[refs] index c39f1addab7d..f6ab5a39c07f 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: bf5295bba804a6aead9bc1c0d5970173a9d4e08e +refs/heads/master: 0f31f99446270e66c6f18c7d87aadd7db1dad214 diff --git a/trunk/drivers/net/bnx2.c b/trunk/drivers/net/bnx2.c index c56888e66351..8ce5ae84c832 100644 --- a/trunk/drivers/net/bnx2.c +++ b/trunk/drivers/net/bnx2.c @@ -359,15 +359,11 @@ bnx2_free_mem(struct bnx2 *bp) { int i; - if (bp->stats_blk) { - pci_free_consistent(bp->pdev, sizeof(struct statistics_block), - bp->stats_blk, bp->stats_blk_mapping); - bp->stats_blk = NULL; - } if (bp->status_blk) { - pci_free_consistent(bp->pdev, sizeof(struct status_block), + pci_free_consistent(bp->pdev, bp->status_stats_size, bp->status_blk, bp->status_blk_mapping); bp->status_blk = NULL; + bp->stats_blk = NULL; } if (bp->tx_desc_ring) { pci_free_consistent(bp->pdev, @@ -392,14 +388,13 @@ bnx2_free_mem(struct bnx2 *bp) static int bnx2_alloc_mem(struct bnx2 *bp) { - int i; + int i, status_blk_size; - bp->tx_buf_ring = kmalloc(sizeof(struct sw_bd) * TX_DESC_CNT, - GFP_KERNEL); + bp->tx_buf_ring = kzalloc(sizeof(struct sw_bd) * TX_DESC_CNT, + GFP_KERNEL); if (bp->tx_buf_ring == NULL) return -ENOMEM; - memset(bp->tx_buf_ring, 0, sizeof(struct sw_bd) * TX_DESC_CNT); bp->tx_desc_ring = pci_alloc_consistent(bp->pdev, sizeof(struct tx_bd) * TX_DESC_CNT, @@ -425,21 +420,22 @@ bnx2_alloc_mem(struct bnx2 *bp) } - bp->status_blk = pci_alloc_consistent(bp->pdev, - sizeof(struct status_block), + /* Combine status and statistics blocks into one allocation. */ + status_blk_size = L1_CACHE_ALIGN(sizeof(struct status_block)); + bp->status_stats_size = status_blk_size + + sizeof(struct statistics_block); + + bp->status_blk = pci_alloc_consistent(bp->pdev, bp->status_stats_size, &bp->status_blk_mapping); if (bp->status_blk == NULL) goto alloc_mem_err; - memset(bp->status_blk, 0, sizeof(struct status_block)); + memset(bp->status_blk, 0, bp->status_stats_size); - bp->stats_blk = pci_alloc_consistent(bp->pdev, - sizeof(struct statistics_block), - &bp->stats_blk_mapping); - if (bp->stats_blk == NULL) - goto alloc_mem_err; + bp->stats_blk = (void *) ((unsigned long) bp->status_blk + + status_blk_size); - memset(bp->stats_blk, 0, sizeof(struct statistics_block)); + bp->stats_blk_mapping = bp->status_blk_mapping + status_blk_size; return 0; diff --git a/trunk/drivers/net/bnx2.h b/trunk/drivers/net/bnx2.h index 18bc0919cc9e..5d132b00e8fd 100644 --- a/trunk/drivers/net/bnx2.h +++ b/trunk/drivers/net/bnx2.h @@ -4083,6 +4083,8 @@ struct bnx2 { struct flash_spec *flash_info; u32 flash_size; + + int status_stats_size; }; static u32 bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset);