dlbeer / dhara

NAND flash translation layer for low-memory systems

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

journal.c: cp_free does an illegal dhara_nand_is_free if on last group and none of the pages are free

bjornwedell opened this issue · comments

} while (!cp_free(j, j->head));

We have seen a situation where we get failed READPAGE command with IpCommandSequenceErrorFlagSet. This is the log:

[ 3.350000] w25n_transfer: Spi command failed with error: 7002
[ 3.350000] w25n_load_nand_buffer: Failed to load page at 0x10000804: 3
[ 3.360000] w25n_nand_read: Failed to load nand buffer with data from 0x10000804.
[ 3.360000] dhara_nand_is_free: Failed to check if page 65536 is free: 3

This basically means that we get an SPI error caused by a read outside the configured memory area. This is our dhara config:
`
/* W25N01GW (1Gb / 128 MB) memory capacity */

/* Log2 sizes defined for Dhara */

#define W25N01GW_PAGE_SIZE_LOG2 (11)

#define W25N01GW_PAGE_SIZE (1 << W25N01GW_PAGE_SIZE_LOG2)

#define W25N01GW_BLOCK_COUNT (1024)

#define W25N01GW_PAGES_PER_BLOCK_LOG2 (6)

#define W25N01GW_PAGES_PER_BLOCK (1 << W25N01GW_PAGES_PER_BLOCK_LOG2)

#define W25N01GW_BLOCK_SIZE (W25N01GW_PAGES_PER_BLOCK * W25N01GW_PAGE_SIZE)
`

To me it seems that if we for some reason end up in the last checkpoint group and that group have no free pages we will keep looking "over the edge", since we start by skipping one page to next user page before the call to cp_free.

Can you help me?

Thank you for your quick response,

I agree with you that next_upage() will wrap, but in this particular situation the next user page will be one page after last checkpoint and from what I understand cp_free will check a full 1 << ppc without wrapping, i.e run outside the memory.

However, in my situation this should actually not be a problem since dhara_nand_is_free will, part from the error log, just act as if the memory is not free. It rather seems I had some actual problem with the memory and I will investigate it further in other directions.

Thank you Daniel and sorry for the slow reply. I am afraid I am not able to reproduce the situation we encountered earlier. It has only occurred once and I am not completely sure in what state the chip was in.

However, when running with your patch in my own tests forcing the head to the end of the memory I now see that the last checkpoint group is handled without attempts to read outside the memory, which is an improvement.