From patchwork Thu Nov 13 11:56:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Agner X-Patchwork-Id: 5296031 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AA829C11AC for ; Thu, 13 Nov 2014 12:05:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D7BE8201F4 for ; Thu, 13 Nov 2014 12:05:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0BD08201EF for ; Thu, 13 Nov 2014 12:05:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932783AbaKMMF1 (ORCPT ); Thu, 13 Nov 2014 07:05:27 -0500 Received: from mail.kmu-office.ch ([178.209.48.109]:53812 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932596AbaKMMF1 (ORCPT ); Thu, 13 Nov 2014 07:05:27 -0500 X-Greylist: delayed 545 seconds by postgrey-1.27 at vger.kernel.org; Thu, 13 Nov 2014 07:05:27 EST Received: from trochilidae.toradex.int (unknown [46.140.72.82]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 136795E3297; Thu, 13 Nov 2014 12:56:16 +0100 (CET) From: Stefan Agner To: vinod.koul@intel.com Cc: jingchang.lu@freescale.com, dan.j.williams@intel.com, dmaengine@vger.kernel.org, shawn.guo@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, Stefan Agner Subject: [PATCH] dmaengine: fsl-edma: fix calculation of remaining bytes Date: Thu, 13 Nov 2014 12:56:02 +0100 Message-Id: <1415879762-12177-1-git-send-email-stefan@agner.ch> X-Mailer: git-send-email 2.1.3 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the current transfer control descriptor (TCD) was not yet started, the address will be the same as the initial address. Hence test if the current address is less than or equal to the start address of each TCD. Signed-off-by: Stefan Agner --- This bug was discovered during development on a AC97 capable SAI driver, I don't think that this is currently a issue since only a few drivers use DMA on Vybrid so far and don't use the remaining bytes information. drivers/dma/fsl-edma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/fsl-edma.c b/drivers/dma/fsl-edma.c index 3c5711d..58c6fc7 100644 --- a/drivers/dma/fsl-edma.c +++ b/drivers/dma/fsl-edma.c @@ -386,7 +386,7 @@ static size_t fsl_edma_desc_residue(struct fsl_edma_chan *fsl_chan, &(edesc->tcd[i].vtcd->daddr)); len -= size; - if (cur_addr > dma_addr && cur_addr < dma_addr + size) { + if (cur_addr >= dma_addr && cur_addr < dma_addr + size) { len += dma_addr + size - cur_addr; break; }