From: David Brownell Subject: Re: [patch 2.6.31-rc1] eeprom/at25: bugfix "not ready" timeout after write Date: Fri, 17 Jul 2009 19:23:14 -0700 Message-ID: <200907171923.14794.david-b@pacbell.net> References: <200907031836.28475.david-b@pacbell.net> <20090717173546.11f55599.akpm@linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, heutling-U9zb0o/1OQCELgA04lAiVw@public.gmane.org To: Andrew Morton Return-path: In-Reply-To: <20090717173546.11f55599.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org> Content-Disposition: inline List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: linux-spi.vger.kernel.org On Friday 17 July 2009, Andrew Morton wrote: > Seems OK. > = > The code's a bit nonsensical though: > = > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Wait for non-busy stat= us */ > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0timeout =3D jiffies + mse= cs_to_jiffies(EE_TIMEOUT); > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0retries =3D 0; > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0do { > = > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0s= r =3D spi_w8r8(at25->spi, AT25_RDSR); > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0i= f (sr < 0 || (sr & AT25_SR_nRDY)) { > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0dev_dbg(&at25->spi->dev, > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0"rdsr --> %d (%02x)\n", sr,= sr); > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0/* at HZ=3D100, this is sloooow */ > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0msleep(1); > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0continue; > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0} > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0i= f (!(sr & AT25_SR_nRDY)) > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0break; > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0} while (retries++ < 3 ||= time_before_eq(jiffies, timeout)); > = > EE_TIMEOUT is 25 msecs and `retries' is 3 msecs. =A0So the > time_before_eq() will never trigger unless there's a tremendous amount > of CPU load or something. =A0It seems a bit ripe for some rationalisation. The retries check is to make sure it *does* retry a few times even in the face of load. Once that limit is met, *then* the EE_TIMOUT limit will apply. Keep in mind also that wih HZ=3D100 (a common setting) the loops are "sloooow" -- 10+ msec each. The goal is to cope with a bunch of odd behaviors and still come out sane. ---------------------------------------------------------------------------= --- Enter the BlackBerry Developer Challenge = This is your chance to win up to $100,000 in prizes! For a limited time, = vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize= = details at: http://p.sf.net/sfu/Challenge