From patchwork Fri Nov 7 18:05:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jon Medhurst \(Tixy\)" X-Patchwork-Id: 40446 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AC76A218C0 for ; Fri, 7 Nov 2014 18:08:06 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id ex7sf2191734wid.8 for ; Fri, 07 Nov 2014 10:08:05 -0800 (PST) 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:subject:date:message-id :in-reply-to:references:cc: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=dpH2VCz0BMDM7t2WHWFSSQ9l5sEOMe/wXa+WLTR5XxM=; b=HzoXHQAU5/pY6rO3zCWP6k6636lMdnTwhKDkTBfZiPlmUdDXBfm51qj+PVgyLUKXgJ Q4uYtnfzDaPZYTSB1SBjDmdnaq6cupyfY81WZtO9Xtpw6vHj+H8aq59fVJaNNiKsIpCo VbiPx42RDlkoRU4/b/8pq/3H8yBK1Rc0fZ9AgmihyyU81qIJ0rl2cOX7OPiV1ifTfPSg 60xWGqpjdvj0t0EbWW8Ggs3EJ545sunY+xsvx8EdXeVqkJeDD25+l5jZfmVVrTENoIFs 8d05BTPJx4sqjBh4lAantqISRpQIBJ8jSpwcjL1ALKKcE1o46WFLbFDs0A48ttJTnu+5 +m1g== X-Gm-Message-State: ALoCoQmZucbEGzWp1fCXNN9Wu+iU0GUxFTu9cunWqZRz3mV2UrUM3laEi0PbeQ3Qr7Q+qqH8rIGq X-Received: by 10.194.191.137 with SMTP id gy9mr2236724wjc.0.1415383685653; Fri, 07 Nov 2014 10:08:05 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.26.228 with SMTP id o4ls220234lag.66.gmail; Fri, 07 Nov 2014 10:08:05 -0800 (PST) X-Received: by 10.152.30.9 with SMTP id o9mr12864419lah.8.1415383685198; Fri, 07 Nov 2014 10:08:05 -0800 (PST) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id h3si15869379laa.106.2014.11.07.10.08.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Nov 2014 10:08:05 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by mail-la0-f41.google.com with SMTP id s18so4854282lam.14 for ; Fri, 07 Nov 2014 10:08:05 -0800 (PST) X-Received: by 10.112.235.196 with SMTP id uo4mr3506255lbc.66.1415383685055; Fri, 07 Nov 2014 10:08:05 -0800 (PST) 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.184.201 with SMTP id ew9csp245703lbc; Fri, 7 Nov 2014 10:08:04 -0800 (PST) X-Received: by 10.70.34.44 with SMTP id w12mr13700556pdi.151.1415383682668; Fri, 07 Nov 2014 10:08:02 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ng11si4039500pdb.165.2014.11.07.10.08.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Nov 2014 10:08:02 -0800 (PST) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xmnvo-0004WK-Iq; Fri, 07 Nov 2014 18:06:44 +0000 Received: from smarthost01a.mail.zen.net.uk ([212.23.1.1]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xmnvf-0004SK-3r for linux-arm-kernel@lists.infradead.org; Fri, 07 Nov 2014 18:06:36 +0000 Received: from [82.69.122.217] (helo=plug1) by smarthost01a.mail.zen.net.uk with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1XmnvC-0000ZR-Ma; Fri, 07 Nov 2014 18:06:06 +0000 Received: from linaro1 ([192.168.2.110] helo=linaro1.home) by plug1 with esmtp (Exim 4.80) (envelope-from ) id 1Xmnv9-0002Dg-5E; Fri, 07 Nov 2014 18:06:03 +0000 Received: from tixy by linaro1.home with local (Exim 4.84) (envelope-from ) id 1Xmnv9-0007dv-3g; Fri, 07 Nov 2014 18:06:03 +0000 From: Jon Medhurst To: Vinod Koul , Dan Williams , dmaengine@vger.kernel.org Subject: [PATCH 1/2] dma: pl330: Align DMA memcpy operations to MFIFO width Date: Fri, 7 Nov 2014 18:05:17 +0000 Message-Id: <1415383518-29327-2-git-send-email-tixy@linaro.org> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1415383518-29327-1-git-send-email-tixy@linaro.org> References: <1415383518-29327-1-git-send-email-tixy@linaro.org> X-Originating-smarthost01a-IP: [82.69.122.217] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141107_100635_322236_8BA333B7 X-CRM114-Status: GOOD ( 10.72 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [212.23.1.1 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [212.23.1.1 listed in wl.mailspike.net] 0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: tixy@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.41 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 The algorithm used for programming the DMA Controller doesn't take into consideration the requirements of transfers that are not aligned to the bus width. This failure may result in DMA transferring one too few MFIFO entries (so too few bytes are copied) or the DMA trying to write one too many MFIFO entries and hanging because this is never provided. See "MFIFO Usage Overview" chapter in the the TRM for "CoreLink DMA Controller DMA-330", Revision r1p1. We work around these shortcomings by making sure we pick a burst size and length which ensures no bursts straddle an MFIFO entry. Signed-off-by: Jon Medhurst --- drivers/dma/pl330.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 4839bfa..8f869ec 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -2459,8 +2459,13 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst, /* Select max possible burst size */ burst = pl330->pcfg.data_bus_width / 8; + /* + * Make sure we use a burst size that aligns with all the memcpy + * parameters because our DMA programming algorithm doesn't cope with + * transfers which straddle an entry in the DMA device's MFIFO. + */ while (burst > 1) { - if (!(len % burst)) + if (!((src | dst | len) % burst)) break; burst /= 2; } @@ -2469,6 +2474,13 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst, while (burst != (1 << desc->rqcfg.brst_size)) desc->rqcfg.brst_size++; + /* + * If burst size is smaller than bus width then make sure we only + * transfer one at a time to avoid a burst stradling an MFIFO entry. + */ + if (desc->rqcfg.brst_size * 8 < pl330->pcfg.data_bus_width) + desc->rqcfg.brst_len = 1; + desc->rqcfg.brst_len = get_burst_len(desc, len); desc->txd.flags = flags;