[U-Boot] [PATCH] arm: mmu: Add missing volatile for reading SCTLR register

Albert ARIBAUD
2015-10-15T13:41:44Z

Hello Alison,

Sorry for the late comment.

On Wed, 9 Sep 2015 10:22:02 +0800, Alison Wang <b18965@freescale.com>
wrote:
> When building u-boot with the latest Linaro toolchain, such as
> gcc-linaro-4.9, u-boot will hang at PCIE init on LS1021A platform.
> The issue is reported on
> http://comments.gmane.org/gmane.linux.linaro.toolchain/5163.
>
> As volatile is missing when reading SCTLR register and SCTLR is set
> according to the value read from SCTLR, it causes CR_M bit is not set.
> Then MMU is not enabled, the access to VA for PCIE fails.

This comment seems misleading to me: it appears to imply that the
"volatile" qualifier is added to alter the semantics of the mrc
statement, whereas it is added only to prevent the compiler from
optimizing out the whole asm statement and making get_cr() return
garbage.

I would prefer a commit message such as:

Add 'volatile' qualifier to the asm statement in get_cr()
so that the statement is not optimized out by the compiler.

Without the 'volatile', get_cr() returns a wrong value which
prevents enabling the MMU and later causes a PCIE VA access
failure.

If this is fine with you, I'll apply the patch with the comment altered
as above.

Amicalement,
--
Albert.