u-boot-brain/arch/arm/mach-imx
Yasushi SHOJI 314d9f7e3e imx: syscounter: make sure asm is volatile
Without the volatile attribute, compilers are entitled to optimize out
the same asm().  In the case of __udelay() in syscounter.c, it calls
`get_ticks()` twice, one for the starting time and the second in the
loop to check the current time.  When compilers inline `get_ticks()`
they see the same `mrrc` instructions and optimize out the second one.
This leads to infinite loop since we don't get updated value from the
system counter.

Here is a portion of the disassembly of __udelay:

  88:	428b      	cmp	r3, r1
  8a:	f8ce 20a4 	str.w	r2, [lr, #164]	; 0xa4
  8e:	bf08      	it	eq
  90:	4282      	cmpeq	r2, r0
  92:	f8ce 30a0 	str.w	r3, [lr, #160]	; 0xa0
  96:	d3f7      	bcc.n	88 <__udelay+0x88>
  98:	e8bd 8cf0 	ldmia.w	sp!, {r4, r5, r6, r7, sl, fp, pc}

Note that final jump / loop at 96 to 88, we don't have any `mrrc`.

With a volatile attribute, the above changes to this:

  8a:	ec53 2f0e 	mrrc	15, 0, r2, r3, cr14
  8e:	42ab      	cmp	r3, r5
  90:	f8c1 20a4 	str.w	r2, [r1, #164]	; 0xa4
  94:	bf08      	it	eq
  96:	42a2      	cmpeq	r2, r4
  98:	f8c1 30a0 	str.w	r3, [r1, #160]	; 0xa0
  9c:	d3f5      	bcc.n	8a <__udelay+0x8a>
  9e:	e8bd 8cf0 	ldmia.w	sp!, {r4, r5, r6, r7, sl, fp, pc}
  a2:	bf00      	nop

I'm advised[1] to put volatile on all asm(), so this commit also adds it
to the asm() in timer_init().

[1]: https://lists.denx.de/pipermail/u-boot/2018-March/322062.html

Signed-off-by: Yasushi SHOJI <yasushi.shoji@gmail.com>
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
2018-03-09 13:06:14 +01:00
..
mx2 mx25: Select the ESDHC_A001 erratum 2017-11-07 10:13:00 +01:00
mx5 arm: imx: mx53loco: remove usage of mx53_dram_size 2018-02-04 12:00:58 +01:00
mx6 libfdt: move headers to <linux/libfdt.h> and <linux/libfdt_env.h> 2018-03-05 10:16:28 -05:00
mx7 imx: mx7: run sec_init for CAAM RNG 2018-02-04 12:14:11 +01:00
mx7ulp arm: imx: Rework i.MX specific commands to be excluded from SPL 2018-01-12 14:28:04 +01:00
mx8m imx: mx8m: add soc related settings and files 2018-02-04 12:00:58 +01:00
mxs arm: imx: mx28: Move MX28 selection to Kconfig 2018-02-08 10:17:17 -05:00
cache.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
cmd_bmode.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
cmd_dek.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
cmd_hdmidet.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
cpu.c imx: cpu: support get_boot_device for i.MX8M 2018-02-04 12:00:58 +01:00
ddrmc-vf610.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
hab.c arm: imx: hab: Define HAB_RVT_BASE according to the processor version 2018-02-22 14:36:06 +01:00
i2c-mxv7.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
imx_bootaux.c imx: bootaux: support i.MX8M 2018-02-04 12:00:58 +01:00
init.c imx: Remove boolean parameter from wdog powerdown function 2017-11-27 10:34:49 +01:00
iomux-v3.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
Kconfig imx: introduce CONFIG_GPT_TIMER 2018-01-08 17:33:06 +01:00
mac.c imx: refactor imx_get_mac_from_fuse 2018-02-04 12:00:58 +01:00
Makefile imx: makefile: compile files for i.MX8M 2018-02-04 12:00:58 +01:00
misc.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
mmc_env.c imx: mx7: move mmc env code to mmc_env.c 2018-02-04 12:00:58 +01:00
rdc-sema.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
sata.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
sip.c imx: add sip function 2018-02-04 12:00:58 +01:00
speed.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
spl_sd.cfg imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
spl.c imx: spl: Partially revert "spl: eMMC/SD: Provide one __weak spl_boot_mode() function" 2018-02-24 19:33:32 +01:00
syscounter.c imx: syscounter: make sure asm is volatile 2018-03-09 13:06:14 +01:00
timer.c imx: timer: don't clear the GPT control register multiple times 2017-08-29 09:47:28 +02:00
video.c env: Rename getenv/_f() to env_get() 2017-08-16 08:30:24 -04:00