All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jörn Engel" <joern@logfs.org>
To: Alexey Korolev <akorolev@infradead.org>
Cc: nico@cam.org, haokexin@gmail.com, dwmw2@infradead.org,
	akpm@linux-foundation.org, linux-mtd@lists.infradead.org
Subject: Re: [PATCH] Fix of broken state in CFI driver caused by FL_SHUTDOWN
Date: Fri, 4 Apr 2008 11:34:00 +0200	[thread overview]
Message-ID: <20080404093359.GA4338@logfs.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0804040949090.2042@pentafluge.infradead.org>

On Fri, 4 April 2008 10:06:59 +0100, Alexey Korolev wrote:
> 
> CFI driver in 2.6.24 kernel is broken. Not so intensive read/write operations cause incomplete writes which lead to kernel panics in JFFS2. 
> We investigated the issue - it is caused by bug in FL_SHUTDOWN parsing code. Sometimes chip returns -EIO as if it is in FL_SHUTDOWN state when it should wait in FL_PONT (error in order of conditions).
> 
> The following patch fixes the problem. 
> Could you please include it?
> 
> Signed-off-by: Alexey Korolev <akorolev@infradead.org>
> 
> diff -aurpp a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
> --- a/drivers/mtd/chips/cfi_cmdset_0001.c	2008-02-11 08:51:11.000000000 +0300
> +++ b/drivers/mtd/chips/cfi_cmdset_0001.c	2008-04-04 12:46:24.000000000 +0400
> @@ -729,14 +729,14 @@ static int chip_ready (struct map_info *
>  		chip->state = FL_READY;
>  		return 0;
>  
> +	case FL_SHUTDOWN:
> +		/* The machine is rebooting now,so no one can get chip anymore */
> +		return -EIO;
>  	case FL_POINT:
>  		/* Only if there's no operation suspended... */
>  		if (mode == FL_READY && chip->oldstate == FL_READY)
>  			return 0;

Ouch!  I've been bitten by these before.  After I've carefully written
code that takes advantage of missing break; statements, a colleague of
mine reordered the code and missed those subtleties.

Could you add a comment like this where appropriate:
		/* fall through */

It might even have prevented this bug if Kevin had seen such a comment
before writing his patch.

Reviewed-By: Joern Engel <joern@logfs.org>

>  
> -	case FL_SHUTDOWN:
> -		/* The machine is rebooting now,so no one can get chip anymore */
> -		return -EIO;
>  	default:
>  	sleep:
>  		set_current_state(TASK_UNINTERRUPTIBLE);

Jörn

-- 
When in doubt, punt.  When somebody actually complains, go back and fix it...
The 90% solution is a good thing.
-- Rob Landley

  reply	other threads:[~2008-04-04  9:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-04  9:06 [PATCH] Fix of broken state in CFI driver caused by FL_SHUTDOWN Alexey Korolev
2008-04-04  9:34 ` Jörn Engel [this message]
2008-04-04 12:10   ` Alexey Korolev
2008-04-04 12:21   ` Alexey Korolev
2008-04-05  3:46     ` Kevin Hao
2008-04-09 22:57     ` Joakim Tjernlund
2008-04-09 23:01       ` Andrew Morton
     [not found]     ` <009801c89a95$09ae4680$1d0ad380$%Tjernlund@transmode.se>
2008-04-09 23:02       ` Nicolas Pitre
2008-04-09 23:08         ` Joakim Tjernlund
2008-04-10 16:57         ` Alexey Korolev

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=20080404093359.GA4338@logfs.org \
    --to=joern@logfs.org \
    --cc=akorolev@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=dwmw2@infradead.org \
    --cc=haokexin@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=nico@cam.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.