From patchwork Fri Sep 7 06:24:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 10591709 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 111E35A4 for ; Fri, 7 Sep 2018 06:26:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00B922AD7C for ; Fri, 7 Sep 2018 06:26:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E8B752AD88; Fri, 7 Sep 2018 06:26:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 940042AD93 for ; Fri, 7 Sep 2018 06:26:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726099AbeIGLEn (ORCPT ); Fri, 7 Sep 2018 07:04:43 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:36017 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725831AbeIGLEn (ORCPT ); Fri, 7 Sep 2018 07:04:43 -0400 Received: by mail-wr1-f68.google.com with SMTP id e1-v6so4659383wrt.3; Thu, 06 Sep 2018 23:25:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Fo4uTu35nfqETk1eWWm0rsB3UI2a2lLeir3RiOJ544s=; b=LFlx4YzX5Ya7qjOtnIVcTKcznS6oeSSl96/9Eol2DoVDZV4tfaciINHpN5I28FWHp5 FG+kdQfb8vZtSonZm3U4no34XsHQOlhf4Y9GmoBSPYK8ekVWtjiHQzdvJSlxEPt/8U+g zxEH+zMHN6dGDO3DcgmSh83wEbx+CUSvQgO8+277LyiMTom+cSSwCZXPvI73+fMFG+7N dXQ+EGHqUX5PQrpDh7Eh2X+v7NhTKJ/FgDZw7ssdxbxRVuDDsevkauPGWdHAN5ZE2YfC lgL1CiEcDuf2esZnwYcvGdzEtx/U/5gBnlbNVOW1zuwKXbdKJUNsosBpSIAJeJ+LCY0D kDyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Fo4uTu35nfqETk1eWWm0rsB3UI2a2lLeir3RiOJ544s=; b=lG+kZoVIAFw3ZatCQOchiOrT7t92BpYEHQOvdefnZuPzpL0yclmRaDrlbeL2lbagxb ROu3HO4RWHNxZbEakUoxtvxQHRzFef5+iA1zHteWzA3flDHSgJh4QW018xd6U9MxVN6v 7NBbYPWYFCtYcrk2ogII6DZY5x0fDA9eE4pkN0vW5olANbPZtXKQmLIGbV7pV5dVWt1V 8JTYFlhZb9vZw6nRlka9ad0Z815Fmw3rdB0/dxWPa45XOMcbx56+oXu0nbbKpcMH7xzc 37zB7/K7l1BaDRlVDJrtjwNSbu8E5WvDeJhr9yXmOhzLwQGlJxdjfq7NYKUdmLfbQm8K cCsw== X-Gm-Message-State: APzg51ATqQUZBxQHlEsR8yzNSEw7STZH+Pse8fOb4yAb/UJrsjHRwhK0 OSlHM8gSmg2Irpf15Cl8vdk= X-Google-Smtp-Source: ANB0VdYTWL2yOchrIoG9vcULbX7veGh8LNTcSKTcf8Y3FzjiOgnNtos3Ep7jw0Hit8PVEqHbLRL7HA== X-Received: by 2002:adf:a3d9:: with SMTP id m25-v6mr4974145wrb.1.1536301519078; Thu, 06 Sep 2018 23:25:19 -0700 (PDT) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id w10-v6sm8387233wrp.31.2018.09.06.23.25.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 23:25:18 -0700 (PDT) From: Andrea Merello To: vkoul@kernel.org, dan.j.williams@intel.com, michal.simek@xilinx.com, appana.durga.rao@xilinx.com, dmaengine@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, radhey.shyam.pandey@xilinx.com, Andrea Merello Subject: [PATCH v5 1/7] dmaengine: xilinx_dma: commonize DMA copy size calculation Date: Fri, 7 Sep 2018 08:24:56 +0200 Message-Id: <20180907062502.8241-1-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch removes a bit of duplicated code by introducing a new function that implements calculations for DMA copy size. Suggested-by: Vinod Koul Signed-off-by: Andrea Merello --- Changes in v4: - introduce this patch in the patch series Changes in v5: None --- drivers/dma/xilinx/xilinx_dma.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c index 27b523530c4a..a3aaa0e34cc7 100644 --- a/drivers/dma/xilinx/xilinx_dma.c +++ b/drivers/dma/xilinx/xilinx_dma.c @@ -952,6 +952,19 @@ static int xilinx_dma_alloc_chan_resources(struct dma_chan *dchan) return 0; } +/** + * xilinx_dma_calc_copysize - Calculate the amount of data to copy + * @size: Total data that needs to be copied + * @done: Amount of data that has been already copied + * + * Return: Amount of data that has to be copied + */ +static int xilinx_dma_calc_copysize(int size, int done) +{ + return min_t(size_t, size - done, + XILINX_DMA_MAX_TRANS_LEN); +} + /** * xilinx_dma_tx_status - Get DMA transaction status * @dchan: DMA channel @@ -1791,8 +1804,8 @@ static struct dma_async_tx_descriptor *xilinx_dma_prep_slave_sg( * Calculate the maximum number of bytes to transfer, * making sure it is less than the hw limit */ - copy = min_t(size_t, sg_dma_len(sg) - sg_used, - XILINX_DMA_MAX_TRANS_LEN); + copy = xilinx_dma_calc_copysize(sg_dma_len(sg), + sg_used); hw = &segment->hw; /* Fill in the descriptor */ @@ -1896,8 +1909,7 @@ static struct dma_async_tx_descriptor *xilinx_dma_prep_dma_cyclic( * Calculate the maximum number of bytes to transfer, * making sure it is less than the hw limit */ - copy = min_t(size_t, period_len - sg_used, - XILINX_DMA_MAX_TRANS_LEN); + copy = xilinx_dma_calc_copysize(period_len, sg_used); hw = &segment->hw; xilinx_axidma_buf(chan, hw, buf_addr, sg_used, period_len * i); From patchwork Fri Sep 7 06:24:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 10591707 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7FD505A4 for ; Fri, 7 Sep 2018 06:25:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C6952AD7C for ; Fri, 7 Sep 2018 06:25:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6050B2AD93; Fri, 7 Sep 2018 06:25:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F278A2AD7C for ; Fri, 7 Sep 2018 06:25:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727529AbeIGLEq (ORCPT ); Fri, 7 Sep 2018 07:04:46 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:32970 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725970AbeIGLEp (ORCPT ); Fri, 7 Sep 2018 07:04:45 -0400 Received: by mail-wr1-f65.google.com with SMTP id v90-v6so13772107wrc.0; Thu, 06 Sep 2018 23:25:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=G0d4E4UUBGUZ+uqudEZiIppK0s4vLLe5noMqkvJPkuU=; b=Pgh9G8deVvztHjVCwyJuRM0Ll6p/RwKoE5lKIPkqaSYFJe7qQ2sasOolra9ymO+Z+2 T9QWgs+2b9wumUqRt/bfnO+lNtf4ITFhaP1yo0RuugFQRpf7WBNO8+YdZ8/gV6XnveGN bnMmAHFYUiM2+jLgrvIsjpm2bdh110HQSJJq5Z1SAq+gw/gItdo3WGKxzCio39lLss0y rfUDac+tuLoBzYNruVTM9MzpXPETZKg7qC6peESB6mVJ8QnEzXxh7VdS5thpZJQsHOEA W3CCBKtZ3Oa8iP26tYaZt3w1rRY+Sb7b4ylMWCpXE1GLlyDIoD7QAzsbE3D29/OhR+f6 Q7rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=G0d4E4UUBGUZ+uqudEZiIppK0s4vLLe5noMqkvJPkuU=; b=IVlA3dNQH3qWvt9F/5S/bXrWWxai3QcgWr8dxYNTsL/peqMuallZV247MVVLm2bC1x 5nuGpQ9ibVZKg0KC4+PUoxvnHzAiM5JGL7K08sASwF2O1fJ5wHy8bspt0Jar8SVkCADL OPt6D92eR8bXiibppaouQ1wRskJNWLyV45i3jhE+0YmUHqO2JuvciRPWg1EoF4nNrv7R Y2kdn+eRC/bUwuZEFEPAX9IuF6TDN4b9xDDo6qIWqEI2u46TFz9ZZ2zdIjnd49+0oQsl i+szVl6RxRQ/5lyTNB8dAz2ygWcUQ0R2QBYygJ5gLXmFYi606tpXQTexEW8Ee+qDFcuE Uqqg== X-Gm-Message-State: APzg51BOKnhttDe9C0fGkrnpOP37YuEBWsjE0qpeYDk1ZW12keIy75iI UZF78XK4Vq1WPweOpKczIBs= X-Google-Smtp-Source: ANB0VdbHcQABVeP+3wDtH9ye0milPJ4WQpEcq3N4Md1LnllLiKvm4bV3NzGKaau9GlVQnbp7CC/6Rw== X-Received: by 2002:adf:93c2:: with SMTP id 60-v6mr4495773wrp.81.1536301520318; Thu, 06 Sep 2018 23:25:20 -0700 (PDT) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id w10-v6sm8387233wrp.31.2018.09.06.23.25.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 23:25:19 -0700 (PDT) From: Andrea Merello To: vkoul@kernel.org, dan.j.williams@intel.com, michal.simek@xilinx.com, appana.durga.rao@xilinx.com, dmaengine@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, radhey.shyam.pandey@xilinx.com, Andrea Merello Subject: [PATCH v5 2/7] dmaengine: xilinx_dma: in axidma slave_sg and dma_cyclic mode align split descriptors Date: Fri, 7 Sep 2018 08:24:57 +0200 Message-Id: <20180907062502.8241-2-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180907062502.8241-1-andrea.merello@gmail.com> References: <20180907062502.8241-1-andrea.merello@gmail.com> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Whenever a single or cyclic transaction is prepared, the driver could eventually split it over several SG descriptors in order to deal with the HW maximum transfer length. This could end up in DMA operations starting from a misaligned address. This seems fatal for the HW if DRE (Data Realignment Engine) is not enabled. This patch eventually adjusts the transfer size in order to make sure all operations start from an aligned address. Cc: Radhey Shyam Pandey Signed-off-by: Andrea Merello Reviewed-by: Radhey Shyam Pandey --- Changes in v2: - don't introduce copy_mask field, rather rely on already-esistent copy_align field. Suggested by Radhey Shyam Pandey - reword title Changes in v3: - fix bug introduced in v2: wrong copy size when DRE is enabled - use implementation suggested by Radhey Shyam Pandey Changes in v4: - rework on the top of 1/6 Changes in v5: - fix typo in commit title - add hint about "DRE" meaning in commit message --- drivers/dma/xilinx/xilinx_dma.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c index a3aaa0e34cc7..aaa6de8a70e4 100644 --- a/drivers/dma/xilinx/xilinx_dma.c +++ b/drivers/dma/xilinx/xilinx_dma.c @@ -954,15 +954,28 @@ static int xilinx_dma_alloc_chan_resources(struct dma_chan *dchan) /** * xilinx_dma_calc_copysize - Calculate the amount of data to copy + * @chan: Driver specific DMA channel * @size: Total data that needs to be copied * @done: Amount of data that has been already copied * * Return: Amount of data that has to be copied */ -static int xilinx_dma_calc_copysize(int size, int done) +static int xilinx_dma_calc_copysize(struct xilinx_dma_chan *chan, + int size, int done) { - return min_t(size_t, size - done, + size_t copy = min_t(size_t, size - done, XILINX_DMA_MAX_TRANS_LEN); + + if ((copy + done < size) && + chan->xdev->common.copy_align) { + /* + * If this is not the last descriptor, make sure + * the next one will be properly aligned + */ + copy = rounddown(copy, + (1 << chan->xdev->common.copy_align)); + } + return copy; } /** @@ -1804,7 +1817,7 @@ static struct dma_async_tx_descriptor *xilinx_dma_prep_slave_sg( * Calculate the maximum number of bytes to transfer, * making sure it is less than the hw limit */ - copy = xilinx_dma_calc_copysize(sg_dma_len(sg), + copy = xilinx_dma_calc_copysize(chan, sg_dma_len(sg), sg_used); hw = &segment->hw; @@ -1909,7 +1922,8 @@ static struct dma_async_tx_descriptor *xilinx_dma_prep_dma_cyclic( * Calculate the maximum number of bytes to transfer, * making sure it is less than the hw limit */ - copy = xilinx_dma_calc_copysize(period_len, sg_used); + copy = xilinx_dma_calc_copysize(chan, + period_len, sg_used); hw = &segment->hw; xilinx_axidma_buf(chan, hw, buf_addr, sg_used, period_len * i); From patchwork Fri Sep 7 06:24:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 10591697 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B64865A4 for ; Fri, 7 Sep 2018 06:25:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A44BA2AD88 for ; Fri, 7 Sep 2018 06:25:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95B332AD7C; Fri, 7 Sep 2018 06:25:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 335422AD7C for ; Fri, 7 Sep 2018 06:25:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727611AbeIGLEy (ORCPT ); Fri, 7 Sep 2018 07:04:54 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:54205 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727651AbeIGLEw (ORCPT ); Fri, 7 Sep 2018 07:04:52 -0400 Received: by mail-wm0-f66.google.com with SMTP id b19-v6so13540791wme.3; Thu, 06 Sep 2018 23:25:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=442uHEx2h0SkzNwr/c2bDFSZt2b3nXe/wow3C9PRspg=; b=qxri8mebiJCUIVqU6eQvVNBD+QtXILHFnszfQ737XEQV3SXUPUkE7dHZJ3oppVK4FX gaSb1fSGEH3Qp6lVhz+a6HTyKx8k7iUNsq6h0mGm4Mz9ZO4d/5JrykBc+0YxSKSQHIAv TJuz8dhWZQkJ7FC3dPnzvcjZPJxNeS+V3GTSMh/aWtHlS41fd9jgmF+z1e2k6JdpE5rv XoPeNk7W8ejqaxk9AzddQu+44DVF4dGeaJ7DkTn0O7k/5ginSjmJYz+0waHMprA/VLM7 6ennR05bokRlnHb3YiU6uf9UWgjQswenGP0Ja65t6TgmWfmkAUziZiVd8PjfwlVgUl59 OtFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=442uHEx2h0SkzNwr/c2bDFSZt2b3nXe/wow3C9PRspg=; b=aiMapeeTHjSr8Lc5sL3yBwywN3cwofme9EDcDeXf6cKefbHGgJ38Hw1PIAwfDRQFOP yxcqOb7poKzz6aScs6bSz9gq9b/DccJKO1+JgzVAgolIJJViZajKCLy3JtTjyVQh5RAd yfJ4VLuPfD0HxFT052MuoWzQqISewe+raFxBUHrWY2LoER2k5ihEXvnCbmO34YggapwD dADsOCuzwvZn/z57Smdx8km0P1nkdVCk7GzgV8yNdxDNBRCVEVLzqweA1kTm6MBEYM2D e2x9TUA+Eyxi8y1r9HGByNWF1oxdfO5bZ8wxdJ/pvIFOsBE7jcB7K9ILTI1X5Yc8HdQM yDaA== X-Gm-Message-State: APzg51BfUEuHO/4SP51kQLLC3USaB0xt+oK+ck1d3n8QDGWDyOlgryVq YC5I7PjpnUSyoOjtv9RUtrs= X-Google-Smtp-Source: ANB0VdbejVTlKHykLHLRKRDbhBGCwq2R0bQSVdymfm9yAIY19MaHRCjB2G3XkriRgKv/mMR3OwATcA== X-Received: by 2002:a1c:dc1:: with SMTP id 184-v6mr3910796wmn.145.1536301521586; Thu, 06 Sep 2018 23:25:21 -0700 (PDT) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id w10-v6sm8387233wrp.31.2018.09.06.23.25.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 23:25:20 -0700 (PDT) From: Andrea Merello To: vkoul@kernel.org, dan.j.williams@intel.com, michal.simek@xilinx.com, appana.durga.rao@xilinx.com, dmaengine@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, radhey.shyam.pandey@xilinx.com, Andrea Merello Subject: [PATCH v5 3/7] dt-bindings: dmaengine: xilinx_dma: add optional xlnx,sg-length-width property Date: Fri, 7 Sep 2018 08:24:58 +0200 Message-Id: <20180907062502.8241-3-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180907062502.8241-1-andrea.merello@gmail.com> References: <20180907062502.8241-1-andrea.merello@gmail.com> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The width of the "length register" cannot be autodetected, and it is now specified with a DT property. Add documentation for it. Cc: Rob Herring Cc: Mark Rutland Cc: devicetree@vger.kernel.org Cc: Radhey Shyam Pandey Signed-off-by: Andrea Merello Reviewed-by: Radhey Shyam Pandey Reviewed-by: Rob Herring --- Changes in v2: - change property name - property is now optional - cc DT maintainer Changes in v3: - reword - cc DT maintainerS and ML Changes in v4: - specify the unit, the valid range and the default value Changes in v5: - commit message trivial fix - fix spaces before tab --- Documentation/devicetree/bindings/dma/xilinx/xilinx_dma.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/dma/xilinx/xilinx_dma.txt b/Documentation/devicetree/bindings/dma/xilinx/xilinx_dma.txt index a2b8bfaec43c..5df4eac7300c 100644 --- a/Documentation/devicetree/bindings/dma/xilinx/xilinx_dma.txt +++ b/Documentation/devicetree/bindings/dma/xilinx/xilinx_dma.txt @@ -41,6 +41,10 @@ Optional properties: - xlnx,include-sg: Tells configured for Scatter-mode in the hardware. Optional properties for AXI DMA: +- xlnx,sg-length-width: Should be set to the width in bits of the length + register as configured in h/w. Takes values {8...26}. If the property + is missing or invalid then the default value 23 is used. This is the + maximum value that is supported by all IP versions. - xlnx,mcdma: Tells whether configured for multi-channel mode in the hardware. Optional properties for VDMA: - xlnx,flush-fsync: Tells which channel to Flush on Frame sync. From patchwork Fri Sep 7 06:24:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 10591705 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 33097139B for ; Fri, 7 Sep 2018 06:25:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 213902AD7C for ; Fri, 7 Sep 2018 06:25:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 158EA2AD93; Fri, 7 Sep 2018 06:25:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 855C42AD7C for ; Fri, 7 Sep 2018 06:25:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727608AbeIGLFH (ORCPT ); Fri, 7 Sep 2018 07:05:07 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36319 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725831AbeIGLEu (ORCPT ); Fri, 7 Sep 2018 07:04:50 -0400 Received: by mail-wm0-f66.google.com with SMTP id j192-v6so13474285wmj.1; Thu, 06 Sep 2018 23:25:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8e5h0rJlmTWn/SkUrpSaeFuxlSy8Y3IfyDjMz/ZKAYw=; b=Ng5Jwu9N9JfkQVZVIOspqsxdHiGoOcr8lWcab+Z54nfXsZspRvOc9MtuLgwF+Ph3Mc BCL+woL6YxvEJ1fY5bZ3WPG+PvQCkIUcheYuDPx98CUWaSi16hDoftnjWPvuSWdffWxh Icok83NAjXKo1cZhg6dz2yr/ocvzgQIoH/p9ENQWzycuziEdd8L3r5Ju7Al33OBTe6iK mHO99FyD2q9TOYO8HeFVarY/7VTWwMiXSWelR6Mp0e8hMMRMK6FIKQEAdp9s7qHB2JgX cxdqRu0ht2+kPPvMu7pKjonfPn5cNsR3Dw/6wdyB1NpPrHBWfYhXVGNkgUUyxPhKRNF5 xtcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8e5h0rJlmTWn/SkUrpSaeFuxlSy8Y3IfyDjMz/ZKAYw=; b=jcUKscAjnCAheaM3VReYqUhbo429/vq0KQZWeoKtyDsKDeHjCoTZKNvoWpJ+NwXOzg kvTp/SiMDyHGkxgptjaFwOxDblXk8M+USMa+XNDfdM+qt34OZ2zzASiM+FhX/mzkgYnZ i+7UpG24r1ek3vyleJ7TDwxlUJ16EU+C2wOU//I0HKcMzVHatCC3CJ25K2WMRi8p3pkl CrUkitwt87H+TvkeDLgDXPVoXMmcUdF8fPU5cNL8PgJCRYzSzyg0AGRjGK8PB0WQBXhC kEkFfVEm/UJVJ18U2AKmfyfn5E2cEpePkZI+9AGQg2Y/80H+sHUnXHzi4OYFScgSwJ5g viYw== X-Gm-Message-State: APzg51B6RjAxE/ZdDWh/zgBrzNM0fZVxlJIEP5fostrAy8fzJlYgyKYZ qS82cgvwEY+UySlFeLmqkGI= X-Google-Smtp-Source: ANB0VdbgJ1zAVFS2WLOsxPpNjnh/dFP46Tq/qpBpj5udz5ZUBMUHFabciXeBdgHX6e+26ecH+D369w== X-Received: by 2002:a1c:8682:: with SMTP id i124-v6mr4453038wmd.77.1536301522886; Thu, 06 Sep 2018 23:25:22 -0700 (PDT) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id w10-v6sm8387233wrp.31.2018.09.06.23.25.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 23:25:22 -0700 (PDT) From: Andrea Merello To: vkoul@kernel.org, dan.j.williams@intel.com, michal.simek@xilinx.com, appana.durga.rao@xilinx.com, dmaengine@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, radhey.shyam.pandey@xilinx.com, Andrea Merello Subject: [PATCH v5 4/7] dmaengine: xilinx_dma: program hardware supported buffer length Date: Fri, 7 Sep 2018 08:24:59 +0200 Message-Id: <20180907062502.8241-4-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180907062502.8241-1-andrea.merello@gmail.com> References: <20180907062502.8241-1-andrea.merello@gmail.com> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Radhey Shyam Pandey AXI-DMA IP supports configurable (c_sg_length_width) buffer length register width, hence read buffer length (xlnx,sg-length-width) DT property and ensure that driver doesn't program buffer length exceeding the supported limit. For VDMA and CDMA there is no change. Cc: Rob Herring Cc: Mark Rutland Cc: devicetree@vger.kernel.org Signed-off-by: Radhey Shyam Pandey Signed-off-by: Michal Simek Signed-off-by: Andrea Merello [rebase, reword] --- Changes in v2: - drop original patch and replace with the one in Xilinx tree Changes in v3: - cc DT maintainers/ML Changes in v4: - upper bound for the property should be 26, not 23 - add warn for width > 23 as per xilinx original patch - rework due to changes introduced in 1/6 Changes in v5: None --- drivers/dma/xilinx/xilinx_dma.c | 36 +++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c index aaa6de8a70e4..b17f24e4ec35 100644 --- a/drivers/dma/xilinx/xilinx_dma.c +++ b/drivers/dma/xilinx/xilinx_dma.c @@ -158,7 +158,9 @@ #define XILINX_DMA_REG_BTT 0x28 /* AXI DMA Specific Masks/Bit fields */ -#define XILINX_DMA_MAX_TRANS_LEN GENMASK(22, 0) +#define XILINX_DMA_MAX_TRANS_LEN_MIN 8 +#define XILINX_DMA_MAX_TRANS_LEN_MAX 23 +#define XILINX_DMA_V2_MAX_TRANS_LEN_MAX 26 #define XILINX_DMA_CR_COALESCE_MAX GENMASK(23, 16) #define XILINX_DMA_CR_CYCLIC_BD_EN_MASK BIT(4) #define XILINX_DMA_CR_COALESCE_SHIFT 16 @@ -418,6 +420,7 @@ struct xilinx_dma_config { * @rxs_clk: DMA s2mm stream clock * @nr_channels: Number of channels DMA device supports * @chan_id: DMA channel identifier + * @max_buffer_len: Max buffer length */ struct xilinx_dma_device { void __iomem *regs; @@ -437,6 +440,7 @@ struct xilinx_dma_device { struct clk *rxs_clk; u32 nr_channels; u32 chan_id; + u32 max_buffer_len; }; /* Macros */ @@ -964,7 +968,7 @@ static int xilinx_dma_calc_copysize(struct xilinx_dma_chan *chan, int size, int done) { size_t copy = min_t(size_t, size - done, - XILINX_DMA_MAX_TRANS_LEN); + chan->xdev->max_buffer_len); if ((copy + done < size) && chan->xdev->common.copy_align) { @@ -1011,7 +1015,7 @@ static enum dma_status xilinx_dma_tx_status(struct dma_chan *dchan, list_for_each_entry(segment, &desc->segments, node) { hw = &segment->hw; residue += (hw->control - hw->status) & - XILINX_DMA_MAX_TRANS_LEN; + chan->xdev->max_buffer_len; } } spin_unlock_irqrestore(&chan->lock, flags); @@ -1263,7 +1267,7 @@ static void xilinx_cdma_start_transfer(struct xilinx_dma_chan *chan) /* Start the transfer */ dma_ctrl_write(chan, XILINX_DMA_REG_BTT, - hw->control & XILINX_DMA_MAX_TRANS_LEN); + hw->control & chan->xdev->max_buffer_len); } list_splice_tail_init(&chan->pending_list, &chan->active_list); @@ -1366,7 +1370,7 @@ static void xilinx_dma_start_transfer(struct xilinx_dma_chan *chan) /* Start the transfer */ dma_ctrl_write(chan, XILINX_DMA_REG_BTT, - hw->control & XILINX_DMA_MAX_TRANS_LEN); + hw->control & chan->xdev->max_buffer_len); } list_splice_tail_init(&chan->pending_list, &chan->active_list); @@ -1727,7 +1731,7 @@ xilinx_cdma_prep_memcpy(struct dma_chan *dchan, dma_addr_t dma_dst, struct xilinx_cdma_tx_segment *segment; struct xilinx_cdma_desc_hw *hw; - if (!len || len > XILINX_DMA_MAX_TRANS_LEN) + if (!len || len > chan->xdev->max_buffer_len) return NULL; desc = xilinx_dma_alloc_tx_descriptor(chan); @@ -2596,7 +2600,7 @@ static int xilinx_dma_probe(struct platform_device *pdev) struct xilinx_dma_device *xdev; struct device_node *child, *np = pdev->dev.of_node; struct resource *io; - u32 num_frames, addr_width; + u32 num_frames, addr_width, len_width; int i, err; /* Allocate and initialize the DMA engine structure */ @@ -2628,8 +2632,24 @@ static int xilinx_dma_probe(struct platform_device *pdev) /* Retrieve the DMA engine properties from the device tree */ xdev->has_sg = of_property_read_bool(node, "xlnx,include-sg"); - if (xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) + xdev->max_buffer_len = GENMASK(XILINX_DMA_MAX_TRANS_LEN_MAX - 1, 0); + + if (xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) { xdev->mcdma = of_property_read_bool(node, "xlnx,mcdma"); + if (!of_property_read_u32(node, "xlnx,sg-length-width", + &len_width)) { + if (len_width < XILINX_DMA_MAX_TRANS_LEN_MIN || + len_width > XILINX_DMA_V2_MAX_TRANS_LEN_MAX) { + dev_warn(xdev->dev, + "invalid xlnx,sg-length-width property value. Using default width\n"); + } else { + if (len_width > XILINX_DMA_MAX_TRANS_LEN_MAX) + dev_warn(xdev->dev, "Please ensure that IP supports buffer length > 23 bits\n"); + xdev->max_buffer_len = + GENMASK(len_width - 1, 0); + } + } + } if (xdev->dma_config->dmatype == XDMA_TYPE_VDMA) { err = of_property_read_u32(node, "xlnx,num-fstores", From patchwork Fri Sep 7 06:25:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 10591695 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 58CCC139B for ; Fri, 7 Sep 2018 06:25:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4836E2AD7C for ; Fri, 7 Sep 2018 06:25:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BB972AD88; Fri, 7 Sep 2018 06:25:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D6CF2AD93 for ; Fri, 7 Sep 2018 06:25:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727645AbeIGLEu (ORCPT ); Fri, 7 Sep 2018 07:04:50 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:39788 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725970AbeIGLEt (ORCPT ); Fri, 7 Sep 2018 07:04:49 -0400 Received: by mail-wm0-f66.google.com with SMTP id q8-v6so13445246wmq.4; Thu, 06 Sep 2018 23:25:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SLdnCYIzmHwIXEy+JAJi0InUj83qMBeYcAZFj8j99Uo=; b=MKv0YsWfRZCx5I+TJdKJLq/KA5QkcrDCt7shmx/O6X/fsvk0oXqOqw8+N+93wCxFyD Mpcc5WdllJ5uO2EI7CiTMOMO+dbZVk87axYMzNgmYRp7h2cRx3Du62bTP0Qoc3990g7w s9IwVs1NV2DBZlXJw7QXuiPfUY/nyS4kZXK+kYfcebwj/1wG85suJv0l760jb2GPp5cC f3hWW3nrSfucDPlXP9C1LxExEg7OKHN+n54SHtcd+T4acigSQP47QCB/CzhK9ZY/D8O4 lhOt1bSaRKP/zUPxfgQbYYz/esqmomLBMzBzs3dG4x2eP8bHXpDxvhL8jcDg+vzalqQo b7GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SLdnCYIzmHwIXEy+JAJi0InUj83qMBeYcAZFj8j99Uo=; b=ZHr1zhb7PsXbS9wLmjNqbULQ4Ai8QutwXRz1S5uMbhldLbR9USKdJ/NY+yGS/YwaCh TBYuvjIokUEGNSXEjVALr3JQusg1TTM0r5fJaG+ovZTGCzU+nU1LIjXQBdXQEyRyYuSN bPBLraasaTb6NYwRzgsogkDyYdYfL7cTtSRyMWcya0s3XYsXJhET8X4xuxBI/e89xZiS u2b+RHO03a2PDvxIRlr/wZ/sZPgraVjHeW2d4SLZSgKC3CAVwbhgwzvg5mUj2NATltEg sph1blvehCoC1hxRlZFXvTNA6oQxbDgeL6NX1nngH9lO1XTIsCgoFQ/LzKctk9cvHWNE rlpg== X-Gm-Message-State: APzg51B0l+tocZXo2PbEAa6aVyIQwe1pqAzTOjiHlTV8CqEQZSLf7AbM jiMJbNScLg/uB2GLWiYivO4cAznGqkg= X-Google-Smtp-Source: ANB0VdbYN2ErQ2qS5rqYX+bUwz6xLS1DNL/hjXrhOXu1MQKkh322XY57jsALBlR+kblUw6cmwkT1Bw== X-Received: by 2002:a7b:c143:: with SMTP id z3-v6mr3972211wmi.105.1536301524188; Thu, 06 Sep 2018 23:25:24 -0700 (PDT) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id w10-v6sm8387233wrp.31.2018.09.06.23.25.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 23:25:23 -0700 (PDT) From: Andrea Merello To: vkoul@kernel.org, dan.j.williams@intel.com, michal.simek@xilinx.com, appana.durga.rao@xilinx.com, dmaengine@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, radhey.shyam.pandey@xilinx.com, Andrea Merello Subject: [PATCH v5 5/7] dmaengine: xilinx_dma: autodetect whether the HW supports scatter-gather Date: Fri, 7 Sep 2018 08:25:00 +0200 Message-Id: <20180907062502.8241-5-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180907062502.8241-1-andrea.merello@gmail.com> References: <20180907062502.8241-1-andrea.merello@gmail.com> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The AXIDMA and CDMA HW can be either direct-access or scatter-gather version. These are SW incompatible. The driver can handle both versions: a DT property was used to tell the driver whether to assume the HW is in scatter-gather mode. This patch makes the driver to autodetect this information. The DT property is not required anymore. No changes for VDMA. Cc: Rob Herring Cc: Mark Rutland Cc: devicetree@vger.kernel.org Cc: Radhey Shyam Pandey Signed-off-by: Andrea Merello Reviewed-by: Radhey Shyam Pandey --- Changes in v2: - autodetect only in !VDMA case Changes in v3: - cc DT maintainers/ML Changes in v4: - fix typos in commit message Changes in v5: None --- drivers/dma/xilinx/xilinx_dma.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c index b17f24e4ec35..78d0f2f8225e 100644 --- a/drivers/dma/xilinx/xilinx_dma.c +++ b/drivers/dma/xilinx/xilinx_dma.c @@ -86,6 +86,7 @@ #define XILINX_DMA_DMASR_DMA_DEC_ERR BIT(6) #define XILINX_DMA_DMASR_DMA_SLAVE_ERR BIT(5) #define XILINX_DMA_DMASR_DMA_INT_ERR BIT(4) +#define XILINX_DMA_DMASR_SG_MASK BIT(3) #define XILINX_DMA_DMASR_IDLE BIT(1) #define XILINX_DMA_DMASR_HALTED BIT(0) #define XILINX_DMA_DMASR_DELAY_MASK GENMASK(31, 24) @@ -407,7 +408,6 @@ struct xilinx_dma_config { * @dev: Device Structure * @common: DMA device structure * @chan: Driver specific DMA channel - * @has_sg: Specifies whether Scatter-Gather is present or not * @mcdma: Specifies whether Multi-Channel is present or not * @flush_on_fsync: Flush on frame sync * @ext_addr: Indicates 64 bit addressing is supported by dma device @@ -427,7 +427,6 @@ struct xilinx_dma_device { struct device *dev; struct dma_device common; struct xilinx_dma_chan *chan[XILINX_DMA_MAX_CHANS_PER_DEVICE]; - bool has_sg; bool mcdma; u32 flush_on_fsync; bool ext_addr; @@ -2400,7 +2399,6 @@ static int xilinx_dma_chan_probe(struct xilinx_dma_device *xdev, chan->dev = xdev->dev; chan->xdev = xdev; - chan->has_sg = xdev->has_sg; chan->desc_pendingcount = 0x0; chan->ext_addr = xdev->ext_addr; /* This variable ensures that descriptors are not @@ -2493,6 +2491,15 @@ static int xilinx_dma_chan_probe(struct xilinx_dma_device *xdev, chan->stop_transfer = xilinx_dma_stop_transfer; } + /* check if SG is enabled (only for AXIDMA and CDMA) */ + if (xdev->dma_config->dmatype != XDMA_TYPE_VDMA) { + if (dma_ctrl_read(chan, XILINX_DMA_REG_DMASR) & + XILINX_DMA_DMASR_SG_MASK) + chan->has_sg = true; + dev_dbg(chan->dev, "ch %d: SG %s\n", chan->id, + chan->has_sg ? "enabled" : "disabled"); + } + /* Initialize the tasklet */ tasklet_init(&chan->tasklet, xilinx_dma_do_tasklet, (unsigned long)chan); @@ -2631,7 +2638,6 @@ static int xilinx_dma_probe(struct platform_device *pdev) return PTR_ERR(xdev->regs); /* Retrieve the DMA engine properties from the device tree */ - xdev->has_sg = of_property_read_bool(node, "xlnx,include-sg"); xdev->max_buffer_len = GENMASK(XILINX_DMA_MAX_TRANS_LEN_MAX - 1, 0); if (xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) { From patchwork Fri Sep 7 06:25:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 10591701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 083305A4 for ; Fri, 7 Sep 2018 06:25:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD5D22AD7C for ; Fri, 7 Sep 2018 06:25:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF5D52AD97; Fri, 7 Sep 2018 06:25:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 751D02AD88 for ; Fri, 7 Sep 2018 06:25:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725933AbeIGLFH (ORCPT ); Fri, 7 Sep 2018 07:05:07 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36321 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727608AbeIGLEu (ORCPT ); Fri, 7 Sep 2018 07:04:50 -0400 Received: by mail-wm0-f65.google.com with SMTP id j192-v6so13474371wmj.1; Thu, 06 Sep 2018 23:25:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=g6yEf7sPUTftU4J49gga7zTfK93CLLR+cwQ15WOA01U=; b=mo1x0tRwtohb/U/gO32QUcNXFIZvBuiAwYmOV7B2Y+7CWbZf3/EijKYIqDPR1VWkMQ /2qFVQ/8aqsRUx34wZLXxoMM8IZLnvME/wazBSTvT9lggm5Gc6cFm5oY5ckCy/XbSv45 cqA8PgPr+3AfpAJ9WNE6w6yuCwL7oX6xAfqQEnFbE0YbHkzSyLnx8302+h5sPk88Bdny jGSybm64/dFZJZHwME1GoTSsbRQgFD/7OG9D097rosXD4ckKzlrSWsRXDCTeKL2CRYsi InspE/TsJyk4cHqX9S8U2lQnT86bjlb0Fd21zh1kcbMDlhwinuGrxiog6VnOvmxAmjy0 /U8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=g6yEf7sPUTftU4J49gga7zTfK93CLLR+cwQ15WOA01U=; b=ajtxAYE87nTR/zY42CXLul8Mz5Fodf9e4z3HRCSY/xk14rfnGjSQOhMWfj4amOs5eR xQA+N+6dFip09/lRNJYRcHIYsroDFXFOkKECdel/kqHRVVHgy/j7N2IidgDerTnYo8nW bBQyCFRjJ+3koYgYLTVEAjbajNbQ1g3wdgHFRrej4izPX36fwCazz3RuI567jxtN2BXI YBl6FcyFJwpZg9wgTluf5vJVusLaqedw4onxcL8zY4VwRrCcpmFXVKderrHT3vyzMWIE ricud8wLc7MYCNzc82OZ9HXIfnRC4cl31bNxxxtUNMey4Jr1amLy04avnINRTWYxD4Bo JrJg== X-Gm-Message-State: APzg51DzcfDKQMQ5UH9B7TBhnrWhg1OOVZiiAQZUK2y4Blo027I2GgKW 4EGZ2so+A4pDod9Ir0BDHA4= X-Google-Smtp-Source: ANB0VdZPyWU0yto9phBQMluQxwVIkHdJpJqHhag12U8FqLdTHE3VVR7cHhRAjVujruV67ng6F3xIgQ== X-Received: by 2002:a1c:bc86:: with SMTP id m128-v6mr3892949wmf.147.1536301525462; Thu, 06 Sep 2018 23:25:25 -0700 (PDT) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id w10-v6sm8387233wrp.31.2018.09.06.23.25.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 23:25:24 -0700 (PDT) From: Andrea Merello To: vkoul@kernel.org, dan.j.williams@intel.com, michal.simek@xilinx.com, appana.durga.rao@xilinx.com, dmaengine@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, radhey.shyam.pandey@xilinx.com, Andrea Merello Subject: [PATCH v5 6/7] dt-bindings: dmaengine: xilinx_dma: drop has-sg property Date: Fri, 7 Sep 2018 08:25:01 +0200 Message-Id: <20180907062502.8241-6-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180907062502.8241-1-andrea.merello@gmail.com> References: <20180907062502.8241-1-andrea.merello@gmail.com> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This property is not needed anymore, because the driver now autodetects it. Delete references in documentation. Cc: Rob Herring Cc: Mark Rutland Cc: devicetree@vger.kernel.org Cc: Radhey Shyam Pandey Signed-off-by: Andrea Merello Reviewed-by: Radhey Shyam Pandey Reviewed-by: Rob Herring --- Changes in v2: - cc DT maintainer Changes in v3: - cc DT maintainerS/ML Changes in v4: None Changes in v5: None --- Documentation/devicetree/bindings/dma/xilinx/xilinx_dma.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/Documentation/devicetree/bindings/dma/xilinx/xilinx_dma.txt b/Documentation/devicetree/bindings/dma/xilinx/xilinx_dma.txt index 5df4eac7300c..6303ce7fcc3d 100644 --- a/Documentation/devicetree/bindings/dma/xilinx/xilinx_dma.txt +++ b/Documentation/devicetree/bindings/dma/xilinx/xilinx_dma.txt @@ -37,9 +37,6 @@ Required properties: Required properties for VDMA: - xlnx,num-fstores: Should be the number of framebuffers as configured in h/w. -Optional properties: -- xlnx,include-sg: Tells configured for Scatter-mode in - the hardware. Optional properties for AXI DMA: - xlnx,sg-length-width: Should be set to the width in bits of the length register as configured in h/w. Takes values {8...26}. If the property From patchwork Fri Sep 7 06:25:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 10591699 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 49D205A4 for ; Fri, 7 Sep 2018 06:25:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 396062AD7C for ; Fri, 7 Sep 2018 06:25:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D77A2AD93; Fri, 7 Sep 2018 06:25:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B86EB2AD7C for ; Fri, 7 Sep 2018 06:25:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727654AbeIGLEw (ORCPT ); Fri, 7 Sep 2018 07:04:52 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:40538 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727611AbeIGLEv (ORCPT ); Fri, 7 Sep 2018 07:04:51 -0400 Received: by mail-wm0-f65.google.com with SMTP id 207-v6so13324587wme.5; Thu, 06 Sep 2018 23:25:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FEMoKkzJKGEd2pan1RZSHub8CW5+hNLYSGu4iHTdeb8=; b=c3492NB2dogE6/5bD94zfn6zPBy1doJZTICG1U6YQS7B8WMUfLbtPiOaZg7t8TWuQm y5bVoDJlhlOlrEmibMwiHXyNSslerqA2t0kAtgIFA9iYFWEXvxwta2hmLb/iUGMCBWP7 oRO3FYLWkobIGF08qPOB4Y1j3idWSiJ8fwCADuuGvTMoBs18cUWO2hP6Zm1Wb/yiLsVZ KuogfekYAHwTgt0lmpDp6CEKU0M1IM3Xb6SZ86qCwG300Yr9tImzb0TrrxOsRgkvXSjf G1reKJ10lX+u9U7hIlMFHFXpZcVMmyiBEsM8CYDtXPwioa84VfUfLL/fk0+jQQjcP3vu xjYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FEMoKkzJKGEd2pan1RZSHub8CW5+hNLYSGu4iHTdeb8=; b=e1M0ihYbRfjA7K9BqWHCjnhYs9Rp0aOEkcxomQT1VoZSXXKqmxNu7rynFI0MND5+MP SZJw2CrByxoyc/TuqLtW/cx1g45WQALRb6NkutGhG+5D6eDrb5G+ahUj+z5et7YNQGrf TCVkUI7Po95Q5qRv/MP87lFReDpR8tJIIjCQxg2pm0U3vy0MQzNAsYS8zrMh62RhE9Ht 9mx0Y0vDdS9894Qt+ULrIuFdOGO96ubRvvbfrKfHluzqUahytfPZ2k8r02upOHvP6M/P gbesluyMdC3g48p20HJEiFJKJCJNZXLY+2Ggpty85VcYpTO+zNPXk6FQFioiniNxbY4L iRyQ== X-Gm-Message-State: APzg51CQauKZWrTVFyN7Za+cO7N8ICg2LBRdSAvxM5nPsVSGhUXp94BY rMUk2GhumFxbiag1Q+IgaFs= X-Google-Smtp-Source: ANB0VdYNaGaKu7zukN4TPi+PO62pjY3gjPuWZVaJtu8FKvp235KumkQL5XilByeojUMshGIlsrG5/Q== X-Received: by 2002:a1c:2e11:: with SMTP id u17-v6mr4134805wmu.102.1536301526621; Thu, 06 Sep 2018 23:25:26 -0700 (PDT) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id w10-v6sm8387233wrp.31.2018.09.06.23.25.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 23:25:25 -0700 (PDT) From: Andrea Merello To: vkoul@kernel.org, dan.j.williams@intel.com, michal.simek@xilinx.com, appana.durga.rao@xilinx.com, dmaengine@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, radhey.shyam.pandey@xilinx.com, Andrea Merello Subject: [PATCH v5 7/7] dmaengine: xilinx_dma: Drop SG support for VDMA IP Date: Fri, 7 Sep 2018 08:25:02 +0200 Message-Id: <20180907062502.8241-7-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180907062502.8241-1-andrea.merello@gmail.com> References: <20180907062502.8241-1-andrea.merello@gmail.com> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP xilinx_vdma_start_transfer() is used only for VDMA IP, still it contains conditional code on has_sg variable. has_sg is set only whenever the HW does support SG mode, that is never true for VDMA IP. This patch drops the never-taken branches. Signed-off-by: Andrea Merello --- Changes in V4: introduced this patch in series Changes in v5: None --- drivers/dma/xilinx/xilinx_dma.c | 84 +++++++++++++-------------------- 1 file changed, 32 insertions(+), 52 deletions(-) diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c index 78d0f2f8225e..07ceadef0a00 100644 --- a/drivers/dma/xilinx/xilinx_dma.c +++ b/drivers/dma/xilinx/xilinx_dma.c @@ -1093,6 +1093,8 @@ static void xilinx_vdma_start_transfer(struct xilinx_dma_chan *chan) struct xilinx_dma_tx_descriptor *desc, *tail_desc; u32 reg, j; struct xilinx_vdma_tx_segment *tail_segment; + struct xilinx_vdma_tx_segment *segment, *last = NULL; + int i = 0; /* This function was invoked with lock held */ if (chan->err) @@ -1112,14 +1114,6 @@ static void xilinx_vdma_start_transfer(struct xilinx_dma_chan *chan) tail_segment = list_last_entry(&tail_desc->segments, struct xilinx_vdma_tx_segment, node); - /* - * If hardware is idle, then all descriptors on the running lists are - * done, start new transfers - */ - if (chan->has_sg) - dma_ctrl_write(chan, XILINX_DMA_REG_CURDESC, - desc->async_tx.phys); - /* Configure the hardware using info in the config structure */ reg = dma_ctrl_read(chan, XILINX_DMA_REG_DMACR); @@ -1128,15 +1122,11 @@ static void xilinx_vdma_start_transfer(struct xilinx_dma_chan *chan) else reg &= ~XILINX_DMA_DMACR_FRAMECNT_EN; - /* - * With SG, start with circular mode, so that BDs can be fetched. - * In direct register mode, if not parking, enable circular mode - */ - if (chan->has_sg || !config->park) - reg |= XILINX_DMA_DMACR_CIRC_EN; - + /* If not parking, enable circular mode */ if (config->park) reg &= ~XILINX_DMA_DMACR_CIRC_EN; + else + reg |= XILINX_DMA_DMACR_CIRC_EN; dma_ctrl_write(chan, XILINX_DMA_REG_DMACR, reg); @@ -1158,48 +1148,38 @@ static void xilinx_vdma_start_transfer(struct xilinx_dma_chan *chan) return; /* Start the transfer */ - if (chan->has_sg) { - dma_ctrl_write(chan, XILINX_DMA_REG_TAILDESC, - tail_segment->phys); - list_splice_tail_init(&chan->pending_list, &chan->active_list); - chan->desc_pendingcount = 0; - } else { - struct xilinx_vdma_tx_segment *segment, *last = NULL; - int i = 0; - - if (chan->desc_submitcount < chan->num_frms) - i = chan->desc_submitcount; - - list_for_each_entry(segment, &desc->segments, node) { - if (chan->ext_addr) - vdma_desc_write_64(chan, - XILINX_VDMA_REG_START_ADDRESS_64(i++), - segment->hw.buf_addr, - segment->hw.buf_addr_msb); - else - vdma_desc_write(chan, + if (chan->desc_submitcount < chan->num_frms) + i = chan->desc_submitcount; + + list_for_each_entry(segment, &desc->segments, node) { + if (chan->ext_addr) + vdma_desc_write_64(chan, + XILINX_VDMA_REG_START_ADDRESS_64(i++), + segment->hw.buf_addr, + segment->hw.buf_addr_msb); + else + vdma_desc_write(chan, XILINX_VDMA_REG_START_ADDRESS(i++), segment->hw.buf_addr); - last = segment; - } - - if (!last) - return; + last = segment; + } - /* HW expects these parameters to be same for one transaction */ - vdma_desc_write(chan, XILINX_DMA_REG_HSIZE, last->hw.hsize); - vdma_desc_write(chan, XILINX_DMA_REG_FRMDLY_STRIDE, - last->hw.stride); - vdma_desc_write(chan, XILINX_DMA_REG_VSIZE, last->hw.vsize); + if (!last) + return; - chan->desc_submitcount++; - chan->desc_pendingcount--; - list_del(&desc->node); - list_add_tail(&desc->node, &chan->active_list); - if (chan->desc_submitcount == chan->num_frms) - chan->desc_submitcount = 0; - } + /* HW expects these parameters to be same for one transaction */ + vdma_desc_write(chan, XILINX_DMA_REG_HSIZE, last->hw.hsize); + vdma_desc_write(chan, XILINX_DMA_REG_FRMDLY_STRIDE, + last->hw.stride); + vdma_desc_write(chan, XILINX_DMA_REG_VSIZE, last->hw.vsize); + + chan->desc_submitcount++; + chan->desc_pendingcount--; + list_del(&desc->node); + list_add_tail(&desc->node, &chan->active_list); + if (chan->desc_submitcount == chan->num_frms) + chan->desc_submitcount = 0; chan->idle = false; }