public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] Fix of broken state in CFI driver caused by FL_SHUTDOWN
@ 2008-04-04  9:06 Alexey Korolev
  2008-04-04  9:34 ` Jörn Engel
  0 siblings, 1 reply; 10+ messages in thread
From: Alexey Korolev @ 2008-04-04  9:06 UTC (permalink / raw)
  To: dwmw2, nico, joern, linux-mtd; +Cc: akpm, haokexin

Hi all,

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

Thanks,
Alexey

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix of broken state in CFI driver caused by FL_SHUTDOWN
  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
  2008-04-04 12:10   ` Alexey Korolev
  2008-04-04 12:21   ` Alexey Korolev
  0 siblings, 2 replies; 10+ messages in thread
From: Jörn Engel @ 2008-04-04  9:34 UTC (permalink / raw)
  To: Alexey Korolev; +Cc: nico, haokexin, dwmw2, akpm, linux-mtd

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix of broken state in CFI driver caused by FL_SHUTDOWN
  2008-04-04  9:34 ` Jörn Engel
@ 2008-04-04 12:10   ` Alexey Korolev
  2008-04-04 12:21   ` Alexey Korolev
  1 sibling, 0 replies; 10+ messages in thread
From: Alexey Korolev @ 2008-04-04 12:10 UTC (permalink / raw)
  To: Jörn Engel; +Cc: nico, haokexin, dwmw2, akpm, linux-mtd

[-- Attachment #1: Type: TEXT/PLAIN, Size: 700 bytes --]

Hi Jörn

> 
> 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 */
No problem. See patch update in next message. 
> 
> 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);
> 
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix of broken state in CFI driver caused by FL_SHUTDOWN
  2008-04-04  9:34 ` Jörn Engel
  2008-04-04 12:10   ` Alexey Korolev
@ 2008-04-04 12:21   ` Alexey Korolev
  2008-04-05  3:46     ` Kevin Hao
                       ` (2 more replies)
  1 sibling, 3 replies; 10+ messages in thread
From: Alexey Korolev @ 2008-04-04 12:21 UTC (permalink / raw)
  To: Jörn Engel; +Cc: nico, haokexin, dwmw2, akpm, linux-mtd

Hi 


 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 bug in state parsing code of CFI. 
Also I've added comments to notify developers if they want to add new case in future.
Please include it.
 
Signed-off-by: Alexey Korolev <akorolev@infradead.org>
Reviewed-By: Joern Engel <joern@logfs.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 15:50:47.000000000 +0400
@@ -669,7 +669,7 @@ static int chip_ready (struct map_info *
 			/* Someone else might have been playing with it. */
 			return -EAGAIN;
 		}
-
+		/* Fall through */
 	case FL_READY:
 	case FL_CFI_QUERY:
 	case FL_JEDEC_QUERY:
@@ -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;
-
-	case FL_SHUTDOWN:
-		/* The machine is rebooting now,so no one can get chip anymore */
-		return -EIO;
+		/* Fall through */
 	default:
 	sleep:
 		set_current_state(TASK_UNINTERRUPTIBLE);
-------------
Thanks,
Alexey

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix of broken state in CFI driver caused by FL_SHUTDOWN
  2008-04-04 12:21   ` Alexey Korolev
@ 2008-04-05  3:46     ` Kevin Hao
  2008-04-09 22:57     ` Joakim Tjernlund
       [not found]     ` <009801c89a95$09ae4680$1d0ad380$%Tjernlund@transmode.se>
  2 siblings, 0 replies; 10+ messages in thread
From: Kevin Hao @ 2008-04-05  3:46 UTC (permalink / raw)
  To: Alexey Korolev; +Cc: nico, Jörn Engel, dwmw2, akpm, linux-mtd

Oh, my fault. Thanks for correction.

Thanks,
Kevin

On 4/4/08, Alexey Korolev <akorolev@infradead.org> wrote:
> Hi
>
>
>  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 bug in state parsing code of CFI.
> Also I've added comments to notify developers if they want to add new case in future.
> Please include it.
>
> Signed-off-by: Alexey Korolev <akorolev@infradead.org>
> Reviewed-By: Joern Engel <joern@logfs.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 15:50:47.000000000 +0400
> @@ -669,7 +669,7 @@ static int chip_ready (struct map_info *
>                        /* Someone else might have been playing with it. */
>                        return -EAGAIN;
>                }
> -
> +               /* Fall through */
>        case FL_READY:
>        case FL_CFI_QUERY:
>        case FL_JEDEC_QUERY:
> @@ -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;
> -
> -       case FL_SHUTDOWN:
> -               /* The machine is rebooting now,so no one can get chip anymore */
> -               return -EIO;
> +               /* Fall through */
>        default:
>        sleep:
>                set_current_state(TASK_UNINTERRUPTIBLE);
> -------------
> Thanks,
> Alexey
>
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [PATCH] Fix of broken state in CFI driver caused by FL_SHUTDOWN
  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>
  2 siblings, 1 reply; 10+ messages in thread
From: Joakim Tjernlund @ 2008-04-09 22:57 UTC (permalink / raw)
  To: 'Alexey Korolev', 'Jörn Engel'
  Cc: haokexin, akpm, nico, dwmw2, linux-mtd

> -----Original Message-----
> From: linux-mtd-bounces@lists.infradead.org [mailto:linux-mtd-bounces@lists.infradead.org] On Behalf
> Of Alexey Korolev
> Sent: den 4 april 2008 14:22
> To: Jörn Engel
> 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
> 
> Hi
> 
> 
>  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 bug in state parsing code of CFI.
> Also I've added comments to notify developers if they want to add new case in future.
> Please include it.
> 
> Signed-off-by: Alexey Korolev <akorolev@infradead.org>
> Reviewed-By: Joern Engel <joern@logfs.org>

Acked-By: Joakim Tjernlund <Joakim.Tjenrlund@transmode.se>

Guys, I think you should sent this directly to Linus as David seems
unavailable ATM. It should really go into 2.6.25

 Jocke

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Fix of broken state in CFI driver caused by FL_SHUTDOWN
  2008-04-09 22:57     ` Joakim Tjernlund
@ 2008-04-09 23:01       ` Andrew Morton
  0 siblings, 0 replies; 10+ messages in thread
From: Andrew Morton @ 2008-04-09 23:01 UTC (permalink / raw)
  To: Joakim Tjernlund; +Cc: haokexin, akorolev, nico, joern, linux-mtd, dwmw2

On Thu, 10 Apr 2008 00:57:07 +0200
"Joakim Tjernlund" <Joakim.Tjernlund@transmode.se> wrote:

> > -----Original Message-----
> > From: linux-mtd-bounces@lists.infradead.org [mailto:linux-mtd-bounces@lists.infradead.org] On Behalf
> > Of Alexey Korolev
> > Sent: den 4 april 2008 14:22
> > To: J__rn Engel
> > 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
> > 
> > Hi
> > 
> > 
> >  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 bug in state parsing code of CFI.
> > Also I've added comments to notify developers if they want to add new case in future.
> > Please include it.
> > 
> > Signed-off-by: Alexey Korolev <akorolev@infradead.org>
> > Reviewed-By: Joern Engel <joern@logfs.org>
> 
> Acked-By: Joakim Tjernlund <Joakim.Tjenrlund@transmode.se>
> 
> Guys, I think you should sent this directly to Linus as David seems
> unavailable ATM. It should really go into 2.6.25
> 

I don't have a copy of the patch.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [PATCH] Fix of broken state in CFI driver caused by FL_SHUTDOWN
       [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
  0 siblings, 2 replies; 10+ messages in thread
From: Nicolas Pitre @ 2008-04-09 23:02 UTC (permalink / raw)
  To: Joakim Tjernlund
  Cc: haokexin, 'Alexey Korolev', 'Jörn Engel',
	linux-mtd, akpm, dwmw2

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1389 bytes --]

On Thu, 10 Apr 2008, Joakim Tjernlund wrote:

> > -----Original Message-----
> > From: linux-mtd-bounces@lists.infradead.org [mailto:linux-mtd-bounces@lists.infradead.org] On Behalf
> > Of Alexey Korolev
> > Sent: den 4 april 2008 14:22
> > To: Jörn Engel
> > 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
> > 
> > Hi
> > 
> > 
> >  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 bug in state parsing code of CFI.
> > Also I've added comments to notify developers if they want to add new case in future.
> > Please include it.
> > 
> > Signed-off-by: Alexey Korolev <akorolev@infradead.org>
> > Reviewed-By: Joern Engel <joern@logfs.org>
> 
> Acked-By: Joakim Tjernlund <Joakim.Tjenrlund@transmode.se>
> 
> Guys, I think you should sent this directly to Linus as David seems
> unavailable ATM. It should really go into 2.6.25

It is already in mainline.  See commit fb6d080c.


Nicolas

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [PATCH] Fix of broken state in CFI driver caused by FL_SHUTDOWN
  2008-04-09 23:02       ` Nicolas Pitre
@ 2008-04-09 23:08         ` Joakim Tjernlund
  2008-04-10 16:57         ` Alexey Korolev
  1 sibling, 0 replies; 10+ messages in thread
From: Joakim Tjernlund @ 2008-04-09 23:08 UTC (permalink / raw)
  To: 'Nicolas Pitre'
  Cc: haokexin, 'Alexey Korolev', 'Jörn Engel',
	linux-mtd, akpm, dwmw2

> -----Original Message-----
> From: Nicolas Pitre [mailto:nico@cam.org]
> Sent: den 10 april 2008 01:02
> To: Joakim Tjernlund
> Cc: 'Alexey Korolev'; 'Jörn Engel'; 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
> 
> On Thu, 10 Apr 2008, Joakim Tjernlund wrote:
> 
> > > -----Original Message-----
> > > From: linux-mtd-bounces@lists.infradead.org [mailto:linux-mtd-bounces@lists.infradead.org] On
> Behalf
> > > Of Alexey Korolev
> > > Sent: den 4 april 2008 14:22
> > > To: Jörn Engel
> > > 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
> > >
> > > Hi
> > >
> > >
> > >  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 bug in state parsing code of CFI.
> > > Also I've added comments to notify developers if they want to add new case in future.
> > > Please include it.
> > >
> > > Signed-off-by: Alexey Korolev <akorolev@infradead.org>
> > > Reviewed-By: Joern Engel <joern@logfs.org>
> >
> > Acked-By: Joakim Tjernlund <Joakim.Tjenrlund@transmode.se>
> >
> > Guys, I think you should sent this directly to Linus as David seems
> > unavailable ATM. It should really go into 2.6.25
> 
> It is already in mainline.  See commit fb6d080c.

Oh, good. Never saw any mail about it on the list, sorry for the noise.

     Jocke

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [PATCH] Fix of broken state in CFI driver caused by FL_SHUTDOWN
  2008-04-09 23:02       ` Nicolas Pitre
  2008-04-09 23:08         ` Joakim Tjernlund
@ 2008-04-10 16:57         ` Alexey Korolev
  1 sibling, 0 replies; 10+ messages in thread
From: Alexey Korolev @ 2008-04-10 16:57 UTC (permalink / raw)
  To: Nicolas Pitre
  Cc: haokexin, Joakim Tjernlund, 'Jörn Engel', linux-mtd,
	akpm, dwmw2

Hi, 

> > >  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 bug in state parsing code of CFI.
> > > Also I've added comments to notify developers if they want to add new case in future.
> > > Please include it.
> > > 
> > > Signed-off-by: Alexey Korolev <akorolev@infradead.org>
> > > Reviewed-By: Joern Engel <joern@logfs.org>
> > 
> > Acked-By: Joakim Tjernlund <Joakim.Tjenrlund@transmode.se>
> > 
> > Guys, I think you should sent this directly to Linus as David seems
> > unavailable ATM. It should really go into 2.6.25
> 
> It is already in mainline.  See commit fb6d080c.
> 
Excelent, thank you very much!

> Nicolas
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-04-10 16:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox