-- backported to 2.6.8 by dev@ Received: from swgw.sw.ru (swgw-dmz-if.sw.ru [195.214.233.2]) by relay.sw.ru (8.13.0/8.13.0) with ESMTP id j9C4NhKb026390; Wed, 12 Oct 2005 08:23:44 +0400 (MSD) Received: from smtp.osdl.org (smtp.osdl.org [65.172.181.4]) by swgw.sw.ru (8.13.0/8.13.0) with ESMTP id j9C4N2Eh027086; Wed, 12 Oct 2005 08:23:37 +0400 (MSD) Received: from shell0.pdx.osdl.net (fw.osdl.org [65.172.181.6]) by smtp.osdl.org (8.12.8/8.12.8) with ESMTP id j9C4Mt4s020768 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Tue, 11 Oct 2005 21:22:56 -0700 Received: from localhost.localdomain (shell0.pdx.osdl.net [10.9.0.31]) by shell0.pdx.osdl.net (8.13.1/8.11.6) with ESMTP id j9C4MtbV013434; Tue, 11 Oct 2005 21:22:55 -0700 Message-Id: <200510120422.j9C4MtbV013434@shell0.pdx.osdl.net> Subject: + sis900-come-alive-after-temporary-memory-shortage.patch added to -mm tree To: khorenko@sw.ru, jgarzik@pobox.com, venza@brownhat.org, vvs@sw.ru, mm-commits@vger.kernel.org From: akpm@osdl.org Date: Tue, 11 Oct 2005 21:22:28 -0700 X-Spam-Status: No, hits=1.088 required=5 tests=NO_REAL_NAME X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 2.63-osdl_revision__1.52__ X-MIMEDefang-Filter: osdl$Revision: 1.124 $ X-Scanned-By: MIMEDefang 2.36 The patch titled sis900: come alive after temporary memory shortage has been added to the -mm tree. Its filename is sis900-come-alive-after-temporary-memory-shortage.patch From: Konstantin Khorenko Patch solves following problems: 1) Forgotten counter incrementation in sis900_rx() in case it doesn't get memory for skb, that leads to whole interface failure. Problem is accompanied with messages: eth0: Memory squeeze,deferring packet. eth0: NULL pointer encountered in Rx ring, skipping 2) If counter cur_rx overflows and there'll be temporary memory problems buffer can't be recreated later, when memory IS avaliable. 3) Limit the work in handler to prevent the endless packets processing if new packets are generated faster then handled. Signed-off-by: Konstantin Khorenko Signed-off-by: Vasily Averin Signed-off-by: Daniele Venzano Cc: Jeff Garzik Signed-off-by: Andrew Morton --- drivers/net/sis900.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) --- ./drivers/net/sis900.c.sisx 2004-08-14 14:55:20.000000000 +0400 +++ ./drivers/net/sis900.c 2005-10-14 15:58:26.000000000 +0400 @@ -1620,15 +1620,20 @@ static int sis900_rx(struct net_device * long ioaddr = net_dev->base_addr; unsigned int entry = sis_priv->cur_rx % NUM_RX_DESC; u32 rx_status = sis_priv->rx_ring[entry].cmdsts; + int rx_work_limit; if (sis900_debug > 3) printk(KERN_INFO "sis900_rx, cur_rx:%4.4d, dirty_rx:%4.4d " "status:0x%8.8x\n", sis_priv->cur_rx, sis_priv->dirty_rx, rx_status); + rx_work_limit = sis_priv->dirty_rx + NUM_RX_DESC - sis_priv->cur_rx; while (rx_status & OWN) { unsigned int rx_size; + if (--rx_work_limit < 0) + break; + rx_size = (rx_status & DSIZE) - CRC_SIZE; if (rx_status & (ABORT|OVERRUN|TOOLONG|RUNT|RXISERR|CRCERR|FAERR)) { @@ -1655,9 +1660,11 @@ static int sis900_rx(struct net_device * some unknow bugs, it is possible that we are working on NULL sk_buff :-( */ if (sis_priv->rx_skbuff[entry] == NULL) { - printk(KERN_INFO "%s: NULL pointer " - "encountered in Rx ring, skipping\n", - net_dev->name); + printk(KERN_WARNING "%s: NULL pointer " + "encountered in Rx ring\n" + "cur_rx:%4.4d, dirty_rx:%4.4d\n", + net_dev->name, sis_priv->cur_rx, + sis_priv->dirty_rx); break; } @@ -1692,6 +1699,7 @@ static int sis900_rx(struct net_device * sis_priv->rx_ring[entry].cmdsts = 0; sis_priv->rx_ring[entry].bufptr = 0; sis_priv->stats.rx_dropped++; + sis_priv->cur_rx++; break; } skb->dev = net_dev; @@ -1709,7 +1717,7 @@ static int sis900_rx(struct net_device * /* refill the Rx buffer, what if the rate of refilling is slower than consuming ?? */ - for (;sis_priv->cur_rx - sis_priv->dirty_rx > 0; sis_priv->dirty_rx++) { + for (; sis_priv->cur_rx != sis_priv->dirty_rx; sis_priv->dirty_rx++) { struct sk_buff *skb; entry = sis_priv->dirty_rx % NUM_RX_DESC;