From patchwork Tue Jul 10 16:23:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Gong X-Patchwork-Id: 10516503 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 0BBF8600CA for ; Tue, 10 Jul 2018 08:25:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED4E128B68 for ; Tue, 10 Jul 2018 08:25:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E107D28C71; Tue, 10 Jul 2018 08:25: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=-1.0 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DATE_IN_FUTURE_06_12,DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI 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 7CA0E28B68 for ; Tue, 10 Jul 2018 08:25:19 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=frjSdsNxk7kdx/sFbYClpe1ULtkIIQA30PN2w7xtZ8g=; b=FkfXwsAwugemIn cDY6XibAtUTtRT7iulvu9nXKcXJ3rTmSyTvw4t8Y5TCT134Tg3LCXIN4G2hbUak+5bbli4/jYmb1W rZsp4agX3tixo9Ad/9EsDpomETm7hRxAs5qzcm/LeQSermhdGfRbd3msuIQtZQunIgsfaaTSyhirp njNvJY1iTPzg6bsWV861M3SRi5lPHB97Tw3ZPVJETIrPgUmmz2Ii+rXwZb9E5AyZ3ezeSvCcPus/T vEDMpK6BidcrTn3Pt9kiqfn9MuGBA9FWMd52aJhb28FTXtt16CaW0Y2K48sTlXmP5Cy1Kv6FBay9N UHgSyAGAdx+crnO+Vd4w==; 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 1fcnxQ-0008Ic-9n; Tue, 10 Jul 2018 08:25:12 +0000 Received: from mail-eopbgr30062.outbound.protection.outlook.com ([40.107.3.62] helo=EUR03-AM5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fcnwq-0007Ng-Hb for linux-arm-kernel@lists.infradead.org; Tue, 10 Jul 2018 08:24:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D2G4lS+cIP2zzUnXTE7aobSTRc5UwCTnOxYI95xY1ec=; b=dC9lO0QqfFz8xlORS7ZkNRYVrYNWINrMAL4/3IR1EEPJi+D5faXfiZq76VEeVBuLuvq3LqME5K0CRI43g1Fb78ni9BQIS7+BaaiYXS3i4c9z4P9ba7yrIwoECNfVOYuDKD6XlxE8zw2UvWluxrj5fDjhSp+zmZQLXZQcSEyHqcQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=yibin.gong@nxp.com; Received: from robin-OptiPlex-790.ap.freescale.net (119.31.174.66) by DB6PR04MB3221.eurprd04.prod.outlook.com (2603:10a6:6:6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.930.21; Tue, 10 Jul 2018 08:24:25 +0000 From: Robin Gong To: vkoul@kernel.org, dan.j.williams@intel.com, shawnguo@kernel.org, s.hauer@pengutronix.de, fabio.estevam@nxp.com, linux@armlinux.org.uk Subject: [PATCH v1 3/4] dmaengine: imx-sdma: support dmatest Date: Wed, 11 Jul 2018 00:23:12 +0800 Message-Id: <1531239793-11781-4-git-send-email-yibin.gong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531239793-11781-1-git-send-email-yibin.gong@nxp.com> References: <1531239793-11781-1-git-send-email-yibin.gong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK0P153CA0008.APCP153.PROD.OUTLOOK.COM (2603:1096:203:18::20) To DB6PR04MB3221.eurprd04.prod.outlook.com (2603:10a6:6:6::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 28e87c44-682d-43a0-e51c-08d5e63e8e9b X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(48565401081)(2017052603328)(7153060)(7193020); SRVR:DB6PR04MB3221; X-Microsoft-Exchange-Diagnostics: 1; DB6PR04MB3221; 3:rOA1NZVM0qhhsWCVqSNdsqphfIJeVDrDOI2Hzf2t/CPnPuY6TnS2MylTYxQMO78ZlqJz+gLve7m24OxCWhgXvRmxilnB7bpcK/MDgT5GtAnUf4deXybbMz3oXU3IreGNSfJSQwOgsGjWJj5V2+g92lZVF/KozbWkYDKeOW7Fa77NYDjp+NY+dnilEgBXHaI+Qxd01qNZQ0hhmVq8feWS/xL5johNgnxz1lZS8L9LRSIP4oWMfrEqU3NaBIjJz04j; 25:rAZ4KTyXg5BUL2nj28QHxzcA4amE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0n8ypN8icTqUG96neSLhbr3i7U5ejkg62F2zfstvvd0iyahT7i; 4:dx7LNrh/ZHED1gdBleg4nDUK83BEcmE1N7iu2mOHsBRmMgo0VAOPSHTtwB7tqxyhdOvJfppOzwHjheSGG00PoPZ9SJiX60+TFk8u462wMc7RwzhhzHB1pGvCAE4qrURi5Rbf3pcu+YZsFf8vxscnw2vdsDvtVNIYirWLtJY7gy4wEd2NwmMDQJsHlBIc1N5k0Q6mO4HlN/hcYBVWF9AJpN7hwc9M7yqx3zQMu+vH9BFxK+FpUdZuOxTVNqXAfcCLBxh2/EH+YFIHruyMmTC5JTMsUteuFyPZiAji8GeSrZjVYsFp8FuzbKHJ/BxxxzMP X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231311)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:DB6PR04MB3221; BCL:0; PCL:0; RULEID:; SRVR:DB6PR04MB3221; X-Forefront-PRVS: 0729050452 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(366004)(396003)(376002)(346002)(136003)(199004)(189003)(53936002)(36756003)(5660300001)(50466002)(50226002)(6116002)(6666003)(106356001)(97736004)(8936002)(52116002)(76176011)(51416003)(3846002)(6486002)(14444005)(47776003)(68736007)(478600001)(86362001)(66066001)(25786009)(48376002)(4326008)(105586002)(2906002)(6512007)(476003)(2616005)(486006)(446003)(956004)(11346002)(305945005)(8676002)(7736002)(26005)(81156014)(16526019)(186003)(316002)(81166006)(6506007)(386003)(16586007); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR04MB3221; H:robin-OptiPlex-790.ap.freescale.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB6PR04MB3221; 23:7/0qZE4yImTEz4yHRY6OTLUXNCyDHQmF50BOYfFyE?= =?us-ascii?Q?xVx186G1XDarAKMC1dKQ8l2aGUm9B2zU87IlCXOtFVM5R3tvc9qCHSL3Pt3q?= =?us-ascii?Q?SFlSiRKdYApon4DBl95cEiipJpXP/DDV4i5nSgpoIw7BHCl8znyVxOYNaKAw?= =?us-ascii?Q?CPtuMnrqSwd9YsUKLphQR0KJVgCbxJ9CyrNo8+9mxbVvTQOxLEWdt8+r+ANC?= =?us-ascii?Q?/9jjrz+SLC/dXHm2Ct2GhHy2jCo3LcPicVQ5z0CZ2zNhaImHkeTYleueLuGN?= =?us-ascii?Q?czUdxtkQ6Y1An2YEWX/50UtrmpLxcijsPEohguCspAL6cngy4SYk0MvVwaEu?= =?us-ascii?Q?9ahlDJZp9wKkBHZwHm7oADe6tp95sAwRMWkDVed83ds2o90cyn/tJbZBta8G?= =?us-ascii?Q?1bxRtzL4Q1OjQ5sZGscEn1scp3NrjWTbHjnHjhmxIRB5jL2z6OTSN3VVin8C?= =?us-ascii?Q?qW8rZpdy8PmWdxp9EbyCv15iABWOHrZxqCXBKei0OkyPpGT/JSRhT4wXrsdE?= =?us-ascii?Q?IPfNXfEOQxs9vL/UWR7pq69Uav402eAVNPFhBlBDH/liTpqB8cdfbk7Ua0l7?= =?us-ascii?Q?+p+m2DIsJzdEeEpD3gM9MuRKcrgVm3whns06kU5MvPQbEwSu+smY7hmbiVEI?= =?us-ascii?Q?UkoZUdMZhk/ku2g4zGA6kaLmSiIaiNHhAjTDa8ii2JG8dMHccfdXRk34kD2r?= =?us-ascii?Q?b32IBxxuRypngLWP7G4SmXPKRu1AT6SOzip3ZCC3ki4CpS58TNDh70/pKnZQ?= =?us-asc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HkPyQr+i34tsG04zPfixlN3o1VAUwN9yITQ3gOonjGaKiqUqk7t9sEGBImI/h8BadAfqTN9DO535pjyjhhXs5Fzt6jT7cOuEeD0DFTaBNktfkyrnRtEAu5MOzpP+iKkPSBxNOsV/d9mF1pzBzK31XarBDGGnqvQ24J0lKxqEGxTANoNOb+/j58KVwujYDQXuj0+R6A5cEC0P8+c3nOF/abEz7p8KqNRECX4lvocVI+LHNnr+djzTSh4YXElUEwGju1MxP07MZImXKHXP96IUwegWN1rOCoOxSj9z85UoW7W7Flzx1+ESfZI86PDB6+krXQ==; 5:pb7zJoO4nbNrv5pGrcrDco0F5YnTcGdhrZjbc/Z2Kf1JbPWJjvJMFDR5loLUAr9bb2l7XP+5XkODJikFR+gy+niKoJ1xM/U8IeQ/om622rNPTzMfKULlrnSL9t1NKsT1Zxpn8tTuu3a5lx8UFh+lbDuMwCz0oT1NI8ibTMzY2n4=; 24:XkyCMFz4TZ8WCVg7U3nXr+e292fUAkanp447knu24mpFi9LcHsBL0fpP6XuET8idcOGzfkDbmZ3URLJHCxY9g9Ns7nKWZo/JRWot0OOItO8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB6PR04MB3221; 7:5LikvaEmQuW1Uc9C2wuHJIP/MaQKeRJ2Tpzr9E2991lNWQ6Kahjzqx2v8c2a/LM+5X+KbuLD/b/wpttxSM0PohyGUowfQVOZ4ZUQJ5H1Q8hJ0g4jaJdmRTDkjYCKaDWYqhncXl9Zig9tmeywIdcT6pNC4DPvtBDQQ17QHD18KqOAZOEkN5wFpNyspgA3UfsPfsZPiltx6z9GA4toJaAEC5lU6fTxOkGZBR6kfiHZ+e0iCVdDclMNmxH5oKDMhn53 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2018 08:24:25.9638 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 28e87c44-682d-43a0-e51c-08d5e63e8e9b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR04MB3221 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180710_012437_011764_D717871B X-CRM114-Status: GOOD ( 14.31 ) 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: dmaengine@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org 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 dmatest(memcpy) will never call dmaengine_slave_config before prep, so jobs in dmaengine_slave_config need to be moved into somewhere before device_prep_dma_memcpy. Besides, dmatest never setup chan ->private as other common case like uart/audio/spi will always setup chan->private. Here check it to judge if it's dmatest case and do jobs in slave_config. Signed-off-by: Robin Gong --- drivers/dma/imx-sdma.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index ed2267d..48f3749 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -1222,10 +1222,36 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan) { struct sdma_channel *sdmac = to_sdma_chan(chan); struct imx_dma_data *data = chan->private; + struct imx_dma_data default_data; int prio, ret; - if (!data) - return -EINVAL; + ret = clk_enable(sdmac->sdma->clk_ipg); + if (ret) + return ret; + ret = clk_enable(sdmac->sdma->clk_ahb); + if (ret) + goto disable_clk_ipg; + /* + * dmatest(memcpy) will never call dmaengine_slave_config before prep, + * so jobs in dmaengine_slave_config need to be moved into somewhere + * before device_prep_dma_memcpy. Besides, dmatest never setup chan + * ->private as other common cases like uart/audio/spi will setup + * chan->private always. Here check it to judge if it's dmatest case + * and do jobs in slave_config. + */ + if (!data) { + dev_warn(sdmac->sdma->dev, "dmatest is running?\n"); + sdmac->word_size = sdmac->sdma->dma_device.copy_align; + default_data.priority = 2; + default_data.peripheral_type = IMX_DMATYPE_MEMORY; + default_data.dma_request = 0; + default_data.dma_request2 = 0; + data = &default_data; + + sdma_config_ownership(sdmac, false, true, false); + sdma_get_pc(sdmac, IMX_DMATYPE_MEMORY); + sdma_load_context(sdmac); + } switch (data->priority) { case DMA_PRIO_HIGH: @@ -1244,13 +1270,6 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan) sdmac->event_id0 = data->dma_request; sdmac->event_id1 = data->dma_request2; - ret = clk_enable(sdmac->sdma->clk_ipg); - if (ret) - return ret; - ret = clk_enable(sdmac->sdma->clk_ahb); - if (ret) - goto disable_clk_ipg; - ret = sdma_set_channel_priority(sdmac, prio); if (ret) goto disable_clk_ahb;