Commit abf3c0f2 authored by Kyungmin Park's avatar Kyungmin Park

[MTD] OneNAND: Reduce internal BufferRAM operations

It use blockpage instead of a pair (block, page). It can also cover a small chunk access. 0x00, 0x20, 0x40 and so on.

And in JFFS2 behavior, sometimes it reads two pages alternatively.
e.g., It first reads A page, B page and A page.
So we check another bufferram to find requested page.
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
parent 4f4fad27
...@@ -577,19 +577,22 @@ static int onenand_write_bufferram(struct mtd_info *mtd, int area, ...@@ -577,19 +577,22 @@ static int onenand_write_bufferram(struct mtd_info *mtd, int area,
static int onenand_check_bufferram(struct mtd_info *mtd, loff_t addr) static int onenand_check_bufferram(struct mtd_info *mtd, loff_t addr)
{ {
struct onenand_chip *this = mtd->priv; struct onenand_chip *this = mtd->priv;
int block, page; int blockpage;
int i; unsigned int i;
block = (int) (addr >> this->erase_shift); blockpage = (int) (addr >> this->page_shift);
page = (int) (addr >> this->page_shift) & this->page_mask;
/* Is there valid data? */
i = ONENAND_CURRENT_BUFFERRAM(this); i = ONENAND_CURRENT_BUFFERRAM(this);
if (this->bufferram[i].blockpage == blockpage)
return 1;
/* Is there valid data? */ /* Check another BufferRAM */
if (this->bufferram[i].block == block && i = ONENAND_NEXT_BUFFERRAM(this);
this->bufferram[i].page == page && if (this->bufferram[i].blockpage == blockpage) {
this->bufferram[i].valid) ONENAND_SET_NEXT_BUFFERRAM(this);
return 1; return 1;
}
return 0; return 0;
} }
...@@ -602,30 +605,26 @@ static int onenand_check_bufferram(struct mtd_info *mtd, loff_t addr) ...@@ -602,30 +605,26 @@ static int onenand_check_bufferram(struct mtd_info *mtd, loff_t addr)
* *
* Update BufferRAM information * Update BufferRAM information
*/ */
static int onenand_update_bufferram(struct mtd_info *mtd, loff_t addr, static void onenand_update_bufferram(struct mtd_info *mtd, loff_t addr,
int valid) int valid)
{ {
struct onenand_chip *this = mtd->priv; struct onenand_chip *this = mtd->priv;
int block, page; int blockpage;
int i; unsigned int i;
block = (int) (addr >> this->erase_shift); blockpage = (int) (addr >> this->page_shift);
page = (int) (addr >> this->page_shift) & this->page_mask;
/* Invalidate BufferRAM */ /* Invalidate another BufferRAM */
for (i = 0; i < MAX_BUFFERRAM; i++) { i = ONENAND_NEXT_BUFFERRAM(this);
if (this->bufferram[i].block == block && if (this->bufferram[i].blockpage == blockpage) {
this->bufferram[i].page == page) this->bufferram[i].blockpage = -1;
this->bufferram[i].valid = 0;
}
/* Update BufferRAM */ /* Update BufferRAM */
i = ONENAND_CURRENT_BUFFERRAM(this); i = ONENAND_CURRENT_BUFFERRAM(this);
this->bufferram[i].block = block; if (valid)
this->bufferram[i].page = page; this->bufferram[i].blockpage = blockpage;
this->bufferram[i].valid = valid; else
this->bufferram[i].blockpage = -1;
return 0;
} }
/** /**
......
...@@ -42,14 +42,10 @@ typedef enum { ...@@ -42,14 +42,10 @@ typedef enum {
/** /**
* struct onenand_bufferram - OneNAND BufferRAM Data * struct onenand_bufferram - OneNAND BufferRAM Data
* @block: block address in BufferRAM * @blockpage: block & page address in BufferRAM
* @page: page address in BufferRAM
* @valid: valid flag
*/ */
struct onenand_bufferram { struct onenand_bufferram {
int block; int blockpage;
int page;
int valid;
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment