From patchwork Tue Mar 7 01:10:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9607933 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 0F50060414 for ; Tue, 7 Mar 2017 01:11:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01D452846D for ; Tue, 7 Mar 2017 01:11:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA7492849C; Tue, 7 Mar 2017 01:11:46 +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 1D8212846D for ; Tue, 7 Mar 2017 01:11:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753596AbdCGBLp (ORCPT ); Mon, 6 Mar 2017 20:11:45 -0500 Received: from relmlor1.renesas.com ([210.160.252.171]:43972 "EHLO relmlie4.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753949AbdCGBLK (ORCPT ); Mon, 6 Mar 2017 20:11:10 -0500 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie4.idc.renesas.com with ESMTP; 07 Mar 2017 10:10:35 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id AD7F24C120; Tue, 7 Mar 2017 10:10:35 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id A3E0D80030; Tue, 7 Mar 2017 10:10:35 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id 9830F8002F; Tue, 7 Mar 2017 10:10:35 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac1.idc.renesas.com with ESMTP id LAJ31123; Tue, 7 Mar 2017 10:10:35 +0900 X-IronPort-AV: E=Sophos;i="5.35,256,1483974000"; d="scan'208";a="235902067" Received: from mail-hk2apc01lp0211.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.211]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 07 Mar 2017 10:10:34 +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=ad30pPHzrCLWDqat+KSm/U8zIVpIuEvam9g1DoSFiQE=; b=EOHfEQdTM30PMjUfbhDfeT0iB8S56HoCnOi6JAdio+BRn8QCPPXg+eWCoNgoJ1MhSosH3D68cKG8noFrTA/hXqzLzbWpn4n52u99L2/nmAWWDCMv9hjYIansgFblbpWv5dl7hUsbkEbB2MmRjlbniRnIBCKJ9eHrDZ5zBnDIZ9A= 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 KL1PR0601MB1928.apcprd06.prod.outlook.com (2603:1096:802:9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Tue, 7 Mar 2017 01:10:32 +0000 Message-ID: <87tw7599od.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH] 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: Tue, 7 Mar 2017 01:10:32 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR06CA0024.apcprd06.prod.outlook.com (2a01:111:e400:5972::34) To KL1PR0601MB1928.apcprd06.prod.outlook.com (2603:1096:802:9::18) X-MS-Office365-Filtering-Correlation-Id: d4cc086e-f045-40ed-18d9-08d464f6c171 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:KL1PR0601MB1928; X-Microsoft-Exchange-Diagnostics: 1; KL1PR0601MB1928; 3:HRD4GnfULo4QQ7ZBs9zRg59qRTWFWt2iN5EoyE6iacwLAl4HDU/SUBigGfPQrzNvo8feVrPN6E/7P+omfZ95gh/KOXm65KXmZ4RGzkKPMiBXG002ek0WDeMpEs5ohRgbTJSdZ3JC45IIbTxb0oFGKjqrEb3fXxXmrcPhAA++CJ1b6FGCfYAdzYOIrM8Jsedo1WqsrttZJ69gM6p871JPwSnd7FKjNsl1wMH/xZYOoC1IbUoE4c5keghbR9b8mkr61VrEkTxn5JBhsnngFfvJzys7aQtW5L2axWk+Pyt/GOI=; 25:IkFZ6eTsmwbNCSVIdaRH5sbZFm6pFSegtQwwBsJxGbyO/iRZJV0Bz7vhb+ZddUc8Pa8PTb/zKpBMszTAf81ju1YFb+YBOdtykVm2yCKKBRfJeN6MPJ+4HhPq6yUyTJ0HbnfIe69cfD/nppybJW6V6zGsTQXPFJXKwsRM+g1+B/t14y4SR+FB0suF0M9LNm462+L2ENYRjdWQRfZsdrgZptksLg7k7tfqj+3h3FuLOnfKKp5ik47doKnw0cKMZKXbIC2aoPT105pSK04WUZzKuiQBIRmb+MGPMQmvPVI9k6OTWH6tqeiCN0OzL7biBVOhBvu3ExYpt2FwbjWytHIR3MFNb5yUW2cIpq2Kr+DsbNc81jYo7AQRyGEF1wqcOyvgbP1Npc0IDlltx1xLEM7vhNZkvfYcJ7EhHNebs0L4oXCfQYX1dHn6gMVq77qDZuA5 X-Microsoft-Exchange-Diagnostics: 1; KL1PR0601MB1928; 31:5VrLQXiLFqZFcVRy+eA2ERXn2XOOplTnyxYTbQVEfeBXDnY3fpnTurMjwQH9LY8pmEOs7765QmcH/vzEm+OI856yrmbD5klWK/tLQfYX6HYZvx6XjihBdMN/k9jc7JGMh5LkfSqt6aIIsYwWQWamCVqAzCv46tw3V//gYjgaeY6b4SxpMQrrOeI7nACkLM6z50LLqgM402JutW1RwJA7nl271H0MSAUn25PCETfGnMkD0Upnb8oVhUrzwtd359NMQe1SrQGpky5CPWPJ07ALYw==; 20:bl+ELMrAahUdnKT60i9I69PCB9IZWzOqEG1URsViSxP1zELso1lJ9HR9AnQCNE71iiiiZQftJ5O/RSXCzVA0qjtD40IQ21TGgbs0PjBBSkNXZSNaS91enFIDyu1xGgh0tzEi411qcC/zVB47IF29z0Q5pUylxrL3prkwXFB94e/HXRqZva3hoXrg7KXvcHrrV2txoWVREuNLJwMC4Ti3jiUZt0l36clJhKInLXre7fWITe/G0tqkubgOohlXL8KdTxPMKFvonDD0jco2HFU4H+VecA1umrufDu+1NCLmNOAcDP1fvmIRCc2JZzE/bCZdjmBVwkKeim8+jUq6Zwwyx5KcdEtS9prhG12pYJUFnTLeEtU3syWwqWiw2YBlUqtYBvyq5WzfugXIl9wHFvg6AoFncpyrQ2cKV3wWYJ3gw03EZ/7cOVraWwiwtuwz9zFBT7N6Z2ROkD7A0PT6hxKHhMS/zDeTcfQk2l+J+Z7C1UEAhShYLDkmynbU4jKOAMAb X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026)(6041248)(20161123558025)(20161123564025)(20161123555025)(20161123562025)(20161123560025)(6072148); SRVR:KL1PR0601MB1928; BCL:0; PCL:0; RULEID:; SRVR:KL1PR0601MB1928; X-Microsoft-Exchange-Diagnostics: 1; KL1PR0601MB1928; 4:cTTAwlp2YCHJMDGBLEgXVgrLylnO4+0rM+/vWMFEnQVVB7Z9+5p29y+xGck5LoVCdsAsi56sNOYSLy4j2MRGgS3mP16QjWm8N6EmYIzhne5B4Ta5yQO8oWL/18Fa+OLyc7M+ObFv2cIMdnS+i5eqwMMr3EkcX9XPIutx/XhSaR1CukY181LUHoUf6esJeRpVfvd6bdDZaatJdDZbEcZndO6P6CrNRO3a7VFuq5krgHjCp7N3oh09GYx+XXtZ9Jmi4yFSv7R+PrMH9oyt8ePHh/Y+spdkg/GTBEYgKGSsao+9ox1gWXj1vzeacQajzagiafNnDnm1dn792YrlateZ/rnGyoIjP83m2Doc57AKrAHkEK4CQS0ksdv+VmnfluTyNazryab0wM8yj4Kg603Oe2iGPJrzeAt0CbymN31yGit8xGsa9Z/SsVNZ+rBE4HYmG4y+Dzmy/nHuUb5jPafanVvoBoNO0fbUZFdY6iGyYUNQ5IxuoULT4sBg+QH809tamCbK+YQm0pO606FaoHTQpaspCa+vwO2hLBdU7xV96yj0KwBVN7gDHByAdlPerr13HYLwtR4likAE1VyDT1/msv1IW3ZVeu/MAD0NrW8g7Toi3bLohVn6/cHvIZ06gQd7 X-Forefront-PRVS: 0239D46DB6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(39860400002)(39850400002)(39410400002)(39840400002)(39450400003)(6486002)(81166006)(92566002)(189998001)(54906002)(23726003)(8676002)(6116002)(3846002)(42186005)(47776003)(46406003)(53936002)(5660300001)(33646002)(66066001)(50466002)(38730400002)(4326008)(36756003)(7736002)(53416004)(50986999)(2906002)(54356999)(305945005)(86362001)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:KL1PR0601MB1928; H:morimoto-PC.renesas.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; KL1PR0601MB1928; 23:diAPVOEvSO7lcDdfLUj/DPCu+zVF1pGRYh0kpTReWMhI5ZjPk7nVFwekqsg4G6tmoPEoJ/cSITZCxyFJi/RllyZPwERvg/FFfbBleob/ZtXeX7pZ9SL9kq3HnjIcpj/WalT37fS/zJZp8mHgUZPUWeCMYV1QuMQPWypjhnpsqdBuHBADVs52X+9TSumj1vgMW5G11PCdxDX7NSsomrkI7hIaO/B1WP2apDgQ2ANiup5keAsJAqg+rvM6KA8JSvfQEalEnwZAvheZFWM0o361lwh+9Nr5OQ1SnZePOI1kfxptYR770RIxwDDRtXcCWC5DCOUK/luJK/UzjTqYznYCWJLpCwmYx3ZUOZnbVpaCGAwgi/S8QVnlY0RMSVIhsJt3sJ/8BnJlc36QiARVqoCyWo0Gx4PuS5nLRRXf9ebLxw5a/3EUSpXk9X0x6pzKB+CqL42j/0KhgBryyMW+fk1dn5MrhAzy7IH7SKlbJ4IeGhQf0qGGz19vnOqC/ZCp18OJSNW6NvVYQ6YmKRfLs1yREmGHiUHQmklW/uYHHlfynfE7KmMYzhOnbO9SNZUH0y3w6Qc4hDAAzXWUrKqGL+ftpm2V58mGwWXrZiqr6dmooam//SEc9vpX6D8uWOWjihdBKEYZXlpr2XG53/ZTBwuIqlaEwRjjeVV8LKFJ7qevHq+CeXbr0YzCN12I6iqoSqE43tTZNQrta/TfdFcSlH8EzJYttYhwcoDeUMt/hooUJj0Fneob452K9csopz+5WLtL9ZSPfu8d0ghguR/QbN3sIWR+Wk+Wb/QKIutNccqW/eINJtrTHoj/SPtcNfP/Vt9O/+0SfjsqWRFzfZB2UBQaYJGBjXlAEnZt4ONn6AwSZChsq0MNDafqPX19KKuCkcM8++iX7wuOkNgn57IomriPEIaFVIQQcAPrTaceE9+ RSMrfthv+tAbkuIRxM6E0E/RJ X-Microsoft-Exchange-Diagnostics: 1; KL1PR0601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QiOrbnLqxENjmPJ+7frucL4v1MKFwSe4fwtFpTMbYjgCvjx1oyyAGShYIXrEXA==; 20:HifSiei+OTXhsgSwtvRkz5yxkNhjkhJ8hUj64TGWGIlixL7xXOxKXVijEm3L0ZpjhInSWhJr+HTxfBLGsK2aexPvxgSLFDy7hKUkNyVH37KvCXCS3AzcmflYwD6mZaSG05Z6bGMueQjnz/4Xh7uE99dpspQk4cnyrZvklgcERGE= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2017 01:10:32.9964 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR0601MB1928 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 --- drivers/dma/sh/rcar-dmac.c | 65 +++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c index 48b22d5..2ebd2be 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_src_addr = 0; + u32 high_dst_addr = 0; +#endif desc = rcar_dmac_desc_get(chan); if (!desc) @@ -885,25 +893,6 @@ static void rcar_dmac_chan_configure_desc(struct rcar_dmac_chan *chan, while (len) { unsigned int size = min(len, max_chunk_size); -#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT - /* - * Prevent individual transfers from crossing 4GB - * boundaries. - */ - 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) - 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; -#endif - chunk = rcar_dmac_xfer_chunk_get(chan); if (!chunk) { rcar_dmac_desc_put(chan, desc); @@ -918,6 +907,26 @@ static void rcar_dmac_chan_configure_desc(struct rcar_dmac_chan *chan, chunk->dst_addr = dev_addr; } +#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT + if (i == 0) { + high_src_addr = chunk->src_addr >> 32; + high_dst_addr = chunk->dst_addr >> 32; + } + + /* + * Prevent individual transfers from crossing 4GB + * boundaries. + */ + 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) + size = ALIGN(mem_addr, 1ULL << 32) - mem_addr; + + if ((chunk->src_addr >> 32 != high_src_addr) || + (chunk->dst_addr >> 32 != high_dst_addr)) + cross_boundary = true; +#endif + chunk->size = size; dev_dbg(chan->chan.device->dev, @@ -943,13 +952,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;