From patchwork Mon Jul 23 17:46: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: 10539823 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12F19112B for ; Mon, 23 Jul 2018 09:46:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0083D285AD for ; Mon, 23 Jul 2018 09:46:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E87FE285B3; Mon, 23 Jul 2018 09:46:30 +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=ham 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 7B6DD285AD for ; Mon, 23 Jul 2018 09:46:30 +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=pQOxKOmKpEU+vJSEwSt1uIkVPK/LvYuXD27SJG07Rqw=; b=uviwOqv+eMOovB +fe8dTVwyRGB4KUS0y9LHWSCnzGhtwr7IsriU9ejjICFfdO7q6uF6YLHC2YkI9GjA+w/fjD3BI7/k dh6/XD2/dQ8tMhfxny0nem8fWU9BNi47famprJEkqW29DjghOFuKoTo/yoIRVluzaUlLXogRoLBEf quaZ8xDBeZYCZFyl34FnXKUnJdQTDLIQd0SWQSVxKKP2G9iaXt2KcL6y/wF8sDA+wYnjbVC1Y2Mjq GKSmlu6N5A64k+ZF6p9eSn7P6IVCAd6CxptMMBxPFFb1V3zhk3wEQ/wTxHDIzz+CE1ZJmJ8K9AM3X oP/QlmamTBBfkvtzSubg==; 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 1fhXQ9-0006GP-DT; Mon, 23 Jul 2018 09:46:25 +0000 Received: from mail-db5eur01on0064.outbound.protection.outlook.com ([104.47.2.64] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fhXPm-0005cV-Al for linux-arm-kernel@lists.infradead.org; Mon, 23 Jul 2018 09:46:06 +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=cYR6WX+u6+d3vL7+0QkiTo0t2BvjvxQpYEVGrjfuRMs=; b=BlqzJF8vzOCso+EA6B2odlpel+HQslk8AkpeGqVIPNuRH9xnqWjFHdmWX00Olc3gMqTygj0Lf1v/aQgmUJF6q8rRVTzsucn1bN46o8KpbArp2oFCnpvwIv6zL0jJTnKu0GgFt1FjGm0VoW947DTKu040MBHxSm2MPqJ2KSyv0yw= 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 VI1PR04MB3232.eurprd04.prod.outlook.com (2603:10a6:802:6::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.21; Mon, 23 Jul 2018 09:45:46 +0000 From: Robin Gong To: vkoul@kernel.org, dan.j.williams@intel.com, s.hauer@pengutronix.de, linux@armlinux.org.uk Subject: [PATCH v3 3/3] dmaengine: imx-sdma: allocate max 20 bds for one transfer Date: Tue, 24 Jul 2018 01:46:12 +0800 Message-Id: <1532367972-29707-4-git-send-email-yibin.gong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532367972-29707-1-git-send-email-yibin.gong@nxp.com> References: <1532367972-29707-1-git-send-email-yibin.gong@nxp.com> MIME-Version: 1.0 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: HK0PR03CA0086.apcprd03.prod.outlook.com (2603:1096:203:72::26) To VI1PR04MB3232.eurprd04.prod.outlook.com (2603:10a6:802:6::29) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 02b5ecce-293b-437b-c0e2-08d5f0811274 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600073)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR04MB3232; X-Microsoft-Exchange-Diagnostics: 1; VI1PR04MB3232; 3:fhZdM9gJOXXep4ktaAyzpxY8SghKgwWhfeoOitYPNeYuUisjSoQhcf3kYD2zeFMTmTrEWIR0N9lMsG0TpUWCIzHZP0X5IwPO0mbmtsfbbB8i03xwXmlzad21LiTBkR2cCg8qnnm0nO8lRvYjzfyfl9uEGNIVgqu/Ut6WTQqreUC6dzsPy9vEggpsIgpdEMWvtvku/Ur9MG5HRoo2lyHLODoXeKFtGUu95DFSGkei+oqhcYjfJakIBsc3RVJs8CAp; 25:DY+DG6fqCFTHhnuXRz4iT5Fc+DEEOKhehdqSJZcWIj2oXw8RymfOn+SIrYkP3sMdZSMUwKqxitwi4LHrTZmk4zjdhZvg+zfWE+DsO02yFP7SrmLRA1ZWbdCmPNOGffsPKe9x9voYRmiVjjB/Y/rr/rfBI9QC3NTEAQ+AcyjelDrB37RErA0WRVTk451qZub2mGjqjd1IYeK8dFg+Fhm8cEYtkysIILOZmXdn40apMufPwqcIEmUbLMWeuVqjKyTQmrcE3tNA++L2/Ilevg7TEksUboIu1zRR4q83ZY8hSjZMc+W3pLFqtfIzOHW95u8QitPKWn2XktSgv4acc2mh2g==; 31:bPp6DembvxEByuiQDig2nFICjh6A4M3FngR9qD+UsUwncecfbDZe45uW7oh14xDOg5WSzbwH03ilnARrsDaDJyazSDFjOzedR2jZac2Aq5NTqd09P/RV6t5TU0qJGy37ju+45J17lz4uZ6zMfojDStYLi1kyJtjKamvfZJaIHnIQvrHkAKDzApaoL7FIxiW3yXVynz0D+qAXh/Th3deav1didXZL4c1uJYob07hfNvA= X-MS-TrafficTypeDiagnostic: VI1PR04MB3232: X-Microsoft-Exchange-Diagnostics: 1; VI1PR04MB3232; 20:ulhu/s5j/Q3EYveHYGeM2+NYZxLXFxF9yjL6bSIrXzs5qX93sye83Mp++KKlO8JE5ls7D1ojNiQwURYPTNrdc8PuXwp2cDCI6uOw0V4GBuzIdmDDlBHgoawTTEC6gUABMzei4s4zIPiq5Oko6yPXzn+1Bxi9rZguwkqf8N/Uw5Qxsb81XQwFoOqnJm1bjfmz279P8qgpzeAMjxd7oEkMiBi4MfCI7HXrPg4n4WJLD1raZBwqPzxjOoY6F/BlTfM8Zgm5MemkfilSFJe6yvVD8yo96eLIzD7xGAuvV+jFDrdFaQDno+vYQyKxqPSpJqmK0I+MTdNFLUtLDsCpjpd7vqWJHhBxXaboFbJhZjAAJfhZoi8qtfk3IzTU8K+j74jxe4miPpQudLzyxusZD3Q3wgYs10p4apXzEXj22CMDThz1mvku+BkbIeQe2DIAbT3M+gGHup4uUU++ovg4P3ss+/jwngJdCG40rhfueqwUTLpvmwWjS42U3fJkizbIrln/; 4:HCROHq7sRPUMjltbI7O27ffrFFrCOOn4aLNs1WT/2ndnn95DCUMDY5yXHIioYQLjSxvMwgIveC6J1yDKmCyz0pn5F6Qn1c8ujokfe5JW80uCbHO4dp5sUraDfGXZx/JU1xgoJvIVzq/EnbqWAKX/2Df9fsTr+/ym0rDDWyZjg4hEp4HnvRGMXF9yRo2ats5BuIX2NsMT3eXat574vcXhCgJtb6I4d15/qYKK67LwbOvt8qRmJK0b2XoTeTQ1rzg/u/EC5yX/gAGaqNCbzwpB4bD5FkZWtVgKlTmtmIrxWgcWmp1DqwOWSVU2cbei24w8 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)(3002001)(10201501046)(93006095)(93001095)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:VI1PR04MB3232; BCL:0; PCL:0; RULEID:; SRVR:VI1PR04MB3232; X-Forefront-PRVS: 0742443479 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(366004)(346002)(136003)(39860400002)(376002)(199004)(189003)(16526019)(6116002)(3846002)(956004)(8936002)(66066001)(47776003)(53936002)(478600001)(305945005)(26005)(50466002)(48376002)(476003)(2616005)(6512007)(25786009)(7736002)(4326008)(11346002)(6506007)(386003)(14444005)(36756003)(50226002)(106356001)(97736004)(446003)(5660300001)(68736007)(6666003)(105586002)(2906002)(486006)(81166006)(8676002)(52116002)(81156014)(186003)(86362001)(51416003)(16586007)(6486002)(316002)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB3232; 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; VI1PR04MB3232; 23:f9mYoH6F34CQFEt0o0BF3pKiBOtZLfutgZBlO7eaG?= In3e9Qif2JiHct9KVMvLtiK2LGrEshVrA/cu1GZrBAQJZpE+LfVZIHQz2xD3FeVAYjUUeVzeZsvnt7dpy1XlNs3gvndm/iYPp2kkAXRYU0BGBFr7BoBxIB6vAtmclTHj5rc5tq/3+OGGmtAksjw7WVC6TdHsaVA6KkfHCmXaQw1FzColjDWbRZfGC46hfUw3jeF0owsKcMqM5GwHeUmQG6UeV2yVnaih8YDTV5c+vd+/gdUb+bnBzEeWpsCdUzjL/FPauowr37CBvJOvDxTKFchK2XBMWLsAn4fRU3r11PuPVicf0f7earQhkunmAabf0BOOQE2qTj8S5G6yT89A/UeCSgYglctFrLdM6BWg3JVXH/KvsQJ4YeERSRKLOllKZCj2mO3LljSx4AN6vAZoutIoHOgmk5HPcUFryQYGrICNrF3lbHp/RbDacMb+9StGpldxNUWG6Wrjc05hiPsOVFamQBcKM4IiLUedJbca29uDXKDrk5UAs9+z+PBWMneOCel261mMBSFEfsYkL/rWjveMeDtc7GK5mgYfSva6E0k1EnLgQuPH/Or4jEKN63R8zez4GussPuqY4xoYTDqN3zHmjF/4iF/Q0YWytAQ1b2NeLLNhxad8cOp1GzX5X4iAbHAXLgLVNlc/LkI6WouZY7RGwQuCtgIjRbbBoQSMQkl1OKo8fLdXxOOz3cE+SDq8v+pzcnTZAZoqFBqpdtlyJIN2ATLbx+eoKx++yVIrCJPQ62VNVLo1odo4PhAxuuHCuBfdH/NnVrJEAAJ4Sw9ven2HArevWx/SeGHWPJG4rIzdD0qilOGNg39Mh+mw4EtCACXkaPpsJeU7Cmk6rCWKtxOvKd/YlMMcSVWuQv9EkXLOUzlTyzX9YUd2EsK3O52NYPa1BuRyqt92zJEVImh5iUjC7JbdUQx+Bpbh4D+XrYZ6l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+81ioWggyw==; 5:Auo8fmFTVQHaVOl5anYZKQ5gIiEMgYWCmG6NGUlTzgNGvOMniVuyq4CWF3DwqM4/lkJ5n1Nr/HLVTYAmXmJcvMVg6O2JcSDCdDo1A+poI7Z7k/g4LxvFg+JgM/2Q6a2ALkmqU3ri6apKqNkSLnDVXX+0v/i5nkm4ItwnBnhP2Ks=; 7:DkGpiZljAioVXCmklDDLA8fVITozE6K2K6RmY94NF3lR7HAu0hxR1U+saLOWDx3/3wwwjFJbVBdiC9Mx5yvQtCmw2hz8ZyaCO/wk59zWKYn2OskRVRdEcRpuhun+vLt3ym0x7jiOBsnRkxb3OEzOm7RA/TtB6mOAKbteTdo669kwg7t2eGaSXL5ZdOfMZTsvzLEpZHeGNaP+gtaHR2SXJqWBlNH0nyMujhfyBRG1uIcJYW+L2kvawl0rHh2RT/9o SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2018 09:45:46.4662 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02b5ecce-293b-437b-c0e2-08d5f0811274 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3232 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180723_024602_763184_502C005A X-CRM114-Status: GOOD ( 15.03 ) 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 If multi-bds used in one transfer, all bds should be consisten memory.To easily follow it, enlarge the dma pool size into 20 bds, and it will report error if the number of bds is over than 20. For dmatest, the max count for single transfer is NUM_BD * SDMA_BD_MAX_CNT = 20 * 65535 = ~1.28MB. Signed-off-by: Robin Gong --- drivers/dma/imx-sdma.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index b4ec2d2..5973489 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -298,6 +298,15 @@ struct sdma_context_data { u32 scratch7; } __attribute__ ((packed)); +/* + * All bds in one transfer should be consitent on SDMA. To easily follow it,just + * set the dma pool size as the enough bds. For example, in dmatest case, the + * max 20 bds means the max for single transfer is NUM_BD * SDMA_BD_MAX_CNT = 20 + * * 65535 = ~1.28MB. 20 bds supposed to be enough basically.If it's still not + * enough in some specific cases, enlarge it here.Warning message would also + * appear if the bd numbers is over than 20. + */ +#define NUM_BD 20 struct sdma_engine; @@ -1273,7 +1282,7 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan) goto disable_clk_ahb; sdmac->bd_pool = dma_pool_create("bd_pool", chan->device->dev, - sizeof(struct sdma_buffer_descriptor), + NUM_BD * sizeof(struct sdma_buffer_descriptor), 32, 0); return 0; @@ -1314,6 +1323,12 @@ static struct sdma_desc *sdma_transfer_init(struct sdma_channel *sdmac, { struct sdma_desc *desc; + if (bds > NUM_BD) { + dev_err(sdmac->sdma->dev, "%d bds exceed the max %d\n", + bds, NUM_BD); + goto err_out; + } + desc = kzalloc((sizeof(*desc)), GFP_NOWAIT); if (!desc) goto err_out;