[U-Boot,v3,5/6] mmc: dcache: allocate cache aligned buffers for ext_csd

Submitted by Anton staaf on Oct. 12, 2011, 11:56 p.m.

Details

Message ID 1318463764-28244-6-git-send-email-robotboy@chromium.org
State Accepted
Headers show

Commit Message

Anton staaf Oct. 12, 2011, 11:56 p.m.
Currently the mmc_change_freq and mmc_startup functions allocates
buffers on the stack that are passed down to the MMC device driver.
These buffers could be unaligned to the L1 dcache line size.  This
causes problems when using DMA and with caches enabled.

This patch correctly cache alignes the buffers used for reading the
ext_csd data from an MMC device.

Signed-off-by: Anton Staaf <robotboy@chromium.org>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
---
 drivers/mmc/mmc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Comments

Mike Frysinger Oct. 13, 2011, 12:56 a.m.
Acked-by: Mike Frysinger <vapier@gentoo.org>
-mike
Wolfgang Denk Oct. 25, 2011, 7:26 a.m.
Dear Anton Staaf,

In message <1318463764-28244-6-git-send-email-robotboy@chromium.org> you wrote:
> Currently the mmc_change_freq and mmc_startup functions allocates
> buffers on the stack that are passed down to the MMC device driver.
> These buffers could be unaligned to the L1 dcache line size.  This
> causes problems when using DMA and with caches enabled.
> 
> This patch correctly cache alignes the buffers used for reading the
> ext_csd data from an MMC device.
> 
> Signed-off-by: Anton Staaf <robotboy@chromium.org>
> Cc: Lukasz Majewski <l.majewski@samsung.com>
> Cc: Mike Frysinger <vapier@gentoo.org>
> Cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
> ---
>  drivers/mmc/mmc.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Patch hide | download patch | download mbox

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index ba6fbfe..e5fedb3 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -618,7 +618,7 @@  int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
 
 int mmc_change_freq(struct mmc *mmc)
 {
-	char ext_csd[512];
+	ALLOC_CACHE_ALIGN_BUFFER(char, ext_csd, 512);
 	char cardtype;
 	int err;
 
@@ -860,7 +860,7 @@  int mmc_startup(struct mmc *mmc)
 	uint mult, freq;
 	u64 cmult, csize, capacity;
 	struct mmc_cmd cmd;
-	char ext_csd[512];
+	ALLOC_CACHE_ALIGN_BUFFER(char, ext_csd, 512);
 	int timeout = 1000;
 
 #ifdef CONFIG_MMC_SPI_CRC_ON