Skip to contentSkip to conversation

Blackfin: nand: drain the write buffer before returning

PATCH New Mike Frysinger 2 participants 6 messages May 7, 2010 – May 20, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Blackfin: nand: drain the write buffer before returning

From: Andrew Caldwell <[email protected]>

The current Blackfin nand write function fills up the write buffer but returns before it has had a chance to drain. On faster systems, this isn't a problem as the operation finishes before the ECC registers are read, but on slower systems the ECC may be incomplete when the core tries to read it.

So wait for the buffer to drain once we're doing writing to it.

---
 drivers/mtd/nand/bfin_nand.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
drivers/mtd/nand/bfin_nand.c +6 -1
index f134ef1..13a509d 100644
@@ -75,7 +75,7 @@ static void bfin_nfc_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
 int bfin_nfc_devready(struct mtd_info *mtd)
 {
 	pr_stamp();
-	return (bfin_read_NFC_STAT() & NBUSY ? 1 : 0);
+	return (bfin_read_NFC_STAT() & NBUSY) ? 1 : 0;
 }
 
 /*
@@ -132,6 +132,11 @@ static void bfin_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len
 
 		bfin_write_NFC_DATA_WR(buf[i]);
 	}
+
+	/* Wait for the buffer to drain before we return */
+	while (bfin_read_NFC_STAT() & WB_EMPTY)
+		if (ctrlc())
+			return;
 }
 
 /*
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 Blackfin: nand: drain the write buffer before returning

Quoted 8 lines · Mike Frysinger

From: Andrew Caldwell <[email protected]>

The current Blackfin nand write function fills up the write buffer but returns before it has had a chance to drain. On faster systems, this isn't a problem as the operation finishes before the ECC registers are read, but on slower systems the ECC may be incomplete when the core tries to read it.

Quoted 7 lines

So wait for the buffer to drain once we're doing writing to it.

---
 drivers/mtd/nand/bfin_nand.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

Applied to u-boot-nand-flash.

-Scott

#2 lore raw

PATCH 1/1 Blackfin: nand: drain the write buffer before returning

Quoted 11 lines · On Friday 07 May 2010 13:51:51 Scott Wood wrote:
Quoted 10 lines · Mike Frysinger

From: Andrew Caldwell <[email protected]>

The current Blackfin nand write function fills up the write buffer but returns before it has had a chance to drain. On faster systems, this isn't a problem as the operation finishes before the ECC registers are read, but on slower systems the ECC may be incomplete when the core tries to read it.

So wait for the buffer to drain once we're doing writing to it.

Quoted 8 lines
Quoted 6 lines

---

 drivers/mtd/nand/bfin_nand.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

Applied to u-boot-nand-flash.

sorry, please drop this. Andrew pointed out that i committed/posted the wrong version. i'll send an update shortly.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100507/c651a82d/attachment.pgp

#3 lore raw

PATCH 1/1 Blackfin: nand: drain the write buffer before returning

Quoted 16 lines · Mike Frysinger
Quoted 15 lines · On Friday 07 May 2010 13:51:51 Scott Wood wrote:
Quoted 14 lines · Mike Frysinger

From: Andrew Caldwell<[email protected]>

The current Blackfin nand write function fills up the write buffer but returns before it has had a chance to drain. On faster systems, this isn't a problem as the operation finishes before the ECC registers are read, but on slower systems the ECC may be incomplete when the core tries to read it.

So wait for the buffer to drain once we're doing writing to it.

---

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
  drivers/mtd/nand/bfin_nand.c |    7 ++++++-
  1 files changed, 6 insertions(+), 1 deletions(-)

Applied to u-boot-nand-flash.

sorry, please drop this. Andrew pointed out that i committed/posted the wrong version. i'll send an update shortly.

OK, done.

-Scott

#4 lore raw

PATCH v2 1/1 Blackfin: nand: drain the write buffer before returning

In reply to Mike Frysinger

From: Andrew Caldwell <[email protected]>

The current Blackfin nand write function fills up the write buffer but returns before it has had a chance to drain. On faster systems, this isn't a problem as the operation finishes before the ECC registers are read, but on slower systems the ECC may be incomplete when the core tries to read it.

So wait for the buffer to drain once we're done writing to it.

---
v2
- fix inverted logic reminded by Andrew

 drivers/mtd/nand/bfin_nand.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
drivers/mtd/nand/bfin_nand.c +6 -1
index f134ef1..6d3d450 100644
@@ -75,7 +75,7 @@ static void bfin_nfc_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
 int bfin_nfc_devready(struct mtd_info *mtd)
 {
 	pr_stamp();
-	return (bfin_read_NFC_STAT() & NBUSY ? 1 : 0);
+	return (bfin_read_NFC_STAT() & NBUSY) ? 1 : 0;
 }
 
 /*
@@ -132,6 +132,11 @@ static void bfin_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len
 
 		bfin_write_NFC_DATA_WR(buf[i]);
 	}
+
+	/* Wait for the buffer to drain before we return */
+	while (!(bfin_read_NFC_STAT() & WB_EMPTY))
+		if (ctrlc())
+			return;
 }
 
 /*
Signature · 1 line
1.7.1
#5 lore raw

PATCH v2 1/1 Blackfin: nand: drain the write buffer before returning

Quoted 8 lines · Mike Frysinger

From: Andrew Caldwell <[email protected]>

The current Blackfin nand write function fills up the write buffer but returns before it has had a chance to drain. On faster systems, this isn't a problem as the operation finishes before the ECC registers are read, but on slower systems the ECC may be incomplete when the core tries to read it.

Quoted 7 lines

So wait for the buffer to drain once we're done writing to it.

---
v2
- fix inverted logic reminded by Andrew

Applied to u-boot-nand-flash.

-Scott