[U-Boot] ELF_RELOC causes strange I-cache issues

Joakim Tjernlund joakim.tjernlund at transmode.se
Thu Oct 21 13:28:19 CEST 2010


> 
> Hello Albert,
> 
> Albert Aribaud wrote:
> > Wolfgang (and others who can/want),
> > 
> > Please test this patch; it should add a complete barrier to make
> > sure that all fixups are written to RAM before jumping there, and
> > that no remnants subsist of the old unfixed code in the instruction
> > paths. However, I cannot even do basic testing on it as I have
> > no 1136 board, so I cannot rule out even basic mistakes.
> > 
> > When this works I'll do a proper [PATCH].
> > 
> > Amicalement,
> > Albert.
> > 
> > diff --git a/arch/arm/cpu/arm1136/start.S 
b/arch/arm/cpu/arm1136/start.S
> > index 8b63192..f49f1de 100644
> > --- a/arch/arm/cpu/arm1136/start.S
> > +++ b/arch/arm/cpu/arm1136/start.S
> > @@ -257,6 +257,11 @@ fixloop:
> >     add   r2, r2, #4
> >     cmp   r2, r3
> >     bne   fixloop
> > +   /* fixups done, cleanup caches if used and prefetch buffer */
> > +   mov   r3, #0
> > +   mcr   p15, 0, r3, c7, c10, 4   /* data synchronization barrier */
> > +   mcr   p15, 0, r3, c7, c5, 0   /* invalidate instruction cache */
> > +   mcr   p15, 0, r3, c7, c5, 4   /* flush prefetch buffer */
> >  #endif
> >  #endif   /* #ifndef CONFIG_SKIP_RELOCATE_UBOOT */
> 
> Actually I tried an identically patch, but didn;t help :-(
> 
> But as reading in the arm manual such a memory barrier should
> not be bad here ...
> 
> BTW:
> 
> I had a fix for this problem, but I completly not understand
> what it has to do with relocation (if it really is a problem
> introduced through relocation ...), nor why a flush_cache
> helps here, because dcache is off and only icache is on ...
> 
> diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
> index f44fc4e..3e326ac 100644
> --- a/drivers/usb/host/ehci-hcd.c
> +++ b/drivers/usb/host/ehci-hcd.c
> @@ -203,6 +203,8 @@ static inline void ehci_invalidate_dcache(struct QH 
*qh)
>  static int handshake(uint32_t *ptr, uint32_t mask, uint32_t done, int 
usec)
>  {
>         uint32_t result;
> +
> +       flush_cache(0, 0);
>         do {
>                 result = ehci_readl(ptr);
>                 if (result == ~(uint32_t)0)
> 
> and the "usb read 80000000 0 1000" command works fine ...
> 
> 
> Maybe Icache flush dosen;t work because the "ARM1136 Errata 411920
> Invalidate Instruction Cache operation can fail" interferes here?

On ppc flush means to write the cache to ram, that is not good if the 
cache
is invalid.
You want to invalidate the cache instead.

      Jocke


More information about the U-Boot mailing list