From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fabio Estevam Date: Sun, 18 Nov 2018 23:35:33 -0200 Subject: [U-Boot] [PULL] Please pull u-boot-imx In-Reply-To: References: <9d19bc5e-b7aa-d7e3-8eeb-b211360edca0@denx.de> <87r2i64oq1.fsf@tkos.co.il> <20181114070750.rqtlh5dnno6v62ob@sapphire.tkos.co.il> <87sgzyg1d4.fsf@tkos.co.il> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Ricardo, On Sun, Nov 18, 2018 at 5:44 PM Ricardo Salveti wrote: > Also tried with ARM's pre-built toolchain (same version), and got the > same hang. Looking a bit further, it basically looks up while waiting > the first mmc command to complete: > > has_emmc -> mmc_get_op_cond -> mmc_send_if_cond (testing for SD > version 2) -> mmc_send_cmd -> esdhc_send_cmd_common -> while > (!(esdhc_read32(®s->irqstat) & flags)) Does the change below help? --- 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, uint irqstat; u32 flags = IRQSTAT_CC | IRQSTAT_CTOE; struct fsl_esdhc *regs = priv->esdhc_regs; + unsigned long start; #ifdef CONFIG_SYS_FSL_ERRATUM_ESDHC111 if (cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION) @@ -453,8 +454,11 @@ static int esdhc_send_cmd_common(struct fsl_esdhc_priv *priv, struct mmc *mmc, flags = IRQSTAT_BRR; /* Wait for the command to complete */ - while (!(esdhc_read32(®s->irqstat) & flags)) - ; + start = get_timer(0); + while (!(esdhc_read32(®s->irqstat) & flags)) { + if (get_timer(start) > 1000) + return -ETIMEDOUT; + } irqstat = esdhc_read32(®s->irqstat);