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: 10591703 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 09D8B139B for ; Fri, 7 Sep 2018 06:25:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EAE4E2AD88 for ; Fri, 7 Sep 2018 06:25:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE63E2AD97; Fri, 7 Sep 2018 06:25:48 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 692D82AD88 for ; Fri, 7 Sep 2018 06:25:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=LCSyadM4IAEmfLI3345BFW8QH/XaqmOiLNStpjkGX4Y=; b=gtN Ts3cUUK76t2WBs01Q2VZiPnEn+8ANumczmXNg54Cj0hMi+BhLhQ4fqe4/TpfqOVY667QGdDsosnfM wWpm9eOW5hIOXNDhqTCrLAKtVEAQxKJiA2PT60VmZLB2qLWlhM8bTvgCWg+womPBh85ff6K6djO4V Gkg8EDwqHtpfuFTk91ITpxiYO2Z+sATwICj8sOBs4LSqGE0SjymzF/zQgzsIcPLsLZeZT9iN6a5l4 Unf22MOmk7l71rGYjBBmiNI+05nJK7/5PKO3YosLiTKzqZkEEGZiJqdZBBvkQSP7otVxYRUp9lmf7 2pPGczpZl5t2X4zespcv1ZT6pNaIrBw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyAD2-0002cB-Cb; Fri, 07 Sep 2018 06:25:36 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyACx-0001zk-VD for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 06:25:33 +0000 Received: by mail-wr1-x442.google.com with SMTP id g33-v6so13754263wrd.1 for ; Thu, 06 Sep 2018 23:25:21 -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=k0yASDF/y16mFoNseNBKD/nKBw//qV/C7mEKwFEG/U5ho7/IbIG69oRw3GLGr5x65R d/Yub6qVpotWokEdPvKY6tDla+/emUsMRIAucQhC4sjOl2d/S34kEw9C3YXyG89j/E8G PdzgkzgwxvrdH1eHrgtgpaIoUC1SMRI6LbbW1DRK4GFXLsvrUPMg54zY10MdcjXipXJD 6ESdi5XPB1df9OTW1UDdnqKvT5WHVvPumbfWjS7Uvs+htAPOqfBGaHgS4oS5Y5Zv1scZ YLy5wzw1B95F0GvFV3N9cDvwm0RzJ3aJJkMIhoTjHBaCh0RLsWOZiARR1ezDEPt1RJrW 7O4Q== X-Gm-Message-State: APzg51Amvddu7yHN3M5k5MiZnqqAtdQfn0AmIQClZAFYbtcQml+X0Yr+ YbGnBjj8mm1+p03oadP7lK0= 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180906_232532_013787_706F7453 X-CRM114-Status: GOOD ( 14.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, Andrea Merello , radhey.shyam.pandey@xilinx.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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: 10591711 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 A4D955A4 for ; Fri, 7 Sep 2018 06:26:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 928592AD93 for ; Fri, 7 Sep 2018 06:26:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86CCB2ADE4; Fri, 7 Sep 2018 06:26: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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 019982AE02 for ; Fri, 7 Sep 2018 06:26:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=cxYo4KZZpHvneZxNJnzC8DnNVatpMgMxZP1Y6c2XinU=; b=KZVHkuFgFtb5t8/XZ7m9oVCSBv ZsA5yJTtXWysqkJJpo4QCXMVck12iwh6gckyGw5UGgpk/ItbWTQJMW8wCIQg6gD5PF5vOGXI9gxqE sjjuQ/MIDad1sJVwLw14qKenXO7xx4M1tlIJYNacT0Ko4G/sa5qVFc555MHN+jBrAyaf4gw5hxQic xZOLon5H9T2476lCDN7JonbqYIu1GzR8dW1scfwlHLwUMuc58wKhK064eOvcZXJ2MUl18CMboiYCy 4I9W9i8qwadAPN104ntGo9FbiQ8GOe3VMqhHCguUAUMftkyNPCJNll6JFCduMV4QDWKiXtoKM5QG2 MHAtm27Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyADo-0002xE-Vt; Fri, 07 Sep 2018 06:26:25 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyACy-00026g-0q for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 06:25:35 +0000 Received: by mail-wr1-x441.google.com with SMTP id v17-v6so13698105wrr.9 for ; Thu, 06 Sep 2018 23:25:21 -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=ariaa7zETrIRNBsGvfZ0mNeapcLi8YQTPwso3FEbcRRLPv824avRa0sMlj0ujSURe6 Zdmspoi3uLFOqvf8E+RECtLmnUuGvF+HSBwBKwwKsa8al2HFhRbOLQs4eKKbEtcXwDzI iKGheBYaWlUsD+tWtSznTmyCII+aWu+nq4AXHT2q0nEPArqo5XZD/maABGgW7YrWKtey Ew5rWB0j3xB5dmR+0kkYLP+ausS2IkSFHEb3baPuXkmtRfOyrviaqJncVInqfDiiWT+x 6cUvOpsL7OrVixcGJ7A3MQFXRBTQAWtA1NYfmqQp3XwptjpykUGtqFIaPuibywjEn8Jl 3Yeg== X-Gm-Message-State: APzg51ARpCcHpfXJwcXICVEtg2sP2VpmIGNpEw1WwUNXMjRL5HI6nO2Z ZYX7bc1tWKQo+mypIM+S4fM= 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180906_232532_114716_3A37B9BA X-CRM114-Status: GOOD ( 18.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, Andrea Merello , radhey.shyam.pandey@xilinx.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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: 10591713 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 9EDF1139B for ; Fri, 7 Sep 2018 06:27:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89B312AD7C for ; Fri, 7 Sep 2018 06:27:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B3702AD93; Fri, 7 Sep 2018 06:27:19 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 19B372AD7C for ; Fri, 7 Sep 2018 06:27:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=KDuWIRVqyE2oHtp9WJ9Eck4t3CcTrn8XNrmncvoBEEQ=; b=PxB5Z3VWTdTNwHJtnycD4NGcLr GvSIEX3BLRevQWf7pqJCJlRB4lm7sSZYJpxorCgiFHUiNerOvRHW4yrEnspNjhzA1RYF0iFbqW6MV WnIECRU8g2lKXJUmdcCo8abFa0c/KifCutyVnyccvxGd9V7dUZBlJ0xmEJq8AGGgcLMChEM9X3ekx apvdOD0/L2KMvr7WWcfYRi2p7j6yt4xEO+7/9iP+m06RZvx2JzWA2TPgiu96CqPGALAlqa/xlEH1n KvQTbzdyGzjUQ6juIBMCAyADxg8QxXPw9rZbSlTofwxdtLWTB1uC7wx/fwtcg2kliWQDXPX/lXqIy qm8+cJJg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyAEW-0003Q3-Or; Fri, 07 Sep 2018 06:27:08 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyAD0-0002D5-AU for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 06:25:36 +0000 Received: by mail-wm0-x244.google.com with SMTP id 207-v6so13324410wme.5 for ; Thu, 06 Sep 2018 23:25:23 -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=s/d6hxJnmqcviYpDYRgIA6tHSqFq2UVypqqGGWfrYLFVT7/MHCsMjT8Z4CngMBckJ9 DRcZG/vqGc/XltPx8C8alT29AIiKbrXoPRv1P2FEFUOiEcPv1KCDpyYmdVoivFHjfZ5t aiNaWi4mYTUyPk5l4DcklT0nQVIoGhpCyRAKXzPoK4KGItb6qSUShQhsYJXEkgSRzDd4 SN5Y/8VUzkrImpMQD0/5LUa8tMVWQ17tzUEOjqDjgJ7LNG78cfMgISZdBBFJV4+LNjUl lnGZupm9Ohpy3MKpOJXXQu1pXy+ZDowDOFD1/kaWPDE0Zt2NWSD5mK2DGFOeLX9C5F+x Iuog== X-Gm-Message-State: APzg51DjnIa6Af3GhEefO/t6rCZutUyJ666sQwxJ5cfNvm9BWfrwDp3m OTeG1TO2U7kE7xZ6djjfzl0= 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180906_232534_373484_B289BA3A X-CRM114-Status: GOOD ( 13.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, Andrea Merello , radhey.shyam.pandey@xilinx.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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: 10591719 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 575FD139B for ; Fri, 7 Sep 2018 06:29:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43E872A6F5 for ; Fri, 7 Sep 2018 06:29:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3822D2A744; Fri, 7 Sep 2018 06:29: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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AAFBA2A6F5 for ; Fri, 7 Sep 2018 06:29:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=bb0c+XW3vG3AvKsCS8I9rNiD6qCKKg6s0C9xLodvVX8=; b=jQUVrIbEVO30G4qPcCXnPsHtg1 D7mq+nUfzbn6hR5+prcKhWrwXYwMnf4MetPcEgc+LHjNBlrEYuU5k7oHsa438hITDqrvM/immgK4c vMwrplhecJ3VSmEh/1P/Ga3OSkoFyIe7B68m6Zxsa+QowiJorNc7o35Mzpf1hZRLne9Aj4+njWqOs mvpVtZdo87326AMTcwjmowLE6HJhRj1CNE4ife0VyYUWoJeF3XeRf0F0Qxu0gIViQyefiFJfx5mnY vR7MASu9OaTIPyvPgfL+F4Rpz1oAdeJU0IrCQuJC+ZDvCX+naxfCLPYb9g1n+0PuSVSrzvxs5zVv8 SUhndizQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyAGW-0004Fd-Tn; Fri, 07 Sep 2018 06:29:12 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyAD0-0002Kq-Jm for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 06:25:39 +0000 Received: by mail-wm0-x242.google.com with SMTP id t25-v6so13374203wmi.3 for ; Thu, 06 Sep 2018 23:25:24 -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=oeeXtbVsOi4JFHrBPRuzaGx7CILCrtaRltdcl8kkas2lBaTsqjsXwvfJ+RM+67j69W T8OGLNTRU30wJiUeTUTcDYTmcyM9gtITsFftw+7mS367c3911ebcEfZvzTh4O0ZI1Zrp FUuAew5403A8++3fCghsKA4n2ZYRPWnQS8bESkh0VsqmzkNMjUsLDVId4lAFY3nsBBtd w5PXsxy4cuCEuA7NXq5IdYqysrQrO9d0coTP1E4XPDubYYpiON9+HEV9iUfFXn/AUzAG TlBy7AguivJWav/azIQehRGmFnF7x3oyUlr6SCIw6b1HlS1FE59C0UGQg2Lq+ORZcjJq H03g== X-Gm-Message-State: APzg51CTbw1nHOW03UxIbynnFJ+bl2oyIuuRC18BCHQGm4KEC4sJ4l00 uqHP4w6S9N1CRaw6OXmz6j7Ww78nX5A= 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180906_232534_697338_ACE6987C X-CRM114-Status: GOOD ( 19.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, Andrea Merello , radhey.shyam.pandey@xilinx.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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: 10591721 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 E9BB0920 for ; Fri, 7 Sep 2018 06:30:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5AA02A744 for ; Fri, 7 Sep 2018 06:30:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C95C02A749; Fri, 7 Sep 2018 06:30:18 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4A6022A744 for ; Fri, 7 Sep 2018 06:30:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=TlRbR/AdA5LrJpKDF5vAXeoGY/eR7E21h5R+FyH3Z80=; b=rFAIsKFK7XNaC3xbu1dRbEIFm7 mDbU/X55cOS4oKnWusQWJ5DFJbfTfhtPGQje/Xr+EYVnRdM5S79qgluMtHEXQJAom28CkZfwTzcbi yYBmSDZC6Zo+hlOBetC/2nyNKf/PcXCTZjnuvuKebwvkOlXo5jXsuvwQiVxD20EPsx3C6HpbjbPbF wJtngSPUbTbiDK/J2ilVRDoLQlrExpoLiotZgNUvrSNG11TE/9N1w+9DJw1+sqb9GPz8eouCIgzdV Oyyp2gU7kEzK1hf9ietIed9+25iY3q9DcqGbMdMeFZsC9TwIFUGIgFNDVNguftpN6mxRk24XWmumR IAbQ65GA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyAHS-0004go-JG; Fri, 07 Sep 2018 06:30:10 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyAD2-0002SG-2R for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 06:25:40 +0000 Received: by mail-wm0-x241.google.com with SMTP id c14-v6so13514126wmb.4 for ; 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=VFlL6I5me5zXv+d1t9Qpk0oZZs6pficZLPgbL9daPNS2vlxYn5z5CqQOF4+hYJr3So HihzBB2eWKOy5RDaopTxXIT7heX4upDE7kDUylAcFcdQm6RDqH3VR23P2/mD9th5ob5p X8usCZ1mPJt+bbSNg/Gw2A9beKx5n7J7YeemtEj48espiom/mt1AO3W+kP0FdvRWpJMQ eFlIxIN8duU2CidoJOwbLX1CTIisAk1srTfc6dud0aylXVAPqkUdkOdTAsIWACwVY4eQ R0+s+czFMNbRhOiR0Q09lgJwxXBtu74z7vEdcFMV3OikkjG3x07KcYnOvkybidyswVdP giIg== X-Gm-Message-State: APzg51Bc75YE5dmJ4nzpOFJAN8+fP8zqdWXs4Rxx7hm6l9en4dMvARyV 0tMJHlBmAKtUc5Tpyc57PAs= 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180906_232536_157773_27EF1599 X-CRM114-Status: GOOD ( 17.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, Andrea Merello , radhey.shyam.pandey@xilinx.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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: 10591715 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 C87215A4 for ; Fri, 7 Sep 2018 06:27:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B037F2A556 for ; Fri, 7 Sep 2018 06:27:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A140D2A701; Fri, 7 Sep 2018 06:27:59 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1D3F62A556 for ; Fri, 7 Sep 2018 06:27:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=MEvMxgp53mR6fuFE4Xjg/p7ARbqFRDPt8BduqIL/u2A=; b=j60BjeIXqtpNqnAxTaPtHqEOqs qHW4JPsEZId9NgP88zpLas+Bd11IRCKUPyTFcTAlr74DgzNN9O9kg17mhHrM00tcAU3tdbotSF/iB m/5QVp6bYgg46WLEa8i3jEMZIDrCBDqqmJ8ijRHNwNR5L5uc4Dqb6CEunpjb7FEBDhx0Y8HwoeGWw n39ItJXbR+PhUus8H7/ArZ0itEgCl+Ri3wacaS1ZZumfkG1S/2ZaF8EJQBOSqIANTL7jIbSM6xR9S rOoOcnqg7zTFUhdLsYc+gdwaBHuFiNx8LRoKEL8ozKhAPmGziaKQCk9MuN5MOtAbPOpfnVCMlSvOI gK5pKdQg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyAFC-0003i8-Sl; Fri, 07 Sep 2018 06:27:50 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyAD0-0002YL-Jq for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 06:25:39 +0000 Received: by mail-wm0-x242.google.com with SMTP id c14-v6so13514152wmb.4 for ; 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=RnZ4ytsOfxOvOs/BvuoX0SSA4EzweMP1d4aRTvdc/1QMsSTMZRSQZNpbD/tP2a8rzK idWiIQ3WuEf9msl8K0uTICC48yFMxZKKMOl2T6Zabd6GESCVtqIjTWAmCOlbakYjCeWO xAnQ+LRpwyCcRjgSJYVEU6fwV+TccTbvqxT1C6ajtEaXuxF+OipHfm297fdA9lyEhk2k V9EWAKJfnTw2JqAa4zb4mLNAZMW9mv7aeNxESq+7ZMqyU1+5AaSKwWhEj1fXl3QK483A dWfhmZzvOY2N3A4tcy4CuviQo5IbCya//XXyjE6z77ibgJ3i83t37wr9rkbTsirva5zL +fTQ== X-Gm-Message-State: APzg51DUlaz0SfZUqaIzGd97XvIo4IqVUactcm1HNCQvwVsx+kaFn4qp iDUcJ78tC90QENXl9TQ7b54= 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180906_232534_704784_C85AE651 X-CRM114-Status: GOOD ( 12.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, Andrea Merello , radhey.shyam.pandey@xilinx.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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: 10591717 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 358AF5A4 for ; Fri, 7 Sep 2018 06:28:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 232DE2A6F5 for ; Fri, 7 Sep 2018 06:28:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14A2C2A71F; Fri, 7 Sep 2018 06:28:48 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 72F352A6F5 for ; Fri, 7 Sep 2018 06:28:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=IRbB+CJ5bYAf1ejnlBBQI/EE2WEJd8QGVpl3yvCVS9g=; b=OBrfQmMD8+sfE18ddxS3TD0zSH liuUb0m8czC+UvfRNfgL2TTKEyqpzkWVg3YKvbMu0Wrmv76JX4riJnM0k3krHw/GimmIFLONkmHhv mIVdR0vF2/FIDA9OFCjmJZ9yv6NydmYeD95l7xOYNh8RXdAIhaBzX3fM9Odnvnhc6fJjCThHGl3Mp /0v2hN0yuUVINE3U94vaJNt/zlTYpR13OXNRzDqrj86f7iN3/eoVr3gQkCFQetGWYWKAlQoi5bztx u+kmbz3lMzvhCtzuScGPiHwCGeE/BJzuLYwKKYh380d7gnMqZDAsYw7nP413az2R4bQCEmgzYyIYb pfqIPwJw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyAFs-0003z7-GU; Fri, 07 Sep 2018 06:28:32 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fyAD0-0002YW-Jn for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2018 06:25:39 +0000 Received: by mail-wm0-x242.google.com with SMTP id n11-v6so13375817wmc.2 for ; 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=uVgNNpeL3FzYfEysgJ4tDAh73ci+ktZ7gMT9ls3qDYzoFDyGjrBKCuR1KzOvht1z03 sk3Iv+ML+tcI6PAdgJ5S93hkJ43rsZiGazkqMYKGzJ+4VgU55VYudFogBXZVDFzJ4KXa I/EXyIarE6I10HB83nBf43+KuO6pLTMwKgnoRZ1Vg5nZYkOJvLI1vzGTIhJHehm3BDiw e6VMqsWGj1BYHYFJ1IIeL9cwKVA3TYMrTwjGcDzGIrhNXtxF8uzRMQyZKDNVm56iHY/D l+PciF2L8evybXaw+XWBBfH45SjloUXAHC66trlF7vh4n2l1UGcQDP74/URBEnV+OJ/A xFLg== X-Gm-Message-State: APzg51CqYtnbSobYnJsdr+FAcUWs3cgbD43d7c6ty3iheF7eNWeT5o9L mciK1iWxKEdoyxzWEPtHHds= 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180906_232534_687733_03C063BE X-CRM114-Status: GOOD ( 18.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, Andrea Merello , radhey.shyam.pandey@xilinx.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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; }