Patchwork [4/4] e1000e: Not initialize the e1000_ps_page array when packet-split is not used

login
register
mail settings
Submitter Wei Yang
Date May 20, 2013, 8:15 a.m.
Message ID <1369037707-27026-5-git-send-email-weiyang@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/244864/
State Awaiting Upstream
Delegated to: David Miller
Headers show

Comments

Wei Yang - May 20, 2013, 8:15 a.m.
When packet split is not used, those fields are still initialized and memory
is allocated for them.

This patch check whether packet split is used and do the initialization base
on the status.

Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
---
 drivers/net/ethernet/intel/e1000e/netdev.c |   38 ++++++++++++++-------------
 1 files changed, 20 insertions(+), 18 deletions(-)
Jeff Kirsher - May 20, 2013, 9:38 a.m.
On 05/20/2013 01:15 AM, Wei Yang wrote:
> When packet split is not used, those fields are still initialized and memory
> is allocated for them.
>
> This patch check whether packet split is used and do the initialization base
> on the status.
>
> Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
> ---
>  drivers/net/ethernet/intel/e1000e/netdev.c |   38 ++++++++++++++-------------
>  1 files changed, 20 insertions(+), 18 deletions(-)
Thanks, I have added the patch to my queue for e1000e.
Wei Yang - May 20, 2013, 4:25 p.m.
On Mon, May 20, 2013 at 02:38:07AM -0700, Jeff Kirsher wrote:
>On 05/20/2013 01:15 AM, Wei Yang wrote:
>> When packet split is not used, those fields are still initialized and memory
>> is allocated for them.
>>
>> This patch check whether packet split is used and do the initialization base
>> on the status.
>>
>> Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
>> ---
>>  drivers/net/ethernet/intel/e1000e/netdev.c |   38 ++++++++++++++-------------
>>  1 files changed, 20 insertions(+), 18 deletions(-)
>Thanks, I have added the patch to my queue for e1000e.
>

Thanks~

Patch

diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index a2e8a53..c75d9cf 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -1690,15 +1690,17 @@  static void e1000_clean_rx_ring(struct e1000_ring *rx_ring)
 			buffer_info->skb = NULL;
 		}
 
-		for (j = 0; j < PS_PAGE_BUFFERS; j++) {
-			ps_page = &buffer_info->ps_pages[j];
-			if (!ps_page->page)
-				break;
-			dma_unmap_page(&pdev->dev, ps_page->dma, PAGE_SIZE,
-				       DMA_FROM_DEVICE);
-			ps_page->dma = 0;
-			put_page(ps_page->page);
-			ps_page->page = NULL;
+		if (adapter->rx_ps_pages) {
+			for (j = 0; j < PS_PAGE_BUFFERS; j++) {
+				ps_page = &buffer_info->ps_pages[j];
+				if (!ps_page->page)
+					break;
+				dma_unmap_page(&pdev->dev, ps_page->dma, PAGE_SIZE,
+					       DMA_FROM_DEVICE);
+				ps_page->dma = 0;
+				put_page(ps_page->page);
+				ps_page->page = NULL;
+			}
 		}
 	}
 
@@ -2355,16 +2357,16 @@  int e1000e_setup_rx_resources(struct e1000_ring *rx_ring)
 	if (!rx_ring->buffer_info)
 		goto err;
 
-	for (i = 0; i < rx_ring->count; i++) {
-		buffer_info = &rx_ring->buffer_info[i];
-		buffer_info->ps_pages = kcalloc(PS_PAGE_BUFFERS,
-						sizeof(struct e1000_ps_page),
-						GFP_KERNEL);
-		if (!buffer_info->ps_pages)
-			goto err_pages;
-	}
-
 	if (adapter->rx_ps_pages) {
+		for (i = 0; i < rx_ring->count; i++) {
+			buffer_info = &rx_ring->buffer_info[i];
+			buffer_info->ps_pages = kcalloc(PS_PAGE_BUFFERS,
+							sizeof(struct e1000_ps_page),
+							GFP_KERNEL);
+			if (!buffer_info->ps_pages)
+				goto err_pages;
+		}
+
 		/* this is a 32 byte descriptor */
 		desc_len = sizeof(union e1000_rx_desc_packet_split);
 	} else {