[RFC] mmc: Remove alignment hole for cmdidx in struct mmc_cmd

Ferass El Hafidi vitali64pmemail at protonmail.com
Sat Sep 30 11:20:39 CEST 2023


On Sat Sep 30, 2023 at 1:06 AM CEST, Jonas Karlman wrote:
> The alignment hole caused by cmdidx in struct mmc_cmd cause strange
> issues together with the peephole2 optimization on Amlogic SoCs.
> Following was observed while working on SPL support for Amlogic SoCs.
>
> sd_get_capabilities() normally issue a CMD55 followed by a CMD51.
> However, on at least Amlogic S905 (Cortex-A53) and S905X3 (Cortex-A55),
> CMD55 was instead followed by CMD8 (and a few reties) in SPL.
>
> Code from the call site:
>
>   cmd.cmdidx = SD_CMD_APP_SEND_SCR; // 51
>   ...
>   data.blocksize = 8;
>   ...
>   err = mmc_send_cmd_retry(mmc, &cmd, &data, 3);
>
> Running the code with MMC_TRACE enabled shows:
>
> CMD_SEND:55
>                 ARG                      0x50480000
>                 MMC_RSP_R1,5,6,7         0x00000920
> CMD_SEND:8
>                 ARG                      0x00000000
>                 RET                      -110
>
> Removing the alignment hole by changing cmdidx from ushort to uint or
> building with -fno-peephole2 flag seem to resolve this issue.
>
> CMD_SEND:55
>                 ARG                      0x50480000
>                 MMC_RSP_R1,5,6,7         0x00000920
> CMD_SEND:51
>                 ARG                      0x00000000
>                 MMC_RSP_R1,5,6,7         0x00000920
>
> Same issue was observed building U-Boot with gcc 8-13. Please advise on
> how to best work around this possible gcc optimization bug.
>
> Signed-off-by: Jonas Karlman <jonas at kwiboo.se>

I'll try reproducing this. I'm using this:
https://git.vitali64.duckdns.org/misc/u-boot-kii-pro.git (branch:
wip/spl, known to boot on S905/GXBB)

For reference, I'm using this version of aarch64 gcc (from the 
Arch Linux repos):

	$ aarch64-linux-gnu-gcc --version
	aarch64-linux-gnu-gcc (GCC) 13.1.0
	Copyright (C) 2023 Free Software Foundation, Inc.
	This is free software; see the source for copying conditions.  There is NO
	warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

And this version of (host) gcc:

	$ gcc --version
	gcc (GCC) 13.1.1 20230429
	Copyright (C) 2023 Free Software Foundation, Inc.
	This is free software; see the source for copying conditions.  There is NO
	warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Cheers.



More information about the U-Boot mailing list