{"id":809450,"url":"http://patchwork.ozlabs.org/api/1.0/patches/809450/?format=json","project":{"id":19,"url":"http://patchwork.ozlabs.org/api/1.0/projects/19/?format=json","name":"Linux IMX development","link_name":"linux-imx","list_id":"linux-imx-kernel.lists.patchwork.ozlabs.org","list_email":"linux-imx-kernel@lists.patchwork.ozlabs.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20170903224100.17893-4-stefan.bruens@rwth-aachen.de>","date":"2017-09-03T22:40:54","name":"[03/10] dmaengine: sun6i: Restructure code to allow extension for new SoCs","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"d6f2b51fc3b64d07bfd9fdd558c4393c7d73c3dd","submitter":{"id":67055,"url":"http://patchwork.ozlabs.org/api/1.0/people/67055/?format=json","name":"Stefan Brüns","email":"stefan.bruens@rwth-aachen.de"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-imx/patch/20170903224100.17893-4-stefan.bruens@rwth-aachen.de/mbox/","series":[{"id":1284,"url":"http://patchwork.ozlabs.org/api/1.0/series/1284/?format=json","date":"2017-09-03T22:40:55","name":"dmaengine: sun6i: Fixes for H3/A83T, enable A64","version":1,"mbox":"http://patchwork.ozlabs.org/series/1284/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/809450/checks/","tags":{},"headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"Zd54CM5e\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xlp1L5FyZz9s06\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tMon,  4 Sep 2017 08:43:50 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dodcI-0000Ux-L2; Sun, 03 Sep 2017 22:43:46 +0000","from mail-out-1.itc.rwth-aachen.de ([134.130.5.46])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dodaF-0006wD-IV for linux-arm-kernel@lists.infradead.org;\n\tSun, 03 Sep 2017 22:41:45 +0000","from rwthex-w2-b.rwth-ad.de ([134.130.26.159])\n\tby mail-in-1.itc.rwth-aachen.de with ESMTP; 04 Sep 2017 00:41:09 +0200","from pebbles.fritz.box (92.225.242.208) by rwthex-w2-b.rwth-ad.de\n\t(2002:8682:1a9f::8682:1a9f) with Microsoft SMTP Server (TLS) id\n\t15.0.1320.4; Mon, 4 Sep 2017 00:41:08 +0200"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=/BlSk8LhHmfO3HZNoagJe3gqWKHcjY6MMrhxMVuR0I8=;\n\tb=Zd54CM5eRfKkSW\n\tJ00plZkdF0mPWqPSCShwV9p62Kcel81Z0dPjBStg0vUd21M+X67A8KMfr0bOUzFuSMGrBYZmaEDhx\n\tT1l8mdWOhHVqghzGXsH0r8iup4v21T/jlNyUd4/Tgso2bRR1x/lUUzTqoad7e5BCIdIDryy55l4qg\n\tGyI2YW5AsmbRR2HefeXgTd0NNpTcuaQwzHQz/kyxmYQpEr28+2LxRHsx6HsLFBMqTef9X2WYUfPAC\n\tiLLa5hJKH0MSbF4DtJJNEHlO/sBpBw+/5hJlq0Ecyx90QgVKmEtPrP0LFNAGFUoBiUFT633AAhV9p\n\tzvVB7f4FwzWBKiEd2AHw==;","X-IronPort-AV":"E=Sophos;i=\"5.41,472,1498514400\"; d=\"scan'208\";a=\"11604244\"","From":"=?utf-8?q?Stefan_Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>","To":"<linux-sunxi@googlegroups.com>","Subject":"[PATCH 03/10] dmaengine: sun6i: Restructure code to allow extension\n\tfor new SoCs","Date":"Mon, 4 Sep 2017 00:40:54 +0200","Message-ID":"<20170903224100.17893-4-stefan.bruens@rwth-aachen.de>","X-Mailer":"git-send-email 2.14.1","In-Reply-To":"<20170903224100.17893-1-stefan.bruens@rwth-aachen.de>","References":"<20170903224100.17893-1-stefan.bruens@rwth-aachen.de>","MIME-Version":"1.0","X-Originating-IP":"[92.225.242.208]","X-ClientProxiedBy":"rwthex-w1-b.rwth-ad.de (2002:8682:1a9d::8682:1a9d) To\n\trwthex-w2-b.rwth-ad.de (2002:8682:1a9f::8682:1a9f)","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170903_154140_137673_2007320F ","X-CRM114-Status":"GOOD (  10.90  )","X-Spam-Score":"-4.2 (----)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-4.2 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\n\tmedium trust [134.130.5.46 listed in list.dnswl.org]\n\t-0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay\n\tdomain\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"devicetree@vger.kernel.org, Vinod Koul <vinod.koul@intel.com>,\n\tAndre Przywara <andre.przywara@arm.com>, linux-kernel@vger.kernel.org,\n\tCode Kipper <codekipper@gmail.com>, Chen-Yu Tsai <wens@csie.org>,\n\tRob Herring <robh+dt@kernel.org>, dmaengine@vger.kernel.org,\n\tMaxime Ripard <maxime.ripard@free-electrons.com>,\n\tlinux-arm-kernel@lists.infradead.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"},"content":"The current code mixes three distinct operations when transforming\nthe slave config to register settings:\n\n  1. special handling of DMA_SLAVE_BUSWIDTH_UNDEFINED, maxburst == 0\n  2. range checking\n  3. conversion of raw to register values\n\nAs the range checks depend on the specific SoC, move these out of the\nconversion to distinct operations.\n\nSigned-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>\n---\n drivers/dma/sun6i-dma.c | 58 +++++++++++++++++++++++++------------------------\n 1 file changed, 30 insertions(+), 28 deletions(-)","diff":"diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c\nindex f1a139f0102f..c5644bd0f91a 100644\n--- a/drivers/dma/sun6i-dma.c\n+++ b/drivers/dma/sun6i-dma.c\n@@ -185,6 +185,8 @@ struct sun6i_dma_dev {\n \tstruct sun6i_pchan\t*pchans;\n \tstruct sun6i_vchan\t*vchans;\n \tconst struct sun6i_dma_config *cfg;\n+\tu32\t\t\tsrc_burst_lengths;\n+\tu32\t\t\tdst_burst_lengths;\n };\n \n static struct device *chan2dev(struct dma_chan *chan)\n@@ -270,10 +272,6 @@ static inline s8 convert_burst(u32 maxburst)\n \n static inline s8 convert_buswidth(enum dma_slave_buswidth addr_width)\n {\n-\tif ((addr_width < DMA_SLAVE_BUSWIDTH_1_BYTE) ||\n-\t    (addr_width > DMA_SLAVE_BUSWIDTH_4_BYTES))\n-\t\treturn -EINVAL;\n-\n \treturn addr_width >> 1;\n }\n \n@@ -520,41 +518,43 @@ static int set_config(struct sun6i_dma_dev *sdev,\n \t\t\tenum dma_transfer_direction direction,\n \t\t\tu32 *p_cfg)\n {\n+\tenum dma_slave_buswidth src_addr_width, dst_addr_width;\n+\tu32 src_maxburst, dst_maxburst;\n \ts8 src_width, dst_width, src_burst, dst_burst;\n \n+\tsrc_addr_width = sconfig->src_addr_width;\n+\tdst_addr_width = sconfig->dst_addr_width;\n+\tsrc_maxburst = sconfig->src_maxburst;\n+\tdst_maxburst = sconfig->dst_maxburst;\n+\n \tswitch (direction) {\n \tcase DMA_MEM_TO_DEV:\n-\t\tsrc_burst = convert_burst(sconfig->src_maxburst ?\n-\t\t\t\t\tsconfig->src_maxburst : 8);\n-\t\tsrc_width = convert_buswidth(sconfig->src_addr_width !=\n-\t\t\t\t\t\tDMA_SLAVE_BUSWIDTH_UNDEFINED ?\n-\t\t\t\tsconfig->src_addr_width :\n-\t\t\t\tDMA_SLAVE_BUSWIDTH_4_BYTES);\n-\t\tdst_burst = convert_burst(sconfig->dst_maxburst);\n-\t\tdst_width = convert_buswidth(sconfig->dst_addr_width);\n+\t\tif (src_addr_width == DMA_SLAVE_BUSWIDTH_UNDEFINED)\n+\t\t\tsrc_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;\n+\t\tsrc_maxburst = src_maxburst ? src_maxburst : 8;\n \t\tbreak;\n \tcase DMA_DEV_TO_MEM:\n-\t\tsrc_burst = convert_burst(sconfig->src_maxburst);\n-\t\tsrc_width = convert_buswidth(sconfig->src_addr_width);\n-\t\tdst_burst = convert_burst(sconfig->dst_maxburst ?\n-\t\t\t\t\tsconfig->dst_maxburst : 8);\n-\t\tdst_width = convert_buswidth(sconfig->dst_addr_width !=\n-\t\t\t\t\t\tDMA_SLAVE_BUSWIDTH_UNDEFINED ?\n-\t\t\t\tsconfig->dst_addr_width :\n-\t\t\t\tDMA_SLAVE_BUSWIDTH_4_BYTES);\n+\t\tif (dst_addr_width == DMA_SLAVE_BUSWIDTH_UNDEFINED)\n+\t\t\tdst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;\n+\t\tdst_maxburst = dst_maxburst ? dst_maxburst : 8;\n \t\tbreak;\n \tdefault:\n \t\treturn -EINVAL;\n \t}\n \n-\tif (src_burst < 0)\n-\t\treturn src_burst;\n-\tif (src_width < 0)\n-\t\treturn src_width;\n-\tif (dst_burst < 0)\n-\t\treturn dst_burst;\n-\tif (dst_width < 0)\n-\t\treturn dst_width;\n+\tif (!(BIT(src_addr_width) & sdev->slave.src_addr_widths))\n+\t\treturn -EINVAL;\n+\tif (!(BIT(dst_addr_width) & sdev->slave.dst_addr_widths))\n+\t\treturn -EINVAL;\n+\tif (!(BIT(src_maxburst) & sdev->src_burst_lengths))\n+\t\treturn -EINVAL;\n+\tif (!(BIT(dst_maxburst) & sdev->dst_burst_lengths))\n+\t\treturn -EINVAL;\n+\n+\tsrc_width = convert_buswidth(src_addr_width);\n+\tdst_width = convert_buswidth(dst_addr_width);\n+\tdst_burst = convert_burst(dst_maxburst);\n+\tsrc_burst = convert_burst(src_maxburst);\n \n \t*p_cfg = DMA_CHAN_CFG_SRC_WIDTH(src_width) |\n \t\tDMA_CHAN_CFG_DST_WIDTH(dst_width);\n@@ -1150,6 +1150,8 @@ static int sun6i_dma_probe(struct platform_device *pdev)\n \tsdc->slave.dst_addr_widths\t\t= BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) |\n \t\t\t\t\t\t  BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) |\n \t\t\t\t\t\t  BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);\n+\tsdc->src_burst_lengths\t\t\t= BIT(1) | BIT(8);\n+\tsdc->dst_burst_lengths\t\t\t= BIT(1) | BIT(8);\n \tsdc->slave.directions\t\t\t= BIT(DMA_DEV_TO_MEM) |\n \t\t\t\t\t\t  BIT(DMA_MEM_TO_DEV);\n \tsdc->slave.residue_granularity\t\t= DMA_RESIDUE_GRANULARITY_BURST;\n","prefixes":["03/10"]}