* NAND ECC Error with wrong SMC ording bug
@ 2009-09-22 21:20 Sean MacLennan
2009-09-23 5:12 ` Stefan Roese
0 siblings, 1 reply; 4+ messages in thread
From: Sean MacLennan @ 2009-09-22 21:20 UTC (permalink / raw)
To: linuxppc-dev
What is the status of this bug?
Cheers,
Sean
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3 v3] powerpc/32: Always order writes to halves of 64-bit PTEs
@ 2009-08-17 23:00 Paul Mackerras
2009-08-18 4:24 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 4+ messages in thread
From: Paul Mackerras @ 2009-08-17 23:00 UTC (permalink / raw)
To: linuxppc-dev
On 32-bit systems with 64-bit PTEs, the PTEs have to be written in two
32-bit halves. On SMP we write the higher-order half and then the
lower-order half, with a write barrier between the two halves, but on
UP there was no particular ordering of the writes to the two halves.
This extends the ordering that we already do on SMP to the UP case as
well. The reason is that with the perf_counter subsystem potentially
accessing user memory at interrupt time to get stack traces, we have
to be careful not to create an incorrect but apparently valid PTE even
on UP.
Signed-off-by: Paul Mackerras <paulus@samba.org>
---
arch/powerpc/include/asm/pgtable.h | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
index eb17da7..2a5da06 100644
--- a/arch/powerpc/include/asm/pgtable.h
+++ b/arch/powerpc/include/asm/pgtable.h
@@ -104,8 +104,8 @@ static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr,
else
pte_update(ptep, ~_PAGE_HASHPTE, pte_val(pte));
-#elif defined(CONFIG_PPC32) && defined(CONFIG_PTE_64BIT) && defined(CONFIG_SMP)
- /* Second case is 32-bit with 64-bit PTE in SMP mode. In this case, we
+#elif defined(CONFIG_PPC32) && defined(CONFIG_PTE_64BIT)
+ /* Second case is 32-bit with 64-bit PTE. In this case, we
* can just store as long as we do the two halves in the right order
* with a barrier in between. This is possible because we take care,
* in the hash code, to pre-invalidate if the PTE was already hashed,
@@ -140,7 +140,7 @@ static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr,
#else
/* Anything else just stores the PTE normally. That covers all 64-bit
- * cases, and 32-bit non-hash with 64-bit PTEs in UP mode
+ * cases, and 32-bit non-hash with 32-bit PTEs.
*/
*ptep = pte;
#endif
--
1.6.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3 v3] powerpc/32: Always order writes to halves of 64-bit PTEs
2009-08-17 23:00 [PATCH 1/3 v3] powerpc/32: Always order writes to halves of 64-bit PTEs Paul Mackerras
@ 2009-08-18 4:24 ` Benjamin Herrenschmidt
2009-08-19 23:16 ` NAND ECC Error with wrong SMC ording bug Feng Kan
0 siblings, 1 reply; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2009-08-18 4:24 UTC (permalink / raw)
To: Paul Mackerras; +Cc: linuxppc-dev
On Tue, 2009-08-18 at 09:00 +1000, Paul Mackerras wrote:
> On 32-bit systems with 64-bit PTEs, the PTEs have to be written in two
> 32-bit halves. On SMP we write the higher-order half and then the
> lower-order half, with a write barrier between the two halves, but on
> UP there was no particular ordering of the writes to the two halves.
>
> This extends the ordering that we already do on SMP to the UP case as
> well. The reason is that with the perf_counter subsystem potentially
> accessing user memory at interrupt time to get stack traces, we have
> to be careful not to create an incorrect but apparently valid PTE even
> on UP.
>
> Signed-off-by: Paul Mackerras <paulus@samba.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
> ---
> arch/powerpc/include/asm/pgtable.h | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
> index eb17da7..2a5da06 100644
> --- a/arch/powerpc/include/asm/pgtable.h
> +++ b/arch/powerpc/include/asm/pgtable.h
> @@ -104,8 +104,8 @@ static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr,
> else
> pte_update(ptep, ~_PAGE_HASHPTE, pte_val(pte));
>
> -#elif defined(CONFIG_PPC32) && defined(CONFIG_PTE_64BIT) && defined(CONFIG_SMP)
> - /* Second case is 32-bit with 64-bit PTE in SMP mode. In this case, we
> +#elif defined(CONFIG_PPC32) && defined(CONFIG_PTE_64BIT)
> + /* Second case is 32-bit with 64-bit PTE. In this case, we
> * can just store as long as we do the two halves in the right order
> * with a barrier in between. This is possible because we take care,
> * in the hash code, to pre-invalidate if the PTE was already hashed,
> @@ -140,7 +140,7 @@ static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr,
>
> #else
> /* Anything else just stores the PTE normally. That covers all 64-bit
> - * cases, and 32-bit non-hash with 64-bit PTEs in UP mode
> + * cases, and 32-bit non-hash with 32-bit PTEs.
> */
> *ptep = pte;
> #endif
^ permalink raw reply [flat|nested] 4+ messages in thread
* NAND ECC Error with wrong SMC ording bug
2009-08-18 4:24 ` Benjamin Herrenschmidt
@ 2009-08-19 23:16 ` Feng Kan
2009-08-20 4:38 ` Sean MacLennan
0 siblings, 1 reply; 4+ messages in thread
From: Feng Kan @ 2009-08-19 23:16 UTC (permalink / raw)
To: linuxppc-dev; +Cc: u-boot, linux-mtd
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: NAND ECC Error with wrong SMC ording bug
2009-08-19 23:16 ` NAND ECC Error with wrong SMC ording bug Feng Kan
@ 2009-08-20 4:38 ` Sean MacLennan
0 siblings, 0 replies; 4+ messages in thread
From: Sean MacLennan @ 2009-08-20 4:38 UTC (permalink / raw)
To: Feng Kan; +Cc: linuxppc-dev, linux-mtd, u-boot
On Wed, 19 Aug 2009 16:16:54 -0700
Feng Kan <fkan@amcc.com> wrote:
> 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.
Odds are the calculate function is wrong. The correction algo is used
by many nand drivers, I *assume* it is correct. The calculate function
was set to agree with u-boot (1.3.0).
Cheers,
Sean
P.S. Yes, I know the u-boot is an ancient version :(
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-09-23 5:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-22 21:20 NAND ECC Error with wrong SMC ording bug Sean MacLennan
2009-09-23 5:12 ` Stefan Roese
-- strict thread matches above, loose matches on Subject: below --
2009-08-17 23:00 [PATCH 1/3 v3] powerpc/32: Always order writes to halves of 64-bit PTEs Paul Mackerras
2009-08-18 4:24 ` Benjamin Herrenschmidt
2009-08-19 23:16 ` NAND ECC Error with wrong SMC ording bug Feng Kan
2009-08-20 4:38 ` Sean MacLennan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).