• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修订版29c2edb42bf3641943a48781ae101c513ede7a88 (tree)
时间2019-01-15 01:26:12
作者Fabio Estevam <festevam@gmai...>
CommiterTom Rini

Log Message

mmc: fsl_esdhc: Avoid infinite loop in esdhc_send_cmd_common()

The following hang is observed on a Hummingboard 2 MicroSOM
i2eX iMX6D - rev 1.3 with no eMMC populated on board:

U-Boot SPL 2018.11+gf6206f8587 (Nov 16 2018 - 00:56:34 +0000)
Trying to boot from MMC1

U-Boot 2018.11+gf6206f8587 (Nov 16 2018 - 00:56:34 +0000)

CPU: Freescale i.MX6D rev1.5 996 MHz (running at 792 MHz)
CPU: Extended Commercial temperature grade (-20C to 105C) at 33C
Reset cause: POR
Board: MX6 HummingBoard2
DRAM: 1 GiB
MMC: FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from MMC... *** Warning - bad CRC, using default environment

No panel detected: default to HDMI
Display: HDMI (1024x768)
In: serial
Out: serial
Err: serial
---> hangs

which is caused by the following infinite loop inside esdhc_send_cmd_common()

while (!(esdhc_read32(&regs->irqstat) & flags))
;

Instead of looping forever, provide an exit path so that a timeout
error can be propagated in the case irqstat does not report
any interrupts, which may happen when no eMMC is populated on
board.

Reported-by: Ricardo Salveti <rsalveti@rsalveti.net>
Signed-off-by: Fabio Estevam <festevam@gmail.com>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Tested-by: Ricardo Salveti <rsalveti@rsalveti.net>

更改概述

差异

--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -396,6 +396,7 @@ static int esdhc_send_cmd_common(struct fsl_esdhc_priv *priv, struct mmc *mmc,
396396 uint irqstat;
397397 u32 flags = IRQSTAT_CC | IRQSTAT_CTOE;
398398 struct fsl_esdhc *regs = priv->esdhc_regs;
399+ unsigned long start;
399400
400401 #ifdef CONFIG_SYS_FSL_ERRATUM_ESDHC111
401402 if (cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION)
@@ -453,8 +454,13 @@ static int esdhc_send_cmd_common(struct fsl_esdhc_priv *priv, struct mmc *mmc,
453454 flags = IRQSTAT_BRR;
454455
455456 /* Wait for the command to complete */
456- while (!(esdhc_read32(&regs->irqstat) & flags))
457- ;
457+ start = get_timer(0);
458+ while (!(esdhc_read32(&regs->irqstat) & flags)) {
459+ if (get_timer(start) > 1000) {
460+ err = -ETIMEDOUT;
461+ goto out;
462+ }
463+ }
458464
459465 irqstat = esdhc_read32(&regs->irqstat);
460466