[Yaffs] bugs report about nandemul2k

Top Page
Attachments:
Message as email
+ (text/plain)
+ (text/html)
+ (message/rfc822)
+ (text/plain)
+ (text/html)
+ (message/rfc822)
+ (text/plain)
+ (text/html)
Delete this message
Reply to this message
Author: bhsong
Date:  
To: yaffs
Subject: [Yaffs] bugs report about nandemul2k
Let me FW the mail to Charles Manning () to you too.
It reports two great bugs in nandemul2k.



Hi Charles,

Sorry to mail you about bugs in nandemul2k again. As to the email yesterday,
erase will crash your nandemul2k. I found the reasons:

In your nand_erase() functions, you should add:

instr->state = MTD_ERASE_DONE; //change state to ERASE_DONE

instr->callback(instr); // this callback will wake up process waiting
erased!

before "return 0".

Without calling the callback, process will die after added to wait_queue in
mtdchar.c here:

case MEMERASE:

{

    ...


    ret = mtd->erase(mtd, erase);


    if (!ret)


    {


      set_current_state(TASK_UNINTERRUPTIBLE);


      add_wait_queue(&waitq, &wait);


      if (erase->state != MTD_ERASE_DONE && erase->state !=
MTD_ERASE_FAILED)


        schedule();


      remove_wait_queue(&waitq, &wait);


      set_current_state(TASK_RUNNING);




      ret = (erase->state == MTD_ERASE_FAILED) ?  - EIO: 0;


}

kfree(erase);

}

break;

}

Callback in mtdchar.c will wake up it:

static void mtdchar_erase_callback (struct erase_info *instr)

{

         wake_up((wait_queue_head_t *)instr->priv);


}



Per my test, the bug was fixed by changing like that.



Thanks and best regards

Baohua Song

Hi Charles,

I am a Chinese engineer in Linux drivers. I am using your nandemul2k in
YAFFS2 to simulate NAND FLASH with 2k page size recently. I find I always
can't write and read OOBs right. So I had to trace your codes to find the
reason.

At last, I found you made a great mistake in nand_write_oob() function. You
call nandemul2k_Program (buf, page, 512 + col,len) in the function. That
will write OOB to wrong places. You should verify it to

nandemul2k_Program(buf,page,PAGE_DATA_SIZE + col,len);

When I changed like that, I read and wrote the pages and oobs of NAND in RAW
and YAFFS2 mode successfully.

Since your codes are used so far and wide in the world, I'd like you can
change it ASAP before puzzling more engineers.

Another bug:

Your nandemul2k will crash when erased by flash_eraseall tool. Then I tested
it by MEMERASE ioctl, it was proved your emulation would crash indeed when
erasing. Since that doesn't affect my using, I will not trace the bug. Would
you?

Test codes I used:

/* read oob*/

if (ioctl(fd_mtd, MEMREADOOB, &oob) != 0)

{

perror("ioctl(MEMREADOOB) fail");

}

/* write oob*/

if (ioctl(fd_mtd, MEMWRITEOOB, &oob) != 0)

{

perror("ioctl(MEMWRITEOOB) fail");

}

/* erase blocks */

if (ioctl(fd_mtd, MEMERASE, &erase) != 0)    //crash here!!!!!


{

perror("MTD Erase failure");

}



Thanks and best regards

Baohua Song