From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 00/16] RFC: Board init using driver model
Date: Wed, 22 Mar 2017 07:05:38 -0600 [thread overview]
Message-ID: <CAPnjgZ3gd_VcFtt=fK+V+pDqUNHA9eLaDZRYYXuU4vB8EKme=g@mail.gmail.com> (raw)
In-Reply-To: <20170320004704.GR19897@bill-the-cat>
Hi Tom,
On 19 March 2017 at 18:47, Tom Rini <trini@konsulko.com> wrote:
> On Sun, Mar 19, 2017 at 12:59:19PM -0600, Simon Glass wrote:
>> At present we have a lot of ad-hoc init functions related to boards, for
>> example board_early_init_f(), board_misc_init_f() and dram_init().
>>
>> There are used in different ways by different boards as useful hooks to
>> do the required init and sequence it correctly. Some functions are always
>> enabled but have a __weak default. Some are controlled by the existence
>> of a CONFIG.
>>
>> There are two main init sequences: board_init_f() (f for running from
>> read-only flash) which runs before relocation and board_init_r() (r for
>> relocated) which runs afterwards.
>>
>> One problem with the current sequence is that it has a lot of
>> arch-specific #ifdefs around various functions. There are also #ifdefs
>> for various features. There has been quite a bit of discussion about how
>> to tidy this up and at least one RFC series[1].
>>
>> Now that we have driver model we can use this to deal with the init
>> sequences. This approach has several advantages:
>>
>> - We have a path to remove the #ifdefs
>> - It is easy for multiple parts of the code to implement the same hook
>> - We can track what is called and what is not
>> - We don't need weak functions
>> - We can eventually adjust the sequence to improve naming or to add new
>> init phases
>> - It provides a model for how we might deal with ft_board_setup() and
>> friends
>>
>> This series starts the process of replacing the pre-relocation init
>> sequence with a driver-model solution. It defines a uclass, adds tests
>> and converts sandbox and a few x86 boards over to use this new setup.
>>
>> This series is not ready for use yet as the rest of the init sequence
>> hooks need to be converted. But there is enough here to show the idea.
>>
>> Comments welcome.
>>
>> [1] https://lists.denx.de/pipermail/u-boot/2011-August/098718.html
>
> How does this look, size wise? With all of these conversions and
> clean-ups, we really need to be size concious as well as it all keeps
> adding up. Thanks!
It include size a bit - e.g. x86 808 bytes of text, although that does
include a few extra features.
11: dm: board: Add documentation
16: dm: x86: board: ivybridge: Remove old board init code
x86: (for 1/1 boards) all +4331.0 bss +2944.0 data +252.0
rodata +327.0 text +808.0
chromebook_link: all +4331 bss +2944 data +252 rodata +327 text +808
u-boot: add: 22/0, grow: 1/-4 bytes: 3012/-2183 (829)
function old new delta
ivybridge_dram_init - 1956 +1956
cpu_x86_ivybridge_phase - 151 +151
board_walk_phase_count - 145 +145
ivybridge_checkcpu - 96 +96
board_phase - 95 +95
do_board - 77 +77
cpu_print_info - 76 +76
_u_boot_list_2_uclass_2_board - 72 +72
_u_boot_list_2_driver_2_cpu_x86_ivybridge_board_drv
- 68 +68
_u_boot_list_2_driver_2__cpu_x86_board_drv -
68 +68
board_walk_phase - 28 +28
board_walk_opt_phase - 28 +28
_u_boot_list_2_cmd_2_board - 28 +28
board_support_phase - 27 +27
board_support_phase_mask - 20 +20
cpu_x86_phase - 14 +14
misc_init_f - 10 +10
cpu_x86_ivybridge_board_probe - 10 +10
cpu_x86_board_probe - 10 +10
checkcpu - 10 +10
_u_boot_list_2_driver_info_2_cpu_x86_ivybridge_board
- 8 +8
_u_boot_list_2_driver_info_2_cpu_x86_board -
8 +8
board_early_init_f 3 10 +7
reserve_arch 14 10 -4
arch_cpu_init_dm 120 7 -113
print_cpuinfo 125 5 -120
dram_init 1956 10 -1946
(no errors to report)
I think I can use a linker-list approach to reduce the overhead. But I
still think the driver has value as it provides a means of adding
hooks to do board-specific things from drivers, something that we keep
running into. Also the idea of a board 'driver' seems conceptually
useful.
So one approach would be to have:
1. A linker-list-based board hook setup, where you can declare, for example:
static int ivybridge_dram_init(void)
{
...
}
U_BOOT_BOARD_HOOK(ivybridge_dram_init, BOARD_F_DRAM_INIT);
This should be pretty cheap, perhaps <200 bytes with some care.
2. An optional BOARD uclass which can be used for more involved
situations, but with a higher code size penalty.
Regards,
Simon
next prev parent reply other threads:[~2017-03-22 13:05 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-19 18:59 [U-Boot] [PATCH 00/16] RFC: Board init using driver model Simon Glass
2017-03-19 18:59 ` [U-Boot] [PATCH 01/16] x86: Drop leading spaces in cpu_x86_get_desc() Simon Glass
2017-04-12 3:09 ` Bin Meng
2017-04-18 7:34 ` Bin Meng
2017-03-19 18:59 ` [U-Boot] [PATCH 02/16] x86: Display the SPL banner only once Simon Glass
2017-04-12 3:09 ` Bin Meng
2017-04-12 3:29 ` Simon Glass
2017-04-18 7:30 ` Bin Meng
2017-04-18 7:34 ` Bin Meng
2017-03-19 18:59 ` [U-Boot] [PATCH 03/16] x86: config: Enable dhrystone command for link Simon Glass
2017-04-12 3:09 ` Bin Meng
2017-04-18 7:34 ` Bin Meng
2017-03-19 18:59 ` [U-Boot] [PATCH 04/16] dm: board: Add a uclass for init functions Simon Glass
2017-03-20 7:54 ` Igor Grinberg
2017-03-22 13:05 ` Simon Glass
2017-03-19 18:59 ` [U-Boot] [PATCH 05/16] dm: board: Add a command to view phase info Simon Glass
2017-03-19 18:59 ` [U-Boot] [PATCH 06/16] dm: board: Adjust pre-relocation init hooks Simon Glass
2017-03-19 18:59 ` [U-Boot] [PATCH 07/16] dm: board: Support printing CPU info using the uclass Simon Glass
2017-03-19 18:59 ` [U-Boot] [PATCH 08/16] dm: sandbox: Convert to using driver-model baord init Simon Glass
2017-03-19 18:59 ` [U-Boot] [PATCH 09/16] dm: board: Add tests for the board uclass Simon Glass
2017-03-19 18:59 ` [U-Boot] [PATCH 10/16] dm: board: Add documentation Simon Glass
2017-03-19 18:59 ` [U-Boot] [PATCH 11/16] dm: x86: board: Enable CONFIG_BOARD Simon Glass
2017-03-19 18:59 ` [U-Boot] [PATCH 12/16] dm: x86: board: Add a BOARD_F_RESERVE_ARCH driver Simon Glass
2017-03-19 18:59 ` [U-Boot] [PATCH 13/16] dm: x86: board: ivybridge: Add support for CONFIG_BOARD Simon Glass
2017-03-19 18:59 ` [U-Boot] [PATCH 14/16] dm: x86: board: ivybridge: Switch to use CONFIG_BOARD Simon Glass
2017-03-19 18:59 ` [U-Boot] [PATCH 15/16] dm: x86: board: ivybridge: Remove old board init code Simon Glass
2017-03-19 18:59 ` [U-Boot] [PATCH 16/16] dm: board: Add information about the new board init to the README Simon Glass
2017-03-20 0:47 ` [U-Boot] [PATCH 00/16] RFC: Board init using driver model Tom Rini
2017-03-22 13:05 ` Simon Glass [this message]
2017-03-22 14:37 ` Tom Rini
2017-03-22 14:43 ` Simon Glass
2017-03-22 15:13 ` Tom Rini
2017-04-01 4:21 ` Simon Glass
2017-04-12 2:39 ` Bin Meng
2017-04-12 3:30 ` Simon Glass
2017-03-20 7:30 ` Igor Grinberg
2017-03-22 13:26 ` Simon Glass
2017-03-22 16:00 ` york sun
2017-04-01 4:21 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAPnjgZ3gd_VcFtt=fK+V+pDqUNHA9eLaDZRYYXuU4vB8EKme=g@mail.gmail.com' \
--to=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.