From patchwork Mon Dec 27 12:05:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 12699717 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 365F3C433FE for ; Mon, 27 Dec 2021 12:09:26 +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=Mq+4n+nA+1R6gD1kbM4tYZQZtHqtXe5OLXjAIFsa2Xk=; b=Ysh5eD1+8RE7cz b0Xc2/qyhLzDm29qr7d7+BrvXGNltoG/bla71ltb9T2NRtxrm3hKjxpYYGN4nEH5ERp7GbQpmKLKu aCWQ0WxCWN4O5j15MKs9WCdq4BACUhW2utf2lKN3jzAJy22VoVOPLbHgN8b3qspMMIs4L7kWvYgDh OTGmKdzAoK1SwkM8E9qFh+ZejsFfSXUHywG9NnuRxBUwG+q8asY7YVhGOS2+QndwkRnvFT4fWW2Lp T71fspBTeB5zixyEvyzTar7wdOueSfRLHS7VDPutxGfwM5N5+16mI8PkGV9eJING/sjnOqN69OvXa +MtzDP1P6wF1iTtD4dNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n1onL-00GcRR-6b; Mon, 27 Dec 2021 12:08:03 +0000 Received: from mout.kundenserver.de ([212.227.126.135]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n1olg-00Gbsx-Sl; Mon, 27 Dec 2021 12:06:26 +0000 Received: from localhost.localdomain ([37.4.249.169]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MCsLo-1nAaBz1wDQ-008rfU; Mon, 27 Dec 2021 13:06:15 +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 05/11] dmaengine: bcm2835: move CB final extra info generation into function Date: Mon, 27 Dec 2021 13:05:39 +0100 Message-Id: <1640606743-10993-6-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:UT61IjKwl0DbobMULXOCOAAWeiIa6jN616fv3vRUKt5uXE7XPa+ V+HQ17CrbavcwDYN9f80AS++6dV1zaASSyohTOfndC19yrqlaWku863uHLG8GyFxtV00Dog Cxce5hLXBQFBq/yeb0TxcGozg/ovjCgeJLqqRX022/ynWDb1ZIvWK1AqLDWllwrfRvmicpO PcmSkMF4VLhx1zNyjFIwA== X-UI-Out-Filterresults: notjunk:1;V03:K0:sBWknKLJQQQ=:7cVpLUapyEQLtqfYq11Ktb oCvuuMFwaZuKMYd8QO0NaSTYiYnwfO45VMEwjVCOke+hu/k4ZXe6zu13ClL64U/zPh3bkiQsP uhy2/U9yR9uesiHUzjpPdeW1MveoXvp330v3GTd2f48ugdY5inKNkac00vr0OMfUpLkjh/9xq b93R4BKNLciGJBgnS8Bqwdweg/O+EOQR+KAA9wT+YhbnYCgx7ml+u5CkiKvZcw9AKPWN3p8Vu qzj/GOKANFMolTy26inh59khhUvxw2DQpz55VgfHLxhwXJ8k+PBSqoCNZ+rUOjRT2aI06MJ7w 7joqeivFXAKefp6KCSVCwF//ocmr3GsUJxDu3Zn19Woa9v0Cn98yJRmOvxEs7ppl1H2e1x3CS skrm6V3z8okFK4NIl6ouENGovvj6XQ9yKDN4jGeqKaINIjL8waY3tYiIXZlL68SwL9FzvfHlf Wd0khgFSmVZlLE8ssJextQVWNwvJLfcNoHWbiK4fK6Zw4lntmkXUKlt0OA61C26tsPsx+gWOg txaO2gDkSwNOEOCv7Zq3Daude5Go+YjKbCPoRK6ti8NFdDThlj3PKXzhOVD2ZnvyOEk2LDv2z QCRaDUMZB/aDUGXRwABlViJ/YPPs2F1h0SJgQ+i7AmZkLNmSrBsYISALKsuv0T2hWjLfm/uDG FzEmPDCSZhLO42RnXSPg6WJ9Zkkff8Nr0LvmYxoCXtLrtKkEc2rCltdtgrNgJ9uOCSkD8E6DN o3Xtd7uRCgGnahXT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211227_040621_268463_C0877868 X-CRM114-Status: GOOD ( 13.51 ) 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 Similar to the info generation, generate the final extra info with a separate function. This is necessary to introduce other platforms with different info bits. Signed-off-by: Stefan Wahren --- drivers/dma/bcm2835-dma.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 10c9ba2..863792e 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -230,6 +230,29 @@ static u32 bcm2835_dma_prepare_cb_info(struct bcm2835_chan *c, return result; } +static u32 bcm2835_dma_prepare_cb_extra(struct bcm2835_chan *c, + enum dma_transfer_direction direction, + bool cyclic, bool final, + unsigned long flags) +{ + u32 result = 0; + + if (cyclic) { + if (flags & DMA_PREP_INTERRUPT) + result |= BCM2835_DMA_INT_EN; + } else { + if (!final) + return 0; + + result |= BCM2835_DMA_INT_EN; + + if (direction == DMA_MEM_TO_MEM) + result |= BCM2835_DMA_WAIT_RESP; + } + + return result; +} + static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc) { size_t i; @@ -645,7 +668,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy( struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; u32 info = bcm2835_dma_prepare_cb_info(c, DMA_MEM_TO_MEM, false); - u32 extra = BCM2835_DMA_INT_EN | BCM2835_DMA_WAIT_RESP; + u32 extra = bcm2835_dma_prepare_cb_extra(c, DMA_MEM_TO_MEM, false, + true, 0); size_t max_len = bcm2835_dma_max_frame_length(c); size_t frames; @@ -676,7 +700,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg( struct bcm2835_desc *d; dma_addr_t src = 0, dst = 0; u32 info = bcm2835_dma_prepare_cb_info(c, direction, false); - u32 extra = BCM2835_DMA_INT_EN; + u32 extra = bcm2835_dma_prepare_cb_extra(c, direction, false, true, 0); size_t frames; if (!is_slave_direction(direction)) { @@ -724,7 +748,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( dma_addr_t src, dst; u32 info = bcm2835_dma_prepare_cb_info(c, direction, buf_addr == od->zero_page); - u32 extra = 0; + u32 extra = bcm2835_dma_prepare_cb_extra(c, direction, true, true, 0); size_t max_len = bcm2835_dma_max_frame_length(c); size_t frames; @@ -740,9 +764,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( return NULL; } - if (flags & DMA_PREP_INTERRUPT) - extra |= BCM2835_DMA_INT_EN; - else + if (!(flags & DMA_PREP_INTERRUPT)) period_len = buf_len; /*