From patchwork Wed Mar 8 00:42:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9610119 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7BAE36016C for ; Wed, 8 Mar 2017 01:06:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CF4528504 for ; Wed, 8 Mar 2017 01:06:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 611F1285AA; Wed, 8 Mar 2017 01:06: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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 A66B828504 for ; Wed, 8 Mar 2017 01:06:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756534AbdCHBGv (ORCPT ); Tue, 7 Mar 2017 20:06:51 -0500 Received: from relmlor4.renesas.com ([210.160.252.174]:21705 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756612AbdCHBGj (ORCPT ); Tue, 7 Mar 2017 20:06:39 -0500 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie3.idc.renesas.com with ESMTP; 08 Mar 2017 09:42:56 +0900 Received: from relmlac4.idc.renesas.com (relmlac4.idc.renesas.com [10.200.69.24]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id BDA5A415F9; Wed, 8 Mar 2017 09:42:56 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id A8BF6480A5; Wed, 8 Mar 2017 09:42:56 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id A3A8348014; Wed, 8 Mar 2017 09:42:56 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac4.idc.renesas.com with ESMTP id KAG17259; Wed, 8 Mar 2017 09:42:56 +0900 X-IronPort-AV: E=Sophos;i="5.36,260,1486393200"; d="scan'208";a="236017807" Received: from mail-pu1apc01lp0021.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.21]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 08 Mar 2017 09:42:55 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Z5/i6e5HMX7DL9FyfMhZU2H/efeVM9vh6oVzDL7tjwE=; b=J9jVh5B3h9GK1zjxoC7l4dwswoy97qoWZqMR1PFuDuKtltfXFWeBL4mwkQ9zxF07lnAbEdkqBMQKqAo5Jw7VEYBnGEwxPBM0TmQfGOtXcn5Ilml6UN20SZU5THyWTsPp8Yit5id+r/EfBb9fJ6CjNy0Ew3iWpoV6Mqa5ObPKbPI= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none; intel.com; dmarc=none action=none header.from=renesas.com; Received: from morimoto-PC.renesas.com (211.11.155.144) by HK2PR0601MB1922.apcprd06.prod.outlook.com (10.170.150.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Wed, 8 Mar 2017 00:42:54 +0000 Message-ID: <871su87gag.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v2] dmaengine: rcar-dmac: enable descriptor mode on 40bit User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Vinod Koul , Laurent Pinchart , Geert Uytterhoeven CC: , MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Wed, 8 Mar 2017 00:42:54 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR0201CA0038.apcprd02.prod.outlook.com (10.164.90.176) To HK2PR0601MB1922.apcprd06.prod.outlook.com (10.170.150.17) X-MS-Office365-Filtering-Correlation-Id: 88b17487-938d-442a-7e96-08d465bc0f0c X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:HK2PR0601MB1922; X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1922; 3:nP+DLB1nZPaX/eGyg3673emv2E0GyGg5V9b/3ifcao+dtWackSi1ejUWSeNPsrZ7HRI/0JDvTRxxuq6kBTxAbajhkcZtFAMPCI3M61KJxP6ElXBnMmsW1P27exYDUL3pMs+D3BwgSmurZoLwEMTyoigztTv4m99Tu3LNc3oUxnqdhqJ+b9zzw6e6aP7Fclw4nYaOJ9S/QHAMELY0949qt8vvEiNWczhkASI4hBp8DVBlUi6P1B41Cug/s4kWPtiUD/0L8QrDRrJ/zK16Vj05tfsSQbJ1cyTe+U5tb3VqCXw=; 25:hhOxXWcXXJOnie3EYa7qf/P0RtIbroskvTCxC8LdlU+ofQqk1LQjX+zzRhaY9JIIqYer4HTyq8z6H89R7wZtur3ZWldZopq1r9zKBvYWSiQLB7rC9UuQujM0AzEjnbyEpO7l4QsaEZAvOn53T+7x7P9C2rjMpe4mlgyeKVLC/jOcxVXVqwCDVNXBRJa1Qd5QPY76TjINOejjbguJvAm5S+ZhLbo8WSig+kgXJElL5+EQP5ylTCEwCprqw51JLdzKnFlQOHgPGjA+aCahJuy1z1IX/u/EdVKmDw8g2mAtJfqazjmmA5dYF5DMRtu2yKwfwxbdUb9J47yFbdh14djv1bfdZCLi35A58L6iwmT266Oi6+9XmjJfmyexbhnTzK51QlxY+DVwqgGolImLk5WMfW4WvkDme+gwmkU4LlWibYAeMmfnR7YpExuRQWbX2xVF X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1922; 31:GEBHmXFTgjbmsfgwe2fuSEJKAyAWRgQdtmmN6oOR7kfXXicN6AU+qIkpNgzuKovzp9urIiWLcqEK/A3IbmKYy8Bqlf5z7fyQdI0+gms5caLnHnEBxwQqOxfcMIFyP+RAM55/m18nUg6MX05gr9aWGq6MQTy5k/CgPR4hXfWS91Npzr2baK71l2kPHXvnUfF5pb8oKrBZnRDVY+EjI8FNAcvfLAduuHe7M1FvI6pQ4n66iAGwRrcGaEShKOC8pKwG; 20:5KgL8vFWyrLLl4dA+pQJczOkgnqyUVdjDlaJ3VWWHJIyfKgNOWe3OFhp48G6cO3t7WtGysTU2y9NnOCvrsnO2alFg0TWsVJcaQrkLbo/LnYvW+GQG06PKVIVkFPaAMvgZXzrqdJ9wixp0/lD68hNsqC9bo+gaOEBFndIZoII42neHu/BKfR+WHADc89cM6ldEkZunU5nMCELu+yhVoctD2HMiw7xdJJmHKNr4ceTTmWKPrI84WmBaeQbIs0wWd62+En+ddt52Whj6CFjGzA106MSXj9I+ABLe/+hqxnRVGoIM+kEO0nYn1BFlkYEVm0mbDCdcHysGF3+/b1/N9aiXVRgGSQ1or54Paga6wz8PEoGY+5gAaABNOD+mun9u2XrrKrkMuj20oUdAF33mddNd/YldHLSuWDsfwagZUlJec5s/13B295WgzDCe8lgV+1ONImtSft8ZfGYt0X/TL1+dFrtPNMHK2rN0OqwSlPagwcBDk1Ws7sLGhlZ/3UileTa X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(20161123555025)(20161123558025)(20161123560025)(20161123564025)(6072148); SRVR:HK2PR0601MB1922; BCL:0; PCL:0; RULEID:; SRVR:HK2PR0601MB1922; X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1922; 4:70Qx7dq82fcdfpZrkaxhORR2m6pFAsSekUNvNryAgeSjcGL+An0AgOEYBkXnEefD+Cz1r0Sgea0o85HV7Ubt/pbIUMkMQ+YXCajHtfeIptgUGLDnQZOGoMwF8yfeX6faWVnsBI/wm27Se9tSKunGfUsnvm0uMm2XBCCnrsXsvmwtwHqZWZCaygRwD2U58q5TqgPQ8jE68cqqTktKoenGnVSjcZRyL01Km4/pSXhx7MO6hnpY8A2hAMyhIaveZEI76WIPj+rZtk8wnkrClvEGl+fh9VS+YaOzI6wWx8C+j4i4QzeBs/S0CSYziqz6DpQM30UnPDsTD5ABwNevi5h7RlDmyTGmeG/M7W18nelqtM5IiVmJRiI2TdMamdIoaGL0wHECI1Z6xer6cMHO1LkjVbQSG/vSDCwUwSoWRKxY99uMwTknx66Gvi5zBYqP8GLeByOys3qvDP0bycrBE2kNaBWRdq5rFCg24klE7TzCswT69+V/HrqRATbglWjcm0ui4ss7v7lTH30qLKd+b6Wvhxg2KmMzTP/7XgG56j2B0l7htOZH5a39HboYFLLhiqWnhfVCIgyCsip0roF/0XL/ZI6BSjSS2z71Du7fCIwCfE5nw6sDmDbGQunpVNw2mu02 X-Forefront-PRVS: 02408926C4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(39410400002)(39860400002)(39840400002)(39850400002)(39450400003)(33646002)(305945005)(42186005)(4326008)(83506001)(5660300001)(47776003)(7736002)(2906002)(54906002)(6116002)(53936002)(3846002)(53416004)(66066001)(23726003)(38730400002)(54356999)(8676002)(36756003)(81166006)(6486002)(86362001)(189998001)(50986999)(46406003)(4001350100001)(50466002)(25786008)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:HK2PR0601MB1922; H:morimoto-PC.renesas.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HK2PR0601MB1922; 23:/J6QAJePO8yUcrClD/2LymGK59cH4dgGhoZwNTO?= =?us-ascii?Q?+OOdpyqvNxLLWbnsSgTIOlnAxh5xWtzBfdX82hu5xhMjq8PAwcpBSNWu33+f?= =?us-ascii?Q?fOs9Xm6VYz4zjyrIYBg4GN+Cj7XHjkbK3kWg2ncCi+R9pHuhTMuDK/D/n+4A?= =?us-ascii?Q?yIevIPRe/krl07v85CbpOEX5nnA/H8mlYlddG+ZygctBXOjHBKKtO91SqdKk?= =?us-ascii?Q?42TVIF7b9pcNf5VbhRpIooybpsaIMoBDSDYgkIU+56rbQ+AoLislsFrxZ0rl?= =?us-ascii?Q?MQwNFPkRf0+BHvSj1+cLliiHCKvs+jp/hWG602/WJCUSqh3c1ZZpeTbZdixn?= =?us-ascii?Q?nBUhHRVC9ndQqo3WTDX91NWFdypHplEnNLHwU7OKPAJue850oFXmviHevd0k?= =?us-ascii?Q?/79PhOFhslyz2XMdyLb0U3NrmXZTtCK5Vz2GYZY7UhzTXxz4lw52t+JfXsZK?= =?us-ascii?Q?41XUsCSmVgp8OVyiOzbSP6Of6O8Yj1hYISEj4SX0Pt8KMHpD6l5ceM3GJSoc?= =?us-ascii?Q?Eigq4oUvctSZb6dzut1nihbsFrrl0ap6RXb32b9VWalMEl/NigGWbQQPmIxI?= =?us-ascii?Q?xovegSiqBkWxq7xiIV4pe7PYffGYexuxD4pLde1cr+fF1XI9KCH+6DoqdNuv?= =?us-ascii?Q?r30vhDLwZJnCizSnjijBwUV+oDhgf3KFVWZX4akm0LmhzlRKQaNZ8qEajDM+?= =?us-ascii?Q?xK5Kh/g9JTxyE0dfntnm6Iu/9sYGSE5aQu5nsG1+psMHZmFyscu1CKu1emQr?= =?us-ascii?Q?+DTweZ7wzbSDVvd1SR17CDwLEdaraiMprILyhFdv1QBSty/BQry3IMYdp22v?= =?us-ascii?Q?5oIHaVsC3b40q/SiDnFRoWa5LZ9NDiF4rqUrT8MT/wRGfdCTl4+Ts0pGzfMl?= =?us-ascii?Q?yqNvB43ElbLKg2l3FPVk48jkF6VK6l7Qg8SfxI9Oh6SCk1q4ZIuF6rCZO1Ao?= =?us-ascii?Q?EXeRWmBgeL6ioFZHHGLT4lt4APVkj/nQhzWnMCll/7Q=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1922; 6:85PijCrRR/gWV+7ZZnGSiJndV2KUkjokALpxdiqs44Byzmln8tUdlxxiyj1PtlAG6pkZPYm+1/tX9qumx/bz6Rubm9k1TvH5zACrMzBFM2YQHG8NPS5tOfCbOmKYSbyMs/K9NZ1A84w1dVp1d/J9LKiTxJkG6TDA0k9gzP3QQLWHfL7/uGbqUQAvy14o2Wkke8HhtoVoLNdyK+a+8WHoGzjXLapKGCEYPxX2PBF4W7svTdMPmq05F2aF3/SXq7MUq9ZPL2SQsA0plqQypQGkuAl+HhAW/9JVaigVkTf+9FLp8L5LP+9Te56J8s7vGaOvBCS6yET/6X4C+/lMn5zriur51gWy/eJd0+D1LhVSwAryoGBUpWE+bbgsw7jftn2iB1fOuSfE/Mkau33EMBUldXIcueO9hVuejWCoOKv6wnY=; 5:MrVgoysU7KbvGQNvVC+l9E3aUd52WQzmROVVV4fuk/tphm94pd7AIER19E16NqziKB5ixfc9B/2zAhmosgTjO0MS+WWoSm4hDPLNrpCosrJ33Zs6ip1OO8N45yqlXisIqHuGpj8ayvsxhCkHfEDiMw==; 24:3pf4kozruG7V/PEHc0xwqSDH2BOhcIX6MeUfixMVJPwrvKaVx7SloDvSFEwFrxsuuZoaXSRXZtrDlCHInX264hAGpMOJIcSzhbMW93nL5ic= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1922; 7:4IdXE1sOSyHkEo8L61ZYEUCZaoBZxQxr0DXQi+sTwD6LtXMF7gZerkKCthAA9StQlRrxlEWSMo9tcW7JG8rexWDsTSkUXL2sMX/Rv2n5XzMkXe65i96HV5XXykIk1UXeDyEtE2q4MFYUXfV1/Nn1FvyhZAymppHzV0vLLH1QbdpxUQcbxBwUGChRhcISXssgeXY8BUJG5hVOrgcoQzn0/HNVV1dgY9h8W4lmLK5e4G7q2tUcergkn2SfOSncOIScNbwuWi102R0qULDfuJ5jIGcvqcBHekGSHU2YIeJilvC3nWJhPTQtaRGWFMRfIx1t0Y/Wu29zr+9BUryAJHE5FA==; 20:PUlUh0tX3ZEMEIhfRO8RQmwO9N6L+7/OEey0zoBfT5FX1Y4+naJ+YIkEjeRQcnIkG9q4mWUqRazyoXiCmCs0lulLMeWY1fFNL1/Xp/srMVa7x0Iqf0Uqo+uq7VQ/kunPseynJDUcnef11VwLzb/SOMOtKd2MbeB4P1WsJarKeno= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2017 00:42:54.2285 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR0601MB1922 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto SYS-DMAC can use 40bit address transfer, and it supports Descriptor Mode too. Current SYS-DMAC driver disables Descriptor Mode if it was 40bit address today. But it can use Descriptor Mode with 40bit if transfer Source/Destination address are located in same 4GiB region in the 40 bit address space. This patch enables it if all condition was clear Signed-off-by: Kuninori Morimoto Reviewed-by: Laurent Pinchart Reviewed-by: Geert Uytterhoeven --- v1 -> v2 - do high_dev_addr / high_mem_addr in out of sg loop - reuse if (dev_addr >> 32 != (dev_addr + size - 1) >> 32) drivers/dma/sh/rcar-dmac.c | 52 ++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c index 48b22d5..a420921 100644 --- a/drivers/dma/sh/rcar-dmac.c +++ b/drivers/dma/sh/rcar-dmac.c @@ -344,13 +344,19 @@ static void rcar_dmac_chan_start_xfer(struct rcar_dmac_chan *chan) rcar_dmac_chan_write(chan, RCAR_DMARS, chan->mid_rid); if (desc->hwdescs.use) { - struct rcar_dmac_xfer_chunk *chunk; + struct rcar_dmac_xfer_chunk *chunk = + list_first_entry(&desc->chunks, + struct rcar_dmac_xfer_chunk, node); dev_dbg(chan->chan.device->dev, "chan%u: queue desc %p: %u@%pad\n", chan->index, desc, desc->nchunks, &desc->hwdescs.dma); #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT + rcar_dmac_chan_write(chan, RCAR_DMAFIXSAR, + chunk->src_addr >> 32); + rcar_dmac_chan_write(chan, RCAR_DMAFIXDAR, + chunk->dst_addr >> 32); rcar_dmac_chan_write(chan, RCAR_DMAFIXDPBASE, desc->hwdescs.dma >> 32); #endif @@ -368,8 +374,6 @@ static void rcar_dmac_chan_start_xfer(struct rcar_dmac_chan *chan) * should. Initialize it manually with the destination address * of the first chunk. */ - chunk = list_first_entry(&desc->chunks, - struct rcar_dmac_xfer_chunk, node); rcar_dmac_chan_write(chan, RCAR_DMADAR, chunk->dst_addr & 0xffffffff); @@ -855,8 +859,12 @@ static void rcar_dmac_chan_configure_desc(struct rcar_dmac_chan *chan, unsigned int nchunks = 0; unsigned int max_chunk_size; unsigned int full_size = 0; - bool highmem = false; + bool cross_boundary = false; unsigned int i; +#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT + u32 high_dev_addr = 0; + u32 high_mem_addr = 0; +#endif desc = rcar_dmac_desc_get(chan); if (!desc) @@ -882,6 +890,16 @@ static void rcar_dmac_chan_configure_desc(struct rcar_dmac_chan *chan, full_size += len; +#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT + if (i == 0) { + high_dev_addr = dev_addr >> 32; + high_mem_addr = mem_addr >> 32; + } + + if ((dev_addr >> 32 != high_dev_addr) || + (mem_addr >> 32 != high_mem_addr)) + cross_boundary = true; +#endif while (len) { unsigned int size = min(len, max_chunk_size); @@ -890,18 +908,14 @@ static void rcar_dmac_chan_configure_desc(struct rcar_dmac_chan *chan, * Prevent individual transfers from crossing 4GB * boundaries. */ - if (dev_addr >> 32 != (dev_addr + size - 1) >> 32) + if (dev_addr >> 32 != (dev_addr + size - 1) >> 32) { size = ALIGN(dev_addr, 1ULL << 32) - dev_addr; - if (mem_addr >> 32 != (mem_addr + size - 1) >> 32) + cross_boundary = true; + } + if (mem_addr >> 32 != (mem_addr + size - 1) >> 32) { size = ALIGN(mem_addr, 1ULL << 32) - mem_addr; - - /* - * Check if either of the source or destination address - * can't be expressed in 32 bits. If so we can't use - * hardware descriptor lists. - */ - if (dev_addr >> 32 || mem_addr >> 32) - highmem = true; + cross_boundary = true; + } #endif chunk = rcar_dmac_xfer_chunk_get(chan); @@ -943,13 +957,11 @@ static void rcar_dmac_chan_configure_desc(struct rcar_dmac_chan *chan, * Use hardware descriptor lists if possible when more than one chunk * needs to be transferred (otherwise they don't make much sense). * - * The highmem check currently covers the whole transfer. As an - * optimization we could use descriptor lists for consecutive lowmem - * chunks and direct manual mode for highmem chunks. Whether the - * performance improvement would be significant enough compared to the - * additional complexity remains to be investigated. + * Source/Destination address should be located in same 4GiB region + * in the 40bit address space when it uses Hardware descriptor, + * and cross_boundary is checking it. */ - desc->hwdescs.use = !highmem && nchunks > 1; + desc->hwdescs.use = !cross_boundary && nchunks > 1; if (desc->hwdescs.use) { if (rcar_dmac_fill_hwdesc(chan, desc) < 0) desc->hwdescs.use = false;