Message ID | 20240127162922.284598-1-jonas@kwiboo.se |
---|---|
State | New |
Delegated to: | Jaehoon Chung |
Headers | show |
Series | [v2] mmc: Remove alignment hole for cmdidx in struct mmc_cmd | expand |
Hi, On 1/28/24 01:29, 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. I read your RFC "https://patchwork.ozlabs.org/patch/1841495/". First, I will retry to reproduce your case with other compiler. After that, I will inform again about this patch. Best Regards, Jaehoon Chung > > 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. > > Remove this alignment hole by changing cmdidx from ushort to uint. > > Signed-off-by: Jonas Karlman <jonas@kwiboo.se> > --- > Changes in v2: > - Drop use of -fno-peephole2 flag > > Link to RFC: https://patchwork.ozlabs.org/patch/1841495/ > --- > include/mmc.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/mmc.h b/include/mmc.h > index 1022db3ffa7c..031ea0fb3545 100644 > --- a/include/mmc.h > +++ b/include/mmc.h > @@ -413,7 +413,7 @@ struct mmc_cid { > }; > > struct mmc_cmd { > - ushort cmdidx; > + uint cmdidx; > uint resp_type; > uint cmdarg; > uint response[4];
diff --git a/include/mmc.h b/include/mmc.h index 1022db3ffa7c..031ea0fb3545 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -413,7 +413,7 @@ struct mmc_cid { }; struct mmc_cmd { - ushort cmdidx; + uint cmdidx; uint resp_type; uint cmdarg; uint response[4];
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. Remove this alignment hole by changing cmdidx from ushort to uint. Signed-off-by: Jonas Karlman <jonas@kwiboo.se> --- Changes in v2: - Drop use of -fno-peephole2 flag Link to RFC: https://patchwork.ozlabs.org/patch/1841495/ --- include/mmc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)