aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Dunn <mikedunn@newsguy.com>2013-10-10 13:25:27 -0400
committerBrian Norris <computersforpeace@gmail.com>2013-11-07 02:32:52 -0500
commit9fee840c03d944ed1564c127375a702e242d9555 (patch)
tree9d37d26744995ad6418258e995e6575f29e9ae75
parent5422933d58c28ebc67c7425f20e85ef27b730188 (diff)
mtd: docg4: fix status polling loop
The loop that polls the status register waiting for an operation to complete foolishly bases the timeout simply on the number of loop iterations that have ocurred. When I increased the processor clock speed, timeouts started to appear for long block erasure operations. This patch measures the timeout using jiffies. Signed-off-by: Mike Dunn <mikedunn@newsguy.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r--drivers/mtd/nand/docg4.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c
index 7c38b8ad4404..bd1cb672034f 100644
--- a/drivers/mtd/nand/docg4.c
+++ b/drivers/mtd/nand/docg4.c
@@ -44,6 +44,7 @@
44#include <linux/mtd/nand.h> 44#include <linux/mtd/nand.h>
45#include <linux/bch.h> 45#include <linux/bch.h>
46#include <linux/bitrev.h> 46#include <linux/bitrev.h>
47#include <linux/jiffies.h>
47 48
48/* 49/*
49 * In "reliable mode" consecutive 2k pages are used in parallel (in some 50 * In "reliable mode" consecutive 2k pages are used in parallel (in some
@@ -269,7 +270,7 @@ static int poll_status(struct docg4_priv *doc)
269 */ 270 */
270 271
271 uint16_t flash_status; 272 uint16_t flash_status;
272 unsigned int timeo; 273 unsigned long timeo;
273 void __iomem *docptr = doc->virtadr; 274 void __iomem *docptr = doc->virtadr;
274 275
275 dev_dbg(doc->dev, "%s...\n", __func__); 276 dev_dbg(doc->dev, "%s...\n", __func__);
@@ -277,22 +278,18 @@ static int poll_status(struct docg4_priv *doc)
277 /* hardware quirk requires reading twice initially */ 278 /* hardware quirk requires reading twice initially */
278 flash_status = readw(docptr + DOC_FLASHCONTROL); 279 flash_status = readw(docptr + DOC_FLASHCONTROL);
279 280
280 timeo = 1000; 281 timeo = jiffies + msecs_to_jiffies(200); /* generous timeout */
281 do { 282 do {
282 cpu_relax(); 283 cpu_relax();
283 flash_status = readb(docptr + DOC_FLASHCONTROL); 284 flash_status = readb(docptr + DOC_FLASHCONTROL);
284 } while (!(flash_status & DOC_CTRL_FLASHREADY) && --timeo); 285 } while (!(flash_status & DOC_CTRL_FLASHREADY) &&
286 time_before(jiffies, timeo));
285 287
286 288 if (unlikely(!(flash_status & DOC_CTRL_FLASHREADY))) {
287 if (!timeo) {
288 dev_err(doc->dev, "%s: timed out!\n", __func__); 289 dev_err(doc->dev, "%s: timed out!\n", __func__);
289 return NAND_STATUS_FAIL; 290 return NAND_STATUS_FAIL;
290 } 291 }
291 292
292 if (unlikely(timeo < 50))
293 dev_warn(doc->dev, "%s: nearly timed out; %d remaining\n",
294 __func__, timeo);
295
296 return 0; 293 return 0;
297} 294}
298 295