CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always defined
Subsystems (9)
PATCH v3 1/1 CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always defined
Since commit 86cf1c82850f ("configs: Migrate CONFIG_NR_DRAM_BANKS") & commit 999a772d9f24 ("Kconfig: Migrate CONFIG_NR_DRAM_BANKS"), CONFIG_NR_DRAM_BANKS is always defined with a value (4 is default). It makes no sense to still carry code that is guarded with "#ifndef CONFIG_NR_DRAM_BANKS" (and similar). This patch removes all these unreferenced code paths.
Also complete remove bi_memstart & bi_memsize from the board-info struct. As now bi_dram[] is always enabled and should be used instead. This removes the redundant varriables.
---
v3:
- Rebase on TOT
- Add check to not overwrite bi_dram[0] if already configured in setup_bdinfo(). This fixes the test issue with Nokia RX51.
Azure test report success:
https://dev.azure.com/sr0718/u-boot/_build/results?buildId=26&view=results
v2:
- Change all references to bi_memstart & bi_memsize to bi_dram[0].start/ size and remove it from the bd_info struct completely, as suggested by Daniel
api/api_platform-mips.c | 4 ++-- api/api_platform-powerpc.c | 2 +- arch/mips/lib/boot.c | 2 +- arch/mips/lib/bootm.c | 2 +- arch/powerpc/cpu/mpc83xx/fdt.c | 2 +- arch/powerpc/cpu/mpc83xx/traps.c | 2 +- arch/powerpc/cpu/mpc85xx/fdt.c | 4 ++-- arch/powerpc/cpu/mpc85xx/traps.c | 2 +- arch/powerpc/cpu/mpc86xx/fdt.c | 2 +- arch/powerpc/cpu/mpc86xx/traps.c | 2 +- arch/powerpc/cpu/mpc8xx/fdt.c | 2 +- arch/powerpc/lib/bootm.c | 4 ++-- arch/x86/cpu/broadwell/cpu_from_spl.c | 2 -- arch/xtensa/lib/bdinfo.c | 4 ++-- arch/xtensa/lib/bootm.c | 4 ++-- board/Arcturus/ucp1020/spl.c | 4 ++-- board/freescale/p1010rdb/spl.c | 4 ++-- board/freescale/p1_p2_rdb_pc/spl.c | 4 ++-- board/freescale/t102xrdb/spl.c | 4 ++-- board/freescale/t104xrdb/spl.c | 4 ++-- board/freescale/t208xqds/spl.c | 4 ++-- board/freescale/t208xrdb/spl.c | 4 ++-- board/freescale/t4rdb/spl.c | 4 ++-- board/xilinx/zynqmp/zynqmp.c | 2 -- cmd/bdinfo.c | 6 ++--- cmd/bedbug.c | 2 +- common/board_f.c | 13 +++++------ common/image.c | 10 +------- common/init/handoff.c | 33 +++++++++++---------------- drivers/pci/pci-uclass.c | 17 +------------- drivers/video/cfb_console.c | 8 +------ include/asm-generic/u-boot.h | 4 ---- include/handoff.h | 2 -- lib/fdtdec.c | 5 ---- lib/lmb.c | 7 ------ 35 files changed, 60 insertions(+), 121 deletions(-)
api/api_platform-mips.c +2 -2
@@ -24,8 +24,8 @@ DECLARE_GLOBAL_DATA_PTR;int platform_sys_info (struct sys_info *si) { -platform_set_mr (si, gd->bd->bi_memstart, - gd->bd->bi_memsize,MR_ATTR_DRAM ); +platform_set_mr (si, gd->bd->bi_dram[0 ].start, + gd->bd->bi_dram[0 ].size,MR_ATTR_DRAM );return 1 ; }
api/api_platform-powerpc.c +1 -1
@@ -42,7 +42,7 @@ int platform_sys_info(struct sys_info *si) si->bar =0 ;#endif -platform_set_mr (si, gd->bd->bi_memstart, gd->bd->bi_memsize,MR_ATTR_DRAM ); +platform_set_mr (si, gd->bd->bi_dram[0 ].start, gd->bd->bi_dram[0 ].size,MR_ATTR_DRAM );platform_set_mr (si, gd->bd->bi_flashstart, gd->bd->bi_flashsize,MR_ATTR_FLASH );platform_set_mr (si, gd->bd->bi_sramstart, gd->bd->bi_sramsize,MR_ATTR_SRAM );
arch/mips/lib/boot.c +1 -1
@@ -17,7 +17,7 @@ unsigned long do_go_exec(ulong (*entry)(int, char * const []),* whole SDRAM area, since we don't know the size of the image * that was loaded. */ -flush_cache (gd->bd->bi_memstart, gd->ram_top - gd->bd->bi_memstart); +flush_cache (gd->bd->bi_dram[0 ].start, gd->ram_top - gd->bd->bi_dram[0 ].start);return entry (argc, argv); }
arch/mips/lib/bootm.c +1 -1
@@ -242,7 +242,7 @@ static int boot_reloc_fdt(bootm_headers_t *images)#if CONFIG_IS_ENABLED (MIPS_BOOT_FDT ) &&CONFIG_IS_ENABLED (OF_LIBFDT )int arch_fixup_fdt (void *blob) { -u64 mem_start =virt_to_phys ((void *)gd->bd->bi_memstart); +u64 mem_start =virt_to_phys ((void *)gd->bd->bi_dram[0 ].start);u64 mem_size = gd->ram_size;return fdt_fixup_memory_banks (blob, &mem_start, &mem_size,1 );
arch/powerpc/cpu/mpc83xx/fdt.c +1 -1
@@ -121,7 +121,7 @@ void ft_cpu_setup(void *blob, struct bd_info *bd) "clock-frequency", get_serial_clock(), 1);#endif -fdt_fixup_memory (blob, (u64 )bd->bi_memstart, (u64 )bd->bi_memsize); +fdt_fixup_memory (blob, (u64 )bd->bi_dram[0 ].start, (u64 )bd->bi_dram[0 ].size);#if defined(CONFIG_BOOTCOUNT_LIMIT ) && \ (defined(CONFIG_QE ) && !defined(CONFIG_ARCH_MPC831X ))
arch/powerpc/cpu/mpc83xx/traps.c +1 -1
@@ -23,7 +23,7 @@ DECLARE_GLOBAL_DATA_PTR;/* Returns 0 if exception not found and fixup otherwise. */ extern unsigned long search_exception_table (unsigned long ); -#define END_OF_MEM (gd->bd->bi_memstart + gd->bd->bi_memsize) +#define END_OF_MEM (gd->bd->bi_dram[0].start + gd->bd->bi_dram[0].size)/* * Trap & Exception support
arch/powerpc/cpu/mpc85xx/fdt.c +2 -2
@@ -672,10 +672,10 @@ void ft_cpu_setup(void *blob, struct bd_info *bd) "clock-frequency", get_bus_freq(0), 1);#endif -fdt_fixup_memory (blob, (u64 )bd->bi_memstart, (u64 )bd->bi_memsize); +fdt_fixup_memory (blob, (u64 )bd->bi_dram[0 ].start, (u64 )bd->bi_dram[0 ].size);#ifdef CONFIG_MP -ft_fixup_cpu (blob, (u64 )bd->bi_memstart + (u64 )bd->bi_memsize); +ft_fixup_cpu (blob, (u64 )bd->bi_dram[0 ].start + (u64 )bd->bi_dram[0 ].size);ft_fixup_num_cores (blob);#endif
arch/powerpc/cpu/mpc85xx/traps.c +1 -1
@@ -37,7 +37,7 @@ extern unsigned long search_exception_table(unsigned long);* amount of memory on the system if we're unable to keep all * the memory mapped in. */ -#define END_OF_MEM (gd->bd->bi_memstart + get_effective_memsize()) +#define END_OF_MEM (gd->bd->bi_dram[0].start + get_effective_memsize())static __inline__void set_tsr (unsigned long val) {
arch/powerpc/cpu/mpc86xx/fdt.c +1 -1
@@ -27,7 +27,7 @@ void ft_cpu_setup(void *blob, struct bd_info *bd)do_fixup_by_prop_u32 (blob,"device_type" ,"soc" ,4 ,"bus-frequency" , bd->bi_busfreq,1 ); -fdt_fixup_memory (blob, (u64 )bd->bi_memstart, (u64 )bd->bi_memsize); +fdt_fixup_memory (blob, (u64 )bd->bi_dram[0 ].start, (u64 )bd->bi_dram[0 ].size);#ifdef CONFIG_SYS_NS16550 do_fixup_by_compat_u32(blob, "ns16550",
arch/powerpc/cpu/mpc86xx/traps.c +1 -1
@@ -30,7 +30,7 @@ extern unsigned long search_exception_table(unsigned long);* amount of memory on the system if we're unable to keep all * the memory mapped in. */ -#define END_OF_MEM (gd->bd->bi_memstart + get_effective_memsize()) +#define END_OF_MEM (gd->bd->bi_dram[0].start + get_effective_memsize())/* * Trap & Exception support
arch/powerpc/cpu/mpc8xx/fdt.c +1 -1
@@ -25,5 +25,5 @@ void ft_cpu_setup(void *blob, struct bd_info *bd)do_fixup_by_compat_u32 (blob,"fsl,cpm-brg" ,"clock-frequency" , gd->arch.brg_clk,1 ); -fdt_fixup_memory (blob, (u64 )bd->bi_memstart, (u64 )bd->bi_memsize); +fdt_fixup_memory (blob, (u64 )bd->bi_dram[0 ].start, (u64 )bd->bi_dram[0 ].size); }
arch/powerpc/lib/bootm.c +2 -2
@@ -298,8 +298,8 @@ void boot_prep_vxworks(bootm_headers_t *images)if (!images->ft_addr)return ; - base = (u64 )gd->bd->bi_memstart; - size = (u64 )gd->bd->bi_memsize; + base = (u64 )gd->bd->bi_dram[0 ].start; + size = (u64 )gd->bd->bi_dram[0 ].size; off =fdt_path_offset (images->ft_addr,"/memory" );if (off <0 )
arch/x86/cpu/broadwell/cpu_from_spl.c +0 -2
@@ -53,14 +53,12 @@ void board_debug_uart_init(void)int dram_init_banksize (void ) { -#ifdef CONFIG_NR_DRAM_BANKS struct spl_handoff *ho; ho =bloblist_find (BLOBLISTT_SPL_HANDOFF ,sizeof (*ho));if (!ho)return log_msg_ret ("Missing SPL hand-off info" , -ENOENT );handoff_load_dram_banks (ho); -#endif return 0 ; }
arch/xtensa/lib/bdinfo.c +2 -2
@@ -15,8 +15,8 @@ int arch_setup_bdinfo(void) {struct bd_info *bd = gd->bd; - bd->bi_memstart =PHYSADDR (CONFIG_SYS_SDRAM_BASE ); - bd->bi_memsize =CONFIG_SYS_SDRAM_SIZE ; + bd->bi_dram[0 ].start =PHYSADDR (CONFIG_SYS_SDRAM_BASE ); + bd->bi_dram[0 ].size =CONFIG_SYS_SDRAM_SIZE ;return 0 ; }
arch/xtensa/lib/bootm.c +2 -2
@@ -48,8 +48,8 @@ static struct bp_tag *setup_memory_tag(struct bp_tag *params) params->size =sizeof (struct meminfo ); mem = (struct meminfo *)params->data; mem->type =MEMORY_TYPE_CONVENTIONAL ; - mem->start = bd->bi_memstart; - mem->end = bd->bi_memstart + bd->bi_memsize; + mem->start = bd->bi_dram[0 ].start; + mem->end = bd->bi_dram[0 ].start + bd->bi_dram[0 ].size;printf (" MEMORY: tag:0x%04x, type:0X%lx, start:0X%lx, end:0X%lx\n" ,BP_TAG_MEMORY , mem->type, mem->start, mem->end);
board/Arcturus/ucp1020/spl.c +2 -2
@@ -83,8 +83,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(CONFIG_SPL_GD_ADDR +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L2_ADDR ; - bd->bi_memsize =CONFIG_SYS_L2_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L2_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L2_SIZE ;arch_cpu_init ();get_clocks ();
board/freescale/p1010rdb/spl.c +2 -2
@@ -69,8 +69,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(CONFIG_SPL_GD_ADDR +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L2_ADDR ; - bd->bi_memsize =CONFIG_SYS_L2_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L2_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L2_SIZE ;arch_cpu_init ();get_clocks ();
board/freescale/p1_p2_rdb_pc/spl.c +2 -2
@@ -75,8 +75,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(CONFIG_SPL_GD_ADDR +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L2_ADDR ; - bd->bi_memsize =CONFIG_SYS_L2_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L2_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L2_SIZE ;arch_cpu_init ();get_clocks ();
board/freescale/t102xrdb/spl.c +2 -2
@@ -103,8 +103,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(gd +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L3_ADDR ; - bd->bi_memsize =CONFIG_SYS_L3_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L3_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L3_SIZE ;arch_cpu_init ();get_clocks ();
board/freescale/t104xrdb/spl.c +2 -2
@@ -94,8 +94,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(gd +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L3_ADDR ; - bd->bi_memsize =CONFIG_SYS_L3_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L3_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L3_SIZE ;arch_cpu_init ();get_clocks ();
board/freescale/t208xqds/spl.c +2 -2
@@ -102,8 +102,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(gd +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L3_ADDR ; - bd->bi_memsize =CONFIG_SYS_L3_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L3_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L3_SIZE ;arch_cpu_init ();get_clocks ();
board/freescale/t208xrdb/spl.c +2 -2
@@ -72,8 +72,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(gd +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L3_ADDR ; - bd->bi_memsize =CONFIG_SYS_L3_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L3_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L3_SIZE ;arch_cpu_init ();get_clocks ();
board/freescale/t4rdb/spl.c +2 -2
@@ -75,8 +75,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(gd +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L3_ADDR ; - bd->bi_memsize =CONFIG_SYS_L3_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L3_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L3_SIZE ;arch_cpu_init ();get_clocks ();
board/xilinx/zynqmp/zynqmp.c +0 -2
@@ -467,10 +467,8 @@ int dram_init(void)#else int dram_init_banksize (void ) { -#if defined(CONFIG_NR_DRAM_BANKS ) gd->bd->bi_dram[0 ].start =CONFIG_SYS_SDRAM_BASE ; gd->bd->bi_dram[0 ].size =get_effective_memsize (); -#endif mem_map_fill ();
cmd/bdinfo.c +2 -4
@@ -49,7 +49,6 @@ void bdinfo_print_mhz(const char *name, unsigned long hz)static void print_bi_dram (const struct bd_info *bd) { -#ifdef CONFIG_NR_DRAM_BANKS int i;for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; ++i) {
@@ -59,7 +58,6 @@ static void print_bi_dram(const struct bd_info *bd)bdinfo_print_num ("-> size" , bd->bi_dram[i].size); } } -#endif }__weak void arch_print_bdinfo (void )
@@ -75,8 +73,8 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])#endif bdinfo_print_num ("boot_params" , (ulong )bd->bi_boot_params);print_bi_dram (bd); -bdinfo_print_num ("memstart" , (ulong )bd->bi_memstart); -print_phys_addr ("memsize" , bd->bi_memsize); +bdinfo_print_num ("memstart" , (ulong )bd->bi_dram[0 ].start); +print_phys_addr ("memsize" , bd->bi_dram[0 ].size);if (IS_ENABLED (CONFIG_SYS_HAS_SRAM )) {bdinfo_print_num ("sramstart" , (ulong )bd->bi_sramstart);bdinfo_print_num ("sramsize" , (ulong )bd->bi_sramsize);
cmd/bedbug.c +1 -1
@@ -348,7 +348,7 @@ int do_bedbug_stack(struct cmd_tbl *cmdtp, int flag, int argc,return 1 ; } - top = gd->bd->bi_memstart + gd->bd->bi_memsize; + top = gd->bd->bi_dram[0 ].start + gd->bd->bi_dram[0 ].size; depth =0 ;printf ("Depth PC\n" );
common/board_f.c +6 -7
@@ -216,7 +216,6 @@ static int show_dram_config(void) {unsigned long long size; -#ifdef CONFIG_NR_DRAM_BANKS int i;debug ("\nRAM Configuration:\n" );
@@ -229,9 +228,6 @@ static int show_dram_config(void)#endif }debug ("\nDRAM: " ); -#else - size = gd->ram_size; -#endif print_size (size,"" );board_add_ram_info (0 );
@@ -242,7 +238,7 @@ static int show_dram_config(void)__weak int dram_init_banksize (void ) { -#if defined(CONFIG_NR_DRAM_BANKS ) && defined(CONFIG_SYS_SDRAM_BASE ) +#if defined(CONFIG_SYS_SDRAM_BASE ) gd->bd->bi_dram[0 ].start =CONFIG_SYS_SDRAM_BASE ; gd->bd->bi_dram[0 ].size =get_effective_memsize ();#endif
@@ -607,8 +603,11 @@ int setup_bdinfo(void) {struct bd_info *bd = gd->bd; - bd->bi_memstart = gd->ram_base;/* start of memory */ - bd->bi_memsize = gd->ram_size;/* size in bytes */ +/* Only overwrite bi_dram[0] values if not already set */ +if (!bd->bi_dram[0 ].size) { + bd->bi_dram[0 ].start = gd->ram_base;/* start of memory */ + bd->bi_dram[0 ].size = gd->ram_size;/* size in bytes */ + }if (IS_ENABLED (CONFIG_SYS_HAS_SRAM )) { bd->bi_sramstart =CONFIG_SYS_SRAM_BASE ;/* start of SRAM */
common/image.c +1 -9
@@ -668,10 +668,8 @@ ulong env_get_bootm_low(void)#if defined(CONFIG_SYS_SDRAM_BASE )return CONFIG_SYS_SDRAM_BASE ; -#elif defined(CONFIG_ARM ) || defined(CONFIG_MICROBLAZE ) -return gd->bd->bi_dram[0 ].start;#else -return 0 ; +return gd->bd->bi_dram[0 ].start;#endif }
@@ -685,14 +683,8 @@ phys_size_t env_get_bootm_size(void)return tmp; } -#if (defined(CONFIG_ARM ) || defined(CONFIG_MICROBLAZE )) && \ - defined(CONFIG_NR_DRAM_BANKS ) start = gd->bd->bi_dram[0 ].start; size = gd->bd->bi_dram[0 ].size; -#else - start = gd->bd->bi_memstart; - size = gd->bd->bi_memsize; -#endif s =env_get ("bootm_low" );if (s)
common/init/handoff.c +13 -20
@@ -12,18 +12,15 @@ DECLARE_GLOBAL_DATA_PTR;void handoff_save_dram (struct spl_handoff *ho) { +struct bd_info *bd = gd->bd; +int i; + ho->ram_size = gd->ram_size; -#ifdef CONFIG_NR_DRAM_BANKS - { -struct bd_info *bd = gd->bd; -int i; - -for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) { - ho->ram_bank[i].start = bd->bi_dram[i].start; - ho->ram_bank[i].size = bd->bi_dram[i].size; - } + +for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) { + ho->ram_bank[i].start = bd->bi_dram[i].start; + ho->ram_bank[i].size = bd->bi_dram[i].size; } -#endif }void handoff_load_dram_size (struct spl_handoff *ho)
@@ -33,15 +30,11 @@ void handoff_load_dram_size(struct spl_handoff *ho)void handoff_load_dram_banks (struct spl_handoff *ho) { -#ifdef CONFIG_NR_DRAM_BANKS - { -struct bd_info *bd = gd->bd; -int i; - -for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) { - bd->bi_dram[i].start = ho->ram_bank[i].start; - bd->bi_dram[i].size = ho->ram_bank[i].size; - } +struct bd_info *bd = gd->bd; +int i; + +for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) { + bd->bi_dram[i].start = ho->ram_bank[i].start; + bd->bi_dram[i].size = ho->ram_bank[i].size; } -#endif }
drivers/pci/pci-uclass.c +1 -16
@@ -871,6 +871,7 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node, ofnode node) {int pci_addr_cells, addr_cells, size_cells; +struct bd_info *bd = gd->bd;int cells_per_record;const u32 *prop;int len;
@@ -938,9 +939,6 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node, }/* Add a region for our local memory */ -#ifdef CONFIG_NR_DRAM_BANKS -struct bd_info *bd = gd->bd; -if (!bd)return ;
@@ -958,19 +956,6 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node, PCI_REGION_MEM | PCI_REGION_SYS_MEMORY); } } -#else -phys_addr_t base =0 , size; - - size = gd->ram_size; -#ifdef CONFIG_SYS_SDRAM_BASE - base =CONFIG_SYS_SDRAM_BASE ; -#endif -if (gd->pci_ram_top && gd->pci_ram_top < base + size) - size = gd->pci_ram_top - base; -if (size) -pci_set_region (hose->regions + hose->region_count++, base, - base, size,PCI_REGION_MEM |PCI_REGION_SYS_MEMORY ); -#endif return ; }
drivers/video/cfb_console.c +1 -7
@@ -1983,8 +1983,6 @@ static void *video_logo(void)static int cfb_fb_is_in_dram (void ) {struct bd_info *bd = gd->bd; -#if defined(CONFIG_ARM ) || defined(CONFIG_NDS32 ) || \ -defined(CONFIG_SANDBOX ) || defined(CONFIG_X86 )ulong start, end;int i;
@@ -1995,11 +1993,7 @@ defined(CONFIG_SANDBOX) || defined(CONFIG_X86) (ulong)video_fb_address < end)return 1 ; } -#else -if ((ulong )video_fb_address >= bd->bi_memstart && - (ulong )video_fb_address < bd->bi_memstart + bd->bi_memsize) -return 1 ; -#endif +return 0 ; }
include/asm-generic/u-boot.h +0 -4
@@ -27,8 +27,6 @@#include <linux/types.h> struct bd_info { -unsigned long bi_memstart;/* start of DRAM memory */ -phys_size_t bi_memsize;/* size of DRAM memory in bytes */ unsigned long bi_flashstart;/* start of FLASH memory */ unsigned long bi_flashsize;/* size of FLASH memory */ unsigned long bi_flashoffset;/* reserved area for startup monitor */
@@ -70,12 +68,10 @@ struct bd_info {#endif ulong bi_arch_number;/* unique id for this board */ ulong bi_boot_params;/* where this board expects params */ -#ifdef CONFIG_NR_DRAM_BANKS struct {/* RAM configuration */ phys_addr_t start;phys_size_t size; } bi_dram[CONFIG_NR_DRAM_BANKS]; -#endif /* CONFIG_NR_DRAM_BANKS */ };#endif /* __ASSEMBLY__ */
include/handoff.h +0 -2
@@ -20,12 +20,10 @@struct spl_handoff {struct arch_spl_handoff arch;u64 ram_size; -#ifdef CONFIG_NR_DRAM_BANKS struct {u64 start;u64 size; } ram_bank[CONFIG_NR_DRAM_BANKS ]; -#endif };void handoff_save_dram (struct spl_handoff *ho);
lib/fdtdec.c +0 -5
@@ -1055,8 +1055,6 @@ int fdtdec_setup_mem_size_base(void)return 0 ; } -#if defined(CONFIG_NR_DRAM_BANKS ) -static int get_next_memory_node (const void *blob,int mem) { do {
@@ -1106,7 +1104,6 @@ int fdtdec_setup_memory_banksize(void)return 0 ; } -#endif #if CONFIG_IS_ENABLED (MULTI_DTB_FIT ) # if CONFIG_IS_ENABLED(MULTI_DTB_FIT_GZIP) ||\
@@ -1569,7 +1566,6 @@ int fdtdec_resetup(int *rescan) }#endif -#ifdef CONFIG_NR_DRAM_BANKS int fdtdec_decode_ram_size (const void *blob,const char *area,int board_id,phys_addr_t *basep,phys_size_t *sizep,struct bd_info *bd)
@@ -1675,6 +1671,5 @@ int fdtdec_decode_ram_size(const void *blob, const char *area, int board_id, return 0; } -#endif /* CONFIG_NR_DRAM_BANKS */ #endif /* !USE_HOSTCC */
lib/lmb.c +0 -7
@@ -117,22 +117,15 @@ static void lmb_reserve_common(struct lmb *lmb, void *fdt_blob)/* Initialize the struct, add memory and call arch/board reserve functions */ void lmb_init_and_reserve (struct lmb *lmb,struct bd_info *bd,void *fdt_blob) { -#ifdef CONFIG_NR_DRAM_BANKS int i; -#endif lmb_init (lmb); -#ifdef CONFIG_NR_DRAM_BANKS for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) {if (bd->bi_dram[i].size) {lmb_add (lmb, bd->bi_dram[i].start, bd->bi_dram[i].size); } } -#else -if (bd->bi_memsize) -lmb_add (lmb, bd->bi_memstart, bd->bi_memsize); -#endif lmb_reserve_common (lmb, fdt_blob); }
Signature · 1 line
2.28.0
PATCH v3 1/1 CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always defined
Quoted 115 lines · On Wednesday 12 August 2020 09:44:17 Stefan Roese wrote:
Since commit
86cf1c82850f("configs: MigrateCONFIG_NR_DRAM_BANKS") & commit999a772d9f24("Kconfig: MigrateCONFIG_NR_DRAM_BANKS"),CONFIG_NR_DRAM_BANKSis always defined with a value (4 is default). It makes no sense to still carry code that is guarded with "#ifndefCONFIG_NR_DRAM_BANKS" (and similar). This patch removes all these unreferenced code paths.Also complete remove
bi_memstart&bi_memsizefrom the board-info struct. As now bi_dram[] is always enabled and should be used instead. This removes the redundant varriables.Signed-off-by Stefan Roese <[email protected]>Cc Daniel Schwierzeck <[email protected]>Cc Tom Rini <[email protected]>Cc Ramon Fried <[email protected]>Cc Simon Glass <[email protected]>Cc Michal Simek <[email protected]>Cc Pali Roh?r <[email protected]>---
v3:
- Rebase on TOT
- Add check to not overwrite bi_dram[0] if already configured insetup_bdinfo(). This fixes the test issue with Nokia RX51.Azure test report success:
https://dev.azure.com/sr0718/u-boot/_build/results?buildId=26&view=resultsv2:
- Change all references tobi_memstart&bi_memsizeto bi_dram[0].start/ size and remove it from thebd_infostruct completely, as suggested by Danielapi/api_platform-mips.c | 4 ++-- api/api_platform-powerpc.c | 2 +- arch/mips/lib/boot.c | 2 +- arch/mips/lib/bootm.c | 2 +- arch/powerpc/cpu/mpc83xx/fdt.c | 2 +- arch/powerpc/cpu/mpc83xx/traps.c | 2 +- arch/powerpc/cpu/mpc85xx/fdt.c | 4 ++-- arch/powerpc/cpu/mpc85xx/traps.c | 2 +- arch/powerpc/cpu/mpc86xx/fdt.c | 2 +- arch/powerpc/cpu/mpc86xx/traps.c | 2 +- arch/powerpc/cpu/mpc8xx/fdt.c | 2 +- arch/powerpc/lib/bootm.c | 4 ++-- arch/x86/cpu/broadwell/cpu_from_spl.c | 2 -- arch/xtensa/lib/bdinfo.c | 4 ++-- arch/xtensa/lib/bootm.c | 4 ++-- board/Arcturus/ucp1020/spl.c | 4 ++-- board/freescale/p1010rdb/spl.c | 4 ++-- board/freescale/p1_p2_rdb_pc/spl.c | 4 ++-- board/freescale/t102xrdb/spl.c | 4 ++-- board/freescale/t104xrdb/spl.c | 4 ++-- board/freescale/t208xqds/spl.c | 4 ++-- board/freescale/t208xrdb/spl.c | 4 ++-- board/freescale/t4rdb/spl.c | 4 ++-- board/xilinx/zynqmp/zynqmp.c | 2 -- cmd/bdinfo.c | 6 ++--- cmd/bedbug.c | 2 +- common/board_f.c | 13 +++++------ common/image.c | 10 +------- common/init/handoff.c | 33 +++++++++++---------------- drivers/pci/pci-uclass.c | 17 +------------- drivers/video/cfb_console.c | 8 +------ include/asm-generic/u-boot.h | 4 ---- include/handoff.h | 2 -- lib/fdtdec.c | 5 ---- lib/lmb.c | 7 ------ 35 files changed, 60 insertions(+), 121 deletions(-)api/api_platform-mips.c +2
-2@@ -24,8 +24,8 @@ DECLARE_GLOBAL_DATA_PTR;int platform_sys_info (struct sys_info *si) { -platform_set_mr (si, gd->bd->bi_memstart, - gd->bd->bi_memsize,MR_ATTR_DRAM ); +platform_set_mr (si, gd->bd->bi_dram[0 ].start, + gd->bd->bi_dram[0 ].size,MR_ATTR_DRAM );return 1 ; }api/api_platform-powerpc.c +1
-1@@ -42,7 +42,7 @@ int platform_sys_info(struct sys_info *si) si->bar =0 ;#endif -platform_set_mr (si, gd->bd->bi_memstart, gd->bd->bi_memsize,MR_ATTR_DRAM ); +platform_set_mr (si, gd->bd->bi_dram[0 ].start, gd->bd->bi_dram[0 ].size,MR_ATTR_DRAM );platform_set_mr (si, gd->bd->bi_flashstart, gd->bd->bi_flashsize,MR_ATTR_FLASH );platform_set_mr (si, gd->bd->bi_sramstart, gd->bd->bi_sramsize,MR_ATTR_SRAM );arch/mips/lib/boot.c +1
-1@@ -17,7 +17,7 @@ unsigned long do_go_exec(ulong (*entry)(int, char * const []),* whole SDRAM area, since we don't know the size of the image * that was loaded. */ -flush_cache (gd->bd->bi_memstart, gd->ram_top - gd->bd->bi_memstart); +flush_cache (gd->bd->bi_dram[0 ].start, gd->ram_top - gd->bd->bi_dram[0 ].start);return entry (argc, argv); }arch/mips/lib/bootm.c +0
-0
arch/mips/lib/bootm.c static int boot_reloc_fdt(bootm_headers_t *images) · line 246
Quoted 6 lines
arch/mips/lib/bootm.c +1
-1@@ -242,7 +242,7 @@ static int boot_reloc_fdt(bootm_headers_t *images)#if CONFIG_IS_ENABLED (MIPS_BOOT_FDT ) &&CONFIG_IS_ENABLED (OF_LIBFDT )int arch_fixup_fdt (void *blob) { -u64 mem_start =virt_to_phys ((void *)gd->bd->bi_memstart); +u64 mem_start =virt_to_phys ((void *)gd->bd->bi_dram[0 ].start);u64 mem_size = gd->ram_size;
I do not fully understand this change. Why on some places you are suing bi_dram[0].size and on some places gd->ram_size?
Quoted 50 lines
arch/mips/lib/bootm.c +0
-0return fdt_fixup_memory_banks (blob, &mem_start, &mem_size,1 );arch/powerpc/cpu/mpc83xx/fdt.c +1
-1@@ -121,7 +121,7 @@ void ft_cpu_setup(void *blob, struct bd_info *bd) "clock-frequency", get_serial_clock(), 1);#endif -fdt_fixup_memory (blob, (u64 )bd->bi_memstart, (u64 )bd->bi_memsize); +fdt_fixup_memory (blob, (u64 )bd->bi_dram[0 ].start, (u64 )bd->bi_dram[0 ].size);#if defined(CONFIG_BOOTCOUNT_LIMIT ) && \ (defined(CONFIG_QE ) && !defined(CONFIG_ARCH_MPC831X ))arch/powerpc/cpu/mpc83xx/traps.c +1
-1@@ -23,7 +23,7 @@ DECLARE_GLOBAL_DATA_PTR;/* Returns 0 if exception not found and fixup otherwise. */ extern unsigned long search_exception_table (unsigned long ); -#define END_OF_MEM (gd->bd->bi_memstart + gd->bd->bi_memsize) +#define END_OF_MEM (gd->bd->bi_dram[0].start + gd->bd->bi_dram[0].size)/* * Trap & Exception support arch/powerpc/cpu/mpc85xx/fdt.c +2
-2@@ -672,10 +672,10 @@ void ft_cpu_setup(void *blob, struct bd_info *bd) "clock-frequency", get_bus_freq(0), 1);#endif -fdt_fixup_memory (blob, (u64 )bd->bi_memstart, (u64 )bd->bi_memsize); +fdt_fixup_memory (blob, (u64 )bd->bi_dram[0 ].start, (u64 )bd->bi_dram[0 ].size);#ifdef CONFIG_MP -ft_fixup_cpu (blob, (u64 )bd->bi_memstart + (u64 )bd->bi_memsize); +ft_fixup_cpu (blob, (u64 )bd->bi_dram[0 ].start + (u64 )bd->bi_dram[0 ].size);ft_fixup_num_cores (blob);#endif arch/powerpc/cpu/mpc85xx/traps.c +0
-0
arch/powerpc/cpu/mpc85xx/traps.c extern unsigned long search_exception_table(unsigned long); · line 40
Quoted 5 lines
arch/powerpc/cpu/mpc85xx/traps.c +1
-1@@ -37,7 +37,7 @@ extern unsigned long search_exception_table(unsigned long);* amount of memory on the system if we're unable to keep all * the memory mapped in. */ -#define END_OF_MEM (gd->bd->bi_memstart + get_effective_memsize()) +#define END_OF_MEM (gd->bd->bi_dram[0].start + get_effective_memsize())
And on other place is get_effective_memsize()?
Quoted 314 lines
arch/powerpc/cpu/mpc85xx/traps.c +0
-0static __inline__void set_tsr (unsigned long val) {arch/powerpc/cpu/mpc86xx/fdt.c +1
-1@@ -27,7 +27,7 @@ void ft_cpu_setup(void *blob, struct bd_info *bd)do_fixup_by_prop_u32 (blob,"device_type" ,"soc" ,4 ,"bus-frequency" , bd->bi_busfreq,1 ); -fdt_fixup_memory (blob, (u64 )bd->bi_memstart, (u64 )bd->bi_memsize); +fdt_fixup_memory (blob, (u64 )bd->bi_dram[0 ].start, (u64 )bd->bi_dram[0 ].size);#ifdef CONFIG_SYS_NS16550 do_fixup_by_compat_u32(blob, "ns16550",arch/powerpc/cpu/mpc86xx/traps.c +1
-1@@ -30,7 +30,7 @@ extern unsigned long search_exception_table(unsigned long);* amount of memory on the system if we're unable to keep all * the memory mapped in. */ -#define END_OF_MEM (gd->bd->bi_memstart + get_effective_memsize()) +#define END_OF_MEM (gd->bd->bi_dram[0].start + get_effective_memsize())/* * Trap & Exception support arch/powerpc/cpu/mpc8xx/fdt.c +1
-1@@ -25,5 +25,5 @@ void ft_cpu_setup(void *blob, struct bd_info *bd)do_fixup_by_compat_u32 (blob,"fsl,cpm-brg" ,"clock-frequency" , gd->arch.brg_clk,1 ); -fdt_fixup_memory (blob, (u64 )bd->bi_memstart, (u64 )bd->bi_memsize); +fdt_fixup_memory (blob, (u64 )bd->bi_dram[0 ].start, (u64 )bd->bi_dram[0 ].size); }arch/powerpc/lib/bootm.c +2
-2@@ -298,8 +298,8 @@ void boot_prep_vxworks(bootm_headers_t *images)if (!images->ft_addr)return ; - base = (u64 )gd->bd->bi_memstart; - size = (u64 )gd->bd->bi_memsize; + base = (u64 )gd->bd->bi_dram[0 ].start; + size = (u64 )gd->bd->bi_dram[0 ].size; off =fdt_path_offset (images->ft_addr,"/memory" );if (off <0 )arch/x86/cpu/broadwell/cpu_from_spl.c +0
-2@@ -53,14 +53,12 @@ void board_debug_uart_init(void)int dram_init_banksize (void ) { -#ifdef CONFIG_NR_DRAM_BANKS struct spl_handoff *ho; ho =bloblist_find (BLOBLISTT_SPL_HANDOFF ,sizeof (*ho));if (!ho)return log_msg_ret ("Missing SPL hand-off info" , -ENOENT );handoff_load_dram_banks (ho); -#endif return 0 ; }arch/xtensa/lib/bdinfo.c +2
-2@@ -15,8 +15,8 @@ int arch_setup_bdinfo(void) {struct bd_info *bd = gd->bd; - bd->bi_memstart =PHYSADDR (CONFIG_SYS_SDRAM_BASE ); - bd->bi_memsize =CONFIG_SYS_SDRAM_SIZE ; + bd->bi_dram[0 ].start =PHYSADDR (CONFIG_SYS_SDRAM_BASE ); + bd->bi_dram[0 ].size =CONFIG_SYS_SDRAM_SIZE ;return 0 ; }arch/xtensa/lib/bootm.c +2
-2@@ -48,8 +48,8 @@ static struct bp_tag *setup_memory_tag(struct bp_tag *params) params->size =sizeof (struct meminfo ); mem = (struct meminfo *)params->data; mem->type =MEMORY_TYPE_CONVENTIONAL ; - mem->start = bd->bi_memstart; - mem->end = bd->bi_memstart + bd->bi_memsize; + mem->start = bd->bi_dram[0 ].start; + mem->end = bd->bi_dram[0 ].start + bd->bi_dram[0 ].size;printf (" MEMORY: tag:0x%04x, type:0X%lx, start:0X%lx, end:0X%lx\n" ,BP_TAG_MEMORY , mem->type, mem->start, mem->end);board/Arcturus/ucp1020/spl.c +2
-2@@ -83,8 +83,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(CONFIG_SPL_GD_ADDR +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L2_ADDR ; - bd->bi_memsize =CONFIG_SYS_L2_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L2_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L2_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/p1010rdb/spl.c +2
-2@@ -69,8 +69,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(CONFIG_SPL_GD_ADDR +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L2_ADDR ; - bd->bi_memsize =CONFIG_SYS_L2_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L2_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L2_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/p1_p2_rdb_pc/spl.c +2
-2@@ -75,8 +75,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(CONFIG_SPL_GD_ADDR +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L2_ADDR ; - bd->bi_memsize =CONFIG_SYS_L2_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L2_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L2_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/t102xrdb/spl.c +2
-2@@ -103,8 +103,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(gd +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L3_ADDR ; - bd->bi_memsize =CONFIG_SYS_L3_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L3_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L3_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/t104xrdb/spl.c +2
-2@@ -94,8 +94,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(gd +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L3_ADDR ; - bd->bi_memsize =CONFIG_SYS_L3_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L3_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L3_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/t208xqds/spl.c +2
-2@@ -102,8 +102,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(gd +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L3_ADDR ; - bd->bi_memsize =CONFIG_SYS_L3_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L3_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L3_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/t208xrdb/spl.c +2
-2@@ -72,8 +72,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(gd +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L3_ADDR ; - bd->bi_memsize =CONFIG_SYS_L3_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L3_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L3_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/t4rdb/spl.c +2
-2@@ -75,8 +75,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(gd +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L3_ADDR ; - bd->bi_memsize =CONFIG_SYS_L3_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L3_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L3_SIZE ;arch_cpu_init ();get_clocks ();board/xilinx/zynqmp/zynqmp.c +0
-2@@ -467,10 +467,8 @@ int dram_init(void)#else int dram_init_banksize (void ) { -#if defined(CONFIG_NR_DRAM_BANKS ) gd->bd->bi_dram[0 ].start =CONFIG_SYS_SDRAM_BASE ; gd->bd->bi_dram[0 ].size =get_effective_memsize (); -#endif mem_map_fill ();cmd/bdinfo.c +2
-4@@ -49,7 +49,6 @@ void bdinfo_print_mhz(const char *name, unsigned long hz)static void print_bi_dram (const struct bd_info *bd) { -#ifdef CONFIG_NR_DRAM_BANKS int i;for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; ++i) {@@ -59,7 +58,6 @@ static void print_bi_dram(const struct bd_info *bd)bdinfo_print_num ("-> size" , bd->bi_dram[i].size); } } -#endif }__weak void arch_print_bdinfo (void )@@ -75,8 +73,8 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])#endif bdinfo_print_num ("boot_params" , (ulong )bd->bi_boot_params);print_bi_dram (bd); -bdinfo_print_num ("memstart" , (ulong )bd->bi_memstart); -print_phys_addr ("memsize" , bd->bi_memsize); +bdinfo_print_num ("memstart" , (ulong )bd->bi_dram[0 ].start); +print_phys_addr ("memsize" , bd->bi_dram[0 ].size);if (IS_ENABLED (CONFIG_SYS_HAS_SRAM )) {bdinfo_print_num ("sramstart" , (ulong )bd->bi_sramstart);bdinfo_print_num ("sramsize" , (ulong )bd->bi_sramsize);cmd/bedbug.c +1
-1@@ -348,7 +348,7 @@ int do_bedbug_stack(struct cmd_tbl *cmdtp, int flag, int argc,return 1 ; } - top = gd->bd->bi_memstart + gd->bd->bi_memsize; + top = gd->bd->bi_dram[0 ].start + gd->bd->bi_dram[0 ].size; depth =0 ;printf ("Depth PC\n" );common/board_f.c +1
-5@@ -216,7 +216,6 @@ static int show_dram_config(void) {unsigned long long size; -#ifdef CONFIG_NR_DRAM_BANKS int i;debug ("\nRAM Configuration:\n" );@@ -229,9 +228,6 @@ static int show_dram_config(void)#endif }debug ("\nDRAM: " ); -#else - size = gd->ram_size; -#endif print_size (size,"" );board_add_ram_info (0 );@@ -242,7 +238,7 @@ static int show_dram_config(void)__weak int dram_init_banksize (void ) { -#if defined(CONFIG_NR_DRAM_BANKS ) && defined(CONFIG_SYS_SDRAM_BASE ) +#if defined(CONFIG_SYS_SDRAM_BASE ) gd->bd->bi_dram[0 ].start =CONFIG_SYS_SDRAM_BASE ; gd->bd->bi_dram[0 ].size =get_effective_memsize ();#endif
common/board_f.c int setup_bdinfo(void) · line 607
Quoted 7 lines
common/board_f.c +2
-2@@ -607,8 +603,11 @@ int setup_bdinfo(void) {struct bd_info *bd = gd->bd; - bd->bi_memstart = gd->ram_base;/* start of memory */ - bd->bi_memsize = gd->ram_size;/* size in bytes */ +/* Only overwrite bi_dram[0] values if not already set */ +if (!bd->bi_dram[0 ].size) {
This still look suspicious. When is bi_dram[0].size zero? I tried to trace source code. dram_init_banksize() is always called before setup_bdinfo() which fills bi_dram[], so when can be dram size zero? Or I'm missing something?
Quoted 266 lines
common/board_f.c +3
-0+ bd->bi_dram[0 ].start = gd->ram_base;/* start of memory */ + bd->bi_dram[0 ].size = gd->ram_size;/* size in bytes */ + }if (IS_ENABLED (CONFIG_SYS_HAS_SRAM )) { bd->bi_sramstart =CONFIG_SYS_SRAM_BASE ;/* start of SRAM */ common/image.c +1
-9@@ -668,10 +668,8 @@ ulong env_get_bootm_low(void)#if defined(CONFIG_SYS_SDRAM_BASE )return CONFIG_SYS_SDRAM_BASE ; -#elif defined(CONFIG_ARM ) || defined(CONFIG_MICROBLAZE ) -return gd->bd->bi_dram[0 ].start;#else -return 0 ; +return gd->bd->bi_dram[0 ].start;#endif }@@ -685,14 +683,8 @@ phys_size_t env_get_bootm_size(void)return tmp; } -#if (defined(CONFIG_ARM ) || defined(CONFIG_MICROBLAZE )) && \ - defined(CONFIG_NR_DRAM_BANKS ) start = gd->bd->bi_dram[0 ].start; size = gd->bd->bi_dram[0 ].size; -#else - start = gd->bd->bi_memstart; - size = gd->bd->bi_memsize; -#endif s =env_get ("bootm_low" );if (s)common/init/handoff.c +13
-20@@ -12,18 +12,15 @@ DECLARE_GLOBAL_DATA_PTR;void handoff_save_dram (struct spl_handoff *ho) { +struct bd_info *bd = gd->bd; +int i; + ho->ram_size = gd->ram_size; -#ifdef CONFIG_NR_DRAM_BANKS - { -struct bd_info *bd = gd->bd; -int i; - -for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) { - ho->ram_bank[i].start = bd->bi_dram[i].start; - ho->ram_bank[i].size = bd->bi_dram[i].size; - } + +for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) { + ho->ram_bank[i].start = bd->bi_dram[i].start; + ho->ram_bank[i].size = bd->bi_dram[i].size; } -#endif }void handoff_load_dram_size (struct spl_handoff *ho)@@ -33,15 +30,11 @@ void handoff_load_dram_size(struct spl_handoff *ho)void handoff_load_dram_banks (struct spl_handoff *ho) { -#ifdef CONFIG_NR_DRAM_BANKS - { -struct bd_info *bd = gd->bd; -int i; - -for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) { - bd->bi_dram[i].start = ho->ram_bank[i].start; - bd->bi_dram[i].size = ho->ram_bank[i].size; - } +struct bd_info *bd = gd->bd; +int i; + +for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) { + bd->bi_dram[i].start = ho->ram_bank[i].start; + bd->bi_dram[i].size = ho->ram_bank[i].size; } -#endif }drivers/pci/pci-uclass.c +1
-16@@ -871,6 +871,7 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node, ofnode node) {int pci_addr_cells, addr_cells, size_cells; +struct bd_info *bd = gd->bd;int cells_per_record;const u32 *prop;int len;@@ -938,9 +939,6 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node, }/* Add a region for our local memory */ -#ifdef CONFIG_NR_DRAM_BANKS -struct bd_info *bd = gd->bd; -if (!bd)return ;@@ -958,19 +956,6 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node, PCI_REGION_MEM | PCI_REGION_SYS_MEMORY); } } -#else -phys_addr_t base =0 , size; - - size = gd->ram_size; -#ifdef CONFIG_SYS_SDRAM_BASE - base =CONFIG_SYS_SDRAM_BASE ; -#endif -if (gd->pci_ram_top && gd->pci_ram_top < base + size) - size = gd->pci_ram_top - base; -if (size) -pci_set_region (hose->regions + hose->region_count++, base, - base, size,PCI_REGION_MEM |PCI_REGION_SYS_MEMORY ); -#endif return ; }drivers/video/cfb_console.c +1
-7@@ -1983,8 +1983,6 @@ static void *video_logo(void)static int cfb_fb_is_in_dram (void ) {struct bd_info *bd = gd->bd; -#if defined(CONFIG_ARM ) || defined(CONFIG_NDS32 ) || \ -defined(CONFIG_SANDBOX ) || defined(CONFIG_X86 )ulong start, end;int i;@@ -1995,11 +1993,7 @@ defined(CONFIG_SANDBOX) || defined(CONFIG_X86) (ulong)video_fb_address < end)return 1 ; } -#else -if ((ulong )video_fb_address >= bd->bi_memstart && - (ulong )video_fb_address < bd->bi_memstart + bd->bi_memsize) -return 1 ; -#endif +return 0 ; }include/asm-generic/u-boot.h +0
-4@@ -27,8 +27,6 @@#include <linux/types.h> struct bd_info { -unsigned long bi_memstart;/* start of DRAM memory */ -phys_size_t bi_memsize;/* size of DRAM memory in bytes */ unsigned long bi_flashstart;/* start of FLASH memory */ unsigned long bi_flashsize;/* size of FLASH memory */ unsigned long bi_flashoffset;/* reserved area for startup monitor */ @@ -70,12 +68,10 @@ struct bd_info {#endif ulong bi_arch_number;/* unique id for this board */ ulong bi_boot_params;/* where this board expects params */ -#ifdef CONFIG_NR_DRAM_BANKS struct {/* RAM configuration */ phys_addr_t start;phys_size_t size; } bi_dram[CONFIG_NR_DRAM_BANKS]; -#endif /* CONFIG_NR_DRAM_BANKS */ };#endif /* __ASSEMBLY__ */ include/handoff.h +0
-2@@ -20,12 +20,10 @@struct spl_handoff {struct arch_spl_handoff arch;u64 ram_size; -#ifdef CONFIG_NR_DRAM_BANKS struct {u64 start;u64 size; } ram_bank[CONFIG_NR_DRAM_BANKS ]; -#endif };void handoff_save_dram (struct spl_handoff *ho);lib/fdtdec.c +0
-5@@ -1055,8 +1055,6 @@ int fdtdec_setup_mem_size_base(void)return 0 ; } -#if defined(CONFIG_NR_DRAM_BANKS ) -static int get_next_memory_node (const void *blob,int mem) { do {@@ -1106,7 +1104,6 @@ int fdtdec_setup_memory_banksize(void)return 0 ; } -#endif #if CONFIG_IS_ENABLED (MULTI_DTB_FIT ) # if CONFIG_IS_ENABLED(MULTI_DTB_FIT_GZIP) ||\@@ -1569,7 +1566,6 @@ int fdtdec_resetup(int *rescan) }#endif -#ifdef CONFIG_NR_DRAM_BANKS int fdtdec_decode_ram_size (const void *blob,const char *area,int board_id,phys_addr_t *basep,phys_size_t *sizep,struct bd_info *bd)@@ -1675,6 +1671,5 @@ int fdtdec_decode_ram_size(const void *blob, const char *area, int board_id, return 0; } -#endif /* CONFIG_NR_DRAM_BANKS */ #endif /* !USE_HOSTCC */ lib/lmb.c +0
-7@@ -117,22 +117,15 @@ static void lmb_reserve_common(struct lmb *lmb, void *fdt_blob)/* Initialize the struct, add memory and call arch/board reserve functions */ void lmb_init_and_reserve (struct lmb *lmb,struct bd_info *bd,void *fdt_blob) { -#ifdef CONFIG_NR_DRAM_BANKS int i; -#endif lmb_init (lmb); -#ifdef CONFIG_NR_DRAM_BANKS for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) {if (bd->bi_dram[i].size) {lmb_add (lmb, bd->bi_dram[i].start, bd->bi_dram[i].size); } } -#else -if (bd->bi_memsize) -lmb_add (lmb, bd->bi_memstart, bd->bi_memsize); -#endif lmb_reserve_common (lmb, fdt_blob); }Signature · 1 line
2.28.0
For me it looks like that this patch is mixing different structures for ram size from different sources. It is really correct? Does not it break other boards?
I think that there is missing explanation of these changes.
PATCH v3 1/1 CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always defined
Hi Pali,
Quoted 109 lines · Pali Roh?r
Quoted 108 lines · On Wednesday 12 August 2020 09:44:17 Stefan Roese wrote:
Since commit
86cf1c82850f("configs: MigrateCONFIG_NR_DRAM_BANKS") & commit999a772d9f24("Kconfig: MigrateCONFIG_NR_DRAM_BANKS"),CONFIG_NR_DRAM_BANKSis always defined with a value (4 is default). It makes no sense to still carry code that is guarded with "#ifndefCONFIG_NR_DRAM_BANKS" (and similar). This patch removes all these unreferenced code paths.Also complete remove
bi_memstart&bi_memsizefrom the board-info struct. As now bi_dram[] is always enabled and should be used instead. This removes the redundant varriables.Signed-off-by Stefan Roese <[email protected]>Cc Daniel Schwierzeck <[email protected]>Cc Tom Rini <[email protected]>Cc Ramon Fried <[email protected]>Cc Simon Glass <[email protected]>Cc Michal Simek <[email protected]>Cc Pali Roh?r <[email protected]>---
v3:
- Rebase on TOT
- Add check to not overwrite bi_dram[0] if already configured insetup_bdinfo(). This fixes the test issue with Nokia RX51.Azure test report success:
https://dev.azure.com/sr0718/u-boot/_build/results?buildId=26&view=resultsv2:
- Change all references tobi_memstart&bi_memsizeto bi_dram[0].start/ size and remove it from thebd_infostruct completely, as suggested by Danielapi/api_platform-mips.c | 4 ++-- api/api_platform-powerpc.c | 2 +- arch/mips/lib/boot.c | 2 +- arch/mips/lib/bootm.c | 2 +- arch/powerpc/cpu/mpc83xx/fdt.c | 2 +- arch/powerpc/cpu/mpc83xx/traps.c | 2 +- arch/powerpc/cpu/mpc85xx/fdt.c | 4 ++-- arch/powerpc/cpu/mpc85xx/traps.c | 2 +- arch/powerpc/cpu/mpc86xx/fdt.c | 2 +- arch/powerpc/cpu/mpc86xx/traps.c | 2 +- arch/powerpc/cpu/mpc8xx/fdt.c | 2 +- arch/powerpc/lib/bootm.c | 4 ++-- arch/x86/cpu/broadwell/cpu_from_spl.c | 2 -- arch/xtensa/lib/bdinfo.c | 4 ++-- arch/xtensa/lib/bootm.c | 4 ++-- board/Arcturus/ucp1020/spl.c | 4 ++-- board/freescale/p1010rdb/spl.c | 4 ++-- board/freescale/p1_p2_rdb_pc/spl.c | 4 ++-- board/freescale/t102xrdb/spl.c | 4 ++-- board/freescale/t104xrdb/spl.c | 4 ++-- board/freescale/t208xqds/spl.c | 4 ++-- board/freescale/t208xrdb/spl.c | 4 ++-- board/freescale/t4rdb/spl.c | 4 ++-- board/xilinx/zynqmp/zynqmp.c | 2 -- cmd/bdinfo.c | 6 ++--- cmd/bedbug.c | 2 +- common/board_f.c | 13 +++++------ common/image.c | 10 +------- common/init/handoff.c | 33 +++++++++++---------------- drivers/pci/pci-uclass.c | 17 +------------- drivers/video/cfb_console.c | 8 +------ include/asm-generic/u-boot.h | 4 ---- include/handoff.h | 2 -- lib/fdtdec.c | 5 ---- lib/lmb.c | 7 ------ 35 files changed, 60 insertions(+), 121 deletions(-)api/api_platform-mips.c +2
-2@@ -24,8 +24,8 @@ DECLARE_GLOBAL_DATA_PTR;int platform_sys_info (struct sys_info *si) { -platform_set_mr (si, gd->bd->bi_memstart, - gd->bd->bi_memsize,MR_ATTR_DRAM ); +platform_set_mr (si, gd->bd->bi_dram[0 ].start, + gd->bd->bi_dram[0 ].size,MR_ATTR_DRAM );return 1 ; }api/api_platform-powerpc.c +1
-1@@ -42,7 +42,7 @@ int platform_sys_info(struct sys_info *si) si->bar =0 ;#endif -platform_set_mr (si, gd->bd->bi_memstart, gd->bd->bi_memsize,MR_ATTR_DRAM ); +platform_set_mr (si, gd->bd->bi_dram[0 ].start, gd->bd->bi_dram[0 ].size,MR_ATTR_DRAM );platform_set_mr (si, gd->bd->bi_flashstart, gd->bd->bi_flashsize,MR_ATTR_FLASH );platform_set_mr (si, gd->bd->bi_sramstart, gd->bd->bi_sramsize,MR_ATTR_SRAM );arch/mips/lib/boot.c +1
-1@@ -17,7 +17,7 @@ unsigned long do_go_exec(ulong (*entry)(int, char * const []),* whole SDRAM area, since we don't know the size of the image * that was loaded. */ -flush_cache (gd->bd->bi_memstart, gd->ram_top - gd->bd->bi_memstart); +flush_cache (gd->bd->bi_dram[0 ].start, gd->ram_top - gd->bd->bi_dram[0 ].start);
Quoted 16 lines
arch/mips/lib/bootm.c static int boot_reloc_fdt(bootm_headers_t *images) · line 246
Quoted 13 lines
arch/mips/lib/boot.c +0
-0return entry (argc, argv); }arch/mips/lib/bootm.c +1
-1@@ -242,7 +242,7 @@ static int boot_reloc_fdt(bootm_headers_t *images)#if CONFIG_IS_ENABLED (MIPS_BOOT_FDT ) &&CONFIG_IS_ENABLED (OF_LIBFDT )int arch_fixup_fdt (void *blob) { -u64 mem_start =virt_to_phys ((void *)gd->bd->bi_memstart); +u64 mem_start =virt_to_phys ((void *)gd->bd->bi_dram[0 ].start);u64 mem_size = gd->ram_size;I do not fully understand this change. Why on some places you are suing bi_dram[0].size and on some places
gd->ram_size?
This patch is mainly a search and replace s/bd->bi_memstart/bd->bi_dram[0].start. But as your test has shown, this is not always
correct.
Quoted 45 lines
Quoted 45 lines
arch/mips/lib/bootm.c +0
-0return fdt_fixup_memory_banks (blob, &mem_start, &mem_size,1 );arch/powerpc/cpu/mpc83xx/fdt.c +1
-1@@ -121,7 +121,7 @@ void ft_cpu_setup(void *blob, struct bd_info *bd) "clock-frequency", get_serial_clock(), 1);#endif -fdt_fixup_memory (blob, (u64 )bd->bi_memstart, (u64 )bd->bi_memsize); +fdt_fixup_memory (blob, (u64 )bd->bi_dram[0 ].start, (u64 )bd->bi_dram[0 ].size);#if defined(CONFIG_BOOTCOUNT_LIMIT ) && \ (defined(CONFIG_QE ) && !defined(CONFIG_ARCH_MPC831X ))arch/powerpc/cpu/mpc83xx/traps.c +1
-1@@ -23,7 +23,7 @@ DECLARE_GLOBAL_DATA_PTR;/* Returns 0 if exception not found and fixup otherwise. */ extern unsigned long search_exception_table (unsigned long ); -#define END_OF_MEM (gd->bd->bi_memstart + gd->bd->bi_memsize) +#define END_OF_MEM (gd->bd->bi_dram[0].start + gd->bd->bi_dram[0].size)/* * Trap & Exception support arch/powerpc/cpu/mpc85xx/fdt.c +2
-2@@ -672,10 +672,10 @@ void ft_cpu_setup(void *blob, struct bd_info *bd) "clock-frequency", get_bus_freq(0), 1);#endif -fdt_fixup_memory (blob, (u64 )bd->bi_memstart, (u64 )bd->bi_memsize); +fdt_fixup_memory (blob, (u64 )bd->bi_dram[0 ].start, (u64 )bd->bi_dram[0 ].size);#ifdef CONFIG_MP -ft_fixup_cpu (blob, (u64 )bd->bi_memstart + (u64 )bd->bi_memsize); +ft_fixup_cpu (blob, (u64 )bd->bi_dram[0 ].start + (u64 )bd->bi_dram[0 ].size);ft_fixup_num_cores (blob);#endif
Quoted 12 lines
arch/powerpc/cpu/mpc85xx/traps.c extern unsigned long search_exception_table(unsigned long); · line 40
Quoted 10 lines
arch/powerpc/cpu/mpc85xx/traps.c +1
-1@@ -37,7 +37,7 @@ extern unsigned long search_exception_table(unsigned long);* amount of memory on the system if we're unable to keep all * the memory mapped in. */ -#define END_OF_MEM (gd->bd->bi_memstart + get_effective_memsize()) +#define END_OF_MEM (gd->bd->bi_dram[0].start + get_effective_memsize())And on other place is
get_effective_memsize()?
Again, its more a search/replace. The idea was to have no functional change, which did not work out.
Quoted 317 lines
Quoted 317 lines
arch/powerpc/cpu/mpc85xx/traps.c +0
-0static __inline__void set_tsr (unsigned long val) {arch/powerpc/cpu/mpc86xx/fdt.c +1
-1@@ -27,7 +27,7 @@ void ft_cpu_setup(void *blob, struct bd_info *bd)do_fixup_by_prop_u32 (blob,"device_type" ,"soc" ,4 ,"bus-frequency" , bd->bi_busfreq,1 ); -fdt_fixup_memory (blob, (u64 )bd->bi_memstart, (u64 )bd->bi_memsize); +fdt_fixup_memory (blob, (u64 )bd->bi_dram[0 ].start, (u64 )bd->bi_dram[0 ].size);#ifdef CONFIG_SYS_NS16550 do_fixup_by_compat_u32(blob, "ns16550",arch/powerpc/cpu/mpc86xx/traps.c +1
-1@@ -30,7 +30,7 @@ extern unsigned long search_exception_table(unsigned long);* amount of memory on the system if we're unable to keep all * the memory mapped in. */ -#define END_OF_MEM (gd->bd->bi_memstart + get_effective_memsize()) +#define END_OF_MEM (gd->bd->bi_dram[0].start + get_effective_memsize())/* * Trap & Exception support arch/powerpc/cpu/mpc8xx/fdt.c +1
-1@@ -25,5 +25,5 @@ void ft_cpu_setup(void *blob, struct bd_info *bd)do_fixup_by_compat_u32 (blob,"fsl,cpm-brg" ,"clock-frequency" , gd->arch.brg_clk,1 ); -fdt_fixup_memory (blob, (u64 )bd->bi_memstart, (u64 )bd->bi_memsize); +fdt_fixup_memory (blob, (u64 )bd->bi_dram[0 ].start, (u64 )bd->bi_dram[0 ].size); }arch/powerpc/lib/bootm.c +2
-2@@ -298,8 +298,8 @@ void boot_prep_vxworks(bootm_headers_t *images)if (!images->ft_addr)return ; - base = (u64 )gd->bd->bi_memstart; - size = (u64 )gd->bd->bi_memsize; + base = (u64 )gd->bd->bi_dram[0 ].start; + size = (u64 )gd->bd->bi_dram[0 ].size; off =fdt_path_offset (images->ft_addr,"/memory" );if (off <0 )arch/x86/cpu/broadwell/cpu_from_spl.c +0
-2@@ -53,14 +53,12 @@ void board_debug_uart_init(void)int dram_init_banksize (void ) { -#ifdef CONFIG_NR_DRAM_BANKS struct spl_handoff *ho; ho =bloblist_find (BLOBLISTT_SPL_HANDOFF ,sizeof (*ho));if (!ho)return log_msg_ret ("Missing SPL hand-off info" , -ENOENT );handoff_load_dram_banks (ho); -#endif return 0 ; }arch/xtensa/lib/bdinfo.c +2
-2@@ -15,8 +15,8 @@ int arch_setup_bdinfo(void) {struct bd_info *bd = gd->bd; - bd->bi_memstart =PHYSADDR (CONFIG_SYS_SDRAM_BASE ); - bd->bi_memsize =CONFIG_SYS_SDRAM_SIZE ; + bd->bi_dram[0 ].start =PHYSADDR (CONFIG_SYS_SDRAM_BASE ); + bd->bi_dram[0 ].size =CONFIG_SYS_SDRAM_SIZE ;return 0 ; }arch/xtensa/lib/bootm.c +2
-2@@ -48,8 +48,8 @@ static struct bp_tag *setup_memory_tag(struct bp_tag *params) params->size =sizeof (struct meminfo ); mem = (struct meminfo *)params->data; mem->type =MEMORY_TYPE_CONVENTIONAL ; - mem->start = bd->bi_memstart; - mem->end = bd->bi_memstart + bd->bi_memsize; + mem->start = bd->bi_dram[0 ].start; + mem->end = bd->bi_dram[0 ].start + bd->bi_dram[0 ].size;printf (" MEMORY: tag:0x%04x, type:0X%lx, start:0X%lx, end:0X%lx\n" ,BP_TAG_MEMORY , mem->type, mem->start, mem->end);board/Arcturus/ucp1020/spl.c +2
-2@@ -83,8 +83,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(CONFIG_SPL_GD_ADDR +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L2_ADDR ; - bd->bi_memsize =CONFIG_SYS_L2_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L2_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L2_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/p1010rdb/spl.c +2
-2@@ -69,8 +69,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(CONFIG_SPL_GD_ADDR +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L2_ADDR ; - bd->bi_memsize =CONFIG_SYS_L2_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L2_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L2_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/p1_p2_rdb_pc/spl.c +2
-2@@ -75,8 +75,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(CONFIG_SPL_GD_ADDR +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L2_ADDR ; - bd->bi_memsize =CONFIG_SYS_L2_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L2_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L2_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/t102xrdb/spl.c +2
-2@@ -103,8 +103,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(gd +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L3_ADDR ; - bd->bi_memsize =CONFIG_SYS_L3_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L3_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L3_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/t104xrdb/spl.c +2
-2@@ -94,8 +94,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(gd +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L3_ADDR ; - bd->bi_memsize =CONFIG_SYS_L3_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L3_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L3_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/t208xqds/spl.c +2
-2@@ -102,8 +102,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(gd +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L3_ADDR ; - bd->bi_memsize =CONFIG_SYS_L3_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L3_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L3_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/t208xrdb/spl.c +2
-2@@ -72,8 +72,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(gd +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L3_ADDR ; - bd->bi_memsize =CONFIG_SYS_L3_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L3_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L3_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/t4rdb/spl.c +2
-2@@ -75,8 +75,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(gd +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L3_ADDR ; - bd->bi_memsize =CONFIG_SYS_L3_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L3_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L3_SIZE ;arch_cpu_init ();get_clocks ();board/xilinx/zynqmp/zynqmp.c +0
-2@@ -467,10 +467,8 @@ int dram_init(void)#else int dram_init_banksize (void ) { -#if defined(CONFIG_NR_DRAM_BANKS ) gd->bd->bi_dram[0 ].start =CONFIG_SYS_SDRAM_BASE ; gd->bd->bi_dram[0 ].size =get_effective_memsize (); -#endif mem_map_fill ();cmd/bdinfo.c +2
-4@@ -49,7 +49,6 @@ void bdinfo_print_mhz(const char *name, unsigned long hz)static void print_bi_dram (const struct bd_info *bd) { -#ifdef CONFIG_NR_DRAM_BANKS int i;for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; ++i) {@@ -59,7 +58,6 @@ static void print_bi_dram(const struct bd_info *bd)bdinfo_print_num ("-> size" , bd->bi_dram[i].size); } } -#endif }__weak void arch_print_bdinfo (void )@@ -75,8 +73,8 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])#endif bdinfo_print_num ("boot_params" , (ulong )bd->bi_boot_params);print_bi_dram (bd); -bdinfo_print_num ("memstart" , (ulong )bd->bi_memstart); -print_phys_addr ("memsize" , bd->bi_memsize); +bdinfo_print_num ("memstart" , (ulong )bd->bi_dram[0 ].start); +print_phys_addr ("memsize" , bd->bi_dram[0 ].size);if (IS_ENABLED (CONFIG_SYS_HAS_SRAM )) {bdinfo_print_num ("sramstart" , (ulong )bd->bi_sramstart);bdinfo_print_num ("sramsize" , (ulong )bd->bi_sramsize);cmd/bedbug.c +1
-1@@ -348,7 +348,7 @@ int do_bedbug_stack(struct cmd_tbl *cmdtp, int flag, int argc,return 1 ; } - top = gd->bd->bi_memstart + gd->bd->bi_memsize; + top = gd->bd->bi_dram[0 ].start + gd->bd->bi_dram[0 ].size; depth =0 ;printf ("Depth PC\n" );common/board_f.c +1
-5@@ -216,7 +216,6 @@ static int show_dram_config(void) {unsigned long long size; -#ifdef CONFIG_NR_DRAM_BANKS int i;debug ("\nRAM Configuration:\n" );@@ -229,9 +228,6 @@ static int show_dram_config(void)#endif }debug ("\nDRAM: " ); -#else - size = gd->ram_size; -#endif print_size (size,"" );board_add_ram_info (0 );@@ -242,7 +238,7 @@ static int show_dram_config(void)__weak int dram_init_banksize (void ) { -#if defined(CONFIG_NR_DRAM_BANKS ) && defined(CONFIG_SYS_SDRAM_BASE ) +#if defined(CONFIG_SYS_SDRAM_BASE ) gd->bd->bi_dram[0 ].start =CONFIG_SYS_SDRAM_BASE ; gd->bd->bi_dram[0 ].size =get_effective_memsize ();#endif @@ -607,8 +603,11 @@ int setup_bdinfo(void) {struct bd_info *bd = gd->bd;
Quoted 9 lines
common/board_f.c int setup_bdinfo(void) · line 607
Quoted 4 lines
common/board_f.c +2
-2- bd->bi_memstart = gd->ram_base;/* start of memory */ - bd->bi_memsize = gd->ram_size;/* size in bytes */ +/* Only overwrite bi_dram[0] values if not already set */ +if (!bd->bi_dram[0 ].size) {This still look suspicious. When is bi_dram[0].size zero? I tried to trace source code.
dram_init_banksize()is always called beforesetup_bdinfo()which fills bi_dram[], so when can be dram size zero? Or I'm missing something?
dram_init_banksize() is always called earlier, yes. But its weak default only sets the bi_dram[] values when CONFIG_SYS_SDRAM_BASE is configured. I'm checking right now, if this might be a problem.
Quoted 263 lines
Quoted 263 lines
common/board_f.c +3
-0+ bd->bi_dram[0 ].start = gd->ram_base;/* start of memory */ + bd->bi_dram[0 ].size = gd->ram_size;/* size in bytes */ + }if (IS_ENABLED (CONFIG_SYS_HAS_SRAM )) { bd->bi_sramstart =CONFIG_SYS_SRAM_BASE ;/* start of SRAM */ common/image.c +1
-9@@ -668,10 +668,8 @@ ulong env_get_bootm_low(void)#if defined(CONFIG_SYS_SDRAM_BASE )return CONFIG_SYS_SDRAM_BASE ; -#elif defined(CONFIG_ARM ) || defined(CONFIG_MICROBLAZE ) -return gd->bd->bi_dram[0 ].start;#else -return 0 ; +return gd->bd->bi_dram[0 ].start;#endif }@@ -685,14 +683,8 @@ phys_size_t env_get_bootm_size(void)return tmp; } -#if (defined(CONFIG_ARM ) || defined(CONFIG_MICROBLAZE )) && \ - defined(CONFIG_NR_DRAM_BANKS ) start = gd->bd->bi_dram[0 ].start; size = gd->bd->bi_dram[0 ].size; -#else - start = gd->bd->bi_memstart; - size = gd->bd->bi_memsize; -#endif s =env_get ("bootm_low" );if (s)common/init/handoff.c +13
-20@@ -12,18 +12,15 @@ DECLARE_GLOBAL_DATA_PTR;void handoff_save_dram (struct spl_handoff *ho) { +struct bd_info *bd = gd->bd; +int i; + ho->ram_size = gd->ram_size; -#ifdef CONFIG_NR_DRAM_BANKS - { -struct bd_info *bd = gd->bd; -int i; - -for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) { - ho->ram_bank[i].start = bd->bi_dram[i].start; - ho->ram_bank[i].size = bd->bi_dram[i].size; - } + +for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) { + ho->ram_bank[i].start = bd->bi_dram[i].start; + ho->ram_bank[i].size = bd->bi_dram[i].size; } -#endif }void handoff_load_dram_size (struct spl_handoff *ho)@@ -33,15 +30,11 @@ void handoff_load_dram_size(struct spl_handoff *ho)void handoff_load_dram_banks (struct spl_handoff *ho) { -#ifdef CONFIG_NR_DRAM_BANKS - { -struct bd_info *bd = gd->bd; -int i; - -for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) { - bd->bi_dram[i].start = ho->ram_bank[i].start; - bd->bi_dram[i].size = ho->ram_bank[i].size; - } +struct bd_info *bd = gd->bd; +int i; + +for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) { + bd->bi_dram[i].start = ho->ram_bank[i].start; + bd->bi_dram[i].size = ho->ram_bank[i].size; } -#endif }drivers/pci/pci-uclass.c +1
-16@@ -871,6 +871,7 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node, ofnode node) {int pci_addr_cells, addr_cells, size_cells; +struct bd_info *bd = gd->bd;int cells_per_record;const u32 *prop;int len;@@ -938,9 +939,6 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node, }/* Add a region for our local memory */ -#ifdef CONFIG_NR_DRAM_BANKS -struct bd_info *bd = gd->bd; -if (!bd)return ;@@ -958,19 +956,6 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node, PCI_REGION_MEM | PCI_REGION_SYS_MEMORY); } } -#else -phys_addr_t base =0 , size; - - size = gd->ram_size; -#ifdef CONFIG_SYS_SDRAM_BASE - base =CONFIG_SYS_SDRAM_BASE ; -#endif -if (gd->pci_ram_top && gd->pci_ram_top < base + size) - size = gd->pci_ram_top - base; -if (size) -pci_set_region (hose->regions + hose->region_count++, base, - base, size,PCI_REGION_MEM |PCI_REGION_SYS_MEMORY ); -#endif return ; }drivers/video/cfb_console.c +1
-7@@ -1983,8 +1983,6 @@ static void *video_logo(void)static int cfb_fb_is_in_dram (void ) {struct bd_info *bd = gd->bd; -#if defined(CONFIG_ARM ) || defined(CONFIG_NDS32 ) || \ -defined(CONFIG_SANDBOX ) || defined(CONFIG_X86 )ulong start, end;int i;@@ -1995,11 +1993,7 @@ defined(CONFIG_SANDBOX) || defined(CONFIG_X86) (ulong)video_fb_address < end)return 1 ; } -#else -if ((ulong )video_fb_address >= bd->bi_memstart && - (ulong )video_fb_address < bd->bi_memstart + bd->bi_memsize) -return 1 ; -#endif +return 0 ; }include/asm-generic/u-boot.h +0
-4@@ -27,8 +27,6 @@#include <linux/types.h> struct bd_info { -unsigned long bi_memstart;/* start of DRAM memory */ -phys_size_t bi_memsize;/* size of DRAM memory in bytes */ unsigned long bi_flashstart;/* start of FLASH memory */ unsigned long bi_flashsize;/* size of FLASH memory */ unsigned long bi_flashoffset;/* reserved area for startup monitor */ @@ -70,12 +68,10 @@ struct bd_info {#endif ulong bi_arch_number;/* unique id for this board */ ulong bi_boot_params;/* where this board expects params */ -#ifdef CONFIG_NR_DRAM_BANKS struct {/* RAM configuration */ phys_addr_t start;phys_size_t size; } bi_dram[CONFIG_NR_DRAM_BANKS]; -#endif /* CONFIG_NR_DRAM_BANKS */ };#endif /* __ASSEMBLY__ */ include/handoff.h +0
-2@@ -20,12 +20,10 @@struct spl_handoff {struct arch_spl_handoff arch;u64 ram_size; -#ifdef CONFIG_NR_DRAM_BANKS struct {u64 start;u64 size; } ram_bank[CONFIG_NR_DRAM_BANKS ]; -#endif };void handoff_save_dram (struct spl_handoff *ho);lib/fdtdec.c +0
-5@@ -1055,8 +1055,6 @@ int fdtdec_setup_mem_size_base(void)return 0 ; } -#if defined(CONFIG_NR_DRAM_BANKS ) -static int get_next_memory_node (const void *blob,int mem) { do {@@ -1106,7 +1104,6 @@ int fdtdec_setup_memory_banksize(void)return 0 ; } -#endif #if CONFIG_IS_ENABLED (MULTI_DTB_FIT ) # if CONFIG_IS_ENABLED(MULTI_DTB_FIT_GZIP) ||\@@ -1569,7 +1566,6 @@ int fdtdec_resetup(int *rescan) }#endif -#ifdef CONFIG_NR_DRAM_BANKS int fdtdec_decode_ram_size (const void *blob,const char *area,int board_id,phys_addr_t *basep,phys_size_t *sizep,struct bd_info *bd)@@ -1675,6 +1671,5 @@ int fdtdec_decode_ram_size(const void *blob, const char *area, int board_id, return 0; } -#endif /* CONFIG_NR_DRAM_BANKS */ #endif /* !USE_HOSTCC */ lib/lmb.c +0
-7@@ -117,22 +117,15 @@ static void lmb_reserve_common(struct lmb *lmb, void *fdt_blob)/* Initialize the struct, add memory and call arch/board reserve functions */ void lmb_init_and_reserve (struct lmb *lmb,struct bd_info *bd,void *fdt_blob) { -#ifdef CONFIG_NR_DRAM_BANKS int i; -#endif lmb_init (lmb); -#ifdef CONFIG_NR_DRAM_BANKS for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) {if (bd->bi_dram[i].size) {lmb_add (lmb, bd->bi_dram[i].start, bd->bi_dram[i].size); } } -#else -if (bd->bi_memsize) -lmb_add (lmb, bd->bi_memstart, bd->bi_memsize); -#endif lmb_reserve_common (lmb, fdt_blob); }
Quoted 6 lines
Quoted 3 lines
Signature · 1 line
2.28.0For me it looks like that this patch is mixing different structures for ram size from different sources.
Again, it started as a "simple" search and replace. It seems, that I need to change this patch, so that the "correct" value is used in place of bi_memstart & bi_memsize instead of always using bi_dram[].
I'll rework this patch again.
Quoted 4 lines
It is really correct? Does not it break
other boards?I think that there is missing explanation of these changes.
Perhaps its also the patch history that you are missing. This patch started with a simple remove of the unreferenced CONFIG_NR_DRAM_BANKS code paths (as the patch subject still mentions). And its extended, after Daniel pointed out, that with the move of CONFIG_NR_DRAM_BANKS the usage of bi_memstart etc is now not 100% correct any more. He suggested to replace those references with bi_dram[].
I agree that this is a bit confusing. I'll rework this patch into multiple separate patches now instead. This will hopefully make it easier to follow the intention and review these changes.
Thanks,
Stefan
PATCH v3 1/1 CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always defined
Hello!
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
arch/mips/lib/bootm.c +0
-0@@ -242,7 +242,7 @@ static int boot_reloc_fdt(bootm_headers_t *images)#if CONFIG_IS_ENABLED (MIPS_BOOT_FDT ) &&CONFIG_IS_ENABLED (OF_LIBFDT )Quoted 8 lines
arch/mips/lib/bootm.c static int boot_reloc_fdt(bootm_headers_t *images) · line 246
Quoted 5 lines
arch/mips/lib/bootm.c +1
-1int arch_fixup_fdt (void *blob) { -u64 mem_start =virt_to_phys ((void *)gd->bd->bi_memstart); +u64 mem_start =virt_to_phys ((void *)gd->bd->bi_dram[0 ].start);u64 mem_size = gd->ram_size;I do not fully understand this change. Why on some places you are suing bi_dram[0].size and on some places
gd->ram_size?
Quoted 4 lines
This patch is mainly a search and replace s/bd->bi_memstart/bd->bi_dram[0].start. But as your test has shown, this is not always
correct.
Yes, this search+replace needs to be better reviewed and tested. Such big change has potential to break random stuff which nobody think about.
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
arch/mips/lib/bootm.c +0
-1@@ -607,8 +603,11 @@ int setup_bdinfo(void) {struct bd_info *bd = gd->bd; - bd->bi_memstart = gd->ram_base;/* start of memory */ Quoted 8 lines
arch/mips/lib/bootm.c int setup_bdinfo(void) · line 606
Quoted 3 lines
arch/mips/lib/bootm.c +2
-1- bd->bi_memsize = gd->ram_size;/* size in bytes */ +/* Only overwrite bi_dram[0] values if not already set */ +if (!bd->bi_dram[0 ].size) {This still look suspicious. When is bi_dram[0].size zero? I tried to trace source code.
dram_init_banksize()is always called beforesetup_bdinfo()which fills bi_dram[], so when can be dram size zero? Or I'm missing something?
Quoted 3 lines
dram_init_banksize()is always called earlier, yes. But its weak default only sets the bi_dram[] values whenCONFIG_SYS_SDRAM_BASEis configured. I'm checking right now, if this might be a problem.
Should not be in this case extended dram_init_banksize() to always properly fill bi_dram[] structure? Setting bi_dram[] on more places and doing overwriting could complicate things for future debugging or extending.
Quoted 12 lines
Quoted 2 lines
For me it looks like that this patch is mixing different structures for ram size from different sources.
Again, it started as a "simple" search and replace. It seems, that I need to change this patch, so that the "correct" value is used in place of
bi_memstart&bi_memsizeinstead of always using bi_dram[].I'll rework this patch again.
Quoted 3 lines
It is really correct? Does not it break
other boards?
Quoted 8 lines
Quoted 1 line
I think that there is missing explanation of these changes.
Perhaps its also the patch history that you are missing. This patch started with a simple remove of the unreferenced
CONFIG_NR_DRAM_BANKScode paths (as the patch subject still mentions). And its extended, after Daniel pointed out, that with the move ofCONFIG_NR_DRAM_BANKSthe usage ofbi_memstartetc is now not 100% correct any more. He suggested to replace those references with bi_dram[].
I have not seen patch history, only its current version which caused u-boot failure on n900. So I was not sure what is intension of this patch. Sorry for that.
I think 1:1 replacement is not such trivial as with more dram banks you would need to join address space from bi_dram[0], bi_dram[1], ... as previous code is expecting.
I would suggest that more people with different hardware affected by this change would test if everything is working fine.
I do not know how many boards have full boot test scenarios (from booting u-boot to booting kernel) like N900 and such tests are useful when playing with patches which changes such big parts.
I would suggest to other board maintainers to write or provides test suite as it can really help with catching such fatal errors.
I cannot believe that N900 was the only device on which u-boot stopped booting kernel. From that code it looks like that all OMAP3 devices must have been affected and possible any architecture with two or more dram banks.
Quoted 3 lines
I agree that this is a bit confusing. I'll rework this patch into multiple separate patches now instead. This will hopefully make it easier to follow the intention and review these changes.
Lokesh, do you have OMAP3 devices to test these future Stefan's patches? For me it looks like that OMAP3 is good candidate which can be affected by these changes if code is not properly reviewed.
PATCH v3 1/1 CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always defined
Am Mittwoch, den 12.08.2020, 14:37 +0200 schrieb Pali Roh?r:
Quoted 38 lines
Hello!
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
arch/mips/lib/bootm.c +0
-0@@ -242,7 +242,7 @@ static int boot_reloc_fdt(bootm_headers_t *images)#if CONFIG_IS_ENABLED (MIPS_BOOT_FDT ) &&CONFIG_IS_ENABLED (OF_LIBFDT )Quoted 8 lines
arch/mips/lib/bootm.c static int boot_reloc_fdt(bootm_headers_t *images) · line 246
Quoted 5 lines
arch/mips/lib/bootm.c +1
-1int arch_fixup_fdt (void *blob) { -u64 mem_start =virt_to_phys ((void *)gd->bd->bi_memstart); +u64 mem_start =virt_to_phys ((void *)gd->bd->bi_dram[0 ].start);u64 mem_size = gd->ram_size;I do not fully understand this change. Why on some places you are suing bi_dram[0].size and on some places
gd->ram_size?Quoted 4 lines
This patch is mainly a search and replace s/bd->bi_memstart/bd->bi_dram[0].start. But as your test has shown, this is not always
correct.Yes, this search+replace needs to be better reviewed and tested. Such big change has potential to break random stuff which nobody think about.
Quoted 13 lines
Quoted 12 lines
arch/mips/lib/bootm.c int setup_bdinfo(void) · line 606
Quoted 7 lines
arch/mips/lib/bootm.c +2
-2@@ -607,8 +603,11 @@ int setup_bdinfo(void) {struct bd_info *bd = gd->bd; - bd->bi_memstart = gd->ram_base;/* start of memory */ - bd->bi_memsize = gd->ram_size;/* size in bytes */ +/* Only overwrite bi_dram[0] values if not already set */ +if (!bd->bi_dram[0 ].size) {This still look suspicious. When is bi_dram[0].size zero? I tried to trace source code.
dram_init_banksize()is always called beforesetup_bdinfo()which fills bi_dram[], so when can be dram size zero? Or I'm missing something?
Quoted 8 lines
Quoted 3 lines
dram_init_banksize()is always called earlier, yes. But its weak default only sets the bi_dram[] values whenCONFIG_SYS_SDRAM_BASEis configured. I'm checking right now, if this might be a problem.Should not be in this case extended
dram_init_banksize()to always properly fill bi_dram[] structure? Setting bi_dram[] on more places and doing overwriting could complicate things for future debugging or extending.
for all users of bi_memstart/bi_memsize the search+replace should be enough. But in setup_bdinfo() it is wrong because it overrides the initialization done in dram_init_banksize(). But setup_bdinfo() is a new function due to some other bd_info refactoring merged two weeks ago and was not available in v2 of this patch. I guess N900 was still working with v2 and v3 now has this kind of merge conflict regression.
Just removing those lines without replacing with bi_dram should fix this:
bd->bi_memstart = gd->ram_base; /* start of memory */bd->bi_memsize = gd->ram_size; /* size in bytes */
BTW: looking deeper in the code and history I think bd_info.bi_dram is heavily misused as storage for DRAM configuration. Such information should be stored in global_data where generic code can access it if needed (e.g. LMB, fdt_fixup_memory_banks()). bd_info should just be initialized and used when needed to boot old kernels. Also there should be a Kconfig option to completely disable the support of bd_info.
Signature · 1 line
- Daniel
PATCH v3 1/1 CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always defined
Quoted 55 lines · Daniel Schwierzeck
Am Mittwoch, den 12.08.2020, 14:37 +0200 schrieb Pali Roh?r:
Quoted 38 lines
Hello!
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
arch/mips/lib/bootm.c +0
-0@@ -242,7 +242,7 @@ static int boot_reloc_fdt(bootm_headers_t *images)#if CONFIG_IS_ENABLED (MIPS_BOOT_FDT ) &&CONFIG_IS_ENABLED (OF_LIBFDT )Quoted 8 lines
arch/mips/lib/bootm.c static int boot_reloc_fdt(bootm_headers_t *images) · line 246
Quoted 5 lines
arch/mips/lib/bootm.c +1
-1int arch_fixup_fdt (void *blob) { -u64 mem_start =virt_to_phys ((void *)gd->bd->bi_memstart); +u64 mem_start =virt_to_phys ((void *)gd->bd->bi_dram[0 ].start);u64 mem_size = gd->ram_size;I do not fully understand this change. Why on some places you are suing bi_dram[0].size and on some places
gd->ram_size?Quoted 4 lines
This patch is mainly a search and replace s/bd->bi_memstart/bd->bi_dram[0].start. But as your test has shown, this is not always
correct.Yes, this search+replace needs to be better reviewed and tested. Such big change has potential to break random stuff which nobody think about.
Quoted 13 lines
Quoted 12 lines
arch/mips/lib/bootm.c int setup_bdinfo(void) · line 606
Quoted 7 lines
arch/mips/lib/bootm.c +2
-2@@ -607,8 +603,11 @@ int setup_bdinfo(void) {struct bd_info *bd = gd->bd; - bd->bi_memstart = gd->ram_base;/* start of memory */ - bd->bi_memsize = gd->ram_size;/* size in bytes */ +/* Only overwrite bi_dram[0] values if not already set */ +if (!bd->bi_dram[0 ].size) {This still look suspicious. When is bi_dram[0].size zero? I tried to trace source code.
dram_init_banksize()is always called beforesetup_bdinfo()which fills bi_dram[], so when can be dram size zero? Or I'm missing something?Quoted 8 lines
Quoted 3 lines
dram_init_banksize()is always called earlier, yes. But its weak default only sets the bi_dram[] values whenCONFIG_SYS_SDRAM_BASEis configured. I'm checking right now, if this might be a problem.Should not be in this case extended
dram_init_banksize()to always properly fill bi_dram[] structure? Setting bi_dram[] on more places and doing overwriting could complicate things for future debugging or extending.for all users of bi_memstart/bi_memsize the search+replace should be enough. But in
setup_bdinfo()it is wrong because it overrides the initialization done indram_init_banksize(). Butsetup_bdinfo()is a new function due to some otherbd_inforefactoring merged two weeks ago and was not available in v2 of this patch. I guess N900 was still working with v2 and v3 now has this kind of merge conflict regression.
Quoted 5 lines
Just removing those lines without replacing with
bi_dramshould fix this:
bd->bi_memstart=gd->ram_base; /* start of memory */bd->bi_memsize=gd->ram_size; /* size in bytes */
Yes. A new patchset will follow soon, which removes these assignments in setup_bdinfo() but also adds a default assignment to dram_init_banksize().
Quoted 4 lines
BTW: looking deeper in the code and history I think bd_info.bi_dram is heavily misused as storage for DRAM configuration. Such information should be stored in
global_datawhere generic code can access it if needed (e.g. LMB,fdt_fixup_memory_banks()).
I agree. Some of this is addressed in the upcoming patchset.
Quoted 3 lines
bd_infoshould just be
initialized and used when needed to boot old kernels. Also there should be aKconfigoption to completely disable the support ofbd_info.
I agree in general, but:
If we want to support booting of the old kernels (at least on PowerPC), then we can't remove bi_memstart/memsize from bd_info. This is a decision that we need to make. Currently my patches remove it and therefore at least booting of old PowerPC kernels using bd_info to transfer the memory infos to the kernel will not work any more. This could easily be changed by not removing those values from the struct and adding one assignment of them to some common place. I'm not sure if its worth it though. And I'm not even sure, if I can test this somehow, as I would need a PowerPC board that is supported in U-Boot & Linux for a very long time.
Thanks,
Stefan
PATCH v3 1/1 CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always defined
In reply to Stefan RoeseAm Mittwoch, den 12.08.2020, 09:44 +0200 schrieb Stefan Roese:
Quoted 436 lines
Since commit
86cf1c82850f("configs: MigrateCONFIG_NR_DRAM_BANKS") & commit999a772d9f24("Kconfig: MigrateCONFIG_NR_DRAM_BANKS"),CONFIG_NR_DRAM_BANKSis always defined with a value (4 is default). It makes no sense to still carry code that is guarded with "#ifndefCONFIG_NR_DRAM_BANKS" (and similar). This patch removes all these unreferenced code paths.Also complete remove
bi_memstart&bi_memsizefrom the board-info struct. As now bi_dram[] is always enabled and should be used instead. This removes the redundant varriables.Signed-off-by Stefan Roese <[email protected]>Cc Daniel Schwierzeck <[email protected]>Cc Tom Rini <[email protected]>Cc Ramon Fried <[email protected]>Cc Simon Glass <[email protected]>Cc Michal Simek <[email protected]>Cc Pali Roh?r <[email protected]>---
v3:
- Rebase on TOT
- Add check to not overwrite bi_dram[0] if already configured insetup_bdinfo(). This fixes the test issue with Nokia RX51.Azure test report success:
https://dev.azure.com/sr0718/u-boot/_build/results?buildId=26&view=resultsv2:
- Change all references tobi_memstart&bi_memsizeto bi_dram[0].start/ size and remove it from thebd_infostruct completely, as suggested by Danielapi/api_platform-mips.c | 4 ++-- api/api_platform-powerpc.c | 2 +- arch/mips/lib/boot.c | 2 +- arch/mips/lib/bootm.c | 2 +- arch/powerpc/cpu/mpc83xx/fdt.c | 2 +- arch/powerpc/cpu/mpc83xx/traps.c | 2 +- arch/powerpc/cpu/mpc85xx/fdt.c | 4 ++-- arch/powerpc/cpu/mpc85xx/traps.c | 2 +- arch/powerpc/cpu/mpc86xx/fdt.c | 2 +- arch/powerpc/cpu/mpc86xx/traps.c | 2 +- arch/powerpc/cpu/mpc8xx/fdt.c | 2 +- arch/powerpc/lib/bootm.c | 4 ++-- arch/x86/cpu/broadwell/cpu_from_spl.c | 2 -- arch/xtensa/lib/bdinfo.c | 4 ++-- arch/xtensa/lib/bootm.c | 4 ++-- board/Arcturus/ucp1020/spl.c | 4 ++-- board/freescale/p1010rdb/spl.c | 4 ++-- board/freescale/p1_p2_rdb_pc/spl.c | 4 ++-- board/freescale/t102xrdb/spl.c | 4 ++-- board/freescale/t104xrdb/spl.c | 4 ++-- board/freescale/t208xqds/spl.c | 4 ++-- board/freescale/t208xrdb/spl.c | 4 ++-- board/freescale/t4rdb/spl.c | 4 ++-- board/xilinx/zynqmp/zynqmp.c | 2 -- cmd/bdinfo.c | 6 ++--- cmd/bedbug.c | 2 +- common/board_f.c | 13 +++++------ common/image.c | 10 +------- common/init/handoff.c | 33 +++++++++++---------------- drivers/pci/pci-uclass.c | 17 +------------- drivers/video/cfb_console.c | 8 +------ include/asm-generic/u-boot.h | 4 ---- include/handoff.h | 2 -- lib/fdtdec.c | 5 ---- lib/lmb.c | 7 ------ 35 files changed, 60 insertions(+), 121 deletions(-)api/api_platform-mips.c +2
-2@@ -24,8 +24,8 @@ DECLARE_GLOBAL_DATA_PTR;int platform_sys_info (struct sys_info *si) { -platform_set_mr (si, gd->bd->bi_memstart, - gd->bd->bi_memsize,MR_ATTR_DRAM ); +platform_set_mr (si, gd->bd->bi_dram[0 ].start, + gd->bd->bi_dram[0 ].size,MR_ATTR_DRAM );return 1 ; }api/api_platform-powerpc.c +1
-1@@ -42,7 +42,7 @@ int platform_sys_info(struct sys_info *si) si->bar =0 ;#endif -platform_set_mr (si, gd->bd->bi_memstart, gd->bd->bi_memsize,MR_ATTR_DRAM ); +platform_set_mr (si, gd->bd->bi_dram[0 ].start, gd->bd->bi_dram[0 ].size,MR_ATTR_DRAM );platform_set_mr (si, gd->bd->bi_flashstart, gd->bd->bi_flashsize,MR_ATTR_FLASH );platform_set_mr (si, gd->bd->bi_sramstart, gd->bd->bi_sramsize,MR_ATTR_SRAM );arch/mips/lib/boot.c +1
-1@@ -17,7 +17,7 @@ unsigned long do_go_exec(ulong (*entry)(int, char * const []),* whole SDRAM area, since we don't know the size of the image * that was loaded. */ -flush_cache (gd->bd->bi_memstart, gd->ram_top - gd->bd->bi_memstart); +flush_cache (gd->bd->bi_dram[0 ].start, gd->ram_top - gd->bd->bi_dram[0 ].start);return entry (argc, argv); }arch/mips/lib/bootm.c +1
-1@@ -242,7 +242,7 @@ static int boot_reloc_fdt(bootm_headers_t *images)#if CONFIG_IS_ENABLED (MIPS_BOOT_FDT ) &&CONFIG_IS_ENABLED (OF_LIBFDT )int arch_fixup_fdt (void *blob) { -u64 mem_start =virt_to_phys ((void *)gd->bd->bi_memstart); +u64 mem_start =virt_to_phys ((void *)gd->bd->bi_dram[0 ].start);u64 mem_size = gd->ram_size;return fdt_fixup_memory_banks (blob, &mem_start, &mem_size,1 );arch/powerpc/cpu/mpc83xx/fdt.c +1
-1@@ -121,7 +121,7 @@ void ft_cpu_setup(void *blob, struct bd_info *bd) "clock-frequency", get_serial_clock(), 1);#endif -fdt_fixup_memory (blob, (u64 )bd->bi_memstart, (u64 )bd->bi_memsize); +fdt_fixup_memory (blob, (u64 )bd->bi_dram[0 ].start, (u64 )bd->bi_dram[0 ].size);#if defined(CONFIG_BOOTCOUNT_LIMIT ) && \ (defined(CONFIG_QE ) && !defined(CONFIG_ARCH_MPC831X ))arch/powerpc/cpu/mpc83xx/traps.c +1
-1@@ -23,7 +23,7 @@ DECLARE_GLOBAL_DATA_PTR;/* Returns 0 if exception not found and fixup otherwise. */ extern unsigned long search_exception_table (unsigned long ); -#define END_OF_MEM (gd->bd->bi_memstart + gd->bd->bi_memsize) +#define END_OF_MEM (gd->bd->bi_dram[0].start + gd->bd->bi_dram[0].size)/* * Trap & Exception support arch/powerpc/cpu/mpc85xx/fdt.c +2
-2@@ -672,10 +672,10 @@ void ft_cpu_setup(void *blob, struct bd_info *bd) "clock-frequency", get_bus_freq(0), 1);#endif -fdt_fixup_memory (blob, (u64 )bd->bi_memstart, (u64 )bd->bi_memsize); +fdt_fixup_memory (blob, (u64 )bd->bi_dram[0 ].start, (u64 )bd->bi_dram[0 ].size);#ifdef CONFIG_MP -ft_fixup_cpu (blob, (u64 )bd->bi_memstart + (u64 )bd->bi_memsize); +ft_fixup_cpu (blob, (u64 )bd->bi_dram[0 ].start + (u64 )bd->bi_dram[0 ].size);ft_fixup_num_cores (blob);#endif arch/powerpc/cpu/mpc85xx/traps.c +1
-1@@ -37,7 +37,7 @@ extern unsigned long search_exception_table(unsigned long);* amount of memory on the system if we're unable to keep all * the memory mapped in. */ -#define END_OF_MEM (gd->bd->bi_memstart + get_effective_memsize()) +#define END_OF_MEM (gd->bd->bi_dram[0].start + get_effective_memsize())static __inline__void set_tsr (unsigned long val) {arch/powerpc/cpu/mpc86xx/fdt.c +1
-1@@ -27,7 +27,7 @@ void ft_cpu_setup(void *blob, struct bd_info *bd)do_fixup_by_prop_u32 (blob,"device_type" ,"soc" ,4 ,"bus-frequency" , bd->bi_busfreq,1 ); -fdt_fixup_memory (blob, (u64 )bd->bi_memstart, (u64 )bd->bi_memsize); +fdt_fixup_memory (blob, (u64 )bd->bi_dram[0 ].start, (u64 )bd->bi_dram[0 ].size);#ifdef CONFIG_SYS_NS16550 do_fixup_by_compat_u32(blob, "ns16550",arch/powerpc/cpu/mpc86xx/traps.c +1
-1@@ -30,7 +30,7 @@ extern unsigned long search_exception_table(unsigned long);* amount of memory on the system if we're unable to keep all * the memory mapped in. */ -#define END_OF_MEM (gd->bd->bi_memstart + get_effective_memsize()) +#define END_OF_MEM (gd->bd->bi_dram[0].start + get_effective_memsize())/* * Trap & Exception support arch/powerpc/cpu/mpc8xx/fdt.c +1
-1@@ -25,5 +25,5 @@ void ft_cpu_setup(void *blob, struct bd_info *bd)do_fixup_by_compat_u32 (blob,"fsl,cpm-brg" ,"clock-frequency" , gd->arch.brg_clk,1 ); -fdt_fixup_memory (blob, (u64 )bd->bi_memstart, (u64 )bd->bi_memsize); +fdt_fixup_memory (blob, (u64 )bd->bi_dram[0 ].start, (u64 )bd->bi_dram[0 ].size); }arch/powerpc/lib/bootm.c +2
-2@@ -298,8 +298,8 @@ void boot_prep_vxworks(bootm_headers_t *images)if (!images->ft_addr)return ; - base = (u64 )gd->bd->bi_memstart; - size = (u64 )gd->bd->bi_memsize; + base = (u64 )gd->bd->bi_dram[0 ].start; + size = (u64 )gd->bd->bi_dram[0 ].size; off =fdt_path_offset (images->ft_addr,"/memory" );if (off <0 )arch/x86/cpu/broadwell/cpu_from_spl.c +0
-2@@ -53,14 +53,12 @@ void board_debug_uart_init(void)int dram_init_banksize (void ) { -#ifdef CONFIG_NR_DRAM_BANKS struct spl_handoff *ho; ho =bloblist_find (BLOBLISTT_SPL_HANDOFF ,sizeof (*ho));if (!ho)return log_msg_ret ("Missing SPL hand-off info" , -ENOENT );handoff_load_dram_banks (ho); -#endif return 0 ; }arch/xtensa/lib/bdinfo.c +2
-2@@ -15,8 +15,8 @@ int arch_setup_bdinfo(void) {struct bd_info *bd = gd->bd; - bd->bi_memstart =PHYSADDR (CONFIG_SYS_SDRAM_BASE ); - bd->bi_memsize =CONFIG_SYS_SDRAM_SIZE ; + bd->bi_dram[0 ].start =PHYSADDR (CONFIG_SYS_SDRAM_BASE ); + bd->bi_dram[0 ].size =CONFIG_SYS_SDRAM_SIZE ;return 0 ; }arch/xtensa/lib/bootm.c +2
-2@@ -48,8 +48,8 @@ static struct bp_tag *setup_memory_tag(struct bp_tag *params) params->size =sizeof (struct meminfo ); mem = (struct meminfo *)params->data; mem->type =MEMORY_TYPE_CONVENTIONAL ; - mem->start = bd->bi_memstart; - mem->end = bd->bi_memstart + bd->bi_memsize; + mem->start = bd->bi_dram[0 ].start; + mem->end = bd->bi_dram[0 ].start + bd->bi_dram[0 ].size;printf (" MEMORY: tag:0x%04x, type:0X%lx, start:0X%lx, end:0X%lx\n" ,BP_TAG_MEMORY , mem->type, mem->start, mem->end);board/Arcturus/ucp1020/spl.c +2
-2@@ -83,8 +83,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(CONFIG_SPL_GD_ADDR +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L2_ADDR ; - bd->bi_memsize =CONFIG_SYS_L2_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L2_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L2_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/p1010rdb/spl.c +2
-2@@ -69,8 +69,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(CONFIG_SPL_GD_ADDR +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L2_ADDR ; - bd->bi_memsize =CONFIG_SYS_L2_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L2_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L2_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/p1_p2_rdb_pc/spl.c +2
-2@@ -75,8 +75,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(CONFIG_SPL_GD_ADDR +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L2_ADDR ; - bd->bi_memsize =CONFIG_SYS_L2_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L2_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L2_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/t102xrdb/spl.c +2
-2@@ -103,8 +103,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(gd +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L3_ADDR ; - bd->bi_memsize =CONFIG_SYS_L3_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L3_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L3_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/t104xrdb/spl.c +2
-2@@ -94,8 +94,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(gd +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L3_ADDR ; - bd->bi_memsize =CONFIG_SYS_L3_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L3_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L3_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/t208xqds/spl.c +2
-2@@ -102,8 +102,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(gd +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L3_ADDR ; - bd->bi_memsize =CONFIG_SYS_L3_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L3_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L3_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/t208xrdb/spl.c +2
-2@@ -72,8 +72,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(gd +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L3_ADDR ; - bd->bi_memsize =CONFIG_SYS_L3_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L3_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L3_SIZE ;arch_cpu_init ();get_clocks ();board/freescale/t4rdb/spl.c +2
-2@@ -75,8 +75,8 @@ void board_init_r(gd_t *gd, ulong dest_addr) bd = (struct bd_info *)(gd +sizeof (gd_t));memset (bd,0 ,sizeof (struct bd_info )); gd->bd = bd; - bd->bi_memstart =CONFIG_SYS_INIT_L3_ADDR ; - bd->bi_memsize =CONFIG_SYS_L3_SIZE ; + bd->bi_dram[0 ].start =CONFIG_SYS_INIT_L3_ADDR ; + bd->bi_dram[0 ].size =CONFIG_SYS_L3_SIZE ;arch_cpu_init ();get_clocks ();board/xilinx/zynqmp/zynqmp.c +0
-2@@ -467,10 +467,8 @@ int dram_init(void)#else int dram_init_banksize (void ) { -#if defined(CONFIG_NR_DRAM_BANKS ) gd->bd->bi_dram[0 ].start =CONFIG_SYS_SDRAM_BASE ; gd->bd->bi_dram[0 ].size =get_effective_memsize (); -#endif mem_map_fill ();cmd/bdinfo.c +0
-2@@ -49,7 +49,6 @@ void bdinfo_print_mhz(const char *name, unsigned long hz)static void print_bi_dram (const struct bd_info *bd) { -#ifdef CONFIG_NR_DRAM_BANKS int i;for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; ++i) {@@ -59,7 +58,6 @@ static void print_bi_dram(const struct bd_info *bd)bdinfo_print_num ("-> size" , bd->bi_dram[i].size); } } -#endif }__weak void arch_print_bdinfo (void )
cmd/bdinfo.c int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) · line 77
Quoted 7 lines
cmd/bdinfo.c +2
-2@@ -75,8 +73,8 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])#endif bdinfo_print_num ("boot_params" , (ulong )bd->bi_boot_params);print_bi_dram (bd); -bdinfo_print_num ("memstart" , (ulong )bd->bi_memstart); -print_phys_addr ("memsize" , bd->bi_memsize); +bdinfo_print_num ("memstart" , (ulong )bd->bi_dram[0 ].start); +print_phys_addr ("memsize" , bd->bi_dram[0 ].size);
this would be redundant because the DRAM banks are already printed in print_bi_dram() above. You could just remove these two lines.
Signature · 1 line
- Daniel