All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rafal Jaworowski <raj@semihalf.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [patch] disable caches before booting an app for Blackfin apps
Date: Wed, 30 Jan 2008 09:51:48 +0100	[thread overview]
Message-ID: <47A03AA4.9010308@semihalf.com> (raw)
In-Reply-To: <200801291821.05927.vapier@gentoo.org>

Hi Mike,

> It isn't generally save to execute applications outside of U-Boot with caches
> enabled due to the way the Blackfin processor handles caches (requires
> software assistance).  This patch disables caches before booting an ELF or
> just booting raw code.  The previous discussion on the patch was that we
> wanted to use weaks instead, but that proved to not be feasible when multiple
> symbols are involved, which puts us back at the ifdef solution.  I've
> minimized the ugliness by moving the setup step outside of the main function.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> ---
> diff --git a/common/cmd_boot.c b/common/cmd_boot.c
> index e68f16f..9d4f026 100644
> --- a/common/cmd_boot.c
> +++ b/common/cmd_boot.c
> @@ -32,6 +32,23 @@
>  DECLARE_GLOBAL_DATA_PTR;
>  #endif
>  
> +static inline void go_setup(int argc, char *argv[])
> +{
> +#if defined(CONFIG_I386)
> +	/*
> +	 * x86 does not use a dedicated register to pass the pointer
> +	 * to the global_data
> +	 */
> +	argv[0] = (char *)gd;
> +
> +#elif defined(CONFIG_BLACKFIN)
> +	if (dcache_status ())
> +		dcache_disable ();
> +	if (icache_status ())
> +		icache_disable ();
> +#endif
> +}
> +
>  int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
>  {
>  	ulong	addr, rc;
> @@ -46,25 +63,20 @@ int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
>  
>  	printf ("## Starting application at 0x%08lX ...\n", addr);
>  
> +	go_setup(argc, argv);
> +
> +#if defined(CONFIG_NIOS)
>  	/*
> -	 * pass address parameter as argv[0] (aka command name),
> -	 * and all remaining args
> -	 */
> -#if defined(CONFIG_I386)
> -	/*
> -	 * x86 does not use a dedicated register to pass the pointer
> -	 * to the global_data
> +	 * Nios function pointers are address >> 1
>  	 */
> -	argv[0] = (char *)gd;
> +	addr >>= 1;
>  #endif
> -#if !defined(CONFIG_NIOS)
> -	rc = ((ulong (*)(int, char *[]))addr) (--argc, &argv[1]);
> -#else
> +
>  	/*
> -	 * Nios function pointers are address >> 1
> +	 * pass address parameter as argv[0] (aka command name),
> +	 * and all remaining args
>  	 */
> -	rc = ((ulong (*)(int, char *[]))(addr>>1)) (--argc, &argv[1]);
> -#endif
> +	rc = ((ulong (*)(int, char *[]))addr) (--argc, &argv[1]);
>  	if (rc != 0) rcode = 1;
>  
>  	printf ("## Application terminated, rc = 0x%lX\n", rc);
> diff --git a/common/cmd_elf.c b/common/cmd_elf.c
> index 2eb7453..4683554 100644
> --- a/common/cmd_elf.c
> +++ b/common/cmd_elf.c
> @@ -27,6 +27,21 @@ DECLARE_GLOBAL_DATA_PTR;
>  #define MAX(a,b) ((a) > (b) ? (a) : (b))
>  #endif
>  
> +static inline void bootelf_setup(int argc, char *argv[])
> +{
> +	/*
> +	 * QNX images require the data cache is disabled.
> +	 * Data cache is already flushed, so just turn it off.
> +	 */
> +	if (dcache_status ())
> +		dcache_disable ();
> +

Please re-formulate the comment, so it doesn't only refer to QNX, as per our
recent discussion disabling d-cache before running an external app is
considered a generic U-Boot operation, not platform specific, see this thread:

http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/34599

Also, I'm wondering if we shouldn't re-enable the cache after returning from
an external app (as they are allowed to do so)? Without doing it we end up
with degraded performance without any notice, require explicit reset to return
to previous state etc.

kind regards,
Rafal

  reply	other threads:[~2008-01-30  8:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-29 23:21 [U-Boot-Users] [patch] disable caches before booting an app for Blackfin apps Mike Frysinger
2008-01-30  8:51 ` Rafal Jaworowski [this message]
2008-01-30 12:45   ` Mike Frysinger
2008-04-13 22:01 ` 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=47A03AA4.9010308@semihalf.com \
    --to=raj@semihalf.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.