Patchwork Patch MTD: increase time out value for buffer program

login
register
mail settings
Submitter Changming Chen (changmingche)
Date June 13, 2012, 4:29 a.m.
Message ID <6ACDE3A4C2F7E94C8DBB6FCC0D06A0873DA88046@NTXBOIMBX05.micron.com>
Download mbox | patch
Permalink /patch/164526/
State New
Headers show

Comments

Changming Chen (changmingche) - June 13, 2012, 4:29 a.m.
The time out value(1ms:typical HZ defined smaller than 1000) defined for function "do_write_buffer" in "cfi_cmdset_0002.c" is not enough. Because the enlargement of buffer size, much time will cost for buffer program. It's has risk that time out will be triggered before buffer program finished and make misjudge for buffer program. we suggest that 4ms is more appropriate compare to 1ms. This change has no impact of program performance.


Best Regards!
chenchangming

Tel:+86-21-3899-7193
E-Mail:changmingche@micron.com
Artem Bityutskiy - June 26, 2012, 3:58 p.m.
On Wed, 2012-06-13 at 04:29 +0000, Changming Chen (changmingche) wrote:
> The time out value(1ms:typical HZ defined smaller than 1000) defined for function "do_write_buffer" in "cfi_cmdset_0002.c" is not enough. Because the enlargement of buffer size, much time will cost for buffer program. It's has risk that time out will be triggered before buffer program finished and make misjudge for buffer program. we suggest that 4ms is more appropriate compare to 1ms. This change has no impact of program performance.
> 
> diff --git a/a/drivers/mtd/chips/cfi_cmdset_0002.c b/b/drivers/mtd/chips/cfi_cmd
> index 9d93c45..7da8fca 100755
> --- a/a/drivers/mtd/chips/cfi_cmdset_0002.c
> +++ b/b/drivers/mtd/chips/cfi_cmdset_0002.c
> @@ -1312,7 +1312,7 @@ static int __xipram do_write_buffer(struct map_info *map, 
>          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;
> +        unsigned long uWriteTimeout = ( HZ / 1000 ) + 4;

No, sorry, this is not a fix, this is a band-aid. The whole HZ/1000
thing is broken. You should not use HZ at all. For this driver it looks
like you should use ' schedule_timeout()' with the right timout instead
of 'schedule()' and get rid of all the HZ and jiffies stuff.

Patch

diff --git a/a/drivers/mtd/chips/cfi_cmdset_0002.c b/b/drivers/mtd/chips/cfi_cmd
index 9d93c45..7da8fca 100755
--- a/a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -1312,7 +1312,7 @@  static int __xipram do_write_buffer(struct map_info *map, 
         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;
+        unsigned long uWriteTimeout = ( HZ / 1000 ) + 4;
         int ret = -EIO;
         unsigned long cmd_adr;
         int z, words;