All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: rawnand: marvell: pass ms delay to wait_op
@ 2018-05-03  2:21 Chris Packham
  2018-05-03  5:28 ` Chris Packham
  2018-05-07  7:41 ` Boris Brezillon
  0 siblings, 2 replies; 6+ messages in thread
From: Chris Packham @ 2018-05-03  2:21 UTC (permalink / raw)
  To: miquel.raynal, boris.brezillon
  Cc: linux-mtd, Chris Packham, stable, Richard Weinberger,
	David Woodhouse, Brian Norris, Marek Vasut, linux-kernel

marvell_nfc_wait_op() expects the delay to be expressed in milliseconds
but nand_sdr_timings uses picoseconds. Use PSEC_TO_MSEC when passing
tPROG_max to marvell_nfc_wait_op().

Fixes: 02f26ecf8c772 ("mtd: nand: add reworked Marvell NAND controller driver")
Cc: stable@vger.kernel.org
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
 drivers/mtd/nand/raw/marvell_nand.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
index 1d779a35ac8e..e4b964fd40d8 100644
--- a/drivers/mtd/nand/raw/marvell_nand.c
+++ b/drivers/mtd/nand/raw/marvell_nand.c
@@ -1074,7 +1074,7 @@ static int marvell_nfc_hw_ecc_hmg_do_write_page(struct nand_chip *chip,
 		return ret;
 
 	ret = marvell_nfc_wait_op(chip,
-				  chip->data_interface.timings.sdr.tPROG_max);
+				  PSEC_TO_MSEC(chip->data_interface.timings.sdr.tPROG_max));
 	return ret;
 }
 
@@ -1494,7 +1494,7 @@ static int marvell_nfc_hw_ecc_bch_write_page(struct mtd_info *mtd,
 	}
 
 	ret = marvell_nfc_wait_op(chip,
-				  chip->data_interface.timings.sdr.tPROG_max);
+				  PSEC_TO_MSEC(chip->data_interface.timings.sdr.tPROG_max));
 
 	marvell_nfc_disable_hw_ecc(chip);
 
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] mtd: rawnand: marvell: pass ms delay to wait_op
  2018-05-03  2:21 [PATCH] mtd: rawnand: marvell: pass ms delay to wait_op Chris Packham
@ 2018-05-03  5:28 ` Chris Packham
  2018-05-03  7:03   ` Boris Brezillon
  2018-05-03  7:05   ` Miquel Raynal
  2018-05-07  7:41 ` Boris Brezillon
  1 sibling, 2 replies; 6+ messages in thread
From: Chris Packham @ 2018-05-03  5:28 UTC (permalink / raw)
  To: miquel.raynal, boris.brezillon
  Cc: linux-mtd, stable, Richard Weinberger, David Woodhouse,
	Brian Norris, Marek Vasut, linux-kernel

On 03/05/18 14:21, Chris Packham wrote:
> marvell_nfc_wait_op() expects the delay to be expressed in milliseconds
> but nand_sdr_timings uses picoseconds. Use PSEC_TO_MSEC when passing
> tPROG_max to marvell_nfc_wait_op().
> 
> Fixes: 02f26ecf8c772 ("mtd: nand: add reworked Marvell NAND controller driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
>   drivers/mtd/nand/raw/marvell_nand.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
> index 1d779a35ac8e..e4b964fd40d8 100644
> --- a/drivers/mtd/nand/raw/marvell_nand.c
> +++ b/drivers/mtd/nand/raw/marvell_nand.c
> @@ -1074,7 +1074,7 @@ static int marvell_nfc_hw_ecc_hmg_do_write_page(struct nand_chip *chip,
>   		return ret;
>   
>   	ret = marvell_nfc_wait_op(chip,
> -				  chip->data_interface.timings.sdr.tPROG_max);
> +				  PSEC_TO_MSEC(chip->data_interface.timings.sdr.tPROG_max));
>   	return ret;
>   }
>   
> @@ -1494,7 +1494,7 @@ static int marvell_nfc_hw_ecc_bch_write_page(struct mtd_info *mtd,
>   	}
>   
>   	ret = marvell_nfc_wait_op(chip,
> -				  chip->data_interface.timings.sdr.tPROG_max);
> +				  PSEC_TO_MSEC(chip->data_interface.timings.sdr.tPROG_max));
>   
>   	marvell_nfc_disable_hw_ecc(chip);
>   

Actually I'm not so sure about this patch. While passing the pico-second 
value for tPROG_max is clearly wrong and leads to seemingly indefinite 
hangs on some systems. Converting the times to micro-seconds leaves us 
with delays that are far too short.

The old pxa3xx driver had hard coded 200ms delays. These delays now work 
out to 1ms which seems every bit as wrong as 600000000ms.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mtd: rawnand: marvell: pass ms delay to wait_op
  2018-05-03  5:28 ` Chris Packham
@ 2018-05-03  7:03   ` Boris Brezillon
  2018-05-03  8:01     ` Miquel Raynal
  2018-05-03  7:05   ` Miquel Raynal
  1 sibling, 1 reply; 6+ messages in thread
From: Boris Brezillon @ 2018-05-03  7:03 UTC (permalink / raw)
  To: Chris Packham
  Cc: miquel.raynal, Richard Weinberger, linux-kernel, stable,
	Marek Vasut, linux-mtd, Brian Norris, David Woodhouse

Hi Chris,

On Thu, 3 May 2018 05:28:32 +0000
Chris Packham <Chris.Packham@alliedtelesis.co.nz> wrote:

> On 03/05/18 14:21, Chris Packham wrote:
> > marvell_nfc_wait_op() expects the delay to be expressed in milliseconds
> > but nand_sdr_timings uses picoseconds. Use PSEC_TO_MSEC when passing
> > tPROG_max to marvell_nfc_wait_op().
> > 
> > Fixes: 02f26ecf8c772 ("mtd: nand: add reworked Marvell NAND controller driver")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> > ---
> >   drivers/mtd/nand/raw/marvell_nand.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
> > index 1d779a35ac8e..e4b964fd40d8 100644
> > --- a/drivers/mtd/nand/raw/marvell_nand.c
> > +++ b/drivers/mtd/nand/raw/marvell_nand.c
> > @@ -1074,7 +1074,7 @@ static int marvell_nfc_hw_ecc_hmg_do_write_page(struct nand_chip *chip,
> >   		return ret;
> >   
> >   	ret = marvell_nfc_wait_op(chip,
> > -				  chip->data_interface.timings.sdr.tPROG_max);
> > +				  PSEC_TO_MSEC(chip->data_interface.timings.sdr.tPROG_max));
> >   	return ret;
> >   }
> >   
> > @@ -1494,7 +1494,7 @@ static int marvell_nfc_hw_ecc_bch_write_page(struct mtd_info *mtd,
> >   	}
> >   
> >   	ret = marvell_nfc_wait_op(chip,
> > -				  chip->data_interface.timings.sdr.tPROG_max);
> > +				  PSEC_TO_MSEC(chip->data_interface.timings.sdr.tPROG_max));
> >   
> >   	marvell_nfc_disable_hw_ecc(chip);
> >     
> 
> Actually I'm not so sure about this patch. While passing the pico-second 
> value for tPROG_max is clearly wrong and leads to seemingly indefinite 
> hangs on some systems. Converting the times to micro-seconds leaves us 
> with delays that are far too short.

What makes you think they are far too short?

> 
> The old pxa3xx driver had hard coded 200ms delays. These delays now work 
> out to 1ms which seems every bit as wrong as 600000000ms.

The old driver was indifferently waiting a huge amount of time no
matter how long the chip is supposed to stay busy for a specific
operation. Here we're using the value exposed by the chip itself, and
it's not a typical value, it's a max value, which means you should
never reach that in real life, and if you do that means your chip is
stuck for some reasons. Now, if you want to take extra safety margin,
you can multiply the value by 2 and that should be enough, but 200ms is
way too long.

Regards,

Boris

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mtd: rawnand: marvell: pass ms delay to wait_op
  2018-05-03  5:28 ` Chris Packham
  2018-05-03  7:03   ` Boris Brezillon
@ 2018-05-03  7:05   ` Miquel Raynal
  1 sibling, 0 replies; 6+ messages in thread
From: Miquel Raynal @ 2018-05-03  7:05 UTC (permalink / raw)
  To: Chris Packham
  Cc: boris.brezillon, linux-mtd, stable, Richard Weinberger,
	David Woodhouse, Brian Norris, Marek Vasut, linux-kernel

Hi Chris,

On Thu, 3 May 2018 05:28:32 +0000, Chris Packham
<Chris.Packham@alliedtelesis.co.nz> wrote:

> On 03/05/18 14:21, Chris Packham wrote:
> > marvell_nfc_wait_op() expects the delay to be expressed in milliseconds
> > but nand_sdr_timings uses picoseconds. Use PSEC_TO_MSEC when passing
> > tPROG_max to marvell_nfc_wait_op().
> > 
> > Fixes: 02f26ecf8c772 ("mtd: nand: add reworked Marvell NAND controller driver")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> > ---
> >   drivers/mtd/nand/raw/marvell_nand.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
> > index 1d779a35ac8e..e4b964fd40d8 100644
> > --- a/drivers/mtd/nand/raw/marvell_nand.c
> > +++ b/drivers/mtd/nand/raw/marvell_nand.c
> > @@ -1074,7 +1074,7 @@ static int marvell_nfc_hw_ecc_hmg_do_write_page(struct nand_chip *chip,
> >   		return ret;
> >   
> >   	ret = marvell_nfc_wait_op(chip,
> > -				  chip->data_interface.timings.sdr.tPROG_max);
> > +				  PSEC_TO_MSEC(chip->data_interface.timings.sdr.tPROG_max));
> >   	return ret;
> >   }
> >   
> > @@ -1494,7 +1494,7 @@ static int marvell_nfc_hw_ecc_bch_write_page(struct mtd_info *mtd,
> >   	}
> >   
> >   	ret = marvell_nfc_wait_op(chip,
> > -				  chip->data_interface.timings.sdr.tPROG_max);
> > +				  PSEC_TO_MSEC(chip->data_interface.timings.sdr.tPROG_max));
> >   
> >   	marvell_nfc_disable_hw_ecc(chip);
> >     
> 
> Actually I'm not so sure about this patch. While passing the pico-second 
> value for tPROG_max is clearly wrong and leads to seemingly indefinite 
> hangs on some systems. Converting the times to micro-seconds leaves us 
> with delays that are far too short.

It is not micro but milli-seconds here.

> 
> The old pxa3xx driver had hard coded 200ms delays. These delays now work 
> out to 1ms which seems every bit as wrong as 600000000ms.

200ms is extremely long, I guess typical values are ~200-500us, so this
1ms timeout does not scare me :)

I'll let Boris conclude.

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks.

-- 
Miquel Raynal, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mtd: rawnand: marvell: pass ms delay to wait_op
  2018-05-03  7:03   ` Boris Brezillon
@ 2018-05-03  8:01     ` Miquel Raynal
  0 siblings, 0 replies; 6+ messages in thread
From: Miquel Raynal @ 2018-05-03  8:01 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Chris Packham, Richard Weinberger, linux-kernel, stable,
	Marek Vasut, linux-mtd, Brian Norris, David Woodhouse

Hi Boris, Chris,

> > > diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
> > > index 1d779a35ac8e..e4b964fd40d8 100644
> > > --- a/drivers/mtd/nand/raw/marvell_nand.c
> > > +++ b/drivers/mtd/nand/raw/marvell_nand.c
> > > @@ -1074,7 +1074,7 @@ static int marvell_nfc_hw_ecc_hmg_do_write_page(struct nand_chip *chip,
> > >   		return ret;
> > >   
> > >   	ret = marvell_nfc_wait_op(chip,
> > > -				  chip->data_interface.timings.sdr.tPROG_max);
> > > +				  PSEC_TO_MSEC(chip->data_interface.timings.sdr.tPROG_max));
> > >   	return ret;
> > >   }
> > >   
> > > @@ -1494,7 +1494,7 @@ static int marvell_nfc_hw_ecc_bch_write_page(struct mtd_info *mtd,
> > >   	}
> > >   
> > >   	ret = marvell_nfc_wait_op(chip,
> > > -				  chip->data_interface.timings.sdr.tPROG_max);
> > > +				  PSEC_TO_MSEC(chip->data_interface.timings.sdr.tPROG_max));
> > >   

[...]

> > The old pxa3xx driver had hard coded 200ms delays. These delays now work 
> > out to 1ms which seems every bit as wrong as 600000000ms.  

When the 'keep-config' property is populated, the
->setup_data_interface() hook of the driver is not shown to the core,
which leads to not "updating" the timings like tPROG_max.

While it worked with the old driver that hardcoded this delay, this
might not work anymore with the current driver because it expects
timings.sdr.tPROG_max to be != 0 (and PSEC_TO_MSEC(0) also returns 0).

This is probably something to fix.

Regards,
Miquèl

-- 
Miquel Raynal, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mtd: rawnand: marvell: pass ms delay to wait_op
  2018-05-03  2:21 [PATCH] mtd: rawnand: marvell: pass ms delay to wait_op Chris Packham
  2018-05-03  5:28 ` Chris Packham
@ 2018-05-07  7:41 ` Boris Brezillon
  1 sibling, 0 replies; 6+ messages in thread
From: Boris Brezillon @ 2018-05-07  7:41 UTC (permalink / raw)
  To: Chris Packham
  Cc: miquel.raynal, linux-mtd, stable, Richard Weinberger,
	David Woodhouse, Brian Norris, Marek Vasut, linux-kernel

On Thu,  3 May 2018 14:21:28 +1200
Chris Packham <chris.packham@alliedtelesis.co.nz> wrote:

> marvell_nfc_wait_op() expects the delay to be expressed in milliseconds
> but nand_sdr_timings uses picoseconds. Use PSEC_TO_MSEC when passing
> tPROG_max to marvell_nfc_wait_op().
> 
> Fixes: 02f26ecf8c772 ("mtd: nand: add reworked Marvell NAND controller driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>

Queued to mtd/fixes.

Thanks,

Boris

> ---
>  drivers/mtd/nand/raw/marvell_nand.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
> index 1d779a35ac8e..e4b964fd40d8 100644
> --- a/drivers/mtd/nand/raw/marvell_nand.c
> +++ b/drivers/mtd/nand/raw/marvell_nand.c
> @@ -1074,7 +1074,7 @@ static int marvell_nfc_hw_ecc_hmg_do_write_page(struct nand_chip *chip,
>  		return ret;
>  
>  	ret = marvell_nfc_wait_op(chip,
> -				  chip->data_interface.timings.sdr.tPROG_max);
> +				  PSEC_TO_MSEC(chip->data_interface.timings.sdr.tPROG_max));
>  	return ret;
>  }
>  
> @@ -1494,7 +1494,7 @@ static int marvell_nfc_hw_ecc_bch_write_page(struct mtd_info *mtd,
>  	}
>  
>  	ret = marvell_nfc_wait_op(chip,
> -				  chip->data_interface.timings.sdr.tPROG_max);
> +				  PSEC_TO_MSEC(chip->data_interface.timings.sdr.tPROG_max));
>  
>  	marvell_nfc_disable_hw_ecc(chip);
>  

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-05-07  7:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-03  2:21 [PATCH] mtd: rawnand: marvell: pass ms delay to wait_op Chris Packham
2018-05-03  5:28 ` Chris Packham
2018-05-03  7:03   ` Boris Brezillon
2018-05-03  8:01     ` Miquel Raynal
2018-05-03  7:05   ` Miquel Raynal
2018-05-07  7:41 ` Boris Brezillon

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.