From patchwork Wed Mar 22 04:22:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9638099 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 3C7076020B for ; Wed, 22 Mar 2017 04:23:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3022226E1A for ; Wed, 22 Mar 2017 04:23:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 234C828354; Wed, 22 Mar 2017 04:23: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=-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 7861A26E1A for ; Wed, 22 Mar 2017 04:23:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758699AbdCVEXS (ORCPT ); Wed, 22 Mar 2017 00:23:18 -0400 Received: from relmlor1.renesas.com ([210.160.252.171]:64709 "EHLO relmlie4.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758523AbdCVEXJ (ORCPT ); Wed, 22 Mar 2017 00:23:09 -0400 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie4.idc.renesas.com with ESMTP; 22 Mar 2017 13:22:41 +0900 Received: from relmlac4.idc.renesas.com (relmlac4.idc.renesas.com [10.200.69.24]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 6711A6C05B; Wed, 22 Mar 2017 13:22:41 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id 377AF480A8; Wed, 22 Mar 2017 13:22:39 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id 895E8480C0; Wed, 22 Mar 2017 13:22:39 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac4.idc.renesas.com with ESMTP id PAC27345; Wed, 22 Mar 2017 13:22:39 +0900 X-IronPort-AV: E=Sophos;i="5.36,203,1486393200"; d="scan'208";a="237365356" Received: from mail-pu1apc01lp0022.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.22]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 22 Mar 2017 13:22:38 +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=mXVC07JTkwjDiKn2rOesPGJJseHHcv9hV7KaG4s1QtA=; b=S/fec5SpWq7ncRVUOmm5FuzR4u3kb/2Cux2eV1IlrVd95XOm1KOxAYncLSdOn5JND+rKF9fLdiQgIBT2+uVx/p9TDmMWfajLACUT+umexRf9K60WnCFJjW0H16wMvpnoVZCiHDKH+U6KNfw/oWw99SGTLogKG6JZFabX8kUx4ws= 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 SG2PR06MB0822.apcprd06.prod.outlook.com (10.162.198.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.977.11; Wed, 22 Mar 2017 04:22:36 +0000 Message-ID: <87y3vyndu6.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto To: Vinod Koul , Laurent Pinchart , Geert Uytterhoeven CC: Linux-Renesas , Linux-Kernel , Subject: [PATCH v3] dmaengine: rcar-dmac: enable descriptor mode on 40bit User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Wed, 22 Mar 2017 04:22:36 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR01CA0066.jpnprd01.prod.outlook.com (10.167.153.154) To SG2PR06MB0822.apcprd06.prod.outlook.com (10.162.198.148) X-MS-Office365-Filtering-Correlation-Id: 511dc71b-c9b7-42d9-3253-08d470db11f2 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:SG2PR06MB0822; X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0822; 3:KwUfAsMrDsG89salNEPXo4/AJ354RahjzCIUTiQp9OcRpVJpTnBruD84O71dElyNZT33JiA7Ll+Us5vi5Qn4fnYBbLUHEpETISopVb+yXUuxK6wT9GeyW0dZIgwqgB1NUTYFUcsewl80J7oOQ4/ufut/w8iJsQSoyYoPBNVCtyM19BVRMgz77ejVrCdgcMW/91dT9+jhhzaNTZjuGivEIBRpUO5PJ7AB4S6jzdJMxz9PPoww+VkMHX/VxbJLt+egg6yB1Xsmj3x52xjL3e3KIryr7fPCvEFtV9K02wUf4ZE=; 25:gpQVVlLWt7jJ409j2rb99kXyX7tAyVL9OEF7VgOXz5TARqHUH706aENk8NGvRcflSXEAxK6R8pvEuiPlFxu9J7k4h5iOJDPlaKcTdiPO03RNxO4WHcHMbiIhMXLwjUVvK7dx8cbwyij3b3WLPlv7STCAeBshDyCQV2mhq3zntXsJ3v8DwYGu9e34GapIDLcdwsnAZCbwgSUPlpsUSu6oV6rafcxquRRDPDUBnX4mKIUlAJXZOJ2cwQPvlAiwPsR1yJ1S3xLoP+cvdz8GnYaqkQwI0Nbz4guVgFTDr4rze7AeoTHkeb7AEQWIXcmOq8zGVWseLTfq6YWt2hLQ43g52Vq6nun4/BYKY8X4+EC2XDwoXi71hw47XKNfc4XgajCzXxMd3ZpCZCTk91hM6WqbMrpOihFp6qIbeW+gQpSs1pJsMWiZmb2qq3V7pqQ+GWaRoBa72aZnsLmygw7Ze10Aww== X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0822; 31:r9PywmIFzQe266Du9m3OrlRKjFVe5c16s5zktyditElWDr6VLYS9EjMeT8gtrepC0bbZcmkf2Pw+MkgxQ5ER8OI3jg1Q/+9ge98DeSGwssd/i9PhbMVR2+BeFm30ZRjQ/bJk0aPzxkQOSJ8Tqfzhl6HZpbXI2K0FYnhnE3dyDfYXBTe3DnSI4y08OZnj69OVm9duXoZVr7M2b/dJhFOxv/2vZHa1q5KCaVTAkdXnfYlxDSQEAw0B71jdNgL6JOzi9LZAzAOtWCbHSSMQYnz55g==; 20:oq/rdePwkax/gbkDZ3P+xLYQAYR7UaOl8VYYE0RjoFSZJSaqaaoDYH1UfVDLLU20Y6YG2Fr9HLMoA1cf26HjCzNt3nS8EdLRuy/LrJdjFEmFq5gtRYY1pcphqrF98wbHDViAWZ/X+W3cRR/p3L7H3rG3w/7xAJhSTeBica5wrODxSoglLDSud8J77Jp/NdTr20MteLbcU72eY70kHiqwltD8LBsZgK0NNCTXKRkAjwPujzCWS3zSpdW+ZKFAHnHupIcEfmxl0mi/aCukvdG/3ZFLGQzYQpxNxxHRDYOYBWIxpIEthh3Kp2EuOsldDzirLWLbw02i2rt+qeYQn1VIaG/v7CYAwt6RZvEBbJD9jv5ZHAKVkwm2bqcEEYaaiCnf92OH+AOtr8sLXhTuVCYOo87g+r8AdNywS1K0phbt5lQUwgHR5gEkRZTqUtrQSaxAoplupT2mc7qDRwdLOVLfZnDtRnhcIdbU7wAd1qqnEpe9nVm7xEm5IrpxZx8mfIBi 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)(3002001)(10201501046)(6055026)(6041248)(20161123560025)(20161123558025)(20161123555025)(20161123562025)(20161123564025)(6072148); SRVR:SG2PR06MB0822; BCL:0; PCL:0; RULEID:; SRVR:SG2PR06MB0822; X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0822; 4:qitsm/fdD/ZKn86M7WpwvixIZBoTpcWBn6yNPWtJjGXF6GRfFC0VhHs15q8XuspDvEnZA2kVvW+brF8p3OoqlRg4/VG5N5eSlglxO2ZkQU0VpcWdwPWY7BbdORh4DNOvpyipXjgm6DbirY/+mDlhGQhHV43afUvpwypbnGWS2ooJXAD9CgmfhV14DW/NNuwTFVNmk4nq81AAgZZDyCNoV6RUa8yF5hT/zxvHdCUsBYz2fvU121x7PwURUnq2v67xxBfL+xY1nwB/dobq3/PIsFCNi2R8o0umKZpJVfXJcpASrAppKh9KCf7OUvt+YihR0D+pLOn8h9ToU1XK0AZpQhCEGHZZ3l9XNn2qTXy6fjgdhWkbK0yaONUYDAtLu4xwqIt1ue5tIPtp2jgvih/CQBs/o3ih9/KOrUqdG/AHqNplT/qj7OEX4C2VcTVd7VO20GZfvgHkgQicdgOFPx9Nda2IotAuR6Mgttz9AI4So6F/ISRykENILyASvtS8BPgfmewO2XVUFscrNEkHaBFVK8L+uLcSkViTOMpEbF/+j1O0oTh4pJVVlvFBcE55CsYiffKvBmvphqlE337qjI+5uY5bqdKaQFb4OUPBW4e6qbgwiamlzqf+Ke0H/UagwHCs X-Forefront-PRVS: 02543CD7CD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(39850400002)(39410400002)(39840400002)(39860400002)(39450400003)(4001350100001)(5660300001)(2906002)(54356999)(86362001)(50466002)(50986999)(38730400002)(25786009)(81166006)(66066001)(47776003)(42186005)(53416004)(46406003)(54906002)(6116002)(23726003)(189998001)(6486002)(36756003)(33646002)(83506001)(8676002)(3846002)(305945005)(4326008)(53936002)(7736002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR06MB0822; H:morimoto-PC.renesas.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SG2PR06MB0822; 23:fyXc72BW6ROX86Lsogq/T88e3w97qGEZsnN+qLmRc?= =?us-ascii?Q?oc99pqHmrD6WzMlRdqmoBtj7tKeuzmEa5+nIfvmNiDtK+XAjEl+vxTlxjume?= =?us-ascii?Q?1gHvKJOkWDqpHvXFZtiuRvRPKGQSS716MrpGMUgpeazlbbKtui/JVKUZdrOS?= =?us-ascii?Q?J36FhK5hkI1P/bmM+Zowmp9+55OGJv24hNGPyuw7zMFKmX8hgURoobvZgwKE?= =?us-ascii?Q?92EnvPIOZi9Jaai5p9EH8Yst7J1JXUSPpmKY7wity59IKdpk0KoPvPlNAMGL?= =?us-ascii?Q?YpF0lnvfzU9/5dM0+x+YcfdM6p5QNGZmiG+cVlIOmbWChVKWGulEH7tPjosJ?= =?us-ascii?Q?RpG7Vx89UxBSeRWWQUN2zZ1Xmx4WrAsTE+l2ZfBq9KskHhWqTFK0Nt4qgVzk?= =?us-ascii?Q?anP1UHIVlCl8RlNf6jqWAOgmhHXSQcf5H5u0rsWp6fmOx03BFDh+eGyBX8XR?= =?us-ascii?Q?QeKKH7LA+9pmQMd2aDJpP7JiQSDybJXifUtSJ/0CTe7frmwIqagp8rccYrUb?= =?us-ascii?Q?CKC1qm23lK+uKgRq9d0IYQ8oA++/iBBeHKy4P9tAybGe8+g/jDRoGfIwLYKV?= =?us-ascii?Q?ckLAc3Cf9tdxAdFH0gbMT69qf9f9bBVw6RIKvWYF/QYK+XQA903LvIAG3wCU?= =?us-ascii?Q?6td6cP9vdTS2KB7UCd/9Zg1o5WLd4uoBlFn+o0tMgpJXGNx6Q8+toZliB5DS?= =?us-ascii?Q?0QyDsnHFdqxGE4G0r85NjvasCW92Vl/pd1uVkFiZ6rCUweBSZHS80t4lnbWB?= =?us-ascii?Q?7tKXYBPIR/kt3N0tcs/JjmRwKAl4rT32IEhdYGdO4rm3vZD0CSVqXFMV/HS2?= =?us-ascii?Q?NeFCRG7zwQaOlcs0FC0LpA1ZuiL0NW0fQuJsczmYyiXVJJUxKr0qM8Ds/byc?= =?us-ascii?Q?FRv2pVp53/Uue9+GwgZxDiSUyFs8OysmheVbo7VC++MgA56RzICUKGcwI2Sk?= =?us-ascii?Q?yEnoCrBB++R+zSdo7Kqt8OaIvXnIeqHCzepP6YyKQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0822; 6:5FcwRJGtlOC2E+8lLcuKKUvQjvYy5MwObvyrGrrJdqrHU+v82V6JwG0+L6Rg9pa9HYb2uVk0PrBaW9G1ECkZTGD1bguI04qM7mwMP1jiKgXzq6XWF/lKsZnyadYAOLnu34+SCyNd598kucqtZvylFebF5146UROmxj7bXqGc+G27e31/Ha0tfA2K4R+FiH7feruKR2yXXlkwL5prDuQhdnlsO7+QdSLyVxOanNRzC84YTT9FXusHwhfku8BdNZ+Xty6g26OOTTOJcXSj2kdg3+BRc/ReEKv88QT0EAcqBKzjIpD+BDgd4A3n7+QBhChhpsaUE3wLEvTkYgG9VyfEqBKg3QnHeqcaXEXu7kIckHKvAj8+9VB17B8hCNyjU7AbH1fHb4F/EDvNmT3yktBBBORJsCG8fCxcFmuub8QaNNc=; 5:BPHcua0EDMdJinN1/hmY36FS4b972gULf8dXfmqxtdEQx76uF83Wkit8xBO60s29fg+lHI6ozbIYKRaJj418Y8Yho9HtlnQWXl2vsZAadaOlx0ETpfrvdv9KdzGGu8CaqBMDcn9nVdY152UGIEWYDA==; 24:h+xygYeQ48R60+xZil0K/mYJFsh3V5B4bpGJen5ShDXkaU1ww0w2kCWEATzTHF0y3psrB9Od63t2+0oFLxulMvUewFyd+y+cFiqgESgFVy8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0822; 7:Ag10sUCMajSPziAmRYiUTT9b52Jqjz1pTgOhKD5sngz1bdjPSDF0XERfUSyXbrLN/w4K4HAZDl3m8l+g+e5dOvjYRWwpMyIXVK+/80LNBXzi0l3PepF5yD3ege2/GCj/drXJYdQUeqq66xxhjZyzQmwYrOCzNoqV5Wfe5iWWAiG7EqqKEm6cv6GrZL/6KeNI/8JEJmZ2/LvU+lTsnACfvjBct4RYWEp1UsJtyl2c8BR6CVDBzKtHa8hPa34SbqyKNZth//EIQdky9qKCLAYbAx6TAR+pPfZhwBWZmcgJYIvni568XAR6VfDFL0dDvgZrm1DL6eYqKzm8CWHHsqEXFg==; 20:7prCNzXW/xPIIrGOpMoNkStbZ1yefqNGziWIWDmOyBY79+NZmxmKhTOcGV7xAazu8qebeaTy2lBBdToOVOAC6X9MZUidjGYIBSVZJ66lj1USWe6La6opxwvxJYD8YXNaA6lxG16sR17Co43AUdTEfYQOPE1E9IKMATQ8pqVaZw0= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2017 04:22:36.0681 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB0822 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 --- v2 -> v3 - add Reviewed-by from Laurent/Geert - remove unneeded = 0 initialize 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..db41795 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; + u32 high_mem_addr; +#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;