[PATCH 1/1] mtd:nor:timeout:fix do_write_buffer() timeout error
Bean Huo 霍斌斌 (beanhuo)
beanhuo at micron.com
Mon Jun 2 23:26:37 PDT 2014
Hi,Christian
1、MT28EW512ABA is Micron's parallel Norflash that use the cfi_cmdset_0002.c driver.
2、yes,I am setting several parameters here(word_write_time_max、buffer_write_time_max、erase_time_max).For this patch,I only used buffer_write_time_max parameter.Because this patch is mainly focus on fix do_write_buffer() timeout error. If this patch is accepted, I will submit another patch that for fix single word program timeout error and erase timeout error.thanks.
3、The time unit of uWriteTimeout is ms. In order to achieve large rather than small timeout ,so using following conversion,
> + unsigned long uWriteTimeout = (chip->buffer_write_time_max % 1000) ?
> + (chip->buffer_write_time_max / 1000 + 1) :
> + (chip->buffer_write_time_max / 1000);
4、For the following code,I now have some ideas,but having not test and verify now.If it test Ok later,I will submit it.
timeo = jiffies+ (HZ / 2); This line has a big /* FIXME */
-----Original Message-----
From: christian.riesch at gmail.com [mailto:christian.riesch at gmail.com] On Behalf Of Christian Riesch
Sent: Monday, June 02, 2014 6:26 PM
To: Bean Huo 霍斌斌 (beanhuo)
Cc: David Woodhouse; Brian Norris; Alexander Shiyan; Paul Gortmaker; Jingoo Han; linux-mtd at lists.infradead.org; Kees Cook
Subject: Re: [PATCH 1/1] mtd:nor:timeout:fix do_write_buffer() timeout error
Hi,
When you send an updated version of a patch, please put version numbers into the subject, e.g. [PATCH v2], [PATCH v3]..., and include a changelog. And I think you shouldn't send the new versions as a reply to an earlier mail, send them as a new post instead.
On Mon, May 26, 2014 at 3:01 AM, Bean Huo 霍斌斌 (beanhuo) <beanhuo at micron.com> wrote:
> The size of the buffer program has been increased from 256 to 512 , 2ms maximum timeout can not adapt to all the different vendor's norflash, There maximum timeout information in the CFI area,so the best way is to choose the result calculated according to timeout field of struct cfi_ident that probed from norflash's CFI aera.This is also a standard defined by CFI.
>
> Without this change, if the size of buffer program is 512 or bigger than 256, due to timeout is the shorter than that the chip required,do_write_buffer sometimes fails.
>
> Tested with Micron JS28F512M29EWx and Micron MT28EW512ABA flash devices.
What kind of device is the MT28EW512ABA? Aren't MT28 devices StrataFlashes that use the cfi_cmdset_0001.c driver?
>
> Signed-off-by: bean huo <beanhuo at micron.com>
> ---
> drivers/mtd/chips/cfi_cmdset_0002.c | 49 ++++++++++++++++++++++++++++++++---
> 1 file changed, 45 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c
> b/drivers/mtd/chips/cfi_cmdset_0002.
> index e21fde9..87d446a 100644
> --- a/drivers/mtd/chips/cfi_cmdset_0002.c
> +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
> @@ -628,10 +628,42 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
> cfi->chips[i].word_write_time = 1<<cfi->cfiq->WordWriteTimeoutTyp;
> cfi->chips[i].buffer_write_time = 1<<cfi->cfiq->BufWriteTimeoutTyp;
> cfi->chips[i].erase_time =
> 1<<cfi->cfiq->BlockEraseTimeoutTyp;
> + /*
> + * We first calculate the timeout max according to timeout
> + * field of struct cfi_ident that probed from chip's CFI
> + * aera,If haven't probed this information,we will specify
> + * a default value,and the time unit is us.
> + */
> + if (cfi->cfiq->WordWriteTimeoutTyp &&
> + cfi->cfiq->WordWriteTimeoutMax){
> + cfi->chips[i].word_write_time_max =
> + 1<<(cfi->cfiq->WordWriteTimeoutTyp +
> + cfi->cfiq->WordWriteTimeoutMax);
> + } else {
> + /* specify maximum timeout for byte/word program 2000us */
> + cfi->chips[i].word_write_time_max = 2000;
> + }
> + if (cfi->cfiq->BufWriteTimeoutTyp &&
> + cfi->cfiq->BufWriteTimeoutMax){
> + cfi->chips[i].buffer_write_time_max =
> + 1<<(cfi->cfiq->BufWriteTimeoutTyp +
> + cfi->cfiq->BufWriteTimeoutMax);
> + } else {
> + /* specify maximum timeout for buffer program 2000us */
> + cfi->chips[i].buffer_write_time_max = 2000;
> + }
> + if (cfi->cfiq->BlockEraseTimeoutTyp &&
> + cfi->cfiq->BlockEraseTimeoutMax){
> + cfi->chips[i].erase_time_max =
> + 1<<(cfi->cfiq->BlockEraseTimeoutTyp +
> + cfi->cfiq->BlockEraseTimeoutMax);
> + } else {
> + /* specify maximum timeout per individual block erase 3000000us */
> + cfi->chips[i].erase_time_max = 3000000;
> + }
You are setting several parameters here, but you only use buffer_write_time_max. Why?
> cfi->chips[i].ref_point_counter = 0;
> init_waitqueue_head(&(cfi->chips[i].wq));
> }
> -
> map->fldrv = &cfi_amdstd_chipdrv;
>
> return cfi_amdstd_setup(mtd);
> @@ -1462,8 +1494,16 @@ 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;
> + /* The size of the buffer program has been increased from 256 to 512,
> + * 2ms maximum timeout can not adapt to all the different vendor's
> + * norflash.There maximum timeout information in the CFI area,so the
> + * best way is to choose the result calculated according to timeout
> + * field of struct cfi_ident that probed from norflash's CFI aera,see
> + * comments in cfi_cmdset_0002().The time unit of uWriteTimeout is ms.
> + */
> + unsigned long uWriteTimeout = (chip->buffer_write_time_max % 1000) ?
> + (chip->buffer_write_time_max / 1000 + 1) :
> + (chip->buffer_write_time_max / 1000);
How about using usecs_to_jiffies below? Then you wouldn't need this conversion, right?
> int ret = -EIO;
> unsigned long cmd_adr;
> int z, words;
> @@ -1520,7 +1560,8 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
> adr, map_bankwidth(map),
> chip->word_write_time);
>
> - timeo = jiffies + uWriteTimeout;
> + /*Maximum timeout must be converted into jiffies */
> + timeo = jiffies + msecs_to_jiffies(uWriteTimeout);
>
A few lines below in the loop timeo is modified again, timeo = jiffies
+ (HZ / 2); This line has a big /* FIXME */ comment. Any ideas what
should be fixed here?
Best regards,
Christian
> for (;;) {
> if (chip->state != FL_WRITING) {
> --
> 1.7.9.5
>
>
>
More information about the linux-mtd
mailing list