netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wei Yang <weiyang@linux.vnet.ibm.com>
To: jeffrey.t.kirsher@intel.com
Cc: e1000-devel@lists.sourceforge.net, netdev@vger.kernel.org,
	Wei Yang <weiyang@linux.vnet.ibm.com>
Subject: [PATCH 4/4] e1000e: Not initialize the e1000_ps_page array when packet-split is not used
Date: Mon, 20 May 2013 16:15:07 +0800	[thread overview]
Message-ID: <1369037707-27026-5-git-send-email-weiyang@linux.vnet.ibm.com> (raw)
In-Reply-To: <1369037707-27026-1-git-send-email-weiyang@linux.vnet.ibm.com>

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(-)

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 {
-- 
1.7.5.4

  parent reply	other threads:[~2013-05-20  8:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-20  8:15 [PATCH 0/4] trivial clean up for e1000e driver Wei Yang
2013-05-20  8:15 ` [PATCH 1/4] e1000e: Remove duplicate assignment of default rx/tx ring size Wei Yang
2013-05-20  9:37   ` Jeff Kirsher
2013-05-20 16:24     ` Wei Yang
2013-05-20  8:15 ` [PATCH 2/4] e1000e: Use marco instead of digit for defining e1000_rx_desc_packet_split Wei Yang
2013-05-20  9:37   ` Jeff Kirsher
2013-05-20 16:24     ` Wei Yang
2013-05-20  8:15 ` [PATCH 3/4] e1000e: Calculate the desc_len based on adapter type Wei Yang
2013-05-20  9:37   ` Jeff Kirsher
2013-05-20 16:25     ` Wei Yang
2013-08-22 10:57   ` Jeff Kirsher
2013-08-22 14:26     ` Wei Yang
2013-05-20  8:15 ` Wei Yang [this message]
2013-05-20  9:38   ` [PATCH 4/4] e1000e: Not initialize the e1000_ps_page array when packet-split is not used Jeff Kirsher
2013-05-20 16:25     ` Wei Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1369037707-27026-5-git-send-email-weiyang@linux.vnet.ibm.com \
    --to=weiyang@linux.vnet.ibm.com \
    --cc=e1000-devel@lists.sourceforge.net \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).