All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bin Meng <bmeng.cn@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/4] Enable CONFIG_TIMER_EARLY with bootstage
Date: Wed, 26 Sep 2018 14:39:16 +0800	[thread overview]
Message-ID: <CAEUhbmWn=-WuryhQcU5QeQWewt1FH-ahU+02sKt3ayqg8Vp7cQ@mail.gmail.com> (raw)
In-Reply-To: <CAPnjgZ11_5rVQZ3W1MvjYEVkJSHNnLiK32sZT+3kSwMTms6VZw@mail.gmail.com>

Hi Simon,

On Wed, Sep 26, 2018 at 1:42 PM Simon Glass <sjg@chromium.org> wrote:
>
> Hi Bin,
>
> On 4 September 2018 at 03:06, Bin Meng <bmeng.cn@gmail.com> wrote:
> > Hi Simon,
> >
> > On Mon, Sep 3, 2018 at 7:02 AM Simon Glass <sjg@chromium.org> wrote:
> >>
> >> In initr_bootstage() we call bootstage_mark_name() which ends up calling
> >> timer_get_us(). This call happens before initr_dm(), which inits driver
> >> model.
> >>
> >> On x86 we set gd->timer to NULL in the transition from board_init_f()
> >
> > It's not just x86 we set gd->timer to NULL. It applied to all
> > architectures when CONFIG_TIMER is on.
> >
> >> to board_init_r(). See board_init_f_r() for this assignment. So U-Boot
> >> knows there is no timer available in the period immediately after
> >> relocation.
> >>
> >> On x86 the timer_get_us() call is implemented as calls to get_ticks() and
> >> get_tbclk(). Both of these call dm_timer_init() to set up the timer, if
> >> gd->timer is NULL and the early timer is not available.
> >>
> >> However dm_timer_init() cannot succeed before initr_dm() is called.
> >>
> >> So it seems that on x86 if we want to use CONFIG_BOOTSTAGE we must enable
> >> CONFIG_TIMER_EARLY. Update the Kconfig to handle this.
> >>
> >> Note: On most architectures we can rely on the pre-relocation memory still
> >> being available, so that gd->timer pointers to a valid timer device and
> >> everything works correctly. Admittedly this is not strictly correct since
> >> the timer device is set up by pre-relocation U-Boot, but normally this is
> >> fine. On x86 the 'CAR' (cache-as-RAM) memory used by pre-relocation U-Boot
> >> disappears in board_init_f_r() and any attempt to access it will hang.
> >> This is the reason why we must mark the timer as invalid when we get to
> >> board_init_f_r().
> >>
> >> Signed-off-by: Simon Glass <sjg@chromium.org>
> >> ---
> >>
> >>  drivers/timer/Kconfig | 3 +++
> >>  1 file changed, 3 insertions(+)
> >>
> >> diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig
> >> index 5ab6749193c..ff434de6f7c 100644
> >> --- a/drivers/timer/Kconfig
> >> +++ b/drivers/timer/Kconfig
> >> @@ -30,6 +30,9 @@ config TPL_TIMER
> >>  config TIMER_EARLY
> >>         bool "Allow timer to be used early in U-Boot"
> >>         depends on TIMER
> >> +       # initr_bootstage() requires a timer and is called before initr_dm()
> >> +       # so only the early timer is available
> >> +       default y if X86 && BOOTSTAGE
> >
> > Since this applies not only on x86, and given without TIMER_EARLY
> > BOOTSTAGE is broken, shouldn't we do this in BOOTSTAGE config instead:
> >
> > config BOOTSTAGE
> >          select TIMER_EARLY
>
> Well we could, but I suspect that would break things since the early
> timer is not supported by many boards. Also for most boards this
> doesn't actually work fine. x86 is really quite awful in that it has
> no SRAM and the CAR becomes inaccessible as soon as you turn on the
> cache!

It's true that early timer is supported by some limited boards, but
that's a different issue. For now that patch does not fix anything. If
we add BOOTSTAGE from either defconfig or 'menuconfig' for a board,
without adding TIMER_EARLY, it will for sure break.

Regards,
Bin

  reply	other threads:[~2018-09-26  6:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-02 23:02 [U-Boot] [PATCH 0/4] x86: Fix up some bootstage problems Simon Glass
2018-09-02 23:02 ` [U-Boot] [PATCH 1/4] Enable CONFIG_TIMER_EARLY with bootstage Simon Glass
2018-09-04  9:06   ` Bin Meng
2018-09-26  5:41     ` Simon Glass
2018-09-26  6:39       ` Bin Meng [this message]
2018-09-27 13:41         ` Simon Glass
2018-10-02 13:25           ` Bin Meng
2018-10-07  1:29             ` Bin Meng
2018-09-02 23:02 ` [U-Boot] [PATCH 2/4] chromebook_samus: Increase pre-relocation memory Simon Glass
2018-09-04  9:06   ` Bin Meng
2018-09-26  6:42     ` Bin Meng
2018-09-02 23:02 ` [U-Boot] [PATCH 3/4] binman: Add support for Intel reference code Simon Glass
2018-09-04  9:06   ` Bin Meng
2018-09-26  6:43     ` Bin Meng
2018-09-02 23:02 ` [U-Boot] [PATCH 4/4] Revert "x86: galileo: Fix boot failure" Simon Glass
2018-09-04  9:07   ` Bin Meng
2018-09-26  5:41     ` Simon Glass
2018-09-26  6:40       ` Bin Meng

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='CAEUhbmWn=-WuryhQcU5QeQWewt1FH-ahU+02sKt3ayqg8Vp7cQ@mail.gmail.com' \
    --to=bmeng.cn@gmail.com \
    --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.