Fw: corrupt my NAND flash device

Alex Samoutin samoutin at hotbox.ru
Fri Apr 25 18:23:36 EDT 2003



> > cause. As I mentioned NAND driver (nand.c) has lock mechanism to prevent
> > this situation. But it doesn't work in my case. I don't know why - the
code
> > look Ok. A added some additional locks and it solved this problem.
>
> Ah, sorry for me misinterpreting you original post. I thought, you had
> found a problem in yaffs.
>
> Do you have a patch for this? Even if it is ugly and slow, correct
> code is better than broken one.
>
This is diff file for drivers/mtd/nand.c  (I made to many changes to create
a patch)

151a152,154
> static struct semaphore sam;
> #define NAND_WRITE_RETRY 1
>
362c365
<
---
> 	int ret = 0;
370c373,381
<
---
> #ifdef NAND_WRITE_RETRY
> repeat:
> 	if (ret>3){
> 		printk ("%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page);
> 		return -EIO;
>
> 	}
> #endif
>
476a488,491
> #ifdef NAND_WRITE_RETRY
> 			++ret;
> 			goto repeat;
> #endif
485c500,504
< 				DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ",
__FUNCTION__, page);
---
> 				DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write verify OOB, page 0x%08x
", __FUNCTION__, page);
> #ifdef NAND_WRITE_RETRY
> 				++ret;
> 				goto repeat;
> #endif
507a527,530
> #ifdef NAND_WRITE_RETRY
> 				++ret;
> 				goto repeat;
> #endif
557c580
<
---
> 	down(&sam);
701a725
> 	up(&sam);
737c761
<
---
> 	down(&sam);
763c787
<
---
>         up(&sam);
807c831
<
---
> 	down(&sam);
851c875,876
<
---
> 	up(&sam);
>
880a906
> 	down(&sam);
944c970,971
<
---
>         up(&sam);
>
990a1018
> 	down(&sam);
1063a1092
> 	up(&sam);
1098c1127,1128
<
---
>
> 	down(&sam);
1189a1220
> 	up(&sam);
1373a1405
> 	init_MUTEX(&sam);






More information about the linux-mtd mailing list