Skip to contentSkip to conversation

dm: core: Round up size when allocating so that it is cache line aligned

PATCH New Faiz Abbas 4 participants 5 messages Sep 19, 2017 – Sep 29, 2017

lore
Share & tools
lore

Faiz Abbas

author
#0 lore raw

PATCH 1/1 dm: core: Round up size when allocating so that it is cache line aligned

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.

---
 drivers/core/device.c | 1 +
 1 file changed, 1 insertion(+)
drivers/core/device.c +1 -0
index 5463d1f..96dfb21 100644
@@ -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);
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 dm: core: Round up size when allocating so that it is cache line aligned

Hi Faiz,

Quoted 4 lines · Faiz Abbas

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.

Quoted 8 lines

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

---
 drivers/core/device.c | 1 +
 1 file changed, 1 insertion(+)

Isn't DM_FLAG_ALLOC_PRIV_DMA sufficient?

Regards,
Bin

author
#2 lore raw

PATCH 1/1 dm: core: Round up size when allocating so that it is cache line aligned

Hi Bin,

Quoted 10 lines · Bin Meng

Hi Faiz,

Quoted 7 lines · Faiz Abbas

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.

Quoted 7 lines
Quoted 5 lines
---
 drivers/core/device.c | 1 +
 1 file changed, 1 insertion(+)

Isn't DM_FLAG_ALLOC_PRIV_DMA sufficient?

The check_cache_range function checks both the beginning and the end of the range given to it for cache alignment. DM_FLAG_ALLOC_PRIV_DMA aligns only the base address but the end address decided by size need not be at a multiple of ARCH_DMA_MINALIGN.

Thanks,
Faiz

#3 lore raw

PATCH 1/1 dm: core: Round up size when allocating so that it is cache line aligned

In reply to Faiz Abbas
Quoted 11 lines · Faiz Abbas

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.

---
 drivers/core/device.c | 1 +
 1 file changed, 1 insertion(+)
#4 lore raw

PATCH 1/1 dm: core: Round up size when allocating so that it is cache line aligned

Quoted 11 lines · Faiz Abbas

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.

---
 drivers/core/device.c | 1 +
 1 file changed, 1 insertion(+)

Applied to u-boot-dm thanks!