stm32f7:SDMMC add dcache alignment check in dma{recv|send}setup
In the where CONFIG_SDIO_PREFLIGHT is not used and dcache write-buffed mode is used (not write-through) buffer alignment is required for DMA transfers because a) arch_invalidate_dcache could lose buffered writes data and b) arch_flush_dcache could corrupt adjacent memory if the buffer and the bufflen, are not on ARMV7M_DCACHE_LINESIZE boundaries.
This commit is contained in:
parent
1e7ddfea8e
commit
ef42c25140
@ -2843,16 +2843,21 @@ static int stm32_dmarecvsetup(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer,
|
||||
DEBUGASSERT(priv != NULL && buffer != NULL && buflen > 0);
|
||||
#ifdef CONFIG_SDIO_PREFLIGHT
|
||||
DEBUGASSERT(stm32_dmapreflight(dev, buffer, buflen) == 0);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ARMV7M_DCACHE
|
||||
/* buffer alignment is required for DMA transfers with dcache */
|
||||
#else
|
||||
# if defined(CONFIG_ARMV7M_DCACHE) && !defined(CONFIG_ARMV7M_DCACHE_WRITETHROUGH)
|
||||
/* buffer alignment is required for DMA transfers with dcache in buffered
|
||||
* mode (not write-through) because the arch_invalidate_dcache could lose
|
||||
* buffered buffered writes if the buffer alignment and sizes are not on
|
||||
* ARMV7M_DCACHE_LINESIZE boundaries.
|
||||
*/
|
||||
|
||||
if (((uintptr_t)buffer & (ARMV7M_DCACHE_LINESIZE-1)) != 0 ||
|
||||
(buflen & (ARMV7M_DCACHE_LINESIZE-1)) != 0)
|
||||
{
|
||||
return -EFAULT;
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
/* Reset the DPSM configuration */
|
||||
@ -2928,16 +2933,20 @@ static int stm32_dmasendsetup(FAR struct sdio_dev_s *dev,
|
||||
DEBUGASSERT(priv != NULL && buffer != NULL && buflen > 0);
|
||||
#ifdef CONFIG_SDIO_PREFLIGHT
|
||||
DEBUGASSERT(stm32_dmapreflight(dev, buffer, buflen) == 0);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ARMV7M_DCACHE
|
||||
/* buffer alignment is required for DMA transfers with dcache */
|
||||
#else
|
||||
# if defined(CONFIG_ARMV7M_DCACHE) && !defined(CONFIG_ARMV7M_DCACHE_WRITETHROUGH)
|
||||
/* buffer alignment is required for DMA transfers with dcache in buffered
|
||||
* mode (not write-through) because the arch_flush_dcache would corrupt adjacent
|
||||
* memory if the buffer alignment and sizes are not on ARMV7M_DCACHE_LINESIZE
|
||||
* boundaries.
|
||||
*/
|
||||
|
||||
if (((uintptr_t)buffer & (ARMV7M_DCACHE_LINESIZE-1)) != 0 ||
|
||||
(buflen & (ARMV7M_DCACHE_LINESIZE-1)) != 0)
|
||||
{
|
||||
return -EFAULT;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Reset the DPSM configuration */
|
||||
|
Loading…
Reference in New Issue
Block a user