Skip to contentSkip to conversation

blackfin arch: fix bug data cannot be put into L1 DATA SRAM bank B

PATCH In review Wu, Bryan 1 participant 1 message Apr 11, 2007

lore
Share & tools
lore

Wu, Bryan

author
#0 lore raw

PATCH 2/5 blackfin arch: fix bug data cannot be put into L1 DATA SRAM bank B

[PATCH] blackfin arch: fix bug data cannot be put into L1 DATA SRAM bank B

Don't allocate Bank B data sram in l1_data_A_sram_alloc (). Add l1_data_sram_alloc (), which allocates data sram from either Bank A or Bank B. Change all the code which call to l1_data_A_sram_alloc () to use l1_data_sram_alloc () if appropriate.
Likewise for l1_data_A_sram_free ().

---
 arch/blackfin/kernel/bfin_ksyms.c  |    2 +
 arch/blackfin/kernel/module.c      |    8 ++--
 arch/blackfin/kernel/setup.c       |   31 +++++++++++------
 arch/blackfin/mm/blackfin_sram.c   |   64 +++++++++++++++++++----------------
 include/asm-blackfin/bfin-global.h |    3 +-
 5 files changed, 63 insertions(+), 45 deletions(-)
arch/blackfin/kernel/bfin_ksyms.c +2 -0
index bcd21ee..f64ecb6 100644
@@ -115,3 +115,5 @@ EXPORT_SYMBOL(_ebss_l1);
 EXPORT_SYMBOL(_stext_l1);
 EXPORT_SYMBOL(_etext_l1);
 EXPORT_SYMBOL(_sdata_l1);
+EXPORT_SYMBOL(_ebss_b_l1);
+EXPORT_SYMBOL(_sdata_b_l1);
arch/blackfin/kernel/module.c +4 -4
index 2e753d5..372f756 100644
@@ -183,7 +183,7 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
 			((strcmp(".data", secstrings + s->sh_name)==0) &&
 			 (hdr->e_flags & FLG_DATA_IN_L1) && (s->sh_size > 0))) {
 			mod->arch.data_a_l1 = s;
-			dest = l1_data_A_sram_alloc(s->sh_size);
+			dest = l1_data_sram_alloc(s->sh_size);
 			if (dest == NULL) {
 				printk(KERN_ERR
 					"module %s: L1 data memory allocation failed\n",
@@ -198,7 +198,7 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
 			((strcmp(".bss", secstrings + s->sh_name)==0) &&
 			 (hdr->e_flags & FLG_DATA_IN_L1) && (s->sh_size > 0))) {
 			mod->arch.bss_a_l1 = s;
-			dest = l1_data_A_sram_alloc(s->sh_size);
+			dest = l1_data_sram_alloc(s->sh_size);
 			if (dest == NULL) {
 				printk(KERN_ERR
 					"module %s: L1 data memory allocation failed\n",
@@ -419,9 +419,9 @@ void module_arch_cleanup(struct module *mod)
 	if ((mod->arch.text_l1) && (mod->arch.text_l1->sh_addr))
 		l1_inst_sram_free((void*)mod->arch.text_l1->sh_addr);
 	if ((mod->arch.data_a_l1) && (mod->arch.data_a_l1->sh_addr))
-		l1_data_A_sram_free((void*)mod->arch.data_a_l1->sh_addr);
+		l1_data_sram_free((void*)mod->arch.data_a_l1->sh_addr);
 	if ((mod->arch.bss_a_l1) && (mod->arch.bss_a_l1->sh_addr))
-		l1_data_A_sram_free((void*)mod->arch.bss_a_l1->sh_addr);
+		l1_data_sram_free((void*)mod->arch.bss_a_l1->sh_addr);
 	if ((mod->arch.data_b_l1) && (mod->arch.data_b_l1->sh_addr))
 		l1_data_B_sram_free((void*)mod->arch.data_b_l1->sh_addr);
 	if ((mod->arch.bss_b_l1) && (mod->arch.bss_b_l1->sh_addr))
arch/blackfin/kernel/setup.c +20 -11
index 7d24229..9e0c3fa 100644
@@ -90,25 +90,34 @@ void __init bf53x_cache_init(void)
 
 void bf53x_relocate_l1_mem(void)
 {
-	unsigned long l1_length;
+	unsigned long l1_code_length;
+	unsigned long l1_data_a_length;
+	unsigned long l1_data_b_length;
 
-	l1_length = _etext_l1 - _stext_l1;
-	if (l1_length > L1_CODE_LENGTH)
-		l1_length = L1_CODE_LENGTH;
+	l1_code_length = _etext_l1 - _stext_l1;
+	if (l1_code_length > L1_CODE_LENGTH)
+		l1_code_length = L1_CODE_LENGTH;
 	/* cannot complain as printk is not available as yet.
 	 * But we can continue booting and complain later!
 	 */
 
 	/* Copy _stext_l1 to _etext_l1 to L1 instruction SRAM */
-	dma_memcpy(_stext_l1, _l1_lma_start, l1_length);
+	dma_memcpy(_stext_l1, _l1_lma_start, l1_code_length);
 
-	l1_length = _ebss_l1 - _sdata_l1;
-	if (l1_length > L1_DATA_A_LENGTH)
-		l1_length = L1_DATA_A_LENGTH;
+	l1_data_a_length = _ebss_l1 - _sdata_l1;
+	if (l1_data_a_length > L1_DATA_A_LENGTH)
+		l1_data_a_length = L1_DATA_A_LENGTH;
+
+	/* Copy _sdata_l1 to _ebss_l1 to L1 data bank A SRAM */
+	dma_memcpy(_sdata_l1, _l1_lma_start + l1_code_length, l1_data_a_length);
+
+	l1_data_b_length = _ebss_b_l1 - _sdata_b_l1;
+	if (l1_data_b_length > L1_DATA_B_LENGTH)
+		l1_data_b_length = L1_DATA_B_LENGTH;
 
-	/* Copy _sdata_l1 to _ebss_l1 to L1 instruction SRAM */
-	dma_memcpy(_sdata_l1, _l1_lma_start + (_etext_l1 - _stext_l1),
-		   l1_length);
+	/* Copy _sdata_b_l1 to _ebss_b_l1 to L1 data bank B SRAM */
+	dma_memcpy(_sdata_b_l1, _l1_lma_start + l1_code_length +
+			l1_data_a_length, l1_data_b_length);
 
 }
 
arch/blackfin/mm/blackfin_sram.c +35 -29

90 lines not on this page · raw message

include/asm-blackfin/bfin-global.h +2 -1
index 5e4db3a..e37f816 100644
@@ -70,6 +70,7 @@ extern void bfin_gpio_interrupt_setup(int irq, int irq_pfx, int type);
 extern void *l1_data_A_sram_alloc(size_t);
 extern void *l1_data_B_sram_alloc(size_t);
 extern void *l1_inst_sram_alloc(size_t);
+extern void *l1_data_sram_alloc(size_t);
 extern void *l1_data_sram_zalloc(size_t);
 extern int l1_data_A_sram_free(const void*);
 extern int l1_data_B_sram_free(const void*);
@@ -108,7 +109,7 @@ extern char _start;
 extern unsigned long _ramstart, _ramend, _rambase;
 extern unsigned long memory_start, memory_end, physical_mem_end;
 extern char _stext_l1[], _etext_l1[], _sdata_l1[], _edata_l1[], _sbss_l1[],
-    _ebss_l1[], _l1_lma_start[];
+    _ebss_l1[], _l1_lma_start[], _sdata_b_l1[], _ebss_b_l1[];
 
 #ifdef CONFIG_MTD_UCLINUX
 extern unsigned long memory_mtd_start, memory_mtd_end, mtd_size;
Signature · 1 line
1.5.0.5