* [Qemu-devel] [PATCH 0/1] nand: Support random data reads.
@ 2010-01-12 14:05 Edgar E. Iglesias
2010-01-12 14:05 ` [Qemu-devel] [PATCH 1/1] nand: Correct " Edgar E. Iglesias
2010-01-12 15:35 ` [Qemu-devel] Re: [PATCH 0/1] nand: Support " Jean-Hugues Deschenes
0 siblings, 2 replies; 3+ messages in thread
From: Edgar E. Iglesias @ 2010-01-12 14:05 UTC (permalink / raw)
To: qemu-devel; +Cc: Edgar E. Iglesias, Jean-Hugues Deschenes
As promised this is a resend of a patch I posted 2008-12-12.
At some point linux MTD started using random data reads and my NAND
boards stopped working. This patch fixed the issue.
I received a comment regarding sequential reads that cross page boundaries.
Those won't work but they don't work without the patch either so IMO that
can be addressed with follow-up patches.
Would be great if someone with access to guests for other NAND boards could
try this out. Even better with something else than linux guests.
I've ran it on CRIS, ARM and MIPS boards but only with linux guests.
Cheers
Edgar E. Iglesias (1):
nand: Correct random data reads.
hw/nand.c | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH 1/1] nand: Correct random data reads.
2010-01-12 14:05 [Qemu-devel] [PATCH 0/1] nand: Support random data reads Edgar E. Iglesias
@ 2010-01-12 14:05 ` Edgar E. Iglesias
2010-01-12 15:35 ` [Qemu-devel] Re: [PATCH 0/1] nand: Support " Jean-Hugues Deschenes
1 sibling, 0 replies; 3+ messages in thread
From: Edgar E. Iglesias @ 2010-01-12 14:05 UTC (permalink / raw)
To: qemu-devel; +Cc: Edgar E. Iglesias, Jean-Hugues Deschenes
Random reading depends on having the last row/page latched and not beeing
clobbered between read and any following random reads.
Also, s->iolen must be updated when loading the io/data register with
randomly accessed flash data.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
---
hw/nand.c | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/hw/nand.c b/hw/nand.c
index 838f8bc..40d5a6a 100644
--- a/hw/nand.c
+++ b/hw/nand.c
@@ -212,6 +212,7 @@ static void nand_reset(NANDFlashState *s)
static void nand_command(NANDFlashState *s)
{
+ unsigned int offset;
switch (s->cmd) {
case NAND_CMD_READ0:
s->iolen = 0;
@@ -233,8 +234,12 @@ static void nand_command(NANDFlashState *s)
case NAND_CMD_NOSERIALREAD2:
if (!(nand_flash_ids[s->chip_id].options & NAND_SAMSUNG_LP))
break;
-
- s->blk_load(s, s->addr, s->addr & ((1 << s->addr_shift) - 1));
+ offset = s->addr & ((1 << s->addr_shift) - 1);
+ s->blk_load(s, s->addr, offset);
+ if (s->gnd)
+ s->iolen = (1 << s->page_shift) - offset;
+ else
+ s->iolen = (1 << s->page_shift) + (1 << s->oob_shift) - offset;
break;
case NAND_CMD_RESET:
@@ -380,12 +385,15 @@ void nand_setio(NANDFlashState *s, uint8_t value)
if (s->cmd != NAND_CMD_RANDOMREAD2) {
s->addrlen = 0;
- s->addr = 0;
}
}
if (s->ale) {
- s->addr |= value << (s->addrlen * 8);
+ unsigned int shift = s->addrlen * 8;
+ unsigned int mask = ~(0xff << shift);
+ unsigned int v = value << shift;
+
+ s->addr = (s->addr & mask) | v;
s->addrlen ++;
if (s->addrlen == 1 && s->cmd == NAND_CMD_READID)
@@ -435,6 +443,7 @@ uint8_t nand_getio(NANDFlashState *s)
return 0;
s->iolen --;
+ s->addr++;
return *(s->ioaddr ++);
}
@@ -633,9 +642,6 @@ static void glue(nand_blk_load_, PAGE_SIZE)(NANDFlashState *s,
offset, PAGE_SIZE + OOB_SIZE - offset);
s->ioaddr = s->io;
}
-
- s->addr &= PAGE_SIZE - 1;
- s->addr += PAGE_SIZE;
}
static void glue(nand_init_, PAGE_SIZE)(NANDFlashState *s)
--
1.6.4.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Qemu-devel] Re: [PATCH 0/1] nand: Support random data reads.
2010-01-12 14:05 [Qemu-devel] [PATCH 0/1] nand: Support random data reads Edgar E. Iglesias
2010-01-12 14:05 ` [Qemu-devel] [PATCH 1/1] nand: Correct " Edgar E. Iglesias
@ 2010-01-12 15:35 ` Jean-Hugues Deschenes
1 sibling, 0 replies; 3+ messages in thread
From: Jean-Hugues Deschenes @ 2010-01-12 15:35 UTC (permalink / raw)
To: Edgar E. Iglesias; +Cc: qemu-devel
Edgar E. Iglesias wrote:
> As promised this is a resend of a patch I posted 2008-12-12.
>
Thanks.
> At some point linux MTD started using random data reads and my NAND
> boards stopped working. This patch fixed the issue.
>
> I received a comment regarding sequential reads that cross page boundaries.
> Those won't work but they don't work without the patch either so IMO that
> can be addressed with follow-up patches.
>
I share you opinion.
> Would be great if someone with access to guests for other NAND boards could
> try this out. Even better with something else than linux guests.
>
For what it's worth, I have tried this on an ARM-based guest running
Linux and it fixed my problem. Note that this (emulated) board
integrates a fairly evolved NAND flash controller that takes over most
flash device operations. The accesses made to the emulated NAND flash
device are then not necessarily the same as would have been done by the
stock MTD subsystem.
Also tested with u-boot integrating a dumbed-down version of the
aforementioned driver.
jh
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-01-12 15:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-12 14:05 [Qemu-devel] [PATCH 0/1] nand: Support random data reads Edgar E. Iglesias
2010-01-12 14:05 ` [Qemu-devel] [PATCH 1/1] nand: Correct " Edgar E. Iglesias
2010-01-12 15:35 ` [Qemu-devel] Re: [PATCH 0/1] nand: Support " Jean-Hugues Deschenes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).