From patchwork Mon Dec 27 12:05:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 12699719 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C3D4EC433EF for ; Mon, 27 Dec 2021 12:10:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/6bNqqovILRUpBaZ0Y7QrR7/9t3N+Dznc0/QKhjPreQ=; b=HZXu5HPr9oH4te 0nnot+32j4CuRrfGzZAsyQd7j90JA5XB1nlM9FF/2XAuteN3/OqWO4yTmTsROGZBjUHbpdc0ZXBNQ zO10Re+mUkiBTJekVXKqkYy0e63M5tWoa6urPf+uHs8JYOIyVEz/tPjU+hUk4pcbpaHCbpFLWgfl3 SD8sFU9F6XwOQJAv3i8fxXs3/42EKtLSKPk730i7dnMDB51Vmna8D2GDUX2LMC6yNvKH870cjNYK7 DrR0Jj/qoxdJspfOm353yizvR6TaMJ7dtxoacpb+9H3FxKqa0VmtKyiiJlpI7SYyqVbS69ZAvVGrx K3Jkzzf1yMMwEf49fHzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n1ont-00Gckh-4j; Mon, 27 Dec 2021 12:08:37 +0000 Received: from mout.kundenserver.de ([212.227.126.187]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n1oli-00GbtJ-Mm; Mon, 27 Dec 2021 12:06:29 +0000 Received: from localhost.localdomain ([37.4.249.169]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MkYkI-1magg545FO-00m2RS; Mon, 27 Dec 2021 13:06:16 +0100 From: Stefan Wahren To: Vinod Koul , Rob Herring , Florian Fainelli , Nicolas Saenz Julienne Cc: Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, dmaengine@vger.kernel.org, Phil Elwell , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Lukas Wunner , linux-rpi-kernel@lists.infradead.org, Stefan Wahren Subject: [PATCH RFC 06/11] dmaengine: bcm2835: make address increment platform independent Date: Mon, 27 Dec 2021 13:05:40 +0100 Message-Id: <1640606743-10993-7-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1640606743-10993-1-git-send-email-stefan.wahren@i2se.com> References: <1640606743-10993-1-git-send-email-stefan.wahren@i2se.com> X-Provags-ID: V03:K1:HrffKyC4m6ikFaJSkU6yeCuvlOClCWXEx4SVySiaZWR2sYV95iQ BgBYtZxP6knwrhszIG5N6afpgRnMTzau0G6fS+Rs2DMd+Nvrh2Ca4bN4EAr1jKTIbnGtbjo 7hjfBm4WQrOfcoyiaPR1jV0MXBqj8/GplXipQ21YhDGLi9hjg+mV1WWEFzdO6dL4Cadlgb9 /rP2OAS/q/m0PBs5YvyUA== X-UI-Out-Filterresults: notjunk:1;V03:K0:DXG1JcMei24=:cHwkAopfBiYzTK5pSHm0yY X+TUWkiYWFgzoqiAzMyAPovCn5PbMF25gZ7ZHvRRqtnE2zGAwSdKfWzWqdAnERAYG6oLjCHsU 2S4DIfiY2ja3/ge87akcdohMjqEwr1H7dZOpooqquDc2mh595daLKhSXt8yAzKTU4AZpQfg7W M8gfpr8J12DSvW1I9EkUGU9f0dIyz4X3qJMcDEVoObxb8PuEUaegm02X25OOz2vBnoE+fUtcA vjYBgStX9c/Nn1RV2DPJzVXiHV77IJndmOoluNbQLWlIdc7qFqk5yvvXsZllcaduGHt/bW4Nb 1cQRlmHxz0AuL4tlDPRxseqnvHQ2jM6MaO3T93oVXpiO4INTn0YWh+m7L3RKjBFnjv3qMptPF H+xoMKe41G5U5pHYiTK1eOULP1OCfOf3Tj+BHxATBjWMGOH1P+WGCV1blJnB4f3gw0HmpT9oK 8xCf0xAYp+tMW7BULKTp4PBrLPTpXUQWibyL+oxOd3UgoqWWZZ6Zp4jhulMJ4ZEP1vKi3/stG TbYsqEwEvJbmM1dMR1aU44HvUaKYCMnudI5tv2YbUPvFBPTP51NRtoCKtkGcL6hddzcOvhEvP RIi+8Lb+fLpetYfbTJpNGN2twEqhCftDfh9ZP5i/CuOYsfl8IBWGxoK9cNp/n/E7PJ45//HSZ dvtYgSegso+lH9H9+Jjk6h1SH5KJiTZHYmyoADlj2ugLawP59TZiHQbCtodgtT7fzrtdhuuUY WpzY5n2GEqgzrlXS X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211227_040623_117820_C7551505 X-CRM114-Status: GOOD ( 14.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 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+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Actually the criteria to increment source & destination address doesn't based on platform specific bits. It's just the DMA transfer direction which is translated into the info bits. So introduce two new helper functions and get the rid of these platform specifics. Signed-off-by: Stefan Wahren --- drivers/dma/bcm2835-dma.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 863792e..a7b9f88 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -253,6 +253,24 @@ static u32 bcm2835_dma_prepare_cb_extra(struct bcm2835_chan *c, return result; } +static inline bool need_src_incr(enum dma_transfer_direction direction) +{ + return direction != DMA_DEV_TO_MEM; +} + +static inline bool need_dst_incr(enum dma_transfer_direction direction) +{ + switch (direction) { + case DMA_MEM_TO_MEM: + case DMA_DEV_TO_MEM: + return true; + default: + break; + } + + return false; +} + static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc) { size_t i; @@ -337,10 +355,8 @@ static inline size_t bcm2835_dma_count_frames_for_sg( * @cyclic: it is a cyclic transfer * @info: the default info bits to apply per controlblock * @frames: number of controlblocks to allocate - * @src: the src address to assign (if the S_INC bit is set - * in @info, then it gets incremented) - * @dst: the dst address to assign (if the D_INC bit is set - * in @info, then it gets incremented) + * @src: the src address to assign + * @dst: the dst address to assign * @buf_len: the full buffer length (may also be 0) * @period_len: the period length when to apply @finalextrainfo * in addition to the last transfer @@ -409,9 +425,9 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( d->cb_list[frame - 1].cb->next = cb_entry->paddr; /* update src and dst and length */ - if (src && (info & BCM2835_DMA_S_INC)) + if (src && need_src_incr(direction)) src += control_block->length; - if (dst && (info & BCM2835_DMA_D_INC)) + if (dst && need_dst_incr(direction)) dst += control_block->length; /* Length of total transfer */