diff mbox

[4/7] mtd: Blackfin NFC: wait for the ECC reset to finish

Message ID 1281020864-26842-4-git-send-email-vapier@gentoo.org
State Accepted
Commit 752b957a37ee1cc09fccb39a8bc5843edf32119b
Headers show

Commit Message

Mike Frysinger Aug. 5, 2010, 3:07 p.m. UTC
From: Barry Song <barry.song@analog.com>

When resetting the ECC registers/counters, the bit will automatically
clear itself once the reset has actually finished.  So make sure we
wait for that to occur before doing anything else rather than assuming
everything is peachy and proceeding with stale ECC values.

Signed-off-by: Barry Song <barry.song@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 drivers/mtd/nand/bf5xx_nand.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Comments

David Woodhouse Aug. 5, 2010, 3:16 p.m. UTC | #1
On Thu, 2010-08-05 at 11:07 -0400, Mike Frysinger wrote:
> 
> +       while (bfin_read_NFC_RST() & ECC_RST)
> +               cpu_relax(); 

All applied, but I'd be happier if this one had some kind of timeout and
didn't have the potential to loop forever if the hardware misbehaves.
Mike Frysinger Aug. 5, 2010, 3:20 p.m. UTC | #2
On Thu, Aug 5, 2010 at 11:16, David Woodhouse wrote:
> On Thu, 2010-08-05 at 11:07 -0400, Mike Frysinger wrote:
>>
>> +       while (bfin_read_NFC_RST() & ECC_RST)
>> +               cpu_relax();
>
> All applied, but I'd be happier if this one had some kind of timeout and
> didn't have the potential to loop forever if the hardware misbehaves.

ive opened a tracker item for it
-mike
Barry Song Aug. 16, 2010, 2:54 a.m. UTC | #3
On Thu, Aug 5, 2010 at 11:16 PM, David Woodhouse <dwmw2@infradead.org> wrote:
> On Thu, 2010-08-05 at 11:07 -0400, Mike Frysinger wrote:
>>
>> +       while (bfin_read_NFC_RST() & ECC_RST)
>> +               cpu_relax();
>
> All applied, but I'd be happier if this one had some kind of timeout and
> didn't have the potential to loop forever if the hardware misbehaves.
If this loop forever, it means a chip bug and really has no any way to
continue to run the system. So the point is "bfin_read_NFC_RST() &
ECC_RST" will must be real for the right chip, if the chip has bug,
there should be workaround but not a timeout.

>
> --
> David Woodhouse                            Open Source Technology Centre
> David.Woodhouse@intel.com                              Intel Corporation
>
>
> _______________________________________________
> Uclinux-dist-devel mailing list
> Uclinux-dist-devel@blackfin.uclinux.org
> https://blackfin.uclinux.org/mailman/listinfo/uclinux-dist-devel
>
Mike Frysinger Aug. 16, 2010, 3:31 a.m. UTC | #4
On Sun, Aug 15, 2010 at 22:54, Barry Song wrote:
> On Thu, Aug 5, 2010 at 11:16 PM, David Woodhouse wrote:
>> On Thu, 2010-08-05 at 11:07 -0400, Mike Frysinger wrote:
>>>
>>> +       while (bfin_read_NFC_RST() & ECC_RST)
>>> +               cpu_relax();
>>
>> All applied, but I'd be happier if this one had some kind of timeout and
>> didn't have the potential to loop forever if the hardware misbehaves.
>
> If this loop forever, it means a chip bug and really has no any way to
> continue to run the system. So the point is "bfin_read_NFC_RST() &
> ECC_RST" will must be real for the right chip, if the chip has bug,
> there should be workaround but not a timeout.

i think the presumption on the linux/driver side is that hardware has
the tendency to suck, so rather than hang the whole system because the
NFC flakes out, it should recover gracefully.  so spitting out NAND
I/O errors all over the console is preferable to a system that goes
nowhere.

personally, i think it depends on the driver/situation, and in the
embedded world, i tend to agree with you Barry in that a dead subpiece
is the same as the whole system being dead.  but my opinion doesnt
matter much if the subsystem maintainers reject the patches ;).
-mike
diff mbox

Patch

diff --git a/drivers/mtd/nand/bf5xx_nand.c b/drivers/mtd/nand/bf5xx_nand.c
index b553705..949f656 100644
--- a/drivers/mtd/nand/bf5xx_nand.c
+++ b/drivers/mtd/nand/bf5xx_nand.c
@@ -507,6 +507,8 @@  static void bf5xx_nand_dma_rw(struct mtd_info *mtd,
 	 */
 	bfin_write_NFC_RST(ECC_RST);
 	SSYNC();
+	while (bfin_read_NFC_RST() & ECC_RST)
+		cpu_relax();
 
 	disable_dma(CH_NFC);
 	clear_dma_irqstat(CH_NFC);