Skip to content

Commit

Permalink
mmcsd:Stuck in 1-bit mode, Removed CONFIG_ARCH_HAVE_SDIO_DELAYED_INVLDT
Browse files Browse the repository at this point in the history
   mmcsd:Remove CONFIG_ARCH_HAVE_SDIO_DELAYED_INVLDT
   stm32h7:sdmmc remove CONFIG_ARCH_HAVE_SDIO_DELAYED_INVLDT
   stm32f7:sdmmc remove CONFIG_ARCH_HAVE_SDIO_DELAYED_INVLDT
   stm32f7:sdmmc WRITE COMPLETE prevent false triggers
   stm32h7:sdmmc WRITE COMPLETE prevent false triggers

   While testing PR apache#2989 on the H7 I noticed that the cards
   were staying in 1-bit mode. The root cause was that the
   scr read path was using DMA without an invlidate.

   This was caused by CONFIG_ARCH_HAVE_SDIO_DELAYED_INVLDT,
   but the sdmmc driver, did not use the delayed invalidate
   nor would it work on 8 bytes.

   The driver fully supported dcache mgt on runt buffers, but
   the #ifdef CONFIG_ARCH_HAVE_SDIO_DELAYED_INVLDT blocked it.

   Reviewing the PR that added CONFIG_ARCH_HAVE_SDIO_DELAYED_INVLDT
   it may have been valid at the time. But after the dcache operations
   we fixed. It is not necessary and offers no benefit.
  • Loading branch information
davids5 committed Mar 12, 2021
1 parent d28962b commit cf9241b
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 200 deletions.
14 changes: 0 additions & 14 deletions arch/arm/src/stm32f7/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,6 @@ config STM32F7_STM32F722XX
default n
select STM32F7_STM32F72XX
select ARCH_HAVE_FPU
select ARCH_HAVE_SDIO_DELAYED_INVLDT
select ARMV7M_HAVE_ICACHE
select ARMV7M_HAVE_DCACHE
select ARMV7M_HAVE_ITCM
Expand All @@ -679,7 +678,6 @@ config STM32F7_STM32F723XX
default n
select STM32F7_STM32F72XX
select ARCH_HAVE_FPU
select ARCH_HAVE_SDIO_DELAYED_INVLDT
select ARMV7M_HAVE_ICACHE
select ARMV7M_HAVE_DCACHE
select ARMV7M_HAVE_ITCM
Expand All @@ -696,7 +694,6 @@ config STM32F7_STM32F745XX
default n
select STM32F7_STM32F74XX
select ARCH_HAVE_FPU
select ARCH_HAVE_SDIO_DELAYED_INVLDT
select ARMV7M_HAVE_ICACHE
select ARMV7M_HAVE_DCACHE
select ARMV7M_HAVE_ITCM
Expand All @@ -716,7 +713,6 @@ config STM32F7_STM32F746XX
default n
select STM32F7_STM32F74XX
select ARCH_HAVE_FPU
select ARCH_HAVE_SDIO_DELAYED_INVLDT
select ARMV7M_HAVE_ICACHE
select ARMV7M_HAVE_DCACHE
select ARMV7M_HAVE_ITCM
Expand Down Expand Up @@ -762,7 +758,6 @@ config STM32F7_STM32F765XX
select STM32F7_STM32F76XX
select ARCH_HAVE_FPU
select ARCH_HAVE_DPFPU
select ARCH_HAVE_SDIO_DELAYED_INVLDT
select ARMV7M_HAVE_ICACHE
select ARMV7M_HAVE_DCACHE
select ARMV7M_HAVE_ITCM
Expand Down Expand Up @@ -812,7 +807,6 @@ config STM32F7_STM32F768XX # Revisit When parts released
select STM32F7_STM32F76XX
select ARCH_HAVE_FPU
select ARCH_HAVE_DPFPU
select ARCH_HAVE_SDIO_DELAYED_INVLDT
select ARMV7M_HAVE_ICACHE
select ARMV7M_HAVE_DCACHE
select ARMV7M_HAVE_ITCM
Expand All @@ -839,7 +833,6 @@ config STM32F7_STM32F768AX # Revisit When parts released
select STM32F7_STM32F76XX
select ARCH_HAVE_FPU
select ARCH_HAVE_DPFPU
select ARCH_HAVE_SDIO_DELAYED_INVLDT
select ARMV7M_HAVE_ICACHE
select ARMV7M_HAVE_DCACHE
select ARMV7M_HAVE_ITCM
Expand All @@ -865,7 +858,6 @@ config STM32F7_STM32F769XX
select STM32F7_STM32F76XX
select ARCH_HAVE_FPU
select ARCH_HAVE_DPFPU
select ARCH_HAVE_SDIO_DELAYED_INVLDT
select ARMV7M_HAVE_ICACHE
select ARMV7M_HAVE_DCACHE
select ARMV7M_HAVE_ITCM
Expand All @@ -892,7 +884,6 @@ config STM32F7_STM32F769AX # Revisit When parts released
select STM32F7_STM32F76XX
select ARCH_HAVE_FPU
select ARCH_HAVE_DPFPU
select ARCH_HAVE_SDIO_DELAYED_INVLDT
select ARMV7M_HAVE_ICACHE
select ARMV7M_HAVE_DCACHE
select ARMV7M_HAVE_ITCM
Expand All @@ -918,7 +909,6 @@ config STM32F7_STM32F777XX
select STM32F7_STM32F77XX
select ARCH_HAVE_FPU
select ARCH_HAVE_DPFPU
select ARCH_HAVE_SDIO_DELAYED_INVLDT
select ARMV7M_HAVE_ICACHE
select ARMV7M_HAVE_DCACHE
select ARMV7M_HAVE_ITCM
Expand Down Expand Up @@ -947,7 +937,6 @@ config STM32F7_STM32F778XX # Revisit when parts released
select STM32F7_STM32F77XX
select ARCH_HAVE_FPU
select ARCH_HAVE_DPFPU
select ARCH_HAVE_SDIO_DELAYED_INVLDT
select ARMV7M_HAVE_ICACHE
select ARMV7M_HAVE_DCACHE
select ARMV7M_HAVE_ITCM
Expand Down Expand Up @@ -976,7 +965,6 @@ config STM32F7_STM32F778AX
select STM32F7_STM32F77XX
select ARCH_HAVE_FPU
select ARCH_HAVE_DPFPU
select ARCH_HAVE_SDIO_DELAYED_INVLDT
select ARMV7M_HAVE_ICACHE
select ARMV7M_HAVE_DCACHE
select ARMV7M_HAVE_ITCM
Expand Down Expand Up @@ -1004,7 +992,6 @@ config STM32F7_STM32F779XX
select STM32F7_STM32F77XX
select ARCH_HAVE_FPU
select ARCH_HAVE_DPFPU
select ARCH_HAVE_SDIO_DELAYED_INVLDT
select ARMV7M_HAVE_ICACHE
select ARMV7M_HAVE_DCACHE
select ARMV7M_HAVE_ITCM
Expand Down Expand Up @@ -1033,7 +1020,6 @@ config STM32F7_STM32F779AX
select STM32F7_STM32F77XX
select ARCH_HAVE_FPU
select ARCH_HAVE_DPFPU
select ARCH_HAVE_SDIO_DELAYED_INVLDT
select ARMV7M_HAVE_ICACHE
select ARMV7M_HAVE_DCACHE
select ARMV7M_HAVE_ITCM
Expand Down
65 changes: 9 additions & 56 deletions arch/arm/src/stm32f7/stm32_sdmmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,10 +583,6 @@ static int stm32_dmarecvsetup(FAR struct sdio_dev_s *dev,
FAR uint8_t *buffer, size_t buflen);
static int stm32_dmasendsetup(FAR struct sdio_dev_s *dev,
FAR const uint8_t *buffer, size_t buflen);
#ifdef CONFIG_ARCH_HAVE_SDIO_DELAYED_INVLDT
static int stm32_dmadelydinvldt(FAR struct sdio_dev_s *dev,
FAR const uint8_t *buffer, size_t buflen);
#endif
#endif /* CONFIG_STM32F7_SDMMC_DMA */

/* Initialization/uninitialization/reset ************************************/
Expand Down Expand Up @@ -636,9 +632,6 @@ struct stm32_dev_s g_sdmmcdev1 =
#endif
.dmarecvsetup = stm32_dmarecvsetup,
.dmasendsetup = stm32_dmasendsetup,
#ifdef CONFIG_ARCH_HAVE_SDIO_DELAYED_INVLDT
.dmadelydinvldt = stm32_dmadelydinvldt,
#endif
#else
#ifdef CONFIG_ARCH_HAVE_SDIO_PREFLIGHT
.dmapreflight = NULL,
Expand Down Expand Up @@ -705,9 +698,6 @@ struct stm32_dev_s g_sdmmcdev2 =
#endif
.dmarecvsetup = stm32_dmarecvsetup,
.dmasendsetup = stm32_dmasendsetup,
#ifdef CONFIG_ARCH_HAVE_SDIO_DELAYED_INVLDT
.dmadelydinvldt = stm32_dmadelydinvldt,
#endif
#endif
},
.base = STM32_SDMMC2_BASE,
Expand Down Expand Up @@ -1600,7 +1590,14 @@ static void stm32_endtransfer(struct stm32_dev_s *priv,
static int stm32_sdmmc_rdyinterrupt(int irq, void *context, void *arg)
{
struct stm32_dev_s *priv = (struct stm32_dev_s *)arg;
stm32_endwait(priv, SDIOWAIT_WRCOMPLETE);

/* Avoid noise, check the state */

if (stm32_gpioread(priv->d0_gpio))
{
stm32_endwait(priv, SDIOWAIT_WRCOMPLETE);
}

return OK;
}
#endif
Expand Down Expand Up @@ -3102,9 +3099,7 @@ static int stm32_dmarecvsetup(FAR struct sdio_dev_s *dev,
if ((uintptr_t)buffer < DTCM_START ||
(uintptr_t)buffer + buflen > DTCM_END)
{
#if !defined(CONFIG_ARCH_HAVE_SDIO_DELAYED_INVLDT)
up_invalidate_dcache((uintptr_t)buffer, (uintptr_t)buffer + buflen);
#endif
}

/* Start the DMA */
Expand Down Expand Up @@ -3177,11 +3172,7 @@ static int stm32_dmasendsetup(FAR struct sdio_dev_s *dev,
if ((uintptr_t)buffer < DTCM_START ||
(uintptr_t)buffer + buflen > DTCM_END)
{
#ifdef CONFIG_ARMV7M_DCACHE_WRITETHROUGH
up_invalidate_dcache((uintptr_t)buffer, (uintptr_t)buffer + buflen);
#else
up_flush_dcache((uintptr_t)buffer, (uintptr_t)buffer + buflen);
#endif
up_clean_dcache((uintptr_t)buffer, (uintptr_t)buffer + buflen);
}

/* Save the source buffer information for use by the interrupt handler */
Expand Down Expand Up @@ -3220,44 +3211,6 @@ static int stm32_dmasendsetup(FAR struct sdio_dev_s *dev,
}
#endif

/****************************************************************************
* Name: stm32_dmadelydinvldt
*
* Description:
* Delayed D-cache invalidation.
* This function should be called after receive DMA completion to perform
* D-cache invalidation. This eliminates the need for cache aligned DMA
* buffers when the D-cache is in store-through mode.
*
* Input Parameters:
* dev - An instance of the SDIO device interface
* buffer - The memory to DMA into
* buflen - The size of the DMA transfer in bytes
*
* Returned Value:
* OK on success; a negated errno on failure
*
****************************************************************************/

#if defined(CONFIG_ARCH_HAVE_SDIO_DELAYED_INVLDT) && \
defined(CONFIG_STM32F7_SDMMC_DMA)

static int stm32_dmadelydinvldt(FAR struct sdio_dev_s *dev,
FAR const uint8_t *buffer, size_t buflen)
{
/* Invaliate cache to physical memory when not in DTCM memory. */

if ((uintptr_t)buffer < DTCM_START ||
(uintptr_t)buffer + buflen > DTCM_END)
{
up_invalidate_dcache((uintptr_t)buffer,
(uintptr_t)buffer + buflen);
}

return OK;
}
#endif

/****************************************************************************
* Name: stm32_callback
*
Expand Down
2 changes: 0 additions & 2 deletions arch/arm/src/stm32h7/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ config STM32H7_STM32H7X3XX
default n
select ARCH_HAVE_FPU
select ARCH_HAVE_DPFPU
select ARCH_HAVE_SDIO_DELAYED_INVLDT
select ARMV7M_HAVE_ICACHE
select ARMV7M_HAVE_DCACHE
select ARMV7M_HAVE_ITCM
Expand All @@ -233,7 +232,6 @@ config STM32H7_STM32H7X7XX
default n
select ARCH_HAVE_FPU
select ARCH_HAVE_DPFPU
select ARCH_HAVE_SDIO_DELAYED_INVLDT
select ARMV7M_HAVE_ICACHE
select ARMV7M_HAVE_DCACHE
select ARMV7M_HAVE_ITCM
Expand Down
Loading

0 comments on commit cf9241b

Please sign in to comment.