From patchwork Wed Oct 12 23:56:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton staaf X-Patchwork-Id: 119331 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id B7691B6F65 for ; Thu, 13 Oct 2011 10:56:41 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9C11528B1F; Thu, 13 Oct 2011 01:56:34 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VMp+NwH-aiGi; Thu, 13 Oct 2011 01:56:34 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B310028A9C; Thu, 13 Oct 2011 01:56:25 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3350D28A8D for ; Thu, 13 Oct 2011 01:56:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5CUl3yK-PO1f for ; Thu, 13 Oct 2011 01:56:22 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp-out.google.com (smtp-out.google.com [216.239.44.51]) by theia.denx.de (Postfix) with ESMTPS id 0AA1228931 for ; Thu, 13 Oct 2011 01:56:21 +0200 (CEST) Received: from hpaq1.eem.corp.google.com (hpaq1.eem.corp.google.com [172.25.149.1]) by smtp-out.google.com with ESMTP id p9CNuBpA029848; Wed, 12 Oct 2011 16:56:12 -0700 Received: from servo.mtv.corp.google.com (servo.mtv.corp.google.com [172.22.72.56]) by hpaq1.eem.corp.google.com with ESMTP id p9CNu81J005722; Wed, 12 Oct 2011 16:56:08 -0700 Received: by servo.mtv.corp.google.com (Postfix, from userid 99248) id C644F4A18E; Wed, 12 Oct 2011 16:56:07 -0700 (PDT) From: Anton Staaf To: u-boot@lists.denx.de Date: Wed, 12 Oct 2011 16:56:01 -0700 Message-Id: <1318463764-28244-4-git-send-email-robotboy@chromium.org> X-Mailer: git-send-email 1.7.3.1 In-Reply-To: <1318463764-28244-1-git-send-email-robotboy@chromium.org> References: <1318463764-28244-1-git-send-email-robotboy@chromium.org> X-System-Of-Record: true Cc: Anton Staaf Subject: [U-Boot] [PATCH v3 3/6] mmc: dcache: allocate cache aligned buffer for scr and switch_status X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Currently the sd_change_freq function allocates two buffers on the stack that it passes 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 scr register and switch status values from an MMC device. Signed-off-by: Anton Staaf Acked-by: Mike Frysinger Cc: Lukasz Majewski Cc: Mike Frysinger Cc: Albert ARIBAUD Acked-by: Mike Frysinger --- drivers/mmc/mmc.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 391bc2b..ba6fbfe 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -702,8 +702,8 @@ int sd_change_freq(struct mmc *mmc) { int err; struct mmc_cmd cmd; - uint scr[2]; - uint switch_status[16]; + ALLOC_CACHE_ALIGN_BUFFER(uint, scr, 2); + ALLOC_CACHE_ALIGN_BUFFER(uint, switch_status, 16); struct mmc_data data; int timeout; @@ -731,7 +731,7 @@ int sd_change_freq(struct mmc *mmc) timeout = 3; retry_scr: - data.dest = (char *)&scr; + data.dest = (char *)scr; data.blocksize = 8; data.blocks = 1; data.flags = MMC_DATA_READ; @@ -773,7 +773,7 @@ retry_scr: timeout = 4; while (timeout--) { err = sd_switch(mmc, SD_SWITCH_CHECK, 0, 1, - (u8 *)&switch_status); + (u8 *)switch_status); if (err) return err; @@ -787,7 +787,7 @@ retry_scr: if (!(__be32_to_cpu(switch_status[3]) & SD_HIGHSPEED_SUPPORTED)) return 0; - err = sd_switch(mmc, SD_SWITCH_SWITCH, 0, 1, (u8 *)&switch_status); + err = sd_switch(mmc, SD_SWITCH_SWITCH, 0, 1, (u8 *)switch_status); if (err) return err;