Patchwork nand_wait_ready timeout fix

login
register
mail settings
Submitter Matthieu CASTET
Date Nov. 5, 2012, 1:51 p.m.
Message ID <1352123511-31538-1-git-send-email-matthieu.castet@parrot.com>
Download mbox | patch
Permalink /patch/197202/
State New
Headers show

Comments

Matthieu CASTET - Nov. 5, 2012, 1:51 p.m.
nand_wait_ready timeout should not assume HZ=1000.
Make it independent of HZ value like it is done in nand_wait.

Signed-off-by: Matthieu CASTET <matthieu.castet@parrot.com>
---
 drivers/mtd/nand/nand_base.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Artem Bityutskiy - Nov. 15, 2012, 1:55 p.m.
On Mon, 2012-11-05 at 14:51 +0100, Matthieu CASTET wrote:
> nand_wait_ready timeout should not assume HZ=1000.
> Make it independent of HZ value like it is done in nand_wait.
> 
> Signed-off-by: Matthieu CASTET <matthieu.castet@parrot.com>
> ---
>  drivers/mtd/nand/nand_base.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index d5ece6e..ee49fe2 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -492,7 +492,7 @@ static void panic_nand_wait_ready(struct mtd_info *mtd, unsigned long timeo)
>  void nand_wait_ready(struct mtd_info *mtd)
>  {
>  	struct nand_chip *chip = mtd->priv;
> -	unsigned long timeo = jiffies + 2;
> +	unsigned long timeo = jiffies + (2 * HZ) / 1000;

I HZ=100, (2 * HZ) / 1000 will be 0, which is probably wrong.

Instead, this cruft should be re-worked and should use milliseconds for
time-outs, and use things like 'msecs_to_jiffies()' instead.
Matthieu CASTET - Nov. 22, 2012, 5:06 p.m.
Artem Bityutskiy a écrit :
> On Mon, 2012-11-05 at 14:51 +0100, Matthieu CASTET wrote:
>> nand_wait_ready timeout should not assume HZ=1000.
>> Make it independent of HZ value like it is done in nand_wait.
>>
>> Signed-off-by: Matthieu CASTET <matthieu.castet@parrot.com>
>> ---
>>  drivers/mtd/nand/nand_base.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
>> index d5ece6e..ee49fe2 100644
>> --- a/drivers/mtd/nand/nand_base.c
>> +++ b/drivers/mtd/nand/nand_base.c
>> @@ -492,7 +492,7 @@ static void panic_nand_wait_ready(struct mtd_info *mtd, unsigned long timeo)
>>  void nand_wait_ready(struct mtd_info *mtd)
>>  {
>>  	struct nand_chip *chip = mtd->priv;
>> -	unsigned long timeo = jiffies + 2;
>> +	unsigned long timeo = jiffies + (2 * HZ) / 1000;
> 
> I HZ=100, (2 * HZ) / 1000 will be 0, which is probably wrong.
> 
> Instead, this cruft should be re-worked and should use milliseconds for
> time-outs, and use things like 'msecs_to_jiffies()' instead.
> 
> 

Ok,

Should I also update nand_wait [1] ?


Matthieu

[1]
static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip)
{

    unsigned long timeo = jiffies;
    int status, state = chip->state;

    if (state == FL_ERASING)
        timeo += (HZ * 400) / 1000;
    else
        timeo += (HZ * 20) / 1000;
Artem Bityutskiy - Nov. 30, 2012, 12:35 p.m.
On Thu, 2012-11-22 at 18:06 +0100, Matthieu CASTET wrote:
> Should I also update nand_wait [1] ?

Would be nice I think.

Patch

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index d5ece6e..ee49fe2 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -492,7 +492,7 @@  static void panic_nand_wait_ready(struct mtd_info *mtd, unsigned long timeo)
 void nand_wait_ready(struct mtd_info *mtd)
 {
 	struct nand_chip *chip = mtd->priv;
-	unsigned long timeo = jiffies + 2;
+	unsigned long timeo = jiffies + (2 * HZ) / 1000;
 
 	/* 400ms timeout */
 	if (in_interrupt() || oops_in_progress)