From: Jonas Karlman <jonas@kwiboo.se>
To: u-boot@lists.denx.de
Cc: Ferass El Hafidi <vitali64pmemail@protonmail.com>,
Jonas Karlman <jonas@kwiboo.se>
Subject: [RFC] mmc: Remove alignment hole for cmdidx in struct mmc_cmd
Date: Fri, 29 Sep 2023 23:06:53 +0000 [thread overview]
Message-ID: <20230929230655.2932698-1-jonas@kwiboo.se> (raw)
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@kwiboo.se>
---
arch/arm/cpu/armv8/config.mk | 2 ++
include/mmc.h | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/arm/cpu/armv8/config.mk b/arch/arm/cpu/armv8/config.mk
index 4d74b2a533e0..7177dcd7c73b 100644
--- a/arch/arm/cpu/armv8/config.mk
+++ b/arch/arm/cpu/armv8/config.mk
@@ -7,6 +7,8 @@ PLATFORM_RELFLAGS += $(call cc-option,-mbranch-protection=none)
PF_NO_UNALIGNED := $(call cc-option, -mstrict-align)
PLATFORM_CPPFLAGS += $(PF_NO_UNALIGNED)
+PLATFORM_CPPFLAGS += $(call cc-option,-fno-peephole2)
+
EFI_LDS := elf_aarch64_efi.lds
EFI_CRT0 := crt0_aarch64_efi.o
EFI_RELOC := reloc_aarch64_efi.o
diff --git a/include/mmc.h b/include/mmc.h
index 9aef31ea5deb..7b3868bb5664 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];
--
2.42.0
next reply other threads:[~2023-09-29 23:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-29 23:06 Jonas Karlman [this message]
2023-09-30 9:20 ` [RFC] mmc: Remove alignment hole for cmdidx in struct mmc_cmd Ferass El Hafidi
2023-10-02 18:56 ` Simon Glass
2023-10-02 19:28 ` Jonas Karlman
2023-10-05 1:23 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230929230655.2932698-1-jonas@kwiboo.se \
--to=jonas@kwiboo.se \
--cc=u-boot@lists.denx.de \
--cc=vitali64pmemail@protonmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.