linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Ajit Khaparde <ajitk@serverengines.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [patch 02/74] be2net: Fix to avoid a crash seen on PPC with LRO and Jumbo frames.
Date: Thu, 13 Aug 2009 12:49:37 -0700	[thread overview]
Message-ID: <20090813195124.932621003@mini.kroah.org> (raw)
In-Reply-To: <20090813195705.GA22393@kroah.com>

[-- Attachment #1: be2net-fix-to-avoid-a-crash-seen-on-ppc-with-lro-and-jumbo-frames.patch --]
[-- Type: text/plain, Size: 5015 bytes --]

2.6.30-stable review patch.  If anyone has any objections, please let us know.

------------------

From: Ajit Khaparde <ajitk@serverengines.com>

[ Upstream commit bd46cb6cf11867130a41ea9546dd65688b71f3c2 ]

While testing the driver on PPC, we ran into a crash with LRO, Jumbo frames.
With CONFIG_PPC_64K_PAGES configured (a default in PPC), MAX_SKB_FRAGS drops to 3 and we were crossing the array limits on skb_shinfo(skb)->frags[].
Now we coalesce the frags from the same physical page into one slot in
skb_shinfo(skb)->frags[] and go to the next index when the frag is from

different physical page.

This patch is against the net-2.6 tree.

Signed-off-by: Ajit Khaparde <ajitk@serverengines.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/net/benet/be.h         |    2 -
 drivers/net/benet/be_ethtool.c |    4 +--
 drivers/net/benet/be_main.c    |   45 +++++++++++++++++++++++++++++------------
 3 files changed, 35 insertions(+), 16 deletions(-)

--- a/drivers/net/benet/be_ethtool.c
+++ b/drivers/net/benet/be_ethtool.c
@@ -162,8 +162,8 @@ be_set_coalesce(struct net_device *netde
 		return -EINVAL;
 
 	adapter->max_rx_coal = coalesce->rx_max_coalesced_frames;
-	if (adapter->max_rx_coal > MAX_SKB_FRAGS)
-		adapter->max_rx_coal = MAX_SKB_FRAGS - 1;
+	if (adapter->max_rx_coal > BE_MAX_FRAGS_PER_FRAME)
+		adapter->max_rx_coal = BE_MAX_FRAGS_PER_FRAME;
 
 	/* if AIC is being turned on now, start with an EQD of 0 */
 	if (rx_eq->enable_aic == 0 &&
--- a/drivers/net/benet/be.h
+++ b/drivers/net/benet/be.h
@@ -73,7 +73,7 @@ static inline char *nic_name(struct pci_
 #define RX_FRAGS_REFILL_WM	(RX_Q_LEN - MAX_RX_POST)
 
 #define BE_MAX_LRO_DESCRIPTORS  16
-#define BE_MAX_FRAGS_PER_FRAME  16
+#define BE_MAX_FRAGS_PER_FRAME  (min((u32) 16, (u32) MAX_SKB_FRAGS))
 
 struct be_dma_mem {
 	void *va;
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -682,7 +682,7 @@ static void skb_fill_rx_data(struct be_a
 {
 	struct be_queue_info *rxq = &adapter->rx_obj.q;
 	struct be_rx_page_info *page_info;
-	u16 rxq_idx, i, num_rcvd;
+	u16 rxq_idx, i, num_rcvd, j;
 	u32 pktsize, hdr_len, curr_frag_len;
 	u8 *start;
 
@@ -725,22 +725,33 @@ static void skb_fill_rx_data(struct be_a
 
 	/* More frags present for this completion */
 	pktsize -= curr_frag_len; /* account for above copied frag */
-	for (i = 1; i < num_rcvd; i++) {
+	for (i = 1, j = 0; i < num_rcvd; i++) {
 		index_inc(&rxq_idx, rxq->len);
 		page_info = get_rx_page_info(adapter, rxq_idx);
 
 		curr_frag_len = min(pktsize, rx_frag_size);
 
-		skb_shinfo(skb)->frags[i].page = page_info->page;
-		skb_shinfo(skb)->frags[i].page_offset = page_info->page_offset;
-		skb_shinfo(skb)->frags[i].size = curr_frag_len;
+		/* Coalesce all frags from the same physical page in one slot */
+		if (page_info->page_offset == 0) {
+			/* Fresh page */
+			j++;
+			skb_shinfo(skb)->frags[j].page = page_info->page;
+			skb_shinfo(skb)->frags[j].page_offset =
+							page_info->page_offset;
+			skb_shinfo(skb)->frags[j].size = 0;
+			skb_shinfo(skb)->nr_frags++;
+		} else {
+			put_page(page_info->page);
+		}
+
+		skb_shinfo(skb)->frags[j].size += curr_frag_len;
 		skb->len += curr_frag_len;
 		skb->data_len += curr_frag_len;
-		skb_shinfo(skb)->nr_frags++;
 		pktsize -= curr_frag_len;
 
 		memset(page_info, 0, sizeof(*page_info));
 	}
+	BUG_ON(j > MAX_SKB_FRAGS);
 
 	be_rx_stats_update(adapter, pktsize, num_rcvd);
 	return;
@@ -803,7 +814,7 @@ static void be_rx_compl_process_lro(stru
 	struct skb_frag_struct rx_frags[BE_MAX_FRAGS_PER_FRAME];
 	struct be_queue_info *rxq = &adapter->rx_obj.q;
 	u32 num_rcvd, pkt_size, remaining, vlanf, curr_frag_len;
-	u16 i, rxq_idx = 0, vid;
+	u16 i, rxq_idx = 0, vid, j;
 
 	num_rcvd = AMAP_GET_BITS(struct amap_eth_rx_compl, numfrags, rxcp);
 	pkt_size = AMAP_GET_BITS(struct amap_eth_rx_compl, pktsize, rxcp);
@@ -811,20 +822,28 @@ static void be_rx_compl_process_lro(stru
 	rxq_idx = AMAP_GET_BITS(struct amap_eth_rx_compl, fragndx, rxcp);
 
 	remaining = pkt_size;
-	for (i = 0; i < num_rcvd; i++) {
+	for (i = 0, j = -1; i < num_rcvd; i++) {
 		page_info = get_rx_page_info(adapter, rxq_idx);
 
 		curr_frag_len = min(remaining, rx_frag_size);
 
-		rx_frags[i].page = page_info->page;
-		rx_frags[i].page_offset = page_info->page_offset;
-		rx_frags[i].size = curr_frag_len;
-		remaining -= curr_frag_len;
+		/* Coalesce all frags from the same physical page in one slot */
+		if (i == 0 || page_info->page_offset == 0) {
+			/* First frag or Fresh page */
+			j++;
+			rx_frags[j].page = page_info->page;
+			rx_frags[j].page_offset = page_info->page_offset;
+			rx_frags[j].size = 0;
+		} else {
+			put_page(page_info->page);
+		}
+		rx_frags[j].size += curr_frag_len;
 
+		remaining -= curr_frag_len;
 		index_inc(&rxq_idx, rxq->len);
-
 		memset(page_info, 0, sizeof(*page_info));
 	}
+	BUG_ON(j > MAX_SKB_FRAGS);
 
 	if (likely(!vlanf)) {
 		lro_receive_frags(&adapter->rx_obj.lro_mgr, rx_frags, pkt_size,



  parent reply	other threads:[~2009-08-13 19:59 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090813194935.985368088@mini.kroah.org>
2009-08-13 19:57 ` [patch 00/74] 2.6.30.5-stable review Greg KH
2009-08-13 19:49   ` [patch 01/74] iwlwifi: only show active power level via sysfs Greg KH
2009-08-13 19:49   ` Greg KH [this message]
2009-08-13 19:49   ` [patch 03/74] E100: work around the driver using streaming DMA mapping for RX descriptors Greg KH
2009-08-13 19:49   ` [patch 04/74] ipsec: Fix name of CAST algorithm Greg KH
2009-08-13 19:49   ` [patch 05/74] sky2: Fix checksum endianness Greg KH
2009-08-13 19:49   ` [patch 06/74] usbnet cdc_subset: fix issues talking to PXA gadgets Greg KH
2009-08-13 19:49   ` [patch 07/74] net: sk_prot_alloc() should not blindly overwrite memory Greg KH
2009-08-13 19:49   ` [patch 08/74] net: sock_copy() fixes Greg KH
2009-08-13 19:49   ` [patch 09/74] gro: Flush GRO packets in napi_disable_pending path Greg KH
2009-08-13 19:49   ` [patch 10/74] gso: Stop fraglists from escaping Greg KH
2009-08-13 19:49   ` [patch 11/74] net: Move rx skb_orphan call to where needed Greg KH
2009-08-13 19:49   ` [patch 12/74] inet: Call skb_orphan before tproxy activates Greg KH
2009-08-13 19:49   ` [patch 13/74] drm/i915: Save/restore cursor state on suspend/resume Greg KH
2009-08-13 19:49   ` [patch 14/74] drm/i915: add ignore lvds quirk info for AOpen Mini PC Greg KH
2009-08-13 19:49   ` [patch 15/74] drm/i915: apply G45 vblank count code to all G4x chips and fix max_frame_count Greg KH
2009-08-13 19:49   ` [patch 16/74] drm/i915: avoid non-atomic sysrq execution Greg KH
2009-08-13 19:49   ` [patch 17/74] drm/i915: Skip lvds with Aopen i945GTt-VFA Greg KH
2009-08-13 19:49   ` [patch 18/74] drm/i915: Hook connector to encoder during load detection (fixes tv/vga detect) Greg KH
2009-08-13 19:49   ` [patch 19/74] drm/i915: initialize fence registers to zero when loading GEM Greg KH
2009-08-13 19:49   ` [patch 20/74] drm/i915: Set SSC frequency for 8xx chips correctly Greg KH
2009-08-13 19:49   ` [patch 21/74] sysfs: fix hardlink count on device_move Greg KH
2009-08-13 19:49   ` [patch 22/74] USB: storage: raise timeout in usb_stor_Bulk_max_lun Greg KH
2009-08-13 19:49   ` [patch 23/74] edac: x38 fix mchbar high register addr Greg KH
2009-08-13 19:49   ` [patch 24/74] Make SCSI SG v4 driver enabled by default and remove EXPERIMENTAL dependency, since udev depends on BSG Greg KH
2009-08-13 19:50   ` [patch 25/74] SCSI: libsas: reuse the original port when hotplugging phys in wide ports Greg KH
2009-08-13 19:50   ` [patch 26/74] cifs: fix error handling in mount-time DFS referral chasing code Greg KH
2009-08-13 19:50   ` [patch 27/74] thinkpad-acpi: disable broken bay and dock subdrivers Greg KH
2009-08-13 19:50   ` [patch 28/74] thinkpad-acpi: fix incorrect use of TPACPI_BRGHT_MODE_ECNVRAM Greg KH
2009-08-13 22:06     ` Stefan Lippers-Hollmann
2009-08-13 22:13       ` Stefan Lippers-Hollmann
2009-08-13 22:29       ` Greg KH
2009-08-13 19:50   ` [patch 29/74] nilfs2: fix oops due to inconsistent state in page with discrete b-tree nodes Greg KH
2009-08-13 19:50   ` [patch 30/74] tracing: Fix invalid function_graph entry Greg KH
2009-08-13 19:50   ` [patch 31/74] tracing: Fix missing function_graph events when we splice_read from trace_pipe Greg KH
2009-08-13 19:50   ` [patch 32/74] parisc: isa-eeprom - Fix loff_t usage Greg KH
2009-08-13 19:50   ` [patch 33/74] cfg80211: add two missing NULL pointer checks Greg KH
2009-08-13 19:50   ` [patch 34/74] posix-timers: Fix oops in clock_nanosleep() with CLOCK_MONOTONIC_RAW Greg KH
2009-08-13 19:50   ` [patch 35/74] PM / ACPI: HP G7000 Notebook needs a SCI_EN resume quirk Greg KH
2009-08-13 19:50   ` [patch 36/74] powerpc/mpc83xx: Fix usb mux setup for mpc834x Greg KH
2009-08-13 19:50   ` [patch 37/74] hugetlbfs: fix i_blocks accounting Greg KH
2009-08-13 19:50   ` [patch 38/74] page-allocator: preserve PFN ordering when __GFP_COLD is set Greg KH
2009-08-13 19:50   ` [patch 39/74] x86: Fix CPA memtype reserving in the set_pages_array*() cases Greg KH
2009-08-13 19:50   ` [patch 40/74] x86: fix assembly constraints in native_save_fl() Greg KH
2009-08-13 19:50   ` [patch 41/74] x86, pat: Fix set_memory_wc related corruption Greg KH
2009-08-13 19:50   ` [patch 42/74] md/raid6: release spare page at ->stop() Greg KH
2009-08-13 19:50   ` [patch 43/74] md: when a level change reduces the number of devices, remove the excess Greg KH
2009-08-13 19:50   ` [patch 44/74] ide: fix handling of unexpected IRQs vs request_irq() Greg KH
2009-08-13 19:50   ` [patch 45/74] ide: relax DMA info validity checking Greg KH
2009-08-13 19:50   ` [patch 46/74] hwmon: (asus_atk0110) Fix upper limit readings Greg KH
2009-08-13 19:50   ` [patch 47/74] hwmon: (smsc47m1) Differentiate between LPC47M233 and LPC47M292 Greg KH
2009-08-13 19:50   ` [patch 48/74] i2c/tsl2550: Fix lux value in dark environment Greg KH
2009-08-13 19:50   ` [patch 49/74] firewire: sbp2: add support for disks >2 TB (and 16 bytes long CDBs) Greg KH
2009-08-13 19:50   ` [patch 50/74] ieee1394: " Greg KH
2009-08-13 19:50   ` [patch 51/74] atl1c: WAKE_MCAST tested twice, not WAKE_UCAST Greg KH
2009-08-13 19:50   ` [patch 52/74] atl1c: add missing parentheses Greg KH
2009-08-13 19:50   ` [patch 53/74] atl1c: misplaced parenthesis Greg KH
2009-08-13 19:50   ` [patch 54/74] md: Handle growth of v1.x metadata correctly Greg KH
2009-08-13 19:50   ` [patch 55/74] execve: must clear current->clear_child_tid Greg KH
2009-08-13 19:50   ` [patch 56/74] flat: fix uninitialized ptr with shared libs Greg KH
2009-08-13 19:50   ` [patch 57/74] compat_ioctl: hook up compat handler for FIEMAP ioctl Greg KH
2009-08-13 19:50   ` [patch 58/74] generic-ipi: fix hotplug_cfd() Greg KH
2009-08-13 19:50   ` [patch 59/74] Staging: rt2870: Revert d44ca7 Removal of kernel_thread() API Greg KH
2009-08-13 19:50   ` [patch 60/74] USB: ftdi_sio: add vendor and product id for Bayer glucose meter serial converter cable Greg KH
2009-08-13 19:50   ` [patch 61/74] USB: ftdi_sio: add product_id for Marvell OpenRD Base, Client Greg KH
2009-08-13 19:50   ` [patch 62/74] USB: storage: include Prolific Technology USB drive in unusual_devs list Greg KH
2009-08-13 19:50   ` [patch 63/74] USB: usbfs: fix -ENOENT error code to be -ENODEV Greg KH
2009-08-13 19:50   ` [patch 64/74] USB: devio: Properly do access_ok() checks Greg KH
2009-08-13 19:50   ` [patch 65/74] ring-buffer: Fix memleak in ring_buffer_free() Greg KH
2009-08-13 19:50   ` [patch 66/74] x86: Fix VMI && stack protector Greg KH
2009-08-13 19:50   ` [patch 67/74] mm_for_maps: simplify, use ptrace_may_access() Greg KH
2009-08-13 19:50   ` [patch 68/74] mm_for_maps: shift down_read(mmap_sem) to the caller Greg KH
2009-08-13 19:50   ` [patch 69/74] mm_for_maps: take ->cred_guard_mutex to fix the race with exec Greg KH
2009-08-13 19:50   ` [patch 70/74] Make sock_sendpage() use kernel_sendpage() Greg KH
2009-08-13 19:50   ` [patch 71/74] ring-buffer: Fix advance of reader in rb_buffer_peek() Greg KH
2009-08-13 19:50   ` [patch 72/74] NFS: Fix an O_DIRECT Oops Greg KH
2009-08-13 19:50   ` [patch 73/74] ALSA: hda - Add missing vmaster initialization for ALC269 Greg KH
2009-08-13 19:50   ` [patch 74/74] ide: fix memory leak when flush command is issued Greg KH
2009-08-13 22:32   ` [stable] [patch 00/74] 2.6.30.5-stable review Greg KH
2009-08-14  6:26   ` Ozan Çağlayan
2009-08-14 16:15     ` Greg KH
2009-08-14 17:00       ` Ozan Çağlayan
2009-08-14 17:09         ` Greg KH
2009-08-14 20:36           ` Ozan Çağlayan
2009-09-15 23:01         ` Greg KH
2009-09-16  6:22           ` Ozan Çağlayan
2009-09-16 13:41             ` Greg KH

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=20090813195124.932621003@mini.kroah.org \
    --to=gregkh@suse.de \
    --cc=ajitk@serverengines.com \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.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).