From patchwork Thu Jul 28 14:29:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ludovic Desroches X-Patchwork-Id: 1015492 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6SDO9K5003204 for ; Thu, 28 Jul 2011 13:24:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755394Ab1G1NYK (ORCPT ); Thu, 28 Jul 2011 09:24:10 -0400 Received: from newsmtp5.atmel.com ([204.2.163.5]:27064 "EHLO sjogate2.atmel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754106Ab1G1NYJ (ORCPT ); Thu, 28 Jul 2011 09:24:09 -0400 Received: from meyreuil.atmel.fr ([10.159.254.132]) by sjogate2.atmel.com (8.13.6/8.13.6) with ESMTP id p6SDKfeZ015662; Thu, 28 Jul 2011 06:20:41 -0700 (PDT) Received: from bendor.rfo.atmel.com ([10.159.245.201]) by meyreuil.atmel.fr (8.11.7p1+Sun/8.11.7) with ESMTP id p6SDNpa27069; Thu, 28 Jul 2011 15:23:51 +0200 (MEST) From: ludovic.desroches@atmel.com To: linux-arm-kernel@lists.infradead.org, linux-mmc@vger.kernel.org Cc: patrice.vilchez@atmel.com, nicolas.ferre@atmel.com, plagnioj@jcrosoft.com, Ludovic Desroches Subject: [RFC PATCH 8/9] mmc: atmel-mci: correct sg buffer size evaluation Date: Thu, 28 Jul 2011 16:29:57 +0200 Message-Id: <1311863398-31579-9-git-send-email-ludovic.desroches@atmel.com> X-Mailer: git-send-email 1.7.5 In-Reply-To: <1311863398-31579-1-git-send-email-ludovic.desroches@atmel.com> References: <1311863398-31579-1-git-send-email-ludovic.desroches@atmel.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 28 Jul 2011 13:24:11 +0000 (UTC) From: Ludovic Desroches Assuming that a sg buffer size is a page size is false so use sg_dma_len. A 4096 bytes can be required with two 2048-bytes sg buffer. Signed-off-by: Ludovic Desroches --- drivers/mmc/host/atmel-mci.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index c415322..963e320 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c @@ -608,7 +608,7 @@ static void atmci_pdc_set_single_buf(struct atmel_mci *host, } atmci_writel(host, pointer_reg, sg_dma_address(host->sg)); - if (host->data_size <= PAGE_SIZE) { + if (host->data_size <= sg_dma_len(host->sg)) { if (host->data_size & 0x3) { /* If size is different from modulo 4, transfer bytes */ atmci_writel(host, counter_reg, host->data_size); @@ -620,8 +620,8 @@ static void atmci_pdc_set_single_buf(struct atmel_mci *host, host->data_size = 0; } else { /* We assume the size of a page is 32-bits aligned */ - atmci_writel(host, counter_reg, PAGE_SIZE / 4); - host->data_size -= PAGE_SIZE; + atmci_writel(host, counter_reg, sg_dma_len(host->sg) / 4); + host->data_size -= sg_dma_len(host->sg); if (host->data_size) host->sg = sg_next(host->sg); } @@ -808,7 +808,6 @@ atmci_prepare_data_pdc(struct atmel_mci *host, struct mmc_data *data) /* Configure PDC */ host->data_size = data->blocks * data->blksz; sg_len = dma_map_sg(&host->pdev->dev, data->sg, data->sg_len, dir); - BUG_ON(sg_len < host->data_size / PAGE_SIZE); if (host->data_size) atmci_pdc_set_both_buf(host, ((dir == DMA_FROM_DEVICE)?XFER_RECEIVE:XFER_TRANSMIT));