diff options
author | Konstantin Baidarov <kbaidarov@ru.mvista.com> | 2005-11-07 04:00:05 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@mtd.linutronix.de> | 2005-11-07 04:47:08 -0500 |
commit | b95f9609c761a14d1e7be1a89f2a66399b5ae343 (patch) | |
tree | d0f097e82deb18ebc0c854ac1ae627865b63a130 /drivers | |
parent | be30c10fd8015a00c97c9b473263fe3c581389de (diff) |
[MTD] chips cfi_cmdset_0002: Prevent timeout race
We've noticed that sometimes "MTD do_write_buffer(): software timeout"
message was printed out when writing to a Fujitsu NOR flash.
It turned out that this was because of a race in the timeout handling
do_write_buffer(). A small timeout of (HZ / 1000) + 1 is used there, and
sometimes if the timer interrupt handling takes more than one or even two
jiffies (which is 1-2 ms with HZ == 1000) and that interrupt happens just
after chip_ready() call, the driver bails out from a ready polling loop
despite the chip has actually become ready while all those interrupts were
handled. To deal with this issue, extra check for chip ready is neccessary on
timeout expiration (and the checks should better be reordered).
As do_write_oneword() uses the same approach, it needs to also be changed.
Signed-off-by: Konstantin Baidarov <kbaidarov@ru.mvista.com>
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/chips/cfi_cmdset_0002.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index e3d31c749045..50dd7d2f096d 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c | |||
@@ -17,7 +17,7 @@ | |||
17 | * | 17 | * |
18 | * This code is GPL | 18 | * This code is GPL |
19 | * | 19 | * |
20 | * $Id: cfi_cmdset_0002.c,v 1.120 2005/07/20 21:01:13 tpoynor Exp $ | 20 | * $Id: cfi_cmdset_0002.c,v 1.121 2005/11/07 09:00:01 gleixner Exp $ |
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | 23 | ||
@@ -1014,16 +1014,16 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, | |||
1014 | continue; | 1014 | continue; |
1015 | } | 1015 | } |
1016 | 1016 | ||
1017 | if (chip_ready(map, adr)) | 1017 | if (time_after(jiffies, timeo) && !chip_ready(map, adr)){ |
1018 | break; | ||
1019 | |||
1020 | if (time_after(jiffies, timeo)) { | ||
1021 | xip_enable(map, chip, adr); | 1018 | xip_enable(map, chip, adr); |
1022 | printk(KERN_WARNING "MTD %s(): software timeout\n", __func__); | 1019 | printk(KERN_WARNING "MTD %s(): software timeout\n", __func__); |
1023 | xip_disable(map, chip, adr); | 1020 | xip_disable(map, chip, adr); |
1024 | break; | 1021 | break; |
1025 | } | 1022 | } |
1026 | 1023 | ||
1024 | if (chip_ready(map, adr)) | ||
1025 | break; | ||
1026 | |||
1027 | /* Latency issues. Drop the lock, wait a while and retry */ | 1027 | /* Latency issues. Drop the lock, wait a while and retry */ |
1028 | UDELAY(map, chip, adr, 1); | 1028 | UDELAY(map, chip, adr, 1); |
1029 | } | 1029 | } |
@@ -1275,13 +1275,13 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
1275 | continue; | 1275 | continue; |
1276 | } | 1276 | } |
1277 | 1277 | ||
1278 | if (time_after(jiffies, timeo) && !chip_ready(map, adr)) | ||
1279 | break; | ||
1280 | |||
1278 | if (chip_ready(map, adr)) { | 1281 | if (chip_ready(map, adr)) { |
1279 | xip_enable(map, chip, adr); | 1282 | xip_enable(map, chip, adr); |
1280 | goto op_done; | 1283 | goto op_done; |
1281 | } | 1284 | } |
1282 | |||
1283 | if( time_after(jiffies, timeo)) | ||
1284 | break; | ||
1285 | 1285 | ||
1286 | /* Latency issues. Drop the lock, wait a while and retry */ | 1286 | /* Latency issues. Drop the lock, wait a while and retry */ |
1287 | UDELAY(map, chip, adr, 1); | 1287 | UDELAY(map, chip, adr, 1); |