From patchwork Tue Jul 22 12:33:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 4601911 X-Patchwork-Delegate: vinod.koul@intel.com 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 EC7D3C0515 for ; Tue, 22 Jul 2014 12:33:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EB2F820154 for ; Tue, 22 Jul 2014 12:33:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C8742015A for ; Tue, 22 Jul 2014 12:33:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752263AbaGVMds (ORCPT ); Tue, 22 Jul 2014 08:33:48 -0400 Received: from perceval.ideasonboard.com ([95.142.166.194]:41658 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753375AbaGVMdr (ORCPT ); Tue, 22 Jul 2014 08:33:47 -0400 Received: from avalon.ideasonboard.com (29-78-169-81.mobileinternet.proximus.be [81.169.78.29]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3713D359FE; Tue, 22 Jul 2014 14:32:36 +0200 (CEST) From: Laurent Pinchart To: dmaengine@vger.kernel.org Cc: linux-sh@vger.kernel.org, Kuninori Morimoto , Magnus Damm Subject: [PATCH/RFC 3/5] dmaengine: rcar-dmac: Compute maximum chunk size at runtime Date: Tue, 22 Jul 2014 14:33:49 +0200 Message-Id: <1406032431-3807-4-git-send-email-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 1.8.5.5 In-Reply-To: <1406032431-3807-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> References: <1406032431-3807-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-6.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 The DMAC expressed DMA request lengths as a number of transfers, limited to 16777216 by the hardware. As a single transfer transfers a configurable number of bytes (from 1 to 64), the chunk size limit isn't fixed and must be computed at runtime by multiplying the transfers number limit by the transfer size. Signed-off-by: Laurent Pinchart --- drivers/dma/sh/rcar-dmac.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c index 09df914..371cca3 100644 --- a/drivers/dma/sh/rcar-dmac.c +++ b/drivers/dma/sh/rcar-dmac.c @@ -242,7 +242,6 @@ struct rcar_dmac { /* Hardcode the MEMCPY transfer size to 4 bytes. */ #define RCAR_DMAC_MEMCPY_XFER_SIZE 4 -#define RCAR_DMAC_MAX_XFER_LEN (RCAR_DMATCR_MASK + 1) /* ----------------------------------------------------------------------------- * Device access @@ -701,6 +700,7 @@ rcar_dmac_chan_prep_sg(struct rcar_dmac_chan *chan, struct scatterlist *sgl, struct rcar_dmac_xfer_chunk *chunk; struct rcar_dmac_desc *desc; struct scatterlist *sg = sgl; + size_t max_chunk_size; size_t full_size = 0; unsigned int i; @@ -716,6 +716,8 @@ rcar_dmac_chan_prep_sg(struct rcar_dmac_chan *chan, struct scatterlist *sgl, rcar_dmac_chan_configure_desc(chan, desc); + max_chunk_size = (RCAR_DMATCR_MASK + 1) << desc->xfer_shift; + /* * Allocate and fill the transfer chunk descriptors. We own the only * reference to the DMA descriptor, there's no need for locking. @@ -727,7 +729,7 @@ rcar_dmac_chan_prep_sg(struct rcar_dmac_chan *chan, struct scatterlist *sgl, full_size += len; while (len) { - size_t size = min_t(size_t, len, RCAR_DMAC_MAX_XFER_LEN); + size_t size = min_t(size_t, len, max_chunk_size); #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT /*