From patchwork Fri Feb 27 16:43:06 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: roel kluin X-Patchwork-Id: 23819 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 3C6DDDDDB6 for ; Sat, 28 Feb 2009 03:43:15 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755360AbZB0QnM (ORCPT ); Fri, 27 Feb 2009 11:43:12 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755236AbZB0QnK (ORCPT ); Fri, 27 Feb 2009 11:43:10 -0500 Received: from an-out-0708.google.com ([209.85.132.243]:55365 "EHLO an-out-0708.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755126AbZB0QnJ (ORCPT ); Fri, 27 Feb 2009 11:43:09 -0500 Received: by an-out-0708.google.com with SMTP id c2so925145anc.1 for ; Fri, 27 Feb 2009 08:43:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=ScLJ5bZYmcya6qsUff4adY4Z+JfxhvRHuRYS/ovfmJo=; b=NQJvGkRmmlgUpPnb/kbZTSxmi40dFoD/goeoY6pVB/9aZmsFgb2o2Zdv6eQ56p8Ni7 y/2UGe3pfJmW7urv5uNd1D+3KKOZZJnB04qrG16/pbhoaD7J9C+PhSNbpXapSvqqYdIW Vc8YM1d+QlgF600DZoIBbshcSLKu96QqcfNIY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=aYDt/+3j0AD3XhE1/A/lmukTuWGyB+86O2yOygq5UrsO2iC+ZvVvsbgKjls3RaTyhX CBr8PMg15Qvon5gPUafpvFMVrTCxieBFVGVPS5C36XLKFxIeoI1dmJ7oEZm5CAeD4mTi hWNQESWbeRbYMRLeWOhUNXorlRXIscI6yzK40= Received: by 10.100.142.19 with SMTP id p19mr432287and.31.1235752986673; Fri, 27 Feb 2009 08:43:06 -0800 (PST) Received: from ?192.168.1.115? (d133062.upc-d.chello.nl [213.46.133.62]) by mx.google.com with ESMTPS id d24sm83556nfh.3.2009.02.27.08.43.05 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 27 Feb 2009 08:43:06 -0800 (PST) Message-ID: <49A8181A.5030106@gmail.com> Date: Fri, 27 Feb 2009 17:43:06 +0100 From: Roel Kluin User-Agent: Thunderbird 2.0.0.18 (X11/20081105) MIME-Version: 1.0 To: cooldavid@cooldavid.org CC: "David S. Miller" , netdev@vger.kernel.org, Andrew Morton Subject: [PATCH v3] net: more timeouts that reach -1 References: <49A5286D.80304@gmail.com> <20090227114015.M80857@cooldavid.org> <25e057c00902270737x529fb5b8m2fdbb044fa75ab0d@mail.gmail.com> <20090227154440.M53654@cooldavid.org> In-Reply-To: <20090227154440.M53654@cooldavid.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Guo-Fu Tseng wrote: > On Fri, 27 Feb 2009 16:37:30 +0100, roel kluin wrote >> On Fri, Feb 27, 2009 at 12:43 PM, Guo-Fu Tseng wrote: >>> There should be no difference after this modification. >>> The return value of this function is: "limit > 0 ? limit : 0;" >> There is: >> In the last iteration limit is 1 during the test before it is decremented to 0. >> >> rxdesc = rxring->desc; >> rxdesc += i; >> >> If then we break out of the loop by the 'goto out;', we continue with: >> >> out: >> atomic_set(&rxring->next_to_clean, i); >> >> out_inc: >> atomic_inc(&jme->rx_cleaning); >> >> but since limit is already decremented, 0 is returned. >> >>> Guo-Fu Tseng >>> >> Roel > I see. > But the correct patch should be following one, right? > > =================================================================== > --- jme.c (revision 580) > +++ jme.c (working copy) > @@ -958,13 +958,14 @@ > goto out_inc; > > i = atomic_read(&rxring->next_to_clean); > - while (limit-- > 0) { > + while (limit > 0) { > rxdesc = rxring->desc; > rxdesc += i; > > if ((rxdesc->descwb.flags & RXWBFLAG_OWN) || > !(rxdesc->descwb.desccnt & RXWBDCNT_WBCPL)) > goto out; > + --limit; > > desccnt = rxdesc->descwb.desccnt & RXWBDCNT_DCNT; > > > > > Guo-Fu Tseng Correct, thanks. Here are all three patches again with another issue I spotted in drivers/net/ucc_geth_mii.c: After my patch it still wouldn't err, because timeout was unsigned. ------------------------------>8-------------8<--------------------------------- with while (timeout-- > 0); timeout reaches -1 after the loop, so the tests below are off by one. also don't do an '< 0' test on an unsigned. Signed-off-by: Roel Kluin --- -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/arm/ks8695net.c b/drivers/net/arm/ks8695net.c index 1cf2f94..f3a1274 100644 --- a/drivers/net/arm/ks8695net.c +++ b/drivers/net/arm/ks8695net.c @@ -560,7 +560,7 @@ ks8695_reset(struct ks8695_priv *ksp) msleep(1); } - if (reset_timeout == 0) { + if (reset_timeout < 0) { dev_crit(ksp->dev, "Timeout waiting for DMA engines to reset\n"); /* And blithely carry on */ diff --git a/drivers/net/jme.c b/drivers/net/jme.c index 08b3405..a6e1a35 100644 --- a/drivers/net/jme.c +++ b/drivers/net/jme.c @@ -957,13 +957,14 @@ jme_process_receive(struct jme_adapter *jme, int limit) goto out_inc; i = atomic_read(&rxring->next_to_clean); - while (limit-- > 0) { + while (limit > 0) { rxdesc = rxring->desc; rxdesc += i; if ((rxdesc->descwb.flags & cpu_to_le16(RXWBFLAG_OWN)) || !(rxdesc->descwb.desccnt & RXWBDCNT_WBCPL)) goto out; + --limit; desccnt = rxdesc->descwb.desccnt & RXWBDCNT_DCNT; diff --git a/drivers/net/ucc_geth_mii.c b/drivers/net/ucc_geth_mii.c index 5463591..0ada4ed 100644 --- a/drivers/net/ucc_geth_mii.c +++ b/drivers/net/ucc_geth_mii.c @@ -107,7 +107,7 @@ int uec_mdio_read(struct mii_bus *bus, int mii_id, int regnum) static int uec_mdio_reset(struct mii_bus *bus) { struct ucc_mii_mng __iomem *regs = (void __iomem *)bus->priv; - unsigned int timeout = PHY_INIT_TIMEOUT; + int timeout = PHY_INIT_TIMEOUT; mutex_lock(&bus->mdio_lock); @@ -123,7 +123,7 @@ static int uec_mdio_reset(struct mii_bus *bus) mutex_unlock(&bus->mdio_lock); - if (timeout <= 0) { + if (timeout < 0) { printk(KERN_ERR "%s: The MII Bus is stuck!\n", bus->name); return -EBUSY; }