From patchwork Tue Oct 21 17:48:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Scott X-Patchwork-Id: 39215 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 308F42039B for ; Tue, 21 Oct 2014 18:01:55 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id b13sf1128334wgh.0 for ; Tue, 21 Oct 2014 11:01:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:cc:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=hNMNfhGmIEClsBqS6pE5ZJKJMm/OGXfq3SpLBJ2YyR0=; b=lBmARR9hF6W5uDDr6d0Eg2TwZmBiGNCHTUIk+61CJmxvMnKG7TwVyPreTzx8HhLJIr Dlvlf+9OFxOXshVm3A6lAnr8SuY0QzN2Bbge76rwOPWNlH9txq74p2Vfwod4psF1tfJw JpWZ/zoG3/zIBn1KkT3sjCZ6qAAej/NRmKL7/MbP55cQ4kZDOYv9Nc0v6NsbFmSnSh1C 0zVbA9aI1YGQRivwIlfv+P+C2CVFtF6fjB4XobOu/iH/iTqXYzn40VK4thOuvD4rNkOW Zz68/U4LSzOF2GydJWrJBg8uS4Qtmj6+/NwybduC8hEIeJjcSNCXuVVZc1RJSJ4auaSo YPvw== X-Gm-Message-State: ALoCoQlS670lQqLu6SYnG7sEApTO7ci/nbaLlZrviiVqBiQnkzIOaIel71KTKkw0p8yXBzj5zOCo X-Received: by 10.180.105.74 with SMTP id gk10mr4626360wib.0.1413914514002; Tue, 21 Oct 2014 11:01:54 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.18.202 with SMTP id y10ls85904lad.51.gmail; Tue, 21 Oct 2014 11:01:53 -0700 (PDT) X-Received: by 10.112.247.43 with SMTP id yb11mr36628760lbc.51.1413914513640; Tue, 21 Oct 2014 11:01:53 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id k3si20159906lbs.64.2014.10.21.11.01.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 21 Oct 2014 11:01:53 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by mail-la0-f42.google.com with SMTP id gf13so1715145lab.15 for ; Tue, 21 Oct 2014 11:01:53 -0700 (PDT) X-Received: by 10.112.130.41 with SMTP id ob9mr35855011lbb.74.1413914513454; Tue, 21 Oct 2014 11:01:53 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp553515lbz; Tue, 21 Oct 2014 11:01:53 -0700 (PDT) X-Received: by 10.180.14.73 with SMTP id n9mr31685204wic.39.1413914512887; Tue, 21 Oct 2014 11:01:52 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id r8si13761836wjr.90.2014.10.21.11.01.51 for ; Tue, 21 Oct 2014 11:01:52 -0700 (PDT) Received-SPF: none (google.com: u-boot-bounces@lists.denx.de does not designate permitted sender hosts) client-ip=85.214.87.163; Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 372E74B657; Tue, 21 Oct 2014 20:01:49 +0200 (CEST) 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 6bbArUrqwz47; Tue, 21 Oct 2014 20:01:48 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7D22D4B62C; Tue, 21 Oct 2014 20:01:48 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A8182A73EC for ; Tue, 21 Oct 2014 19:48:28 +0200 (CEST) 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 vnsii1BAeG2Z for ; Tue, 21 Oct 2014 19:48:28 +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 mail-oi0-f46.google.com (mail-oi0-f46.google.com [209.85.218.46]) by theia.denx.de (Postfix) with ESMTPS id 4AE1DA73E7 for ; Tue, 21 Oct 2014 19:48:24 +0200 (CEST) Received: by mail-oi0-f46.google.com with SMTP id h136so1372304oig.19 for ; Tue, 21 Oct 2014 10:48:23 -0700 (PDT) X-Received: by 10.60.76.72 with SMTP id i8mr3598665oew.53.1413913703354; Tue, 21 Oct 2014 10:48:23 -0700 (PDT) Received: from localhost.localdomain (172-2-231-169.lightspeed.irvnca.sbcglobal.net. [172.2.231.169]) by mx.google.com with ESMTPSA id c191sm5440158oid.14.2014.10.21.10.48.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Oct 2014 10:48:22 -0700 (PDT) From: Michael Scott To: u-boot@lists.denx.de Date: Tue, 21 Oct 2014 10:48:08 -0700 Message-Id: <1413913688-5073-1-git-send-email-michael.scott@linaro.org> X-Mailer: git-send-email 1.9.1 X-Mailman-Approved-At: Tue, 21 Oct 2014 20:01:47 +0200 Cc: Stephen Warren , Tom Warren , Michael Scott Subject: [U-Boot] [PATCH] mmc: tegra: handle error returned from bounce_buffer_start X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: 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 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: michael.scott@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Function bounce_buffer_start can return ENOMEM when memalign fails, but the error code is never checked. One such failure happens when state->len_aligned is larger than the remaining free memory (set via CONFIG_SYS_MALLOC_LEN). This leaves state->bounce_buffer as a NULL. If unchecked, the tegra_mmc driver writes the entire block as a 0xFF and will continue on its way. Let's handle this error by printing that it happened, and then return it up the chain. This bug was discoverd during fastboot flashing of sparse images. A pointer is moved through buffered data and often needs to be DMA aligned prior to MMC write. These blocks are are often more than 4mb which is the default Tegra setting for CONFIG_SYS_MALLOC_LEN. Signed-off-by: Michael Scott Cc: Tom Warren Cc: Stephen Warren --- drivers/mmc/tegra_mmc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/tegra_mmc.c b/drivers/mmc/tegra_mmc.c index ca9c4aa..5ecc2c9 100644 --- a/drivers/mmc/tegra_mmc.c +++ b/drivers/mmc/tegra_mmc.c @@ -332,7 +332,13 @@ static int tegra_mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, } len = data->blocks * data->blocksize; - bounce_buffer_start(&bbstate, buf, len, bbflags); + ret = bounce_buffer_start(&bbstate, buf, len, bbflags); + if (ret) { + printf("%s: bounce_buffer_start failed with error %d " + "(buf = %p, len = %u, flags = %u)\n", + __func__, ret, buf, len, bbflags); + return ret; + } } ret = mmc_send_cmd_bounced(mmc, cmd, data, &bbstate);