All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] Possible bug in NAND driver
@ 2009-07-13 19:34 Paulraj, Sandeep
  2009-07-14  9:03 ` Valeriy Glushkov
  2009-07-16 17:46 ` [U-Boot] Possible bug in NAND driver Scott Wood
  0 siblings, 2 replies; 6+ messages in thread
From: Paulraj, Sandeep @ 2009-07-13 19:34 UTC (permalink / raw)
  To: u-boot


If we refer to the following code snippet from nand_util.c

rval = nand_read (nand, offset, &read_length, p_buffer);

                if (rval != 0) {

                          printf ("NAND read from offset %llx failed %d\n",

                                  offset, rval);

                         *length -= left_to_read;

                          return rval;

                  }


The above code will return failure even after ECC errors are corrected.

This is because of the following line of code in nand_base.c

return  mtd->ecc_stats.corrected - stats.corrected ? -EUCLEAN : 0;

This is in the nand_do_read_ops in nand_bsae.c


I see that changing

if (rval != 0)


to

if (rval != 0 && rval != -EUCLEAN )


solves the problem.

I can submit a patch if required.


Thanks,
Sandeep

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

* [U-Boot] Possible bug in NAND driver
  2009-07-13 19:34 [U-Boot] Possible bug in NAND driver Paulraj, Sandeep
@ 2009-07-14  9:03 ` Valeriy Glushkov
  2009-07-14 10:51   ` [U-Boot] [PATCH] nand: fixed failed reads on corrected ECC errors in nand_util.c Valeriy Glushkov
  2009-07-16 17:46 ` [U-Boot] Possible bug in NAND driver Scott Wood
  1 sibling, 1 reply; 6+ messages in thread
From: Valeriy Glushkov @ 2009-07-14  9:03 UTC (permalink / raw)
  To: u-boot

You are right, this is a bug.

I've already fixed it in our code tree some monthes ago but forgotten to 
send the patch to the list.

Best regards,
Valeriy Glushkov

----- Original Message ----- 
From: "Paulraj, Sandeep" <s-paulraj@ti.com>
To: <u-boot@lists.denx.de>
Sent: 13 ???? 2009 ?. 22:34
Subject: [U-Boot] Possible bug in NAND driver


>
> If we refer to the following code snippet from nand_util.c
>
> rval = nand_read (nand, offset, &read_length, p_buffer);
>
>                if (rval != 0) {
>
>                          printf ("NAND read from offset %llx failed %d\n",
>
>                                  offset, rval);
>
>                         *length -= left_to_read;
>
>                          return rval;
>
>                  }
>
>
> The above code will return failure even after ECC errors are corrected.
>
> This is because of the following line of code in nand_base.c
>
> return  mtd->ecc_stats.corrected - stats.corrected ? -EUCLEAN : 0;
>
> This is in the nand_do_read_ops in nand_bsae.c
>
>
> I see that changing
>
> if (rval != 0)
>
>
> to
>
> if (rval != 0 && rval != -EUCLEAN )
>
>
> solves the problem.
>
> I can submit a patch if required.
>
>
> Thanks,
> Sandeep
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot 

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

* [U-Boot] [PATCH] nand: fixed failed reads on corrected ECC errors in nand_util.c
@ 2009-07-14 10:51   ` Valeriy Glushkov
  2009-07-16 19:50     ` Scott Wood
  0 siblings, 1 reply; 6+ messages in thread
From: Valeriy Glushkov @ 2009-07-14 10:51 UTC (permalink / raw)
  To: u-boot


Signed-off-by: Valeriy Glushkov <gvv@lstec.com>
Signed-off-by: Paulraj, Sandeep <s-paulraj@ti.com>
---
 drivers/mtd/nand/nand_util.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/nand/nand_util.c b/drivers/mtd/nand/nand_util.c
index fc16282..694ead6 100644
--- a/drivers/mtd/nand/nand_util.c
+++ b/drivers/mtd/nand/nand_util.c
@@ -567,10 +567,10 @@ int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
 
 	if (len_incl_bad == *length) {
 		rval = nand_read (nand, offset, length, buffer);
-		if (rval != 0)
-			printf ("NAND read from offset %llx failed %d\n",
-				offset, rval);
-
+		if (!rval || rval == -EUCLEAN)
+			return 0;
+		printf ("NAND read from offset %llx failed %d\n",
+			offset, rval);
 		return rval;
 	}
 
@@ -591,7 +591,7 @@ int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
 			read_length = nand->erasesize - block_offset;
 
 		rval = nand_read (nand, offset, &read_length, p_buffer);
-		if (rval != 0) {
+		if (rval && rval != -EUCLEAN) {
 			printf ("NAND read from offset %llx failed %d\n",
 				offset, rval);
 			*length -= left_to_read;
-- 
1.5.2.5

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

* [U-Boot] Possible bug in NAND driver
  2009-07-13 19:34 [U-Boot] Possible bug in NAND driver Paulraj, Sandeep
  2009-07-14  9:03 ` Valeriy Glushkov
@ 2009-07-16 17:46 ` Scott Wood
  1 sibling, 0 replies; 6+ messages in thread
From: Scott Wood @ 2009-07-16 17:46 UTC (permalink / raw)
  To: u-boot

On Mon, Jul 13, 2009 at 02:34:42PM -0500, Paulraj, Sandeep wrote:
> I see that changing
> 
> if (rval != 0)
> 
> 
> to
> 
> if (rval != 0 && rval != -EUCLEAN )
> 
> 
> solves the problem.
> 
> I can submit a patch if required.

Yes, please submit a patch.  Thanks!

-Scott

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

* [U-Boot] [PATCH] nand: fixed failed reads on corrected ECC errors in nand_util.c
  2009-07-14 10:51   ` [U-Boot] [PATCH] nand: fixed failed reads on corrected ECC errors in nand_util.c Valeriy Glushkov
@ 2009-07-16 19:50     ` Scott Wood
  2009-07-17  8:11       ` Valeriy Glushkov
  0 siblings, 1 reply; 6+ messages in thread
From: Scott Wood @ 2009-07-16 19:50 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 14, 2009 at 01:51:10PM +0300, Valeriy Glushkov wrote:
> 
> Signed-off-by: Valeriy Glushkov <gvv@lstec.com>
> Signed-off-by: Paulraj, Sandeep <s-paulraj@ti.com>
> ---

Applied to u-boot-nand-flash.

>  drivers/mtd/nand/nand_util.c |   10 +++++-----
>  1 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_util.c b/drivers/mtd/nand/nand_util.c
> index fc16282..694ead6 100644
> --- a/drivers/mtd/nand/nand_util.c
> +++ b/drivers/mtd/nand/nand_util.c
> @@ -567,10 +567,10 @@ int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
>  
>  	if (len_incl_bad == *length) {
>  		rval = nand_read (nand, offset, length, buffer);
> -		if (rval != 0)
> -			printf ("NAND read from offset %llx failed %d\n",
> -				offset, rval);
> -
> +		if (!rval || rval == -EUCLEAN)
> +			return 0;
> +		printf ("NAND read from offset %llx failed %d\n",
> +			offset, rval);

Out of curiosity, why invert the logic from if (error) print; return to if
(!error) return; print; return?

-Scott

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

* [U-Boot] [PATCH] nand: fixed failed reads on corrected ECC errors in nand_util.c
  2009-07-16 19:50     ` Scott Wood
@ 2009-07-17  8:11       ` Valeriy Glushkov
  0 siblings, 0 replies; 6+ messages in thread
From: Valeriy Glushkov @ 2009-07-17  8:11 UTC (permalink / raw)
  To: u-boot

Hi Scott,
>>  if (len_incl_bad == *length) {
>>  rval = nand_read (nand, offset, length, buffer);
>> - if (rval != 0)
>> - printf ("NAND read from offset %llx failed %d\n",
>> - offset, rval);
>> -
>> + if (!rval || rval == -EUCLEAN)
>> + return 0;
>> + printf ("NAND read from offset %llx failed %d\n",
>> + offset, rval);
> 
> Out of curiosity, why invert the logic from if (error) print; return to if
> (!error) return; print; return?

Because it looks a bit better for me than 2 other versions.
And saves a line. :)
-------
if (!rval || rval == -EUCLEAN)
  return 0;
printf ("NAND read from offset %llx failed %d\n",
  offset, rval);
return rval;
--------
if (rval && rval != -EUCLEAN) {
 printf ("NAND read from offset %llx failed %d\n",
  offset, rval);
 return rval;
}
return 0;
-------

if (rval && rval != -EUCLEAN)
 printf ("NAND read from offset %llx failed %d\n",
  offset, rval);
else
  rval = 0;
return rval;
--------

Best regards,
Valeriy Glushkov

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

end of thread, other threads:[~2009-07-17  8:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-13 19:34 [U-Boot] Possible bug in NAND driver Paulraj, Sandeep
2009-07-14  9:03 ` Valeriy Glushkov
2009-07-14 10:51   ` [U-Boot] [PATCH] nand: fixed failed reads on corrected ECC errors in nand_util.c Valeriy Glushkov
2009-07-16 19:50     ` Scott Wood
2009-07-17  8:11       ` Valeriy Glushkov
2009-07-16 17:46 ` [U-Boot] Possible bug in NAND driver Scott Wood

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.