From: Graeme Russ <graeme.russ@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 01/21] Define new system_restart() and emergency_restart()
Date: Tue, 22 Mar 2011 23:05:46 +1100 [thread overview]
Message-ID: <4D88909A.80508@gmail.com> (raw)
In-Reply-To: <20110321120054.71E63DD9C74@gemini.denx.de>
On 21/03/11 23:00, Wolfgang Denk wrote:
> Dear Graeme Russ,
>
> In message <4D8739F6.5040805@gmail.com> you wrote:
>>
>> I kind of like the idea of different reset sources (CPU exception, hardware
>> failure, user initiated) but agree copying the linux architecture is over
>> the top.
>
> What's the difference as far as do_reset() is concenred? It shall
> just (hard) reset the system, nothing else.
>
>> Is there any reason reset() could not take a 'reason' parameter? It could
>> be a bit-mask with CPU, SOC and arch reserved bits (unhandled exception,
>> user initiated, panic etc) and board specific bits
>
> What for? To perform the intended purpose, no parameter is needed.
>
>> Board or arch specific code could handle different reasons however they
>> please (like logging it in NVRAM prior to restart, gracefully shutting down
>> multiple CPU's, clearing DMA buffers etc)
>
> That would be a layer higher than do_reset() (for example, in
> panic()).
Hmmm, but panic() is defined in lib/vsprintf.c with no possibility for it
to be overridden in any arch or board specific way
>
>> All 'hang', 'panic', 'reset' etc code can be simplified into a single code
>> path (although calling 'reset' to 'hang' is a bit odd)
>
> hang() and reset() are intentionally very different things. A call to
> hang() is supposed to hang (surprise, surprise!) infinitely. It must
> not cause a reset.
As I said, calling reset() to hang is odd :)
>
> panic() is a higher software layer. It probably results in calling
> reset() in the end.
>
Unless CONFIG_PANIC_HANG is defined...
Looking into the code
panic():
- ~130 call sites
- Implemented in lib/vsprintf.c
- Calls do_reset() if CONFIG_PANIC_HANG is not defined
- Calls hang() if CONFIG_PANIC_HANG is defined
hang():
- ~180 call sites using hang() and hang ()
- Implemented in arch\lib\board.c
- ARM, i386, m68k, microblaze, mips, prints "### ERROR ### Please RESET
the board ###\n" and loops
- avr32 prints nothing and loops
- Blackfin can set status LEDs based on #define, prints "### ERROR ###
Please RESET the board ###\n" and triggers a breakpoint if a JTAG debugger
is connected
- nios2 disables interrupts then does the same as ARM et all
- powerpc is similar to ARM et al but also calls show_boot_progress(-30)
- sh - same as ARM et al but prints "Board ERROR\n"
- sparc - if CONFIG_SHOW_BOOT_PROGRESS defined, same as powerpc, else
same as ARM et al
So hang() could easily be weakly implemented in common\ which would allow
arch and board specific overrides
do_reset():
- ~70 call sites
- 39 implemetations
- Implemented all over the place (arch/cpu/, arch/lib, board/)
- Only ARM is in arch/lib which could likely be moved to arch/cpu
- Is U_BOOT_CMD
- m68k has a number of very similar/identical implementations
- Is not weak - Cannot be overridden at the board level
- Ouch, PPC is real ugly:
#if !defined(CONFIG_PCIPPC2) && \
!defined(CONFIG_BAB7xx) && \
!defined(CONFIG_ELPPC) && \
!defined(CONFIG_PPMC7XX)
/* no generic way to do board reset. simply call soft_reset. */
int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
...
Boards can thus provide their own do_reset()
- Wow, m68k/cpu/mcf52x2/cpu.c is even uglier - 7 definitions selectable
by #ifdef's
- Because do_reset() is U_BOOT_CMD, practically every call is:
do_reset (NULL, 0, 0, NULL) - do_bootm() does pass it's args onto
do_reset()
- No implementation of do_reset() uses any args anyway
reset():
- does not exist (as far as I can tell)
So, maybe we could replace do_reset() with a weak reset() function defined
in arch/cpu which can be overridden at the board level. All existing calls
to do_reset() can be converted to simply reset()
The U_BOOT_CMD do_reset() would simply call reset()
Could many of the current calls to do_reset() be replaced with calls to
panic()?
I still like the idea of passing a 'reason' to reset() / panic() - Could we
change panic() to:
void panic(u32 reason, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
vprintf(fmt, args);
putc('\n');
va_end(args);
if (reason |= PANIC_FLAG_HANG)
hang(reason);
else
reset(reason);
}
Anywhere in the code that needed to hang has a choice - hang(reason) or
panic(reason | PANIC_FLAG_HANG)
Default implementations of hang() and reset() would just ignore reason.
Board specific code can use reason to do one last boot_progress(), set LED
states etc.
Regards,
Graeme
next prev parent reply other threads:[~2011-03-22 12:05 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-07 17:37 [U-Boot] [PATCH 0/21] Generic cross-architecture system restart support Kyle Moffett
2011-03-07 17:37 ` [U-Boot] [PATCH 01/21] Define new system_restart() and emergency_restart() Kyle Moffett
2011-03-07 21:40 ` Mike Frysinger
2011-03-07 21:56 ` Moffett, Kyle D
2011-03-07 22:10 ` Mike Frysinger
2011-03-07 23:09 ` Graeme Russ
2011-03-08 2:45 ` Mike Frysinger
2011-03-13 19:24 ` Wolfgang Denk
2011-03-14 16:23 ` Moffett, Kyle D
2011-03-14 18:59 ` Wolfgang Denk
2011-03-14 19:52 ` Moffett, Kyle D
2011-03-14 20:38 ` Wolfgang Denk
2011-03-14 21:20 ` Moffett, Kyle D
2011-03-14 22:01 ` Wolfgang Denk
2011-03-21 11:43 ` Graeme Russ
2011-03-21 12:00 ` Wolfgang Denk
2011-03-22 12:05 ` Graeme Russ [this message]
2011-03-22 13:28 ` Wolfgang Denk
2011-03-23 0:19 ` Graeme Russ
2011-04-11 18:31 ` Wolfgang Denk
2011-03-07 17:37 ` [U-Boot] [PATCH 02/21] Replace do_reset() calls with {system, emergency}_restart() Kyle Moffett
2011-03-07 17:37 ` [U-Boot] [PATCH 03/21] arm: Call "panic()" instead of "hang()" for div-by-zero Kyle Moffett
2011-03-07 17:37 ` [U-Boot] [PATCH 04/21] arm: Replace unnecessary bad_mode() with panic() Kyle Moffett
2011-03-07 17:37 ` [U-Boot] [PATCH 05/21] arm: cpux9k2: Remove unnecessary XF_do_reset assignment Kyle Moffett
2011-03-07 17:37 ` [U-Boot] [PATCH 06/21] arm: Rename nonstandard board_reset() as at91_board_reset() Kyle Moffett
2011-03-07 17:37 ` [U-Boot] [PATCH 07/21] arm: Generic system restart support Kyle Moffett
2011-03-07 17:37 ` [U-Boot] [PATCH 08/21] avr32: " Kyle Moffett
2011-03-07 17:37 ` [U-Boot] [PATCH 09/21] blackfin: Replace "bfin_reset_or_hang()" with "panic()" Kyle Moffett
2011-03-07 21:44 ` Mike Frysinger
2011-03-07 17:37 ` [U-Boot] [PATCH 10/21] blackfin: Generic system restart support Kyle Moffett
2011-03-07 17:37 ` [U-Boot] [PATCH 11/21] i386: " Kyle Moffett
2011-03-07 21:54 ` Graeme Russ
2011-03-07 22:06 ` Moffett, Kyle D
2011-03-07 22:26 ` Graeme Russ
2011-03-07 22:57 ` Moffett, Kyle D
2011-03-07 23:06 ` Graeme Russ
2011-03-07 17:37 ` [U-Boot] [PATCH 12/21] m68k: " Kyle Moffett
2011-03-07 17:37 ` [U-Boot] [PATCH 13/21] microblaze: " Kyle Moffett
2011-03-07 17:37 ` [U-Boot] [PATCH 14/21] mips: " Kyle Moffett
2011-03-07 17:37 ` [U-Boot] [PATCH 15/21] nios2: " Kyle Moffett
2011-03-09 0:13 ` Scott McNutt
2011-03-09 0:42 ` Moffett, Kyle D
2011-03-09 1:33 ` Scott McNutt
2011-03-07 17:37 ` [U-Boot] [PATCH 16/21] powerpc: " Kyle Moffett
2011-03-07 17:37 ` [U-Boot] [PATCH 17/21] sh: Unify duplicate reset code Kyle Moffett
2011-03-07 17:37 ` [U-Boot] [PATCH 18/21] sh: Generic system restart support Kyle Moffett
2011-03-07 17:37 ` [U-Boot] [PATCH 19/21] sparc: Unify duplicate reset code Kyle Moffett
2011-03-07 17:37 ` [U-Boot] [PATCH 20/21] sparc: Generic system restart support Kyle Moffett
2011-03-07 17:37 ` [U-Boot] [PATCH 21/21] Remove legacy do_reset() function Kyle Moffett
2011-03-07 21:55 ` Graeme Russ
2011-03-07 23:00 ` Moffett, Kyle D
2011-03-07 23:03 ` Graeme Russ
2011-03-07 21:44 ` [U-Boot] [PATCH 0/21] Generic cross-architecture system restart support Graeme Russ
2011-03-13 19:16 ` Wolfgang Denk
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=4D88909A.80508@gmail.com \
--to=graeme.russ@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.