dm: core: Round up size when allocating so that it is cache line aligned
authorFaiz Abbas <faiz_abbas@ti.com>
Tue, 19 Sep 2017 11:23:50 +0000 (16:53 +0530)
committerSimon Glass <sjg@chromium.org>
Mon, 9 Oct 2017 02:41:09 +0000 (20:41 -0600)
The size variable may not be always be a mulitple of
ARCH_DMA_MINALIGN and using it to flush cache leads to cache
misaligned warnings.

Therefore, round up the size to a multiple of ARCH_DMA_MINLAIGN
when allocating private data.

Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/core/device.c

index de63e53..9a46a7b 100644 (file)
@@ -254,6 +254,7 @@ static void *alloc_priv(int size, uint flags)
        void *priv;
 
        if (flags & DM_FLAG_ALLOC_PRIV_DMA) {
+               size = ROUND(size, ARCH_DMA_MINALIGN);
                priv = memalign(ARCH_DMA_MINALIGN, size);
                if (priv) {
                        memset(priv, '\0', size);