public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stefano Babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] mx6: invalidate D-cache only when booting from USB
Date: Sun, 24 May 2015 09:24:48 +0200	[thread overview]
Message-ID: <55617CC0.5090004@denx.de> (raw)
In-Reply-To: <1432306377-29169-1-git-send-email-vincent.stehle@freescale.com>

Hi Vincent,

On 22/05/2015 16:52, Vincent Stehl? wrote:
> Add a detection at runtime of the boot from USB on i.MX6, and invalidate
> the D-cache only in that case.
> 
> The USB boot detection method is taken from Freescale u-boot commit
> 1309b1ed78b3 ("ENGR00315499-8 Auto check if boot from usb").
> 
> This repairs u-boot when it is built with CONFIG_SKIP_LOWLEVEL_INIT
> defined, and is booted from another u-boot, which booted from SD card,
> for example.

Please help me to find the use case. I searched in all i.MX6 boards in
mainline, but none of them is setting CONFIG_SKIP_LOWLEVEL_INIT. Can you
tell me on which board there is this issue ?

> 
> Signed-off-by: Vincent Stehl? <vincent.stehle@freescale.com>
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Fabio Estevam <fabio.estevam@freescale.com>
> Cc: Frank Li <Frank.li@freescale.com>
> Cc: Nitin Garg <nitin.garg@freescale.com>
> ---
>  arch/arm/cpu/armv7/mx6/soc.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c
> index 21ef9d0..774f078 100644
> --- a/arch/arm/cpu/armv7/mx6/soc.c
> +++ b/arch/arm/cpu/armv7/mx6/soc.c
> @@ -350,6 +350,18 @@ int board_postclk_init(void)
>  	return 0;
>  }
>  
> +/*
> + * Determine if we booted from USB.
> + *
> + * We look at the USBPH0_PWD0.RXPWDRX register to determine if the USB
> + * PHY is powered on or off. If the USB PHY is turned on, we assume that
> + * the ROM booted us from USB.
> + */
> +static bool is_boot_from_usb(void)
> +{
> +	return !(readl(USB_PHY0_BASE_ADDR) & (1<<20));
> +}

This looks like a hack. I understand this can work in your case, but can
we set as general case ? You check power for PHY0, but what about if a
board is using PHY1 ?

Anyway, is it not possible to get the boot storage from the SRC ?

> +
>  #ifndef CONFIG_SYS_DCACHE_OFF
>  void enable_caches(void)
>  {
> @@ -360,7 +372,8 @@ void enable_caches(void)
>  #endif
>  
>  	/* Avoid random hang when download by usb */
> -	invalidate_dcache_all();
> +	if (is_boot_from_usb())
> +		invalidate_dcache_all();

I cannot understand well this. The correct implementation seems correct
to me. And if you have issues booting with USB, why are you changing the
behavior in all other cases *except* booting from USB, where you rely on
the current implementation invalidating the cache ?

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

  parent reply	other threads:[~2015-05-24  7:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-22 14:52 [U-Boot] [PATCH] mx6: invalidate D-cache only when booting from USB Vincent Stehlé
2015-05-22 15:15 ` Li Frank
2015-05-22 15:37   ` Vincent Stehlé
2015-05-24  7:24 ` Stefano Babic [this message]
2015-05-26 15:16   ` Vincent
2015-05-26 17:08     ` Stefano Babic

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=55617CC0.5090004@denx.de \
    --to=sbabic@denx.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox