Skip to contentSkip to conversation

enabling ecc on P2041 and QoreIQ familly not valid for memory >= 4GB

U-Boot Benoit Sansoni 2 participants 8 messages Jul 18, 2014 – Sep 22, 2014

lore
Share & tools
lore
#0 lore raw

Hi ,

I found out an issue when enabling ECC for P2041 platform with an amount of memory of 8GB.
The routine "void dma_meminit(uint val, uint size)" is not adapted to manage memory size greater or equal to 4GB due to the 'uint' type. With this typing the dma_meminit sees 0 as size when memory is for example at 8GB. So the ECC part of the memory is not initialized and when going in memory the code crash.
To correct it you need to use phys_size_t type instead of uint. It is the same thing for all routines that are called by "dma_meminit". I attached a patch that able to correct it easily.
This patch should be integrated in the main branch I think so.

Regards,
Benoit

u-boot-2012.10/arch/powerpc/include/asm/fsl_ddr_sdram.h renamed from u-boot-2012.10/arch/powerpc/include/asm/fsl_ddr_sdram.h:1.1.1.1 +1 -1
diff -u vx3240/u-boot-2012.10/arch/powerpc/include/asm/fsl_ddr_sdram.h:1.1.1.1 vx3240/u-boot-2012.10/arch/powerpc/include/asm/fsl_ddr_sdram.h:1.2
@@ -308,7 +308,7 @@
  #endif
  
  #if defined(CONFIG_DDR_ECC)
-extern void ddr_enable_ecc(unsigned int dram_size);
+extern void ddr_enable_ecc(phys_size_t dram_size);
  #endif
  
u-boot-2012.10/arch/powerpc/include/asm/fsl_dma.h renamed from u-boot-2012.10/arch/powerpc/include/asm/fsl_dma.h:1.1.1.1 +1 -1
diff -u vx3240/u-boot-2012.10/arch/powerpc/include/asm/fsl_dma.h:1.1.1.1 vx3240/u-boot-2012.10/arch/powerpc/include/asm/fsl_dma.h:1.2
@@ -134,7 +134,7 @@
  void dma_init(void);
  int dmacpy(phys_addr_t dest, phys_addr_t src, phys_size_t n);
  #if (defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER))
-void dma_meminit(uint val, uint size);
+void dma_meminit(uint val, phys_size_t size);
  #endif
  #endif
  
u-boot-2012.10/drivers/dma/fsl_dma.c renamed from u-boot-2012.10/drivers/dma/fsl_dma.c:1.1.1.1 +32 -30

79 lines not on this page · raw message

#1 lore raw
Quoted 14 lines · Benoit Sansoni

Hi ,

I found out an issue when enabling ECC for P2041 platform with an amount of memory of 8GB.
The routine "void dma_meminit(uint val, uint size)" is not adapted to manage memory size greater or equal to 4GB due to the 'uint' type. With this typing the dma_meminit sees 0 as size when memory is for example at 8GB. So the ECC part of the memory is not initialized and when going in memory the code crash.
To correct it you need to use phys_size_t type instead of uint. It is the same thing for all routines that are called by "dma_meminit". I attached a patch that able to correct it easily.
This patch should be integrated in the main branch I think so.

Quoted 3 lines

Regards,
Benoit

This is a valid concern. Some code started when we had far less memory. We need to comb through the code to fix more of them.

York

#2 lore raw

Hi York,

That what I saw in the code.

Also to test it you need to have the hardware, but the evaluation board P2041rdb for example does not have some ECC signals rooted for DIMM slot. I validated the patch that I sent on a board based on P2041 with 8GB of memory. Obviously it works with 2GB and 4GB.

If you need help, you are welcome.

Thanks for your help
Benoit

Quoted 24 lines · York Sun
Quoted 14 lines · Benoit Sansoni

Hi ,

I found out an issue when enabling ECC for P2041 platform with an amount of memory of 8GB.
The routine "void dma_meminit(uint val, uint size)" is not adapted to manage memory size greater or equal to 4GB due to the 'uint' type. With this typing the dma_meminit sees 0 as size when memory is for example at 8GB. So the ECC part of the memory is not initialized and when going in memory the code crash.
To correct it you need to use phys_size_t type instead of uint. It is the same thing for all routines that are called by "dma_meminit". I attached a patch that able to correct it easily.
This patch should be integrated in the main branch I think so.

Quoted 3 lines

Regards,
Benoit

This is a valid concern. Some code started when we had far less memory. We need to comb through the code to fix more of them.

York

Signature · 6 lines
Benoit SANSONI
Kontron Modular Computers S.A.S
150 rue Marcelin Berthelot - ZI Toulon Est - BP 244
83078 TOULON Cedex 9 - FRANCE
E-mail: benoit.sansoni at kontron.com
TEL: +33 (0)4 98 16 33 68
#3 lore raw

Benoit,

If your interest is in initializing DDR for ECC, you don't have use dma_meminit(). There is a better and faster way to do so. All Freescale modern DDR controllers support this feature. All you have to do is to define these macros

CONFIG_DDR_ECC
CONFIG_ECC_INIT_VIA_DDRCONTROLLER
CONFIG_MEM_INIT_VALUE

There are plenty of example for you to follow.

But again, we should fix the DMA function anyway.

York

Quoted 41 lines · Benoit Sansoni

Hi York,

That what I saw in the code.

Also to test it you need to have the hardware, but the evaluation board P2041rdb for example does not have some ECC signals rooted for DIMM slot. I validated the patch that I sent on a board based on P2041 with 8GB of memory. Obviously it works with 2GB and 4GB.

If you need help, you are welcome.

Thanks for your help
Benoit

Quoted 24 lines · York Sun
Quoted 14 lines · Benoit Sansoni

Hi ,

I found out an issue when enabling ECC for P2041 platform with an amount of memory of 8GB.
The routine "void dma_meminit(uint val, uint size)" is not adapted to manage memory size greater or equal to 4GB due to the 'uint' type. With this typing the dma_meminit sees 0 as size when memory is for example at 8GB. So the ECC part of the memory is not initialized and when going in memory the code crash.
To correct it you need to use phys_size_t type instead of uint. It is the same thing for all routines that are called by "dma_meminit". I attached a patch that able to correct it easily.
This patch should be integrated in the main branch I think so.

Quoted 3 lines

Regards,
Benoit

This is a valid concern. Some code started when we had far less memory. We need to comb through the code to fix more of them.

York

#4 lore raw

York,

I am going to check out the method that you talk about. For now the fix allow me to boot our board with 8GB it is a good step for me.

Thanks
Benoit

Quoted 60 lines · York Sun

Benoit,

If your interest is in initializing DDR for ECC, you don't have use dma_meminit(). There is a better and faster way to do so. All Freescale modern DDR controllers support this feature. All you have to do is to define these macros

CONFIG_DDR_ECC
CONFIG_ECC_INIT_VIA_DDRCONTROLLER
CONFIG_MEM_INIT_VALUE

There are plenty of example for you to follow.

But again, we should fix the DMA function anyway.

York

Quoted 9 lines · Benoit Sansoni

Hi York,

That what I saw in the code.

Also to test it you need to have the hardware, but the evaluation board P2041rdb for example does not have some ECC signals rooted for DIMM slot. I validated the patch that I sent on a board based on P2041 with 8GB of memory. Obviously it works with 2GB and 4GB.

Quoted 31 lines

If you need help, you are welcome.

Thanks for your help
Benoit

Quoted 24 lines · York Sun
Quoted 14 lines · Benoit Sansoni

Hi ,

I found out an issue when enabling ECC for P2041 platform with an amount of memory of 8GB.
The routine "void dma_meminit(uint val, uint size)" is not adapted to manage memory size greater or equal to 4GB due to the 'uint' type. With this typing the dma_meminit sees 0 as size when memory is for example at 8GB. So the ECC part of the memory is not initialized and when going in memory the code crash.
To correct it you need to use phys_size_t type instead of uint. It is the same thing for all routines that are called by "dma_meminit". I attached a patch that able to correct it easily.
This patch should be integrated in the main branch I think so.

Quoted 3 lines

Regards,
Benoit

This is a valid concern. Some code started when we had far less memory. We need to comb through the code to fix more of them.

York

.

Signature · 6 lines
Benoit SANSONI
Kontron Modular Computers S.A.S
150 rue Marcelin Berthelot - ZI Toulon Est - BP 244
83078 TOULON Cedex 9 - FRANCE
E-mail: benoit.sansoni at kontron.com
TEL: +33 (0)4 98 16 33 68
#5 lore raw
Quoted 24 lines · Benoit Sansoni

York,

I am going to check out the method that you talk about. For now the fix allow me to boot our board with 8GB it is a good step for me.

Thanks
Benoit

Quoted 14 lines · York Sun

Benoit,

If your interest is in initializing DDR for ECC, you don't have use dma_meminit(). There is a better and faster way to do so. All Freescale modern DDR controllers support this feature. All you have to do is to define these macros

CONFIG_DDR_ECC
CONFIG_ECC_INIT_VIA_DDRCONTROLLER
CONFIG_MEM_INIT_VALUE

There are plenty of example for you to follow.

But again, we should fix the DMA function anyway.

Benoit,

Have you tried my suggestion?

York

#6 lore raw

Hi York,

Sorry for the delay. I was in holidays. I am back at work today. Yes I have tried the other method that you proposed.
It works perfectly and It seems that this method initialized the ECC in a faster manner.

I faced a stability issue during ddr initialization. To resolve it I deactivate the autocalibration as recommended in the erratum num A-003474. So for me the u-boot release that I am currently using is u-boot-2012.10 and in the file u-boot-2012.10/arch/powerpc/cpu/mpc85xx/ddr-gen3.c I modified it
depending my ddr ram timing :

     out_be32(&ddr->timing_cfg_3, regs->timing_cfg_3);
     out_be32(&ddr->timing_cfg_0, regs->timing_cfg_0);
     out_be32(&ddr->timing_cfg_1, regs->timing_cfg_1);
     /*dataT = fsl_dbg_timing();*/
     dataT = 0x9;
     out_be32(&ddr->timing_cfg_2, (regs->timing_cfg_2 & 0xf07fffff) | 
(dataT<<23));
     out_be32(&ddr->sdram_mode, regs->ddr_sdram_mode);
     out_be32(&ddr->sdram_mode_2, regs->ddr_sdram_mode_2);
     out_be32(&ddr->sdram_mode_3, regs->ddr_sdram_mode_3);
     out_be32(&ddr->sdram_mode_4, regs->ddr_sdram_mode_4);
     out_be32(&ddr->sdram_mode_5, regs->ddr_sdram_mode_5);
     out_be32(&ddr->sdram_mode_6, regs->ddr_sdram_mode_6);
     out_be32(&ddr->sdram_mode_7, regs->ddr_sdram_mode_7);
     out_be32(&ddr->sdram_mode_8, regs->ddr_sdram_mode_8);
     out_be32(&ddr->sdram_md_cntl, regs->ddr_sdram_md_cntl);
     out_be32(&ddr->sdram_interval, regs->ddr_sdram_interval);
     out_be32(&ddr->sdram_data_init, regs->ddr_data_init);
     out_be32(&ddr->sdram_clk_cntl, regs->ddr_sdram_clk_cntl);
     out_be32(&ddr->init_addr, regs->ddr_init_addr);
     out_be32(&ddr->init_ext_addr, regs->ddr_init_ext_addr);

So for me the timing_cfg_2 must be set at a deterministic value to avoid stability issue when the CONFIG_SYS_FSL_ERRATUM_DDR_A003474 flag is set.

Many thanks
Benoit

Quoted 33 lines · York Sun
Quoted 24 lines · Benoit Sansoni

York,

I am going to check out the method that you talk about. For now the fix allow me to boot our board with 8GB it is a good step for me.

Thanks
Benoit

Quoted 14 lines · York Sun

Benoit,

If your interest is in initializing DDR for ECC, you don't have use dma_meminit(). There is a better and faster way to do so. All Freescale modern DDR controllers support this feature. All you have to do is to define these macros

CONFIG_DDR_ECC
CONFIG_ECC_INIT_VIA_DDRCONTROLLER
CONFIG_MEM_INIT_VALUE

There are plenty of example for you to follow.

But again, we should fix the DMA function anyway.

Benoit,

Have you tried my suggestion?

York

Signature · 6 lines
Benoit SANSONI
Software Engineer
Kontron
150 rue Marcelin Berthelot | BP 244 - ZI Toulon-Est | 83078 Toulon Cedex 9 | France
P: +33 (0)4 98 16 33 68
benoit.sansoni at kontron.com
#7 lore raw

Benoit,

Since you should and you have used the suggested method to initialize ECC, I am going to close this patch as N/A. I will find some time to clean up the size variable.

I will follow up with you on the other thread regarding dcache issue.

York

Quoted 79 lines · Benoit Sansoni

Hi York,

Sorry for the delay. I was in holidays. I am back at work today. Yes I have tried the other method that you proposed.
It works perfectly and It seems that this method initialized the ECC in a faster manner.

I faced a stability issue during ddr initialization. To resolve it I deactivate the autocalibration as recommended in the erratum num A-003474. So for me the u-boot release that I am currently using is u-boot-2012.10 and in the file u-boot-2012.10/arch/powerpc/cpu/mpc85xx/ddr-gen3.c I modified it
depending my ddr ram timing :

     out_be32(&ddr->timing_cfg_3, regs->timing_cfg_3);
     out_be32(&ddr->timing_cfg_0, regs->timing_cfg_0);
     out_be32(&ddr->timing_cfg_1, regs->timing_cfg_1);
     /*dataT = fsl_dbg_timing();*/
     dataT = 0x9;
     out_be32(&ddr->timing_cfg_2, (regs->timing_cfg_2 & 0xf07fffff) | 
(dataT<<23));
     out_be32(&ddr->sdram_mode, regs->ddr_sdram_mode);
     out_be32(&ddr->sdram_mode_2, regs->ddr_sdram_mode_2);
     out_be32(&ddr->sdram_mode_3, regs->ddr_sdram_mode_3);
     out_be32(&ddr->sdram_mode_4, regs->ddr_sdram_mode_4);
     out_be32(&ddr->sdram_mode_5, regs->ddr_sdram_mode_5);
     out_be32(&ddr->sdram_mode_6, regs->ddr_sdram_mode_6);
     out_be32(&ddr->sdram_mode_7, regs->ddr_sdram_mode_7);
     out_be32(&ddr->sdram_mode_8, regs->ddr_sdram_mode_8);
     out_be32(&ddr->sdram_md_cntl, regs->ddr_sdram_md_cntl);
     out_be32(&ddr->sdram_interval, regs->ddr_sdram_interval);
     out_be32(&ddr->sdram_data_init, regs->ddr_data_init);
     out_be32(&ddr->sdram_clk_cntl, regs->ddr_sdram_clk_cntl);
     out_be32(&ddr->init_addr, regs->ddr_init_addr);
     out_be32(&ddr->init_ext_addr, regs->ddr_init_ext_addr);

So for me the timing_cfg_2 must be set at a deterministic value to avoid stability issue when the CONFIG_SYS_FSL_ERRATUM_DDR_A003474 flag is set.

Many thanks
Benoit

Quoted 33 lines · York Sun
Quoted 24 lines · Benoit Sansoni

York,

I am going to check out the method that you talk about. For now the fix allow me to boot our board with 8GB it is a good step for me.

Thanks
Benoit

Quoted 14 lines · York Sun

Benoit,

If your interest is in initializing DDR for ECC, you don't have use dma_meminit(). There is a better and faster way to do so. All Freescale modern DDR controllers support this feature. All you have to do is to define these macros

CONFIG_DDR_ECC
CONFIG_ECC_INIT_VIA_DDRCONTROLLER
CONFIG_MEM_INIT_VALUE

There are plenty of example for you to follow.

But again, we should fix the DMA function anyway.

Benoit,

Have you tried my suggestion?

York