Skip to contentSkip to conversation

MPC83xx platform memory access performance improved

PATCH New Liu Dave-r63238 3 participants 4 messages May 30, 2006 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MPC83xx platform memory access performance improved

Hi Wolfwang,

Here is one patch which can make DMA performance improved 6x, memory write access performance improved 2.5x. and fixed some bugs.

The change is:

1. Bus pipeline
Set the CSB bus pipeline depth as 4, which makes 4 outstanding transcation on CSB bus.

2. Memory write
When ECC enable, CPU write with 64bit. It makes DDR bus more effective.

3. DMA performance
DMA transfer with cache line burst read and burst write.

4. ECC test
I fixed some bugs in ECC test code, and enhanced the test code.

5. Platform clean up and bug fixed
I clean up the start.S file, and change the comments which comes from 826x and 74xx.

The write performance is:
ECC on
write duration: 646 ms

ECC off
write duration: 646 ms

DMA ECC on
DDR init duration: 1338 ms

DMA ECC off
DDR init duration: 968 ms

Best Regards,
Dave

==========

board/mpc8349emds/mpc8349emds.c +76 -25
diff -Naur u-boot/board/mpc8349emds/mpc8349emds.c u-boot-new/board/mpc8349emds/mpc8349emds.c
@@ -235,7 +235,7 @@
 #else
 void sdram_init(void)
 {
-	put("SDRAM on Local Bus is NOT available!\n");
+	puts("SDRAM on Local Bus is NOT available!\n");
 }
 #endif
 
@@ -323,14 +323,24 @@
 	volatile immap_t *immap = (immap_t *)CFG_IMMRBAR;
 	volatile ddr8349_t *ddr = &immap->ddr;
 	volatile u32 val;
-	u64 *addr, count, val64;
+	u64 *addr;
+	u32 count;
 	register u64 *i;
+	u32 ret[2];
+	u32 pattern[2];
+	u32 writeback[2];
+
+	pattern[0] = 0xfedcba98UL;
+	pattern[1] = 0x76543210UL;
+
+	writeback[0] = 0x01234567UL;
+	writeback[1] = 0x89abcdefUL;
 
 	if (argc > 4) {
 		printf ("Usage:\n%s\n", cmdtp->usage);
 		return 1;
 	}
-
+	
 	if (argc == 2) {
 		if (strcmp(argv[1], "status") == 0) {
 			ecc_print_status();
@@ -343,8 +353,8 @@
 			ddr->capture_attributes = 0;
 			return 0;
 		}
-	}
-
+	} 
+	
 	if (argc == 3) {
 		if (strcmp(argv[1], "sbecnt") == 0) {
 			val = simple_strtoul(argv[2], NULL, 10);
@@ -380,8 +390,8 @@
 			} else if (strcmp(argv[2], "+mse") == 0) {
 				val |= ECC_ERROR_DISABLE_MSED;
 			} else if (strcmp(argv[2], "+all") == 0) {
-				val |= (ECC_ERROR_DISABLE_SBED |
-					ECC_ERROR_DISABLE_MBED |
+				val |= (ECC_ERROR_DISABLE_SBED | 
+					ECC_ERROR_DISABLE_MBED | 
 					ECC_ERROR_DISABLE_MSED);
 			} else if (strcmp(argv[2], "-sbe") == 0) {
 				val &= ~ECC_ERROR_DISABLE_SBED;
@@ -390,8 +400,8 @@
 			} else if (strcmp(argv[2], "-mse") == 0) {
 				val &= ~ECC_ERROR_DISABLE_MSED;
 			} else if (strcmp(argv[2], "-all") == 0) {
-				val &= ~(ECC_ERROR_DISABLE_SBED |
-					ECC_ERROR_DISABLE_MBED |
+				val &= ~(ECC_ERROR_DISABLE_SBED | 
+					ECC_ERROR_DISABLE_MBED | 
 					ECC_ERROR_DISABLE_MSED);
 			} else {
 				printf("Incorrect err_disable field\n");
@@ -475,7 +485,7 @@
 	}
 
 	if (argc == 4) {
-		if (strcmp(argv[1], "test") == 0) {
+		if (strcmp(argv[1], "testdw") == 0) {
 			addr = (u64 *)simple_strtoul(argv[2], NULL, 16);
 			count = simple_strtoul(argv[3], NULL, 16);
 
@@ -485,16 +495,16 @@
 			}
 
 			disable_interrupts();
-			icache_disable();
 
 			for (i = addr; i < addr + count; i++) {
+
 				/* enable injects */
 				ddr->ecc_err_inject |= ECC_ERR_INJECT_EIEN;
 				__asm__ __volatile__ ("sync");
 				__asm__ __volatile__ ("isync");
 
 				/* write memory location injecting errors */
-				*i = 0x1122334455667788ULL;
+				ppcDWstore((u32*)i, pattern);
 				__asm__ __volatile__ ("sync");
 
 				/* disable injects */
@@ -503,30 +513,65 @@
 				__asm__ __volatile__ ("isync");
 
 				/* read data, this generates ECC error */
-				val64 = *i;
+				ppcDWload((u32*)i, ret);
 				__asm__ __volatile__ ("sync");
 
-				/* disable errors for ECC */
-				ddr->err_disable |= ~ECC_ERROR_ENABLE;
+				/* re-initialize memory, double word write the location again,
+				 * generates new ECC code this time */
+				ppcDWstore((u32*)i, writeback);
+				__asm__ __volatile__ ("sync");
+
+			}
+			
+			enable_interrupts();
+
+			return 0;
+		}
+
+		if (strcmp(argv[1], "testword") == 0) {
+			addr = (u64 *)simple_strtoul(argv[2], NULL, 16);
+			count = simple_strtoul(argv[3], NULL, 16);
+
+			if ((u32)addr % 8) {
+				printf("Address not alligned on double word boundary\n");
+				return 1;
+			}
+
+			disable_interrupts();
+
+			for (i = addr; i < addr + count; i++) {
+
+				/* enable injects */
+				ddr->ecc_err_inject |= ECC_ERR_INJECT_EIEN;
 				__asm__ __volatile__ ("sync");
 				__asm__ __volatile__ ("isync");
 
-				/* re-initialize memory, write the location again
-				 * NOT injecting errors this time */
-				*i = 0xcafecafecafecafeULL;
+				/* write memory location injecting errors */
+				*(u32*)i = 0xfedcba98UL;
+				__asm__ __volatile__ ("sync");
+
+				/* sub double word write, bus will read-modify-write, generates ECC error */
+				*((u32*)i+1) = 0x76543210UL;
 				__asm__ __volatile__ ("sync");
 
-				/* enable errors for ECC */
-				ddr->err_disable &= ECC_ERROR_ENABLE;
+				/* disable injects */
+				ddr->ecc_err_inject &= ~ECC_ERR_INJECT_EIEN;
 				__asm__ __volatile__ ("sync");
 				__asm__ __volatile__ ("isync");
-			}
 
-			icache_enable();
+				/* re-initialize memory, double word write the location again,
+				 * generates new ECC code this time */
+				ppcDWstore((u32*)i, writeback);
+				__asm__ __volatile__ ("sync");
+
+			}
+			
 			enable_interrupts();
 
 			return 0;
 		}
+
+
 	}
 
 	printf ("Usage:\n%s\n", cmdtp->usage);
@@ -556,11 +601,17 @@
 	"ecc injectecc <ecc>    - set ECC Error Injection Mask\n"
 	"ecc inject <en|dis>    - enable/disable error injection\n"
 	"ecc mirror <en|dis>    - enable/disable mirror byte\n"
-	"ecc test <addr> <cnt>  - test mem region:\n"
+	"ecc testdw <addr> <cnt>  - test mem region with double word access:\n"
+	"  - enables injects\n"
+	"  - writes pattern injecting errors with double word access\n"
+	"  - disables injects\n"
+	"  - reads pattern back with double word access, generates error\n"
+	"  - re-inits memory\n"
+	"ecc testword <addr> <cnt>  - test mem region with word access:\n"
 	"  - enables injects\n"
-	"  - writes pattern injecting errors\n"
+	"  - writes pattern injecting errors with word access\n"
+	"  - writes pattern with word access, generates error\n"
 	"  - disables injects\n"
-	"  - reads pattern back, generates error\n"
 	"  - re-inits memory"
 );
 #endif /* if defined(CONFIG_DDR_ECC) && defined(CONFIG_DDR_ECC_CMD) */
cpu/mpc83xx/cpu.c +1 -4
diff -Naur u-boot/cpu/mpc83xx/cpu.c u-boot-new/cpu/mpc83xx/cpu.c
@@ -257,10 +257,7 @@
 	__asm__ __volatile__ ("isync");
 
 	/* init direct transfer, clear CS bit */
-	dmamr0 = (DMA_CHANNEL_TRANSFER_MODE_DIRECT |
-			DMA_CHANNEL_SOURCE_ADDRESS_HOLD_8B |
-			DMA_CHANNEL_SOURCE_ADRESSS_HOLD_EN);
-
+	dmamr0 = DMA_CHANNEL_TRANSFER_MODE_DIRECT;
 	dma->dmamr0 = swab32(dmamr0);
 
 	__asm__ __volatile__ ("sync");
cpu/mpc83xx/cpu_init.c +3 -0
diff -Naur u-boot/cpu/mpc83xx/cpu_init.c u-boot-new/cpu/mpc83xx/cpu_init.c
@@ -56,6 +56,9 @@
 	 */
 	im->reset.rmr = (RMR_CSRE & (1<<RMR_CSRE_SHIFT));
 
+	/* Set the CSB bus pipeline depth as 4 */
+	im->arbiter.acr |= ACR_PIPE_DEP_4; 
+
 	/* LCRR - Clock Ratio Register (10.3.1.16) */
 	im->lbus.lcrr = CFG_LCRR;
 
cpu/mpc83xx/spd_sdram.c +20 -30

74 lines not on this page · raw message

cpu/mpc83xx/speed.c +1 -1
diff -Naur u-boot/cpu/mpc83xx/speed.c u-boot-new/cpu/mpc83xx/speed.c
@@ -333,7 +333,7 @@
 	gd->pci_clk    = pci_sync_in;
 
 	gd->cpu_clk = gd->core_clk;
-	gd->bus_clk = gd->lbiu_clk;
+	gd->bus_clk = gd->csb_clk;
 	return 0;
 }
 
cpu/mpc83xx/start.S +51 -45

200 lines not on this page · raw message

include/asm-ppc/immap_83xx.h +4 -0
diff -Naur u-boot/include/asm-ppc/immap_83xx.h u-boot-new/include/asm-ppc/immap_83xx.h
@@ -371,6 +371,10 @@
 	u32 acr; /* Arbiter Configuration Register */
 #define ACR_COREDIS    0x10000000 /* Core disable. */
 #define ACR_PIPE_DEP   0x00070000 /* Pipeline depth (number of outstanding transactions). */
+#define ACR_PIPE_DEP_1 0x00000000 /* Pipeline depth 1 */
+#define ACR_PIPE_DEP_2 0x00010000 /* Pipeline depth 2 */
+#define ACR_PIPE_DEP_3 0x00020000 /* Pipeline depth 3 */
+#define ACR_PIPE_DEP_4 0x00030000 /* Pipeline depth 4 */
 #define ACR_PCI_RPTCNT 0x00007000 /* PCI repeat count. */
 #define ACR_RPTCNT     0x00000700 /* Repeat count. */
 #define ACR_APARK      0x00000030 /* Address parking. */
include/common.h +5 -0
diff -Naur u-boot/include/common.h u-boot-new/include/common.h
@@ -383,6 +383,11 @@
 void		ppcDcbz(unsigned long value);
 #endif
 
+#if defined (CONFIG_MPC83XX)
+void		ppcDWload(unsigned int *addr, unsigned int *ret);
+void		ppcDWstore(unsigned int *addr, unsigned int *value);
+#endif
+
 /* $(CPU)/cpu.c */
 int	checkcpu      (void);
 int	checkicache   (void);
Makefile +0 -3
diff -Naur u-boot/Makefile u-boot-new/Makefile
@@ -1326,9 +1326,6 @@
 ## MPC83xx Systems
 #########################################################################
 
-MPC8349ADS_config:	unconfig
-	@./mkconfig $(@:_config=) ppc mpc83xx mpc8349ads
-
 TQM834x_config:	unconfig
 	@./mkconfig $(@:_config=) ppc mpc83xx tqm834x
 
#1 lore raw

PATCH 1/1 MPC83xx platform memory access performance improved

Quoted 7 lines · On May 30, 2006, at 12:06 AM, Liu Dave-r63238 wrote:

Hi Wolfwang,

Here is one patch which can make DMA performance improved 6x, memory write access performance improved 2.5x. and fixed some bugs.

The change is:

Quoted 7 lines

1. Bus pipeline
Set the CSB bus pipeline depth as 4, which makes 4 outstanding transcation on CSB bus.

2. Memory write
When ECC enable, CPU write with 64bit. It makes DDR bus more effective.

we need to be careful with this since not all 83xx have the ability to do 64bit writes (832x doesn't have FP)

Quoted 9 lines

3. DMA performance
DMA transfer with cache line burst read and burst write.

4. ECC test
I fixed some bugs in ECC test code, and enhanced the test code.

5. Platform clean up and bug fixed
I clean up the start.S file, and change the comments which comes from 826x and 74xx.

[snip]

#2 lore raw

PATCH 1/1 MPC83xx platform memory access performance improved

Quoted 7 lines · In message <[email protected]> you wrote:
Quoted 4 lines

2. Memory write
When ECC enable, CPU write with 64bit. It makes DDR bus more effective.

we need to be careful with this since not all 83xx have the ability to do 64bit writes (832x doesn't have FP)

Also, what will happen on a 32 bit wide bus? [This was the szenario in our case - a 32 bit wide memory interface.]

Best regards,

Wolfgang Denk

Signature · 4 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The Wright Bothers weren't the first to fly. They were just the first
not to crash.
#3 lore raw

PATCH 1/1 MPC83xx platform memory access performance improved

Quoted 7 lines · Wolfgang Denk

In message <DA6718F1-0DE0-4FF2-8080-

Quoted 5 lines · B3C732CC89F4 at kernel.crashing.org> you wrote:
Quoted 4 lines

2. Memory write
When ECC enable, CPU write with 64bit. It makes DDR bus more effective.

Quoted 5 lines
Quoted 2 lines

we need to be careful with this since not all 83xx have the ability to do 64bit writes (832x doesn't have FP)

Also, what will happen on a 32 bit wide bus? [This was the szenario in our case - a 32 bit wide memory interface.]

I would hope the system does the right thing in this case. (Otherwise all FP code would be broken :)

- k