Message ID | 54D0CA41.3030700@monstr.eu |
---|---|
State | RFC |
Delegated to: | Tom Rini |
Headers | show |
Hi Michal, On 3 February 2015 at 06:16, Michal Simek <monstr@monstr.eu> wrote: > Hi Simon, > > I am playing with driver model and I have moved uartlite to it and > it is working fine for normal u-boot +10k but SPL size is dramatically > bigger. Without DM I can fit to 3k but now it has ~16k. > > microblaze-generic: all +10759 bss +4 data +560 rodata +1379 > spl/u-boot-spl:all +9100 spl/u-boot-spl:bss -4 spl/u-boot-spl:data -48 > spl/u-boot-spl:rodata +5660 spl/u-boot-spl:text +3492 text +8816 > > This 9k is after removing all printf calling which is adding 6kB. > > > diff --git a/common/malloc_simple.c b/common/malloc_simple.c > index afdacff80d8e..a9e4d96738a0 100644 > --- a/common/malloc_simple.c > +++ b/common/malloc_simple.c > @@ -19,7 +19,7 @@ void *malloc_simple(size_t bytes) > > new_ptr = gd->malloc_ptr + bytes; > if (new_ptr > gd->malloc_limit) > - panic("Out of pre-reloc memory"); > + puts("Out of pre-reloc memory"); > ptr = map_sysmem(gd->malloc_base + gd->malloc_ptr, bytes); > gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr)); > return ptr; > diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c > index 3fc7104359d3..d56fafcb8ee2 100644 > --- a/drivers/serial/serial-uclass.c > +++ b/drivers/serial/serial-uclass.c > @@ -72,7 +72,7 @@ static void serial_find_console_or_panic(void) > if (uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) && > uclass_get_device(UCLASS_SERIAL, INDEX, &dev) && > (uclass_first_device(UCLASS_SERIAL, &dev) || !dev)) > - panic("No serial driver found"); > + puts("No serial driver found"); > #undef INDEX > gd->cur_serial_dev = dev; > } > > > Here is diff between versions. I have setup CONFIG_SYS_MALLOC_SIMPLE > Simon: Have you tried to to reduce size in this too? > Interesting part is that new uartlite functions are not called that's why I am expecting > any other problem. > > spl-u-boot-spl: add: 27/-13, grow: 2/-1 bytes: 4024/-576 (3448) > function old new delta > device_bind - 596 +596 > device_probe_child - 508 +508 > uclass_get - 296 +296 > lists_bind_drivers - 212 +212 > uclass_resolve_seq - 188 +188 > uclass_bind_device - 180 +180 > uclass_find_device_by_seq - 172 +172 > device_bind_by_name - 152 +152 > uclass_get_device_by_seq - 140 +140 > serial_find_console_or_panic - 136 +136 > uclass_find_device - 132 +132 > lists_driver_lookup_name - 128 +128 > uclass_first_device - 108 +108 > dm_init - 96 +96 > _serial_putc - 96 +96 > uclass_unbind_device - 92 +92 > malloc_simple - 92 +92 > uclass_get_device - 88 +88 > lists_uclass_lookup - 80 +80 > dm_init_and_scan - 80 +80 > calloc - 80 +80 > uclass_find - 72 +72 > uclass_pre_probe_child - 60 +60 > uclass_post_probe_device - 52 +52 > strcmp - 52 +52 > dm_scan_platdata - 52 +52 > serial_puts 44 80 +36 > device_probe - 32 +32 > board_init_r 232 248 +16 > serial_current 4 - -4 > userial0_setbrg 8 - -8 > serial_init 56 48 -8 > userial0_tstc 20 - -20 > userial0_puts 32 - -32 > userial0_putc 32 - -32 > userial0_init 32 - -32 > userial0_getc 32 - -32 > uartlite_serial_getc 40 - -40 > uartlite_serial0_device 48 - -48 > uartlite_serial_init 52 - -52 > uartlite_serial_puts 80 - -80 > uartlite_serial_putc 92 - -92 > get_current 96 - -96 I took a look at this quite recently and your numbers (4KB) are similar to mine - for ARM. I suppose. Actually on Tegra I see 5KB but I think that is due to GPIOs being used too. I expect Thumb will cut this by 20% or so. There is also a bug in gcc which causes the rodata to blow up. You might be seeing that also. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54303 I just got a response with a possible patch on the gcc mailing list. So this is very much work-in-progress. I see a few options: 1. Reduce functionality further, like the existing CONFIG_DM_WARN/DEVICE_REMOVE/STDIO but operating on things like device_bind/probe(). I have not seriously looked at this but I suspect it would be painful. 2. Support for static binding, i.e. declare a struct udevice directly, using const static init and perhaps some sort of macro to help thread tings together. Then we could add CONFIG_DM_BIND (to support binding new devices) and disable it for SPL. A bit ick but it might get us closer to running in a 4KB SRAM. If you have ideas/patches please send them through. Right now I need to get Kconfig support v2 landed, and we still need a few more gdata patches before we can enable DM in SPL anyway (Tom is looking at that). Regards, Simon
Hi Simon, On 02/03/2015 03:11 PM, Simon Glass wrote: > Hi Michal, > > On 3 February 2015 at 06:16, Michal Simek <monstr@monstr.eu> wrote: >> Hi Simon, >> >> I am playing with driver model and I have moved uartlite to it and >> it is working fine for normal u-boot +10k but SPL size is dramatically >> bigger. Without DM I can fit to 3k but now it has ~16k. >> >> microblaze-generic: all +10759 bss +4 data +560 rodata +1379 >> spl/u-boot-spl:all +9100 spl/u-boot-spl:bss -4 spl/u-boot-spl:data -48 >> spl/u-boot-spl:rodata +5660 spl/u-boot-spl:text +3492 text +8816 >> >> This 9k is after removing all printf calling which is adding 6kB. >> >> >> diff --git a/common/malloc_simple.c b/common/malloc_simple.c >> index afdacff80d8e..a9e4d96738a0 100644 >> --- a/common/malloc_simple.c >> +++ b/common/malloc_simple.c >> @@ -19,7 +19,7 @@ void *malloc_simple(size_t bytes) >> >> new_ptr = gd->malloc_ptr + bytes; >> if (new_ptr > gd->malloc_limit) >> - panic("Out of pre-reloc memory"); >> + puts("Out of pre-reloc memory"); >> ptr = map_sysmem(gd->malloc_base + gd->malloc_ptr, bytes); >> gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr)); >> return ptr; >> diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c >> index 3fc7104359d3..d56fafcb8ee2 100644 >> --- a/drivers/serial/serial-uclass.c >> +++ b/drivers/serial/serial-uclass.c >> @@ -72,7 +72,7 @@ static void serial_find_console_or_panic(void) >> if (uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) && >> uclass_get_device(UCLASS_SERIAL, INDEX, &dev) && >> (uclass_first_device(UCLASS_SERIAL, &dev) || !dev)) >> - panic("No serial driver found"); >> + puts("No serial driver found"); >> #undef INDEX >> gd->cur_serial_dev = dev; >> } >> >> >> Here is diff between versions. I have setup CONFIG_SYS_MALLOC_SIMPLE >> Simon: Have you tried to to reduce size in this too? >> Interesting part is that new uartlite functions are not called that's why I am expecting >> any other problem. >> >> spl-u-boot-spl: add: 27/-13, grow: 2/-1 bytes: 4024/-576 (3448) >> function old new delta >> device_bind - 596 +596 >> device_probe_child - 508 +508 >> uclass_get - 296 +296 >> lists_bind_drivers - 212 +212 >> uclass_resolve_seq - 188 +188 >> uclass_bind_device - 180 +180 >> uclass_find_device_by_seq - 172 +172 >> device_bind_by_name - 152 +152 >> uclass_get_device_by_seq - 140 +140 >> serial_find_console_or_panic - 136 +136 >> uclass_find_device - 132 +132 >> lists_driver_lookup_name - 128 +128 >> uclass_first_device - 108 +108 >> dm_init - 96 +96 >> _serial_putc - 96 +96 >> uclass_unbind_device - 92 +92 >> malloc_simple - 92 +92 >> uclass_get_device - 88 +88 >> lists_uclass_lookup - 80 +80 >> dm_init_and_scan - 80 +80 >> calloc - 80 +80 >> uclass_find - 72 +72 >> uclass_pre_probe_child - 60 +60 >> uclass_post_probe_device - 52 +52 >> strcmp - 52 +52 >> dm_scan_platdata - 52 +52 >> serial_puts 44 80 +36 >> device_probe - 32 +32 >> board_init_r 232 248 +16 >> serial_current 4 - -4 >> userial0_setbrg 8 - -8 >> serial_init 56 48 -8 >> userial0_tstc 20 - -20 >> userial0_puts 32 - -32 >> userial0_putc 32 - -32 >> userial0_init 32 - -32 >> userial0_getc 32 - -32 >> uartlite_serial_getc 40 - -40 >> uartlite_serial0_device 48 - -48 >> uartlite_serial_init 52 - -52 >> uartlite_serial_puts 80 - -80 >> uartlite_serial_putc 92 - -92 >> get_current 96 - -96 > > I took a look at this quite recently and your numbers (4KB) are > similar to mine - for ARM. I suppose. Actually on Tegra I see 5KB but > I think that is due to GPIOs being used too. I expect Thumb will cut > this by 20% or so. > > There is also a bug in gcc which causes the rodata to blow up. You > might be seeing that also. > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54303 > > I just got a response with a possible patch on the gcc mailing list. I don't think this is a problem on microblaze - or at least can't see any problem related to that. I put SPL to DDR and it is loading image from NOR flash and it is working with DM enabled. U-Boot SPL 2015.04-rc1-00030-g705afe6b99a2 (Feb 03 2015 - 15:48:09) U-Boot 2015.04-rc1-00030-g705afe6b99a2 (Feb 03 2015 - 15:48:09) DRAM: 128 MiB Flash: 32 MiB *** Warning - bad CRC, using default environment In: serial Out: serial Err: serial Net: Xelite.40e00000 U-BOOT for Xilinx-SP605-AXI-lite-14.7 U-Boot-mONStR> U-Boot-mONStR> I have done some changes in SPL to support DM > So this is very much work-in-progress. I see a few options: > > 1. Reduce functionality further, like the existing > CONFIG_DM_WARN/DEVICE_REMOVE/STDIO but operating on things like > device_bind/probe(). I have not seriously looked at this but I suspect > it would be painful. DM_WARN is printf at the end - that's why disable it. DEVICE_REMOVE is disable for me - don't want to remove devices. STDIO is disabled for SPL too. > > 2. Support for static binding, i.e. declare a struct udevice directly, > using const static init and perhaps some sort of macro to help thread > tings together. Then we could add CONFIG_DM_BIND (to support binding > new devices) and disable it for SPL. A bit ick but it might get us > closer to running in a 4KB SRAM. > > If you have ideas/patches please send them through. Right now I need > to get Kconfig support v2 landed, and we still need a few more gdata > patches before we can enable DM in SPL anyway (Tom is looking at > that). The whole DM code is new for me but I will see what I can do with it. Definitely any example will be more then helpful This is stat for the current version. spl-u-boot-spl: add: 39/-11, grow: 4/-1 bytes: 4668/-444 (4224) function old new delta device_bind - 596 +596 device_probe_child - 508 +508 uclass_get - 296 +296 lists_bind_drivers - 212 +212 uclass_resolve_seq - 188 +188 uclass_bind_device - 180 +180 uclass_find_device_by_seq - 172 +172 device_bind_by_name - 152 +152 uclass_get_device_by_seq - 140 +140 serial_find_console_or_panic - 136 +136 uclass_find_device - 132 +132 lists_driver_lookup_name - 128 +128 memset - 124 +124 uclass_first_device - 108 +108 dm_init - 96 +96 _serial_putc - 96 +96 uclass_unbind_device - 92 +92 malloc_simple - 92 +92 uclass_get_device - 88 +88 lists_uclass_lookup - 80 +80 dm_init_and_scan - 80 +80 calloc - 80 +80 uclass_find - 72 +72 uartlite_serial_probe - 68 +68 _u_boot_list_2_driver_2_uartlite_serial - 68 +68 _u_boot_list_2_driver_2_root_driver - 68 +68 uartlite_serial_tstc - 64 +64 _u_boot_list_2_uclass_2_serial - 64 +64 _u_boot_list_2_uclass_2_root - 64 +64 uclass_pre_probe_child - 60 +60 serial_post_probe - 56 +56 uclass_post_probe_device - 52 +52 strcmp - 52 +52 dm_scan_platdata - 52 +52 serial_puts 44 80 +36 device_probe - 32 +32 dev_get_platdata - 20 +20 uartlite_serial_getc 40 56 +16 board_init_r 216 232 +16 uartlite_serial_putc 92 104 +12 serial_pre_remove - 8 +8 _u_boot_list_2_driver_info_2_uartlite0 - 8 +8 plat_uartlite_0 - 4 +4 serial_current 4 - -4 userial0_setbrg 8 - -8 serial_init 56 48 -8 userial0_tstc 20 - -20 userial0_puts 32 - -32 userial0_putc 32 - -32 userial0_init 32 - -32 userial0_getc 32 - -32 uartlite_serial0_device 48 - -48 uartlite_serial_init 52 - -52 uartlite_serial_puts 80 - -80 get_current 96 - -96 Thanks, Michal
Hi Michal, On 3 February 2015 at 08:46, Michal Simek <monstr@monstr.eu> wrote: > Hi Simon, > > On 02/03/2015 03:11 PM, Simon Glass wrote: >> Hi Michal, >> >> On 3 February 2015 at 06:16, Michal Simek <monstr@monstr.eu> wrote: >>> Hi Simon, >>> >>> I am playing with driver model and I have moved uartlite to it and >>> it is working fine for normal u-boot +10k but SPL size is dramatically >>> bigger. Without DM I can fit to 3k but now it has ~16k. >>> >>> microblaze-generic: all +10759 bss +4 data +560 rodata +1379 >>> spl/u-boot-spl:all +9100 spl/u-boot-spl:bss -4 spl/u-boot-spl:data -48 >>> spl/u-boot-spl:rodata +5660 spl/u-boot-spl:text +3492 text +8816 >>> >>> This 9k is after removing all printf calling which is adding 6kB. >>> >>> >>> diff --git a/common/malloc_simple.c b/common/malloc_simple.c >>> index afdacff80d8e..a9e4d96738a0 100644 >>> --- a/common/malloc_simple.c >>> +++ b/common/malloc_simple.c >>> @@ -19,7 +19,7 @@ void *malloc_simple(size_t bytes) >>> >>> new_ptr = gd->malloc_ptr + bytes; >>> if (new_ptr > gd->malloc_limit) >>> - panic("Out of pre-reloc memory"); >>> + puts("Out of pre-reloc memory"); >>> ptr = map_sysmem(gd->malloc_base + gd->malloc_ptr, bytes); >>> gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr)); >>> return ptr; >>> diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c >>> index 3fc7104359d3..d56fafcb8ee2 100644 >>> --- a/drivers/serial/serial-uclass.c >>> +++ b/drivers/serial/serial-uclass.c >>> @@ -72,7 +72,7 @@ static void serial_find_console_or_panic(void) >>> if (uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) && >>> uclass_get_device(UCLASS_SERIAL, INDEX, &dev) && >>> (uclass_first_device(UCLASS_SERIAL, &dev) || !dev)) >>> - panic("No serial driver found"); >>> + puts("No serial driver found"); >>> #undef INDEX >>> gd->cur_serial_dev = dev; >>> } >>> >>> >>> Here is diff between versions. I have setup CONFIG_SYS_MALLOC_SIMPLE >>> Simon: Have you tried to to reduce size in this too? >>> Interesting part is that new uartlite functions are not called that's why I am expecting >>> any other problem. >>> >>> spl-u-boot-spl: add: 27/-13, grow: 2/-1 bytes: 4024/-576 (3448) >>> function old new delta >>> device_bind - 596 +596 >>> device_probe_child - 508 +508 >>> uclass_get - 296 +296 >>> lists_bind_drivers - 212 +212 >>> uclass_resolve_seq - 188 +188 >>> uclass_bind_device - 180 +180 >>> uclass_find_device_by_seq - 172 +172 >>> device_bind_by_name - 152 +152 >>> uclass_get_device_by_seq - 140 +140 >>> serial_find_console_or_panic - 136 +136 >>> uclass_find_device - 132 +132 >>> lists_driver_lookup_name - 128 +128 >>> uclass_first_device - 108 +108 >>> dm_init - 96 +96 >>> _serial_putc - 96 +96 >>> uclass_unbind_device - 92 +92 >>> malloc_simple - 92 +92 >>> uclass_get_device - 88 +88 >>> lists_uclass_lookup - 80 +80 >>> dm_init_and_scan - 80 +80 >>> calloc - 80 +80 >>> uclass_find - 72 +72 >>> uclass_pre_probe_child - 60 +60 >>> uclass_post_probe_device - 52 +52 >>> strcmp - 52 +52 >>> dm_scan_platdata - 52 +52 >>> serial_puts 44 80 +36 >>> device_probe - 32 +32 >>> board_init_r 232 248 +16 >>> serial_current 4 - -4 >>> userial0_setbrg 8 - -8 >>> serial_init 56 48 -8 >>> userial0_tstc 20 - -20 >>> userial0_puts 32 - -32 >>> userial0_putc 32 - -32 >>> userial0_init 32 - -32 >>> userial0_getc 32 - -32 >>> uartlite_serial_getc 40 - -40 >>> uartlite_serial0_device 48 - -48 >>> uartlite_serial_init 52 - -52 >>> uartlite_serial_puts 80 - -80 >>> uartlite_serial_putc 92 - -92 >>> get_current 96 - -96 >> >> I took a look at this quite recently and your numbers (4KB) are >> similar to mine - for ARM. I suppose. Actually on Tegra I see 5KB but >> I think that is due to GPIOs being used too. I expect Thumb will cut >> this by 20% or so. >> >> There is also a bug in gcc which causes the rodata to blow up. You >> might be seeing that also. >> >> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54303 >> >> I just got a response with a possible patch on the gcc mailing list. > > I don't think this is a problem on microblaze - or at least can't see > any problem related to that. OK good. > > > I put SPL to DDR and it is loading image from NOR flash and it is working > with DM enabled. > > U-Boot SPL 2015.04-rc1-00030-g705afe6b99a2 (Feb 03 2015 - 15:48:09) > > > U-Boot 2015.04-rc1-00030-g705afe6b99a2 (Feb 03 2015 - 15:48:09) > > DRAM: 128 MiB > Flash: 32 MiB > *** Warning - bad CRC, using default environment > > In: serial > Out: serial > Err: serial > Net: Xelite.40e00000 > U-BOOT for Xilinx-SP605-AXI-lite-14.7 > > U-Boot-mONStR> > U-Boot-mONStR> > > I have done some changes in SPL to support DM > > >> So this is very much work-in-progress. I see a few options: >> >> 1. Reduce functionality further, like the existing >> CONFIG_DM_WARN/DEVICE_REMOVE/STDIO but operating on things like >> device_bind/probe(). I have not seriously looked at this but I suspect >> it would be painful. > > DM_WARN is printf at the end - that's why disable it. DEVICE_REMOVE > is disable for me - don't want to remove devices. > > STDIO is disabled for SPL too. Yes these are the default. > >> >> 2. Support for static binding, i.e. declare a struct udevice directly, >> using const static init and perhaps some sort of macro to help thread >> tings together. Then we could add CONFIG_DM_BIND (to support binding >> new devices) and disable it for SPL. A bit ick but it might get us >> closer to running in a 4KB SRAM. >> >> If you have ideas/patches please send them through. Right now I need >> to get Kconfig support v2 landed, and we still need a few more gdata >> patches before we can enable DM in SPL anyway (Tom is looking at >> that). > > The whole DM code is new for me but I will see what I can do with it. > Definitely any example will be more then helpful Well first start with an objective (i.e. what you want the side to be!). See u-boot-dm/spl-working for current tegra approach. > > This is stat for the current version. > > > spl-u-boot-spl: add: 39/-11, grow: 4/-1 bytes: 4668/-444 (4224) > function old new delta > device_bind - 596 +596 > device_probe_child - 508 +508 > uclass_get - 296 +296 > lists_bind_drivers - 212 +212 > uclass_resolve_seq - 188 +188 > uclass_bind_device - 180 +180 > uclass_find_device_by_seq - 172 +172 > device_bind_by_name - 152 +152 > uclass_get_device_by_seq - 140 +140 > serial_find_console_or_panic - 136 +136 > uclass_find_device - 132 +132 > lists_driver_lookup_name - 128 +128 > memset - 124 +124 > uclass_first_device - 108 +108 > dm_init - 96 +96 > _serial_putc - 96 +96 > uclass_unbind_device - 92 +92 > malloc_simple - 92 +92 > uclass_get_device - 88 +88 > lists_uclass_lookup - 80 +80 > dm_init_and_scan - 80 +80 > calloc - 80 +80 > uclass_find - 72 +72 > uartlite_serial_probe - 68 +68 > _u_boot_list_2_driver_2_uartlite_serial - 68 +68 > _u_boot_list_2_driver_2_root_driver - 68 +68 > uartlite_serial_tstc - 64 +64 > _u_boot_list_2_uclass_2_serial - 64 +64 > _u_boot_list_2_uclass_2_root - 64 +64 > uclass_pre_probe_child - 60 +60 > serial_post_probe - 56 +56 > uclass_post_probe_device - 52 +52 > strcmp - 52 +52 > dm_scan_platdata - 52 +52 > serial_puts 44 80 +36 > device_probe - 32 +32 > dev_get_platdata - 20 +20 > uartlite_serial_getc 40 56 +16 > board_init_r 216 232 +16 > uartlite_serial_putc 92 104 +12 > serial_pre_remove - 8 +8 > _u_boot_list_2_driver_info_2_uartlite0 - 8 +8 > plat_uartlite_0 - 4 +4 > serial_current 4 - -4 > userial0_setbrg 8 - -8 > serial_init 56 48 -8 > userial0_tstc 20 - -20 > userial0_puts 32 - -32 > userial0_putc 32 - -32 > userial0_init 32 - -32 > userial0_getc 32 - -32 > uartlite_serial0_device 48 - -48 > uartlite_serial_init 52 - -52 > uartlite_serial_puts 80 - -80 > get_current 96 - -96 Regards, Simon
diff --git a/common/malloc_simple.c b/common/malloc_simple.c index afdacff80d8e..a9e4d96738a0 100644 --- a/common/malloc_simple.c +++ b/common/malloc_simple.c @@ -19,7 +19,7 @@ void *malloc_simple(size_t bytes) new_ptr = gd->malloc_ptr + bytes; if (new_ptr > gd->malloc_limit) - panic("Out of pre-reloc memory"); + puts("Out of pre-reloc memory"); ptr = map_sysmem(gd->malloc_base + gd->malloc_ptr, bytes); gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr)); return ptr; diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 3fc7104359d3..d56fafcb8ee2 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -72,7 +72,7 @@ static void serial_find_console_or_panic(void) if (uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) && uclass_get_device(UCLASS_SERIAL, INDEX, &dev) && (uclass_first_device(UCLASS_SERIAL, &dev) || !dev)) - panic("No serial driver found"); + puts("No serial driver found"); #undef INDEX gd->cur_serial_dev = dev; }