From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
To: linux-mtd@lists.infradead.org, David Woodhouse <dwmw2@infradead.org>
Subject: [PATCH] [MTD] Adjust the NOR CFI flash timeouts to round better
Date: Fri, 5 Oct 2012 12:32:02 -0600 [thread overview]
Message-ID: <20121005183202.GA11385@obsidianresearch.com> (raw)
Using jiffies for timeout could have significant rounding, ie if we
start at jiffie 1.9 and timeout at 2 then we may only get .1 jiffies
of timeout, which is not nearly enough. With a Hz of 250 I've seen
random bogus timeouts from this code.
Add a +1 to the HZ calculations to ensure a guaranteed minimum
timeout period.
This also increases the write_buffer timeout to 1.5us since I have
flashes in use that have a datasheet max of over 1 us.
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
---
drivers/mtd/chips/cfi_cmdset_0002.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index 22d0493..46a1dde 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -1150,10 +1150,10 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
* use the maximum timeout value given by the chip at probe time
* instead. Unfortunately, struct flchip does have a field for
* maximum timeout, only for typical which can be far too short
- * depending of the conditions. The ' + 1' is to avoid having a
- * timeout of 0 jiffies if HZ is smaller than 1000.
+ * depending of the conditions. The ' + 2' is to ensure we get
+ * *at least* 1000us of timeout.
*/
- unsigned long uWriteTimeout = ( HZ / 1000 ) + 1;
+ unsigned long uWriteTimeout = (HZ / 1000) + 2;
int ret = 0;
map_word oldd;
int retry_cnt = 0;
@@ -1382,8 +1382,11 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
{
struct cfi_private *cfi = map->fldrv_priv;
unsigned long timeo = jiffies + HZ;
- /* see comments in do_write_oneword() regarding uWriteTimeo. */
- unsigned long uWriteTimeout = ( HZ / 1000 ) + 1;
+ /* see comments in do_write_oneword() regarding uWriteTimeo.
+ Note: write_buffer commands take longer so we use a higher
+ time. The AMD 29LV256M for instance has a datasheet max
+ of 1.2ms for page and 600us for byte */
+ unsigned long uWriteTimeout = (HZ / 1500) + 2;
int ret = -EIO;
unsigned long cmd_adr;
int z, words;
--
1.7.5.4
next reply other threads:[~2012-10-05 18:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-05 18:32 Jason Gunthorpe [this message]
2012-10-15 13:42 ` [PATCH] [MTD] Adjust the NOR CFI flash timeouts to round better Artem Bityutskiy
2012-10-15 16:09 ` David Woodhouse
2012-10-15 16:57 ` Jason Gunthorpe
2012-10-15 17:31 ` David Woodhouse
2012-10-15 17:49 ` Jason Gunthorpe
2012-10-15 18:32 ` David Woodhouse
2012-10-15 19:08 ` Jason Gunthorpe
2012-10-15 19:28 ` Artem Bityutskiy
2012-10-15 20:00 ` David Woodhouse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121005183202.GA11385@obsidianresearch.com \
--to=jgunthorpe@obsidianresearch.com \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.