[Yaffs] Optimizing the number of reads and writes to flash
Daniel Gustafsson
daniel.gustafsson@space.se
Mon, 11 Oct 2004 16:14:24 +0200
=20
Thanks.=20
I had already fixed the defines. The problem that confused me was that =
the
CONFIG_YAFFS_DISABLE_WRITE_VERIFY didn't optimize the reads.
With the movement of the #ifndef CONFIG_YAFFS_DISABLE_WRITE_VERIFY like =
in
your code the problem was solved. I believe that this is how the define
CONFIG_YAFFS_DISABLE_WRITE_VERIFY is meant to work.
//Daniel
>-----Original Message-----
>From: Reggiani, Adamo [mailto:areggiani@ferrari.it]=20
>Sent: Monday, October 11, 2004 3:25 PM
>To: Daniel Gustafsson; yaffs@stoneboat.aleph1.co.uk
>Subject: RE: [Yaffs] Optimizing the number of reads and writes to flash
>
>Hi Daniel,
>uncomment the define of this two labels in the makefile:
>CONFIG_YAFFS_DISABLE_CHUNK_ERASED_CHECK
>CONFIG_YAFFS_DISABLE_WRITE_VERIFY
>
>In this way you avoid to re-read every chunk before write (to=20
>control if it's blank) and to re-read after a succesfull write.
>I've also made a little modification of the=20
>yaffs_WriteNewChunkToNAND, to completely avoid chunks read=20
>after write (the original code avoids yaffs_VerifyCompare only).
>Check the following code against cvs one.
>
>
>static int yaffs_WriteNewChunkToNAND(struct yaffs_DeviceStruct=20
>*dev, const __u8 *data, yaffs_Spare *spare,int useReserve)
>{
> int chunk;
>
> int writeOk =3D 1;
> int attempts =3D 0;
>
> do{
> chunk =3D yaffs_AllocateChunk(dev,useReserve);
>
> if(chunk >=3D 0)
> {
>
> // First check this chunk is erased...
>#ifndef CONFIG_YAFFS_DISABLE_CHUNK_ERASED_CHECK
> writeOk =3D yaffs_CheckChunkErased(dev,chunk);
>#endif
> if(!writeOk)
> {
> T(YAFFS_TRACE_ERROR,(TSTR("**>>=20
>yaffs chunk %d was not erased" TENDSTR),chunk));
> }
> else
> {
> writeOk =3D =20
>yaffs_WriteChunkToNAND(dev,chunk,data,spare);
> }
> attempts++;
>#ifndef CONFIG_YAFFS_DISABLE_WRITE_VERIFY
> if(writeOk)
> {
> unsigned char=20
>rbData[YAFFS_BYTES_PER_CHUNK];
> yaffs_Spare rbSpare;
>
> // Readback & verify
> // If verify fails, then delete=20
>this chunk and try again
> // To verify we compare=20
>everything except the block and
> // page status bytes.
> // NB We check a raw read=20
>without ECC correction applied
>
> =09
>yaffs_ReadChunkFromNAND(dev,chunk,rbData,&rbSpare,0);
>
> =09
>if(!yaffs_VerifyCompare(data,rbData,spare,&rbSpare))
> {
> // Didn't verify
> =09
>T(YAFFS_TRACE_ERROR,(TSTR("**>> yaffs write verify failed on=20
>chunk %d" TENDSTR), chunk));
>
> writeOk =3D 0;
> }
>
> }
>#endif
> if(writeOk)
> {
> // Copy the data into the write buffer.
> // NB We do this at the end to=20
>prevent duplicates in the case of a write error.
> //Todo
> =09
>yaffs_HandleWriteChunkOk(dev,chunk,data,spare);
> }
> else
> {
> yaffs_HandleWriteChunkError(dev,chunk);
> }
> }
>
> } while(chunk >=3D 0 && ! writeOk);
>
> if(attempts > 1)
> {
> T(YAFFS_TRACE_ERROR,(TSTR("**>> yaffs write=20
>required %d attempts" TENDSTR),attempts));
> dev->nRetriedWrites+=3D (attempts - 1);
> }
>
> return chunk;
>}
>
>
>To reduce writes I think you must wait (or aid ;) for Yaffs2,=20
>which will use a zero page rewrites to spare area and will=20
>have generally better performance over Yaffs.
>Look at www.aleph1.co.uk/yaffs/yaffs2.html
>
>
>Regards
>Adamo
>
>
>
>> -----Original Message-----
>> From: yaffs-admin@stoneboat.aleph1.co.uk
>> [mailto:yaffs-admin@stoneboat.aleph1.co.uk]On Behalf Of Daniel
>> Gustafsson
>> Sent: luned=EC 11 ottobre 2004 14.47
>> To: yaffs@stoneboat.aleph1.co.uk
>> Subject: [Yaffs] Optimizing the number of reads and writes to flash
>>=20
>>=20
>>=20
>>=20
>> I am using yaffs/direct and I want to reduce the reads and=20
>> writes towards
>> the flash to an absolute minimum. I do not want any=20
>> verifications of flash
>> etc. I don not want to use ECC.
>>=20
>> I would greatly appreatiate any tips regarding the above=20
>> issue but also how
>> to reduce the footprint in RAM and size.=20
>>=20
>> Further more I am interested in some documetation what=20
>> happens (reads/writes
>> to flash) when performing some simple fs operations like=20
>> read/write/open
>> etc.
>>=20
>>=20
>> I hope someone have the answers I am looking for,
>>=20
>> Best Regards
>> Daniel Gustavsson
>>=20
>>=20
>> _______________________________________________
>> yaffs mailing list
>> yaffs@stoneboat.aleph1.co.uk
>> http://stoneboat.aleph1.co.uk/cgi-bin/mailman/listinfo/yaffs
>>=20
>
>