mtd/drivers/mtd/chips cfi_cmdset_0002.c,1.101,1.102
ebiederman at lnxi.com
ebiederman at lnxi.com
Wed Jul 14 01:17:58 EDT 2004
Update of /home/cvs/mtd/drivers/mtd/chips
In directory phoenix.infradead.org:/tmp/cvs-serv32012/drivers/mtd/chips
Modified Files:
cfi_cmdset_0002.c
Log Message:
- In cfi_cmdset_0002 add error detection
- In cfi_cmdset_0002 add retries in do_write_one_word
For transient errors this make progress more likely.
user space can only really retry at the block/sector level.
- In ichxrom add support for using non-firmware hub flash parts
- In ichxrom add support for using cfi flash parts
- In ichxrom add support for probing multiple bank widths.
I still don't support multiple bank widths but this is as close as I come.
Index: cfi_cmdset_0002.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/cfi_cmdset_0002.c,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -r1.101 -r1.102
--- cfi_cmdset_0002.c 10 Jul 2004 21:14:17 -0000 1.101
+++ cfi_cmdset_0002.c 14 Jul 2004 05:17:55 -0000 1.102
@@ -38,6 +38,7 @@
#define AMD_BOOTLOC_BUG
#define FORCE_WORD_WRITE 0
+#define MAX_WORD_RETRIES 3
static int cfi_amdstd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
static int cfi_amdstd_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
@@ -386,12 +387,12 @@
*/
static int chip_ready(struct map_info *map, unsigned long addr)
{
- map_word d, t;
+ map_word d, t;
- d = map_read(map, addr);
- t = map_read(map, addr);
+ d = map_read(map, addr);
+ t = map_read(map, addr);
- return map_word_equal(map, d, t);
+ return map_word_equal(map, d, t);
}
static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode)
@@ -701,7 +702,8 @@
*/
unsigned long uWriteTimeout = ( HZ / 1000 ) + 1;
int ret = 0;
- map_word oldd;
+ map_word oldd, curd;
+ int retry_cnt = 0;
adr += chip->start;
@@ -729,6 +731,7 @@
}
ENABLE_VPP(map);
+ retry:
/*
* The CFI_DEVICETYPE_X8 argument is needed even when
* cfi->device_type != CFI_DEVICETYPE_X8. The addresses for
@@ -764,11 +767,23 @@
continue;
}
- if (chip_ready(map, adr))
- goto op_done;
+ /* Test to see if toggling has stopped. */
+ oldd = map_read(map, adr);
+ curd = map_read(map, adr);
+ if (map_word_equal(map, curd, oldd)) {
+ /* Do we have the correct value? */
+ if (map_word_equal(map, curd, datum)) {
+ goto op_done;
+ }
+ /* Nope something has gone wrong. */
+ break;
+ }
- if (time_after(jiffies, timeo))
+ if (time_after(jiffies, timeo)) {
+ printk(KERN_WARNING "MTD %s(): software timeout\n",
+ __func__ );
break;
+ }
/* Latency issues. Drop the lock, wait a while and retry */
cfi_spin_unlock(chip->mutex);
@@ -776,14 +791,13 @@
cfi_spin_lock(chip->mutex);
}
- printk(KERN_WARNING "MTD %s(): software timeout\n",
- __func__ );
-
/* reset on all failures. */
map_write( map, CMD(0xF0), chip->start );
/* FIXME - should have reset delay before continuing */
- ret = -EIO;
+ if (++retry_cnt <= MAX_WORD_RETRIES)
+ goto retry;
+ ret = -EIO;
op_done:
chip->state = FL_READY;
put_chip(map, chip, adr);
@@ -1033,8 +1047,8 @@
/* reset on all failures. */
map_write( map, CMD(0xF0), chip->start );
/* FIXME - should have reset delay before continuing */
- ret = -EIO;
+ ret = -EIO;
op_done:
chip->state = FL_READY;
put_chip(map, chip, adr);
@@ -1203,8 +1217,8 @@
/* reset on all failures. */
map_write( map, CMD(0xF0), chip->start );
/* FIXME - should have reset delay before continuing */
- ret = -EIO;
+ ret = -EIO;
op_done:
chip->state = FL_READY;
put_chip(map, chip, adr);
@@ -1382,8 +1396,8 @@
/* reset on all failures. */
map_write( map, CMD(0xF0), chip->start );
/* FIXME - should have reset delay before continuing */
- ret = -EIO;
+ ret = -EIO;
op_done:
chip->state = FL_READY;
put_chip(map, chip, adr);
More information about the linux-mtd-cvs
mailing list