All of lore.kernel.org
 help / color / mirror / Atom feed
From: Feng Kan <fkan@amcc.com>
To: linuxppc-dev@ozlabs.org
Cc: u-boot@lists.denx.de, linux-mtd@lists.infradead.org
Subject: NAND  ECC Error with wrong SMC ording bug
Date: Wed, 19 Aug 2009 16:16:54 -0700	[thread overview]
Message-ID: <4A8C87E6.6070702@amcc.com> (raw)
In-Reply-To: <1250569482.19007.23.camel@pasglop>

Hi All:

It seems that the ECC correction is broken on the Linux with the 4xx 
NDFC driver.
It uses the SMC order when reading the ECC code. 2-1-3

static int ndfc_calculate_ecc(struct mtd_info *mtd,
                               const u_char *dat, u_char *ecc_code)
{
         struct ndfc_controller *ndfc = &ndfc_ctrl;
         uint32_t ecc;
         uint8_t *p = (uint8_t *)&ecc;

         wmb();
         ecc = in_be32(ndfc->ndfcbase + NDFC_ECC);
         /* The NDFC uses Smart Media (SMC) bytes order */
         ecc_code[0] = p[2];
         ecc_code[1] = p[1];
         ecc_code[2] = p[3];

         return 0;
}

However, when in the correction function, the byte address order is 
again reverses
causing incorrect byte location.

                  * performace it does not make any difference
                  */
                 if (eccsize_mult == 1)
                         byte_addr = (addressbits[b0] << 4) + 
addressbits[b1];
 >>>> The above really should be byte_addr = (addressbits[b1] << 4) + 
addressbits[b0];

                 else
                         byte_addr = (addressbits[b2 & 0x3] << 8) +
                                     (addressbits[b1] << 4) + 
addressbits[b0];
                 bit_addr = addressbits[b2 >> 2];
                 /* flip the bit */
                 buf[byte_addr] ^= (1 << bit_addr);
                 printk(KERN_INFO "Corrected b[0] 0x%x b[1]0x%x\n", b0, b1);
                 printk(KERN_INFO "cal ecc b[0] 0x%x b[1]0x%x\n", 
calc_ecc[0] , calc_ecc[1]);
                 printk(KERN_INFO "read ecc b[0] 0x%x b[1]0x%x\n", 
read_ecc[0] , read_ecc[1]);
                 return 1;

I see other boards using SMC as well, can someone comment on the change 
I am proposing.
Should I change the correction algorithm or the calculate function? If 
the later is preferred
it would mean the change must be pushed in both U-Boot and Linux.

Feng Kan
AMCC Software

WARNING: multiple messages have this Message-ID (diff)
From: Feng Kan <fkan@amcc.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] NAND  ECC Error with wrong SMC ording bug
Date: Wed, 19 Aug 2009 16:16:54 -0700	[thread overview]
Message-ID: <4A8C87E6.6070702@amcc.com> (raw)
In-Reply-To: <1250569482.19007.23.camel@pasglop>

Hi All:

It seems that the ECC correction is broken on the Linux with the 4xx 
NDFC driver.
It uses the SMC order when reading the ECC code. 2-1-3

static int ndfc_calculate_ecc(struct mtd_info *mtd,
                               const u_char *dat, u_char *ecc_code)
{
         struct ndfc_controller *ndfc = &ndfc_ctrl;
         uint32_t ecc;
         uint8_t *p = (uint8_t *)&ecc;

         wmb();
         ecc = in_be32(ndfc->ndfcbase + NDFC_ECC);
         /* The NDFC uses Smart Media (SMC) bytes order */
         ecc_code[0] = p[2];
         ecc_code[1] = p[1];
         ecc_code[2] = p[3];

         return 0;
}

However, when in the correction function, the byte address order is 
again reverses
causing incorrect byte location.

                  * performace it does not make any difference
                  */
                 if (eccsize_mult == 1)
                         byte_addr = (addressbits[b0] << 4) + 
addressbits[b1];
 >>>> The above really should be byte_addr = (addressbits[b1] << 4) + 
addressbits[b0];

                 else
                         byte_addr = (addressbits[b2 & 0x3] << 8) +
                                     (addressbits[b1] << 4) + 
addressbits[b0];
                 bit_addr = addressbits[b2 >> 2];
                 /* flip the bit */
                 buf[byte_addr] ^= (1 << bit_addr);
                 printk(KERN_INFO "Corrected b[0] 0x%x b[1]0x%x\n", b0, b1);
                 printk(KERN_INFO "cal ecc b[0] 0x%x b[1]0x%x\n", 
calc_ecc[0] , calc_ecc[1]);
                 printk(KERN_INFO "read ecc b[0] 0x%x b[1]0x%x\n", 
read_ecc[0] , read_ecc[1]);
                 return 1;

I see other boards using SMC as well, can someone comment on the change 
I am proposing.
Should I change the correction algorithm or the calculate function? If 
the later is preferred
it would mean the change must be pushed in both U-Boot and Linux.

Feng Kan
AMCC Software

  reply	other threads:[~2009-08-19 23:17 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-17 23:00 [PATCH 1/3 v3] powerpc/32: Always order writes to halves of 64-bit PTEs Paul Mackerras
2009-08-17 23:00 ` [PATCH 2/3 v3] powerpc: Allow perf_counters to access user memory at interrupt time Paul Mackerras
2009-08-18  4:24   ` Benjamin Herrenschmidt
2009-08-17 23:01 ` [PATCH 3/3 v3] perf_counter: powerpc: Add callchain support Paul Mackerras
2009-08-18  4:23   ` Benjamin Herrenschmidt
2009-08-18  0:00 ` [PATCH 1/3 v3] powerpc/32: Always order writes to halves of 64-bit PTEs Kumar Gala
2009-08-18  0:14   ` Paul Mackerras
2009-08-18  4:24 ` Benjamin Herrenschmidt
2009-08-19 23:16   ` Feng Kan [this message]
2009-08-19 23:16     ` [U-Boot] NAND ECC Error with wrong SMC ording bug Feng Kan
2009-08-20  4:38     ` Sean MacLennan
2009-08-20  4:38       ` [U-Boot] " Sean MacLennan
2009-08-20  5:01       ` Stefan Roese
2009-08-20  5:01         ` Stefan Roese
2009-08-20 19:36         ` Sean MacLennan
2009-08-20 19:36           ` Sean MacLennan
2009-08-20 22:56           ` Victor Gallardo
2009-08-20 22:56             ` Victor Gallardo
2009-08-20 22:56             ` Victor Gallardo
2009-08-21  5:17           ` vimal singh
2009-08-21  5:17             ` vimal singh
2009-08-21  5:17             ` vimal singh
2009-08-21  6:26             ` Sean MacLennan
2009-08-21  6:26               ` Sean MacLennan
2009-08-21  6:27             ` Stefan Roese
2009-08-21  6:27               ` Stefan Roese
2009-08-21  6:30             ` Victor Gallardo
2009-08-21  6:30               ` Victor Gallardo
2009-08-21  6:30               ` Victor Gallardo
2009-08-20 23:42         ` Feng Kan
2009-08-20 23:42           ` Feng Kan
2009-08-21  7:59           ` Stefan Roese
2009-08-21  7:59             ` Stefan Roese
  -- strict thread matches above, loose matches on Subject: below --
2009-09-22 21:20 Sean MacLennan
2009-09-23  5:12 ` Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A8C87E6.6070702@amcc.com \
    --to=fkan@amcc.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.